]> Cypherpunks.ru repositories - gogost.git/commitdiff
Habr-article 34.11-2012 test vector
authorSergey Matveev <stargrave@stargrave.org>
Sun, 9 Jun 2019 09:40:14 +0000 (12:40 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Sun, 9 Jun 2019 09:40:14 +0000 (12:40 +0300)
src/cypherpunks.ru/gogost/internal/gost34112012/hash_test.go

index e7422d7db97e014adbf8350a29a86d19991b4ab7..903e60fa17a652f8891c92221e8fed6720c9b64d 100644 (file)
@@ -105,6 +105,38 @@ func TestVectors(t *testing.T) {
        }) != 0 {
                t.Fail()
        }
+
+       // Test vector from https://habr.com/ru/post/450024/
+       h256.Reset()
+       m = []byte{
+               0xd0, 0xcf, 0x11, 0xe0, 0xa1, 0xb1, 0x1a, 0xe1,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x3e, 0x00, 0x03, 0x00, 0xfe, 0xff, 0x09, 0x00,
+               0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+               0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0x00, 0x10, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00,
+               0x01, 0x00, 0x00, 0x00, 0xfe, 0xff, 0xff, 0xff,
+               0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+               0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
+       }
+       h256.Write(m)
+       if bytes.Compare(h256.Sum(nil), []byte{
+               0xc7, 0x66, 0x08, 0x55, 0x40, 0xca, 0xaa, 0x89,
+               0x53, 0xbf, 0xcf, 0x7a, 0x1b, 0xa2, 0x20, 0x61,
+               0x9c, 0xee, 0x50, 0xd6, 0x5d, 0xc2, 0x42, 0xf8,
+               0x2f, 0x23, 0xba, 0x4b, 0x18, 0x0b, 0x18, 0xe0,
+       }) != 0 {
+               t.Fail()
+       }
 }
 
 func TestBlocksized(t *testing.T) {