예제 #1
0
def do_init(email, password_b64, db_server, do_network, scrypt_server):
    UK_b64 = b64encode(os.urandom(2*KEYLEN))
    print "UK created:", UK_b64

    keys = build_PWK(email, password_b64, scrypt_server, do_network)
    PWK_b64, MAC_b64, SRPpw_b64 = keys
    SRPv_b64 = do_SRP_setup(SRPpw_b64, email)
    MAGIC_SEND_SAFELY(db_server, [email, SRPv_b64], do_network)

    WUK_b64 = encrypt_and_mac(PWK_b64, MAC_b64, UK_b64)
    SRPsession = do_SRP(db_server, email, SRPpw_b64, do_network)
    resp = do_request(SRPsession, ["set", WUK_b64], do_network, db_server)
    if resp[0] != "ok":
        raise Oops("server reject")
    return UK_b64
예제 #2
0
def do_change(email, old_password_b64, new_password_b64, db_server, do_network,
              scrypt_server):
    # read the old password, compute the new secrets, send a change request
    UK_b64, old_SRPpw_b64 = read(email, old_password_b64, db_server, do_network,
                                 scrypt_server)

    keys = build_PWK(email, new_password_b64, scrypt_server, do_network)
    (new_PWK_b64, new_MAC_b64, new_SRPpw_b64) = keys
    new_SRPv_b64 = do_SRP_setup(new_SRPpw_b64, email)
    new_WUK_b64 = encrypt_and_mac(new_PWK_b64, new_MAC_b64, UK_b64)

    SRPsession = do_SRP(db_server, email, old_SRPpw_b64, do_network)
    resp = do_request(SRPsession,
                      ["change", new_SRPv_b64, new_WUK_b64],
                      do_network, db_server)
    if resp[0] != "ok":
        raise Oops("server reject")