]> Cypherpunks.ru repositories - gogost.git/blobdiff - gost28147/mac_test.go
Download link for 5.14.1 release
[gogost.git] / gost28147 / mac_test.go
index c91db0491f48e837b323ef8cbb77f6eed2a7b324..e968ffc28f0f3aef9a812907230384d8a2e4120d 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2019 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
@@ -34,7 +34,7 @@ func TestMACVectors(t *testing.T) {
 
        t.Run("a", func(t *testing.T) {
                m.Write([]byte("a"))
-               if bytes.Compare(m.Sum(nil), []byte{0xbd, 0x5d, 0x3b, 0x5b, 0x2b, 0x7b, 0x57, 0xaf}) != 0 {
+               if !bytes.Equal(m.Sum(nil), []byte{0xbd, 0x5d, 0x3b, 0x5b, 0x2b, 0x7b, 0x57, 0xaf}) {
                        t.FailNow()
                }
        })
@@ -42,7 +42,7 @@ func TestMACVectors(t *testing.T) {
        t.Run("abc", func(t *testing.T) {
                m.Reset()
                m.Write([]byte("abc"))
-               if bytes.Compare(m.Sum(nil), []byte{0x28, 0x66, 0x1e, 0x40, 0x80, 0x5b, 0x1f, 0xf9}) != 0 {
+               if !bytes.Equal(m.Sum(nil), []byte{0x28, 0x66, 0x1e, 0x40, 0x80, 0x5b, 0x1f, 0xf9}) {
                        t.FailNow()
                }
        })
@@ -52,7 +52,7 @@ func TestMACVectors(t *testing.T) {
                for i := 0; i < 128; i++ {
                        m.Write([]byte("U"))
                }
-               if bytes.Compare(m.Sum(nil), []byte{0x1a, 0x06, 0xd1, 0xba, 0xd7, 0x45, 0x80, 0xef}) != 0 {
+               if !bytes.Equal(m.Sum(nil), []byte{0x1a, 0x06, 0xd1, 0xba, 0xd7, 0x45, 0x80, 0xef}) {
                        t.FailNow()
                }
        })
@@ -62,7 +62,7 @@ func TestMACVectors(t *testing.T) {
                for i := 0; i < 13; i++ {
                        m.Write([]byte("x"))
                }
-               if bytes.Compare(m.Sum(nil), []byte{0x91, 0x7e, 0xe1, 0xf1, 0xa6, 0x68, 0xfb, 0xd3}) != 0 {
+               if !bytes.Equal(m.Sum(nil), []byte{0x91, 0x7e, 0xe1, 0xf1, 0xa6, 0x68, 0xfb, 0xd3}) {
                        t.FailNow()
                }
        })
@@ -93,7 +93,7 @@ func TestMACRandom(t *testing.T) {
                m.Write(data)
                m.Sum(tag2)
 
-               return bytes.Compare(tag1, tag2) == 0
+               return bytes.Equal(tag1, tag2)
        }
        if err := quick.Check(f, nil); err != nil {
                t.Error(err)