X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost341264%2Fcipher.go;h=53a27920b8009a602b5be3a4dfd0fd3b5107128d;hb=91562b3cf4aad503c493aa7b69abfbb07b46e63a;hp=68a43b8d38dba13a3c7571a7c82ed3b4976d1456;hpb=bfe87fc2ae85dce7cf14b0e03603544eafa7d130;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost341264/cipher.go b/src/cypherpunks.ru/gogost/gost341264/cipher.go index 68a43b8..53a2792 100644 --- a/src/cypherpunks.ru/gogost/gost341264/cipher.go +++ b/src/cypherpunks.ru/gogost/gost341264/cipher.go @@ -3,8 +3,7 @@ // // 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 -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. +// the Free Software Foundation, version 3 of the License. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -31,8 +30,11 @@ type Cipher struct { blk *[BlockSize]byte } -func NewCipher(key [KeySize]byte) *Cipher { - keyCompatible := new([KeySize]byte) +func NewCipher(key []byte) *Cipher { + if len(key) != KeySize { + panic("invalid key size") + } + keyCompatible := make([]byte, KeySize) for i := 0; i < KeySize/4; i++ { keyCompatible[i*4+0] = key[i*4+3] keyCompatible[i*4+1] = key[i*4+2] @@ -40,10 +42,7 @@ func NewCipher(key [KeySize]byte) *Cipher { keyCompatible[i*4+3] = key[i*4+0] } return &Cipher{ - c: gost28147.NewCipher( - *keyCompatible, - &gost28147.SboxIdtc26gost28147paramZ, - ), + c: gost28147.NewCipher(keyCompatible, &gost28147.SboxIdtc26gost28147paramZ), blk: new([BlockSize]byte), } }