diff --git a/AES128_8cpp_source.html b/AES128_8cpp_source.html index e9eb144b..fe98732d 100644 --- a/AES128_8cpp_source.html +++ b/AES128_8cpp_source.html @@ -175,7 +175,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AES192_8cpp_source.html b/AES192_8cpp_source.html index 2c8c31c6..006d315d 100644 --- a/AES192_8cpp_source.html +++ b/AES192_8cpp_source.html @@ -175,7 +175,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AES256_8cpp_source.html b/AES256_8cpp_source.html index 1891597a..7dcc7563 100644 --- a/AES256_8cpp_source.html +++ b/AES256_8cpp_source.html @@ -182,7 +182,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AESCommon_8cpp_source.html b/AESCommon_8cpp_source.html index f6cbf811..b1aa21ef 100644 --- a/AESCommon_8cpp_source.html +++ b/AESCommon_8cpp_source.html @@ -415,7 +415,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AES_8h_source.html b/AES_8h_source.html index 0591c8aa..9021ad6e 100644 --- a/AES_8h_source.html +++ b/AES_8h_source.html @@ -203,7 +203,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AuthenticatedCipher_8cpp_source.html b/AuthenticatedCipher_8cpp_source.html index 02090343..4113a82e 100644 --- a/AuthenticatedCipher_8cpp_source.html +++ b/AuthenticatedCipher_8cpp_source.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/AuthenticatedCipher_8h_source.html b/AuthenticatedCipher_8h_source.html index a70acac7..0551d88b 100644 --- a/AuthenticatedCipher_8h_source.html +++ b/AuthenticatedCipher_8h_source.html @@ -141,7 +141,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2b_8cpp_source.html b/BLAKE2b_8cpp_source.html index 08c46185..9eb05a53 100644 --- a/BLAKE2b_8cpp_source.html +++ b/BLAKE2b_8cpp_source.html @@ -117,221 +117,255 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
27 #include "utility/ProgMemUtil.h"
28 #include <string.h>
29 
-
47 BLAKE2b::BLAKE2b()
-
48 {
-
49  reset();
-
50 }
-
51 
-
56 BLAKE2b::~BLAKE2b()
-
57 {
-
58  clean(state);
-
59 }
-
60 
-
61 size_t BLAKE2b::hashSize() const
-
62 {
-
63  return 64;
-
64 }
-
65 
-
66 size_t BLAKE2b::blockSize() const
-
67 {
-
68  return 128;
-
69 }
-
70 
-
71 // Initialization vectors for BLAKE2b.
-
72 #define BLAKE2b_IV0 0x6a09e667f3bcc908ULL
-
73 #define BLAKE2b_IV1 0xbb67ae8584caa73bULL
-
74 #define BLAKE2b_IV2 0x3c6ef372fe94f82bULL
-
75 #define BLAKE2b_IV3 0xa54ff53a5f1d36f1ULL
-
76 #define BLAKE2b_IV4 0x510e527fade682d1ULL
-
77 #define BLAKE2b_IV5 0x9b05688c2b3e6c1fULL
-
78 #define BLAKE2b_IV6 0x1f83d9abfb41bd6bULL
-
79 #define BLAKE2b_IV7 0x5be0cd19137e2179ULL
-
80 
-
81 void BLAKE2b::reset()
-
82 {
-
83  state.h[0] = BLAKE2b_IV0 ^ 0x01010040; // Default output length of 64.
-
84  state.h[1] = BLAKE2b_IV1;
-
85  state.h[2] = BLAKE2b_IV2;
-
86  state.h[3] = BLAKE2b_IV3;
-
87  state.h[4] = BLAKE2b_IV4;
-
88  state.h[5] = BLAKE2b_IV5;
-
89  state.h[6] = BLAKE2b_IV6;
-
90  state.h[7] = BLAKE2b_IV7;
-
91  state.chunkSize = 0;
-
92  state.lengthLow = 0;
-
93  state.lengthHigh = 0;
-
94 }
-
95 
-
103 void BLAKE2b::reset(uint8_t outputLength)
-
104 {
-
105  state.h[0] = BLAKE2b_IV0 ^ 0x01010000 ^ outputLength;
-
106  state.h[1] = BLAKE2b_IV1;
-
107  state.h[2] = BLAKE2b_IV2;
-
108  state.h[3] = BLAKE2b_IV3;
-
109  state.h[4] = BLAKE2b_IV4;
-
110  state.h[5] = BLAKE2b_IV5;
-
111  state.h[6] = BLAKE2b_IV6;
-
112  state.h[7] = BLAKE2b_IV7;
-
113  state.chunkSize = 0;
-
114  state.lengthLow = 0;
-
115  state.lengthHigh = 0;
-
116 }
-
117 
-
118 void BLAKE2b::update(const void *data, size_t len)
-
119 {
-
120  // Break the input up into 1024-bit chunks and process each in turn.
-
121  const uint8_t *d = (const uint8_t *)data;
-
122  while (len > 0) {
-
123  if (state.chunkSize == 128) {
-
124  // Previous chunk was full and we know that it wasn't the
-
125  // last chunk, so we can process it now with f0 set to zero.
-
126  processChunk(0);
-
127  state.chunkSize = 0;
-
128  }
-
129  uint8_t size = 128 - state.chunkSize;
-
130  if (size > len)
-
131  size = len;
-
132  memcpy(((uint8_t *)state.m) + state.chunkSize, d, size);
-
133  state.chunkSize += size;
-
134  uint64_t temp = state.lengthLow;
-
135  state.lengthLow += size;
-
136  if (state.lengthLow < temp)
-
137  ++state.lengthHigh;
-
138  len -= size;
-
139  d += size;
-
140  }
-
141 }
-
142 
-
143 void BLAKE2b::finalize(void *hash, size_t len)
-
144 {
-
145  // Pad the last chunk and hash it with f0 set to all-ones.
-
146  memset(((uint8_t *)state.m) + state.chunkSize, 0, 128 - state.chunkSize);
-
147  processChunk(0xFFFFFFFFFFFFFFFFULL);
-
148 
-
149  // Convert the hash into little-endian in the message buffer.
-
150  for (uint8_t posn = 0; posn < 8; ++posn)
-
151  state.m[posn] = htole64(state.h[posn]);
-
152 
-
153  // Copy the hash to the caller's return buffer.
-
154  if (len > 64)
-
155  len = 64;
-
156  memcpy(hash, state.m, len);
-
157 }
-
158 
-
159 void BLAKE2b::clear()
-
160 {
-
161  clean(state);
-
162  reset();
-
163 }
-
164 
-
165 void BLAKE2b::resetHMAC(const void *key, size_t keyLen)
-
166 {
-
167  formatHMACKey(state.m, key, keyLen, 0x36);
-
168  state.lengthLow += 128;
-
169  processChunk(0);
-
170 }
-
171 
-
172 void BLAKE2b::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
-
173 {
-
174  uint8_t temp[64];
-
175  finalize(temp, sizeof(temp));
-
176  formatHMACKey(state.m, key, keyLen, 0x5C);
-
177  state.lengthLow += 128;
-
178  processChunk(0);
-
179  update(temp, sizeof(temp));
-
180  finalize(hash, hashLen);
-
181  clean(temp);
-
182 }
-
183 
-
184 // Permutation on the message input state for BLAKE2b.
-
185 static const uint8_t sigma[12][16] PROGMEM = {
-
186  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
-
187  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
-
188  {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
-
189  { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8},
-
190  { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13},
-
191  { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9},
-
192  {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11},
-
193  {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10},
-
194  { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5},
-
195  {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0},
-
196  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
-
197  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
-
198 };
-
199 
-
200 // Perform a BLAKE2b quarter round operation.
-
201 #define quarterRound(a, b, c, d, i) \
-
202  do { \
-
203  uint64_t _b = (b); \
-
204  uint64_t _a = (a) + _b + state.m[pgm_read_byte(&(sigma[index][2 * (i)]))]; \
-
205  uint64_t _d = rightRotate32_64((d) ^ _a); \
-
206  uint64_t _c = (c) + _d; \
-
207  _b = rightRotate24_64(_b ^ _c); \
-
208  _a += _b + state.m[pgm_read_byte(&(sigma[index][2 * (i) + 1]))]; \
-
209  (d) = _d = rightRotate16_64(_d ^ _a); \
-
210  _c += _d; \
-
211  (a) = _a; \
-
212  (b) = rightRotate63_64(_b ^ _c); \
-
213  (c) = _c; \
-
214  } while (0)
-
215 
-
216 void BLAKE2b::processChunk(uint64_t f0)
-
217 {
-
218  uint8_t index;
-
219  uint64_t v[16];
-
220 
-
221  // Byte-swap the message buffer into little-endian if necessary.
-
222 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
223  for (index = 0; index < 16; ++index)
-
224  state.m[index] = le64toh(state.m[index]);
-
225 #endif
-
226 
-
227  // Format the block to be hashed.
-
228  memcpy(v, state.h, sizeof(state.h));
-
229  v[8] = BLAKE2b_IV0;
-
230  v[9] = BLAKE2b_IV1;
-
231  v[10] = BLAKE2b_IV2;
-
232  v[11] = BLAKE2b_IV3;
-
233  v[12] = BLAKE2b_IV4 ^ state.lengthLow;
-
234  v[13] = BLAKE2b_IV5 ^ state.lengthHigh;
-
235  v[14] = BLAKE2b_IV6 ^ f0;
-
236  v[15] = BLAKE2b_IV7;
-
237 
-
238  // Perform the 12 BLAKE2b rounds.
-
239  for (index = 0; index < 12; ++index) {
-
240  // Column round.
-
241  quarterRound(v[0], v[4], v[8], v[12], 0);
-
242  quarterRound(v[1], v[5], v[9], v[13], 1);
-
243  quarterRound(v[2], v[6], v[10], v[14], 2);
-
244  quarterRound(v[3], v[7], v[11], v[15], 3);
+
75 BLAKE2b::BLAKE2b()
+
76 {
+
77  reset();
+
78 }
+
79 
+
84 BLAKE2b::~BLAKE2b()
+
85 {
+
86  clean(state);
+
87 }
+
88 
+
89 size_t BLAKE2b::hashSize() const
+
90 {
+
91  return 64;
+
92 }
+
93 
+
94 size_t BLAKE2b::blockSize() const
+
95 {
+
96  return 128;
+
97 }
+
98 
+
99 // Initialization vectors for BLAKE2b.
+
100 #define BLAKE2b_IV0 0x6a09e667f3bcc908ULL
+
101 #define BLAKE2b_IV1 0xbb67ae8584caa73bULL
+
102 #define BLAKE2b_IV2 0x3c6ef372fe94f82bULL
+
103 #define BLAKE2b_IV3 0xa54ff53a5f1d36f1ULL
+
104 #define BLAKE2b_IV4 0x510e527fade682d1ULL
+
105 #define BLAKE2b_IV5 0x9b05688c2b3e6c1fULL
+
106 #define BLAKE2b_IV6 0x1f83d9abfb41bd6bULL
+
107 #define BLAKE2b_IV7 0x5be0cd19137e2179ULL
+
108 
+
109 void BLAKE2b::reset()
+
110 {
+
111  state.h[0] = BLAKE2b_IV0 ^ 0x01010040; // Default output length of 64.
+
112  state.h[1] = BLAKE2b_IV1;
+
113  state.h[2] = BLAKE2b_IV2;
+
114  state.h[3] = BLAKE2b_IV3;
+
115  state.h[4] = BLAKE2b_IV4;
+
116  state.h[5] = BLAKE2b_IV5;
+
117  state.h[6] = BLAKE2b_IV6;
+
118  state.h[7] = BLAKE2b_IV7;
+
119  state.chunkSize = 0;
+
120  state.lengthLow = 0;
+
121  state.lengthHigh = 0;
+
122 }
+
123 
+
131 void BLAKE2b::reset(uint8_t outputLength)
+
132 {
+
133  if (outputLength < 1)
+
134  outputLength = 1;
+
135  else if (outputLength > 64)
+
136  outputLength = 64;
+
137  state.h[0] = BLAKE2b_IV0 ^ 0x01010000 ^ outputLength;
+
138  state.h[1] = BLAKE2b_IV1;
+
139  state.h[2] = BLAKE2b_IV2;
+
140  state.h[3] = BLAKE2b_IV3;
+
141  state.h[4] = BLAKE2b_IV4;
+
142  state.h[5] = BLAKE2b_IV5;
+
143  state.h[6] = BLAKE2b_IV6;
+
144  state.h[7] = BLAKE2b_IV7;
+
145  state.chunkSize = 0;
+
146  state.lengthLow = 0;
+
147  state.lengthHigh = 0;
+
148 }
+
149 
+
162 void BLAKE2b::reset(const void *key, size_t keyLen, uint8_t outputLength)
+
163 {
+
164  if (keyLen > 64)
+
165  keyLen = 64;
+
166  if (outputLength < 1)
+
167  outputLength = 1;
+
168  else if (outputLength > 64)
+
169  outputLength = 64;
+
170  state.h[0] = BLAKE2b_IV0 ^ 0x01010000 ^ (keyLen << 8) ^ outputLength;
+
171  state.h[1] = BLAKE2b_IV1;
+
172  state.h[2] = BLAKE2b_IV2;
+
173  state.h[3] = BLAKE2b_IV3;
+
174  state.h[4] = BLAKE2b_IV4;
+
175  state.h[5] = BLAKE2b_IV5;
+
176  state.h[6] = BLAKE2b_IV6;
+
177  state.h[7] = BLAKE2b_IV7;
+
178  if (keyLen > 0) {
+
179  // Set the first block to the key and pad with zeroes.
+
180  memcpy(state.m, key, keyLen);
+
181  memset(((uint8_t *)state.m) + keyLen, 0, 128 - keyLen);
+
182  state.chunkSize = 128;
+
183  state.lengthLow = 128;
+
184  } else {
+
185  // No key. The first data block is the first hashed block.
+
186  state.chunkSize = 0;
+
187  state.lengthLow = 0;
+
188  }
+
189  state.lengthHigh = 0;
+
190 }
+
191 
+
192 void BLAKE2b::update(const void *data, size_t len)
+
193 {
+
194  // Break the input up into 1024-bit chunks and process each in turn.
+
195  const uint8_t *d = (const uint8_t *)data;
+
196  while (len > 0) {
+
197  if (state.chunkSize == 128) {
+
198  // Previous chunk was full and we know that it wasn't the
+
199  // last chunk, so we can process it now with f0 set to zero.
+
200  processChunk(0);
+
201  state.chunkSize = 0;
+
202  }
+
203  uint8_t size = 128 - state.chunkSize;
+
204  if (size > len)
+
205  size = len;
+
206  memcpy(((uint8_t *)state.m) + state.chunkSize, d, size);
+
207  state.chunkSize += size;
+
208  uint64_t temp = state.lengthLow;
+
209  state.lengthLow += size;
+
210  if (state.lengthLow < temp)
+
211  ++state.lengthHigh;
+
212  len -= size;
+
213  d += size;
+
214  }
+
215 }
+
216 
+
217 void BLAKE2b::finalize(void *hash, size_t len)
+
218 {
+
219  // Pad the last chunk and hash it with f0 set to all-ones.
+
220  memset(((uint8_t *)state.m) + state.chunkSize, 0, 128 - state.chunkSize);
+
221  processChunk(0xFFFFFFFFFFFFFFFFULL);
+
222 
+
223  // Convert the hash into little-endian in the message buffer.
+
224  for (uint8_t posn = 0; posn < 8; ++posn)
+
225  state.m[posn] = htole64(state.h[posn]);
+
226 
+
227  // Copy the hash to the caller's return buffer.
+
228  if (len > 64)
+
229  len = 64;
+
230  memcpy(hash, state.m, len);
+
231 }
+
232 
+
233 void BLAKE2b::clear()
+
234 {
+
235  clean(state);
+
236  reset();
+
237 }
+
238 
+
239 void BLAKE2b::resetHMAC(const void *key, size_t keyLen)
+
240 {
+
241  formatHMACKey(state.m, key, keyLen, 0x36);
+
242  state.lengthLow += 128;
+
243  processChunk(0);
+
244 }
245 
-
246  // Diagonal round.
-
247  quarterRound(v[0], v[5], v[10], v[15], 4);
-
248  quarterRound(v[1], v[6], v[11], v[12], 5);
-
249  quarterRound(v[2], v[7], v[8], v[13], 6);
-
250  quarterRound(v[3], v[4], v[9], v[14], 7);
-
251  }
-
252 
-
253  // Combine the new and old hash values.
-
254  for (index = 0; index < 8; ++index)
-
255  state.h[index] ^= (v[index] ^ v[index + 8]);
+
246 void BLAKE2b::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
+
247 {
+
248  uint8_t temp[64];
+
249  finalize(temp, sizeof(temp));
+
250  formatHMACKey(state.m, key, keyLen, 0x5C);
+
251  state.lengthLow += 128;
+
252  processChunk(0);
+
253  update(temp, sizeof(temp));
+
254  finalize(hash, hashLen);
+
255  clean(temp);
256 }
-
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:143
-
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:81
-
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:159
-
BLAKE2b::BLAKE2b
BLAKE2b()
Constructs a BLAKE2b hash object.
Definition: BLAKE2b.cpp:47
-
BLAKE2b::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2b.cpp:66
-
BLAKE2b::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2b.cpp:61
-
BLAKE2b::~BLAKE2b
virtual ~BLAKE2b()
Destroys this BLAKE2b hash object after clearing sensitive information.
Definition: BLAKE2b.cpp:56
-
BLAKE2b::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2b.cpp:118
+
257 
+
258 // Permutation on the message input state for BLAKE2b.
+
259 static const uint8_t sigma[12][16] PROGMEM = {
+
260  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
+
261  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
+
262  {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
+
263  { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8},
+
264  { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13},
+
265  { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9},
+
266  {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11},
+
267  {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10},
+
268  { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5},
+
269  {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0},
+
270  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
+
271  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
+
272 };
+
273 
+
274 // Perform a BLAKE2b quarter round operation.
+
275 #define quarterRound(a, b, c, d, i) \
+
276  do { \
+
277  uint64_t _b = (b); \
+
278  uint64_t _a = (a) + _b + state.m[pgm_read_byte(&(sigma[index][2 * (i)]))]; \
+
279  uint64_t _d = rightRotate32_64((d) ^ _a); \
+
280  uint64_t _c = (c) + _d; \
+
281  _b = rightRotate24_64(_b ^ _c); \
+
282  _a += _b + state.m[pgm_read_byte(&(sigma[index][2 * (i) + 1]))]; \
+
283  (d) = _d = rightRotate16_64(_d ^ _a); \
+
284  _c += _d; \
+
285  (a) = _a; \
+
286  (b) = rightRotate63_64(_b ^ _c); \
+
287  (c) = _c; \
+
288  } while (0)
+
289 
+
290 void BLAKE2b::processChunk(uint64_t f0)
+
291 {
+
292  uint8_t index;
+
293  uint64_t v[16];
+
294 
+
295  // Byte-swap the message buffer into little-endian if necessary.
+
296 #if !defined(CRYPTO_LITTLE_ENDIAN)
+
297  for (index = 0; index < 16; ++index)
+
298  state.m[index] = le64toh(state.m[index]);
+
299 #endif
+
300 
+
301  // Format the block to be hashed.
+
302  memcpy(v, state.h, sizeof(state.h));
+
303  v[8] = BLAKE2b_IV0;
+
304  v[9] = BLAKE2b_IV1;
+
305  v[10] = BLAKE2b_IV2;
+
306  v[11] = BLAKE2b_IV3;
+
307  v[12] = BLAKE2b_IV4 ^ state.lengthLow;
+
308  v[13] = BLAKE2b_IV5 ^ state.lengthHigh;
+
309  v[14] = BLAKE2b_IV6 ^ f0;
+
310  v[15] = BLAKE2b_IV7;
+
311 
+
312  // Perform the 12 BLAKE2b rounds.
+
313  for (index = 0; index < 12; ++index) {
+
314  // Column round.
+
315  quarterRound(v[0], v[4], v[8], v[12], 0);
+
316  quarterRound(v[1], v[5], v[9], v[13], 1);
+
317  quarterRound(v[2], v[6], v[10], v[14], 2);
+
318  quarterRound(v[3], v[7], v[11], v[15], 3);
+
319 
+
320  // Diagonal round.
+
321  quarterRound(v[0], v[5], v[10], v[15], 4);
+
322  quarterRound(v[1], v[6], v[11], v[12], 5);
+
323  quarterRound(v[2], v[7], v[8], v[13], 6);
+
324  quarterRound(v[3], v[4], v[9], v[14], 7);
+
325  }
+
326 
+
327  // Combine the new and old hash values.
+
328  for (index = 0; index < 8; ++index)
+
329  state.h[index] ^= (v[index] ^ v[index + 8]);
+
330 }
+
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:217
+
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:109
+
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:233
+
BLAKE2b::BLAKE2b
BLAKE2b()
Constructs a BLAKE2b hash object.
Definition: BLAKE2b.cpp:75
+
BLAKE2b::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2b.cpp:94
+
BLAKE2b::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2b.cpp:89
+
BLAKE2b::~BLAKE2b
virtual ~BLAKE2b()
Destroys this BLAKE2b hash object after clearing sensitive information.
Definition: BLAKE2b.cpp:84
+
BLAKE2b::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2b.cpp:192
Bitmap::data
uint8_t * data()
Returns a pointer to the start of the bitmap's data buffer.
Definition: Bitmap.h:53
-
BLAKE2b::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2b.cpp:165
+
BLAKE2b::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2b.cpp:239
Hash::formatHMACKey
void formatHMACKey(void *block, const void *key, size_t len, uint8_t pad)
Formats a HMAC key into a block.
Definition: Hash.cpp:162
-
BLAKE2b::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2b.cpp:172
+
BLAKE2b::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2b.cpp:246
diff --git a/BLAKE2b_8h_source.html b/BLAKE2b_8h_source.html index 2af01e28..e7a728f0 100644 --- a/BLAKE2b_8h_source.html +++ b/BLAKE2b_8h_source.html @@ -126,43 +126,45 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
36 
37  void reset();
38  void reset(uint8_t outputLength);
-
39  void update(const void *data, size_t len);
-
40  void finalize(void *hash, size_t len);
-
41 
-
42  void clear();
+
39  void reset(const void *key, size_t keyLen, uint8_t outputLength = 64);
+
40 
+
41  void update(const void *data, size_t len);
+
42  void finalize(void *hash, size_t len);
43 
-
44  void resetHMAC(const void *key, size_t keyLen);
-
45  void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen);
-
46 
-
47 private:
-
48  struct {
-
49  uint64_t h[8];
-
50  uint64_t m[16];
-
51  uint64_t lengthLow;
-
52  uint64_t lengthHigh;
-
53  uint8_t chunkSize;
-
54  } state;
-
55 
-
56  void processChunk(uint64_t f0);
-
57 };
-
58 
-
59 #endif
-
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:143
-
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:81
-
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:159
-
BLAKE2b::BLAKE2b
BLAKE2b()
Constructs a BLAKE2b hash object.
Definition: BLAKE2b.cpp:47
-
BLAKE2b::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2b.cpp:66
+
44  void clear();
+
45 
+
46  void resetHMAC(const void *key, size_t keyLen);
+
47  void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen);
+
48 
+
49 private:
+
50  struct {
+
51  uint64_t h[8];
+
52  uint64_t m[16];
+
53  uint64_t lengthLow;
+
54  uint64_t lengthHigh;
+
55  uint8_t chunkSize;
+
56  } state;
+
57 
+
58  void processChunk(uint64_t f0);
+
59 };
+
60 
+
61 #endif
+
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:217
+
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:109
+
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:233
+
BLAKE2b::BLAKE2b
BLAKE2b()
Constructs a BLAKE2b hash object.
Definition: BLAKE2b.cpp:75
+
BLAKE2b::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2b.cpp:94
Hash
Abstract base class for cryptographic hash algorithms.
Definition: Hash.h:29
BLAKE2b
BLAKE2b hash algorithm.
Definition: BLAKE2b.h:28
-
BLAKE2b::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2b.cpp:61
-
BLAKE2b::~BLAKE2b
virtual ~BLAKE2b()
Destroys this BLAKE2b hash object after clearing sensitive information.
Definition: BLAKE2b.cpp:56
-
BLAKE2b::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2b.cpp:118
-
BLAKE2b::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2b.cpp:165
-
BLAKE2b::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2b.cpp:172
+
BLAKE2b::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2b.cpp:89
+
BLAKE2b::~BLAKE2b
virtual ~BLAKE2b()
Destroys this BLAKE2b hash object after clearing sensitive information.
Definition: BLAKE2b.cpp:84
+
BLAKE2b::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2b.cpp:192
+
BLAKE2b::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2b.cpp:239
+
BLAKE2b::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2b.cpp:246
diff --git a/BLAKE2s_8cpp_source.html b/BLAKE2s_8cpp_source.html index c3332aca..dcd3d3d4 100644 --- a/BLAKE2s_8cpp_source.html +++ b/BLAKE2s_8cpp_source.html @@ -117,213 +117,246 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
27 #include "utility/ProgMemUtil.h"
28 #include <string.h>
29 
-
47 BLAKE2s::BLAKE2s()
-
48 {
-
49  reset();
-
50 }
-
51 
-
56 BLAKE2s::~BLAKE2s()
-
57 {
-
58  clean(state);
-
59 }
-
60 
-
61 size_t BLAKE2s::hashSize() const
-
62 {
-
63  return 32;
-
64 }
-
65 
-
66 size_t BLAKE2s::blockSize() const
-
67 {
-
68  return 64;
-
69 }
-
70 
-
71 // Initialization vectors for BLAKE2s.
-
72 #define BLAKE2s_IV0 0x6A09E667
-
73 #define BLAKE2s_IV1 0xBB67AE85
-
74 #define BLAKE2s_IV2 0x3C6EF372
-
75 #define BLAKE2s_IV3 0xA54FF53A
-
76 #define BLAKE2s_IV4 0x510E527F
-
77 #define BLAKE2s_IV5 0x9B05688C
-
78 #define BLAKE2s_IV6 0x1F83D9AB
-
79 #define BLAKE2s_IV7 0x5BE0CD19
-
80 
-
81 void BLAKE2s::reset()
-
82 {
-
83  state.h[0] = BLAKE2s_IV0 ^ 0x01010020; // Default output length of 32.
-
84  state.h[1] = BLAKE2s_IV1;
-
85  state.h[2] = BLAKE2s_IV2;
-
86  state.h[3] = BLAKE2s_IV3;
-
87  state.h[4] = BLAKE2s_IV4;
-
88  state.h[5] = BLAKE2s_IV5;
-
89  state.h[6] = BLAKE2s_IV6;
-
90  state.h[7] = BLAKE2s_IV7;
-
91  state.chunkSize = 0;
-
92  state.length = 0;
-
93 }
-
94 
-
102 void BLAKE2s::reset(uint8_t outputLength)
-
103 {
-
104  state.h[0] = BLAKE2s_IV0 ^ 0x01010000 ^ outputLength;
-
105  state.h[1] = BLAKE2s_IV1;
-
106  state.h[2] = BLAKE2s_IV2;
-
107  state.h[3] = BLAKE2s_IV3;
-
108  state.h[4] = BLAKE2s_IV4;
-
109  state.h[5] = BLAKE2s_IV5;
-
110  state.h[6] = BLAKE2s_IV6;
-
111  state.h[7] = BLAKE2s_IV7;
-
112  state.chunkSize = 0;
-
113  state.length = 0;
-
114 }
-
115 
-
116 void BLAKE2s::update(const void *data, size_t len)
-
117 {
-
118  // Break the input up into 512-bit chunks and process each in turn.
-
119  const uint8_t *d = (const uint8_t *)data;
-
120  while (len > 0) {
-
121  if (state.chunkSize == 64) {
-
122  // Previous chunk was full and we know that it wasn't the
-
123  // last chunk, so we can process it now with f0 set to zero.
-
124  processChunk(0);
-
125  state.chunkSize = 0;
-
126  }
-
127  uint8_t size = 64 - state.chunkSize;
-
128  if (size > len)
-
129  size = len;
-
130  memcpy(((uint8_t *)state.m) + state.chunkSize, d, size);
-
131  state.chunkSize += size;
-
132  state.length += size;
-
133  len -= size;
-
134  d += size;
-
135  }
-
136 }
-
137 
-
138 void BLAKE2s::finalize(void *hash, size_t len)
-
139 {
-
140  // Pad the last chunk and hash it with f0 set to all-ones.
-
141  memset(((uint8_t *)state.m) + state.chunkSize, 0, 64 - state.chunkSize);
-
142  processChunk(0xFFFFFFFF);
-
143 
-
144  // Convert the hash into little-endian in the message buffer.
-
145  for (uint8_t posn = 0; posn < 8; ++posn)
-
146  state.m[posn] = htole32(state.h[posn]);
+
75 BLAKE2s::BLAKE2s()
+
76 {
+
77  reset();
+
78 }
+
79 
+
84 BLAKE2s::~BLAKE2s()
+
85 {
+
86  clean(state);
+
87 }
+
88 
+
89 size_t BLAKE2s::hashSize() const
+
90 {
+
91  return 32;
+
92 }
+
93 
+
94 size_t BLAKE2s::blockSize() const
+
95 {
+
96  return 64;
+
97 }
+
98 
+
99 // Initialization vectors for BLAKE2s.
+
100 #define BLAKE2s_IV0 0x6A09E667
+
101 #define BLAKE2s_IV1 0xBB67AE85
+
102 #define BLAKE2s_IV2 0x3C6EF372
+
103 #define BLAKE2s_IV3 0xA54FF53A
+
104 #define BLAKE2s_IV4 0x510E527F
+
105 #define BLAKE2s_IV5 0x9B05688C
+
106 #define BLAKE2s_IV6 0x1F83D9AB
+
107 #define BLAKE2s_IV7 0x5BE0CD19
+
108 
+
109 void BLAKE2s::reset()
+
110 {
+
111  state.h[0] = BLAKE2s_IV0 ^ 0x01010020; // Default output length of 32.
+
112  state.h[1] = BLAKE2s_IV1;
+
113  state.h[2] = BLAKE2s_IV2;
+
114  state.h[3] = BLAKE2s_IV3;
+
115  state.h[4] = BLAKE2s_IV4;
+
116  state.h[5] = BLAKE2s_IV5;
+
117  state.h[6] = BLAKE2s_IV6;
+
118  state.h[7] = BLAKE2s_IV7;
+
119  state.chunkSize = 0;
+
120  state.length = 0;
+
121 }
+
122 
+
130 void BLAKE2s::reset(uint8_t outputLength)
+
131 {
+
132  if (outputLength < 1)
+
133  outputLength = 1;
+
134  else if (outputLength > 32)
+
135  outputLength = 32;
+
136  state.h[0] = BLAKE2s_IV0 ^ 0x01010000 ^ outputLength;
+
137  state.h[1] = BLAKE2s_IV1;
+
138  state.h[2] = BLAKE2s_IV2;
+
139  state.h[3] = BLAKE2s_IV3;
+
140  state.h[4] = BLAKE2s_IV4;
+
141  state.h[5] = BLAKE2s_IV5;
+
142  state.h[6] = BLAKE2s_IV6;
+
143  state.h[7] = BLAKE2s_IV7;
+
144  state.chunkSize = 0;
+
145  state.length = 0;
+
146 }
147 
-
148  // Copy the hash to the caller's return buffer.
-
149  if (len > 32)
-
150  len = 32;
-
151  memcpy(hash, state.m, len);
-
152 }
-
153 
-
154 void BLAKE2s::clear()
-
155 {
-
156  clean(state);
-
157  reset();
-
158 }
-
159 
-
160 void BLAKE2s::resetHMAC(const void *key, size_t keyLen)
+
160 void BLAKE2s::reset(const void *key, size_t keyLen, uint8_t outputLength)
161 {
-
162  formatHMACKey(state.m, key, keyLen, 0x36);
-
163  state.length += 64;
-
164  processChunk(0);
-
165 }
-
166 
-
167 void BLAKE2s::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
-
168 {
-
169  uint8_t temp[32];
-
170  finalize(temp, sizeof(temp));
-
171  formatHMACKey(state.m, key, keyLen, 0x5C);
-
172  state.length += 64;
-
173  processChunk(0);
-
174  update(temp, sizeof(temp));
-
175  finalize(hash, hashLen);
-
176  clean(temp);
-
177 }
-
178 
-
179 // Permutation on the message input state for BLAKE2s.
-
180 static const uint8_t sigma[10][16] PROGMEM = {
-
181  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
-
182  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
-
183  {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
-
184  { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8},
-
185  { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13},
-
186  { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9},
-
187  {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11},
-
188  {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10},
-
189  { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5},
-
190  {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0}
-
191 };
-
192 
-
193 // Perform a BLAKE2s quarter round operation.
-
194 #define quarterRound(a, b, c, d, i) \
-
195  do { \
-
196  uint32_t _b = (b); \
-
197  uint32_t _a = (a) + _b + state.m[pgm_read_byte(&(sigma[index][2 * (i)]))]; \
-
198  uint32_t _d = rightRotate16((d) ^ _a); \
-
199  uint32_t _c = (c) + _d; \
-
200  _b = rightRotate12(_b ^ _c); \
-
201  _a += _b + state.m[pgm_read_byte(&(sigma[index][2 * (i) + 1]))]; \
-
202  (d) = _d = rightRotate8(_d ^ _a); \
-
203  _c += _d; \
-
204  (a) = _a; \
-
205  (b) = rightRotate7(_b ^ _c); \
-
206  (c) = _c; \
-
207  } while (0)
-
208 
-
209 void BLAKE2s::processChunk(uint32_t f0)
-
210 {
-
211  uint8_t index;
-
212  uint32_t v[16];
-
213 
-
214  // Byte-swap the message buffer into little-endian if necessary.
-
215 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
216  for (index = 0; index < 16; ++index)
-
217  state.m[index] = le32toh(state.m[index]);
-
218 #endif
-
219 
-
220  // Format the block to be hashed.
-
221  memcpy(v, state.h, sizeof(state.h));
-
222  v[8] = BLAKE2s_IV0;
-
223  v[9] = BLAKE2s_IV1;
-
224  v[10] = BLAKE2s_IV2;
-
225  v[11] = BLAKE2s_IV3;
-
226  v[12] = BLAKE2s_IV4 ^ (uint32_t)(state.length);
-
227  v[13] = BLAKE2s_IV5 ^ (uint32_t)(state.length >> 32);
-
228  v[14] = BLAKE2s_IV6 ^ f0;
-
229  v[15] = BLAKE2s_IV7;
-
230 
-
231  // Perform the 10 BLAKE2s rounds.
-
232  for (index = 0; index < 10; ++index) {
-
233  // Column round.
-
234  quarterRound(v[0], v[4], v[8], v[12], 0);
-
235  quarterRound(v[1], v[5], v[9], v[13], 1);
-
236  quarterRound(v[2], v[6], v[10], v[14], 2);
-
237  quarterRound(v[3], v[7], v[11], v[15], 3);
-
238 
-
239  // Diagonal round.
-
240  quarterRound(v[0], v[5], v[10], v[15], 4);
-
241  quarterRound(v[1], v[6], v[11], v[12], 5);
-
242  quarterRound(v[2], v[7], v[8], v[13], 6);
-
243  quarterRound(v[3], v[4], v[9], v[14], 7);
-
244  }
-
245 
-
246  // Combine the new and old hash values.
-
247  for (index = 0; index < 8; ++index)
-
248  state.h[index] ^= (v[index] ^ v[index + 8]);
-
249 }
-
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:56
-
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:61
-
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:154
-
BLAKE2s::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2s.cpp:81
-
BLAKE2s::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2s.cpp:66
-
BLAKE2s::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2s.cpp:116
-
BLAKE2s::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2s.cpp:160
-
BLAKE2s::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2s.cpp:138
-
BLAKE2s::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2s.cpp:167
-
BLAKE2s::BLAKE2s
BLAKE2s()
Constructs a BLAKE2s hash object.
Definition: BLAKE2s.cpp:47
+
162  if (keyLen > 32)
+
163  keyLen = 32;
+
164  if (outputLength < 1)
+
165  outputLength = 1;
+
166  else if (outputLength > 32)
+
167  outputLength = 32;
+
168  state.h[0] = BLAKE2s_IV0 ^ 0x01010000 ^ (keyLen << 8) ^ outputLength;
+
169  state.h[1] = BLAKE2s_IV1;
+
170  state.h[2] = BLAKE2s_IV2;
+
171  state.h[3] = BLAKE2s_IV3;
+
172  state.h[4] = BLAKE2s_IV4;
+
173  state.h[5] = BLAKE2s_IV5;
+
174  state.h[6] = BLAKE2s_IV6;
+
175  state.h[7] = BLAKE2s_IV7;
+
176  if (keyLen > 0) {
+
177  // Set the first block to the key and pad with zeroes.
+
178  memcpy(state.m, key, keyLen);
+
179  memset(((uint8_t *)state.m) + keyLen, 0, 64 - keyLen);
+
180  state.chunkSize = 64;
+
181  state.length = 64;
+
182  } else {
+
183  // No key. The first data block is the first hashed block.
+
184  state.chunkSize = 0;
+
185  state.length = 0;
+
186  }
+
187 }
+
188 
+
189 void BLAKE2s::update(const void *data, size_t len)
+
190 {
+
191  // Break the input up into 512-bit chunks and process each in turn.
+
192  const uint8_t *d = (const uint8_t *)data;
+
193  while (len > 0) {
+
194  if (state.chunkSize == 64) {
+
195  // Previous chunk was full and we know that it wasn't the
+
196  // last chunk, so we can process it now with f0 set to zero.
+
197  processChunk(0);
+
198  state.chunkSize = 0;
+
199  }
+
200  uint8_t size = 64 - state.chunkSize;
+
201  if (size > len)
+
202  size = len;
+
203  memcpy(((uint8_t *)state.m) + state.chunkSize, d, size);
+
204  state.chunkSize += size;
+
205  state.length += size;
+
206  len -= size;
+
207  d += size;
+
208  }
+
209 }
+
210 
+
211 void BLAKE2s::finalize(void *hash, size_t len)
+
212 {
+
213  // Pad the last chunk and hash it with f0 set to all-ones.
+
214  memset(((uint8_t *)state.m) + state.chunkSize, 0, 64 - state.chunkSize);
+
215  processChunk(0xFFFFFFFF);
+
216 
+
217  // Convert the hash into little-endian in the message buffer.
+
218  for (uint8_t posn = 0; posn < 8; ++posn)
+
219  state.m[posn] = htole32(state.h[posn]);
+
220 
+
221  // Copy the hash to the caller's return buffer.
+
222  if (len > 32)
+
223  len = 32;
+
224  memcpy(hash, state.m, len);
+
225 }
+
226 
+
227 void BLAKE2s::clear()
+
228 {
+
229  clean(state);
+
230  reset();
+
231 }
+
232 
+
233 void BLAKE2s::resetHMAC(const void *key, size_t keyLen)
+
234 {
+
235  formatHMACKey(state.m, key, keyLen, 0x36);
+
236  state.length += 64;
+
237  processChunk(0);
+
238 }
+
239 
+
240 void BLAKE2s::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
+
241 {
+
242  uint8_t temp[32];
+
243  finalize(temp, sizeof(temp));
+
244  formatHMACKey(state.m, key, keyLen, 0x5C);
+
245  state.length += 64;
+
246  processChunk(0);
+
247  update(temp, sizeof(temp));
+
248  finalize(hash, hashLen);
+
249  clean(temp);
+
250 }
+
251 
+
252 // Permutation on the message input state for BLAKE2s.
+
253 static const uint8_t sigma[10][16] PROGMEM = {
+
254  { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15},
+
255  {14, 10, 4, 8, 9, 15, 13, 6, 1, 12, 0, 2, 11, 7, 5, 3},
+
256  {11, 8, 12, 0, 5, 2, 15, 13, 10, 14, 3, 6, 7, 1, 9, 4},
+
257  { 7, 9, 3, 1, 13, 12, 11, 14, 2, 6, 5, 10, 4, 0, 15, 8},
+
258  { 9, 0, 5, 7, 2, 4, 10, 15, 14, 1, 11, 12, 6, 8, 3, 13},
+
259  { 2, 12, 6, 10, 0, 11, 8, 3, 4, 13, 7, 5, 15, 14, 1, 9},
+
260  {12, 5, 1, 15, 14, 13, 4, 10, 0, 7, 6, 3, 9, 2, 8, 11},
+
261  {13, 11, 7, 14, 12, 1, 3, 9, 5, 0, 15, 4, 8, 6, 2, 10},
+
262  { 6, 15, 14, 9, 11, 3, 0, 8, 12, 2, 13, 7, 1, 4, 10, 5},
+
263  {10, 2, 8, 4, 7, 6, 1, 5, 15, 11, 9, 14, 3, 12, 13 , 0}
+
264 };
+
265 
+
266 // Perform a BLAKE2s quarter round operation.
+
267 #define quarterRound(a, b, c, d, i) \
+
268  do { \
+
269  uint32_t _b = (b); \
+
270  uint32_t _a = (a) + _b + state.m[pgm_read_byte(&(sigma[index][2 * (i)]))]; \
+
271  uint32_t _d = rightRotate16((d) ^ _a); \
+
272  uint32_t _c = (c) + _d; \
+
273  _b = rightRotate12(_b ^ _c); \
+
274  _a += _b + state.m[pgm_read_byte(&(sigma[index][2 * (i) + 1]))]; \
+
275  (d) = _d = rightRotate8(_d ^ _a); \
+
276  _c += _d; \
+
277  (a) = _a; \
+
278  (b) = rightRotate7(_b ^ _c); \
+
279  (c) = _c; \
+
280  } while (0)
+
281 
+
282 void BLAKE2s::processChunk(uint32_t f0)
+
283 {
+
284  uint8_t index;
+
285  uint32_t v[16];
+
286 
+
287  // Byte-swap the message buffer into little-endian if necessary.
+
288 #if !defined(CRYPTO_LITTLE_ENDIAN)
+
289  for (index = 0; index < 16; ++index)
+
290  state.m[index] = le32toh(state.m[index]);
+
291 #endif
+
292 
+
293  // Format the block to be hashed.
+
294  memcpy(v, state.h, sizeof(state.h));
+
295  v[8] = BLAKE2s_IV0;
+
296  v[9] = BLAKE2s_IV1;
+
297  v[10] = BLAKE2s_IV2;
+
298  v[11] = BLAKE2s_IV3;
+
299  v[12] = BLAKE2s_IV4 ^ (uint32_t)(state.length);
+
300  v[13] = BLAKE2s_IV5 ^ (uint32_t)(state.length >> 32);
+
301  v[14] = BLAKE2s_IV6 ^ f0;
+
302  v[15] = BLAKE2s_IV7;
+
303 
+
304  // Perform the 10 BLAKE2s rounds.
+
305  for (index = 0; index < 10; ++index) {
+
306  // Column round.
+
307  quarterRound(v[0], v[4], v[8], v[12], 0);
+
308  quarterRound(v[1], v[5], v[9], v[13], 1);
+
309  quarterRound(v[2], v[6], v[10], v[14], 2);
+
310  quarterRound(v[3], v[7], v[11], v[15], 3);
+
311 
+
312  // Diagonal round.
+
313  quarterRound(v[0], v[5], v[10], v[15], 4);
+
314  quarterRound(v[1], v[6], v[11], v[12], 5);
+
315  quarterRound(v[2], v[7], v[8], v[13], 6);
+
316  quarterRound(v[3], v[4], v[9], v[14], 7);
+
317  }
+
318 
+
319  // Combine the new and old hash values.
+
320  for (index = 0; index < 8; ++index)
+
321  state.h[index] ^= (v[index] ^ v[index + 8]);
+
322 }
+
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:84
+
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:89
+
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:227
+
BLAKE2s::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2s.cpp:109
+
BLAKE2s::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2s.cpp:94
+
BLAKE2s::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2s.cpp:189
+
BLAKE2s::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2s.cpp:233
+
BLAKE2s::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2s.cpp:211
+
BLAKE2s::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2s.cpp:240
+
BLAKE2s::BLAKE2s
BLAKE2s()
Constructs a BLAKE2s hash object.
Definition: BLAKE2s.cpp:75
Hash::formatHMACKey
void formatHMACKey(void *block, const void *key, size_t len, uint8_t pad)
Formats a HMAC key into a block.
Definition: Hash.cpp:162
diff --git a/BLAKE2s_8h_source.html b/BLAKE2s_8h_source.html index 2dbe53bf..ba3be186 100644 --- a/BLAKE2s_8h_source.html +++ b/BLAKE2s_8h_source.html @@ -126,42 +126,44 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
36 
37  void reset();
38  void reset(uint8_t outputLength);
-
39  void update(const void *data, size_t len);
-
40  void finalize(void *hash, size_t len);
-
41 
-
42  void clear();
+
39  void reset(const void *key, size_t keyLen, uint8_t outputLength = 32);
+
40 
+
41  void update(const void *data, size_t len);
+
42  void finalize(void *hash, size_t len);
43 
-
44  void resetHMAC(const void *key, size_t keyLen);
-
45  void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen);
-
46 
-
47 private:
-
48  struct {
-
49  uint32_t h[8];
-
50  uint32_t m[16];
-
51  uint64_t length;
-
52  uint8_t chunkSize;
-
53  } state;
-
54 
-
55  void processChunk(uint32_t f0);
-
56 };
-
57 
-
58 #endif
-
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:56
-
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:61
-
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:154
-
BLAKE2s::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2s.cpp:81
-
BLAKE2s::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2s.cpp:66
+
44  void clear();
+
45 
+
46  void resetHMAC(const void *key, size_t keyLen);
+
47  void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen);
+
48 
+
49 private:
+
50  struct {
+
51  uint32_t h[8];
+
52  uint32_t m[16];
+
53  uint64_t length;
+
54  uint8_t chunkSize;
+
55  } state;
+
56 
+
57  void processChunk(uint32_t f0);
+
58 };
+
59 
+
60 #endif
+
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:84
+
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:89
+
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:227
+
BLAKE2s::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2s.cpp:109
+
BLAKE2s::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: BLAKE2s.cpp:94
Hash
Abstract base class for cryptographic hash algorithms.
Definition: Hash.h:29
-
BLAKE2s::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2s.cpp:116
+
BLAKE2s::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: BLAKE2s.cpp:189
BLAKE2s
BLAKE2s hash algorithm.
Definition: BLAKE2s.h:28
-
BLAKE2s::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2s.cpp:160
-
BLAKE2s::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2s.cpp:138
-
BLAKE2s::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2s.cpp:167
-
BLAKE2s::BLAKE2s
BLAKE2s()
Constructs a BLAKE2s hash object.
Definition: BLAKE2s.cpp:47
+
BLAKE2s::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: BLAKE2s.cpp:233
+
BLAKE2s::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2s.cpp:211
+
BLAKE2s::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: BLAKE2s.cpp:240
+
BLAKE2s::BLAKE2s
BLAKE2s()
Constructs a BLAKE2s hash object.
Definition: BLAKE2s.cpp:75
diff --git a/BigNumberUtil_8cpp_source.html b/BigNumberUtil_8cpp_source.html index af087b10..a04ab626 100644 --- a/BigNumberUtil_8cpp_source.html +++ b/BigNumberUtil_8cpp_source.html @@ -557,7 +557,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BigNumberUtil_8h_source.html b/BigNumberUtil_8h_source.html index dd743ccc..884fe9a8 100644 --- a/BigNumberUtil_8h_source.html +++ b/BigNumberUtil_8h_source.html @@ -199,7 +199,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Bitmap_8cpp_source.html b/Bitmap_8cpp_source.html index 19ea767d..4f4f4760 100644 --- a/Bitmap_8cpp_source.html +++ b/Bitmap_8cpp_source.html @@ -694,7 +694,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Bitmap_8h_source.html b/Bitmap_8h_source.html index 97ea520a..b1630cbe 100644 --- a/Bitmap_8h_source.html +++ b/Bitmap_8h_source.html @@ -271,7 +271,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BlinkLED_8cpp_source.html b/BlinkLED_8cpp_source.html index ba9d2e7b..06c29b4f 100644 --- a/BlinkLED_8cpp_source.html +++ b/BlinkLED_8cpp_source.html @@ -196,7 +196,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BlinkLED_8h_source.html b/BlinkLED_8h_source.html index d4f6d250..f62ab7dc 100644 --- a/BlinkLED_8h_source.html +++ b/BlinkLED_8h_source.html @@ -157,7 +157,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BlockCipher_8cpp_source.html b/BlockCipher_8cpp_source.html index 5e7d6794..a3a4eab4 100644 --- a/BlockCipher_8cpp_source.html +++ b/BlockCipher_8cpp_source.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BlockCipher_8h_source.html b/BlockCipher_8h_source.html index c43d6574..71a2d6d0 100644 --- a/BlockCipher_8h_source.html +++ b/BlockCipher_8h_source.html @@ -146,7 +146,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BoolField_8cpp_source.html b/BoolField_8cpp_source.html index 8c957a32..b42caf22 100644 --- a/BoolField_8cpp_source.html +++ b/BoolField_8cpp_source.html @@ -202,7 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BoolField_8h_source.html b/BoolField_8h_source.html index bbef01f1..ba9e403b 100644 --- a/BoolField_8h_source.html +++ b/BoolField_8h_source.html @@ -160,7 +160,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CBC_8cpp_source.html b/CBC_8cpp_source.html index 1d52c3b5..099b2d4a 100644 --- a/CBC_8cpp_source.html +++ b/CBC_8cpp_source.html @@ -208,7 +208,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CBC_8h_source.html b/CBC_8h_source.html index 4890c0be..7c111ed1 100644 --- a/CBC_8h_source.html +++ b/CBC_8h_source.html @@ -172,7 +172,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CFB_8cpp_source.html b/CFB_8cpp_source.html index bc3400a4..7aa33474 100644 --- a/CFB_8cpp_source.html +++ b/CFB_8cpp_source.html @@ -233,7 +233,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CFB_8h_source.html b/CFB_8h_source.html index 29fa070d..1a2efb1b 100644 --- a/CFB_8h_source.html +++ b/CFB_8h_source.html @@ -171,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CTR_8cpp_source.html b/CTR_8cpp_source.html index c6fe485e..5aec1c44 100644 --- a/CTR_8cpp_source.html +++ b/CTR_8cpp_source.html @@ -228,7 +228,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/CTR_8h_source.html b/CTR_8h_source.html index 73cf55cf..c4357f8b 100644 --- a/CTR_8h_source.html +++ b/CTR_8h_source.html @@ -175,7 +175,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ChaChaPoly_8cpp_source.html b/ChaChaPoly_8cpp_source.html index 4edbb504..ac5f6254 100644 --- a/ChaChaPoly_8cpp_source.html +++ b/ChaChaPoly_8cpp_source.html @@ -169,74 +169,75 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
99  state.dataSize = 0;
100  state.dataStarted = false;
101  state.ivSize = len;
-
102 }
-
103 
-
104 void ChaChaPoly::encrypt(uint8_t *output, const uint8_t *input, size_t len)
-
105 {
-
106  if (!state.dataStarted) {
-
107  poly1305.pad();
-
108  state.dataStarted = true;
-
109  }
-
110  chacha.encrypt(output, input, len);
-
111  poly1305.update(output, len);
-
112  state.dataSize += len;
-
113 }
-
114 
-
115 void ChaChaPoly::decrypt(uint8_t *output, const uint8_t *input, size_t len)
-
116 {
-
117  if (!state.dataStarted) {
-
118  poly1305.pad();
-
119  state.dataStarted = true;
-
120  }
-
121  poly1305.update(input, len);
-
122  chacha.encrypt(output, input, len); // encrypt() is the same as decrypt()
-
123  state.dataSize += len;
-
124 }
-
125 
-
126 void ChaChaPoly::addAuthData(const void *data, size_t len)
-
127 {
-
128  if (!state.dataStarted) {
-
129  poly1305.update(data, len);
-
130  state.authSize += len;
-
131  }
-
132 }
-
133 
-
134 void ChaChaPoly::computeTag(void *tag, size_t len)
-
135 {
-
136  uint64_t sizes[2];
-
137 
-
138  // Pad the final Poly1305 block and then hash the sizes.
-
139  poly1305.pad();
-
140  sizes[0] = htole64(state.authSize);
-
141  sizes[1] = htole64(state.dataSize);
-
142  poly1305.update(sizes, sizeof(sizes));
-
143 
-
144  // Compute the tag and copy it to the return buffer.
-
145  poly1305.finalize(state.nonce, tag, len);
-
146  clean(sizes);
-
147 }
-
148 
-
149 bool ChaChaPoly::checkTag(const void *tag, size_t len)
-
150 {
-
151  // Can never match if the expected tag length is too long.
-
152  if (len > 16)
-
153  return false;
-
154 
-
155  // Compute the tag and check it.
-
156  uint8_t temp[16];
-
157  computeTag(temp, len);
-
158  bool equal = secure_compare(temp, tag, len);
-
159  clean(temp);
-
160  return equal;
-
161 }
-
162 
-
163 void ChaChaPoly::clear()
-
164 {
-
165  chacha.clear();
-
166  poly1305.clear();
-
167  clean(state);
-
168  state.ivSize = 8;
-
169 }
+
102  return true;
+
103 }
+
104 
+
105 void ChaChaPoly::encrypt(uint8_t *output, const uint8_t *input, size_t len)
+
106 {
+
107  if (!state.dataStarted) {
+
108  poly1305.pad();
+
109  state.dataStarted = true;
+
110  }
+
111  chacha.encrypt(output, input, len);
+
112  poly1305.update(output, len);
+
113  state.dataSize += len;
+
114 }
+
115 
+
116 void ChaChaPoly::decrypt(uint8_t *output, const uint8_t *input, size_t len)
+
117 {
+
118  if (!state.dataStarted) {
+
119  poly1305.pad();
+
120  state.dataStarted = true;
+
121  }
+
122  poly1305.update(input, len);
+
123  chacha.encrypt(output, input, len); // encrypt() is the same as decrypt()
+
124  state.dataSize += len;
+
125 }
+
126 
+
127 void ChaChaPoly::addAuthData(const void *data, size_t len)
+
128 {
+
129  if (!state.dataStarted) {
+
130  poly1305.update(data, len);
+
131  state.authSize += len;
+
132  }
+
133 }
+
134 
+
135 void ChaChaPoly::computeTag(void *tag, size_t len)
+
136 {
+
137  uint64_t sizes[2];
+
138 
+
139  // Pad the final Poly1305 block and then hash the sizes.
+
140  poly1305.pad();
+
141  sizes[0] = htole64(state.authSize);
+
142  sizes[1] = htole64(state.dataSize);
+
143  poly1305.update(sizes, sizeof(sizes));
+
144 
+
145  // Compute the tag and copy it to the return buffer.
+
146  poly1305.finalize(state.nonce, tag, len);
+
147  clean(sizes);
+
148 }
+
149 
+
150 bool ChaChaPoly::checkTag(const void *tag, size_t len)
+
151 {
+
152  // Can never match if the expected tag length is too long.
+
153  if (len > 16)
+
154  return false;
+
155 
+
156  // Compute the tag and check it.
+
157  uint8_t temp[16];
+
158  computeTag(temp, len);
+
159  bool equal = secure_compare(temp, tag, len);
+
160  clean(temp);
+
161  return equal;
+
162 }
+
163 
+
164 void ChaChaPoly::clear()
+
165 {
+
166  chacha.clear();
+
167  poly1305.clear();
+
168  clean(state);
+
169  state.ivSize = 8;
+
170 }
Poly1305::finalize
void finalize(const void *nonce, void *token, size_t len)
Finalizes the authentication process and returns the token.
Definition: Poly1305.cpp:179
Poly1305::reset
void reset(const void *key)
Resets the Poly1305 message authenticator for a new session.
Definition: Poly1305.cpp:110
ChaCha::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: ChaCha.cpp:87
@@ -245,24 +246,24 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ChaCha::setIV
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
Definition: ChaCha.cpp:111
ChaChaPoly::setIV
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
Definition: ChaChaPoly.cpp:84
ChaChaPoly::keySize
size_t keySize() const
Default size of the key for this cipher, in bytes.
Definition: ChaChaPoly.cpp:61
-
ChaChaPoly::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: ChaChaPoly.cpp:134
+
ChaChaPoly::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: ChaChaPoly.cpp:135
ChaChaPoly::ChaChaPoly
ChaChaPoly()
Constructs a new ChaChaPoly authenticated cipher.
Definition: ChaChaPoly.cpp:45
ChaCha::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: ChaCha.cpp:158
-
ChaChaPoly::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: ChaChaPoly.cpp:126
-
ChaChaPoly::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: ChaChaPoly.cpp:104
+
ChaChaPoly::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: ChaChaPoly.cpp:127
+
ChaChaPoly::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: ChaChaPoly.cpp:105
ChaChaPoly::ivSize
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:142
ChaCha::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaCha.cpp:218
-
ChaChaPoly::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaChaPoly.cpp:163
-
ChaChaPoly::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: ChaChaPoly.cpp:115
+
ChaChaPoly::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaChaPoly.cpp:164
+
ChaChaPoly::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: ChaChaPoly.cpp:116
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:251
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
ChaChaPoly::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: ChaChaPoly.cpp:79
-
ChaChaPoly::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: ChaChaPoly.cpp:149
+
ChaChaPoly::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: ChaChaPoly.cpp:150
diff --git a/ChaChaPoly_8h_source.html b/ChaChaPoly_8h_source.html index 30589fcc..1ca8b6b5 100644 --- a/ChaChaPoly_8h_source.html +++ b/ChaChaPoly_8h_source.html @@ -161,19 +161,19 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
AuthenticatedCipher
Abstract base class for authenticated ciphers.
Definition: AuthenticatedCipher.h:28
ChaChaPoly::setIV
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
Definition: ChaChaPoly.cpp:84
ChaChaPoly::keySize
size_t keySize() const
Default size of the key for this cipher, in bytes.
Definition: ChaChaPoly.cpp:61
-
ChaChaPoly::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: ChaChaPoly.cpp:134
+
ChaChaPoly::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: ChaChaPoly.cpp:135
ChaChaPoly::ChaChaPoly
ChaChaPoly()
Constructs a new ChaChaPoly authenticated cipher.
Definition: ChaChaPoly.cpp:45
-
ChaChaPoly::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: ChaChaPoly.cpp:126
-
ChaChaPoly::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: ChaChaPoly.cpp:104
+
ChaChaPoly::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: ChaChaPoly.cpp:127
+
ChaChaPoly::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: ChaChaPoly.cpp:105
ChaChaPoly::ivSize
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
-
ChaChaPoly::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaChaPoly.cpp:163
-
ChaChaPoly::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: ChaChaPoly.cpp:115
+
ChaChaPoly::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaChaPoly.cpp:164
+
ChaChaPoly::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: ChaChaPoly.cpp:116
ChaChaPoly::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: ChaChaPoly.cpp:79
-
ChaChaPoly::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: ChaChaPoly.cpp:149
+
ChaChaPoly::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: ChaChaPoly.cpp:150
diff --git a/ChaCha_8cpp_source.html b/ChaCha_8cpp_source.html index 95553779..ae35b465 100644 --- a/ChaCha_8cpp_source.html +++ b/ChaCha_8cpp_source.html @@ -311,7 +311,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ChaCha_8h_source.html b/ChaCha_8h_source.html index 734d8e7a..1c3f1f43 100644 --- a/ChaCha_8h_source.html +++ b/ChaCha_8h_source.html @@ -170,7 +170,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Charlieplex_8cpp_source.html b/Charlieplex_8cpp_source.html index 5e68473b..c86fcf21 100644 --- a/Charlieplex_8cpp_source.html +++ b/Charlieplex_8cpp_source.html @@ -232,7 +232,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Charlieplex_8h_source.html b/Charlieplex_8h_source.html index 00521025..73d79090 100644 --- a/Charlieplex_8h_source.html +++ b/Charlieplex_8h_source.html @@ -162,7 +162,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ChaseLEDs_8cpp_source.html b/ChaseLEDs_8cpp_source.html index 32bf2095..b863eef2 100644 --- a/ChaseLEDs_8cpp_source.html +++ b/ChaseLEDs_8cpp_source.html @@ -160,7 +160,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ChaseLEDs_8h_source.html b/ChaseLEDs_8h_source.html index d53983a5..21ac8c94 100644 --- a/ChaseLEDs_8h_source.html +++ b/ChaseLEDs_8h_source.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Cipher_8cpp_source.html b/Cipher_8cpp_source.html index 85caa68a..acde1763 100644 --- a/Cipher_8cpp_source.html +++ b/Cipher_8cpp_source.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Cipher_8h_source.html b/Cipher_8h_source.html index 5a7c1c3a..55060376 100644 --- a/Cipher_8h_source.html +++ b/Cipher_8h_source.html @@ -148,7 +148,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Crypto_8cpp_source.html b/Crypto_8cpp_source.html index e4b4a821..9aee5a91 100644 --- a/Crypto_8cpp_source.html +++ b/Crypto_8cpp_source.html @@ -138,7 +138,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Crypto_8h_source.html b/Crypto_8h_source.html index 71614c7a..8472d9f3 100644 --- a/Crypto_8h_source.html +++ b/Crypto_8h_source.html @@ -130,7 +130,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Curve25519_8cpp_source.html b/Curve25519_8cpp_source.html index 5f4f65ba..d08769ee 100644 --- a/Curve25519_8cpp_source.html +++ b/Curve25519_8cpp_source.html @@ -1458,7 +1458,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Curve25519_8h_source.html b/Curve25519_8h_source.html index 56fc2727..12bf1a5d 100644 --- a/Curve25519_8h_source.html +++ b/Curve25519_8h_source.html @@ -173,7 +173,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DMD_8cpp_source.html b/DMD_8cpp_source.html index df356e72..1feed326 100644 --- a/DMD_8cpp_source.html +++ b/DMD_8cpp_source.html @@ -456,7 +456,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DMD_8h_source.html b/DMD_8h_source.html index a88ebafb..958ed2a2 100644 --- a/DMD_8h_source.html +++ b/DMD_8h_source.html @@ -170,7 +170,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS1307RTC_8cpp_source.html b/DS1307RTC_8cpp_source.html index d8863a71..71feb705 100644 --- a/DS1307RTC_8cpp_source.html +++ b/DS1307RTC_8cpp_source.html @@ -415,7 +415,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS1307RTC_8h_source.html b/DS1307RTC_8h_source.html index 45016e5f..1fd34b4a 100644 --- a/DS1307RTC_8h_source.html +++ b/DS1307RTC_8h_source.html @@ -172,7 +172,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS3231RTC_8cpp_source.html b/DS3231RTC_8cpp_source.html index aa4cfbae..cd516f0f 100644 --- a/DS3231RTC_8cpp_source.html +++ b/DS3231RTC_8cpp_source.html @@ -657,7 +657,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS3231RTC_8h_source.html b/DS3231RTC_8h_source.html index 8470a185..946b07d2 100644 --- a/DS3231RTC_8h_source.html +++ b/DS3231RTC_8h_source.html @@ -202,7 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS3232RTC_8cpp_source.html b/DS3232RTC_8cpp_source.html index c0ad1709..3306d0a9 100644 --- a/DS3232RTC_8cpp_source.html +++ b/DS3232RTC_8cpp_source.html @@ -575,7 +575,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DS3232RTC_8h_source.html b/DS3232RTC_8h_source.html index 8ce71db5..3a3bc81b 100644 --- a/DS3232RTC_8h_source.html +++ b/DS3232RTC_8h_source.html @@ -190,7 +190,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DejaVuSans9_8h_source.html b/DejaVuSans9_8h_source.html index 4e5cd0a0..8bfd6b46 100644 --- a/DejaVuSans9_8h_source.html +++ b/DejaVuSans9_8h_source.html @@ -257,7 +257,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DejaVuSansBold9_8h_source.html b/DejaVuSansBold9_8h_source.html index 569684ee..4f538320 100644 --- a/DejaVuSansBold9_8h_source.html +++ b/DejaVuSansBold9_8h_source.html @@ -257,7 +257,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/DejaVuSansItalic9_8h_source.html b/DejaVuSansItalic9_8h_source.html index 74822db4..bb5d438b 100644 --- a/DejaVuSansItalic9_8h_source.html +++ b/DejaVuSansItalic9_8h_source.html @@ -257,7 +257,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/EAX_8cpp_source.html b/EAX_8cpp_source.html index ec414039..3756218b 100644 --- a/EAX_8cpp_source.html +++ b/EAX_8cpp_source.html @@ -301,7 +301,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/EAX_8h_source.html b/EAX_8h_source.html index e001e2fd..8d02868d 100644 --- a/EAX_8h_source.html +++ b/EAX_8h_source.html @@ -196,7 +196,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/EEPROM24_8cpp_source.html b/EEPROM24_8cpp_source.html index 2a41029a..84f4a5c5 100644 --- a/EEPROM24_8cpp_source.html +++ b/EEPROM24_8cpp_source.html @@ -282,7 +282,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/EEPROM24_8h_source.html b/EEPROM24_8h_source.html index 171a82fb..ee9bc60e 100644 --- a/EEPROM24_8h_source.html +++ b/EEPROM24_8h_source.html @@ -186,7 +186,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Ed25519_8cpp_source.html b/Ed25519_8cpp_source.html index 7ca7e817..949e7b0f 100644 --- a/Ed25519_8cpp_source.html +++ b/Ed25519_8cpp_source.html @@ -252,308 +252,307 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
256 void Ed25519::derivePublicKey(uint8_t publicKey[32], const uint8_t privateKey[32])
257 {
258  SHA512 hash;
-
259  uint8_t *buf = (uint8_t *)(hash.state.w);
-
260  limb_t a[NUM_LIMBS_256BIT];
-
261  Point ptA;
-
262 
-
263  // Derive the secret scalar a from the private key.
-
264  deriveKeys(&hash, a, privateKey);
-
265 
-
266  // Compute the point A = aB and encode it.
-
267  mul(ptA, a);
-
268  encodePoint(publicKey, ptA);
-
269 
-
270  // Clean up and exit.
-
271  clean(a);
-
272  clean(ptA);
-
273 }
-
274 
-
284 void Ed25519::reduceQFromBuffer(limb_t *result, const uint8_t buf[64], limb_t *temp)
-
285 {
-
286  BigNumberUtil::unpackLE(temp, NUM_LIMBS_512BIT, buf, 64);
-
287  temp[NUM_LIMBS_512BIT] = 0;
-
288  reduceQ(result, temp);
-
289 }
-
290 
-
303 void Ed25519::reduceQ(limb_t *result, limb_t *r)
-
304 {
-
305  // Algorithm from: http://en.wikipedia.org/wiki/Barrett_reduction
-
306  //
-
307  // We assume that r is less than or equal to (q - 1)^2.
-
308  //
-
309  // We want to compute result = r mod q. Find the smallest k such
-
310  // that 2^k > q. In our case, k = 253. Then set m = floor(4^k / q)
-
311  // and let r = r - q * floor(m * r / 4^k). This will be the result
-
312  // or it will be at most one subtraction of q away from the result.
-
313  //
-
314  // Note: 4^k = 4^253 = 2^506 = 2^512/2^6. We can more easily compute
-
315  // the result we want if we set m = floor(4^k * 2^6 / q) instead and
-
316  // then r = r - q * floor(m * r / 2^512). Because the slight extra
-
317  // precision in m, r is at most two subtractions of q away from the
-
318  // final result.
-
319  static limb_t const numM[NUM_LIMBS_256BIT + 1] PROGMEM = {
-
320  LIMB(0x0A2C131B), LIMB(0xED9CE5A3), LIMB(0x086329A7), LIMB(0x2106215D),
-
321  LIMB(0xFFFFFFEB), LIMB(0xFFFFFFFF), LIMB(0xFFFFFFFF), LIMB(0xFFFFFFFF),
-
322  0x0F
-
323  };
-
324  limb_t temp[NUM_LIMBS_512BIT + NUM_LIMBS_256BIT + 1];
-
325 
-
326  // Multiply r by m.
-
327  BigNumberUtil::mul_P(temp, r, NUM_LIMBS_512BIT, numM, NUM_LIMBS_256BIT + 1);
-
328 
-
329  // Multiply (m * r) / 2^512 by q and subtract it from r.
-
330  // We can ignore the high words of the subtraction result
-
331  // because they will all turn into zero after the subtraction.
-
332  BigNumberUtil::mul_P(temp, temp + NUM_LIMBS_512BIT, NUM_LIMBS_256BIT + 1,
-
333  numQ, NUM_LIMBS_256BIT);
-
334  BigNumberUtil::sub(r, r, temp, NUM_LIMBS_256BIT);
-
335 
-
336  // Perform two subtractions of q from the result to reduce it.
-
337  BigNumberUtil::reduceQuick_P(result, r, numQ, NUM_LIMBS_256BIT);
-
338  BigNumberUtil::reduceQuick_P(result, result, numQ, NUM_LIMBS_256BIT);
-
339 
-
340  // Clean up and exit.
-
341  clean(temp);
-
342 }
-
343 
-
353 void Ed25519::mul(Point &result, const limb_t *s, Point &p, bool constTime)
-
354 {
-
355  Point q;
-
356  limb_t A[NUM_LIMBS_256BIT];
-
357  limb_t B[NUM_LIMBS_256BIT];
-
358  limb_t C[NUM_LIMBS_256BIT];
-
359  limb_t D[NUM_LIMBS_256BIT];
-
360  limb_t mask, select;
-
361  uint8_t sposn, t;
-
362 
-
363  // Initialize the result to (0, 1, 1, 0).
-
364  memset(&result, 0, sizeof(Point));
-
365  result.y[0] = 1;
-
366  result.z[0] = 1;
-
367 
-
368  // Iterate over the 255 bits of "s" to calculate "s * p".
-
369  mask = 1;
-
370  sposn = 0;
-
371  for (t = 255; t > 0; --t) {
-
372  // Add p to the result to produce q. The specification refers
-
373  // to temporary variables A to H. We can dispense with E to H
-
374  // by using B, D, q.z, and q.t to hold those values temporarily.
-
375  select = s[sposn] & mask;
-
376  if (constTime || select) {
-
377  Curve25519::sub(A, result.y, result.x);
-
378  Curve25519::sub(C, p.y, p.x);
-
379  Curve25519::mul(A, A, C);
-
380  Curve25519::add(B, result.y, result.x);
-
381  Curve25519::add(C, p.y, p.x);
-
382  Curve25519::mul(B, B, C);
-
383  Curve25519::mul(C, result.t, p.t);
-
384  Curve25519::mul_P(C, C, numDx2);
-
385  Curve25519::mul(D, result.z, p.z);
-
386  Curve25519::add(D, D, D);
-
387  Curve25519::sub(q.t, B, A); // E = B - A
-
388  Curve25519::sub(q.z, D, C); // F = D - C
-
389  Curve25519::add(D, D, C); // G = D + C
-
390  Curve25519::add(B, B, A); // H = B + A
-
391  if (constTime) {
-
392  // Put the intermediate value into q.
-
393  Curve25519::mul(q.x, q.t, q.z); // q.x = E * F
-
394  Curve25519::mul(q.y, D, B); // q.y = G * H
-
395  Curve25519::mul(q.z, q.z, D); // q.z = F * G
-
396  Curve25519::mul(q.t, q.t, B); // q.t = E * H
-
397 
-
398  // Copy q into the result if the current bit of s is 1.
-
399  Curve25519::cmove(select, result.x, q.x);
-
400  Curve25519::cmove(select, result.y, q.y);
-
401  Curve25519::cmove(select, result.z, q.z);
-
402  Curve25519::cmove(select, result.t, q.t);
-
403  } else {
-
404  // Put the intermediate value directly into the result.
-
405  Curve25519::mul(result.x, q.t, q.z); // q.x = E * F
-
406  Curve25519::mul(result.y, D, B); // q.y = G * H
-
407  Curve25519::mul(result.z, q.z, D); // q.z = F * G
-
408  Curve25519::mul(result.t, q.t, B); // q.t = E * H
-
409  }
-
410  }
-
411 
-
412  // Double p for the next iteration.
-
413  Curve25519::sub(A, p.y, p.x);
-
414  Curve25519::square(A, A);
-
415  Curve25519::add(B, p.y, p.x);
-
416  Curve25519::square(B, B);
-
417  Curve25519::square(C, p.t);
-
418  Curve25519::mul_P(C, C, numDx2);
-
419  Curve25519::square(D, p.z);
-
420  Curve25519::add(D, D, D);
-
421  Curve25519::sub(p.t, B, A); // E = B - A
-
422  Curve25519::sub(p.z, D, C); // F = D - C
-
423  Curve25519::add(D, D, C); // G = D + C
-
424  Curve25519::add(B, B, A); // H = B + A
-
425  Curve25519::mul(p.x, p.t, p.z); // p.x = E * F
-
426  Curve25519::mul(p.y, D, B); // p.y = G * H
-
427  Curve25519::mul(p.z, p.z, D); // p.z = F * G
-
428  Curve25519::mul(p.t, p.t, B); // p.t = E * H
-
429 
-
430  // Move onto the next bit of s from lowest to highest.
-
431  if (mask != (((limb_t)1) << (LIMB_BITS - 1))) {
-
432  mask <<= 1;
-
433  } else {
-
434  ++sposn;
-
435  mask = 1;
-
436  }
-
437  }
-
438 
-
439  // Clean up.
-
440  clean(q);
-
441  clean(A);
-
442  clean(B);
-
443  clean(C);
-
444  clean(D);
-
445 }
-
446 
-
455 void Ed25519::mul(Point &result, const limb_t *s, bool constTime)
-
456 {
-
457  Point P;
-
458  memcpy_P(P.x, numBx, sizeof(P.x));
-
459  memcpy_P(P.y, numBy, sizeof(P.y));
-
460  memcpy_P(P.z, numBz, sizeof(P.z));
-
461  memcpy_P(P.t, numBt, sizeof(P.t));
-
462  mul(result, s, P, constTime);
-
463  clean(P);
-
464 }
-
465 
-
472 void Ed25519::add(Point &p, const Point &q)
-
473 {
-
474  limb_t A[NUM_LIMBS_256BIT];
-
475  limb_t B[NUM_LIMBS_256BIT];
-
476  limb_t C[NUM_LIMBS_256BIT];
-
477  limb_t D[NUM_LIMBS_256BIT];
-
478 
-
479  Curve25519::sub(A, p.y, p.x);
-
480  Curve25519::sub(C, q.y, q.x);
-
481  Curve25519::mul(A, A, C);
-
482  Curve25519::add(B, p.y, p.x);
-
483  Curve25519::add(C, q.y, q.x);
-
484  Curve25519::mul(B, B, C);
-
485  Curve25519::mul(C, p.t, q.t);
-
486  Curve25519::mul_P(C, C, numDx2);
-
487  Curve25519::mul(D, p.z, q.z);
-
488  Curve25519::add(D, D, D);
-
489  Curve25519::sub(p.t, B, A); // E = B - A
-
490  Curve25519::sub(p.z, D, C); // F = D - C
-
491  Curve25519::add(D, D, C); // G = D + C
-
492  Curve25519::add(B, B, A); // H = B + A
-
493  Curve25519::mul(p.x, p.t, p.z); // p.x = E * F
-
494  Curve25519::mul(p.y, D, B); // p.y = G * H
-
495  Curve25519::mul(p.z, p.z, D); // p.z = F * G
-
496  Curve25519::mul(p.t, p.t, B); // p.t = E * H
-
497 
-
498  clean(A);
-
499  clean(B);
-
500  clean(C);
-
501  clean(D);
-
502 }
-
503 
-
512 bool Ed25519::equal(const Point &p, const Point &q)
-
513 {
-
514  limb_t a[NUM_LIMBS_256BIT];
-
515  limb_t b[NUM_LIMBS_256BIT];
-
516  bool result = true;
-
517 
-
518  Curve25519::mul(a, p.x, q.z);
-
519  Curve25519::mul(b, q.x, p.z);
-
520  result &= secure_compare(a, b, sizeof(a));
-
521 
-
522  Curve25519::mul(a, p.y, q.z);
-
523  Curve25519::mul(b, q.y, p.z);
-
524  result &= secure_compare(a, b, sizeof(a));
-
525 
-
526  clean(a);
-
527  clean(b);
-
528  return result;
-
529 }
-
530 
-
540 void Ed25519::encodePoint(uint8_t *buf, Point &point)
-
541 {
-
542  // Convert the homogeneous coordinates into plain (x, y) coordinates:
-
543  // zinv = z^(-1) mod p
-
544  // x = x * zinv mod p
-
545  // y = y * zinv mod p
-
546  // We don't need the t coordinate, so use that to store zinv temporarily.
-
547  Curve25519::recip(point.t, point.z);
-
548  Curve25519::mul(point.x, point.x, point.t);
-
549  Curve25519::mul(point.y, point.y, point.t);
-
550 
-
551  // Copy the lowest bit of x to the highest bit of y.
-
552  point.y[NUM_LIMBS_256BIT - 1] |= (point.x[0] << (LIMB_BITS - 1));
-
553 
-
554  // Convert y into little-endian in the return buffer.
-
555  BigNumberUtil::packLE(buf, 32, point.y, NUM_LIMBS_256BIT);
-
556 }
-
557 
-
570 bool Ed25519::decodePoint(Point &point, const uint8_t *buf)
-
571 {
-
572  limb_t temp[NUM_LIMBS_256BIT];
-
573 
-
574  // Convert the input buffer from little-endian into the limbs of y.
-
575  BigNumberUtil::unpackLE(point.y, NUM_LIMBS_256BIT, buf, 32);
-
576 
-
577  // The high bit of y is the sign bit for x.
-
578  limb_t sign = point.y[NUM_LIMBS_256BIT - 1] >> (LIMB_BITS - 1);
-
579  point.y[NUM_LIMBS_256BIT - 1] &= ~(((limb_t)1) << (LIMB_BITS - 1));
-
580 
-
581  // Set z to 1.
-
582  memcpy_P(point.z, numBz, sizeof(point.z));
-
583 
-
584  // Compute t = (y * y - 1) * modinv(d * y * y + 1).
-
585  Curve25519::square(point.t, point.y);
-
586  Curve25519::sub(point.x, point.t, point.z);
-
587  Curve25519::mul_P(point.t, point.t, numD);
-
588  Curve25519::add(point.t, point.t, point.z);
-
589  Curve25519::recip(temp, point.t);
-
590  Curve25519::mul(point.t, point.x, temp);
-
591  clean(temp);
-
592 
-
593  // Check for t = 0.
-
594  limb_t check = point.t[0];
-
595  for (uint8_t posn = 1; posn < NUM_LIMBS_256BIT; ++posn)
-
596  check |= point.t[posn];
-
597  if (!check) {
-
598  // If the sign bit is set, then decoding has failed.
-
599  // Otherwise x is zero and we're done.
-
600  if (sign)
-
601  return false;
-
602  memset(point.x, 0, sizeof(point.x));
-
603  return true;
-
604  }
-
605 
-
606  // Recover x by taking the sqrt of t and flipping the sign if necessary.
-
607  if (!Curve25519::sqrt(point.x, point.t))
-
608  return false;
-
609  if (sign != (point.x[0] & ((limb_t)1))) {
-
610  // The signs are different so we want the other square root.
-
611  memset(point.t, 0, sizeof(point.t));
-
612  Curve25519::sub(point.x, point.t, point.x);
-
613  }
-
614 
-
615  // Finally, t = x * y.
-
616  Curve25519::mul(point.t, point.x, point.y);
-
617  return true;
-
618 }
-
619 
-
630 void Ed25519::deriveKeys(SHA512 *hash, limb_t *a, const uint8_t privateKey[32])
-
631 {
-
632  // Hash the private key to get the "a" scalar and the message prefix.
-
633  uint8_t *buf = (uint8_t *)(hash->state.w); // Reuse hash buffer to save memory.
-
634  hash->reset();
-
635  hash->update(privateKey, 32);
-
636  hash->finalize(buf, 0);
-
637  buf[0] &= 0xF8;
-
638  buf[31] &= 0x7F;
-
639  buf[31] |= 0x40;
-
640 
-
641  // Unpack the first half of the hash value into "a".
-
642  BigNumberUtil::unpackLE(a, NUM_LIMBS_256BIT, buf, 32);
-
643 }
+
259  limb_t a[NUM_LIMBS_256BIT];
+
260  Point ptA;
+
261 
+
262  // Derive the secret scalar a from the private key.
+
263  deriveKeys(&hash, a, privateKey);
+
264 
+
265  // Compute the point A = aB and encode it.
+
266  mul(ptA, a);
+
267  encodePoint(publicKey, ptA);
+
268 
+
269  // Clean up and exit.
+
270  clean(a);
+
271  clean(ptA);
+
272 }
+
273 
+
283 void Ed25519::reduceQFromBuffer(limb_t *result, const uint8_t buf[64], limb_t *temp)
+
284 {
+
285  BigNumberUtil::unpackLE(temp, NUM_LIMBS_512BIT, buf, 64);
+
286  temp[NUM_LIMBS_512BIT] = 0;
+
287  reduceQ(result, temp);
+
288 }
+
289 
+
302 void Ed25519::reduceQ(limb_t *result, limb_t *r)
+
303 {
+
304  // Algorithm from: http://en.wikipedia.org/wiki/Barrett_reduction
+
305  //
+
306  // We assume that r is less than or equal to (q - 1)^2.
+
307  //
+
308  // We want to compute result = r mod q. Find the smallest k such
+
309  // that 2^k > q. In our case, k = 253. Then set m = floor(4^k / q)
+
310  // and let r = r - q * floor(m * r / 4^k). This will be the result
+
311  // or it will be at most one subtraction of q away from the result.
+
312  //
+
313  // Note: 4^k = 4^253 = 2^506 = 2^512/2^6. We can more easily compute
+
314  // the result we want if we set m = floor(4^k * 2^6 / q) instead and
+
315  // then r = r - q * floor(m * r / 2^512). Because the slight extra
+
316  // precision in m, r is at most two subtractions of q away from the
+
317  // final result.
+
318  static limb_t const numM[NUM_LIMBS_256BIT + 1] PROGMEM = {
+
319  LIMB(0x0A2C131B), LIMB(0xED9CE5A3), LIMB(0x086329A7), LIMB(0x2106215D),
+
320  LIMB(0xFFFFFFEB), LIMB(0xFFFFFFFF), LIMB(0xFFFFFFFF), LIMB(0xFFFFFFFF),
+
321  0x0F
+
322  };
+
323  limb_t temp[NUM_LIMBS_512BIT + NUM_LIMBS_256BIT + 1];
+
324 
+
325  // Multiply r by m.
+
326  BigNumberUtil::mul_P(temp, r, NUM_LIMBS_512BIT, numM, NUM_LIMBS_256BIT + 1);
+
327 
+
328  // Multiply (m * r) / 2^512 by q and subtract it from r.
+
329  // We can ignore the high words of the subtraction result
+
330  // because they will all turn into zero after the subtraction.
+
331  BigNumberUtil::mul_P(temp, temp + NUM_LIMBS_512BIT, NUM_LIMBS_256BIT + 1,
+
332  numQ, NUM_LIMBS_256BIT);
+
333  BigNumberUtil::sub(r, r, temp, NUM_LIMBS_256BIT);
+
334 
+
335  // Perform two subtractions of q from the result to reduce it.
+
336  BigNumberUtil::reduceQuick_P(result, r, numQ, NUM_LIMBS_256BIT);
+
337  BigNumberUtil::reduceQuick_P(result, result, numQ, NUM_LIMBS_256BIT);
+
338 
+
339  // Clean up and exit.
+
340  clean(temp);
+
341 }
+
342 
+
352 void Ed25519::mul(Point &result, const limb_t *s, Point &p, bool constTime)
+
353 {
+
354  Point q;
+
355  limb_t A[NUM_LIMBS_256BIT];
+
356  limb_t B[NUM_LIMBS_256BIT];
+
357  limb_t C[NUM_LIMBS_256BIT];
+
358  limb_t D[NUM_LIMBS_256BIT];
+
359  limb_t mask, select;
+
360  uint8_t sposn, t;
+
361 
+
362  // Initialize the result to (0, 1, 1, 0).
+
363  memset(&result, 0, sizeof(Point));
+
364  result.y[0] = 1;
+
365  result.z[0] = 1;
+
366 
+
367  // Iterate over the 255 bits of "s" to calculate "s * p".
+
368  mask = 1;
+
369  sposn = 0;
+
370  for (t = 255; t > 0; --t) {
+
371  // Add p to the result to produce q. The specification refers
+
372  // to temporary variables A to H. We can dispense with E to H
+
373  // by using B, D, q.z, and q.t to hold those values temporarily.
+
374  select = s[sposn] & mask;
+
375  if (constTime || select) {
+
376  Curve25519::sub(A, result.y, result.x);
+
377  Curve25519::sub(C, p.y, p.x);
+
378  Curve25519::mul(A, A, C);
+
379  Curve25519::add(B, result.y, result.x);
+
380  Curve25519::add(C, p.y, p.x);
+
381  Curve25519::mul(B, B, C);
+
382  Curve25519::mul(C, result.t, p.t);
+
383  Curve25519::mul_P(C, C, numDx2);
+
384  Curve25519::mul(D, result.z, p.z);
+
385  Curve25519::add(D, D, D);
+
386  Curve25519::sub(q.t, B, A); // E = B - A
+
387  Curve25519::sub(q.z, D, C); // F = D - C
+
388  Curve25519::add(D, D, C); // G = D + C
+
389  Curve25519::add(B, B, A); // H = B + A
+
390  if (constTime) {
+
391  // Put the intermediate value into q.
+
392  Curve25519::mul(q.x, q.t, q.z); // q.x = E * F
+
393  Curve25519::mul(q.y, D, B); // q.y = G * H
+
394  Curve25519::mul(q.z, q.z, D); // q.z = F * G
+
395  Curve25519::mul(q.t, q.t, B); // q.t = E * H
+
396 
+
397  // Copy q into the result if the current bit of s is 1.
+
398  Curve25519::cmove(select, result.x, q.x);
+
399  Curve25519::cmove(select, result.y, q.y);
+
400  Curve25519::cmove(select, result.z, q.z);
+
401  Curve25519::cmove(select, result.t, q.t);
+
402  } else {
+
403  // Put the intermediate value directly into the result.
+
404  Curve25519::mul(result.x, q.t, q.z); // q.x = E * F
+
405  Curve25519::mul(result.y, D, B); // q.y = G * H
+
406  Curve25519::mul(result.z, q.z, D); // q.z = F * G
+
407  Curve25519::mul(result.t, q.t, B); // q.t = E * H
+
408  }
+
409  }
+
410 
+
411  // Double p for the next iteration.
+
412  Curve25519::sub(A, p.y, p.x);
+
413  Curve25519::square(A, A);
+
414  Curve25519::add(B, p.y, p.x);
+
415  Curve25519::square(B, B);
+
416  Curve25519::square(C, p.t);
+
417  Curve25519::mul_P(C, C, numDx2);
+
418  Curve25519::square(D, p.z);
+
419  Curve25519::add(D, D, D);
+
420  Curve25519::sub(p.t, B, A); // E = B - A
+
421  Curve25519::sub(p.z, D, C); // F = D - C
+
422  Curve25519::add(D, D, C); // G = D + C
+
423  Curve25519::add(B, B, A); // H = B + A
+
424  Curve25519::mul(p.x, p.t, p.z); // p.x = E * F
+
425  Curve25519::mul(p.y, D, B); // p.y = G * H
+
426  Curve25519::mul(p.z, p.z, D); // p.z = F * G
+
427  Curve25519::mul(p.t, p.t, B); // p.t = E * H
+
428 
+
429  // Move onto the next bit of s from lowest to highest.
+
430  if (mask != (((limb_t)1) << (LIMB_BITS - 1))) {
+
431  mask <<= 1;
+
432  } else {
+
433  ++sposn;
+
434  mask = 1;
+
435  }
+
436  }
+
437 
+
438  // Clean up.
+
439  clean(q);
+
440  clean(A);
+
441  clean(B);
+
442  clean(C);
+
443  clean(D);
+
444 }
+
445 
+
454 void Ed25519::mul(Point &result, const limb_t *s, bool constTime)
+
455 {
+
456  Point P;
+
457  memcpy_P(P.x, numBx, sizeof(P.x));
+
458  memcpy_P(P.y, numBy, sizeof(P.y));
+
459  memcpy_P(P.z, numBz, sizeof(P.z));
+
460  memcpy_P(P.t, numBt, sizeof(P.t));
+
461  mul(result, s, P, constTime);
+
462  clean(P);
+
463 }
+
464 
+
471 void Ed25519::add(Point &p, const Point &q)
+
472 {
+
473  limb_t A[NUM_LIMBS_256BIT];
+
474  limb_t B[NUM_LIMBS_256BIT];
+
475  limb_t C[NUM_LIMBS_256BIT];
+
476  limb_t D[NUM_LIMBS_256BIT];
+
477 
+
478  Curve25519::sub(A, p.y, p.x);
+
479  Curve25519::sub(C, q.y, q.x);
+
480  Curve25519::mul(A, A, C);
+
481  Curve25519::add(B, p.y, p.x);
+
482  Curve25519::add(C, q.y, q.x);
+
483  Curve25519::mul(B, B, C);
+
484  Curve25519::mul(C, p.t, q.t);
+
485  Curve25519::mul_P(C, C, numDx2);
+
486  Curve25519::mul(D, p.z, q.z);
+
487  Curve25519::add(D, D, D);
+
488  Curve25519::sub(p.t, B, A); // E = B - A
+
489  Curve25519::sub(p.z, D, C); // F = D - C
+
490  Curve25519::add(D, D, C); // G = D + C
+
491  Curve25519::add(B, B, A); // H = B + A
+
492  Curve25519::mul(p.x, p.t, p.z); // p.x = E * F
+
493  Curve25519::mul(p.y, D, B); // p.y = G * H
+
494  Curve25519::mul(p.z, p.z, D); // p.z = F * G
+
495  Curve25519::mul(p.t, p.t, B); // p.t = E * H
+
496 
+
497  clean(A);
+
498  clean(B);
+
499  clean(C);
+
500  clean(D);
+
501 }
+
502 
+
511 bool Ed25519::equal(const Point &p, const Point &q)
+
512 {
+
513  limb_t a[NUM_LIMBS_256BIT];
+
514  limb_t b[NUM_LIMBS_256BIT];
+
515  bool result = true;
+
516 
+
517  Curve25519::mul(a, p.x, q.z);
+
518  Curve25519::mul(b, q.x, p.z);
+
519  result &= secure_compare(a, b, sizeof(a));
+
520 
+
521  Curve25519::mul(a, p.y, q.z);
+
522  Curve25519::mul(b, q.y, p.z);
+
523  result &= secure_compare(a, b, sizeof(a));
+
524 
+
525  clean(a);
+
526  clean(b);
+
527  return result;
+
528 }
+
529 
+
539 void Ed25519::encodePoint(uint8_t *buf, Point &point)
+
540 {
+
541  // Convert the homogeneous coordinates into plain (x, y) coordinates:
+
542  // zinv = z^(-1) mod p
+
543  // x = x * zinv mod p
+
544  // y = y * zinv mod p
+
545  // We don't need the t coordinate, so use that to store zinv temporarily.
+
546  Curve25519::recip(point.t, point.z);
+
547  Curve25519::mul(point.x, point.x, point.t);
+
548  Curve25519::mul(point.y, point.y, point.t);
+
549 
+
550  // Copy the lowest bit of x to the highest bit of y.
+
551  point.y[NUM_LIMBS_256BIT - 1] |= (point.x[0] << (LIMB_BITS - 1));
+
552 
+
553  // Convert y into little-endian in the return buffer.
+
554  BigNumberUtil::packLE(buf, 32, point.y, NUM_LIMBS_256BIT);
+
555 }
+
556 
+
569 bool Ed25519::decodePoint(Point &point, const uint8_t *buf)
+
570 {
+
571  limb_t temp[NUM_LIMBS_256BIT];
+
572 
+
573  // Convert the input buffer from little-endian into the limbs of y.
+
574  BigNumberUtil::unpackLE(point.y, NUM_LIMBS_256BIT, buf, 32);
+
575 
+
576  // The high bit of y is the sign bit for x.
+
577  limb_t sign = point.y[NUM_LIMBS_256BIT - 1] >> (LIMB_BITS - 1);
+
578  point.y[NUM_LIMBS_256BIT - 1] &= ~(((limb_t)1) << (LIMB_BITS - 1));
+
579 
+
580  // Set z to 1.
+
581  memcpy_P(point.z, numBz, sizeof(point.z));
+
582 
+
583  // Compute t = (y * y - 1) * modinv(d * y * y + 1).
+
584  Curve25519::square(point.t, point.y);
+
585  Curve25519::sub(point.x, point.t, point.z);
+
586  Curve25519::mul_P(point.t, point.t, numD);
+
587  Curve25519::add(point.t, point.t, point.z);
+
588  Curve25519::recip(temp, point.t);
+
589  Curve25519::mul(point.t, point.x, temp);
+
590  clean(temp);
+
591 
+
592  // Check for t = 0.
+
593  limb_t check = point.t[0];
+
594  for (uint8_t posn = 1; posn < NUM_LIMBS_256BIT; ++posn)
+
595  check |= point.t[posn];
+
596  if (!check) {
+
597  // If the sign bit is set, then decoding has failed.
+
598  // Otherwise x is zero and we're done.
+
599  if (sign)
+
600  return false;
+
601  memset(point.x, 0, sizeof(point.x));
+
602  return true;
+
603  }
+
604 
+
605  // Recover x by taking the sqrt of t and flipping the sign if necessary.
+
606  if (!Curve25519::sqrt(point.x, point.t))
+
607  return false;
+
608  if (sign != (point.x[0] & ((limb_t)1))) {
+
609  // The signs are different so we want the other square root.
+
610  memset(point.t, 0, sizeof(point.t));
+
611  Curve25519::sub(point.x, point.t, point.x);
+
612  }
+
613 
+
614  // Finally, t = x * y.
+
615  Curve25519::mul(point.t, point.x, point.y);
+
616  return true;
+
617 }
+
618 
+
629 void Ed25519::deriveKeys(SHA512 *hash, limb_t *a, const uint8_t privateKey[32])
+
630 {
+
631  // Hash the private key to get the "a" scalar and the message prefix.
+
632  uint8_t *buf = (uint8_t *)(hash->state.w); // Reuse hash buffer to save memory.
+
633  hash->reset();
+
634  hash->update(privateKey, 32);
+
635  hash->finalize(buf, 0);
+
636  buf[0] &= 0xF8;
+
637  buf[31] &= 0x7F;
+
638  buf[31] |= 0x40;
+
639 
+
640  // Unpack the first half of the hash value into "a".
+
641  BigNumberUtil::unpackLE(a, NUM_LIMBS_256BIT, buf, 32);
+
642 }
BigNumberUtil::reduceQuick_P
static void reduceQuick_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction where y is in program memory.
Definition: BigNumberUtil.cpp:620
Ed25519::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[32])
Generates a private key for Ed25519 signing operations.
Definition: Ed25519.cpp:243
BigNumberUtil::add
static limb_t add(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers.
Definition: BigNumberUtil.cpp:381
@@ -572,7 +571,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Ed25519_8h_source.html b/Ed25519_8h_source.html index 9ea065df..7026e895 100644 --- a/Ed25519_8h_source.html +++ b/Ed25519_8h_source.html @@ -168,7 +168,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Field_8cpp_source.html b/Field_8cpp_source.html index 36009311..7df5bf61 100644 --- a/Field_8cpp_source.html +++ b/Field_8cpp_source.html @@ -196,7 +196,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Field_8h_source.html b/Field_8h_source.html index 6e496f11..e2caf6f3 100644 --- a/Field_8h_source.html +++ b/Field_8h_source.html @@ -164,7 +164,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Form_8cpp_source.html b/Form_8cpp_source.html index 2c5eed05..70d2549a 100644 --- a/Form_8cpp_source.html +++ b/Form_8cpp_source.html @@ -278,7 +278,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Form_8h_source.html b/Form_8h_source.html index 37d8caaf..4c37eb4b 100644 --- a/Form_8h_source.html +++ b/Form_8h_source.html @@ -172,7 +172,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GCM_8cpp_source.html b/GCM_8cpp_source.html index 15d72a70..06a504d0 100644 --- a/GCM_8cpp_source.html +++ b/GCM_8cpp_source.html @@ -193,152 +193,153 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
122  // This value will be XOR'ed with the final authentication hash
123  // value in computeTag().
124  blockCipher->encryptBlock(state.nonce, state.counter);
-
125 }
-
126 
-
132 static inline void increment(uint8_t counter[16])
-
133 {
-
134  uint16_t carry = 1;
-
135  carry += counter[15];
-
136  counter[15] = (uint8_t)carry;
-
137  carry = (carry >> 8) + counter[14];
-
138  counter[14] = (uint8_t)carry;
-
139  carry = (carry >> 8) + counter[13];
-
140  counter[13] = (uint8_t)carry;
-
141  carry = (carry >> 8) + counter[12];
-
142  counter[12] = (uint8_t)carry;
-
143 }
-
144 
-
145 void GCMCommon::encrypt(uint8_t *output, const uint8_t *input, size_t len)
-
146 {
-
147  // Finalize the authenticated data if necessary.
-
148  if (!state.dataStarted) {
-
149  ghash.pad();
-
150  state.dataStarted = true;
-
151  }
-
152 
-
153  // Encrypt the plaintext using the block cipher in counter mode.
-
154  uint8_t *out = output;
-
155  size_t size = len;
-
156  while (size > 0) {
-
157  // Create a new keystream block if necessary.
-
158  if (state.posn >= 16) {
-
159  increment(state.counter);
-
160  blockCipher->encryptBlock(state.stream, state.counter);
-
161  state.posn = 0;
-
162  }
-
163 
-
164  // Encrypt as many bytes as we can using the keystream block.
-
165  uint8_t temp = 16 - state.posn;
-
166  if (temp > size)
-
167  temp = size;
-
168  uint8_t *stream = state.stream + state.posn;
-
169  state.posn += temp;
-
170  size -= temp;
-
171  while (temp > 0) {
-
172  *out++ = *input++ ^ *stream++;
-
173  --temp;
-
174  }
-
175  }
-
176 
-
177  // Feed the ciphertext into the hash.
-
178  ghash.update(output, len);
-
179  state.dataSize += len;
-
180 }
-
181 
-
182 void GCMCommon::decrypt(uint8_t *output, const uint8_t *input, size_t len)
-
183 {
-
184  // Finalize the authenticated data if necessary.
-
185  if (!state.dataStarted) {
-
186  ghash.pad();
-
187  state.dataStarted = true;
-
188  }
-
189 
-
190  // Feed the ciphertext into the hash before we decrypt it.
-
191  ghash.update(input, len);
-
192  state.dataSize += len;
-
193 
-
194  // Decrypt the plaintext using the block cipher in counter mode.
-
195  while (len > 0) {
-
196  // Create a new keystream block if necessary.
-
197  if (state.posn >= 16) {
-
198  increment(state.counter);
-
199  blockCipher->encryptBlock(state.stream, state.counter);
-
200  state.posn = 0;
-
201  }
-
202 
-
203  // Decrypt as many bytes as we can using the keystream block.
-
204  uint8_t temp = 16 - state.posn;
-
205  if (temp > len)
-
206  temp = len;
-
207  uint8_t *stream = state.stream + state.posn;
-
208  state.posn += temp;
-
209  len -= temp;
-
210  while (temp > 0) {
-
211  *output++ = *input++ ^ *stream++;
-
212  --temp;
-
213  }
-
214  }
-
215 }
-
216 
-
217 void GCMCommon::addAuthData(const void *data, size_t len)
-
218 {
-
219  if (!state.dataStarted) {
-
220  ghash.update(data, len);
-
221  state.authSize += len;
-
222  }
-
223 }
-
224 
-
225 void GCMCommon::computeTag(void *tag, size_t len)
-
226 {
-
227  // Pad the hashed data and add the sizes.
-
228  ghash.pad();
-
229  uint64_t sizes[2] = {
-
230  htobe64(state.authSize * 8),
-
231  htobe64(state.dataSize * 8)
-
232  };
-
233  ghash.update(sizes, sizeof(sizes));
-
234  clean(sizes);
-
235 
-
236  // Get the finalized hash, encrypt it with the nonce, and return the tag.
-
237  ghash.finalize(state.stream, 16);
-
238  for (uint8_t posn = 0; posn < 16; ++posn)
-
239  state.stream[posn] ^= state.nonce[posn];
-
240  if (len > 16)
-
241  len = 16;
-
242  memcpy(tag, state.stream, len);
-
243 }
-
244 
-
245 bool GCMCommon::checkTag(const void *tag, size_t len)
-
246 {
-
247  // Can never match if the expected tag length is too long.
-
248  if (len > 16)
-
249  return false;
-
250 
-
251  // Compute the tag and check it.
-
252  computeTag(state.counter, 16);
-
253  return secure_compare(state.counter, tag, len);
-
254 }
-
255 
-
256 void GCMCommon::clear()
-
257 {
-
258  blockCipher->clear();
-
259  ghash.clear();
-
260  clean(state);
-
261  state.posn = 16;
-
262 }
-
263 
-
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:225
+
125  return true;
+
126 }
+
127 
+
133 static inline void increment(uint8_t counter[16])
+
134 {
+
135  uint16_t carry = 1;
+
136  carry += counter[15];
+
137  counter[15] = (uint8_t)carry;
+
138  carry = (carry >> 8) + counter[14];
+
139  counter[14] = (uint8_t)carry;
+
140  carry = (carry >> 8) + counter[13];
+
141  counter[13] = (uint8_t)carry;
+
142  carry = (carry >> 8) + counter[12];
+
143  counter[12] = (uint8_t)carry;
+
144 }
+
145 
+
146 void GCMCommon::encrypt(uint8_t *output, const uint8_t *input, size_t len)
+
147 {
+
148  // Finalize the authenticated data if necessary.
+
149  if (!state.dataStarted) {
+
150  ghash.pad();
+
151  state.dataStarted = true;
+
152  }
+
153 
+
154  // Encrypt the plaintext using the block cipher in counter mode.
+
155  uint8_t *out = output;
+
156  size_t size = len;
+
157  while (size > 0) {
+
158  // Create a new keystream block if necessary.
+
159  if (state.posn >= 16) {
+
160  increment(state.counter);
+
161  blockCipher->encryptBlock(state.stream, state.counter);
+
162  state.posn = 0;
+
163  }
+
164 
+
165  // Encrypt as many bytes as we can using the keystream block.
+
166  uint8_t temp = 16 - state.posn;
+
167  if (temp > size)
+
168  temp = size;
+
169  uint8_t *stream = state.stream + state.posn;
+
170  state.posn += temp;
+
171  size -= temp;
+
172  while (temp > 0) {
+
173  *out++ = *input++ ^ *stream++;
+
174  --temp;
+
175  }
+
176  }
+
177 
+
178  // Feed the ciphertext into the hash.
+
179  ghash.update(output, len);
+
180  state.dataSize += len;
+
181 }
+
182 
+
183 void GCMCommon::decrypt(uint8_t *output, const uint8_t *input, size_t len)
+
184 {
+
185  // Finalize the authenticated data if necessary.
+
186  if (!state.dataStarted) {
+
187  ghash.pad();
+
188  state.dataStarted = true;
+
189  }
+
190 
+
191  // Feed the ciphertext into the hash before we decrypt it.
+
192  ghash.update(input, len);
+
193  state.dataSize += len;
+
194 
+
195  // Decrypt the plaintext using the block cipher in counter mode.
+
196  while (len > 0) {
+
197  // Create a new keystream block if necessary.
+
198  if (state.posn >= 16) {
+
199  increment(state.counter);
+
200  blockCipher->encryptBlock(state.stream, state.counter);
+
201  state.posn = 0;
+
202  }
+
203 
+
204  // Decrypt as many bytes as we can using the keystream block.
+
205  uint8_t temp = 16 - state.posn;
+
206  if (temp > len)
+
207  temp = len;
+
208  uint8_t *stream = state.stream + state.posn;
+
209  state.posn += temp;
+
210  len -= temp;
+
211  while (temp > 0) {
+
212  *output++ = *input++ ^ *stream++;
+
213  --temp;
+
214  }
+
215  }
+
216 }
+
217 
+
218 void GCMCommon::addAuthData(const void *data, size_t len)
+
219 {
+
220  if (!state.dataStarted) {
+
221  ghash.update(data, len);
+
222  state.authSize += len;
+
223  }
+
224 }
+
225 
+
226 void GCMCommon::computeTag(void *tag, size_t len)
+
227 {
+
228  // Pad the hashed data and add the sizes.
+
229  ghash.pad();
+
230  uint64_t sizes[2] = {
+
231  htobe64(state.authSize * 8),
+
232  htobe64(state.dataSize * 8)
+
233  };
+
234  ghash.update(sizes, sizeof(sizes));
+
235  clean(sizes);
+
236 
+
237  // Get the finalized hash, encrypt it with the nonce, and return the tag.
+
238  ghash.finalize(state.stream, 16);
+
239  for (uint8_t posn = 0; posn < 16; ++posn)
+
240  state.stream[posn] ^= state.nonce[posn];
+
241  if (len > 16)
+
242  len = 16;
+
243  memcpy(tag, state.stream, len);
+
244 }
+
245 
+
246 bool GCMCommon::checkTag(const void *tag, size_t len)
+
247 {
+
248  // Can never match if the expected tag length is too long.
+
249  if (len > 16)
+
250  return false;
+
251 
+
252  // Compute the tag and check it.
+
253  computeTag(state.counter, 16);
+
254  return secure_compare(state.counter, tag, len);
+
255 }
+
256 
+
257 void GCMCommon::clear()
+
258 {
+
259  blockCipher->clear();
+
260  ghash.clear();
+
261  clean(state);
+
262  state.posn = 16;
+
263 }
+
264 
+
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:226
GCMCommon::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: GCM.cpp:77
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:72
-
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:145
-
GCMCommon::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: GCM.cpp:256
-
GCMCommon::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: GCM.cpp:245
+
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:146
+
GCMCommon::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: GCM.cpp:257
+
GCMCommon::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: GCM.cpp:246
GCMCommon::ivSize
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
Definition: GCM.cpp:66
GHASH::finalize
void finalize(void *token, size_t len)
Finalizes the authentication process and returns the token.
Definition: GHASH.cpp:121
-
GCMCommon::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: GCM.cpp:217
+
GCMCommon::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: GCM.cpp:218
GHASH::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: GHASH.cpp:85
BlockCipher::encryptBlock
virtual void encryptBlock(uint8_t *output, const uint8_t *input)=0
Encrypts a single block using this cipher.
-
GCMCommon::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: GCM.cpp:182
+
GCMCommon::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: GCM.cpp:183
BlockCipher::setKey
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
GCMCommon::GCMCommon
GCMCommon()
Constructs a new cipher in GCM mode.
Definition: GCM.cpp:44
GHASH::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: GHASH.cpp:137
@@ -352,7 +353,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GCM_8h_source.html b/GCM_8h_source.html index 1408f4d5..1d977c6b 100644 --- a/GCM_8h_source.html +++ b/GCM_8h_source.html @@ -168,20 +168,20 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
78 };
79 
80 #endif
-
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:225
+
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:226
GCM
Implementation of the Galois Counter Mode (GCM).
Definition: GCM.h:71
GCMCommon::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: GCM.cpp:77
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:72
-
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:145
+
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:146
BlockCipher
Abstract base class for block ciphers.
Definition: BlockCipher.h:29
GCM::GCM
GCM()
Constructs a new GCM object for the block cipher T.
Definition: GCM.h:74
AuthenticatedCipher
Abstract base class for authenticated ciphers.
Definition: AuthenticatedCipher.h:28
GCMCommon
Concrete base class to assist with implementing GCM for 128-bit block ciphers.
Definition: GCM.h:30
-
GCMCommon::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: GCM.cpp:256
-
GCMCommon::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: GCM.cpp:245
+
GCMCommon::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: GCM.cpp:257
+
GCMCommon::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: GCM.cpp:246
GCMCommon::ivSize
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
Definition: GCM.cpp:66
-
GCMCommon::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: GCM.cpp:217
-
GCMCommon::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: GCM.cpp:182
+
GCMCommon::addAuthData
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: GCM.cpp:218
+
GCMCommon::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: GCM.cpp:183
GCMCommon::GCMCommon
GCMCommon()
Constructs a new cipher in GCM mode.
Definition: GCM.cpp:44
GCMCommon::setBlockCipher
void setBlockCipher(BlockCipher *cipher)
Sets the block cipher to use for this GCM object.
Definition: GCM.h:54
GHASH
Implementation of the GHASH message authenticator.
Definition: GHASH.h:29
@@ -191,7 +191,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GF128_8cpp_source.html b/GF128_8cpp_source.html index 61515823..1106a9df 100644 --- a/GF128_8cpp_source.html +++ b/GF128_8cpp_source.html @@ -578,7 +578,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GF128_8h_source.html b/GF128_8h_source.html index c9319584..72559451 100644 --- a/GF128_8h_source.html +++ b/GF128_8h_source.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GHASH_8cpp_source.html b/GHASH_8cpp_source.html index 05ed615a..20b1c698 100644 --- a/GHASH_8cpp_source.html +++ b/GHASH_8cpp_source.html @@ -190,7 +190,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GHASH_8h_source.html b/GHASH_8h_source.html index 4ab3b601..e6fbf8dd 100644 --- a/GHASH_8h_source.html +++ b/GHASH_8h_source.html @@ -150,7 +150,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Hash_8cpp_source.html b/Hash_8cpp_source.html index 90845c39..60ffa11d 100644 --- a/Hash_8cpp_source.html +++ b/Hash_8cpp_source.html @@ -133,8 +133,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
171  finalize(block, len);
172  reset();
173  }
-
174  memset(block + len, pad, size - len);
-
175  uint8_t *b = (uint8_t *)block;
+
174  uint8_t *b = (uint8_t *)block;
+
175  memset(b + len, pad, size - len);
176  while (len > 0) {
177  *b++ ^= pad;
178  --len;
@@ -151,7 +151,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Hash_8h_source.html b/Hash_8h_source.html index 6d107e12..c6a32747 100644 --- a/Hash_8h_source.html +++ b/Hash_8h_source.html @@ -154,7 +154,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/I2CMaster_8cpp_source.html b/I2CMaster_8cpp_source.html index a1bce6a3..bb715e86 100644 --- a/I2CMaster_8cpp_source.html +++ b/I2CMaster_8cpp_source.html @@ -115,7 +115,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/I2CMaster_8h_source.html b/I2CMaster_8h_source.html index 9c093181..1f38ec76 100644 --- a/I2CMaster_8h_source.html +++ b/I2CMaster_8h_source.html @@ -140,7 +140,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/IRreceiver_8cpp_source.html b/IRreceiver_8cpp_source.html index 6d52b117..dfa71ebf 100644 --- a/IRreceiver_8cpp_source.html +++ b/IRreceiver_8cpp_source.html @@ -261,7 +261,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/IRreceiver_8h_source.html b/IRreceiver_8h_source.html index c47f6234..e5b4d905 100644 --- a/IRreceiver_8h_source.html +++ b/IRreceiver_8h_source.html @@ -157,7 +157,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/IntField_8cpp_source.html b/IntField_8cpp_source.html index c3320fdb..1ee8d1db 100644 --- a/IntField_8cpp_source.html +++ b/IntField_8cpp_source.html @@ -208,7 +208,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/IntField_8h_source.html b/IntField_8h_source.html index 09110ada..77b0df18 100644 --- a/IntField_8h_source.html +++ b/IntField_8h_source.html @@ -173,7 +173,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/KeccakCore_8cpp_source.html b/KeccakCore_8cpp_source.html index e19f05e5..1d6adaa3 100644 --- a/KeccakCore_8cpp_source.html +++ b/KeccakCore_8cpp_source.html @@ -1991,7 +1991,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/KeccakCore_8h_source.html b/KeccakCore_8h_source.html index 22693b7b..f6344f38 100644 --- a/KeccakCore_8h_source.html +++ b/KeccakCore_8h_source.html @@ -167,7 +167,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/LCD_8cpp_source.html b/LCD_8cpp_source.html index 5eb0b1f4..7db69108 100644 --- a/LCD_8cpp_source.html +++ b/LCD_8cpp_source.html @@ -290,7 +290,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/LCD_8h_source.html b/LCD_8h_source.html index 8c079be6..99b136e1 100644 --- a/LCD_8h_source.html +++ b/LCD_8h_source.html @@ -202,7 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ListField_8cpp_source.html b/ListField_8cpp_source.html index a871a919..9618a079 100644 --- a/ListField_8cpp_source.html +++ b/ListField_8cpp_source.html @@ -221,7 +221,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ListField_8h_source.html b/ListField_8h_source.html index 5ddcc74e..494d0dc7 100644 --- a/ListField_8h_source.html +++ b/ListField_8h_source.html @@ -159,7 +159,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/LoginShell_8cpp_source.html b/LoginShell_8cpp_source.html index a0bf537a..3654c2a4 100644 --- a/LoginShell_8cpp_source.html +++ b/LoginShell_8cpp_source.html @@ -126,7 +126,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/LoginShell_8h_source.html b/LoginShell_8h_source.html index 6dcc909c..873adf5f 100644 --- a/LoginShell_8h_source.html +++ b/LoginShell_8h_source.html @@ -155,7 +155,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Melody_8cpp_source.html b/Melody_8cpp_source.html index 8822bd8f..81d51270 100644 --- a/Melody_8cpp_source.html +++ b/Melody_8cpp_source.html @@ -215,7 +215,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Melody_8h_source.html b/Melody_8h_source.html index 1824ef42..c5660620 100644 --- a/Melody_8h_source.html +++ b/Melody_8h_source.html @@ -258,7 +258,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Mono5x7_8h_source.html b/Mono5x7_8h_source.html index 16abf477..b47fc09d 100644 --- a/Mono5x7_8h_source.html +++ b/Mono5x7_8h_source.html @@ -246,7 +246,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/NoiseSource_8cpp_source.html b/NoiseSource_8cpp_source.html index 5685844b..4e6b428e 100644 --- a/NoiseSource_8cpp_source.html +++ b/NoiseSource_8cpp_source.html @@ -138,7 +138,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/NoiseSource_8h_source.html b/NoiseSource_8h_source.html index 8c3b3b33..3a8104c8 100644 --- a/NoiseSource_8h_source.html +++ b/NoiseSource_8h_source.html @@ -142,7 +142,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/OFB_8cpp_source.html b/OFB_8cpp_source.html index fbc9e3c5..0c582fe6 100644 --- a/OFB_8cpp_source.html +++ b/OFB_8cpp_source.html @@ -206,7 +206,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/OFB_8h_source.html b/OFB_8h_source.html index 3ec20680..47bca086 100644 --- a/OFB_8h_source.html +++ b/OFB_8h_source.html @@ -171,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/OMAC_8cpp_source.html b/OMAC_8cpp_source.html index c37ea299..6151a749 100644 --- a/OMAC_8cpp_source.html +++ b/OMAC_8cpp_source.html @@ -208,7 +208,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/OMAC_8h_source.html b/OMAC_8h_source.html index 0219d36a..1230facd 100644 --- a/OMAC_8h_source.html +++ b/OMAC_8h_source.html @@ -152,7 +152,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Poly1305_8cpp_source.html b/Poly1305_8cpp_source.html index c55c2b56..3c4bf0cf 100644 --- a/Poly1305_8cpp_source.html +++ b/Poly1305_8cpp_source.html @@ -355,7 +355,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Poly1305_8h_source.html b/Poly1305_8h_source.html index 4fa0517d..fabac036 100644 --- a/Poly1305_8h_source.html +++ b/Poly1305_8h_source.html @@ -153,7 +153,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/PowerSave_8cpp_source.html b/PowerSave_8cpp_source.html index b5a9bd20..7515b29e 100644 --- a/PowerSave_8cpp_source.html +++ b/PowerSave_8cpp_source.html @@ -155,7 +155,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/PowerSave_8h_source.html b/PowerSave_8h_source.html index bb5cc2a1..56eb7607 100644 --- a/PowerSave_8h_source.html +++ b/PowerSave_8h_source.html @@ -158,7 +158,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RC5_8h_source.html b/RC5_8h_source.html index 2509bbbd..b59c23b0 100644 --- a/RC5_8h_source.html +++ b/RC5_8h_source.html @@ -435,7 +435,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RNG_8cpp_source.html b/RNG_8cpp_source.html index 9840181e..74ac6806 100644 --- a/RNG_8cpp_source.html +++ b/RNG_8cpp_source.html @@ -651,7 +651,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RNG_8h_source.html b/RNG_8h_source.html index a59f443a..dc299866 100644 --- a/RNG_8h_source.html +++ b/RNG_8h_source.html @@ -177,7 +177,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RTC_8cpp_source.html b/RTC_8cpp_source.html index 54a2e169..e2336711 100644 --- a/RTC_8cpp_source.html +++ b/RTC_8cpp_source.html @@ -380,7 +380,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RTC_8h_source.html b/RTC_8h_source.html index fd37987e..3ea6b832 100644 --- a/RTC_8h_source.html +++ b/RTC_8h_source.html @@ -237,7 +237,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RingOscillatorNoiseSource_8cpp_source.html b/RingOscillatorNoiseSource_8cpp_source.html index 7d80d52c..4477401e 100644 --- a/RingOscillatorNoiseSource_8cpp_source.html +++ b/RingOscillatorNoiseSource_8cpp_source.html @@ -285,7 +285,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/RingOscillatorNoiseSource_8h_source.html b/RingOscillatorNoiseSource_8h_source.html index 87e1cec3..5eec576d 100644 --- a/RingOscillatorNoiseSource_8h_source.html +++ b/RingOscillatorNoiseSource_8h_source.html @@ -145,7 +145,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA256_8cpp_source.html b/SHA256_8cpp_source.html index c4725c0f..3bacbcb0 100644 --- a/SHA256_8cpp_source.html +++ b/SHA256_8cpp_source.html @@ -339,7 +339,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA256_8h_source.html b/SHA256_8h_source.html index aaa8602e..06d4df22 100644 --- a/SHA256_8h_source.html +++ b/SHA256_8h_source.html @@ -160,7 +160,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA3_8cpp_source.html b/SHA3_8cpp_source.html index 4e903e83..8c3973ae 100644 --- a/SHA3_8cpp_source.html +++ b/SHA3_8cpp_source.html @@ -257,7 +257,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA3_8h_source.html b/SHA3_8h_source.html index 471871eb..5e170bb9 100644 --- a/SHA3_8h_source.html +++ b/SHA3_8h_source.html @@ -188,7 +188,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA512_8cpp_source.html b/SHA512_8cpp_source.html index d1fbbcaa..0ecb20f3 100644 --- a/SHA512_8cpp_source.html +++ b/SHA512_8cpp_source.html @@ -355,7 +355,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHA512_8h_source.html b/SHA512_8h_source.html index f41c6984..87e580b9 100644 --- a/SHA512_8h_source.html +++ b/SHA512_8h_source.html @@ -166,7 +166,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHAKE_8cpp_source.html b/SHAKE_8cpp_source.html index eb7ea353..9f0bc4d9 100644 --- a/SHAKE_8cpp_source.html +++ b/SHAKE_8cpp_source.html @@ -192,7 +192,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SHAKE_8h_source.html b/SHAKE_8h_source.html index 715de10b..f28fb65d 100644 --- a/SHAKE_8h_source.html +++ b/SHAKE_8h_source.html @@ -174,7 +174,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Shell_8cpp_source.html b/Shell_8cpp_source.html index 1ca46925..f7648e41 100644 --- a/Shell_8cpp_source.html +++ b/Shell_8cpp_source.html @@ -848,7 +848,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Shell_8h_source.html b/Shell_8h_source.html index 969db5b2..f2af49ef 100644 --- a/Shell_8h_source.html +++ b/Shell_8h_source.html @@ -273,7 +273,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SoftI2C_8cpp_source.html b/SoftI2C_8cpp_source.html index 848c4aab..47bcab34 100644 --- a/SoftI2C_8cpp_source.html +++ b/SoftI2C_8cpp_source.html @@ -283,7 +283,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SoftI2C_8h_source.html b/SoftI2C_8h_source.html index 7ed9a810..c06f016a 100644 --- a/SoftI2C_8h_source.html +++ b/SoftI2C_8h_source.html @@ -157,7 +157,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SpeckSmall_8cpp_source.html b/SpeckSmall_8cpp_source.html index 9dd084fe..bf3c6fc0 100644 --- a/SpeckSmall_8cpp_source.html +++ b/SpeckSmall_8cpp_source.html @@ -715,7 +715,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SpeckSmall_8h_source.html b/SpeckSmall_8h_source.html index 5a15f48e..5bbcff3f 100644 --- a/SpeckSmall_8h_source.html +++ b/SpeckSmall_8h_source.html @@ -141,7 +141,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SpeckTiny_8cpp_source.html b/SpeckTiny_8cpp_source.html index d3901398..00733179 100644 --- a/SpeckTiny_8cpp_source.html +++ b/SpeckTiny_8cpp_source.html @@ -596,7 +596,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SpeckTiny_8h_source.html b/SpeckTiny_8h_source.html index de2a4549..615db242 100644 --- a/SpeckTiny_8h_source.html +++ b/SpeckTiny_8h_source.html @@ -154,7 +154,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Speck_8cpp_source.html b/Speck_8cpp_source.html index 0d0031e8..b76ccbc0 100644 --- a/Speck_8cpp_source.html +++ b/Speck_8cpp_source.html @@ -679,7 +679,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Speck_8h_source.html b/Speck_8h_source.html index ec866be4..3471df0a 100644 --- a/Speck_8h_source.html +++ b/Speck_8h_source.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TelnetDefs_8h_source.html b/TelnetDefs_8h_source.html index f96f2805..cc852c43 100644 --- a/TelnetDefs_8h_source.html +++ b/TelnetDefs_8h_source.html @@ -205,7 +205,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Terminal_8cpp_source.html b/Terminal_8cpp_source.html index 81510583..06dcb904 100644 --- a/Terminal_8cpp_source.html +++ b/Terminal_8cpp_source.html @@ -1037,7 +1037,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Terminal_8h_source.html b/Terminal_8h_source.html index 4ef6e916..7e290dca 100644 --- a/Terminal_8h_source.html +++ b/Terminal_8h_source.html @@ -299,7 +299,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TextField_8cpp_source.html b/TextField_8cpp_source.html index d47ed3d0..0b372f4a 100644 --- a/TextField_8cpp_source.html +++ b/TextField_8cpp_source.html @@ -156,7 +156,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TextField_8h_source.html b/TextField_8h_source.html index ba58090b..b8e38dac 100644 --- a/TextField_8h_source.html +++ b/TextField_8h_source.html @@ -142,7 +142,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TimeField_8cpp_source.html b/TimeField_8cpp_source.html index 0f23c6f2..6dd1a3c1 100644 --- a/TimeField_8cpp_source.html +++ b/TimeField_8cpp_source.html @@ -325,7 +325,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TimeField_8h_source.html b/TimeField_8h_source.html index ed08fbda..fa7f68db 100644 --- a/TimeField_8h_source.html +++ b/TimeField_8h_source.html @@ -167,7 +167,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TransistorNoiseSource_8cpp_source.html b/TransistorNoiseSource_8cpp_source.html index 294bcf1d..cf1424a5 100644 --- a/TransistorNoiseSource_8cpp_source.html +++ b/TransistorNoiseSource_8cpp_source.html @@ -295,7 +295,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/TransistorNoiseSource_8h_source.html b/TransistorNoiseSource_8h_source.html index 5d6dfad8..e00b07f4 100644 --- a/TransistorNoiseSource_8h_source.html +++ b/TransistorNoiseSource_8h_source.html @@ -151,7 +151,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/USBKeysExtra_8h_source.html b/USBKeysExtra_8h_source.html index edca3a01..78f12b32 100644 --- a/USBKeysExtra_8h_source.html +++ b/USBKeysExtra_8h_source.html @@ -215,7 +215,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/XOF_8cpp_source.html b/XOF_8cpp_source.html index 50075a84..6dd29280 100644 --- a/XOF_8cpp_source.html +++ b/XOF_8cpp_source.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/XOF_8h_source.html b/XOF_8h_source.html index ef516327..1215f761 100644 --- a/XOF_8h_source.html +++ b/XOF_8h_source.html @@ -152,7 +152,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/XTS_8cpp_source.html b/XTS_8cpp_source.html index f23c8a46..d8c1aee1 100644 --- a/XTS_8cpp_source.html +++ b/XTS_8cpp_source.html @@ -290,7 +290,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/XTS_8h_source.html b/XTS_8h_source.html index b8ee1052..db2dfe7c 100644 --- a/XTS_8h_source.html +++ b/XTS_8h_source.html @@ -217,7 +217,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/alarm-clock_8dox.html b/alarm-clock_8dox.html index c8c49d8e..898ec337 100644 --- a/alarm-clock_8dox.html +++ b/alarm-clock_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/alarm_clock.html b/alarm_clock.html index ac2168de..ca677166 100644 --- a/alarm_clock.html +++ b/alarm_clock.html @@ -140,7 +140,7 @@ Completed Clock diff --git a/annotated.html b/annotated.html index fa4d6b86..a79ee56d 100644 --- a/annotated.html +++ b/annotated.html @@ -174,7 +174,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink-blink_8dox.html b/blink-blink_8dox.html index 1836cede..05b2bf89 100644 --- a/blink-blink_8dox.html +++ b/blink-blink_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink-charlieplex_8dox.html b/blink-charlieplex_8dox.html index 2e67bafa..213326a7 100644 --- a/blink-charlieplex_8dox.html +++ b/blink-charlieplex_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink-cylon_8dox.html b/blink-cylon_8dox.html index bf0885c7..85eac688 100644 --- a/blink-cylon_8dox.html +++ b/blink-cylon_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink-startrek_8dox.html b/blink-startrek_8dox.html index 024606c8..eab3bb92 100644 --- a/blink-startrek_8dox.html +++ b/blink-startrek_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink_blink.html b/blink_blink.html index 33fec583..fab855a4 100644 --- a/blink_blink.html +++ b/blink_blink.html @@ -120,7 +120,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink_charlieplex.html b/blink_charlieplex.html index f24929c9..6f55d6b2 100644 --- a/blink_charlieplex.html +++ b/blink_charlieplex.html @@ -160,7 +160,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink_cylon.html b/blink_cylon.html index 7a5d204e..6f44f4ae 100644 --- a/blink_cylon.html +++ b/blink_cylon.html @@ -171,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/blink_startrek.html b/blink_startrek.html index 0474de9c..32a2d75a 100644 --- a/blink_startrek.html +++ b/blink_startrek.html @@ -237,7 +237,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAES128-members.html b/classAES128-members.html index 6ac77dfe..3a0c964b 100644 --- a/classAES128-members.html +++ b/classAES128-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAES128.html b/classAES128.html index 81dd6b09..b953491c 100644 --- a/classAES128.html +++ b/classAES128.html @@ -265,7 +265,7 @@ Additional Inherited Members diff --git a/classAES192-members.html b/classAES192-members.html index 89744e86..bb26c4a1 100644 --- a/classAES192-members.html +++ b/classAES192-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAES192.html b/classAES192.html index 83ca39ee..fe3c8026 100644 --- a/classAES192.html +++ b/classAES192.html @@ -265,7 +265,7 @@ Additional Inherited Members diff --git a/classAES256-members.html b/classAES256-members.html index f928dd42..75520813 100644 --- a/classAES256-members.html +++ b/classAES256-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAES256.html b/classAES256.html index 5599802e..885b0448 100644 --- a/classAES256.html +++ b/classAES256.html @@ -265,7 +265,7 @@ Additional Inherited Members diff --git a/classAESCommon-members.html b/classAESCommon-members.html index 94ffe4b3..18bbf5d7 100644 --- a/classAESCommon-members.html +++ b/classAESCommon-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAESCommon.html b/classAESCommon.html index 87124d42..1667b4f5 100644 --- a/classAESCommon.html +++ b/classAESCommon.html @@ -322,7 +322,7 @@ Protected Member Functions diff --git a/classAuthenticatedCipher-members.html b/classAuthenticatedCipher-members.html index 8427b1c7..5a90f83b 100644 --- a/classAuthenticatedCipher-members.html +++ b/classAuthenticatedCipher-members.html @@ -108,7 +108,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classAuthenticatedCipher.html b/classAuthenticatedCipher.html index 8d447507..1604b88a 100644 --- a/classAuthenticatedCipher.html +++ b/classAuthenticatedCipher.html @@ -351,7 +351,7 @@ virtual  diff --git a/classBLAKE2b-members.html b/classBLAKE2b-members.html index 0fbe9bd0..ab5275eb 100644 --- a/classBLAKE2b-members.html +++ b/classBLAKE2b-members.html @@ -105,14 +105,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); m (defined in BLAKE2b)BLAKE2b reset()BLAKE2bvirtual reset(uint8_t outputLength)BLAKE2b - resetHMAC(const void *key, size_t keyLen)BLAKE2bvirtual - update(const void *data, size_t len)BLAKE2bvirtual - ~BLAKE2b()BLAKE2bvirtual - ~Hash()Hashvirtual + reset(const void *key, size_t keyLen, uint8_t outputLength=64)BLAKE2b + resetHMAC(const void *key, size_t keyLen)BLAKE2bvirtual + update(const void *data, size_t len)BLAKE2bvirtual + ~BLAKE2b()BLAKE2bvirtual + ~Hash()Hashvirtual diff --git a/classBLAKE2b.html b/classBLAKE2b.html index 36a9d81d..abf4e82c 100644 --- a/classBLAKE2b.html +++ b/classBLAKE2b.html @@ -127,6 +127,9 @@ virtual void reset (uint8_t outputLength)  Resets the hash ready for a new hashing process with a specified output length. More...
  +void reset (const void *key, size_t keyLen, uint8_t outputLength=64) + Resets the hash ready for a new hashing process with a specified key and output length. More...
