diff --git a/internal/rfc2945/test.go b/internal/rfc2945/test.go new file mode 100644 index 0000000..b0f8cea --- /dev/null +++ b/internal/rfc2945/test.go @@ -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`)) +) diff --git a/srp_internal_test.go b/srp_internal_test.go index b2ad3d0..7faa869 100644 --- a/srp_internal_test.go +++ b/srp_internal_test.go @@ -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" @@ -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)))) +}