15#if CRYPTOPP_BOOL_X32 || defined(CRYPTOPP_DISABLE_MIXED_ASM)
16# define CRYPTOPP_DISABLE_GCM_ASM 1
37 {
return GetBlockCipher().AlgorithmName() + std::string(
"/GCM");}
39 {
return GetBlockCipher().AlgorithmProvider();}
41 {
return GetBlockCipher().MinKeyLength();}
43 {
return GetBlockCipher().MaxKeyLength();}
45 {
return GetBlockCipher().DefaultKeyLength();}
47 {
return GetBlockCipher().GetValidKeyLength(n);}
49 {
return GetBlockCipher().IsValidKeyLength(n);}
62 {
return (
W64LIT(1)<<61)-1;}
64 {
return ((
W64LIT(1)<<39)-256)/8;}
68 bool AuthenticationIsOnPlaintext()
const
70 unsigned int AuthenticationBlockSize()
const
71 {
return HASH_BLOCKSIZE;}
72 void SetKeyWithoutResync(
const byte *userKey,
size_t keylength,
const NameValuePairs ¶ms);
73 void Resync(
const byte *iv,
size_t len);
74 size_t AuthenticateBlocks(
const byte *data,
size_t len);
75 void AuthenticateLastHeaderBlock();
76 void AuthenticateLastConfidentialBlock();
77 void AuthenticateLastFooterBlock(
byte *mac,
size_t macSize);
83 const BlockCipher & GetBlockCipher()
const {
return const_cast<GCM_Base *
>(
this)->AccessBlockCipher();}
84 byte *HashBuffer() {
return m_buffer+REQUIRED_BLOCKSIZE;}
85 byte *HashKey() {
return m_buffer+2*REQUIRED_BLOCKSIZE;}
86 byte *MulTable() {
return m_buffer+3*REQUIRED_BLOCKSIZE;}
87 inline void ReverseHashBufferIfNeeded();
92 void IncrementCounterBy256();
96 static word16 s_reductionTable[256];
97 static volatile bool s_reductionTableInitialized;
98 enum {REQUIRED_BLOCKSIZE = 16, HASH_BLOCKSIZE = 16};
106template <
class T_BlockCipher, GCM_TablesOption T_TablesOption,
bool T_IsEncryption>
110 static std::string StaticAlgorithmName()
111 {
return T_BlockCipher::StaticAlgorithmName() + std::string(
"/GCM");}
113 {
return T_IsEncryption;}
117 BlockCipher & AccessBlockCipher() {
return m_cipher;}
118 typename T_BlockCipher::Encryption m_cipher;
130template <
class T_BlockCipher, GCM_TablesOption T_TablesOption=GCM_2K_Tables>
Classes for authenticated encryption modes of operation.
Base class for authenticated encryption modes of operation.
Interface for one direction (encryption or decryption) of a block cipher.
GCM block cipher base implementation.
unsigned int OptimalDataAlignment() const
Provides input and output data alignment for optimal performance.
size_t MinKeyLength() const
Returns smallest valid key length.
std::string AlgorithmName() const
Provides the name of this algorithm.
unsigned int IVSize() const
Returns length of the IV accepted by this object.
lword MaxMessageLength() const
Provides the maximum length of encrypted data.
size_t MaxKeyLength() const
Returns largest valid key length.
lword MaxHeaderLength() const
Provides the maximum length of AAD that can be input.
bool IsValidKeyLength(size_t n) const
Returns whether keylength is a valid key length.
unsigned int DigestSize() const
Provides the digest size of the hash.
size_t GetValidKeyLength(size_t n) const
Returns a valid key length for the algorithm.
size_t DefaultKeyLength() const
Returns default key length.
IV_Requirement IVRequirement() const
Minimal requirement for secure IVs.
unsigned int MaxIVLength() const
Provides the maximum size of an IV.
std::string AlgorithmProvider() const
Retrieve the provider of this algorithm.
unsigned int MinIVLength() const
Provides the minimum size of an IV.
GCM block cipher final implementation.
bool IsForwardTransformation() const
Determines if the cipher is being operated in its forward direction.
Interface for retrieving values given their names.
IV_Requirement
Secure IVs requirements as enumerated values.
@ UNIQUE_IV
The IV must be unique.
Interface for one direction (encryption or decryption) of a stream cipher or cipher mode.
#define W64LIT(x)
Declare an unsigned word64.
unsigned short word16
16-bit unsigned datatype
word64 lword
Large word type.
GCM_TablesOption
GCM table size options.
@ GCM_2K_Tables
Use a table with 2K entries.
@ GCM_64K_Tables
Use a table with 64K entries.
Classes for block cipher modes of operation.
Crypto++ library namespace.
Provides Encryption and Decryption typedefs used by derived classes to implement an authenticated enc...
GCM block cipher mode of operation.