+  void update (const void *data, size_t len)  Updates the hash with more data. More...
  @@ -161,7 +164,23 @@ Additional Inherited Members

Detailed Description

BLAKE2b hash algorithm.

BLAKE2b is a variation on the ChaCha stream cipher, designed for hashing, with a 512-bit hash output. It is intended as a high performance replacement for SHA512 for when speed is critical but exact SHA512 compatibility is not.

-

Reference: https://blake2.net/

+

This class supports two types of keyed hash. The BLAKE2 keyed hash and traditional HMAC. The BLAKE2 keyed hash is recommended unless there is some higher-level application need to be compatible with the HMAC construction. The keyed hash is computed as follows:

+
BLAKE2b blake;
+
blake.reset(key, sizeof(key), outputLength);
+
blake.update(data1, sizeof(data1));
+
blake.update(data2, sizeof(data2));
+
...
+
blake.update(dataN, sizeof(dataN));
+
blake.finalize(hash, outputLength);
+

The HMAC is computed as follows (the output length is always 64):

+
BLAKE2b blake;
+
blake.resetHMAC(key, sizeof(key));
+
blake.update(data1, sizeof(data1));
+
blake.update(data2, sizeof(data2));
+
...
+
blake.update(dataN, sizeof(dataN));
+
blake.finalizeHMAC(key, sizeof(key), hash, 32);
+

