summaryrefslogtreecommitdiffstats
path: root/lib/srp.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2022-04-16 20:14:29 -0400
committersiddharth <s@ricketyspace.net>2022-04-16 20:14:29 -0400
commit1362ed8d4d68c10f20e67027482826eea3214fb3 (patch)
treec77146b4b8a6fe1d96e20b9d10036e7eab3bac18 /lib/srp.go
parent8e1700059a73f7090528194fab0b36751d6d1693 (diff)
lib: add srp mac verification functions
Diffstat (limited to 'lib/srp.go')
-rw-r--r--lib/srp.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/srp.go b/lib/srp.go
index a7f14e1..9fdd594 100644
--- a/lib/srp.go
+++ b/lib/srp.go
@@ -223,6 +223,10 @@ func (u *SRPUser) ComputeSessionKey(a *big.Int) error {
return nil
}
+func (u *SRPUser) SessionKeyMacVerify(mac []byte) bool {
+ return u.h.MacVerify(u.salt, u.sk, mac)
+}
+
func NewSRPClientSession(n, g, k, ident string) (*SRPClientSession, error) {
var ok bool
@@ -347,3 +351,13 @@ func (s *SRPClientSession) ComputeSessionKey(salt []byte,
return nil
}
+
+func (s *SRPClientSession) SessionKeyMac(salt []byte) ([]byte, error) {
+ if len(s.sk) < 1 {
+ return nil, CPError{"sk is invalid"}
+ }
+ if len(salt) < 1 {
+ return nil, CPError{"salt is invalid"}
+ }
+ return s.h.Mac(salt, s.sk), nil
+}