summaryrefslogtreecommitdiff
path: root/cmac.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-13 16:28:05 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-13 16:28:05 -0400
commite226523b05b5d6ab99f68961246091fbc28195e9 (patch)
tree5fb0b29e4ed831d5b0f1e4f2bd754e0a42eca217 /cmac.cpp
parent0611e1150778dec829b5bc42e20641356bbca9fa (diff)
downloadcryptopp-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.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/cmac.cpp b/cmac.cpp
index 09ce4d31..f8570a7f 100644
--- a/cmac.cpp
+++ b/cmac.cpp
@@ -43,9 +43,9 @@ static void MulU(byte *k, unsigned int length)
void CMAC_Base::UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs &params)
{
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;