References: https://blake2.net/, RFC 7693

See Also
BLAKE2s, SHA512, SHA3_512

Definition at line 28 of file BLAKE2b.h.

@@ -192,7 +211,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 66 of file BLAKE2b.cpp.

+

Definition at line 94 of file BLAKE2b.cpp.

@@ -222,7 +241,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 159 of file BLAKE2b.cpp.

+

Definition at line 233 of file BLAKE2b.cpp.

@@ -272,7 +291,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 143 of file BLAKE2b.cpp.

+

Definition at line 217 of file BLAKE2b.cpp.

@@ -334,7 +353,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 172 of file BLAKE2b.cpp.

+

Definition at line 246 of file BLAKE2b.cpp.

@@ -364,7 +383,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 61 of file BLAKE2b.cpp.

+

Definition at line 89 of file BLAKE2b.cpp.

@@ -394,7 +413,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 81 of file BLAKE2b.cpp.

+

Definition at line 109 of file BLAKE2b.cpp.

@@ -420,7 +439,52 @@ Additional Inherited Members -

Definition at line 103 of file BLAKE2b.cpp.

+

Definition at line 131 of file BLAKE2b.cpp.

+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void BLAKE2b::reset (const void * key,
size_t keyLen,
uint8_t outputLength = 64 
)
+
+ +

