Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions internal/rfc2945/test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Package rfc2945 provides test vectors documented in
// RFC 2945.
//
//nolint:gochecknoglobals
package rfc2945

import "github.com/bodgit/srp/internal/util"

// RFC 2945 SRP Test Vectors.
var (
M1 = util.Must(util.BytesFromHexString(`
3F3BC671 69EA7130 2599CF1B 0F5D408B 7B65D347`))
M2 = util.Must(util.BytesFromHexString(`
9CAB3C57 5A11DE37 D3AC1421 A9F00923 6A48EB55`))
)
21 changes: 21 additions & 0 deletions srp_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"math/big"
"testing"

"github.com/bodgit/srp/internal/rfc2945"
"github.com/bodgit/srp/internal/rfc5054"
"github.com/bodgit/srp/internal/util"
"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -145,3 +146,23 @@ func TestSRP_computeServerS(t *testing.T) {
new(big.Int).SetBytes(rfc5054.U),
new(big.Int).SetBytes(rfc5054.V)).Bytes())
}

func TestSRP_computeM1(t *testing.T) {
t.Parallel()

assert.Equal(t, rfc2945.M1, newSRP().computeM1(
new(big.Int).SetBytes(rfc5054.XA),
new(big.Int).SetBytes(rfc5054.XB),
newSRP().computeK(new(big.Int).SetBytes(rfc5054.PremasterSecret)),
rfc5054.Identity,
rfc5054.Salt))
}

func TestSRP_computeM2(t *testing.T) {
t.Parallel()

assert.Equal(t, rfc2945.M2, newSRP().computeM2(
new(big.Int).SetBytes(rfc5054.XA),
rfc2945.M1,
newSRP().computeK(new(big.Int).SetBytes(rfc5054.PremasterSecret))))
}
Loading