diff options
Diffstat (limited to 'lib/srp.go')
-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() { |