Resets the hash ready for a new hashing process with a specified key and output length.

+
Parameters
+ + + + +
keyPoints to the key.
keyLenThe length of the key in bytes, between 0 and 64.
outputLengthThe output length to use for the final hash in bytes, between 1 and 64.
+
+
+

If keyLen is greater than 64, then the key will be truncated to the first 64 bytes.

+ +

Definition at line 162 of file BLAKE2b.cpp.

@@ -476,7 +540,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 165 of file BLAKE2b.cpp.

+

Definition at line 239 of file BLAKE2b.cpp.

@@ -525,7 +589,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 118 of file BLAKE2b.cpp.

+

Definition at line 192 of file BLAKE2b.cpp.

@@ -536,7 +600,7 @@ Additional Inherited Members diff --git a/classBLAKE2s-members.html b/classBLAKE2s-members.html index 149aaccd..41063e57 100644 --- a/classBLAKE2s-members.html +++ b/classBLAKE2s-members.html @@ -104,14 +104,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); m (defined in BLAKE2s)BLAKE2s reset()BLAKE2svirtual reset(uint8_t outputLength)BLAKE2s - resetHMAC(const void *key, size_t keyLen)BLAKE2svirtual - update(const void *data, size_t len)BLAKE2svirtual - ~BLAKE2s()BLAKE2svirtual - ~Hash()Hashvirtual + reset(const void *key, size_t keyLen, uint8_t outputLength=32)BLAKE2s + resetHMAC(const void *key, size_t keyLen)BLAKE2svirtual + update(const void *data, size_t len)BLAKE2svirtual + ~BLAKE2s()BLAKE2svirtual + ~Hash()Hashvirtual diff --git a/classBLAKE2s.html b/classBLAKE2s.html index 5da0602f..80560e84 100644 --- a/classBLAKE2s.html +++ b/classBLAKE2s.html @@ -127,6 +127,9 @@ virtual void reset (uint8_t outputLength)  Resets the hash ready for a new hashing process with a specified output length. More...
  +void reset (const void *key, size_t keyLen, uint8_t outputLength=32) + Resets the hash ready for a new hashing process with a specified key and output length. More...
