summaryrefslogtreecommitdiff
path: root/seckey.h
diff options
context:
space:
mode:
authorJeffrey Walton <noloader@gmail.com>2017-05-03 22:34:37 -0400
committerJeffrey Walton <noloader@gmail.com>2017-05-03 22:34:37 -0400
commit7131a0fbb827878a3895bddbde75dc866c6ae0f1 (patch)
tree022e27b22e63de855061eea4b334d35cfd23f302 /seckey.h
parent2d9678fa6db28598eb9c7f978491327383aa2d3d (diff)
downloadcryptopp-git-7131a0fbb827878a3895bddbde75dc866c6ae0f1.tar.gz
Add VariableBlockSize constants to FixedBlockSize
This also follows the pattern set forth by FxiedKeyLength and VariableKeyLength
Diffstat (limited to 'seckey.h')
-rw-r--r--seckey.h47
1 files changed, 38 insertions, 9 deletions
diff --git a/seckey.h b/seckey.h
index 323f4d3e..76d73605 100644
--- a/seckey.h
+++ b/seckey.h
@@ -42,6 +42,29 @@ class FixedBlockSize
public:
//! \brief The block size of the algorithm provided as a constant.
CRYPTOPP_CONSTANT(BLOCKSIZE = N)
+ //! \brief The default blocksize for the algorithm provided as a constant.
+ CRYPTOPP_CONSTANT(DEFAULT_BLOCKSIZE = N)
+ //! \brief The minimum blocksize for the algorithm provided as a constant.
+ CRYPTOPP_CONSTANT(MIN_BLOCKSIZE = N)
+ //! \brief The maximum blocksize for the algorithm provided as a constant.
+ CRYPTOPP_CONSTANT(MAX_BLOCKSIZE = N)
+ //! \brief The default block size for the algorithm provided by a static function.
+ //! \param blocksize the block size, in bytes
+ //! \details The default implementation returns BLOCKSIZE. blocksize is unused
+ //! in the default implementation.
+ CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidBlockSize(size_t blocksize)
+ {
+ return CRYPTOPP_UNUSED(blocksize), static_cast<size_t>(BLOCKSIZE);
+ }
+ //! \brief The default block size under a key provided by a static function.
+ //! \param keylength the size of the key, in bytes
+ //! \param blocksize the block size, in bytes
+ //! \details The default implementation returns BLOCKSIZE. blocksize is unused
+ //! in the default implementation.
+ CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidBlockSize(size_t keylength, size_t blocksize)
+ {
+ return CRYPTOPP_UNUSED(keylength), CRYPTOPP_UNUSED(blocksize), static_cast<size_t>(BLOCKSIZE);
+ }
};
// ************** rounds ***************
@@ -125,21 +148,27 @@ class VariableBlockSize
{
public:
//! \brief The default blocksize for the algorithm provided as a constant.
- // 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.
CRYPTOPP_CONSTANT(MIN_BLOCKSIZE = N)
//! \brief The maximum blocksize for the algorithm provided as a constant.
CRYPTOPP_CONSTANT(MAX_BLOCKSIZE = M)
- //! \brief The default blocksize for the algorithm based on key length
- //! provided by a static function.
+ //! \brief The default block size for the algorithm provided by a static function.
+ //! \param blocksize the block size, in bytes
+ //! \details The default implementation returns BLOCKSIZE. blocksize is unused
+ //! in the default implementation.
+ CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidBlockSize(size_t blocksize)
+ {
+ return CRYPTOPP_UNUSED(blocksize), static_cast<size_t>(DEFAULT_BLOCKSIZE);
+ }
+ //! \brief The default block size under a key provided by a static function.
//! \param keylength the size of the key, in bytes
- //! \details keylength is unused in the default implementation.
- CRYPTOPP_STATIC_CONSTEXPR unsigned int StaticGetDefaultBlockSize(size_t keylength)
+ //! \param blocksize the block size, in bytes
+ //! \details The default implementation returns BLOCKSIZE. blocksize is unused
+ //! in the default implementation.
+ CRYPTOPP_STATIC_CONSTEXPR size_t CRYPTOPP_API StaticGetValidBlockSize(size_t keylength, size_t blocksize)
{
- return (keylength >= MAX_BLOCKSIZE) ? MAX_BLOCKSIZE :
- (keylength >= DEFAULT_BLOCKSIZE) ? DEFAULT_BLOCKSIZE : MIN_BLOCKSIZE;
+ return CRYPTOPP_UNUSED(keylength), CRYPTOPP_UNUSED(blocksize), static_cast<size_t>(DEFAULT_BLOCKSIZE);
}
protected:
@@ -440,7 +469,7 @@ class CRYPTOPP_NO_VTABLE VariableBlockCipherImpl : public AlgorithmImpl<SimpleKe
public:
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) {}
+ 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