X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost28147%2Fctr_test.go;h=1998e652baacf21ffd549e1dee7bc413f9b29b5a;hb=d681002980ca0b115936a6e217de5649bb8966d3;hp=7eace06576693f312f71c4d7c972e3ead1f5c69b;hpb=5afe1dcbfaf1043ed9e72e215a285966eaba3369;p=gogost.git diff --git a/gost28147/ctr_test.go b/gost28147/ctr_test.go index 7eace06..1998e65 100644 --- a/gost28147/ctr_test.go +++ b/gost28147/ctr_test.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2023 Sergey Matveev +// Copyright (C) 2015-2024 Sergey Matveev // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -104,12 +104,12 @@ func TestCTRGCL3Vector(t *testing.T) { ctr := c.NewCTR(iv) tmp := make([]byte, len(plaintext)) ctr.XORKeyStream(tmp, plaintext) - if bytes.Compare(tmp, ciphertext) != 0 { + if !bytes.Equal(tmp, ciphertext) { t.Fatal("encryption failed") } ctr = c.NewCTR(iv) ctr.XORKeyStream(tmp, tmp) - if bytes.Compare(tmp, plaintext) != 0 { + if !bytes.Equal(tmp, plaintext) { t.Fatal("decryption failed") } } @@ -145,12 +145,12 @@ func TestCTRGCL2Vector(t *testing.T) { ctr := c.NewCTR(iv[:]) tmp := make([]byte, len(plaintext)) ctr.XORKeyStream(tmp, plaintext) - if bytes.Compare(tmp, ciphertext) != 0 { + if !bytes.Equal(tmp, ciphertext) { t.Fatal("encryption failed") } ctr = c.NewCTR(iv[:]) ctr.XORKeyStream(tmp, tmp) - if bytes.Compare(tmp, plaintext) != 0 { + if !bytes.Equal(tmp, plaintext) { t.Fatal("decryption failed") } } @@ -166,7 +166,7 @@ func TestCTRRandom(t *testing.T) { ctr.XORKeyStream(tmp, pt[:]) ctr = c.NewCTR(iv[:]) ctr.XORKeyStream(tmp, tmp) - return bytes.Compare(tmp, pt) == 0 + return bytes.Equal(tmp, pt) } if err := quick.Check(f, nil); err != nil { t.Error(err)