+  void update (const void *data, size_t len)  Updates the hash with more data. More...
  @@ -161,7 +164,23 @@ Additional Inherited Members

Detailed Description

BLAKE2s hash algorithm.

BLAKE2s is a variation on the ChaCha stream cipher, designed for hashing, with a 256-bit hash output. It is intended as a high performance replacement for SHA256 for when speed is critical but exact SHA256 compatibility is not.

-

Reference: https://blake2.net/

+

This class supports two types of keyed hash. The BLAKE2 keyed hash and traditional HMAC. The BLAKE2 keyed hash is recommended unless there is some higher-level application need to be compatible with the HMAC construction. The keyed hash is computed as follows:

+
BLAKE2s blake;
+
blake.reset(key, sizeof(key), outputLength);
+
blake.update(data1, sizeof(data1));
+
blake.update(data2, sizeof(data2));
+
...
+
blake.update(dataN, sizeof(dataN));
+
blake.finalize(hash, outputLength);
+

The HMAC is computed as follows (the output length is always 32):

+
BLAKE2s blake;
+
blake.resetHMAC(key, sizeof(key));
+
blake.update(data1, sizeof(data1));
+
blake.update(data2, sizeof(data2));
+
...
+
blake.update(dataN, sizeof(dataN));
+
blake.finalizeHMAC(key, sizeof(key), hash, 32);
+

