Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Cole Hecht committed Jun 9, 2018
1 parent 3f8f186 commit d28049e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
12 changes: 2 additions & 10 deletions server.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package srp

import (
"encoding/base64"
"errors"
"fmt"
)

// Handshake -
Expand Down Expand Up @@ -34,27 +32,21 @@ func Handshake(A, v []byte) ([]byte, []byte, error) {
}

// Calculate the SRP-6a version of the multiplier parameter "k"
// TODO: Pad g
k := Hash(Pad(dGrp.N, 512), Pad(dGrp.g, 512))
fmt.Println("srp_k: " + base64.StdEncoding.EncodeToString(k))
k := Hash(dGrp.pad(dGrp.N), dGrp.pad(dGrp.g))

// Compute a value "B" based on "b"
// B = (v + g^b) % N
B := dGrp.add(dGrp.mul(k, v), dGrp.exp(dGrp.g, b))

// Calculate "u"
// TODO: Pad A and B
u := Hash(Pad(A, 512), Pad(B, 512))
fmt.Println("srp_u: " + base64.StdEncoding.EncodeToString(u))
u := Hash(dGrp.pad(A), dGrp.pad(B))

// Compute the pseudo-session key, "S"
// S = (Av^u) ^ b
S := dGrp.exp(dGrp.mul(A, dGrp.exp(v, u)), b)
fmt.Println("srp_S: " + base64.StdEncoding.EncodeToString(S))

// The actual session key is the hash of the pseudo-session key "S"
K := Hash(S)
fmt.Println("srp_K: " + base64.StdEncoding.EncodeToString(K))

return B, K, nil
}
2 changes: 1 addition & 1 deletion srp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"fmt"
"testing"

"github.com/voynic/srp"
"gitlab.com/voynic/srp"
)

func TestFullHandshake(t *testing.T) {
Expand Down

0 comments on commit d28049e

Please sign in to comment.