summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsiddharth ravikumar <s@ricketyspace.net>2022-07-23 10:26:45 -0400
committersiddharth ravikumar <s@ricketyspace.net>2022-07-23 10:26:45 -0400
commitf380717da9eb772488ff18e2327dbef35fbe3265 (patch)
tree4b18c8d694b289046ce493617bcfdb93f5780bca
parenta1ef92cc8c029b8380d0b87075d2a4472debca6a (diff)
lib: `SRPUser`: add ComputeVerifier
Move verifier computation to its own function.
-rw-r--r--lib/srp.go17
1 files changed, 11 insertions, 6 deletions
diff --git a/lib/srp.go b/lib/srp.go
index 21df3bb..37430b4 100644
--- a/lib/srp.go
+++ b/lib/srp.go
@@ -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() {