X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgogost%2Fgost341264%2Fcipher.go;h=813d79da15caeaba0e9d17a8e6285308bec1ef76;hb=69e668f3499122e0b1140f3bd927de41ad279b94;hp=68a43b8d38dba13a3c7571a7c82ed3b4976d1456;hpb=9be6f384bae8ebeabc129ede9f8a597de12835d3;p=gogost.git diff --git a/src/cypherpunks.ru/gogost/gost341264/cipher.go b/src/cypherpunks.ru/gogost/gost341264/cipher.go index 68a43b8..813d79d 100644 --- a/src/cypherpunks.ru/gogost/gost341264/cipher.go +++ b/src/cypherpunks.ru/gogost/gost341264/cipher.go @@ -31,8 +31,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 +43,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), } }