7 NAMESPACE_BEGIN(CryptoPP)
10 enum GCM_TablesOption {GCM_2K_Tables, GCM_64K_Tables};
18 {
return GetBlockCipher().AlgorithmName() + std::string(
"/GCM");}
20 {
return GetBlockCipher().MinKeyLength();}
22 {
return GetBlockCipher().MaxKeyLength();}
24 {
return GetBlockCipher().DefaultKeyLength();}
26 {
return GetBlockCipher().GetValidKeyLength(n);}
28 {
return GetBlockCipher().IsValidKeyLength(n);}
32 unsigned int IVSize()
const
41 {
return (W64LIT(1)<<61)-1;}
43 {
return ((W64LIT(1)<<39)-256)/8;}
47 bool AuthenticationIsOnPlaintext()
const
49 unsigned int AuthenticationBlockSize()
const
50 {
return HASH_BLOCKSIZE;}
51 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
52 void Resync(
const byte *iv,
size_t len);
53 size_t AuthenticateBlocks(
const byte *data,
size_t len);
54 void AuthenticateLastHeaderBlock();
55 void AuthenticateLastConfidentialBlock();
56 void AuthenticateLastFooterBlock(byte *mac,
size_t macSize);
60 virtual GCM_TablesOption GetTablesOption()
const =0;
62 const BlockCipher & GetBlockCipher()
const {
return const_cast<GCM_Base *
>(
this)->AccessBlockCipher();};
63 byte *HashBuffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
64 byte *HashKey() {
return m_buffer+2*REQUIRED_BLOCKSIZE;}
65 byte *MulTable() {
return m_buffer+3*REQUIRED_BLOCKSIZE;}
66 inline void ReverseHashBufferIfNeeded();
71 void IncrementCounterBy256();
75 static word16 s_reductionTable[256];
76 static volatile bool s_reductionTableInitialized;
77 enum {REQUIRED_BLOCKSIZE = 16, HASH_BLOCKSIZE = 16};
81 template <
class T_BlockCipher, GCM_TablesOption T_TablesOption,
bool T_IsEncryption>
85 static std::string StaticAlgorithmName()
86 {
return T_BlockCipher::StaticAlgorithmName() + std::string(
"/GCM");}
88 {
return T_IsEncryption;}
91 GCM_TablesOption GetTablesOption()
const {
return T_TablesOption;}
92 BlockCipher & AccessBlockCipher() {
return m_cipher;}
93 typename T_BlockCipher::Encryption m_cipher;
97 template <
class T_BlockCipher, GCM_TablesOption T_TablesOption=GCM_2K_Tables>