X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=gost341194%2Fpbkdf2_test.go;h=ee08fc71b90ab27dafc832777c06c7b4391d365b;hb=d681002980ca0b115936a6e217de5649bb8966d3;hp=2e2d578e2d58a2c5f08d778198dc3107d7b50240;hpb=e38f7b828c16660814ac5b55b53644b3822e067b;p=gogost.git diff --git a/gost341194/pbkdf2_test.go b/gost341194/pbkdf2_test.go index 2e2d578..ee08fc7 100644 --- a/gost341194/pbkdf2_test.go +++ b/gost341194/pbkdf2_test.go @@ -1,5 +1,5 @@ // GoGOST -- Pure Go GOST cryptographic functions library -// Copyright (C) 2015-2020 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 @@ -32,7 +32,7 @@ func PBKDF2Hash() hash.Hash { // http://tc26.ru/methods/containers_v1/Addition_to_PKCS5_v1_0.pdf test vectors func TestPBKDF2Vectors(t *testing.T) { t.Run("1", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("password"), []byte("salt"), 1, @@ -43,13 +43,13 @@ func TestPBKDF2Vectors(t *testing.T) { 0xc5, 0x43, 0x67, 0x42, 0x53, 0xf6, 0x8b, 0xd0, 0xb7, 0x34, 0x45, 0xd0, 0x7f, 0x24, 0x1b, 0xed, 0x87, 0x28, 0x82, 0xda, 0x21, 0x66, 0x2d, 0x58, - }) != 0 { + }) { t.FailNow() } }) t.Run("2", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("password"), []byte("salt"), 2, @@ -60,13 +60,13 @@ func TestPBKDF2Vectors(t *testing.T) { 0xa4, 0x8b, 0x07, 0xb7, 0x92, 0x77, 0x5d, 0xf7, 0x9f, 0x2d, 0xb3, 0x4f, 0xef, 0x25, 0xf2, 0x74, 0x37, 0x88, 0x72, 0xfe, 0xd7, 0xed, 0x1b, 0xb3, - }) != 0 { + }) { t.FailNow() } }) t.Run("4096", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("password"), []byte("salt"), 4096, @@ -77,14 +77,14 @@ func TestPBKDF2Vectors(t *testing.T) { 0x10, 0xd0, 0xae, 0xb3, 0x6a, 0xf4, 0x98, 0xe7, 0xa9, 0x74, 0x67, 0xf3, 0xb3, 0x11, 0x16, 0xa5, 0xa7, 0xc1, 0xaf, 0xff, 0x9d, 0xea, 0xda, 0xfe, - }) != 0 { + }) { t.FailNow() } }) /* t.Run("16777216", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("password"), []byte("salt"), 16777216, @@ -95,14 +95,14 @@ func TestPBKDF2Vectors(t *testing.T) { 0x20, 0x85, 0x0c, 0x5c, 0x09, 0xde, 0x0a, 0x52, 0x51, 0x00, 0x93, 0x8a, 0x59, 0xb1, 0xb5, 0xc3, 0xf7, 0x81, 0x09, 0x10, 0xd0, 0x5f, 0xcd, 0x97, - }) != 0 { + }) { t.FailNow() } }) */ t.Run("many", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("passwordPASSWORDpassword"), []byte("saltSALTsaltSALTsaltSALTsaltSALTsalt"), 4096, @@ -114,13 +114,13 @@ func TestPBKDF2Vectors(t *testing.T) { 0x26, 0x5a, 0x79, 0x2a, 0x35, 0xbe, 0xcd, 0xe8, 0xd5, 0x6f, 0x32, 0x6b, 0x49, 0xc8, 0x50, 0x47, 0xb7, 0x63, 0x8a, 0xcb, 0x47, 0x64, 0xb1, 0xfd, - }) != 0 { + }) { t.FailNow() } }) t.Run("zero byte", func(t *testing.T) { - if bytes.Compare(pbkdf2.Key( + if !bytes.Equal(pbkdf2.Key( []byte("pass\x00word"), []byte("sa\x00lt"), 4096, @@ -130,7 +130,7 @@ func TestPBKDF2Vectors(t *testing.T) { 0x43, 0xe0, 0x6c, 0x55, 0x90, 0xb0, 0x8c, 0x02, 0x25, 0x24, 0x23, 0x73, 0x12, 0x7e, 0xdf, 0x9c, 0x8e, 0x9c, 0x32, 0x91, - }) != 0 { + }) { t.FailNow() } })