diff options
author | siddharth ravikumar <s@ricketyspace.net> | 2022-07-23 10:26:45 -0400 |
---|---|---|
committer | siddharth ravikumar <s@ricketyspace.net> | 2022-07-23 10:26:45 -0400 |
commit | f380717da9eb772488ff18e2327dbef35fbe3265 (patch) | |
tree | 4b18c8d694b289046ce493617bcfdb93f5780bca /lib | |
parent | a1ef92cc8c029b8380d0b87075d2a4472debca6a (diff) |
lib: `SRPUser`: add ComputeVerifier
Move verifier computation to its own function.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/srp.go | 17 |
1 files changed, 11 insertions, 6 deletions
@@ -124,17 +124,22 @@ func NewSRPUser(n, g, k, ident, pass string) (*SRPUser, error) { return nil, err } + // Compute verifier. + user.ComputeVerifier(pass) + + return user, nil +} + +func (u *SRPUser) ComputeVerifier(pass string) { // Generate private key `x` from salt+pass m := make([]byte, 0) - copy(m, user.salt) + copy(m, u.salt) m = append(m, StrToBytes(pass)...) - user.h.Message(m) - user.x.SetBytes(user.h.Hash()) + u.h.Message(m) + u.x.SetBytes(u.h.Hash()) // Generate password verifier `v` - user.v.Exp(user.g, user.x, user.n) - - return user, nil + u.v.Exp(u.g, u.x, u.n) } func (u *SRPUser) EphemeralKeyGen() { |