summaryrefslogtreecommitdiffstats
path: root/lib/srp_test.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2022-04-09 20:26:52 -0400
committersiddharth <s@ricketyspace.net>2022-04-09 20:26:52 -0400
commitafc801186f2591555eb43c0138ac1951da02cea4 (patch)
tree54bd9e50c1a7e7024935dd7b8dd1e1a122c810a9 /lib/srp_test.go
parent33423e8e822165045f0506101763ff527cce9d22 (diff)
lib: add NewSRPClientSession
Diffstat (limited to 'lib/srp_test.go')
-rw-r--r--lib/srp_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/srp_test.go b/lib/srp_test.go
index d7e3b0d..a31e658 100644
--- a/lib/srp_test.go
+++ b/lib/srp_test.go
@@ -67,3 +67,52 @@ func TestNewSRPUser(t *testing.T) {
return
}
}
+
+func TestNewSRPClientSession(t *testing.T) {
+ n := StripSpaceChars(
+ `ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024
+ e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd
+ 3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec
+ 6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f
+ 24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361
+ c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552
+ bb9ed529077096966d670c354e4abc9804f1746c08ca237327fff
+ fffffffffffff`)
+ g := "2"
+ k := "3"
+ ident := "s@ricketyspace.net"
+ session, err := NewSRPClientSession(n, g, k, ident)
+ if err != nil {
+ t.Errorf("Error: %v\n", err)
+ return
+ }
+
+ // Check n.
+ bigN, _ := new(big.Int).SetString(StripSpaceChars(n), 16)
+ if session.n.Cmp(bigN) != 0 {
+ t.Error("Error: n not set correctly\n")
+ return
+ }
+ // Check g.
+ bigG, _ := new(big.Int).SetString(StripSpaceChars(g), 16)
+ if session.g.Cmp(bigG) != 0 {
+ t.Error("Error: g not set correctly\n")
+ return
+ }
+ // Check k.
+ bigK, _ := new(big.Int).SetString(StripSpaceChars(k), 16)
+ if session.k.Cmp(bigK) != 0 {
+ t.Error("Error: k not set correctly\n")
+ return
+ }
+ // Check ident.
+ if session.ident != ident {
+ t.Error("Error: user not set correctly\n")
+ return
+ }
+ // Check a.
+ if session.a.Cmp(big.NewInt(1)) < 0 {
+ t.Error("Error: a not set correctly\n")
+ return
+ }
+}