Skip to content

Commit

Permalink
Add test for xof Reset()
Browse files Browse the repository at this point in the history
  • Loading branch information
K1li4nL committed Mar 26, 2024
1 parent de86258 commit 0af6c4f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions xof/xof_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,30 @@ func testReseed(t *testing.T, s kyber.XOFFactory) {
}
}

func TestReset(t *testing.T) {
for _, s := range impls {
testReset(t, s)
}
}

func testReset(t *testing.T, s kyber.XOFFactory) {
t.Logf("implementation %T", s)
seed := []byte("seed")
nbrBytes := 1024
x := s.XOF(seed)

beforeResetBytes := make([]byte, nbrBytes)
afterResetBytes := make([]byte, nbrBytes)
x.Read(beforeResetBytes)

x.Reset()
x.Read(afterResetBytes)

if !bytes.Equal(beforeResetBytes, afterResetBytes) {
t.Fatal("reset doesn't restore initial states")
}
}

func TestEncDecMismatch(t *testing.T) {
for _, i := range impls {
testEncDecMismatch(t, i)
Expand Down

0 comments on commit 0af6c4f

Please sign in to comment.