]> Cypherpunks.ru repositories - gogost.git/blobdiff - src/cypherpunks.ru/gogost/internal/gost34112012/hash_test.go
Habr-article 34.11-2012 test vector
[gogost.git] / src / cypherpunks.ru / gogost / internal / gost34112012 / hash_test.go
index 1e056c6d1c0828d2c4b627c38fd4fda1903d2ae0..903e60fa17a652f8891c92221e8fed6720c9b64d 100644 (file)
@@ -1,5 +1,5 @@
 // GoGOST -- Pure Go GOST cryptographic functions library
-// Copyright (C) 2015-2018 Sergey Matveev <stargrave@stargrave.org>
+// Copyright (C) 2015-2019 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
@@ -68,6 +68,8 @@ func TestVectors(t *testing.T) {
        }
 
        // Second vector
+       // It is CP1251-encoded "Се ветри, Стрибожи внуци, веютъ с моря
+       // стрелами на храбрыя плъкы Игоревы" string
        h512.Reset()
        h256.Reset()
        m = []byte{
@@ -103,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) {