module SecureRemotePassword::Helpers

Direct including types

Defined in:

secure-remote-password/helpers.cr

Instance Method Summary

Instance Method Detail

def calculate_A(a : BigInt) : BigInt #

Calculate the client's public value A = g^a % N where param 'a' is a random number at least 256 bits in length


[View source]
def calculate_B(b : BigInt, v : BigInt) : BigInt #

Calculate the server's public value B B = g^b + k v (mod N)


[View source]
def calculate_client_S(arg_B : BigInt, salt : String, uu : BigInt, a : BigInt) : BigInt #

Client secret S = (B - (k * g^x)) ^ (a + (u * x)) % N


[View source]
def calculate_h_amk(xaa, xmm, xkk) #

H(A, M, K) for final client validation


[View source]
def calculate_k : BigInt #

Calculate k = H(N || g), which is used throughout various SRP calculations.


[View source]
def calculate_M(username : String, salt : String, xaa, xbb, xkk) : BigInt #

M = H(H(N) xor H(g), H(I), s, A, B, K)

NOTE : overwrite what is hashed here if your implementation differs


[View source]
def calculate_server_S(arg_A : BigInt, v : BigInt, u : BigInt, arg_b : BigInt) : BigInt #

Server secret S = (A * v^u) ^ b % N


[View source]
def calculate_u(arg_A, arg_B) : BigInt #

Calculate u = SHA1(PAD(A) | PAD(B)), which serves to prevent an attacker who learns a user's verifier from being able to authenticate as that user.


[View source]
def calculate_v(username : String, password : String, salt : String) : BigInt #

verifier version


[View source]
def calculate_v(salt : String) : BigInt #

Calculate v = g^x % N


[View source]
def calculate_x(salt : String, username : String = @username, password : String = @password) #

Calculate x = SHA1(s | SHA1(I | ":" | P))


[View source]
def hash(h : Bytes | String) : BigInt #

[View source]
def hash_hex(bytes : Bytes) : String #

[View source]
def hash_hex(h : String) : String #

[View source]
def hash_string(string : String) : String #

[View source]
def initialization_value(group : Int) : Tuple(BigInt, BigInt) #

[View source]
def modpow(a : BigInt, n : BigInt, m : BigInt) : BigInt #

a^n (mod m)


[View source]
def no_padding_hash(*a) : BigInt #

[View source]
def padded_hash(*parts) : BigInt #

[View source]
def random_big_int(bytes : Int) : BigInt #

[View source]
def random_hex(bytes : Int) : String #

[View source]