summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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