From: Sergey Matveev Date: Wed, 17 Jul 2019 14:49:12 +0000 (+0300) Subject: Sbox names comply with OIDs X-Git-Tag: 3.0~9 X-Git-Url: http://www.git.cypherpunks.ru/?p=gogost.git;a=commitdiff_plain;h=bfe87fc2ae85dce7cf14b0e03603544eafa7d130 Sbox names comply with OIDs --- diff --git a/src/cypherpunks.ru/gogost/gost28147/cfb_test.go b/src/cypherpunks.ru/gogost/gost28147/cfb_test.go index 3b60a6f..af527fb 100644 --- a/src/cypherpunks.ru/gogost/gost28147/cfb_test.go +++ b/src/cypherpunks.ru/gogost/gost28147/cfb_test.go @@ -31,7 +31,7 @@ func TestCFBCryptomanager(t *testing.T) { 0x4F, 0xF9, 0x9D, 0xA6, 0xD1, 0xB5, 0x3B, 0x5B, 0x1B, 0x40, 0x2A, 0x1B, 0xAA, 0x03, 0x0D, 0x1B, } - sbox := &GostR3411_94_TestParamSet + sbox := &SboxIdGostR341194TestParamSet pt := []byte{ 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0x80, 0x00, 0x00, diff --git a/src/cypherpunks.ru/gogost/gost28147/ctr_test.go b/src/cypherpunks.ru/gogost/gost28147/ctr_test.go index 0395338..73a96ae 100644 --- a/src/cypherpunks.ru/gogost/gost28147/ctr_test.go +++ b/src/cypherpunks.ru/gogost/gost28147/ctr_test.go @@ -25,7 +25,7 @@ import ( ) func TestCTRGCL3Vector(t *testing.T) { - sbox := &Gost2814789_TestParamSet + sbox := &SboxIdGost2814789TestParamSet key := [KeySize]byte{ 0x04, 0x75, 0xf6, 0xe0, 0x50, 0x38, 0xfb, 0xfa, 0xd2, 0xc7, 0xc3, 0x90, 0xed, 0xb3, 0xca, 0x3d, @@ -116,7 +116,7 @@ func TestCTRGCL3Vector(t *testing.T) { } func TestCTRGCL2Vector(t *testing.T) { - sbox := &Gost2814789_TestParamSet + sbox := &SboxIdGost2814789TestParamSet key := [KeySize]byte{ 0xfc, 0x7a, 0xd2, 0x88, 0x6f, 0x45, 0x5b, 0x50, 0xd2, 0x90, 0x08, 0xfa, 0x62, 0x2b, 0x57, 0xd5, diff --git a/src/cypherpunks.ru/gogost/gost28147/ecb_test.go b/src/cypherpunks.ru/gogost/gost28147/ecb_test.go index 868d849..b293a22 100644 --- a/src/cypherpunks.ru/gogost/gost28147/ecb_test.go +++ b/src/cypherpunks.ru/gogost/gost28147/ecb_test.go @@ -29,7 +29,7 @@ func TestECBGCL3Vectors(t *testing.T) { 0x15, 0x47, 0x12, 0x42, 0x91, 0xae, 0x1e, 0x8a, 0x2f, 0x79, 0xcd, 0x9e, 0xd2, 0xbc, 0xef, 0xbd, } - c := NewCipher(key, &Gost2814789_TestParamSet) + c := NewCipher(key, &SboxIdGost2814789TestParamSet) plaintext := []byte{ 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00, 0x0f, 0x0e, 0x0d, 0x0c, 0x0b, 0x0a, 0x09, 0x08, @@ -113,7 +113,7 @@ func TestECBGCL3Vectors(t *testing.T) { // Crypto++ 5.6.2 test vectors func TestECBCryptoPPVectors(t *testing.T) { - sbox := &AppliedCryptographyParamSet + sbox := &SboxAppliedCryptographyParamSet var key [KeySize]byte var pt [BlockSize]byte var ct [BlockSize]byte @@ -235,7 +235,7 @@ func TestECBCryptoPPVectors(t *testing.T) { // http://cryptomanager.com/tv.html test vectors. func TestECBCryptomanager(t *testing.T) { - sbox := &GostR3411_94_TestParamSet + sbox := &SboxIdGostR341194TestParamSet key := [KeySize]byte{ 0x75, 0x71, 0x31, 0x34, 0xB6, 0x0F, 0xEC, 0x45, 0xA6, 0x07, 0xBB, 0x83, 0xAA, 0x37, 0x46, 0xAF, diff --git a/src/cypherpunks.ru/gogost/gost28147/sbox.go b/src/cypherpunks.ru/gogost/gost28147/sbox.go index 443dce4..5a17d84 100644 --- a/src/cypherpunks.ru/gogost/gost28147/sbox.go +++ b/src/cypherpunks.ru/gogost/gost28147/sbox.go @@ -20,7 +20,7 @@ package gost28147 type Sbox [8][16]uint8 var ( - Gost2814789_TestParamSet = Sbox([8][16]uint8{ + SboxIdGost2814789TestParamSet = Sbox([8][16]uint8{ {4, 2, 15, 5, 9, 1, 0, 8, 14, 3, 11, 12, 13, 7, 10, 6}, {12, 9, 15, 14, 8, 1, 3, 10, 2, 7, 4, 13, 6, 0, 11, 5}, {13, 8, 14, 12, 7, 3, 9, 10, 1, 5, 2, 4, 6, 15, 0, 11}, @@ -30,7 +30,7 @@ var ( {9, 11, 12, 0, 3, 6, 7, 5, 4, 8, 14, 15, 1, 10, 2, 13}, {12, 6, 5, 2, 11, 0, 9, 13, 3, 14, 7, 10, 15, 4, 1, 8}, }) - Gost28147_CryptoProParamSetA = Sbox([8][16]uint8{ + SboxIdGost2814789CryptoProAParamSet = Sbox([8][16]uint8{ {9, 6, 3, 2, 8, 11, 1, 7, 10, 4, 14, 15, 12, 0, 13, 5}, {3, 7, 14, 9, 8, 10, 15, 0, 5, 2, 6, 12, 11, 4, 13, 1}, {14, 4, 6, 2, 11, 3, 13, 8, 12, 15, 5, 10, 0, 7, 1, 9}, @@ -40,7 +40,7 @@ var ( {1, 13, 2, 9, 7, 10, 6, 0, 8, 12, 4, 5, 15, 3, 11, 14}, {11, 10, 15, 5, 0, 12, 14, 8, 6, 2, 3, 9, 1, 7, 13, 4}, }) - Gost28147_CryptoProParamSetB = Sbox([8][16]uint8{ + SboxIdGost2814789CryptoProBParamSet = Sbox([8][16]uint8{ {8, 4, 11, 1, 3, 5, 0, 9, 2, 14, 10, 12, 13, 6, 7, 15}, {0, 1, 2, 10, 4, 13, 5, 12, 9, 7, 3, 15, 11, 8, 6, 14}, {14, 12, 0, 10, 9, 2, 13, 11, 7, 5, 8, 15, 3, 6, 1, 4}, @@ -50,7 +50,7 @@ var ( {5, 2, 10, 11, 9, 1, 12, 3, 7, 4, 13, 0, 6, 15, 8, 14}, {0, 4, 11, 14, 8, 3, 7, 1, 10, 2, 9, 6, 15, 13, 5, 12}, }) - Gost28147_CryptoProParamSetC = Sbox([8][16]uint8{ + SboxIdGost2814789CryptoProCParamSet = Sbox([8][16]uint8{ {1, 11, 12, 2, 9, 13, 0, 15, 4, 5, 8, 14, 10, 7, 6, 3}, {0, 1, 7, 13, 11, 4, 5, 2, 8, 14, 15, 12, 9, 10, 6, 3}, {8, 2, 5, 0, 4, 9, 15, 10, 3, 7, 12, 13, 6, 14, 1, 11}, @@ -60,7 +60,7 @@ var ( {10, 9, 6, 8, 13, 14, 2, 0, 15, 3, 5, 11, 4, 1, 12, 7}, {7, 4, 0, 5, 10, 2, 15, 14, 12, 6, 1, 11, 13, 9, 3, 8}, }) - Gost28147_CryptoProParamSetD = Sbox([8][16]uint8{ + SboxIdGost2814789CryptoProDParamSet = Sbox([8][16]uint8{ {15, 12, 2, 10, 6, 4, 5, 0, 7, 9, 14, 13, 1, 11, 8, 3}, {11, 6, 3, 4, 12, 15, 14, 2, 7, 13, 8, 0, 5, 10, 9, 1}, {1, 12, 11, 0, 15, 14, 6, 5, 10, 13, 4, 8, 9, 3, 7, 2}, @@ -70,7 +70,17 @@ var ( {3, 0, 6, 15, 1, 14, 9, 2, 13, 8, 12, 4, 11, 10, 5, 7}, {1, 10, 6, 8, 15, 11, 0, 4, 12, 3, 5, 9, 7, 13, 2, 14}, }) - GostR3411_94_TestParamSet = Sbox([8][16]uint8{ + SboxIdtc26gost28147paramZ = Sbox([8][16]uint8{ + {12, 4, 6, 2, 10, 5, 11, 9, 14, 8, 13, 7, 0, 3, 15, 1}, + {6, 8, 2, 3, 9, 10, 5, 12, 1, 14, 4, 7, 11, 13, 0, 15}, + {11, 3, 5, 8, 2, 15, 10, 13, 14, 1, 7, 4, 12, 9, 6, 0}, + {12, 8, 2, 1, 13, 4, 15, 6, 7, 0, 10, 5, 3, 14, 9, 11}, + {7, 15, 5, 10, 8, 1, 6, 13, 0, 9, 3, 14, 11, 4, 2, 12}, + {5, 13, 15, 6, 9, 2, 12, 10, 11, 7, 8, 1, 4, 3, 14, 0}, + {8, 14, 2, 5, 6, 9, 1, 12, 15, 4, 11, 0, 13, 10, 3, 7}, + {1, 7, 14, 13, 0, 5, 8, 3, 4, 15, 10, 6, 9, 12, 11, 2}, + }) + SboxIdGostR341194TestParamSet = Sbox([8][16]uint8{ {4, 10, 9, 2, 13, 8, 0, 14, 6, 11, 1, 12, 7, 15, 5, 3}, {14, 11, 4, 12, 6, 13, 15, 10, 2, 3, 8, 1, 0, 7, 5, 9}, {5, 8, 1, 13, 10, 3, 4, 2, 14, 15, 12, 7, 6, 0, 9, 11}, @@ -80,7 +90,8 @@ var ( {13, 11, 4, 1, 3, 15, 5, 9, 0, 10, 14, 7, 6, 8, 2, 12}, {1, 15, 13, 0, 5, 7, 10, 4, 9, 2, 3, 14, 6, 11, 8, 12}, }) - GostR3411_94_CryptoProParamSet = Sbox([8][16]uint8{ + SboxAppliedCryptographyParamSet = SboxIdGostR341194TestParamSet + SboxIdGostR341194CryptoProParamSet = Sbox([8][16]uint8{ {10, 4, 5, 6, 8, 1, 3, 7, 13, 12, 14, 0, 9, 2, 11, 15}, {5, 15, 4, 0, 2, 13, 11, 9, 1, 7, 6, 3, 12, 14, 10, 8}, {7, 15, 12, 14, 9, 4, 1, 0, 3, 11, 5, 2, 6, 10, 8, 13}, @@ -90,18 +101,7 @@ var ( {13, 14, 4, 1, 7, 0, 5, 10, 3, 12, 8, 15, 6, 2, 9, 11}, {1, 3, 10, 9, 5, 11, 4, 15, 8, 6, 7, 14, 13, 0, 2, 12}, }) - AppliedCryptographyParamSet = GostR3411_94_TestParamSet - Gost28147_tc26_ParamZ = Sbox([8][16]uint8{ - {12, 4, 6, 2, 10, 5, 11, 9, 14, 8, 13, 7, 0, 3, 15, 1}, - {6, 8, 2, 3, 9, 10, 5, 12, 1, 14, 4, 7, 11, 13, 0, 15}, - {11, 3, 5, 8, 2, 15, 10, 13, 14, 1, 7, 4, 12, 9, 6, 0}, - {12, 8, 2, 1, 13, 4, 15, 6, 7, 0, 10, 5, 3, 14, 9, 11}, - {7, 15, 5, 10, 8, 1, 6, 13, 0, 9, 3, 14, 11, 4, 2, 12}, - {5, 13, 15, 6, 9, 2, 12, 10, 11, 7, 8, 1, 4, 3, 14, 0}, - {8, 14, 2, 5, 6, 9, 1, 12, 15, 4, 11, 0, 13, 10, 3, 7}, - {1, 7, 14, 13, 0, 5, 8, 3, 4, 15, 10, 6, 9, 12, 11, 2}, - }) - EACParamSet = Sbox([8][16]uint8{ + SboxEACParamSet = Sbox([8][16]uint8{ {11, 4, 8, 10, 9, 7, 0, 3, 1, 6, 2, 15, 14, 5, 12, 13}, {1, 7, 14, 9, 11, 3, 15, 12, 0, 5, 4, 6, 13, 10, 8, 2}, {7, 3, 1, 9, 2, 4, 13, 15, 8, 10, 12, 6, 5, 0, 11, 14}, @@ -111,7 +111,7 @@ var ( {4, 0, 14, 1, 5, 11, 8, 3, 12, 2, 9, 7, 6, 10, 13, 15}, {7, 14, 12, 13, 9, 4, 8, 15, 10, 2, 6, 0, 3, 11, 5, 1}, }) - SboxDefault = &Gost28147_CryptoProParamSetA + SboxDefault = &SboxIdGost2814789CryptoProAParamSet ) // Sbox substitution itself. diff --git a/src/cypherpunks.ru/gogost/gost3410/vko2001.go b/src/cypherpunks.ru/gogost/gost3410/vko2001.go index 258568d..e7482bb 100644 --- a/src/cypherpunks.ru/gogost/gost3410/vko2001.go +++ b/src/cypherpunks.ru/gogost/gost3410/vko2001.go @@ -34,7 +34,7 @@ func (prv *PrivateKey) KEK2001(pub *PublicKey, ukm *big.Int) ([]byte, error) { if err != nil { return nil, err } - h := gost341194.New(&gost28147.GostR3411_94_CryptoProParamSet) + h := gost341194.New(&gost28147.SboxIdGostR341194CryptoProParamSet) h.Write(key) return h.Sum(key[:0]), nil } diff --git a/src/cypherpunks.ru/gogost/gost341194/hash.go b/src/cypherpunks.ru/gogost/gost341194/hash.go index a65a3f5..71cbb87 100644 --- a/src/cypherpunks.ru/gogost/gost341194/hash.go +++ b/src/cypherpunks.ru/gogost/gost341194/hash.go @@ -31,7 +31,7 @@ const ( ) var ( - SboxDefault *gost28147.Sbox = &gost28147.GostR3411_94_TestParamSet + SboxDefault *gost28147.Sbox = &gost28147.SboxIdGostR341194TestParamSet c2 [BlockSize]byte = [BlockSize]byte{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, diff --git a/src/cypherpunks.ru/gogost/gost341194/hash_test.go b/src/cypherpunks.ru/gogost/gost341194/hash_test.go index ea49387..ba38307 100644 --- a/src/cypherpunks.ru/gogost/gost341194/hash_test.go +++ b/src/cypherpunks.ru/gogost/gost341194/hash_test.go @@ -135,7 +135,7 @@ func TestVectors(t *testing.T) { } func TestVectorsCryptoPro(t *testing.T) { - h := New(&gost28147.GostR3411_94_CryptoProParamSet) + h := New(&gost28147.SboxIdGostR341194CryptoProParamSet) if bytes.Compare(h.Sum(nil), []byte{ 0x98, 0x1e, 0x5f, 0x3c, 0xa3, 0x0c, 0x84, 0x14, diff --git a/src/cypherpunks.ru/gogost/gost341194/pbkdf2_test.go b/src/cypherpunks.ru/gogost/gost341194/pbkdf2_test.go index 89f2ccd..8f28022 100644 --- a/src/cypherpunks.ru/gogost/gost341194/pbkdf2_test.go +++ b/src/cypherpunks.ru/gogost/gost341194/pbkdf2_test.go @@ -26,7 +26,7 @@ import ( ) func PBKDF2Hash() hash.Hash { - return New(&gost28147.GostR3411_94_CryptoProParamSet) + return New(&gost28147.SboxIdGostR341194CryptoProParamSet) } // Test vectors for PBKDF2 taken from diff --git a/src/cypherpunks.ru/gogost/gost341264/cipher.go b/src/cypherpunks.ru/gogost/gost341264/cipher.go index b8c4dbd..68a43b8 100644 --- a/src/cypherpunks.ru/gogost/gost341264/cipher.go +++ b/src/cypherpunks.ru/gogost/gost341264/cipher.go @@ -40,7 +40,10 @@ func NewCipher(key [KeySize]byte) *Cipher { keyCompatible[i*4+3] = key[i*4+0] } return &Cipher{ - c: gost28147.NewCipher(*keyCompatible, &gost28147.Gost28147_tc26_ParamZ), + c: gost28147.NewCipher( + *keyCompatible, + &gost28147.SboxIdtc26gost28147paramZ, + ), blk: new([BlockSize]byte), } }