summaryrefslogtreecommitdiff
path: root/cryptlib.cpp
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-01 16:23:57 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-01 16:23:57 -0400
commitbd8edfa87b579073ead850f6ed19973381620cd3 (patch)
tree366a6048c2fdfdedcc7eb13f89392733c1a4ef0f /cryptlib.cpp
parent1543649ead50f2c1a0cdb2a3a8134d0cbcc81098 (diff)
downloadcryptopp-git-bd8edfa87b579073ead850f6ed19973381620cd3.tar.gz
Add variable block size support for block ciphers
This should lead the way for more modern block ciphers like Threefish and Kalyna. It tested well with both regular cipher modes (the mode has an instance of the cipher) and external cipher modes (the cipher and mode are distinct objects, and the mode holds a reference to the cipher). We still have to work out the details of naming a cipher. For example, Kalyna with a 128-bit key can use a 128-bit or 256-bit block size. Kalyna-128 is not enough to describe the algorithm and locate it in the object registry. Kalyna-128-128 looks kind of weird; maybe Kalyna-128(128) or Kalyna-128(256) would be better. Here are the initial test cases to verify functionality: byte key[64] = {}, iv[32] = {}; ECB_Mode<Kalyna>::Encryption enc1; enc1.SetKey(key, 16); CBC_Mode<Kalyna>::Encryption enc2; enc2.SetKeyWithIV(key, 16, iv); AlgorithmParameters params = MakeParameters (Name::BlockSize(), 32) (Name::IV(), ConstByteArrayParameter(iv, 32)); CTR_Mode<Kalyna>::Encryption enc3; enc3.SetKey(key, 16, params); CBC_Mode<Kalyna>::Encryption enc4; enc4.SetKey(key, 32, params); Kalyna::Encryption enc5; ECB_Mode_ExternalCipher::Encryption ecb(enc5); ecb.SetKey(key, 16, params); Kalyna::Encryption enc6; ECB_Mode_ExternalCipher::Encryption cbc(enc6); cbc.SetKey(key, 32, params);
Diffstat (limited to 'cryptlib.cpp')
-rw-r--r--cryptlib.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/cryptlib.cpp b/cryptlib.cpp
index 19ea1c6a..8920d356 100644
--- a/cryptlib.cpp
+++ b/cryptlib.cpp
@@ -71,7 +71,7 @@ Algorithm::Algorithm(bool checkSelfTestStatus)
void SimpleKeyingInterface::SetKey(const byte *key, size_t length, const NameValuePairs &params)
{
this->ThrowIfInvalidKeyLength(length);
- this->UncheckedSetKey(key, (unsigned int)length, params);
+ this->UncheckedSetKey(key, static_cast<unsigned int>(length), params);
}
void SimpleKeyingInterface::SetKeyWithRounds(const byte *key, size_t length, int rounds)
@@ -127,7 +127,7 @@ const byte * SimpleKeyingInterface::GetIVAndThrowIfInvalid(const NameValuePairs
{
iv = ivWithLength.begin();
ThrowIfInvalidIV(iv);
- size = ThrowIfInvalidIVLength((int)ivWithLength.size());
+ size = ThrowIfInvalidIVLength(static_cast<int>(ivWithLength.size()));
return iv;
}
else if (params.GetValue(Name::IV(), iv))