22 : m_digestSize(0), m_L(0), m_messageLength(0), m_aadLength(0) {}
26 {
return GetBlockCipher().AlgorithmName() + std::string(
"/CCM");}
28 {
return GetBlockCipher().AlgorithmProvider();}
30 {
return GetBlockCipher().MinKeyLength();}
32 {
return GetBlockCipher().MaxKeyLength();}
34 {
return GetBlockCipher().DefaultKeyLength();}
36 {
return GetBlockCipher().GetValidKeyLength(keylength);}
38 {
return GetBlockCipher().IsValidKeyLength(keylength);}
40 {
return GetBlockCipher().OptimalDataAlignment();}
50 {
return m_digestSize;}
54 {
return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
57 void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
61 bool AuthenticationIsOnPlaintext()
const 63 unsigned int AuthenticationBlockSize()
const 64 {
return GetBlockCipher().BlockSize();}
65 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
66 void Resync(
const byte *iv,
size_t len);
67 size_t AuthenticateBlocks(
const byte *data,
size_t len);
68 void AuthenticateLastHeaderBlock();
69 void AuthenticateLastConfidentialBlock();
70 void AuthenticateLastFooterBlock(byte *mac,
size_t macSize);
74 virtual int DefaultDigestSize()
const =0;
76 const BlockCipher & GetBlockCipher()
const {
return const_cast<CCM_Base *
>(
this)->AccessBlockCipher();}
77 byte *CBC_Buffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
79 enum {REQUIRED_BLOCKSIZE = 16};
80 int m_digestSize, m_L;
81 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;
114 template <
class T_BlockCipher,
int T_DefaultDigestSize = 16>
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
size_t MinKeyLength() const
Returns smallest valid key length.
Classes for block cipher modes of operation.
bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
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.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
unsigned int DigestSize() const
Provides the digest size of the hash.
size_t DefaultKeyLength() const
Returns default key length.
bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
Base class for authenticated encryption modes of operation.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
CCM block cipher base implementation.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
std::string AlgorithmName() const
Provides the name of this algorithm.
IV_Requirement
Secure IVs requirements as enumerated values.
size_t MaxKeyLength() const
Returns largest valid key length.
size_t GetValidKeyLength(size_t keylength) const
Returns a valid key length for the algorithm.
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Crypto++ library namespace.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
Classes for authenticated encryption modes of operation.
CCM block cipher final implementation.
Interface for retrieving values given their names.