19 : m_digestSize(0), m_L(0), m_messageLength(0), m_aadLength(0) {}
23 {
return GetBlockCipher().AlgorithmName() + std::string(
"/CCM");}
25 {
return GetBlockCipher().MinKeyLength();}
27 {
return GetBlockCipher().MaxKeyLength();}
29 {
return GetBlockCipher().DefaultKeyLength();}
31 {
return GetBlockCipher().GetValidKeyLength(n);}
33 {
return GetBlockCipher().IsValidKeyLength(n);}
35 {
return GetBlockCipher().OptimalDataAlignment();}
45 {
return m_digestSize;}
49 {
return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
52 void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
56 bool AuthenticationIsOnPlaintext()
const 58 unsigned int AuthenticationBlockSize()
const 59 {
return GetBlockCipher().BlockSize();}
60 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
61 void Resync(
const byte *iv,
size_t len);
62 size_t AuthenticateBlocks(
const byte *data,
size_t len);
63 void AuthenticateLastHeaderBlock();
64 void AuthenticateLastConfidentialBlock();
65 void AuthenticateLastFooterBlock(byte *mac,
size_t macSize);
69 virtual int DefaultDigestSize()
const =0;
71 const BlockCipher & GetBlockCipher()
const {
return const_cast<CCM_Base *
>(
this)->AccessBlockCipher();};
72 byte *CBC_Buffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
74 enum {REQUIRED_BLOCKSIZE = 16};
75 int m_digestSize, m_L;
76 word64 m_messageLength, m_aadLength;
80 template <
class T_BlockCipher,
int T_DefaultDigestSize,
bool T_IsEncryption>
84 static std::string StaticAlgorithmName()
85 {
return T_BlockCipher::StaticAlgorithmName() + std::string(
"/CCM");}
87 {
return T_IsEncryption;}
90 BlockCipher & AccessBlockCipher() {
return m_cipher;}
91 int DefaultDigestSize()
const {
return T_DefaultDigestSize;}
92 typename T_BlockCipher::Encryption m_cipher;
97 template <
class T_BlockCipher,
int T_DefaultDigestSize = 16>
lword MaxHeaderLength() const
the maximum length of AAD that can be input before the encrypted data
size_t MinKeyLength() const
Returns smallest valid key length in bytes.
Class file for modes of operation.
bool NeedsPrespecifiedDataLengths() const
if this function returns true, SpecifyDataLengths() must be called before attempting to input data ...
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
size_t GetValidKeyLength(size_t n) const
Interface for one direction (encryption or decryption) of a block cipher.
lword MaxMessageLength() const
the maximum length of encrypted data
unsigned int DigestSize() const
Provides the digest size of the hash.
size_t DefaultKeyLength() const
Returns default (recommended) key length in bytes.
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...
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
unsigned int MinIVLength() const
returns minimal length of IVs accepted by this object
std::string AlgorithmName() const
Provides the name of this algorithm.
IV_Requirement
Provides IV requirements as an enumerated value.
size_t MaxKeyLength() const
Returns largest valid key length in bytes.
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Crypto++ library namespace.
unsigned int MaxIVLength() const
returns maximal length of IVs accepted by this object
IV_Requirement IVRequirement() const
returns the minimal requirement for secure IVs
Base classes for working with authenticated encryption modes of encryption.
Interface for retrieving values given their names.