@aa = aa
@b = bigrand(32).hex
# B = g^b + k v (mod N)
- @bb = (modpow(GENERATOR, @b, BIG_PRIME_N) + multiplier * verifier) % BIG_PRIME_N
+ @bb = (modpow(GENERATOR, @b) + multiplier * verifier) % BIG_PRIME_N
end
def u
# do not cache this - it's secret and someone might store the
# session in a CookieStore
def secret(verifier)
- base = (modpow(verifier, u, BIG_PRIME_N) * aa) % BIG_PRIME_N
- modpow(base, @b, BIG_PRIME_N)
+ base = (modpow(verifier, u) * aa) % BIG_PRIME_N
+ modpow(base, @b)
end
def m1(verifier)
def authenticate(server, username, password)
x = calculate_x(username, password)
a = bigrand(32).hex
- aa = modpow(GENERATOR, a, BIG_PRIME_N) # A = g^a (mod N)
+ aa = modpow(GENERATOR, a) # A = g^a (mod N)
bb = server.handshake(username, aa)
u = calculate_u(aa, bb)
client_s = calculate_client_s(x, a, bb, u)
protected
def calculate_verifier
x = calculate_x
- @verifier = modpow(GENERATOR, x, BIG_PRIME_N)
+ @verifier = modpow(GENERATOR, x)
@verifier
end
def calculate_client_s(x, a, bb, u)
base = bb
base += BIG_PRIME_N * @multiplier
- base -= modpow(GENERATOR, x, BIG_PRIME_N) * @multiplier
+ base -= modpow(GENERATOR, x) * @multiplier
base = base % BIG_PRIME_N
- modpow(base, x * u + a, BIG_PRIME_N)
+ modpow(base, x * u + a)
end
end
end