5 #ifndef CRYPTOPP_IMPORTS 13 unsigned int blockSize = AuthenticationBlockSize();
14 unsigned int &num = m_bufferedDataLength;
15 byte* data = m_buffer.begin();
19 if (num+len >= blockSize)
21 memcpy(data+num, input, blockSize-num);
22 AuthenticateBlocks(data, blockSize);
23 input += (blockSize-num);
24 len -= (blockSize-num);
30 memcpy(data+num, input, len);
31 num += (
unsigned int)len;
39 size_t leftOver = AuthenticateBlocks(input, len);
40 input += (len - leftOver);
44 memcpy(data, input, len);
45 num = (
unsigned int)len;
50 m_bufferedDataLength = 0;
51 m_state = State_Start;
53 SetKeyWithoutResync(userKey, keylength, params);
54 m_state = State_KeySet;
57 const byte *iv = GetIVAndThrowIfInvalid(params, length);
64 if (m_state < State_KeySet)
67 m_bufferedDataLength = 0;
68 m_totalHeaderLength = m_totalMessageLength = m_totalFooterLength = 0;
69 m_state = State_KeySet;
71 Resync(iv, this->ThrowIfInvalidIVLength(length));
72 m_state = State_IVSet;
86 AuthenticateData(input, length);
87 m_totalHeaderLength += length;
89 case State_AuthUntransformed:
90 case State_AuthTransformed:
91 AuthenticateLastConfidentialBlock();
92 m_bufferedDataLength = 0;
93 m_state = State_AuthFooter;
95 case State_AuthFooter:
96 AuthenticateData(input, length);
97 m_totalFooterLength += length;
106 m_totalMessageLength += length;
116 case State_AuthFooter:
119 AuthenticateLastHeaderBlock();
120 m_bufferedDataLength = 0;
121 m_state = AuthenticationIsOnPlaintext()==
IsForwardTransformation() ? State_AuthUntransformed : State_AuthTransformed;
123 case State_AuthUntransformed:
124 AuthenticateData(inString, length);
125 AccessSymmetricCipher().
ProcessData(outString, inString, length);
127 case State_AuthTransformed:
128 AccessSymmetricCipher().
ProcessData(outString, inString, length);
129 AuthenticateData(outString, length);
144 throw InvalidArgument(
AlgorithmName() +
": additional authenticated data (AAD) cannot be input after data to be encrypted or decrypted");
156 AuthenticateLastHeaderBlock();
157 m_bufferedDataLength = 0;
160 case State_AuthUntransformed:
161 case State_AuthTransformed:
162 AuthenticateLastConfidentialBlock();
163 m_bufferedDataLength = 0;
166 case State_AuthFooter:
167 AuthenticateLastFooterBlock(mac, macSize);
168 m_bufferedDataLength = 0;
175 m_state = State_KeySet;
An invalid argument was detected.
void ProcessData(byte *outString, const byte *inString, size_t length)
Encrypt or decrypt an array of bytes.
this indicates that a member function was called in the wrong state, for example trying to encrypt a ...
void Resynchronize(const byte *iv, int length=-1)
resynchronize with an IV. ivLength=-1 means use IVSize()
virtual lword MaxMessageLength() const =0
the maximum length of encrypted data
virtual lword MaxFooterLength() const
the maximum length of AAD that can be input after the encrypted data
void SetKey(const byte *userKey, size_t keylength, const NameValuePairs ¶ms)
Sets or reset the key of this object.
virtual std::string AlgorithmName() const =0
Provides the name of this algorithm.
void Update(const byte *input, size_t length)
Updates a hash with additional input.
std::string IntToString(T value, unsigned int base=10)
Converts a value to a string.
Crypto++ library namespace.
void TruncatedFinal(byte *mac, size_t macSize)
Computes the hash of the current message.
virtual lword MaxHeaderLength() const =0
the maximum length of AAD that can be input before the encrypted data
Base classes for working with authenticated encryption modes of encryption.
Interface for retrieving values given their names.