13NAMESPACE_BEGIN(CryptoPP)
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;
90template <
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;
114template <
class T_BlockCipher,
int T_DefaultDigestSize = 16>
Classes for authenticated encryption modes of operation.
Base class for authenticated encryption modes of operation.
Interface for one direction (encryption or decryption) of a block cipher.
CCM block cipher base implementation.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
size_t DefaultKeyLength() const
Returns default key length.
std::string AlgorithmName() const
Provides the name of this algorithm.
size_t GetValidKeyLength(size_t keylength) const
Returns a valid key length for the algorithm.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
unsigned int DigestSize() const
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
bool IsValidKeyLength(size_t keylength) const
Returns whether keylength is a valid key length.
size_t MinKeyLength() const
Returns smallest valid key length.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
bool NeedsPrespecifiedDataLengths() const
Determines if data lengths must be specified prior to inputting data.
size_t MaxKeyLength() const
Returns largest valid key length.
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.
IV_Requirement
Secure IVs requirements as enumerated values.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
word64 lword
Large word type.
Classes for block cipher modes of operation.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
CCM block cipher mode of operation.