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>
std::string AlgorithmName() const
Provides the name of this algorithm.
size_t GetValidKeyLength(size_t n) const
unsigned int MinIVLength() const
returns minimal length of IVs accepted by this object
Class file for modes of operation.
unsigned int MaxIVLength() const
returns maximal length of IVs accepted by this object
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
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
if this function returns true, SpecifyDataLengths() must be called before attempting to input data ...
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode...
size_t MinKeyLength() const
Returns smallest valid key length in bytes.
size_t MaxKeyLength() const
Returns largest valid key length in bytes.
IV_Requirement IVRequirement() const
returns the minimal requirement for secure IVs
lword MaxHeaderLength() const
the maximum length of AAD that can be input before the encrypted data
IV_Requirement
Provides IV requirements as an enumerated value.
lword MaxMessageLength() const
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.
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Interface for retrieving values given their names.