References: https://blake2.net/, RFC 7693

See Also
BLAKE2b, SHA256, SHA3_256

Definition at line 28 of file BLAKE2s.h.

@@ -192,7 +211,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 66 of file BLAKE2s.cpp.

+

Definition at line 94 of file BLAKE2s.cpp.

@@ -222,7 +241,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 154 of file BLAKE2s.cpp.

+

Definition at line 227 of file BLAKE2s.cpp.

@@ -272,7 +291,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 138 of file BLAKE2s.cpp.

+

Definition at line 211 of file BLAKE2s.cpp.

@@ -334,7 +353,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 167 of file BLAKE2s.cpp.

+

Definition at line 240 of file BLAKE2s.cpp.

@@ -364,7 +383,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 61 of file BLAKE2s.cpp.

+

Definition at line 89 of file BLAKE2s.cpp.

@@ -394,7 +413,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 81 of file BLAKE2s.cpp.

+

Definition at line 109 of file BLAKE2s.cpp.

@@ -420,7 +439,52 @@ Additional Inherited Members -

Definition at line 102 of file BLAKE2s.cpp.

+

Definition at line 130 of file BLAKE2s.cpp.

+ + + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void BLAKE2s::reset (const void * key,
size_t keyLen,
uint8_t outputLength = 32 
)
+
+ +

