summaryrefslogtreecommitdiff
path: root/seckey.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-03 21:06:49 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-03 21:06:49 -0400
commit2d9678fa6db28598eb9c7f978491327383aa2d3d (patch)
tree1eb751b26e995eb856e23aa8d2d6bbc247445f8d /seckey.h
parentca9e788fbfada9c47cb1933c10ddf8d4c8b746c9 (diff)
downloadcryptopp-git-2d9678fa6db28598eb9c7f978491327383aa2d3d.tar.gz
Remove BLOCKSIZE from VariableBlockSize (Issue 408)
VariableBlockSize and VariableBlockCipherImpl were added at Commit bd8edfa87b579073. Reflecting on FixedKeyLength and VariableKeyLength, the const KEYLENGTH is only provided by FixedKeyLength. VariableKeyLength provides DEFAULT_KEYLENGTH. This check-in makes VariableBlockSize follow VariableKeyLength. This check-in also splits block size and iv length. Its conceivable we will encounter a cipher with a block size of 128-bits with an iv of 256-bits. The bd8edfa87b579073 check-in could not handle the difference, so we fix it now.
Diffstat (limited to 'seckey.h')
-rw-r--r--seckey.h13
1 files changed, 7 insertions, 6 deletions
diff --git a/seckey.h b/seckey.h
index dcf28fbe..323f4d3e 100644
--- a/seckey.h
+++ b/seckey.h
@@ -125,7 +125,7 @@ class VariableBlockSize
{
public:
//! \brief The default blocksize for the algorithm provided as a constant.
- CRYPTOPP_CONSTANT(BLOCKSIZE = D)
+ // CRYPTOPP_CONSTANT(BLOCKSIZE = D)
//! \brief The default blocksize for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(DEFAULT_BLOCKSIZE = D)
//! \brief The minimum blocksize for the algorithm provided as a constant.
@@ -438,13 +438,14 @@ template <class INFO, class BASE = BlockCipher>
class CRYPTOPP_NO_VTABLE VariableBlockCipherImpl : public AlgorithmImpl<SimpleKeyingInterfaceImpl<TwoBases<BASE, INFO> > >
{
public:
- VariableBlockCipherImpl() : m_blocksize(0) {}
- VariableBlockCipherImpl(unsigned int blocksize) : m_blocksize(blocksize) {}
+ VariableBlockCipherImpl() : m_blocksize(0), m_ivlength(0) {}
+ VariableBlockCipherImpl(unsigned int blockSize) : m_blocksize(blockSize), m_ivlength(blockSize) {}
+ VariableBlockCipherImpl(unsigned int blockSize, unsigned int ivLength) : m_blocksize(blocksize), m_ivlength(ivLength) {}
//! Provides the block size of the algorithm
//! \returns the block size, in bytes
unsigned int BlockSize() const {
- return m_blocksize ? m_blocksize : this->BLOCKSIZE;
+ return m_blocksize ? m_blocksize : this->DEFAULT_BLOCKSIZE;
}
//! Provides the initialization vector length of the algorithm
@@ -452,11 +453,11 @@ public:
unsigned int IVSize() const {
if (!this->IsResynchronizable())
throw NotImplemented(this->GetAlgorithm().AlgorithmName() + ": this object doesn't support resynchronization");
- return m_blocksize ? m_blocksize : this->IV_LENGTH;
+ return m_ivlength ? m_ivlength : this->IV_LENGTH;
}
protected:
- unsigned int m_blocksize;
+ unsigned int m_blocksize, m_ivlength;
};
//! \class BlockCipherFinal