13 #define CONSTANT_TIME_CARRY(a,b) ((a ^ ((a ^ b) | ((a - b) ^ b))) >> (sizeof(a) * 8 - 1)) 22 m_cipher.SetKey(key, length);
38 m_cipher.ProcessBlock(t.
begin(), nk);
57 size_t rem, num = m_idx;
60 rem = BLOCKSIZE - num;
64 memcpy_s(m_acc + num, BLOCKSIZE - num, input, rem);
65 HashBlocks(m_acc, BLOCKSIZE, 1);
72 memcpy_s(m_acc + num, BLOCKSIZE - num, input, length);
78 rem = length % BLOCKSIZE;
81 if (length >= BLOCKSIZE) {
82 HashBlocks(input, length, 1);
100 r0 = m_r[0]; r1 = m_r[1];
101 r2 = m_r[2]; r3 = m_r[3];
107 h0 = m_h[0]; h1 = m_h[1]; h2 = m_h[2];
108 h3 = m_h[3]; h4 = m_h[4];
110 while (length >= BLOCKSIZE)
114 h1 = (
word32)(d1 = (
word64)h1 + (d0 >> 32) + GetWord<word32>(
false, LITTLE_ENDIAN_ORDER, input + 4));
115 h2 = (
word32)(d2 = (
word64)h2 + (d1 >> 32) + GetWord<word32>(
false, LITTLE_ENDIAN_ORDER, input + 8));
116 h3 = (
word32)(d3 = (
word64)h3 + (d2 >> 32) + GetWord<word32>(
false, LITTLE_ENDIAN_ORDER, input + 12));
117 h4 += (
word32)(d3 >> 32) + padbit;
143 h1 = (
word32)(d1 += d0 >> 32);
144 h2 = (
word32)(d2 += d1 >> 32);
145 h3 = (
word32)(d3 += d2 >> 32);
149 c = (h4 >> 2) + (h4 & ~3U);
161 m_h[0] =
h0; m_h[1] =
h1; m_h[2] =
h2;
162 m_h[3] =
h3; m_h[4] =
h4;
171 ThrowIfInvalidTruncatedSize(size);
177 while (num < BLOCKSIZE)
179 HashBlocks(m_acc, BLOCKSIZE, 0);
182 HashFinal(mac, size);
208 g4 = h4 + (
word32)(t >> 32);
211 mask = 0 - (g4 >> 2);
212 g0 &= mask; g1 &= mask;
213 g2 &= mask; g3 &= mask;
215 h0 = (h0 & mask) | g0; h1 = (h1 & mask) | g1;
216 h2 = (h2 & mask) | g2; h3 = (h3 & mask) | g3;
224 if (size >= BLOCKSIZE)
246 nonceLength == -1 ? nonceLength = BLOCKSIZE : nonceLength;
259 m_h[0] = m_h[1] = m_h[2] = m_h[3] = m_h[4] = 0;
Used to pass byte array input as part of a NameValuePairs object.
virtual void GenerateBlock(byte *output, size_t size)
Generate random array of bytes.
static const std::string s2("AAD")
#define NAMESPACE_BEGIN(x)
Abstract base classes that provide a uniform interface to this library.
void memcpy_s(void *dest, size_t sizeInBytes, const void *src, size_t count)
Bounds checking replacement for memcpy()
void UncheckedSetKey(const byte *key, unsigned int length, const NameValuePairs ¶ms)
Sets the key for this object without performing parameter validation.
size_t size() const
Length of the memory block.
Interface for random number generators.
const byte * begin() const
Pointer to the first byte in the memory block.
void HashFinal(byte *mac, size_t length)
byte order is little-endian
bool GetValue(const char *name, T &value) const
Get a named value.
void TruncatedFinal(byte *mac, size_t size)
Computes the hash of the current message.
AlgorithmParameters MakeParameters(const char *name, const T &value, bool throwIfNotUsed=true)
Create an object that implements NameValuePairs.
Class file for the AES cipher (Rijndael)
T1 SaturatingSubtract(const T1 &a, const T2 &b)
Performs a saturating subtract clamped at 0.
unsigned long long word64
void Resynchronize(const byte *iv, int ivLength=-1)
Resynchronize with an IV.
Poly1305 message authentication code.
void GetNextIV(RandomNumberGenerator &rng, byte *iv)
Retrieves a secure IV for the next message.
#define CRYPTOPP_ASSERT(exp)
Functions for CPU features and intrinsics.
uint8_t const size_t const size
void * memcpy(void *a, const void *b, size_t c)
void HashBlocks(const byte *input, size_t length, word32 padbit)
Classes for Poly1305 message authentication code.
#define CONSTANT_TIME_CARRY(a, b)
void Update(const byte *input, size_t length)
Updates a hash with additional input.
void Restart()
Restart the hash.
Interface for retrieving values given their names.