23 : m_digestSize(0), m_L(0), m_messageLength(0), m_aadLength(0) {}
27 {
return GetBlockCipher().AlgorithmName() + std::string(
"/CCM");}
29 {
return GetBlockCipher().MinKeyLength();}
31 {
return GetBlockCipher().MaxKeyLength();}
33 {
return GetBlockCipher().DefaultKeyLength();}
35 {
return GetBlockCipher().GetValidKeyLength(n);}
37 {
return GetBlockCipher().IsValidKeyLength(n);}
39 {
return GetBlockCipher().OptimalDataAlignment();}
49 {
return m_digestSize;}
53 {
return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
56 void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
60 bool AuthenticationIsOnPlaintext()
const 62 unsigned int AuthenticationBlockSize()
const 63 {
return GetBlockCipher().BlockSize();}
64 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
65 void Resync(
const byte *iv,
size_t len);
66 size_t AuthenticateBlocks(
const byte *data,
size_t len);
67 void AuthenticateLastHeaderBlock();
68 void AuthenticateLastConfidentialBlock();
69 void AuthenticateLastFooterBlock(byte *mac,
size_t macSize);
73 virtual int DefaultDigestSize()
const =0;
75 const BlockCipher & GetBlockCipher()
const {
return const_cast<CCM_Base *
>(
this)->AccessBlockCipher();};
76 byte *CBC_Buffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
78 enum {REQUIRED_BLOCKSIZE = 16};
79 int m_digestSize, m_L;
80 word64 m_messageLength, m_aadLength;
90 template <
class T_BlockCipher,
int T_DefaultDigestSize,
bool T_IsEncryption>
94 static std::string StaticAlgorithmName()
95 {
return T_BlockCipher::StaticAlgorithmName() + std::string(
"/CCM");}
97 {
return T_IsEncryption;}
100 BlockCipher & AccessBlockCipher() {
return m_cipher;}
101 int DefaultDigestSize()
const {
return T_DefaultDigestSize;}
102 typename T_BlockCipher::Encryption m_cipher;
113 template <
class T_BlockCipher,
int T_DefaultDigestSize = 16>
std::string AlgorithmName() const
Provides the name of this algorithm.
size_t GetValidKeyLength(size_t n) const
unsigned int MinIVLength() const
Provides the minimum size of an IV.
Class file for modes of operation.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
CCM block cipher mode of operation.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
Interface for one direction (encryption or decryption) of a block cipher.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
size_t DefaultKeyLength() const
Returns default (recommended) key length in bytes.
bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Base implementation for one direction (encryption or decryption) of a stream cipher or block cipher m...
size_t MinKeyLength() const
Returns smallest valid key length in bytes.
size_t MaxKeyLength() const
Returns largest valid key length in bytes.
CCM block cipher base implementation.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
IV_Requirement
Secure IVs requirements as enumerated values.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
Crypto++ library namespace.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Base classes for working with authenticated encryption modes of encryption.
unsigned int DigestSize() const
Provides the digest size of the hash.
CCM block cipher final implementation.
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Interface for retrieving values given their names.