1. Taru Karttunen
  2. go-extra

Source

go-extra / crypto / srp /

Filename Size Date modified Message
..
1.1 KB
Import
129 B
Updated Makefiles
697 B
Import
5.9 KB
srp: SToKey and CalculateM2
This module implements the Secure Remote Password (RFC 2945) mechanism.

ph   := pbkdf2.HashPassword("mypass")
// Client
a    := srp.NewRandom()
A    := srp.ClientA(a)
// Send C->S: (username,A)
// Server
srp.MustBeValidParameter(A)
b    := srp.NewRandom()
B    := srp.ServerB(ph.Hash, b)
// Send S->C: (B,salt), B MUST be sent ONLY after A is received
// Client
srp.MustBeValidParameter(B)
cs   := srp.ClientS(a, B, ph.Hash)
cm   := srp.CalculateM(A,B,ph.Salt,cs)
// C->S: M
// Server
ss   := srp.ServerS(A, b, B, ph.Hash)
sm   := srp.CalculateM(A,B,ph.Salt,ss)
if !bytes.equal(cm,sm) { panic("Wrong client!") }
// cs and ss form the shared key
fmt.Printf("c=%x\ns=%x\n\n",cs.Bytes(),ss.Bytes())