]> Cypherpunks.ru repositories - gogost.git/blobdiff - gost28147/ctr_test.go
Download link for 5.14.1 release
[gogost.git] / gost28147 / ctr_test.go
index 7eace06576693f312f71c4d7c972e3ead1f5c69b..1998e652baacf21ffd549e1dee7bc413f9b29b5a 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2023 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2024 Sergey Matveev <stargrave@stargrave.org>
 //
 // 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)