diff options
author | Jeffrey Walton <noloader@gmail.com> | 2019-10-12 10:41:55 -0400 |
---|---|---|
committer | Jeffrey Walton <noloader@gmail.com> | 2019-10-12 10:41:55 -0400 |
commit | 9eb0d4572dd807ab4a0d6b788381fc04b32f2534 (patch) | |
tree | 054353aae593ca44342778f96cd5b0f0d3f8963c /xts.cpp | |
parent | b91ce07bfbbf53d03ce002b08cf6ef3ea699af5a (diff) | |
download | cryptopp-git-9eb0d4572dd807ab4a0d6b788381fc04b32f2534.tar.gz |
Validate XTS block size when CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS==0
Diffstat (limited to 'xts.cpp')
-rw-r--r-- | xts.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -145,6 +145,12 @@ void XTS_ModeBase::SetKey(const byte *key, size_t length, const NameValuePairs & {
CRYPTOPP_ASSERT(length % 2 == 0);
+#if (CRYPTOPP_XTS_WIDE_BLOCK_CIPHERS == 0)
+ CRYPTOPP_ASSERT(BlockSize() == 16);
+ if (BlockSize() != 16)
+ throw InvalidArgument(AlgorithmName() + ": block size of underlying block cipher is not 16");
+#endif
+
const size_t klen = length/2;
AccessBlockCipher().SetKey(key+0, klen, params);
AccessTweakCipher().SetKey(key+klen, klen, params);
|