//
// 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
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]
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),
}
}