summaryrefslogtreecommitdiff
path: root/simple.h
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 /simple.h
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 'simple.h')
-rw-r--r--simple.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/simple.h b/simple.h
index 2b92d343..8be4d422 100644
--- a/simple.h
+++ b/simple.h
@@ -58,6 +58,14 @@ public:
explicit InvalidRounds(const std::string &algorithm, unsigned int rounds) : InvalidArgument(algorithm + ": " + IntToString(rounds) + " is not a valid number of rounds") {}
};
+//! \class InvalidBlockSize
+//! \brief Exception thrown when an invalid block size is encountered
+class CRYPTOPP_DLL InvalidBlockSize : public InvalidArgument
+{
+public:
+ explicit InvalidBlockSize(const std::string &algorithm, size_t length) : InvalidArgument(algorithm + ": " + IntToString(length) + " is not a valid block size") {}
+};
+
//! \class InvalidPersonalizationLength
//! \brief Exception thrown when an invalid personalization string length is encountered
class CRYPTOPP_DLL InvalidPersonalizationLength : public InvalidArgument