]> Cypherpunks.ru repositories - gogost.git/commitdiff
FailNow() must be used instead of just marking Fail()
authorSergey Matveev <stargrave@stargrave.org>
Fri, 26 Jul 2019 08:37:33 +0000 (11:37 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Fri, 26 Jul 2019 08:37:33 +0000 (11:37 +0300)
src/cypherpunks.ru/gogost/gost28147/cfb_test.go
src/cypherpunks.ru/gogost/gost28147/ctr_test.go
src/cypherpunks.ru/gogost/gost28147/ecb_test.go
src/cypherpunks.ru/gogost/gost28147/mac_test.go
src/cypherpunks.ru/gogost/gost341194/hash_test.go
src/cypherpunks.ru/gogost/gost341194/pbkdf2_test.go
src/cypherpunks.ru/gogost/internal/gost34112012/hash_test.go
src/cypherpunks.ru/gogost/internal/gost34112012/hmac_test.go

index fd0e18699076d29035af15947b0f1a578acc217f..cd30d86f8e42db1ee3a66ed8569054e1c0673226 100644 (file)
@@ -45,12 +45,12 @@ func TestCFBCryptomanager(t *testing.T) {
        fe := c.NewCFBEncrypter(iv)
        fe.XORKeyStream(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.Fatal("encryption failed")
        }
        fd := c.NewCFBDecrypter(iv)
        fd.XORKeyStream(tmp, ct)
        if bytes.Compare(tmp, pt) != 0 {
-               t.Fail()
+               t.Fatal("decryption failed")
        }
 }
 
index 357d15c0ec8148607165dca258b31dffdd80f19a..139bbb984e762e235e32a9c7d237de205841d0cc 100644 (file)
@@ -106,12 +106,12 @@ func TestCTRGCL3Vector(t *testing.T) {
        tmp := make([]byte, len(plaintext))
        ctr.XORKeyStream(tmp, plaintext)
        if bytes.Compare(tmp, ciphertext) != 0 {
-               t.Fail()
+               t.Fatal("encryption failed")
        }
        ctr = c.NewCTR(iv)
        ctr.XORKeyStream(tmp, tmp)
        if bytes.Compare(tmp, plaintext) != 0 {
-               t.Fail()
+               t.Fatal("decryption failed")
        }
 }
 
@@ -147,12 +147,12 @@ func TestCTRGCL2Vector(t *testing.T) {
        tmp := make([]byte, len(plaintext))
        ctr.XORKeyStream(tmp, plaintext)
        if bytes.Compare(tmp, ciphertext) != 0 {
-               t.Fail()
+               t.Fatal("encryption failed")
        }
        ctr = c.NewCTR(iv[:])
        ctr.XORKeyStream(tmp, tmp)
        if bytes.Compare(tmp, plaintext) != 0 {
-               t.Fail()
+               t.Fatal("decryption failed")
        }
 }
 
index 76928c9986abc51e438a73e3b75db561b0e5d2df..9a0f08b3f5b4c91021b337fbe53b228bc64f26e8 100644 (file)
@@ -102,12 +102,12 @@ func TestECBGCL3Vectors(t *testing.T) {
        tmp := make([]byte, len(plaintext))
        e.CryptBlocks(tmp, plaintext)
        if bytes.Compare(tmp, ciphertext) != 0 {
-               t.Fail()
+               t.Fatal("encryption failed")
        }
        d := c.NewECBDecrypter()
        d.CryptBlocks(tmp, tmp)
        if bytes.Compare(tmp, plaintext) != 0 {
-               t.Fail()
+               t.Fatal("decryption failed")
        }
 }
 
@@ -126,7 +126,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c := NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -140,7 +140,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -154,7 +154,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -168,7 +168,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -182,7 +182,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -196,7 +196,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -210,7 +210,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        key = []byte{
@@ -224,7 +224,7 @@ func TestECBCryptoPPVectors(t *testing.T) {
        c = NewCipher(key, sbox)
        c.Encrypt(tmp, pt)
        if bytes.Compare(tmp, ct) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
@@ -240,7 +240,7 @@ func TestECBCryptomanager(t *testing.T) {
        tmp := make([]byte, BlockSize)
        c.Encrypt(tmp, []byte{0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88})
        if bytes.Compare(tmp, []byte{0x03, 0x25, 0x1E, 0x14, 0xF9, 0xD2, 0x8A, 0xCB}) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
index 58ed6ecfcef0c8a98c0205c992d0e19daaee7a03..9f85665b7e3fd8af776994262e3e988e2ac07695 100644 (file)
@@ -30,18 +30,18 @@ func TestMACVectors(t *testing.T) {
        var iv [8]byte
        m, err := c.NewMAC(8, iv[:])
        if err != nil {
-               t.Fail()
+               t.FailNow()
        }
 
        m.Write([]byte("a"))
        if bytes.Compare(m.Sum(nil), []byte{0xbd, 0x5d, 0x3b, 0x5b, 0x2b, 0x7b, 0x57, 0xaf}) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        m.Reset()
        m.Write([]byte("abc"))
        if bytes.Compare(m.Sum(nil), []byte{0x28, 0x66, 0x1e, 0x40, 0x80, 0x5b, 0x1f, 0xf9}) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        m.Reset()
@@ -49,7 +49,7 @@ func TestMACVectors(t *testing.T) {
                m.Write([]byte("U"))
        }
        if bytes.Compare(m.Sum(nil), []byte{0x1a, 0x06, 0xd1, 0xba, 0xd7, 0x45, 0x80, 0xef}) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        m.Reset()
@@ -57,7 +57,7 @@ func TestMACVectors(t *testing.T) {
                m.Write([]byte("x"))
        }
        if bytes.Compare(m.Sum(nil), []byte{0x91, 0x7e, 0xe1, 0xf1, 0xa6, 0x68, 0xfb, 0xd3}) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
@@ -71,7 +71,7 @@ func TestMACRandom(t *testing.T) {
                }
                m, err := c.NewMAC(8, iv[:])
                if err != nil {
-                       t.Fail()
+                       return false
                }
 
                var tag1 []byte
index ba38307840ed3c8078f65b94316aa9718f24f1c6..49f86289be97c25c30b8d64aac4026febf8c12b3 100644 (file)
@@ -40,7 +40,7 @@ func TestVectors(t *testing.T) {
                0xab, 0xb4, 0xc2, 0xd2, 0x05, 0x5c, 0xff, 0x68,
                0x5a, 0xf4, 0x91, 0x2c, 0x49, 0x49, 0x0f, 0x8d,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -51,7 +51,7 @@ func TestVectors(t *testing.T) {
                0x21, 0x87, 0x1b, 0x43, 0x44, 0xc6, 0xa5, 0x73,
                0xf8, 0x49, 0xfd, 0xce, 0x62, 0xf3, 0x14, 0xdd,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -62,7 +62,7 @@ func TestVectors(t *testing.T) {
                0xcb, 0x5e, 0x0f, 0x29, 0xc9, 0x75, 0xbc, 0x75,
                0x3b, 0x70, 0x49, 0x7c, 0x06, 0xa4, 0xd5, 0x1d,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -73,7 +73,7 @@ func TestVectors(t *testing.T) {
                0x58, 0x2b, 0x65, 0x27, 0x3f, 0x48, 0xde, 0x72,
                0xdb, 0x2f, 0xde, 0x16, 0xa4, 0x88, 0x9a, 0x4d,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -86,7 +86,7 @@ func TestVectors(t *testing.T) {
                0x1c, 0x25, 0x66, 0x0a, 0x87, 0x06, 0x2a, 0x52,
                0xd9, 0x26, 0xa9, 0xe8, 0xfe, 0x57, 0x33, 0xa4,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -97,7 +97,7 @@ func TestVectors(t *testing.T) {
                0x29, 0x65, 0x29, 0x31, 0x5e, 0xac, 0xa7, 0x6b,
                0xd1, 0xa1, 0x0f, 0x37, 0x6d, 0x1f, 0x42, 0x94,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -108,7 +108,7 @@ func TestVectors(t *testing.T) {
                0xe6, 0x02, 0x67, 0x0d, 0x54, 0x35, 0x21, 0x31,
                0x91, 0x50, 0xd2, 0xe1, 0x4e, 0xee, 0xc4, 0x45,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -119,7 +119,7 @@ func TestVectors(t *testing.T) {
                0x47, 0xa2, 0x8c, 0xb6, 0xf8, 0x3e, 0xff, 0x1c,
                0x69, 0x16, 0xa8, 0x15, 0xa6, 0x37, 0xff, 0xfa,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -130,7 +130,7 @@ func TestVectors(t *testing.T) {
                0x4e, 0xf1, 0x4d, 0xe5, 0x1f, 0x78, 0xb4, 0xae,
                0x57, 0xdd, 0x89, 0x3b, 0x62, 0xf5, 0x52, 0x08,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
@@ -143,7 +143,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0xac, 0x11, 0x01, 0x56, 0x9b, 0x9c, 0x13, 0x58,
                0x4a, 0xc4, 0x83, 0x23, 0x4c, 0xd6, 0x56, 0xc0,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -154,7 +154,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0x71, 0x5a, 0x10, 0x3f, 0x17, 0xe3, 0x13, 0x3c,
                0xef, 0xf1, 0xaa, 0xcf, 0x2f, 0x40, 0x30, 0x11,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -165,7 +165,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0x74, 0x74, 0x59, 0xed, 0x81, 0x43, 0x99, 0x7e,
                0x16, 0x3b, 0x29, 0x86, 0xf9, 0x2f, 0xd4, 0x2c,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -176,7 +176,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0xbd, 0xb4, 0x72, 0x9a, 0xa9, 0x72, 0xd6, 0x0f,
                0x54, 0x9a, 0xc3, 0x9b, 0x29, 0x72, 0x1b, 0xa0,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -187,7 +187,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0x67, 0x65, 0xe7, 0x1b, 0x76, 0x54, 0x72, 0x78,
                0x6e, 0x47, 0x70, 0xd5, 0x65, 0x83, 0x0a, 0x76,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -198,7 +198,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0xe7, 0xfa, 0x17, 0xd6, 0x52, 0xc7, 0x5f, 0x69,
                0xcb, 0x1b, 0xe7, 0x89, 0x3e, 0xde, 0x48, 0xeb,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -209,7 +209,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0x4e, 0xf7, 0x53, 0x31, 0xd9, 0x40, 0x5e, 0x5f,
                0x1a, 0x61, 0xdc, 0x31, 0x30, 0xa6, 0x50, 0x11,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h.Reset()
@@ -222,7 +222,7 @@ func TestVectorsCryptoPro(t *testing.T) {
                0x0d, 0x92, 0xed, 0xfd, 0x37, 0xcd, 0x10, 0x27,
                0x51, 0x4c, 0x10, 0x08, 0xf6, 0x49, 0xc4, 0xe8,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
index 8f280224f0ba72c8a37f58a190f1c99c2a011f0c..a4088e0efa9b1df2e96f60a7d0243bf68713cb76 100644 (file)
@@ -44,7 +44,7 @@ func TestPBKDF2Vectors(t *testing.T) {
                0xb7, 0x34, 0x45, 0xd0, 0x7f, 0x24, 0x1b, 0xed,
                0x87, 0x28, 0x82, 0xda, 0x21, 0x66, 0x2d, 0x58,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        if bytes.Compare(pbkdf2.Key(
                []byte("password"),
@@ -58,7 +58,7 @@ func TestPBKDF2Vectors(t *testing.T) {
                0x9f, 0x2d, 0xb3, 0x4f, 0xef, 0x25, 0xf2, 0x74,
                0x37, 0x88, 0x72, 0xfe, 0xd7, 0xed, 0x1b, 0xb3,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        if bytes.Compare(pbkdf2.Key(
                []byte("password"),
@@ -72,7 +72,7 @@ func TestPBKDF2Vectors(t *testing.T) {
                0xa9, 0x74, 0x67, 0xf3, 0xb3, 0x11, 0x16, 0xa5,
                0xa7, 0xc1, 0xaf, 0xff, 0x9d, 0xea, 0xda, 0xfe,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        /* It takes too long
        if bytes.Compare(pbkdf2.Key(
@@ -87,7 +87,7 @@ func TestPBKDF2Vectors(t *testing.T) {
                0x51, 0x00, 0x93, 0x8a, 0x59, 0xb1, 0xb5, 0xc3,
                0xf7, 0x81, 0x09, 0x10, 0xd0, 0x5f, 0xcd, 0x97,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        */
        if bytes.Compare(pbkdf2.Key(
@@ -103,7 +103,7 @@ func TestPBKDF2Vectors(t *testing.T) {
                0xd5, 0x6f, 0x32, 0x6b, 0x49, 0xc8, 0x50, 0x47,
                0xb7, 0x63, 0x8a, 0xcb, 0x47, 0x64, 0xb1, 0xfd,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        if bytes.Compare(pbkdf2.Key(
                []byte("pass\x00word"),
@@ -116,6 +116,6 @@ func TestPBKDF2Vectors(t *testing.T) {
                0x25, 0x24, 0x23, 0x73, 0x12, 0x7e, 0xdf, 0x9c,
                0x8e, 0x9c, 0x32, 0x91,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
index 903e60fa17a652f8891c92221e8fed6720c9b64d..b9422b7105ea96b5e9e804668a17a9530e4c506b 100644 (file)
@@ -55,7 +55,7 @@ func TestVectors(t *testing.T) {
                0xe2, 0xa4, 0x81, 0x33, 0x2b, 0x08, 0xef, 0x7f,
                0x41, 0x79, 0x78, 0x91, 0xc1, 0x64, 0x6f, 0x48,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        h256.Write(m)
        if bytes.Compare(h256.Sum(nil), []byte{
@@ -64,7 +64,7 @@ func TestVectors(t *testing.T) {
                0x5d, 0xd0, 0x51, 0x02, 0x6b, 0xb1, 0x49, 0xa4,
                0x52, 0xfd, 0x84, 0xe5, 0xe5, 0x7b, 0x55, 0x00,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        // Second vector
@@ -94,7 +94,7 @@ func TestVectors(t *testing.T) {
                0x3f, 0x0c, 0xb9, 0xdd, 0xdc, 0x2b, 0x64, 0x60,
                0x14, 0x3b, 0x03, 0xda, 0xba, 0xc9, 0xfb, 0x28,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        h256.Write(m)
        if bytes.Compare(h256.Sum(nil), []byte{
@@ -103,7 +103,7 @@ func TestVectors(t *testing.T) {
                0xc0, 0xca, 0xc6, 0x28, 0xfc, 0x66, 0x9a, 0x74,
                0x1d, 0x50, 0x06, 0x3c, 0x55, 0x7e, 0x8f, 0x50,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        // Test vector from https://habr.com/ru/post/450024/
@@ -135,7 +135,7 @@ func TestVectors(t *testing.T) {
                0x9c, 0xee, 0x50, 0xd6, 0x5d, 0xc2, 0x42, 0xf8,
                0x2f, 0x23, 0xba, 0x4b, 0x18, 0x0b, 0x18, 0xe0,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
@@ -156,7 +156,7 @@ func TestBlocksized(t *testing.T) {
                0x6f, 0xa8, 0xa1, 0x55, 0xdc, 0xb3, 0xeb, 0x82,
                0x2d, 0x92, 0x58, 0x08, 0xf7, 0xc7, 0xe3, 0x45,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
@@ -165,17 +165,17 @@ func TestBehaviour(t *testing.T) {
        // Sum does not change the state
        hsh1 := h.Sum(nil)
        if bytes.Compare(h.Sum(nil), hsh1) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        // No data equals to no state changing
        h.Write([]byte{})
        if bytes.Compare(h.Sum(nil), hsh1) != 0 {
-               t.Fail()
+               t.FailNow()
        }
        // Just to be sure
        h.Write([]byte{})
        if bytes.Compare(h.Sum(nil), hsh1) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }
 
index ea806d51275d52940354ae8a0d8b053dd623d6bc..859d484f441f1544b34384275f357860b5b8cbc2 100644 (file)
@@ -50,7 +50,7 @@ func TestHMACVectors(t *testing.T) {
                0x01, 0x31, 0x37, 0x01, 0x0a, 0x83, 0x75, 0x4f,
                0xd0, 0xaf, 0x6d, 0x7c, 0xd4, 0x92, 0x2e, 0xd9,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 
        h = hmac.New(hash512, []byte{
@@ -73,6 +73,6 @@ func TestHMACVectors(t *testing.T) {
                0x3a, 0xfe, 0x93, 0xb2, 0x81, 0x4f, 0x79, 0xf5,
                0x00, 0x0f, 0xfc, 0x03, 0x66, 0xc2, 0x51, 0xe6,
        }) != 0 {
-               t.Fail()
+               t.FailNow()
        }
 }