7 NAMESPACE_BEGIN(CryptoPP)
14 : m_digestSize(0), m_L(0) {}
18 {
return GetBlockCipher().AlgorithmName() + std::string(
"/CCM");}
20 {
return GetBlockCipher().MinKeyLength();}
22 {
return GetBlockCipher().MaxKeyLength();}
24 {
return GetBlockCipher().DefaultKeyLength();}
26 {
return GetBlockCipher().GetValidKeyLength(n);}
28 {
return GetBlockCipher().IsValidKeyLength(n);}
30 {
return GetBlockCipher().OptimalDataAlignment();}
33 unsigned int IVSize()
const
40 {
return m_digestSize;}
44 {
return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
47 void UncheckedSpecifyDataLengths(lword headerLength, lword messageLength, lword footerLength);
51 bool AuthenticationIsOnPlaintext()
const
53 unsigned int AuthenticationBlockSize()
const
54 {
return GetBlockCipher().BlockSize();}
55 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
56 void Resync(
const byte *iv,
size_t len);
57 size_t AuthenticateBlocks(
const byte *data,
size_t len);
58 void AuthenticateLastHeaderBlock();
59 void AuthenticateLastConfidentialBlock();
60 void AuthenticateLastFooterBlock(byte *mac,
size_t macSize);
64 virtual int DefaultDigestSize()
const =0;
66 const BlockCipher & GetBlockCipher()
const {
return const_cast<CCM_Base *
>(
this)->AccessBlockCipher();};
67 byte *CBC_Buffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
69 enum {REQUIRED_BLOCKSIZE = 16};
70 int m_digestSize, m_L;
71 word64 m_messageLength, m_aadLength;
76 template <
class T_BlockCipher,
int T_DefaultDigestSize,
bool T_IsEncryption>
80 static std::string StaticAlgorithmName()
81 {
return T_BlockCipher::StaticAlgorithmName() + std::string(
"/CCM");}
83 {
return T_IsEncryption;}
86 BlockCipher & AccessBlockCipher() {
return m_cipher;}
87 int DefaultDigestSize()
const {
return T_DefaultDigestSize;}
88 typename T_BlockCipher::Encryption m_cipher;
92 template <
class T_BlockCipher,
int T_DefaultDigestSize = 16>
std::string AlgorithmName() const
returns name of this algorithm, not universally implemented yet
size_t GetValidKeyLength(size_t n) const
returns the smallest valid key length in bytes that is >= min(n, GetMaxKeyLength()) ...
unsigned int MinIVLength() const
returns minimal length of IVs accepted by this object
unsigned int MaxIVLength() const
returns maximal length of IVs accepted by this object
bool IsValidKeyLength(size_t n) const
returns whether n is a valid key length
Each class derived from this one defines two types, Encryption and Decryption, both of which implemen...
interface for one direction (encryption or decryption) of a block cipher
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
lword MaxMessageLength() const
the maximum length of encrypted data
unsigned int OptimalDataAlignment() const
returns how input should be aligned for optimal performance
unsigned int DigestSize() const
size of the hash/digest/MAC returned by Final()
bool IsForwardTransformation() const
returns whether this is an encryption object
interface for retrieving values given their names