diff options
author | Jeffrey Walton <noloader@gmail.com> | 2017-05-13 16:28:05 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2017-05-13 16:28:05 -0400 |
commit | e226523b05b5d6ab99f68961246091fbc28195e9 (patch) | |
tree | 5fb0b29e4ed831d5b0f1e4f2bd754e0a42eca217 /cmac.cpp | |
parent | 0611e1150778dec829b5bc42e20641356bbca9fa (diff) | |
download | cryptopp-git-e226523b05b5d6ab99f68961246091fbc28195e9.tar.gz |
Call cipher.SetKey() before cipher.BlockSize() (Issue 408)
Variable block size ciphers need the key set before they can return an accurate size for BlockSize(). This issue surfaced during Kalyna testing with authenticated encryption modes. In particular, EAX mode, which effectively uses CMAC:
AlgorithmParameters params = MakeParameters(Name::BlockSize(), 64)
(Name::IV(), ConstByteArrayParameter((const byte *)iv, 64));
EAX<Kalyna>::Encryption kalyna;
kalyna.SetKey(key, 64, params);
Diffstat (limited to 'cmac.cpp')
-rw-r--r-- | cmac.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
@@ -43,9 +43,9 @@ static void MulU(byte *k, unsigned int length) void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
{
BlockCipher &cipher = AccessCipher();
- unsigned int blockSize = cipher.BlockSize();
-
cipher.SetKey(key, length, params);
+
+ unsigned int blockSize = cipher.BlockSize();
m_reg.CleanNew(3*blockSize);
m_counter = 0;
|