7 NAMESPACE_BEGIN(CryptoPP)
14 : m_digestSize(0), m_L(0) {}
17 std::string AlgorithmName()
const
18 {
return GetBlockCipher().AlgorithmName() + std::string(
"/CCM");}
19 size_t MinKeyLength()
const
20 {
return GetBlockCipher().MinKeyLength();}
21 size_t MaxKeyLength()
const
22 {
return GetBlockCipher().MaxKeyLength();}
23 size_t DefaultKeyLength()
const
24 {
return GetBlockCipher().DefaultKeyLength();}
25 size_t GetValidKeyLength(
size_t n)
const
26 {
return GetBlockCipher().GetValidKeyLength(n);}
27 bool IsValidKeyLength(
size_t n)
const
28 {
return GetBlockCipher().IsValidKeyLength(n);}
29 unsigned int OptimalDataAlignment()
const
30 {
return GetBlockCipher().OptimalDataAlignment();}
31 IV_Requirement IVRequirement()
const
33 unsigned int IVSize()
const
35 unsigned int MinIVLength()
const
37 unsigned int MaxIVLength()
const
39 unsigned int DigestSize()
const
40 {
return m_digestSize;}
41 lword MaxHeaderLength()
const
43 lword MaxMessageLength()
const
44 {
return m_L<8 ? (W64LIT(1)<<(8*m_L))-1 : W64LIT(0)-1;}
45 bool NeedsPrespecifiedDataLengths()
const
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>