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>