Resets the hash ready for a new hashing process with a specified key and output length.

+
Parameters
+ + + + +
keyPoints to the key.
keyLenThe length of the key in bytes, between 0 and 32.
outputLengthThe output length to use for the final hash in bytes, between 1 and 32.
+
+
+

If keyLen is greater than 32, then the key will be truncated to the first 32 bytes.

+ +

Definition at line 160 of file BLAKE2s.cpp.

@@ -476,7 +540,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 160 of file BLAKE2s.cpp.

+

Definition at line 233 of file BLAKE2s.cpp.

@@ -525,7 +589,7 @@ Additional Inherited Members

Implements Hash.

-

Definition at line 116 of file BLAKE2s.cpp.

+

Definition at line 189 of file BLAKE2s.cpp.

@@ -536,7 +600,7 @@ Additional Inherited Members diff --git a/classBigNumberUtil-members.html b/classBigNumberUtil-members.html index f62728a8..f4216529 100644 --- a/classBigNumberUtil-members.html +++ b/classBigNumberUtil-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBigNumberUtil.html b/classBigNumberUtil.html index a4e07811..21b5a558 100644 --- a/classBigNumberUtil.html +++ b/classBigNumberUtil.html @@ -893,7 +893,7 @@ Static Public Member Functions diff --git a/classBitmap-members.html b/classBitmap-members.html index 42a1a217..60173648 100644 --- a/classBitmap-members.html +++ b/classBitmap-members.html @@ -138,7 +138,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBitmap.html b/classBitmap.html index 88ec4edf..b9bac106 100644 --- a/classBitmap.html +++ b/classBitmap.html @@ -1745,7 +1745,7 @@ class DMD diff --git a/classBlinkLED-members.html b/classBlinkLED-members.html index c3958a21..94ffae55 100644 --- a/classBlinkLED-members.html +++ b/classBlinkLED-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBlinkLED.html b/classBlinkLED.html index 97b80471..dbcc2115 100644 --- a/classBlinkLED.html +++ b/classBlinkLED.html @@ -428,7 +428,7 @@ Public Member Functions diff --git a/classBlockCipher-members.html b/classBlockCipher-members.html index 2c06a376..cb25905d 100644 --- a/classBlockCipher-members.html +++ b/classBlockCipher-members.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBlockCipher.html b/classBlockCipher.html index 194d1e05..c5398a36 100644 --- a/classBlockCipher.html +++ b/classBlockCipher.html @@ -410,7 +410,7 @@ Public Member Functions diff --git a/classBoolField-members.html b/classBoolField-members.html index e1f80f00..d93e9524 100644 --- a/classBoolField-members.html +++ b/classBoolField-members.html @@ -113,7 +113,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBoolField.html b/classBoolField.html index 694fbfdc..a2d5c5fb 100644 --- a/classBoolField.html +++ b/classBoolField.html @@ -506,7 +506,7 @@ LiquidCrystal *  diff --git a/classCBC-members.html b/classCBC-members.html index 89751bb3..44d7f715 100644 --- a/classCBC-members.html +++ b/classCBC-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCBC.html b/classCBC.html index 23f1b6b7..a2cd5aef 100644 --- a/classCBC.html +++ b/classCBC.html @@ -185,7 +185,7 @@ class CBC< T > diff --git a/classCBCCommon-members.html b/classCBCCommon-members.html index 62a8fd72..481967df 100644 --- a/classCBCCommon-members.html +++ b/classCBCCommon-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCBCCommon.html b/classCBCCommon.html index 691e1674..d9bcf3ba 100644 --- a/classCBCCommon.html +++ b/classCBCCommon.html @@ -534,7 +534,7 @@ Protected Member Functions diff --git a/classCFB-members.html b/classCFB-members.html index 06e00ddb..81122d12 100644 --- a/classCFB-members.html +++ b/classCFB-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCFB.html b/classCFB.html index 0e1fb9e3..2436974f 100644 --- a/classCFB.html +++ b/classCFB.html @@ -185,7 +185,7 @@ class CFB< T > diff --git a/classCFBCommon-members.html b/classCFBCommon-members.html index 8144f886..fd5489c8 100644 --- a/classCFBCommon-members.html +++ b/classCFBCommon-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCFBCommon.html b/classCFBCommon.html index de39d4e3..0b925b04 100644 --- a/classCFBCommon.html +++ b/classCFBCommon.html @@ -534,7 +534,7 @@ Protected Member Functions diff --git a/classCTR-members.html b/classCTR-members.html index 91e577a0..9252ca69 100644 --- a/classCTR-members.html +++ b/classCTR-members.html @@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCTR.html b/classCTR.html index 72290ae8..538fdb35 100644 --- a/classCTR.html +++ b/classCTR.html @@ -181,7 +181,7 @@ class CTR< T > diff --git a/classCTRCommon-members.html b/classCTRCommon-members.html index 68245a61..091f6750 100644 --- a/classCTRCommon-members.html +++ b/classCTRCommon-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCTRCommon.html b/classCTRCommon.html index 88a660d4..7b96d6f7 100644 --- a/classCTRCommon.html +++ b/classCTRCommon.html @@ -563,7 +563,7 @@ Protected Member Functions diff --git a/classChaCha-members.html b/classChaCha-members.html index 6e7291f8..bf88f010 100644 --- a/classChaCha-members.html +++ b/classChaCha-members.html @@ -109,7 +109,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classChaCha.html b/classChaCha.html index a5f26642..e9cb4392 100644 --- a/classChaCha.html +++ b/classChaCha.html @@ -673,7 +673,7 @@ class ChaChaPoly< diff --git a/classChaChaPoly-members.html b/classChaChaPoly-members.html index c2b14fdf..3454ec44 100644 --- a/classChaChaPoly-members.html +++ b/classChaChaPoly-members.html @@ -115,7 +115,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classChaChaPoly.html b/classChaChaPoly.html index 4e99dcce..838b8c40 100644 --- a/classChaChaPoly.html +++ b/classChaChaPoly.html @@ -220,7 +220,7 @@ virtual AuthenticatedCipher.

-

Definition at line 126 of file ChaChaPoly.cpp.

+

Definition at line 127 of file ChaChaPoly.cpp.

@@ -271,7 +271,7 @@ virtual AuthenticatedCipher.

-

Definition at line 149 of file ChaChaPoly.cpp.

+

Definition at line 150 of file ChaChaPoly.cpp.

@@ -301,7 +301,7 @@ virtual Cipher.

-

Definition at line 163 of file ChaChaPoly.cpp.

+

Definition at line 164 of file ChaChaPoly.cpp.

@@ -349,7 +349,7 @@ virtual AuthenticatedCipher.

-

Definition at line 134 of file ChaChaPoly.cpp.

+

Definition at line 135 of file ChaChaPoly.cpp.

@@ -405,7 +405,7 @@ virtual Cipher.

-

Definition at line 115 of file ChaChaPoly.cpp.

+

Definition at line 116 of file ChaChaPoly.cpp.

@@ -461,7 +461,7 @@ virtual Cipher.

-

Definition at line 104 of file ChaChaPoly.cpp.

+

Definition at line 105 of file ChaChaPoly.cpp.

@@ -665,7 +665,7 @@ virtual  diff --git a/classCharlieplex-members.html b/classCharlieplex-members.html index 689a64fe..b2f4ee49 100644 --- a/classCharlieplex-members.html +++ b/classCharlieplex-members.html @@ -104,7 +104,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCharlieplex.html b/classCharlieplex.html index 7e39c360..f375068b 100644 --- a/classCharlieplex.html +++ b/classCharlieplex.html @@ -538,7 +538,7 @@ Public Member Functions diff --git a/classChaseLEDs-members.html b/classChaseLEDs-members.html index 2a1317a3..c0a090a3 100644 --- a/classChaseLEDs-members.html +++ b/classChaseLEDs-members.html @@ -99,7 +99,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classChaseLEDs.html b/classChaseLEDs.html index 6fe3905a..11d8dc55 100644 --- a/classChaseLEDs.html +++ b/classChaseLEDs.html @@ -347,7 +347,7 @@ Protected Member Functions diff --git a/classCipher-members.html b/classCipher-members.html index d31d794a..ee99ae5d 100644 --- a/classCipher-members.html +++ b/classCipher-members.html @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCipher.html b/classCipher.html index b034b2f5..24b12bbf 100644 --- a/classCipher.html +++ b/classCipher.html @@ -485,7 +485,7 @@ Public Member Functions diff --git a/classCurve25519-members.html b/classCurve25519-members.html index 969c6847..6ac4d011 100644 --- a/classCurve25519-members.html +++ b/classCurve25519-members.html @@ -97,7 +97,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classCurve25519.html b/classCurve25519.html index 6072d989..f75790ff 100644 --- a/classCurve25519.html +++ b/classCurve25519.html @@ -303,7 +303,7 @@ class Ed25519 diff --git a/classDMD-members.html b/classDMD-members.html index 2be9b38c..3d5105e3 100644 --- a/classDMD-members.html +++ b/classDMD-members.html @@ -150,7 +150,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classDMD.html b/classDMD.html index 37dab271..f839ccf2 100644 --- a/classDMD.html +++ b/classDMD.html @@ -755,7 +755,7 @@ Multiple panels diff --git a/classDS1307RTC-members.html b/classDS1307RTC-members.html index c628349a..a798f09e 100644 --- a/classDS1307RTC-members.html +++ b/classDS1307RTC-members.html @@ -125,7 +125,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classDS1307RTC.html b/classDS1307RTC.html index d59c8d5f..ea811f45 100644 --- a/classDS1307RTC.html +++ b/classDS1307RTC.html @@ -598,7 +598,7 @@ static const uint8_t  diff --git a/classDS3231RTC-members.html b/classDS3231RTC-members.html index ac0ce67c..46069603 100644 --- a/classDS3231RTC-members.html +++ b/classDS3231RTC-members.html @@ -133,7 +133,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classDS3231RTC.html b/classDS3231RTC.html index e017207d..511bfe95 100644 --- a/classDS3231RTC.html +++ b/classDS3231RTC.html @@ -713,7 +713,7 @@ static const uint8_t  diff --git a/classDS3232RTC-members.html b/classDS3232RTC-members.html index 5085ab01..d7646fe3 100644 --- a/classDS3232RTC-members.html +++ b/classDS3232RTC-members.html @@ -130,7 +130,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classDS3232RTC.html b/classDS3232RTC.html index 665803f8..dcc8e773 100644 --- a/classDS3232RTC.html +++ b/classDS3232RTC.html @@ -750,7 +750,7 @@ static const uint8_t  diff --git a/classEAX-members.html b/classEAX-members.html index 5dc67aa6..027563da 100644 --- a/classEAX-members.html +++ b/classEAX-members.html @@ -118,7 +118,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classEAX.html b/classEAX.html index 85dc3f1d..d5d6c262 100644 --- a/classEAX.html +++ b/classEAX.html @@ -219,7 +219,7 @@ class EAX< T > diff --git a/classEAXCommon-members.html b/classEAXCommon-members.html index cd29f937..42e93094 100644 --- a/classEAXCommon-members.html +++ b/classEAXCommon-members.html @@ -117,7 +117,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classEAXCommon.html b/classEAXCommon.html index 9fc0be0f..19563807 100644 --- a/classEAXCommon.html +++ b/classEAXCommon.html @@ -732,7 +732,7 @@ Protected Member Functions diff --git a/classEEPROM24-members.html b/classEEPROM24-members.html index b1053cfe..cf7b7c7a 100644 --- a/classEEPROM24-members.html +++ b/classEEPROM24-members.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classEEPROM24.html b/classEEPROM24.html index 9fff5c55..01c00eaf 100644 --- a/classEEPROM24.html +++ b/classEEPROM24.html @@ -431,7 +431,7 @@ Public Member Functions diff --git a/classEd25519-members.html b/classEd25519-members.html index 13b13844..d4c74bbd 100644 --- a/classEd25519-members.html +++ b/classEd25519-members.html @@ -97,7 +97,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classEd25519.html b/classEd25519.html index e1c29c22..56311368 100644 --- a/classEd25519.html +++ b/classEd25519.html @@ -354,7 +354,7 @@ Static Public Member Functions diff --git a/classField-members.html b/classField-members.html index e3ad81bb..00d56a57 100644 --- a/classField-members.html +++ b/classField-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classField.html b/classField.html index fc4f1fa1..c8339955 100644 --- a/classField.html +++ b/classField.html @@ -424,7 +424,7 @@ class Form diff --git a/classForm-members.html b/classForm-members.html index ffa638fc..ec361e16 100644 --- a/classForm-members.html +++ b/classForm-members.html @@ -108,7 +108,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classForm.html b/classForm.html index a9a981d6..9e67db18 100644 --- a/classForm.html +++ b/classForm.html @@ -485,7 +485,7 @@ class Field diff --git a/classGCM-members.html b/classGCM-members.html index 7316a0c2..10eb14b4 100644 --- a/classGCM-members.html +++ b/classGCM-members.html @@ -119,7 +119,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classGCM.html b/classGCM.html index 80ded69e..661199da 100644 --- a/classGCM.html +++ b/classGCM.html @@ -223,7 +223,7 @@ class GCM< T > diff --git a/classGCMCommon-members.html b/classGCMCommon-members.html index e93fcd63..fb04d64e 100644 --- a/classGCMCommon-members.html +++ b/classGCMCommon-members.html @@ -118,7 +118,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classGCMCommon.html b/classGCMCommon.html index ec1f9322..8d6c6bf8 100644 --- a/classGCMCommon.html +++ b/classGCMCommon.html @@ -255,7 +255,7 @@ Protected Member Functions

Implements AuthenticatedCipher.

-

Definition at line 217 of file GCM.cpp.

+

Definition at line 218 of file GCM.cpp.

@@ -306,7 +306,7 @@ Protected Member Functions

Implements AuthenticatedCipher.

-

Definition at line 245 of file GCM.cpp.

+

Definition at line 246 of file GCM.cpp.

@@ -336,7 +336,7 @@ Protected Member Functions

Implements Cipher.

-

Definition at line 256 of file GCM.cpp.

+

Definition at line 257 of file GCM.cpp.

@@ -384,7 +384,7 @@ Protected Member Functions

Implements AuthenticatedCipher.

