summaryrefslogtreecommitdiffstats
path: root/lib/srp.go
diff options
context:
space:
mode:
authorsiddharth <s@ricketyspace.net>2022-04-30 21:13:20 -0400
committersiddharth <s@ricketyspace.net>2022-04-30 21:13:20 -0400
commit2d00d9eb360e887d8d71179f150feba0237449f0 (patch)
treeca1a2bd903065b623ac3554947a299142efd347b /lib/srp.go
parent1362ed8d4d68c10f20e67027482826eea3214fb3 (diff)
lib: add SRPServer.RegisterUser
Diffstat (limited to 'lib/srp.go')
-rw-r--r--lib/srp.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/srp.go b/lib/srp.go
index 9fdd594..cdecc4f 100644
--- a/lib/srp.go
+++ b/lib/srp.go
@@ -30,7 +30,7 @@ import "math/big"
// SRP Server.
type SRPServer struct {
- users []SRPUser
+ users []*SRPUser
}
// Registered user on the SRP server.
@@ -90,6 +90,16 @@ type SRPClientSession struct {
sk []byte
}
+func (server *SRPServer) RegisterUser(user *SRPUser) error {
+ for _, u := range server.users {
+ if u.ident == user.ident {
+ return CPError{"user already registered"}
+ }
+ }
+ server.users = append(server.users, user)
+ return nil
+}
+
func NewSRPUser(n, g, k, ident, pass string) (*SRPUser, error) {
var err error
var ok bool