-

Definition at line 225 of file GCM.cpp.

+

Definition at line 226 of file GCM.cpp.

@@ -440,7 +440,7 @@ Protected Member Functions

Implements Cipher.

-

Definition at line 182 of file GCM.cpp.

+

Definition at line 183 of file GCM.cpp.

@@ -496,7 +496,7 @@ Protected Member Functions

Implements Cipher.

-

Definition at line 145 of file GCM.cpp.

+

Definition at line 146 of file GCM.cpp.

@@ -736,7 +736,7 @@ Protected Member Functions diff --git a/classGF128-members.html b/classGF128-members.html index 33c1d140..99cf5022 100644 --- a/classGF128-members.html +++ b/classGF128-members.html @@ -98,7 +98,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classGF128.html b/classGF128.html index 0d37354f..1dcfe93e 100644 --- a/classGF128.html +++ b/classGF128.html @@ -334,7 +334,7 @@ Static Public Member Functions diff --git a/classGHASH-members.html b/classGHASH-members.html index 7f1a5cc7..43166f6a 100644 --- a/classGHASH-members.html +++ b/classGHASH-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classGHASH.html b/classGHASH.html index 1ba96eb2..400c9a06 100644 --- a/classGHASH.html +++ b/classGHASH.html @@ -265,7 +265,7 @@ void  diff --git a/classHash-members.html b/classHash-members.html index 5f055e83..663181ce 100644 --- a/classHash-members.html +++ b/classHash-members.html @@ -104,7 +104,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classHash.html b/classHash.html index 5f9d96bc..86f7ae1b 100644 --- a/classHash.html +++ b/classHash.html @@ -239,7 +239,7 @@ Protected Member Functions

Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process.

See Also
reset()
-

Implemented in SHA3_512, SHA512, BLAKE2b, BLAKE2s, SHA3_256, and SHA256.

+

Implemented in SHA3_512, BLAKE2b, BLAKE2s, SHA512, SHA3_256, and SHA256.

@@ -287,7 +287,7 @@ Protected Member Functions

If finalize() is called again, then the returned hash value is undefined. Call reset() first to start a new hashing process.

See Also
reset(), update(), finalizeHMAC()
-

Implemented in SHA3_512, SHA512, BLAKE2b, BLAKE2s, SHA3_256, and SHA256.

+

Implemented in SHA3_512, BLAKE2b, BLAKE2s, SHA512, SHA3_256, and SHA256.

@@ -347,7 +347,7 @@ Protected Member Functions
See Also
resetHMAC(), finalize()
-

Implemented in SHA3_512, SHA512, BLAKE2b, BLAKE2s, SHA3_256, and SHA256.

+

Implemented in SHA3_512, BLAKE2b, BLAKE2s, SHA512, SHA3_256, and SHA256.

@@ -517,7 +517,7 @@ Protected Member Functions

The same key must be passed to both resetHMAC() and finalizeHMAC().

See Also
finalizeHMAC(), reset()
-

Implemented in SHA3_512, SHA512, BLAKE2b, BLAKE2s, SHA3_256, and SHA256.

+

Implemented in SHA3_512, BLAKE2b, BLAKE2s, SHA512, SHA3_256, and SHA256.

@@ -564,7 +564,7 @@ Protected Member Functions

If finalize() has already been called, then the behavior of update() will be undefined. Call reset() first to start a new hashing process.

See Also
reset(), finalize()
-

Implemented in SHA3_512, SHA512, BLAKE2b, BLAKE2s, SHA3_256, and SHA256.

+

Implemented in SHA3_512, BLAKE2b, BLAKE2s, SHA512, SHA3_256, and SHA256.

@@ -575,7 +575,7 @@ Protected Member Functions diff --git a/classI2CMaster-members.html b/classI2CMaster-members.html index 95f79a36..b729ca8c 100644 --- a/classI2CMaster-members.html +++ b/classI2CMaster-members.html @@ -100,7 +100,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classI2CMaster.html b/classI2CMaster.html index f6ebf352..e2b34c33 100644 --- a/classI2CMaster.html +++ b/classI2CMaster.html @@ -328,7 +328,7 @@ virtual unsigned int  diff --git a/classIRreceiver-members.html b/classIRreceiver-members.html index a578b7c0..4c3b7f61 100644 --- a/classIRreceiver-members.html +++ b/classIRreceiver-members.html @@ -100,7 +100,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classIRreceiver.html b/classIRreceiver.html index dfa8f32c..9fe9e66c 100644 --- a/classIRreceiver.html +++ b/classIRreceiver.html @@ -328,7 +328,7 @@ void _IR_receive_interrupt diff --git a/classIntField-members.html b/classIntField-members.html index c4397baa..aaebe8bc 100644 --- a/classIntField-members.html +++ b/classIntField-members.html @@ -118,7 +118,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classIntField.html b/classIntField.html index bb4efecd..1a25eb4c 100644 --- a/classIntField.html +++ b/classIntField.html @@ -647,7 +647,7 @@ LiquidCrystal *  diff --git a/classKeccakCore-members.html b/classKeccakCore-members.html index 37926b8b..624c472e 100644 --- a/classKeccakCore-members.html +++ b/classKeccakCore-members.html @@ -108,7 +108,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classKeccakCore.html b/classKeccakCore.html index f61e304f..3d5ff17a 100644 --- a/classKeccakCore.html +++ b/classKeccakCore.html @@ -475,7 +475,7 @@ void  diff --git a/classLCD-members.html b/classLCD-members.html index 930f26aa..1eb90768 100644 --- a/classLCD-members.html +++ b/classLCD-members.html @@ -110,7 +110,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classLCD.html b/classLCD.html index 4079035c..2ebe4f55 100644 --- a/classLCD.html +++ b/classLCD.html @@ -592,7 +592,7 @@ Support for DFRobot LCD Shield diff --git a/classListField-members.html b/classListField-members.html index 4427ce5e..98491943 100644 --- a/classListField-members.html +++ b/classListField-members.html @@ -111,7 +111,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classListField.html b/classListField.html index d0ab5ca0..839a23bd 100644 --- a/classListField.html +++ b/classListField.html @@ -411,7 +411,7 @@ LiquidCrystal *  diff --git a/classLoginShell-members.html b/classLoginShell-members.html index f478be68..39a07a2f 100644 --- a/classLoginShell-members.html +++ b/classLoginShell-members.html @@ -180,7 +180,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classLoginShell.html b/classLoginShell.html index 7afcb6ba..9fe25fcd 100644 --- a/classLoginShell.html +++ b/classLoginShell.html @@ -572,7 +572,7 @@ Additional Inherited Members diff --git a/classMelody-members.html b/classMelody-members.html index 3faa2970..fd3ee331 100644 --- a/classMelody-members.html +++ b/classMelody-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classMelody.html b/classMelody.html index d1e33d30..46a51bcb 100644 --- a/classMelody.html +++ b/classMelody.html @@ -371,7 +371,7 @@ bool  diff --git a/classNoiseSource-members.html b/classNoiseSource-members.html index 962a2bd9..da9dfdb9 100644 --- a/classNoiseSource-members.html +++ b/classNoiseSource-members.html @@ -99,7 +99,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classNoiseSource.html b/classNoiseSource.html index 349e69b8..e92bfe98 100644 --- a/classNoiseSource.html +++ b/classNoiseSource.html @@ -289,7 +289,7 @@ Protected Member Functions diff --git a/classOFB-members.html b/classOFB-members.html index f3e8942b..66f49cd7 100644 --- a/classOFB-members.html +++ b/classOFB-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classOFB.html b/classOFB.html index 7c4d916b..bfa04aa6 100644 --- a/classOFB.html +++ b/classOFB.html @@ -181,7 +181,7 @@ class OFB< T > diff --git a/classOFBCommon-members.html b/classOFBCommon-members.html index d42382e9..d26ccf65 100644 --- a/classOFBCommon-members.html +++ b/classOFBCommon-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classOFBCommon.html b/classOFBCommon.html index 557fc47f..0459e03d 100644 --- a/classOFBCommon.html +++ b/classOFBCommon.html @@ -534,7 +534,7 @@ Protected Member Functions diff --git a/classOMAC-members.html b/classOMAC-members.html index b98cfdc7..9edd3183 100644 --- a/classOMAC-members.html +++ b/classOMAC-members.html @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classOMAC.html b/classOMAC.html index 2d015b60..b751aeaa 100644 --- a/classOMAC.html +++ b/classOMAC.html @@ -387,7 +387,7 @@ void  diff --git a/classPoly1305-members.html b/classPoly1305-members.html index 00e8fbf6..f9e47adc 100644 --- a/classPoly1305-members.html +++ b/classPoly1305-members.html @@ -104,7 +104,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classPoly1305.html b/classPoly1305.html index 3a109a52..15b32745 100644 --- a/classPoly1305.html +++ b/classPoly1305.html @@ -280,7 +280,7 @@ void  diff --git a/classRNGClass-members.html b/classRNGClass-members.html index eac5548a..b215715d 100644 --- a/classRNGClass-members.html +++ b/classRNGClass-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRNGClass.html b/classRNGClass.html index 90f1e583..2c0de757 100644 --- a/classRNGClass.html +++ b/classRNGClass.html @@ -519,7 +519,7 @@ static const int  diff --git a/classRTC-members.html b/classRTC-members.html index d90b549a..57af686b 100644 --- a/classRTC-members.html +++ b/classRTC-members.html @@ -123,7 +123,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRTC.html b/classRTC.html index cf30874e..29adbd49 100644 --- a/classRTC.html +++ b/classRTC.html @@ -779,7 +779,7 @@ static const uint8_t  diff --git a/classRTCAlarm-members.html b/classRTCAlarm-members.html index f119f340..01e72bcd 100644 --- a/classRTCAlarm-members.html +++ b/classRTCAlarm-members.html @@ -99,7 +99,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRTCDate-members.html b/classRTCDate-members.html index bc691cde..4f2b10f6 100644 --- a/classRTCDate-members.html +++ b/classRTCDate-members.html @@ -96,7 +96,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRTCTime-members.html b/classRTCTime-members.html index b335b017..544cb6aa 100644 --- a/classRTCTime-members.html +++ b/classRTCTime-members.html @@ -96,7 +96,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRingOscillatorNoiseSource-members.html b/classRingOscillatorNoiseSource-members.html index 546e1fa5..3fc52025 100644 --- a/classRingOscillatorNoiseSource-members.html +++ b/classRingOscillatorNoiseSource-members.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classRingOscillatorNoiseSource.html b/classRingOscillatorNoiseSource.html index 85423cf4..71d971b4 100644 --- a/classRingOscillatorNoiseSource.html +++ b/classRingOscillatorNoiseSource.html @@ -253,7 +253,7 @@ Additional Inherited Members diff --git a/classSHA256-members.html b/classSHA256-members.html index 9bb38887..5a4c8139 100644 --- a/classSHA256-members.html +++ b/classSHA256-members.html @@ -110,7 +110,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHA256.html b/classSHA256.html index 1ff381d8..406eefc4 100644 --- a/classSHA256.html +++ b/classSHA256.html @@ -506,7 +506,7 @@ Additional Inherited Members diff --git a/classSHA3__256-members.html b/classSHA3__256-members.html index 1f8d3009..c0019334 100644 --- a/classSHA3__256-members.html +++ b/classSHA3__256-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHA3__256.html b/classSHA3__256.html index 6a2bc30a..b200bba5 100644 --- a/classSHA3__256.html +++ b/classSHA3__256.html @@ -506,7 +506,7 @@ Additional Inherited Members diff --git a/classSHA3__512-members.html b/classSHA3__512-members.html index f068ddce..19c7e319 100644 --- a/classSHA3__512-members.html +++ b/classSHA3__512-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHA3__512.html b/classSHA3__512.html index 0e91c557..d58e256f 100644 --- a/classSHA3__512.html +++ b/classSHA3__512.html @@ -506,7 +506,7 @@ Additional Inherited Members diff --git a/classSHA512-members.html b/classSHA512-members.html index 9cd48612..b0e78772 100644 --- a/classSHA512-members.html +++ b/classSHA512-members.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHA512.html b/classSHA512.html index a9455f86..0cdb455f 100644 --- a/classSHA512.html +++ b/classSHA512.html @@ -513,7 +513,7 @@ Additional Inherited Members diff --git a/classSHAKE-members.html b/classSHAKE-members.html index e65f72d7..9b7dbab3 100644 --- a/classSHAKE-members.html +++ b/classSHAKE-members.html @@ -104,7 +104,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHAKE.html b/classSHAKE.html index d8752728..f732da15 100644 --- a/classSHAKE.html +++ b/classSHAKE.html @@ -443,7 +443,7 @@ Protected Member Functions diff --git a/classSHAKE128-members.html b/classSHAKE128-members.html index 0d65601b..b3ad44c2 100644 --- a/classSHAKE128-members.html +++ b/classSHAKE128-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHAKE128.html b/classSHAKE128.html index 2e284aa4..7728ebd6 100644 --- a/classSHAKE128.html +++ b/classSHAKE128.html @@ -171,7 +171,7 @@ Additional Inherited Members diff --git a/classSHAKE256-members.html b/classSHAKE256-members.html index 5954b2ae..fe21a077 100644 --- a/classSHAKE256-members.html +++ b/classSHAKE256-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSHAKE256.html b/classSHAKE256.html index 33bda6f2..1ec2005c 100644 --- a/classSHAKE256.html +++ b/classSHAKE256.html @@ -171,7 +171,7 @@ Additional Inherited Members diff --git a/classShell-members.html b/classShell-members.html index 54a90e60..170bc355 100644 --- a/classShell-members.html +++ b/classShell-members.html @@ -174,7 +174,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classShell.html b/classShell.html index 0dba1031..8f3c42eb 100644 --- a/classShell.html +++ b/classShell.html @@ -837,7 +837,7 @@ Additional Inherited Members diff --git a/classShellArguments-members.html b/classShellArguments-members.html index fbee4da2..01a3d1fc 100644 --- a/classShellArguments-members.html +++ b/classShellArguments-members.html @@ -96,7 +96,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classShellArguments.html b/classShellArguments.html index 63178ba2..7a4720dc 100644 --- a/classShellArguments.html +++ b/classShellArguments.html @@ -182,7 +182,7 @@ class Shell diff --git a/classSoftI2C-members.html b/classSoftI2C-members.html index 9a27e7ff..c1e74c1e 100644 --- a/classSoftI2C-members.html +++ b/classSoftI2C-members.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSoftI2C.html b/classSoftI2C.html index 7e5d6398..338d3c17 100644 --- a/classSoftI2C.html +++ b/classSoftI2C.html @@ -346,7 +346,7 @@ unsigned int  diff --git a/classSpeck-members.html b/classSpeck-members.html index 9e9e501b..01089b03 100644 --- a/classSpeck-members.html +++ b/classSpeck-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSpeck.html b/classSpeck.html index 0f2e4048..c9689721 100644 --- a/classSpeck.html +++ b/classSpeck.html @@ -415,7 +415,7 @@ Public Member Functions diff --git a/classSpeckSmall-members.html b/classSpeckSmall-members.html index 284f1523..063a554e 100644 --- a/classSpeckSmall-members.html +++ b/classSpeckSmall-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSpeckSmall.html b/classSpeckSmall.html index 54d0d51e..bb4220ed 100644 --- a/classSpeckSmall.html +++ b/classSpeckSmall.html @@ -319,7 +319,7 @@ Public Member Functions diff --git a/classSpeckTiny-members.html b/classSpeckTiny-members.html index 6f5efa45..4ca43288 100644 --- a/classSpeckTiny-members.html +++ b/classSpeckTiny-members.html @@ -104,7 +104,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSpeckTiny.html b/classSpeckTiny.html index 6487c918..19a89fb3 100644 --- a/classSpeckTiny.html +++ b/classSpeckTiny.html @@ -428,7 +428,7 @@ class SpeckSmall< diff --git a/classTerminal-members.html b/classTerminal-members.html index e80f4004..3c8cc9ad 100644 --- a/classTerminal-members.html +++ b/classTerminal-members.html @@ -156,7 +156,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classTerminal.html b/classTerminal.html index e86c49a3..5fa2d80e 100644 --- a/classTerminal.html +++ b/classTerminal.html @@ -1443,7 +1443,7 @@ Static Public Member Functions diff --git a/classTextField-members.html b/classTextField-members.html index a25675cf..b9ade08a 100644 --- a/classTextField-members.html +++ b/classTextField-members.html @@ -109,7 +109,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classTextField.html b/classTextField.html index a362ab20..ec7fc861 100644 --- a/classTextField.html +++ b/classTextField.html @@ -343,7 +343,7 @@ LiquidCrystal *  diff --git a/classTimeField-members.html b/classTimeField-members.html index 17125352..ad33ebbc 100644 --- a/classTimeField-members.html +++ b/classTimeField-members.html @@ -113,7 +113,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classTimeField.html b/classTimeField.html index 0774973d..50268a01 100644 --- a/classTimeField.html +++ b/classTimeField.html @@ -541,7 +541,7 @@ LiquidCrystal *  diff --git a/classTransistorNoiseSource-members.html b/classTransistorNoiseSource-members.html index f3857c5a..7d7e8aa6 100644 --- a/classTransistorNoiseSource-members.html +++ b/classTransistorNoiseSource-members.html @@ -101,7 +101,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classTransistorNoiseSource.html b/classTransistorNoiseSource.html index 27806381..71fe5a2f 100644 --- a/classTransistorNoiseSource.html +++ b/classTransistorNoiseSource.html @@ -280,7 +280,7 @@ Additional Inherited Members diff --git a/classXOF-members.html b/classXOF-members.html index 6369ed1a..54cf54d8 100644 --- a/classXOF-members.html +++ b/classXOF-members.html @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classXOF.html b/classXOF.html index 013cb351..94bb332a 100644 --- a/classXOF.html +++ b/classXOF.html @@ -508,7 +508,7 @@ Public Member Functions diff --git a/classXTS-members.html b/classXTS-members.html index b595f8ae..c0b79020 100644 --- a/classXTS-members.html +++ b/classXTS-members.html @@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classXTS.html b/classXTS.html index fb98c15a..2f7cb8bc 100644 --- a/classXTS.html +++ b/classXTS.html @@ -220,7 +220,7 @@ template<typename T1, typename T2 = T1> diff --git a/classXTSCommon-members.html b/classXTSCommon-members.html index 0f1bf05f..05b648c1 100644 --- a/classXTSCommon-members.html +++ b/classXTSCommon-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classXTSCommon.html b/classXTSCommon.html index 0541f3aa..aebf68f8 100644 --- a/classXTSCommon.html +++ b/classXTSCommon.html @@ -497,7 +497,7 @@ class XTSSingleKeyCommon diff --git a/classXTSSingleKey-members.html b/classXTSSingleKey-members.html index ac1dc11a..4f0bb42c 100644 --- a/classXTSSingleKey-members.html +++ b/classXTSSingleKey-members.html @@ -109,7 +109,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classXTSSingleKey.html b/classXTSSingleKey.html index 4f466364..6b46106c 100644 --- a/classXTSSingleKey.html +++ b/classXTSSingleKey.html @@ -218,7 +218,7 @@ template<typename T > diff --git a/classXTSSingleKeyCommon-members.html b/classXTSSingleKeyCommon-members.html index c413c905..c0217315 100644 --- a/classXTSSingleKeyCommon-members.html +++ b/classXTSSingleKeyCommon-members.html @@ -107,7 +107,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classXTSSingleKeyCommon.html b/classXTSSingleKeyCommon.html index 5504f169..47c1a0ef 100644 --- a/classXTSSingleKeyCommon.html +++ b/classXTSSingleKeyCommon.html @@ -257,7 +257,7 @@ Protected Member Functions diff --git a/classes.html b/classes.html index 52bb9b28..f45b7cfe 100644 --- a/classes.html +++ b/classes.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/crypto-rng-ring_8dox.html b/crypto-rng-ring_8dox.html index 8e72283c..a31959b3 100644 --- a/crypto-rng-ring_8dox.html +++ b/crypto-rng-ring_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/crypto-rng_8dox.html b/crypto-rng_8dox.html index a4b7f9c6..7de2654a 100644 --- a/crypto-rng_8dox.html +++ b/crypto-rng_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/crypto.html b/crypto.html index 0ce5c8cb..cde4f0cf 100644 --- a/crypto.html +++ b/crypto.html @@ -95,7 +95,7 @@ Supported Algorithms

All cryptographic algorithms have been optimized for 8-bit Arduino platforms like the Uno. Memory usage is also reduced, particularly for SHA256 and SHA512 which save 192 and 512 bytes respectively over traditional implementations. For all algorithms, static sbox tables and the like are placed into program memory to further reduce data memory usage.

ChaCha with 20 rounds and 256-bit keys is the recommended symmetric encryption algorithm because it is twice as fast as AES128, constant-time, and much more secure. AES128, AES192, and AES256 are provided for use in applications where compatibility with other systems is desirable.

If code size is an issue for your application (for example on very low end Arduino variants), then Speck on AVR is less than half the code size of ChaCha, at the cost of more data memory for the state and longer key setup times. The SpeckTiny and SpeckSmall classes are even smaller at the cost of some performance when encrypting.

-

BLAKE2s and BLAKE2b are variations on the ChaCha stream cipher, designed for hashing, with 256-bit and 512-bit hash outputs respectively. They are intended as high performance replacements for SHA256 and SHA512 for when speed is critical but exact bit-compatibility of hash values is not.

+

BLAKE2s and BLAKE2b are variations on the ChaCha stream cipher, designed for hashing, with 256-bit and 512-bit hash outputs respectively. They are intended as high performance replacements for SHA256 and SHA512 for when speed is critical but exact bit-compatibility of hash values is not. BLAKE2s and BLAKE2b support regular hashing, BLAKE2 keyed hashing, and HMAC modes.

Examples and other topics