diff --git a/AES128_8cpp_source.html b/AES128_8cpp_source.html index 770896f9..6c420aff 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 2afa9ecc..73b381bb 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 93ffe432..a4f7cb1b 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 ac1ad716..cc4433d5 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 32d91cdf..9a67c7e9 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 ee5f43b2..050f5102 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 1a32ac38..8f2adb6c 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 08382b9d..a0422c36 100644 --- a/BLAKE2b_8cpp_source.html +++ b/BLAKE2b_8cpp_source.html @@ -365,7 +365,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2b_8h_source.html b/BLAKE2b_8h_source.html index dbf7856e..7f70206a 100644 --- a/BLAKE2b_8h_source.html +++ b/BLAKE2b_8h_source.html @@ -164,7 +164,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2s_8cpp_source.html b/BLAKE2s_8cpp_source.html index 2666d869..6158f88d 100644 --- a/BLAKE2s_8cpp_source.html +++ b/BLAKE2s_8cpp_source.html @@ -356,7 +356,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2s_8h_source.html b/BLAKE2s_8h_source.html index 45912925..6a849d13 100644 --- a/BLAKE2s_8h_source.html +++ b/BLAKE2s_8h_source.html @@ -163,7 +163,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BigNumberUtil_8cpp_source.html b/BigNumberUtil_8cpp_source.html index 476e9f58..83475bb2 100644 --- a/BigNumberUtil_8cpp_source.html +++ b/BigNumberUtil_8cpp_source.html @@ -159,7 +159,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
96  --count;
97  len -= 4;
98  }
-
99  if (count > 0) {
+
99  if (count > 0 && len > 0) {
100  if (len == 3) {
101  *limbs++ = ((limb_t)(bytes[0])) |
102  (((limb_t)(bytes[1])) << 8) |
@@ -167,7 +167,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
104  } else if (len == 2) {
105  *limbs++ = ((limb_t)(bytes[0])) |
106  (((limb_t)(bytes[1])) << 8);
-
107  } else if (len == 1) {
+
107  } else {
108  *limbs++ = ((limb_t)(bytes[0]));
109  }
110  --count;
@@ -176,399 +176,513 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
113  *limbs++ = 0;
114  --count;
115  }
-
116 #endif
-
117 }
-
118 
-
134 void BigNumberUtil::unpackBE(limb_t *limbs, size_t count,
-
135  const uint8_t *bytes, size_t len)
-
136 {
-
137 #if BIGNUMBER_LIMB_8BIT
-
138  while (count > 0 && len > 0) {
+
116 #elif BIGNUMBER_LIMB_64BIT
+
117  while (count > 0 && len >= 8) {
+
118  *limbs++ = ((limb_t)(bytes[0])) |
+
119  (((limb_t)(bytes[1])) << 8) |
+
120  (((limb_t)(bytes[2])) << 16) |
+
121  (((limb_t)(bytes[3])) << 24) |
+
122  (((limb_t)(bytes[4])) << 32) |
+
123  (((limb_t)(bytes[5])) << 40) |
+
124  (((limb_t)(bytes[6])) << 48) |
+
125  (((limb_t)(bytes[7])) << 56);
+
126  bytes += 8;
+
127  --count;
+
128  len -= 8;
+
129  }
+
130  if (count > 0 && len > 0) {
+
131  limb_t word = 0;
+
132  uint8_t shift = 0;
+
133  while (len > 0 && shift < 64) {
+
134  word |= (((limb_t)(*bytes++)) << shift);
+
135  shift += 8;
+
136  --len;
+
137  }
+
138  *limbs++ = word;
139  --count;
-
140  --len;
-
141  *limbs++ = bytes[len];
-
142  }
-
143  memset(limbs, 0, count);
-
144 #elif BIGNUMBER_LIMB_16BIT
-
145  bytes += len;
-
146  while (count > 0 && len >= 2) {
-
147  --count;
-
148  bytes -= 2;
-
149  len -= 2;
-
150  *limbs++ = ((limb_t)(bytes[1])) |
-
151  (((limb_t)(bytes[0])) << 8);
-
152  }
-
153  if (count > 0 && len == 1) {
-
154  --count;
-
155  --bytes;
-
156  *limbs++ = (limb_t)(bytes[0]);
-
157  }
-
158  memset(limbs, 0, count * sizeof(limb_t));
-
159 #elif BIGNUMBER_LIMB_32BIT
-
160  bytes += len;
-
161  while (count > 0 && len >= 4) {
-
162  --count;
-
163  bytes -= 4;
-
164  len -= 4;
-
165  *limbs++ = ((limb_t)(bytes[3])) |
-
166  (((limb_t)(bytes[2])) << 8) |
-
167  (((limb_t)(bytes[1])) << 16) |
-
168  (((limb_t)(bytes[0])) << 24);
-
169  }
-
170  if (count > 0) {
-
171  if (len == 3) {
-
172  --count;
-
173  bytes -= 3;
-
174  *limbs++ = ((limb_t)(bytes[2])) |
-
175  (((limb_t)(bytes[1])) << 8) |
-
176  (((limb_t)(bytes[0])) << 16);
-
177  } else if (len == 2) {
-
178  --count;
-
179  bytes -= 2;
-
180  *limbs++ = ((limb_t)(bytes[1])) |
-
181  (((limb_t)(bytes[0])) << 8);
-
182  } else if (len == 1) {
-
183  --count;
-
184  --bytes;
-
185  *limbs++ = (limb_t)(bytes[0]);
-
186  }
-
187  }
-
188  memset(limbs, 0, count * sizeof(limb_t));
-
189 #endif
-
190 }
-
191 
-
208 void BigNumberUtil::packLE(uint8_t *bytes, size_t len,
-
209  const limb_t *limbs, size_t count)
-
210 {
-
211 #if BIGNUMBER_LIMB_8BIT
-
212  if (len <= count) {
-
213  memcpy(bytes, limbs, len);
-
214  } else {
-
215  memcpy(bytes, limbs, count);
-
216  memset(bytes + count, 0, len - count);
-
217  }
-
218 #elif CRYPTO_LITTLE_ENDIAN
-
219  count *= sizeof(limb_t);
-
220  if (len <= count) {
-
221  memcpy(bytes, limbs, len);
-
222  } else {
-
223  memcpy(bytes, limbs, count);
-
224  memset(bytes + count, 0, len - count);
-
225  }
-
226 #elif BIGNUMBER_LIMB_16BIT
-
227  limb_t word;
-
228  while (count > 0 && len >= 2) {
-
229  word = *limbs++;
-
230  bytes[0] = (uint8_t)word;
-
231  bytes[1] = (uint8_t)(word >> 8);
-
232  --count;
-
233  len -= 2;
-
234  bytes += 2;
-
235  }
-
236  if (count > 0 && len == 1) {
-
237  bytes[0] = (uint8_t)(*limbs);
-
238  --len;
-
239  ++bytes;
-
240  }
-
241  memset(bytes, 0, len);
-
242 #elif BIGNUMBER_LIMB_32BIT
-
243  limb_t word;
-
244  while (count > 0 && len >= 4) {
-
245  word = *limbs++;
-
246  bytes[0] = (uint8_t)word;
-
247  bytes[1] = (uint8_t)(word >> 8);
-
248  bytes[2] = (uint8_t)(word >> 16);
-
249  bytes[3] = (uint8_t)(word >> 24);
-
250  --count;
-
251  len -= 4;
-
252  bytes += 4;
-
253  }
-
254  if (count > 0) {
-
255  if (len == 3) {
-
256  word = *limbs;
-
257  bytes[0] = (uint8_t)word;
-
258  bytes[1] = (uint8_t)(word >> 8);
-
259  bytes[2] = (uint8_t)(word >> 16);
-
260  len -= 3;
-
261  bytes += 3;
-
262  } else if (len == 2) {
-
263  word = *limbs;
-
264  bytes[0] = (uint8_t)word;
-
265  bytes[1] = (uint8_t)(word >> 8);
-
266  len -= 2;
-
267  bytes += 2;
-
268  } else if (len == 1) {
-
269  bytes[0] = (uint8_t)(*limbs);
-
270  --len;
-
271  ++bytes;
-
272  }
+
140  }
+
141  while (count > 0) {
+
142  *limbs++ = 0;
+
143  --count;
+
144  }
+
145 #endif
+
146 }
+
147 
+
163 void BigNumberUtil::unpackBE(limb_t *limbs, size_t count,
+
164  const uint8_t *bytes, size_t len)
+
165 {
+
166 #if BIGNUMBER_LIMB_8BIT
+
167  while (count > 0 && len > 0) {
+
168  --count;
+
169  --len;
+
170  *limbs++ = bytes[len];
+
171  }
+
172  memset(limbs, 0, count);
+
173 #elif BIGNUMBER_LIMB_16BIT
+
174  bytes += len;
+
175  while (count > 0 && len >= 2) {
+
176  --count;
+
177  bytes -= 2;
+
178  len -= 2;
+
179  *limbs++ = ((limb_t)(bytes[1])) |
+
180  (((limb_t)(bytes[0])) << 8);
+
181  }
+
182  if (count > 0 && len == 1) {
+
183  --count;
+
184  --bytes;
+
185  *limbs++ = (limb_t)(bytes[0]);
+
186  }
+
187  memset(limbs, 0, count * sizeof(limb_t));
+
188 #elif BIGNUMBER_LIMB_32BIT
+
189  bytes += len;
+
190  while (count > 0 && len >= 4) {
+
191  --count;
+
192  bytes -= 4;
+
193  len -= 4;
+
194  *limbs++ = ((limb_t)(bytes[3])) |
+
195  (((limb_t)(bytes[2])) << 8) |
+
196  (((limb_t)(bytes[1])) << 16) |
+
197  (((limb_t)(bytes[0])) << 24);
+
198  }
+
199  if (count > 0) {
+
200  if (len == 3) {
+
201  --count;
+
202  bytes -= 3;
+
203  *limbs++ = ((limb_t)(bytes[2])) |
+
204  (((limb_t)(bytes[1])) << 8) |
+
205  (((limb_t)(bytes[0])) << 16);
+
206  } else if (len == 2) {
+
207  --count;
+
208  bytes -= 2;
+
209  *limbs++ = ((limb_t)(bytes[1])) |
+
210  (((limb_t)(bytes[0])) << 8);
+
211  } else if (len == 1) {
+
212  --count;
+
213  --bytes;
+
214  *limbs++ = (limb_t)(bytes[0]);
+
215  }
+
216  }
+
217  memset(limbs, 0, count * sizeof(limb_t));
+
218 #elif BIGNUMBER_LIMB_64BIT
+
219  bytes += len;
+
220  while (count > 0 && len >= 8) {
+
221  --count;
+
222  bytes -= 8;
+
223  len -= 8;
+
224  *limbs++ = ((limb_t)(bytes[7])) |
+
225  (((limb_t)(bytes[6])) << 8) |
+
226  (((limb_t)(bytes[5])) << 16) |
+
227  (((limb_t)(bytes[4])) << 24) |
+
228  (((limb_t)(bytes[3])) << 32) |
+
229  (((limb_t)(bytes[2])) << 40) |
+
230  (((limb_t)(bytes[1])) << 48) |
+
231  (((limb_t)(bytes[0])) << 56);
+
232  }
+
233  if (count > 0 && len > 0) {
+
234  limb_t word = 0;
+
235  uint8_t shift = 0;
+
236  while (len > 0 && shift < 64) {
+
237  word |= (((limb_t)(*(--bytes))) << shift);
+
238  shift += 8;
+
239  --len;
+
240  }
+
241  *limbs++ = word;
+
242  --count;
+
243  }
+
244  memset(limbs, 0, count * sizeof(limb_t));
+
245 #endif
+
246 }
+
247 
+
264 void BigNumberUtil::packLE(uint8_t *bytes, size_t len,
+
265  const limb_t *limbs, size_t count)
+
266 {
+
267 #if BIGNUMBER_LIMB_8BIT
+
268  if (len <= count) {
+
269  memcpy(bytes, limbs, len);
+
270  } else {
+
271  memcpy(bytes, limbs, count);
+
272  memset(bytes + count, 0, len - count);
273  }
-
274  memset(bytes, 0, len);
-
275 #endif
-
276 }
-
277 
-
294 void BigNumberUtil::packBE(uint8_t *bytes, size_t len,
-
295  const limb_t *limbs, size_t count)
-
296 {
-
297 #if BIGNUMBER_LIMB_8BIT
-
298  if (len > count) {
-
299  size_t size = len - count;
-
300  memset(bytes, 0, size);
-
301  len -= size;
-
302  bytes += size;
-
303  } else if (len < count) {
-
304  count = len;
-
305  }
-
306  limbs += count;
-
307  while (count > 0) {
-
308  --count;
-
309  *bytes++ = *(--limbs);
-
310  }
-
311 #elif BIGNUMBER_LIMB_16BIT
-
312  size_t countBytes = count * sizeof(limb_t);
-
313  limb_t word;
-
314  if (len >= countBytes) {
-
315  size_t size = len - countBytes;
-
316  memset(bytes, 0, size);
-
317  len -= size;
-
318  bytes += size;
-
319  limbs += count;
-
320  } else {
-
321  count = len / sizeof(limb_t);
-
322  limbs += count;
-
323  if ((len & 1) != 0)
-
324  *bytes++ = (uint8_t)(*limbs);
-
325  }
-
326  while (count > 0) {
-
327  --count;
-
328  word = *(--limbs);
-
329  *bytes++ = (uint8_t)(word >> 8);
-
330  *bytes++ = (uint8_t)word;
-
331  }
-
332 #elif BIGNUMBER_LIMB_32BIT
-
333  size_t countBytes = count * sizeof(limb_t);
-
334  limb_t word;
-
335  if (len >= countBytes) {
-
336  size_t size = len - countBytes;
-
337  memset(bytes, 0, size);
-
338  len -= size;
-
339  bytes += size;
-
340  limbs += count;
-
341  } else {
-
342  count = len / sizeof(limb_t);
-
343  limbs += count;
-
344  if ((len & 3) == 3) {
-
345  word = *limbs;
-
346  *bytes++ = (uint8_t)(word >> 16);
-
347  *bytes++ = (uint8_t)(word >> 8);
-
348  *bytes++ = (uint8_t)word;
-
349  } else if ((len & 3) == 2) {
-
350  word = *limbs;
-
351  *bytes++ = (uint8_t)(word >> 8);
-
352  *bytes++ = (uint8_t)word;
-
353  } else if ((len & 3) == 1) {
-
354  *bytes++ = (uint8_t)(*limbs);
-
355  }
-
356  }
-
357  while (count > 0) {
-
358  --count;
-
359  word = *(--limbs);
-
360  *bytes++ = (uint8_t)(word >> 24);
-
361  *bytes++ = (uint8_t)(word >> 16);
-
362  *bytes++ = (uint8_t)(word >> 8);
-
363  *bytes++ = (uint8_t)word;
-
364  }
-
365 #endif
-
366 }
-
367 
-
381 limb_t BigNumberUtil::add(limb_t *result, const limb_t *x,
-
382  const limb_t *y, size_t size)
-
383 {
-
384  dlimb_t carry = 0;
-
385  while (size > 0) {
-
386  carry += *x++;
-
387  carry += *y++;
-
388  *result++ = (limb_t)carry;
-
389  carry >>= LIMB_BITS;
-
390  --size;
+
274 #elif CRYPTO_LITTLE_ENDIAN
+
275  count *= sizeof(limb_t);
+
276  if (len <= count) {
+
277  memcpy(bytes, limbs, len);
+
278  } else {
+
279  memcpy(bytes, limbs, count);
+
280  memset(bytes + count, 0, len - count);
+
281  }
+
282 #elif BIGNUMBER_LIMB_16BIT
+
283  limb_t word;
+
284  while (count > 0 && len >= 2) {
+
285  word = *limbs++;
+
286  bytes[0] = (uint8_t)word;
+
287  bytes[1] = (uint8_t)(word >> 8);
+
288  --count;
+
289  len -= 2;
+
290  bytes += 2;
+
291  }
+
292  if (count > 0 && len == 1) {
+
293  bytes[0] = (uint8_t)(*limbs);
+
294  --len;
+
295  ++bytes;
+
296  }
+
297  memset(bytes, 0, len);
+
298 #elif BIGNUMBER_LIMB_32BIT
+
299  limb_t word;
+
300  while (count > 0 && len >= 4) {
+
301  word = *limbs++;
+
302  bytes[0] = (uint8_t)word;
+
303  bytes[1] = (uint8_t)(word >> 8);
+
304  bytes[2] = (uint8_t)(word >> 16);
+
305  bytes[3] = (uint8_t)(word >> 24);
+
306  --count;
+
307  len -= 4;
+
308  bytes += 4;
+
309  }
+
310  if (count > 0) {
+
311  if (len == 3) {
+
312  word = *limbs;
+
313  bytes[0] = (uint8_t)word;
+
314  bytes[1] = (uint8_t)(word >> 8);
+
315  bytes[2] = (uint8_t)(word >> 16);
+
316  len -= 3;
+
317  bytes += 3;
+
318  } else if (len == 2) {
+
319  word = *limbs;
+
320  bytes[0] = (uint8_t)word;
+
321  bytes[1] = (uint8_t)(word >> 8);
+
322  len -= 2;
+
323  bytes += 2;
+
324  } else if (len == 1) {
+
325  bytes[0] = (uint8_t)(*limbs);
+
326  --len;
+
327  ++bytes;
+
328  }
+
329  }
+
330  memset(bytes, 0, len);
+
331 #elif BIGNUMBER_LIMB_64BIT
+
332  limb_t word;
+
333  while (count > 0 && len >= 8) {
+
334  word = *limbs++;
+
335  bytes[0] = (uint8_t)word;
+
336  bytes[1] = (uint8_t)(word >> 8);
+
337  bytes[2] = (uint8_t)(word >> 16);
+
338  bytes[3] = (uint8_t)(word >> 24);
+
339  bytes[4] = (uint8_t)(word >> 32);
+
340  bytes[5] = (uint8_t)(word >> 40);
+
341  bytes[6] = (uint8_t)(word >> 48);
+
342  bytes[7] = (uint8_t)(word >> 56);
+
343  --count;
+
344  len -= 8;
+
345  bytes += 8;
+
346  }
+
347  if (count > 0) {
+
348  word = *limbs;
+
349  while (len > 0) {
+
350  *bytes++ = (uint8_t)word;
+
351  word >>= 8;
+
352  --len;
+
353  }
+
354  }
+
355  memset(bytes, 0, len);
+
356 #endif
+
357 }
+
358 
+
375 void BigNumberUtil::packBE(uint8_t *bytes, size_t len,
+
376  const limb_t *limbs, size_t count)
+
377 {
+
378 #if BIGNUMBER_LIMB_8BIT
+
379  if (len > count) {
+
380  size_t size = len - count;
+
381  memset(bytes, 0, size);
+
382  len -= size;
+
383  bytes += size;
+
384  } else if (len < count) {
+
385  count = len;
+
386  }
+
387  limbs += count;
+
388  while (count > 0) {
+
389  --count;
+
390  *bytes++ = *(--limbs);
391  }
-
392  return (limb_t)carry;
-
393 }
-
394 
-
408 limb_t BigNumberUtil::sub(limb_t *result, const limb_t *x,
-
409  const limb_t *y, size_t size)
-
410 {
-
411  dlimb_t borrow = 0;
-
412  while (size > 0) {
-
413  borrow = ((dlimb_t)(*x++)) - (*y++) - ((borrow >> LIMB_BITS) & 0x01);
-
414  *result++ = (limb_t)borrow;
-
415  --size;
-
416  }
-
417  return ((limb_t)(borrow >> LIMB_BITS)) & 0x01;
-
418 }
-
419 
-
432 void BigNumberUtil::mul(limb_t *result, const limb_t *x, size_t xcount,
-
433  const limb_t *y, size_t ycount)
-
434 {
-
435  size_t i, j;
-
436  dlimb_t carry;
-
437  limb_t word;
-
438  const limb_t *xx;
-
439  limb_t *rr;
-
440 
-
441  // Multiply the lowest limb of y by x.
-
442  carry = 0;
-
443  word = y[0];
-
444  xx = x;
-
445  rr = result;
-
446  for (i = 0; i < xcount; ++i) {
-
447  carry += ((dlimb_t)(*xx++)) * word;
-
448  *rr++ = (limb_t)carry;
-
449  carry >>= LIMB_BITS;
-
450  }
-
451  *rr = (limb_t)carry;
-
452 
-
453  // Multiply and add the remaining limbs of y by x.
-
454  for (i = 1; i < ycount; ++i) {
-
455  word = y[i];
-
456  carry = 0;
-
457  xx = x;
-
458  rr = result + i;
-
459  for (j = 0; j < xcount; ++j) {
-
460  carry += ((dlimb_t)(*xx++)) * word;
-
461  carry += *rr;
-
462  *rr++ = (limb_t)carry;
-
463  carry >>= LIMB_BITS;
-
464  }
-
465  *rr = (limb_t)carry;
+
392 #elif BIGNUMBER_LIMB_16BIT
+
393  size_t countBytes = count * sizeof(limb_t);
+
394  limb_t word;
+
395  if (len >= countBytes) {
+
396  size_t size = len - countBytes;
+
397  memset(bytes, 0, size);
+
398  len -= size;
+
399  bytes += size;
+
400  limbs += count;
+
401  } else {
+
402  count = len / sizeof(limb_t);
+
403  limbs += count;
+
404  if ((len & 1) != 0)
+
405  *bytes++ = (uint8_t)(*limbs);
+
406  }
+
407  while (count > 0) {
+
408  --count;
+
409  word = *(--limbs);
+
410  *bytes++ = (uint8_t)(word >> 8);
+
411  *bytes++ = (uint8_t)word;
+
412  }
+
413 #elif BIGNUMBER_LIMB_32BIT
+
414  size_t countBytes = count * sizeof(limb_t);
+
415  limb_t word;
+
416  if (len >= countBytes) {
+
417  size_t size = len - countBytes;
+
418  memset(bytes, 0, size);
+
419  len -= size;
+
420  bytes += size;
+
421  limbs += count;
+
422  } else {
+
423  count = len / sizeof(limb_t);
+
424  limbs += count;
+
425  if ((len & 3) == 3) {
+
426  word = *limbs;
+
427  *bytes++ = (uint8_t)(word >> 16);
+
428  *bytes++ = (uint8_t)(word >> 8);
+
429  *bytes++ = (uint8_t)word;
+
430  } else if ((len & 3) == 2) {
+
431  word = *limbs;
+
432  *bytes++ = (uint8_t)(word >> 8);
+
433  *bytes++ = (uint8_t)word;
+
434  } else if ((len & 3) == 1) {
+
435  *bytes++ = (uint8_t)(*limbs);
+
436  }
+
437  }
+
438  while (count > 0) {
+
439  --count;
+
440  word = *(--limbs);
+
441  *bytes++ = (uint8_t)(word >> 24);
+
442  *bytes++ = (uint8_t)(word >> 16);
+
443  *bytes++ = (uint8_t)(word >> 8);
+
444  *bytes++ = (uint8_t)word;
+
445  }
+
446 #elif BIGNUMBER_LIMB_64BIT
+
447  size_t countBytes = count * sizeof(limb_t);
+
448  limb_t word;
+
449  if (len >= countBytes) {
+
450  size_t size = len - countBytes;
+
451  memset(bytes, 0, size);
+
452  len -= size;
+
453  bytes += size;
+
454  limbs += count;
+
455  } else {
+
456  count = len / sizeof(limb_t);
+
457  limbs += count;
+
458  uint8_t size = len & 7;
+
459  uint8_t shift = size * 8;
+
460  word = *limbs;
+
461  while (size > 0) {
+
462  shift -= 8;
+
463  *bytes++ = (uint8_t)(word >> shift);
+
464  --size;
+
465  }
466  }
-
467 }
-
468 
-
484 void BigNumberUtil::reduceQuick(limb_t *result, const limb_t *x,
-
485  const limb_t *y, size_t size)
-
486 {
-
487  // Subtract "y" from "x" and turn the borrow into an AND mask.
-
488  limb_t mask = sub(result, x, y, size);
-
489  mask = (~mask) + 1;
-
490 
-
491  // Add "y" back to the result if the mask is non-zero.
-
492  dlimb_t carry = 0;
-
493  while (size > 0) {
-
494  carry += *result;
-
495  carry += (*y++ & mask);
-
496  *result++ = (limb_t)carry;
-
497  carry >>= LIMB_BITS;
-
498  --size;
-
499  }
-
500 }
-
501 
-
514 limb_t BigNumberUtil::add_P(limb_t *result, const limb_t *x,
-
515  const limb_t *y, size_t size)
-
516 {
-
517  dlimb_t carry = 0;
-
518  while (size > 0) {
-
519  carry += *x++;
-
520  carry += pgm_read_limb(y++);
-
521  *result++ = (limb_t)carry;
-
522  carry >>= LIMB_BITS;
-
523  --size;
-
524  }
-
525  return (limb_t)carry;
-
526 }
-
527 
-
541 limb_t BigNumberUtil::sub_P(limb_t *result, const limb_t *x,
-
542  const limb_t *y, size_t size)
-
543 {
-
544  dlimb_t borrow = 0;
-
545  while (size > 0) {
-
546  borrow = ((dlimb_t)(*x++)) - pgm_read_limb(y++) - ((borrow >> LIMB_BITS) & 0x01);
-
547  *result++ = (limb_t)borrow;
-
548  --size;
-
549  }
-
550  return ((limb_t)(borrow >> LIMB_BITS)) & 0x01;
-
551 }
-
552 
-
566 void BigNumberUtil::mul_P(limb_t *result, const limb_t *x, size_t xcount,
-
567  const limb_t *y, size_t ycount)
-
568 {
-
569  size_t i, j;
-
570  dlimb_t carry;
-
571  limb_t word;
-
572  const limb_t *xx;
-
573  limb_t *rr;
-
574 
-
575  // Multiply the lowest limb of y by x.
-
576  carry = 0;
-
577  word = pgm_read_limb(&(y[0]));
-
578  xx = x;
-
579  rr = result;
-
580  for (i = 0; i < xcount; ++i) {
-
581  carry += ((dlimb_t)(*xx++)) * word;
-
582  *rr++ = (limb_t)carry;
-
583  carry >>= LIMB_BITS;
-
584  }
-
585  *rr = (limb_t)carry;
-
586 
-
587  // Multiply and add the remaining limb of y by x.
-
588  for (i = 1; i < ycount; ++i) {
-
589  word = pgm_read_limb(&(y[i]));
-
590  carry = 0;
-
591  xx = x;
-
592  rr = result + i;
-
593  for (j = 0; j < xcount; ++j) {
-
594  carry += ((dlimb_t)(*xx++)) * word;
-
595  carry += *rr;
-
596  *rr++ = (limb_t)carry;
-
597  carry >>= LIMB_BITS;
-
598  }
-
599  *rr = (limb_t)carry;
-
600  }
-
601 }
-
602 
-
620 void BigNumberUtil::reduceQuick_P(limb_t *result, const limb_t *x,
-
621  const limb_t *y, size_t size)
-
622 {
-
623  // Subtract "y" from "x" and turn the borrow into an AND mask.
-
624  limb_t mask = sub_P(result, x, y, size);
-
625  mask = (~mask) + 1;
-
626 
-
627  // Add "y" back to the result if the mask is non-zero.
-
628  dlimb_t carry = 0;
-
629  while (size > 0) {
-
630  carry += *result;
-
631  carry += (pgm_read_limb(y++) & mask);
-
632  *result++ = (limb_t)carry;
-
633  carry >>= LIMB_BITS;
-
634  --size;
-
635  }
-
636 }
-
637 
-
647 limb_t BigNumberUtil::isZero(const limb_t *x, size_t size)
-
648 {
-
649  limb_t word = 0;
-
650  while (size > 0) {
-
651  word |= *x++;
-
652  --size;
-
653  }
-
654  return (limb_t)(((((dlimb_t)1) << LIMB_BITS) - word) >> LIMB_BITS);
-
655 }
-
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
-
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
-
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:541
-
BigNumberUtil::reduceQuick
static void reduceQuick(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction.
Definition: BigNumberUtil.cpp:484
-
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:408
-
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:566
-
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:294
+
467  while (count > 0) {
+
468  --count;
+
469  word = *(--limbs);
+
470  *bytes++ = (uint8_t)(word >> 56);
+
471  *bytes++ = (uint8_t)(word >> 48);
+
472  *bytes++ = (uint8_t)(word >> 40);
+
473  *bytes++ = (uint8_t)(word >> 32);
+
474  *bytes++ = (uint8_t)(word >> 24);
+
475  *bytes++ = (uint8_t)(word >> 16);
+
476  *bytes++ = (uint8_t)(word >> 8);
+
477  *bytes++ = (uint8_t)word;
+
478  }
+
479 #endif
+
480 }
+
481 
+
495 limb_t BigNumberUtil::add(limb_t *result, const limb_t *x,
+
496  const limb_t *y, size_t size)
+
497 {
+
498  dlimb_t carry = 0;
+
499  while (size > 0) {
+
500  carry += *x++;
+
501  carry += *y++;
+
502  *result++ = (limb_t)carry;
+
503  carry >>= LIMB_BITS;
+
504  --size;
+
505  }
+
506  return (limb_t)carry;
+
507 }
+
508 
+
522 limb_t BigNumberUtil::sub(limb_t *result, const limb_t *x,
+
523  const limb_t *y, size_t size)
+
524 {
+
525  dlimb_t borrow = 0;
+
526  while (size > 0) {
+
527  borrow = ((dlimb_t)(*x++)) - (*y++) - ((borrow >> LIMB_BITS) & 0x01);
+
528  *result++ = (limb_t)borrow;
+
529  --size;
+
530  }
+
531  return ((limb_t)(borrow >> LIMB_BITS)) & 0x01;
+
532 }
+
533 
+
546 void BigNumberUtil::mul(limb_t *result, const limb_t *x, size_t xcount,
+
547  const limb_t *y, size_t ycount)
+
548 {
+
549  size_t i, j;
+
550  dlimb_t carry;
+
551  limb_t word;
+
552  const limb_t *xx;
+
553  limb_t *rr;
+
554 
+
555  // Multiply the lowest limb of y by x.
+
556  carry = 0;
+
557  word = y[0];
+
558  xx = x;
+
559  rr = result;
+
560  for (i = 0; i < xcount; ++i) {
+
561  carry += ((dlimb_t)(*xx++)) * word;
+
562  *rr++ = (limb_t)carry;
+
563  carry >>= LIMB_BITS;
+
564  }
+
565  *rr = (limb_t)carry;
+
566 
+
567  // Multiply and add the remaining limbs of y by x.
+
568  for (i = 1; i < ycount; ++i) {
+
569  word = y[i];
+
570  carry = 0;
+
571  xx = x;
+
572  rr = result + i;
+
573  for (j = 0; j < xcount; ++j) {
+
574  carry += ((dlimb_t)(*xx++)) * word;
+
575  carry += *rr;
+
576  *rr++ = (limb_t)carry;
+
577  carry >>= LIMB_BITS;
+
578  }
+
579  *rr = (limb_t)carry;
+
580  }
+
581 }
+
582 
+
598 void BigNumberUtil::reduceQuick(limb_t *result, const limb_t *x,
+
599  const limb_t *y, size_t size)
+
600 {
+
601  // Subtract "y" from "x" and turn the borrow into an AND mask.
+
602  limb_t mask = sub(result, x, y, size);
+
603  mask = (~mask) + 1;
+
604 
+
605  // Add "y" back to the result if the mask is non-zero.
+
606  dlimb_t carry = 0;
+
607  while (size > 0) {
+
608  carry += *result;
+
609  carry += (*y++ & mask);
+
610  *result++ = (limb_t)carry;
+
611  carry >>= LIMB_BITS;
+
612  --size;
+
613  }
+
614 }
+
615 
+
628 limb_t BigNumberUtil::add_P(limb_t *result, const limb_t *x,
+
629  const limb_t *y, size_t size)
+
630 {
+
631  dlimb_t carry = 0;
+
632  while (size > 0) {
+
633  carry += *x++;
+
634  carry += pgm_read_limb(y++);
+
635  *result++ = (limb_t)carry;
+
636  carry >>= LIMB_BITS;
+
637  --size;
+
638  }
+
639  return (limb_t)carry;
+
640 }
+
641 
+
655 limb_t BigNumberUtil::sub_P(limb_t *result, const limb_t *x,
+
656  const limb_t *y, size_t size)
+
657 {
+
658  dlimb_t borrow = 0;
+
659  while (size > 0) {
+
660  borrow = ((dlimb_t)(*x++)) - pgm_read_limb(y++) - ((borrow >> LIMB_BITS) & 0x01);
+
661  *result++ = (limb_t)borrow;
+
662  --size;
+
663  }
+
664  return ((limb_t)(borrow >> LIMB_BITS)) & 0x01;
+
665 }
+
666 
+
680 void BigNumberUtil::mul_P(limb_t *result, const limb_t *x, size_t xcount,
+
681  const limb_t *y, size_t ycount)
+
682 {
+
683  size_t i, j;
+
684  dlimb_t carry;
+
685  limb_t word;
+
686  const limb_t *xx;
+
687  limb_t *rr;
+
688 
+
689  // Multiply the lowest limb of y by x.
+
690  carry = 0;
+
691  word = pgm_read_limb(&(y[0]));
+
692  xx = x;
+
693  rr = result;
+
694  for (i = 0; i < xcount; ++i) {
+
695  carry += ((dlimb_t)(*xx++)) * word;
+
696  *rr++ = (limb_t)carry;
+
697  carry >>= LIMB_BITS;
+
698  }
+
699  *rr = (limb_t)carry;
+
700 
+
701  // Multiply and add the remaining limb of y by x.
+
702  for (i = 1; i < ycount; ++i) {
+
703  word = pgm_read_limb(&(y[i]));
+
704  carry = 0;
+
705  xx = x;
+
706  rr = result + i;
+
707  for (j = 0; j < xcount; ++j) {
+
708  carry += ((dlimb_t)(*xx++)) * word;
+
709  carry += *rr;
+
710  *rr++ = (limb_t)carry;
+
711  carry >>= LIMB_BITS;
+
712  }
+
713  *rr = (limb_t)carry;
+
714  }
+
715 }
+
716 
+
734 void BigNumberUtil::reduceQuick_P(limb_t *result, const limb_t *x,
+
735  const limb_t *y, size_t size)
+
736 {
+
737  // Subtract "y" from "x" and turn the borrow into an AND mask.
+
738  limb_t mask = sub_P(result, x, y, size);
+
739  mask = (~mask) + 1;
+
740 
+
741  // Add "y" back to the result if the mask is non-zero.
+
742  dlimb_t carry = 0;
+
743  while (size > 0) {
+
744  carry += *result;
+
745  carry += (pgm_read_limb(y++) & mask);
+
746  *result++ = (limb_t)carry;
+
747  carry >>= LIMB_BITS;
+
748  --size;
+
749  }
+
750 }
+
751 
+
761 limb_t BigNumberUtil::isZero(const limb_t *x, size_t size)
+
762 {
+
763  limb_t word = 0;
+
764  while (size > 0) {
+
765  word |= *x++;
+
766  --size;
+
767  }
+
768  return (limb_t)(((((dlimb_t)1) << LIMB_BITS) - word) >> LIMB_BITS);
+
769 }
+
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:734
+
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:495
+
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:655
+
BigNumberUtil::reduceQuick
static void reduceQuick(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction.
Definition: BigNumberUtil.cpp:598
+
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:522
+
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:680
+
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:375
BigNumberUtil::unpackLE
static void unpackLE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the little-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:55
-
BigNumberUtil::mul
static void mul(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers.
Definition: BigNumberUtil.cpp:432
-
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:134
-
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:208
-
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:647
-
BigNumberUtil::add_P
static limb_t add_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers where one of them is in program memory.
Definition: BigNumberUtil.cpp:514
+
BigNumberUtil::mul
static void mul(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers.
Definition: BigNumberUtil.cpp:546
+
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:163
+
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:264
+
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:761
+
BigNumberUtil::add_P
static limb_t add_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers where one of them is in program memory.
Definition: BigNumberUtil.cpp:628
diff --git a/BigNumberUtil_8h_source.html b/BigNumberUtil_8h_source.html index 67f3d959..17c6bf1f 100644 --- a/BigNumberUtil_8h_source.html +++ b/BigNumberUtil_8h_source.html @@ -117,92 +117,104 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
27 #include <stddef.h>
28 
29 // Define exactly one of these to 1 to set the size of the basic limb type.
-
30 // 16-bit limbs seem to give the best performance on 8-bit AVR micros.
-
31 #if defined(__AVR__)
-
32 #define BIGNUMBER_LIMB_8BIT 0
+
30 #if defined(__AVR__)
+
31 // 16-bit limbs seem to give the best performance on 8-bit AVR micros.
+
32 #define BIGNUMBER_LIMB_8BIT 0
33 #define BIGNUMBER_LIMB_16BIT 1
34 #define BIGNUMBER_LIMB_32BIT 0
-
35 #else
-
36 // On all other platforms, assume 32-bit is best (e.g. ARM).
-
37 #define BIGNUMBER_LIMB_8BIT 0
-
38 #define BIGNUMBER_LIMB_16BIT 0
-
39 #define BIGNUMBER_LIMB_32BIT 1
-
40 #endif
-
41 
-
42 // Define the limb types to use on this platform.
-
43 #if BIGNUMBER_LIMB_8BIT
-
44 typedef uint8_t limb_t;
-
45 typedef int8_t slimb_t;
-
46 typedef uint16_t dlimb_t;
-
47 #elif BIGNUMBER_LIMB_16BIT
-
48 typedef uint16_t limb_t;
-
49 typedef int16_t slimb_t;
-
50 typedef uint32_t dlimb_t;
-
51 #elif BIGNUMBER_LIMB_32BIT
-
52 typedef uint32_t limb_t;
-
53 typedef int32_t slimb_t;
-
54 typedef uint64_t dlimb_t;
-
55 #else
-
56 #error "limb_t must be 8, 16, or 32 bits in size"
-
57 #endif
-
58 
-
59 class BigNumberUtil
-
60 {
-
61 public:
-
62  static void unpackLE(limb_t *limbs, size_t count,
-
63  const uint8_t *bytes, size_t len);
-
64  static void unpackBE(limb_t *limbs, size_t count,
-
65  const uint8_t *bytes, size_t len);
-
66  static void packLE(uint8_t *bytes, size_t len,
-
67  const limb_t *limbs, size_t count);
-
68  static void packBE(uint8_t *bytes, size_t len,
-
69  const limb_t *limbs, size_t count);
-
70 
-
71  static limb_t add(limb_t *result, const limb_t *x,
-
72  const limb_t *y, size_t size);
-
73  static limb_t sub(limb_t *result, const limb_t *x,
-
74  const limb_t *y, size_t size);
-
75  static void mul(limb_t *result, const limb_t *x, size_t xcount,
-
76  const limb_t *y, size_t ycount);
-
77  static void reduceQuick(limb_t *result, const limb_t *x,
-
78  const limb_t *y, size_t size);
-
79 
-
80  static limb_t add_P(limb_t *result, const limb_t *x,
-
81  const limb_t *y, size_t size);
-
82  static limb_t sub_P(limb_t *result, const limb_t *x,
-
83  const limb_t *y, size_t size);
-
84  static void mul_P(limb_t *result, const limb_t *x, size_t xcount,
-
85  const limb_t *y, size_t ycount);
-
86  static void reduceQuick_P(limb_t *result, const limb_t *x,
-
87  const limb_t *y, size_t size);
-
88 
-
89  static limb_t isZero(const limb_t *x, size_t size);
-
90 
-
91 private:
-
92  // Constructor and destructor are private - cannot instantiate this class.
-
93  BigNumberUtil() {}
-
94  ~BigNumberUtil() {}
-
95 };
-
96 
-
97 #endif
-
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
-
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
-
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:541
-
BigNumberUtil::reduceQuick
static void reduceQuick(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction.
Definition: BigNumberUtil.cpp:484
-
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:408
-
BigNumberUtil
Utilities to assist with implementing big number arithmetic.
Definition: BigNumberUtil.h:59
-
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:566
-
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:294
+
35 #define BIGNUMBER_LIMB_64BIT 0
+
36 #elif defined(__GNUC__) && __WORDSIZE == 64
+
37 // 64-bit system with 128-bit double limbs.
+
38 #define BIGNUMBER_LIMB_8BIT 0
+
39 #define BIGNUMBER_LIMB_16BIT 0
+
40 #define BIGNUMBER_LIMB_32BIT 0
+
41 #define BIGNUMBER_LIMB_64BIT 1
+
42 #else
+
43 // On all other platforms, assume 32-bit is best.
+
44 #define BIGNUMBER_LIMB_8BIT 0
+
45 #define BIGNUMBER_LIMB_16BIT 0
+
46 #define BIGNUMBER_LIMB_32BIT 1
+
47 #define BIGNUMBER_LIMB_64BIT 0
+
48 #endif
+
49 
+
50 // Define the limb types to use on this platform.
+
51 #if BIGNUMBER_LIMB_8BIT
+
52 typedef uint8_t limb_t;
+
53 typedef int8_t slimb_t;
+
54 typedef uint16_t dlimb_t;
+
55 #elif BIGNUMBER_LIMB_16BIT
+
56 typedef uint16_t limb_t;
+
57 typedef int16_t slimb_t;
+
58 typedef uint32_t dlimb_t;
+
59 #elif BIGNUMBER_LIMB_32BIT
+
60 typedef uint32_t limb_t;
+
61 typedef int32_t slimb_t;
+
62 typedef uint64_t dlimb_t;
+
63 #elif BIGNUMBER_LIMB_64BIT
+
64 typedef uint64_t limb_t;
+
65 typedef int64_t slimb_t;
+
66 typedef unsigned __int128 dlimb_t;
+
67 #else
+
68 #error "limb_t must be 8, 16, 32, or 64 bits in size"
+
69 #endif
+
70 
+
71 class BigNumberUtil
+
72 {
+
73 public:
+
74  static void unpackLE(limb_t *limbs, size_t count,
+
75  const uint8_t *bytes, size_t len);
+
76  static void unpackBE(limb_t *limbs, size_t count,
+
77  const uint8_t *bytes, size_t len);
+
78  static void packLE(uint8_t *bytes, size_t len,
+
79  const limb_t *limbs, size_t count);
+
80  static void packBE(uint8_t *bytes, size_t len,
+
81  const limb_t *limbs, size_t count);
+
82 
+
83  static limb_t add(limb_t *result, const limb_t *x,
+
84  const limb_t *y, size_t size);
+
85  static limb_t sub(limb_t *result, const limb_t *x,
+
86  const limb_t *y, size_t size);
+
87  static void mul(limb_t *result, const limb_t *x, size_t xcount,
+
88  const limb_t *y, size_t ycount);
+
89  static void reduceQuick(limb_t *result, const limb_t *x,
+
90  const limb_t *y, size_t size);
+
91 
+
92  static limb_t add_P(limb_t *result, const limb_t *x,
+
93  const limb_t *y, size_t size);
+
94  static limb_t sub_P(limb_t *result, const limb_t *x,
+
95  const limb_t *y, size_t size);
+
96  static void mul_P(limb_t *result, const limb_t *x, size_t xcount,
+
97  const limb_t *y, size_t ycount);
+
98  static void reduceQuick_P(limb_t *result, const limb_t *x,
+
99  const limb_t *y, size_t size);
+
100 
+
101  static limb_t isZero(const limb_t *x, size_t size);
+
102 
+
103 private:
+
104  // Constructor and destructor are private - cannot instantiate this class.
+
105  BigNumberUtil() {}
+
106  ~BigNumberUtil() {}
+
107 };
+
108 
+
109 #endif
+
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:734
+
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:495
+
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:655
+
BigNumberUtil::reduceQuick
static void reduceQuick(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction.
Definition: BigNumberUtil.cpp:598
+
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:522
+
BigNumberUtil
Utilities to assist with implementing big number arithmetic.
Definition: BigNumberUtil.h:71
+
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:680
+
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:375
BigNumberUtil::unpackLE
static void unpackLE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the little-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:55
-
BigNumberUtil::mul
static void mul(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers.
Definition: BigNumberUtil.cpp:432
-
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:134
-
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:208
-
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:647
-
BigNumberUtil::add_P
static limb_t add_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers where one of them is in program memory.
Definition: BigNumberUtil.cpp:514
+
BigNumberUtil::mul
static void mul(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers.
Definition: BigNumberUtil.cpp:546
+
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:163
+
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:264
+
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:761
+
BigNumberUtil::add_P
static limb_t add_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers where one of them is in program memory.
Definition: BigNumberUtil.cpp:628
diff --git a/Bitmap_8cpp_source.html b/Bitmap_8cpp_source.html index efda936f..a38e9999 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 bfe6055e..48ba7650 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 977d7e85..d5c1341e 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 ba85a78a..62acb93b 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 bd07c7f8..4e6a5be0 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 fe46629e..2efa9f1c 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 dc6b2132..cb8094bb 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 082a2464..8879bc40 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 3b257913..ab19634b 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 3eb20794..28b2e08c 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 4fba491d..76eb2271 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 157da345..6f24591d 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 15a6b9a7..dcb4f183 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 30f1b8e1..5eb81dbb 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 9e6b5b06..2ebb182f 100644 --- a/ChaChaPoly_8cpp_source.html +++ b/ChaChaPoly_8cpp_source.html @@ -238,8 +238,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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
+
Poly1305::finalize
void finalize(const void *nonce, void *token, size_t len)
Finalizes the authentication process and returns the token.
Definition: Poly1305.cpp:182
+
Poly1305::reset
void reset(const void *key)
Resets the Poly1305 message authenticator for a new session.
Definition: Poly1305.cpp:113
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
ChaChaPoly::~ChaChaPoly
virtual ~ChaChaPoly()
Destroys this ChaChaPoly authenticated cipher.
Definition: ChaChaPoly.cpp:56
ChaChaPoly::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: ChaChaPoly.cpp:73
@@ -252,18 +252,18 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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
+
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:145
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: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
+
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:254
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:268
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:150
diff --git a/ChaChaPoly_8h_source.html b/ChaChaPoly_8h_source.html index 792f50d0..9071cdc6 100644 --- a/ChaChaPoly_8h_source.html +++ b/ChaChaPoly_8h_source.html @@ -173,7 +173,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ChaCha_8cpp_source.html b/ChaCha_8cpp_source.html index d2f8329a..9d6e72d0 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 3fde8694..66af6d44 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 6a838073..7e560bf6 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 fe69e9f1..f2cb9107 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 a453fd33..8f69a727 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 d20627f1..0644ce90 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 be7ab393..ea9f0f70 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 a2890be2..cca5ac21 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 c2623afe..4c78043f 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 2f277fdb..2ca67997 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 cb4cded8..6b6b7f6a 100644 --- a/Curve25519_8cpp_source.html +++ b/Curve25519_8cpp_source.html @@ -887,10 +887,10 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
962  static limb_t const a24[3] PROGMEM = {0x41, 0xDB, 0x01};
963 #elif BIGNUMBER_LIMB_16BIT
964  static limb_t const a24[2] PROGMEM = {0xDB41, 0x0001};
-
965 #elif BIGNUMBER_LIMB_32BIT
+
965 #elif BIGNUMBER_LIMB_32BIT || BIGNUMBER_LIMB_64BIT
966  static limb_t const a24[1] PROGMEM = {0x0001DB41};
967 #else
-
968  #error "limb_t must be 8, 16, or 32 bits in size"
+
968  #error "limb_t must be 8, 16, 32, or 64 bits in size"
969 #endif
970  #define NUM_A24_LIMBS (sizeof(a24) / sizeof(limb_t))
971 
@@ -1201,7 +1201,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
1319  --sel;
1320 
1321  // Swap the two values based on "select". Algorithm from:
-
1322  // https://tools.ietf.org/html/draft-irtf-cfrg-curves-02
+
1322  // http://tools.ietf.org/html/rfc7748
1323  for (posn = 0; posn < NUM_LIMBS_256BIT; ++posn) {
1324  dummy = sel & (x[posn] ^ y[posn]);
1325  x[posn] ^= dummy;
@@ -1414,51 +1414,50 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
1572 {
1573  // sqrt(-1) mod (2^255 - 19).
1574  static limb_t const numSqrtM1[NUM_LIMBS_256BIT] PROGMEM = {
-
1575  LIMB(0x4A0EA0B0), LIMB(0xC4EE1B27), LIMB(0xAD2FE478), LIMB(0x2F431806),
-
1576  LIMB(0x3DFBD7A7), LIMB(0x2B4D0099), LIMB(0x4FC1DF0B), LIMB(0x2B832480)
+
1575  LIMB_PAIR(0x4A0EA0B0, 0xC4EE1B27), LIMB_PAIR(0xAD2FE478, 0x2F431806),
+
1576  LIMB_PAIR(0x3DFBD7A7, 0x2B4D0099), LIMB_PAIR(0x4FC1DF0B, 0x2B832480)
1577  };
1578  limb_t y[NUM_LIMBS_256BIT];
1579 
-
1580  // Algorithm from:
-
1581  // https://tools.ietf.org/id/draft-josefsson-eddsa-ed25519-02.txt
-
1582 
-
1583  // Compute a candidate root: result = x^((p + 3) / 8) mod p.
-
1584  // (p + 3) / 8 = (2^252 - 2) which is 251 one bits followed by a zero:
-
1585  // 0FFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE
-
1586  pow250(result, x);
-
1587  square(result, result);
-
1588  mul(result, result, x);
-
1589  square(result, result);
-
1590 
-
1591  // Did we get the square root immediately?
-
1592  square(y, result);
-
1593  if (memcmp(x, y, sizeof(y)) == 0) {
-
1594  clean(y);
-
1595  return true;
-
1596  }
-
1597 
-
1598  // Multiply the result by sqrt(-1) and check again.
-
1599  mul_P(result, result, numSqrtM1);
-
1600  square(y, result);
-
1601  if (memcmp(x, y, sizeof(y)) == 0) {
-
1602  clean(y);
-
1603  return true;
-
1604  }
-
1605 
-
1606  // The number does not have a square root.
-
1607  clean(y);
-
1608  return false;
-
1609 }
+
1580  // Algorithm from: http://tools.ietf.org/html/rfc7748
+
1581 
+
1582  // Compute a candidate root: result = x^((p + 3) / 8) mod p.
+
1583  // (p + 3) / 8 = (2^252 - 2) which is 251 one bits followed by a zero:
+
1584  // 0FFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFF FFFFFFFE
+
1585  pow250(result, x);
+
1586  square(result, result);
+
1587  mul(result, result, x);
+
1588  square(result, result);
+
1589 
+
1590  // Did we get the square root immediately?
+
1591  square(y, result);
+
1592  if (memcmp(x, y, sizeof(y)) == 0) {
+
1593  clean(y);
+
1594  return true;
+
1595  }
+
1596 
+
1597  // Multiply the result by sqrt(-1) and check again.
+
1598  mul_P(result, result, numSqrtM1);
+
1599  square(y, result);
+
1600  if (memcmp(x, y, sizeof(y)) == 0) {
+
1601  clean(y);
+
1602  return true;
+
1603  }
+
1604 
+
1605  // The number does not have a square root.
+
1606  clean(y);
+
1607  return false;
+
1608 }
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
Curve25519::eval
static bool eval(uint8_t result[32], const uint8_t s[32], const uint8_t x[32])
Evaluates the raw Curve25519 function.
Definition: Curve25519.cpp:79
BigNumberUtil::unpackLE
static void unpackLE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the little-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:55
-
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:208
+
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:264
Curve25519::dh1
static void dh1(uint8_t k[32], uint8_t f[32])
Performs phase 1 of a Diffie-Hellman key exchange using Curve25519.
Definition: Curve25519.cpp:244
Curve25519::dh2
static bool dh2(uint8_t k[32], uint8_t f[32])
Performs phase 2 of a Diffie-Hellman key exchange using Curve25519.
Definition: Curve25519.cpp:282
diff --git a/Curve25519_8h_source.html b/Curve25519_8h_source.html index b42748ac..365c7dc6 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 4701ac1b..41d54615 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 d4bc0807..0da1afa7 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 2efc76bf..67c3ee8c 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 f40d8e30..227f9f64 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 00b8f7b8..2d2fc609 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 01dad7f4..861be51f 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 05339e07..6b9356ac 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 143ebae0..a704e0c4 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 21a5e018..7310c462 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 13f70d8d..a413ba29 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 a4fe7cc2..c6a68e06 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 a9c11cc5..83472ef4 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 d3a74e7e..43b3dd37 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 bd5222b7..56be884e 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 6b56e014..cb521d62 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 9269f6ea..34171608 100644 --- a/Ed25519_8cpp_source.html +++ b/Ed25519_8cpp_source.html @@ -119,38 +119,38 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
29 
78 // 37095705934669439343138083508754565189542113879843219016388785533085940283555
79 static limb_t const numD[NUM_LIMBS_256BIT] PROGMEM = {
-
80  LIMB(0x135978A3), LIMB(0x75EB4DCA), LIMB(0x4141D8AB), LIMB(0x00700A4D),
-
81  LIMB(0x7779E898), LIMB(0x8CC74079), LIMB(0x2B6FFE73), LIMB(0x52036CEE)
+
80  LIMB_PAIR(0x135978A3, 0x75EB4DCA), LIMB_PAIR(0x4141D8AB, 0x00700A4D),
+
81  LIMB_PAIR(0x7779E898, 0x8CC74079), LIMB_PAIR(0x2B6FFE73, 0x52036CEE)
82 };
83 
84 // d * 2
85 static limb_t const numDx2[NUM_LIMBS_256BIT] PROGMEM = {
-
86  LIMB(0x26B2F159), LIMB(0xEBD69B94), LIMB(0x8283B156), LIMB(0x00E0149A),
-
87  LIMB(0xEEF3D130), LIMB(0x198E80F2), LIMB(0x56DFFCE7), LIMB(0x2406D9DC)
+
86  LIMB_PAIR(0x26B2F159, 0xEBD69B94), LIMB_PAIR(0x8283B156, 0x00E0149A),
+
87  LIMB_PAIR(0xEEF3D130, 0x198E80F2), LIMB_PAIR(0x56DFFCE7, 0x2406D9DC)
88 };
89 
90 // Extended homogenous co-ordinates for the base point.
91 static limb_t const numBx[NUM_LIMBS_256BIT] PROGMEM = {
-
92  LIMB(0x8F25D51A), LIMB(0xC9562D60), LIMB(0x9525A7B2), LIMB(0x692CC760),
-
93  LIMB(0xFDD6DC5C), LIMB(0xC0A4E231), LIMB(0xCD6E53FE), LIMB(0x216936D3)
+
92  LIMB_PAIR(0x8F25D51A, 0xC9562D60), LIMB_PAIR(0x9525A7B2, 0x692CC760),
+
93  LIMB_PAIR(0xFDD6DC5C, 0xC0A4E231), LIMB_PAIR(0xCD6E53FE, 0x216936D3)
94 };
95 static limb_t const numBy[NUM_LIMBS_256BIT] PROGMEM = {
-
96  LIMB(0x66666658), LIMB(0x66666666), LIMB(0x66666666), LIMB(0x66666666),
-
97  LIMB(0x66666666), LIMB(0x66666666), LIMB(0x66666666), LIMB(0x66666666)
+
96  LIMB_PAIR(0x66666658, 0x66666666), LIMB_PAIR(0x66666666, 0x66666666),
+
97  LIMB_PAIR(0x66666666, 0x66666666), LIMB_PAIR(0x66666666, 0x66666666)
98 };
99 static limb_t const numBz[NUM_LIMBS_256BIT] PROGMEM = {
-
100  LIMB(0x00000001), LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000),
-
101  LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000)
+
100  LIMB_PAIR(0x00000001, 0x00000000), LIMB_PAIR(0x00000000, 0x00000000),
+
101  LIMB_PAIR(0x00000000, 0x00000000), LIMB_PAIR(0x00000000, 0x00000000)
102 };
103 static limb_t const numBt[NUM_LIMBS_256BIT] PROGMEM = {
-
104  LIMB(0xA5B7DDA3), LIMB(0x6DDE8AB3), LIMB(0x775152F5), LIMB(0x20F09F80),
-
105  LIMB(0x64ABE37D), LIMB(0x66EA4E8E), LIMB(0xD78B7665), LIMB(0x67875F0F)
+
104  LIMB_PAIR(0xA5B7DDA3, 0x6DDE8AB3), LIMB_PAIR(0x775152F5, 0x20F09F80),
+
105  LIMB_PAIR(0x64ABE37D, 0x66EA4E8E), LIMB_PAIR(0xD78B7665, 0x67875F0F)
106 };
107 
108 // 2^252 + 27742317777372353535851937790883648493
109 static limb_t const numQ[NUM_LIMBS_256BIT] PROGMEM = {
-
110  LIMB(0x5CF5D3ED), LIMB(0x5812631A), LIMB(0xA2F79CD6), LIMB(0x14DEF9DE),
-
111  LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000), LIMB(0x10000000)
+
110  LIMB_PAIR(0x5CF5D3ED, 0x5812631A), LIMB_PAIR(0xA2F79CD6, 0x14DEF9DE),
+
111  LIMB_PAIR(0x00000000, 0x00000000), LIMB_PAIR(0x00000000, 0x10000000)
112 };
113 
127 void Ed25519::sign(uint8_t signature[64], const uint8_t privateKey[32],
@@ -291,8 +291,8 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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),
+
319  LIMB_PAIR(0x0A2C131B, 0xED9CE5A3), LIMB_PAIR(0x086329A7, 0x2106215D),
+
320  LIMB_PAIR(0xFFFFFFEB, 0xFFFFFFFF), LIMB_PAIR(0xFFFFFFFF, 0xFFFFFFFF),
321  0x0F
322  };
323  limb_t temp[NUM_LIMBS_512BIT + NUM_LIMBS_256BIT + 1];
@@ -553,25 +553,25 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
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
+
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:734
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
+
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:495
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
Ed25519::verify
static bool verify(const uint8_t signature[64], const uint8_t publicKey[32], const void *message, size_t len)
Verifies a signature using a specific Ed25519 public key.
Definition: Ed25519.cpp:189
SHA512
SHA-512 hash algorithm.
Definition: SHA512.h:30
SHA512::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: SHA512.cpp:66
SHA512::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA512.cpp:79
-
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:408
-
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:566
+
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:522
+
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:680
BigNumberUtil::unpackLE
static void unpackLE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the little-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:55
SHA512::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA512.cpp:105
-
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:208
+
BigNumberUtil::packLE
static void packLE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the little-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:264
Ed25519::sign
static void sign(uint8_t signature[64], const uint8_t privateKey[32], const uint8_t publicKey[32], const void *message, size_t len)
Signs a message using a specific Ed25519 private key.
Definition: Ed25519.cpp:127
Ed25519::derivePublicKey
static void derivePublicKey(uint8_t publicKey[32], const uint8_t privateKey[32])
Derives the public key from a private key.
Definition: Ed25519.cpp:256
diff --git a/Ed25519_8h_source.html b/Ed25519_8h_source.html index fd76ae07..fa940628 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 cd987ac8..ec0e6c54 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 09a40284..498b9575 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 225b6bad..e33db32a 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 0ef203db..653b7d7c 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 2961303f..5742fa12 100644 --- a/GCM_8cpp_source.html +++ b/GCM_8cpp_source.html @@ -353,7 +353,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GCM_8h_source.html b/GCM_8h_source.html index 2ba57626..cbe2ea81 100644 --- a/GCM_8h_source.html +++ b/GCM_8h_source.html @@ -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 d547f107..bf2e82de 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 dc0a7077..e5ae73a9 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 da4f7e96..26a0df69 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 a0dea5be..d269b1ff 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 753dfe9c..b8705368 100644 --- a/Hash_8cpp_source.html +++ b/Hash_8cpp_source.html @@ -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 ab833294..8321f11e 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 230163b0..32393ebd 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 2adb1d44..0a7374ff 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 d4ac16ae..214e4198 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 02afc255..7441336b 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 466cb911..df10f17e 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 19355b72..6d8abf93 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 d190193c..98ef8dc4 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 db1ffd49..05b86683 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 19a19742..a541039f 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 b470bb78..2e06a53a 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 1f2db0cd..f67e021e 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 afe63b4f..03e24c55 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 8450d2f1..1568cf04 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 09ea12b7..580d51ea 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 4c3ece29..8b528916 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 a11c1854..bfe4ef39 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 5573065a..4642d989 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/NewHope_8cpp_source.html b/NewHope_8cpp_source.html new file mode 100644 index 00000000..dde67cb4 --- /dev/null +++ b/NewHope_8cpp_source.html @@ -0,0 +1,1201 @@ + + + + + + +ArduinoLibs: NewHope.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
+ + +
+ +
+ + +
+
+
+
NewHope.cpp
+
+
+
1 /*
+
2  * Copyright (C) 2016 Southern Storm Software, Pty Ltd.
+
3  *
+
4  * Permission is hereby granted, free of charge, to any person obtaining a
+
5  * copy of this software and associated documentation files (the "Software"),
+
6  * to deal in the Software without restriction, including without limitation
+
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+
8  * and/or sell copies of the Software, and to permit persons to whom the
+
9  * Software is furnished to do so, subject to the following conditions:
+
10  *
+
11  * The above copyright notice and this permission notice shall be included
+
12  * in all copies or substantial portions of the Software.
+
13  *
+
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+
20  * DEALINGS IN THE SOFTWARE.
+
21  */
+
22 
+
23 #include "NewHope.h"
+
24 #include <Crypto.h>
+
25 #include <ChaCha.h>
+
26 #include <SHA3.h>
+
27 #include <SHAKE.h>
+
28 #include <RNG.h>
+
29 #include <string.h>
+
30 
+
31 // Define this to 0 to disable the "torref" version, which will save
+
32 // some code and data memory if you don't need that variant.
+
33 #define NEWHOPE_TORREF 1
+
34 
+
130 // The following is public domain code from the reference C version of
+
131 // New Hope at https://cryptojedi.org/crypto/#newhope. This part of
+
132 // the Arduino port remains public domain. Original authors:
+
133 // Erdem Alkim, Léo Ducas, Thomas Pöppelmann, Peter Schwabe
+
134 
+
135 #define PARAM_N 1024
+
136 #define PARAM_K 16
+
137 #define PARAM_Q 12289
+
138 #define POLY_BYTES 1792
+
139 #define NEWHOPE_SEEDBYTES 32
+
140 #define NEWHOPE_RECBYTES 256
+
141 
+
142 static uint16_t const omegas_montgomery[PARAM_N/2] = {
+
143  4075,6974,7373,7965,3262,5079,522,2169,6364,1018,1041,8775,2344,
+
144  11011,5574,1973,4536,1050,6844,3860,3818,6118,2683,1190,4789,7822,
+
145  7540,6752,5456,4449,3789,12142,11973,382,3988,468,6843,5339,6196,
+
146  3710,11316,1254,5435,10930,3998,10256,10367,3879,11889,1728,6137,
+
147  4948,5862,6136,3643,6874,8724,654,10302,1702,7083,6760,56,3199,9987,
+
148  605,11785,8076,5594,9260,6403,4782,6212,4624,9026,8689,4080,11868,
+
149  6221,3602,975,8077,8851,9445,5681,3477,1105,142,241,12231,1003,
+
150  3532,5009,1956,6008,11404,7377,2049,10968,12097,7591,5057,3445,
+
151  4780,2920,7048,3127,8120,11279,6821,11502,8807,12138,2127,2839,
+
152  3957,431,1579,6383,9784,5874,677,3336,6234,2766,1323,9115,12237,
+
153  2031,6956,6413,2281,3969,3991,12133,9522,4737,10996,4774,5429,11871,
+
154  3772,453,5908,2882,1805,2051,1954,11713,3963,2447,6142,8174,3030,
+
155  1843,2361,12071,2908,3529,3434,3202,7796,2057,5369,11939,1512,6906,
+
156  10474,11026,49,10806,5915,1489,9789,5942,10706,10431,7535,426,8974,
+
157  3757,10314,9364,347,5868,9551,9634,6554,10596,9280,11566,174,2948,
+
158  2503,6507,10723,11606,2459,64,3656,8455,5257,5919,7856,1747,9166,
+
159  5486,9235,6065,835,3570,4240,11580,4046,10970,9139,1058,8210,11848,
+
160  922,7967,1958,10211,1112,3728,4049,11130,5990,1404,325,948,11143,
+
161  6190,295,11637,5766,8212,8273,2919,8527,6119,6992,8333,1360,2555,
+
162  6167,1200,7105,7991,3329,9597,12121,5106,5961,10695,10327,3051,9923,
+
163  4896,9326,81,3091,1000,7969,4611,726,1853,12149,4255,11112,2768,
+
164  10654,1062,2294,3553,4805,2747,4846,8577,9154,1170,2319,790,11334,
+
165  9275,9088,1326,5086,9094,6429,11077,10643,3504,3542,8668,9744,1479,
+
166  1,8246,7143,11567,10984,4134,5736,4978,10938,5777,8961,4591,5728,
+
167  6461,5023,9650,7468,949,9664,2975,11726,2744,9283,10092,5067,12171,
+
168  2476,3748,11336,6522,827,9452,5374,12159,7935,3296,3949,9893,4452,
+
169  10908,2525,3584,8112,8011,10616,4989,6958,11809,9447,12280,1022,
+
170  11950,9821,11745,5791,5092,2089,9005,2881,3289,2013,9048,729,7901,
+
171  1260,5755,4632,11955,2426,10593,1428,4890,5911,3932,9558,8830,3637,
+
172  5542,145,5179,8595,3707,10530,355,3382,4231,9741,1207,9041,7012,1168,
+
173  10146,11224,4645,11885,10911,10377,435,7952,4096,493,9908,6845,6039,
+
174  2422,2187,9723,8643,9852,9302,6022,7278,1002,4284,5088,1607,7313,
+
175  875,8509,9430,1045,2481,5012,7428,354,6591,9377,11847,2401,1067,
+
176  7188,11516,390,8511,8456,7270,545,8585,9611,12047,1537,4143,4714,
+
177  4885,1017,5084,1632,3066,27,1440,8526,9273,12046,11618,9289,3400,
+
178  9890,3136,7098,8758,11813,7384,3985,11869,6730,10745,10111,2249,
+
179  4048,2884,11136,2126,1630,9103,5407,2686,9042,2969,8311,9424,
+
180  9919,8779,5332,10626,1777,4654,10863,7351,3636,9585,5291,8374,
+
181  2166,4919,12176,9140,12129,7852,12286,4895,10805,2780,5195,2305,
+
182  7247,9644,4053,10600,3364,3271,4057,4414,9442,7917,2174
+
183 };
+
184 
+
185 static uint16_t const omegas_inv_montgomery[PARAM_N/2] = {
+
186  4075,5315,4324,4916,10120,11767,7210,9027,10316,6715,1278,9945,
+
187  3514,11248,11271,5925,147,8500,7840,6833,5537,4749,4467,7500,11099,
+
188  9606,6171,8471,8429,5445,11239,7753,9090,12233,5529,5206,10587,
+
189  1987,11635,3565,5415,8646,6153,6427,7341,6152,10561,400,8410,1922,
+
190  2033,8291,1359,6854,11035,973,8579,6093,6950,5446,11821,8301,11907,
+
191  316,52,3174,10966,9523,6055,8953,11612,6415,2505,5906,10710,11858,
+
192  8332,9450,10162,151,3482,787,5468,1010,4169,9162,5241,9369,7509,
+
193  8844,7232,4698,192,1321,10240,4912,885,6281,10333,7280,8757,11286,
+
194  58,12048,12147,11184,8812,6608,2844,3438,4212,11314,8687,6068,421,
+
195  8209,3600,3263,7665,6077,7507,5886,3029,6695,4213,504,11684,2302,
+
196  1962,1594,6328,7183,168,2692,8960,4298,5184,11089,6122,9734,10929,
+
197  3956,5297,6170,3762,9370,4016,4077,6523,652,11994,6099,1146,11341,
+
198  11964,10885,6299,1159,8240,8561,11177,2078,10331,4322,11367,441,
+
199  4079,11231,3150,1319,8243,709,8049,8719,11454,6224,3054,6803,3123,
+
200  10542,4433,6370,7032,3834,8633,12225,9830,683,1566,5782,9786,9341,
+
201  12115,723,3009,1693,5735,2655,2738,6421,11942,2925,1975,8532,3315,
+
202  11863,4754,1858,1583,6347,2500,10800,6374,1483,12240,1263,1815,
+
203  5383,10777,350,6920,10232,4493,9087,8855,8760,9381,218,9928,10446,
+
204  9259,4115,6147,9842,8326,576,10335,10238,10484,9407,6381,11836,8517,
+
205  418,6860,7515,1293,7552,2767,156,8298,8320,10008,5876,5333,10258,
+
206  10115,4372,2847,7875,8232,9018,8925,1689,8236,2645,5042,9984,7094,
+
207  9509,1484,7394,3,4437,160,3149,113,7370,10123,3915,6998,2704,8653,
+
208  4938,1426,7635,10512,1663,6957,3510,2370,2865,3978,9320,3247,9603,
+
209  6882,3186,10659,10163,1153,9405,8241,10040,2178,1544,5559,420,8304,
+
210  4905,476,3531,5191,9153,2399,8889,3000,671,243,3016,3763,10849,12262,
+
211  9223,10657,7205,11272,7404,7575,8146,10752,242,2678,3704,11744,
+
212  5019,3833,3778,11899,773,5101,11222,9888,442,2912,5698,11935,4861,
+
213  7277,9808,11244,2859,3780,11414,4976,10682,7201,8005,11287,5011,
+
214  6267,2987,2437,3646,2566,10102,9867,6250,5444,2381,11796,8193,4337,
+
215  11854,1912,1378,404,7644,1065,2143,11121,5277,3248,11082,2548,8058,
+
216  8907,11934,1759,8582,3694,7110,12144,6747,8652,3459,2731,8357,6378,
+
217  7399,10861,1696,9863,334,7657,6534,11029,4388,11560,3241,10276,9000,
+
218  9408,3284,10200,7197,6498,544,2468,339,11267,9,2842,480,5331,7300,
+
219  1673,4278,4177,8705,9764,1381,7837,2396,8340,8993,4354,130,6915,
+
220  2837,11462,5767,953,8541,9813,118,7222,2197,3006,9545,563,9314,
+
221  2625,11340,4821,2639,7266,5828,6561,7698,3328,6512,1351,7311,6553,
+
222  8155,1305,722,5146,4043,12288,10810,2545,3621,8747,8785,1646,1212,
+
223  5860,3195,7203,10963,3201,3014,955,11499,9970,11119,3135,3712,7443,
+
224  9542,7484,8736,9995,11227,1635,9521,1177,8034,140,10436,11563,7678,
+
225  4320,11289,9198,12208,2963,7393,2366,9238
+
226 };
+
227 
+
228 static uint16_t const psis_bitrev_montgomery[PARAM_N] = {
+
229  4075,6974,7373,7965,3262,5079,522,2169,6364,1018,1041,8775,2344,
+
230  11011,5574,1973,4536,1050,6844,3860,3818,6118,2683,1190,4789,7822,
+
231  7540,6752,5456,4449,3789,12142,11973,382,3988,468,6843,5339,6196,3710,
+
232  11316,1254,5435,10930,3998,10256,10367,3879,11889,1728,6137,4948,
+
233  5862,6136,3643,6874,8724,654,10302,1702,7083,6760,56,3199,9987,605,
+
234  11785,8076,5594,9260,6403,4782,6212,4624,9026,8689,4080,11868,6221,
+
235  3602,975,8077,8851,9445,5681,3477,1105,142,241,12231,1003,3532,5009,
+
236  1956,6008,11404,7377,2049,10968,12097,7591,5057,3445,4780,2920,
+
237  7048,3127,8120,11279,6821,11502,8807,12138,2127,2839,3957,431,1579,
+
238  6383,9784,5874,677,3336,6234,2766,1323,9115,12237,2031,6956,6413,
+
239  2281,3969,3991,12133,9522,4737,10996,4774,5429,11871,3772,453,
+
240  5908,2882,1805,2051,1954,11713,3963,2447,6142,8174,3030,1843,2361,
+
241  12071,2908,3529,3434,3202,7796,2057,5369,11939,1512,6906,10474,
+
242  11026,49,10806,5915,1489,9789,5942,10706,10431,7535,426,8974,3757,
+
243  10314,9364,347,5868,9551,9634,6554,10596,9280,11566,174,2948,2503,
+
244  6507,10723,11606,2459,64,3656,8455,5257,5919,7856,1747,9166,5486,
+
245  9235,6065,835,3570,4240,11580,4046,10970,9139,1058,8210,11848,922,
+
246  7967,1958,10211,1112,3728,4049,11130,5990,1404,325,948,11143,6190,
+
247  295,11637,5766,8212,8273,2919,8527,6119,6992,8333,1360,2555,6167,
+
248  1200,7105,7991,3329,9597,12121,5106,5961,10695,10327,3051,9923,
+
249  4896,9326,81,3091,1000,7969,4611,726,1853,12149,4255,11112,2768,
+
250  10654,1062,2294,3553,4805,2747,4846,8577,9154,1170,2319,790,11334,
+
251  9275,9088,1326,5086,9094,6429,11077,10643,3504,3542,8668,9744,1479,
+
252  1,8246,7143,11567,10984,4134,5736,4978,10938,5777,8961,4591,5728,
+
253  6461,5023,9650,7468,949,9664,2975,11726,2744,9283,10092,5067,12171,
+
254  2476,3748,11336,6522,827,9452,5374,12159,7935,3296,3949,9893,4452,
+
255  10908,2525,3584,8112,8011,10616,4989,6958,11809,9447,12280,1022,
+
256  11950,9821,11745,5791,5092,2089,9005,2881,3289,2013,9048,729,7901,
+
257  1260,5755,4632,11955,2426,10593,1428,4890,5911,3932,9558,8830,3637,
+
258  5542,145,5179,8595,3707,10530,355,3382,4231,9741,1207,9041,7012,
+
259  1168,10146,11224,4645,11885,10911,10377,435,7952,4096,493,9908,6845,
+
260  6039,2422,2187,9723,8643,9852,9302,6022,7278,1002,4284,5088,1607,
+
261  7313,875,8509,9430,1045,2481,5012,7428,354,6591,9377,11847,2401,
+
262  1067,7188,11516,390,8511,8456,7270,545,8585,9611,12047,1537,4143,
+
263  4714,4885,1017,5084,1632,3066,27,1440,8526,9273,12046,11618,9289,
+
264  3400,9890,3136,7098,8758,11813,7384,3985,11869,6730,10745,10111,
+
265  2249,4048,2884,11136,2126,1630,9103,5407,2686,9042,2969,8311,9424,
+
266  9919,8779,5332,10626,1777,4654,10863,7351,3636,9585,5291,8374,
+
267  2166,4919,12176,9140,12129,7852,12286,4895,10805,2780,5195,2305,
+
268  7247,9644,4053,10600,3364,3271,4057,4414,9442,7917,2174,3947,
+
269  11951,2455,6599,10545,10975,3654,2894,7681,7126,7287,12269,4119,
+
270  3343,2151,1522,7174,7350,11041,2442,2148,5959,6492,8330,8945,5598,
+
271  3624,10397,1325,6565,1945,11260,10077,2674,3338,3276,11034,506,
+
272  6505,1392,5478,8778,1178,2776,3408,10347,11124,2575,9489,12096,
+
273  6092,10058,4167,6085,923,11251,11912,4578,10669,11914,425,10453,
+
274  392,10104,8464,4235,8761,7376,2291,3375,7954,8896,6617,7790,1737,
+
275  11667,3982,9342,6680,636,6825,7383,512,4670,2900,12050,7735,994,
+
276  1687,11883,7021,146,10485,1403,5189,6094,2483,2054,3042,10945,
+
277  3981,10821,11826,8882,8151,180,9600,7684,5219,10880,6780,204,
+
278  11232,2600,7584,3121,3017,11053,7814,7043,4251,4739,11063,6771,
+
279  7073,9261,2360,11925,1928,11825,8024,3678,3205,3359,11197,5209,
+
280  8581,3238,8840,1136,9363,1826,3171,4489,7885,346,2068,1389,8257,
+
281  3163,4840,6127,8062,8921,612,4238,10763,8067,125,11749,10125,5416,
+
282  2110,716,9839,10584,11475,11873,3448,343,1908,4538,10423,7078,
+
283  4727,1208,11572,3589,2982,1373,1721,10753,4103,2429,4209,5412,
+
284  5993,9011,438,3515,7228,1218,8347,5232,8682,1327,7508,4924,448,
+
285  1014,10029,12221,4566,5836,12229,2717,1535,3200,5588,5845,412,
+
286  5102,7326,3744,3056,2528,7406,8314,9202,6454,6613,1417,10032,7784,
+
287  1518,3765,4176,5063,9828,2275,6636,4267,6463,2065,7725,3495,8328,
+
288  8755,8144,10533,5966,12077,9175,9520,5596,6302,8400,579,6781,11014,
+
289  5734,11113,11164,4860,1131,10844,9068,8016,9694,3837,567,9348,7000,
+
290  6627,7699,5082,682,11309,5207,4050,7087,844,7434,3769,293,9057,
+
291  6940,9344,10883,2633,8190,3944,5530,5604,3480,2171,9282,11024,2213,
+
292  8136,3805,767,12239,216,11520,6763,10353,7,8566,845,7235,3154,4360,
+
293  3285,10268,2832,3572,1282,7559,3229,8360,10583,6105,3120,6643,6203,
+
294  8536,8348,6919,3536,9199,10891,11463,5043,1658,5618,8787,5789,4719,
+
295  751,11379,6389,10783,3065,7806,6586,2622,5386,510,7628,6921,578,
+
296  10345,11839,8929,4684,12226,7154,9916,7302,8481,3670,11066,2334,
+
297  1590,7878,10734,1802,1891,5103,6151,8820,3418,7846,9951,4693,417,
+
298  9996,9652,4510,2946,5461,365,881,1927,1015,11675,11009,1371,12265,
+
299  2485,11385,5039,6742,8449,1842,12217,8176,9577,4834,7937,9461,2643,
+
300  11194,3045,6508,4094,3451,7911,11048,5406,4665,3020,6616,11345,
+
301  7519,3669,5287,1790,7014,5410,11038,11249,2035,6125,10407,4565,
+
302  7315,5078,10506,2840,2478,9270,4194,9195,4518,7469,1160,6878,2730,
+
303  10421,10036,1734,3815,10939,5832,10595,10759,4423,8420,9617,7119,
+
304  11010,11424,9173,189,10080,10526,3466,10588,7592,3578,11511,7785,
+
305  9663,530,12150,8957,2532,3317,9349,10243,1481,9332,3454,3758,7899,
+
306  4218,2593,11410,2276,982,6513,1849,8494,9021,4523,7988,8,457,648,
+
307  150,8000,2307,2301,874,5650,170,9462,2873,9855,11498,2535,11169,
+
308  5808,12268,9687,1901,7171,11787,3846,1573,6063,3793,466,11259,
+
309  10608,3821,6320,4649,6263,2929
+
310 };
+
311 
+
312 static uint16_t const psis_inv_montgomery[PARAM_N] = {
+
313  256,10570,1510,7238,1034,7170,6291,7921,11665,3422,4000,2327,
+
314  2088,5565,795,10647,1521,5484,2539,7385,1055,7173,8047,11683,
+
315  1669,1994,3796,5809,4341,9398,11876,12230,10525,12037,12253,
+
316  3506,4012,9351,4847,2448,7372,9831,3160,2207,5582,2553,7387,6322,
+
317  9681,1383,10731,1533,219,5298,4268,7632,6357,9686,8406,4712,9451,
+
318  10128,4958,5975,11387,8649,11769,6948,11526,12180,1740,10782,
+
319  6807,2728,7412,4570,4164,4106,11120,12122,8754,11784,3439,5758,
+
320  11356,6889,9762,11928,1704,1999,10819,12079,12259,7018,11536,
+
321  1648,1991,2040,2047,2048,10826,12080,8748,8272,8204,1172,1923,
+
322  7297,2798,7422,6327,4415,7653,6360,11442,12168,7005,8023,9924,
+
323  8440,8228,2931,7441,1063,3663,5790,9605,10150,1450,8985,11817,
+
324  10466,10273,12001,3470,7518,1074,1909,7295,9820,4914,702,5367,
+
325  7789,8135,9940,1420,3714,11064,12114,12264,1752,5517,9566,11900,
+
326  1700,3754,5803,829,1874,7290,2797,10933,5073,7747,8129,6428,
+
327  6185,11417,1631,233,5300,9535,10140,11982,8734,8270,2937,10953,
+
328  8587,8249,2934,9197,4825,5956,4362,9401,1343,3703,529,10609,
+
329  12049,6988,6265,895,3639,4031,4087,4095,585,10617,8539,4731,
+
330  4187,9376,3095,9220,10095,10220,1460,10742,12068,1724,5513,
+
331  11321,6884,2739,5658,6075,4379,11159,10372,8504,4726,9453,3106,
+
332  7466,11600,10435,8513,9994,8450,9985,3182,10988,8592,2983,9204,
+
333  4826,2445,5616,6069,867,3635,5786,11360,5134,2489,10889,12089,
+
334  1727,7269,2794,9177,1311,5454,9557,6632,2703,9164,10087,1441,
+
335  3717,531,3587,2268,324,5313,759,1864,5533,2546,7386,9833,8427,
+
336  4715,11207,1601,7251,4547,11183,12131,1733,10781,10318,1474,
+
337  10744,5046,4232,11138,10369,6748,964,7160,4534,7670,8118,8182,
+
338  4680,11202,6867,981,8918,1274,182,26,7026,8026,11680,12202,
+
339  10521,1503,7237,4545,5916,9623,8397,11733,10454,3249,9242,6587,
+
340  941,1890,270,10572,6777,9746,6659,6218,6155,6146,878,1881,7291,
+
341  11575,12187,1741,7271,8061,11685,6936,4502,9421,4857,4205,7623,
+
342  1089,10689,1527,8996,10063,11971,10488,6765,2722,3900,9335,11867,
+
343  6962,11528,5158,4248,4118,5855,2592,5637,6072,2623,7397,8079,
+
344  9932,4930,5971,853,3633,519,8852,11798,3441,11025,1575,225,8810,
+
345  11792,12218,3501,9278,3081,9218,4828,7712,8124,11694,12204,3499,
+
346  4011,573,3593,5780,7848,9899,10192,1456,208,7052,2763,7417,11593,
+
347  10434,12024,8740,11782,10461,3250,5731,7841,9898,1414,202,3540,
+
348  7528,2831,2160,10842,5060,4234,4116,588,84,12,7024,2759,9172,6577,
+
349  11473,1639,9012,3043,7457,6332,11438,1634,1989,9062,11828,8712,
+
350  11778,12216,10523,6770,9745,10170,4964,9487,6622,946,8913,6540,
+
351  6201,4397,9406,8366,9973,8447,8229,11709,8695,10020,3187,5722,
+
352  2573,10901,6824,4486,4152,9371,8361,2950,2177,311,1800,9035,
+
353  8313,11721,3430,490,70,10,1757,251,3547,7529,11609,3414,7510,
+
354  4584,4166,9373,1339,5458,7802,11648,1664,7260,9815,10180,6721,
+
355  9738,10169,8475,8233,9954,1422,8981,1283,5450,11312,1616,3742,
+
356  11068,10359,4991,713,3613,9294,8350,4704,672,96,7036,9783,11931,
+
357  3460,5761,823,10651,12055,10500,1500,5481,783,3623,11051,8601,
+
358  8251,8201,11705,10450,5004,4226,7626,2845,2162,3820,7568,9859,
+
359  3164,452,10598,1514,5483,6050,6131,4387,7649,8115,6426,918,8909,
+
360  8295,1185,5436,11310,8638,1234,5443,11311,5127,2488,2111,10835,
+
361  5059,7745,2862,3920,560,80,1767,2008,3798,11076,6849,2734,10924,
+
362  12094,8750,1250,10712,6797,971,7161,1023,8924,4786,7706,4612,4170,
+
363  7618,6355,4419,5898,11376,10403,10264,6733,4473,639,5358,2521,
+
364  9138,3061,5704,4326,618,5355,765,5376,768,7132,4530,9425,3102,
+
365  9221,6584,11474,10417,10266,12000,6981,6264,4406,2385,7363,4563,
+
366  4163,7617,9866,3165,9230,11852,10471,5007,5982,11388,5138,734,
+
367  3616,11050,12112,6997,11533,12181,10518,12036,3475,2252,7344,
+
368  9827,4915,9480,6621,4457,7659,9872,6677,4465,4149,7615,4599,657,
+
369  3605,515,10607,6782,4480,640,1847,3775,5806,2585,5636,9583,1369,
+
370  10729,8555,10000,11962,5220,7768,8132,8184,9947,1421,203,29,8782,
+
371  11788,1684,10774,10317,4985,9490,8378,4708,11206,5112,5997,7879,
+
372  11659,12199,8765,10030,4944,5973,6120,6141,6144,7900,11662,1666,
+
373  238,34,3516,5769,9602,8394,9977,6692,956,10670,6791,9748,11926,
+
374  8726,11780,5194,742,106,8793,10034,3189,10989,5081,4237,5872,4350,
+
375  2377,10873,6820,6241,11425,10410,10265,3222,5727,9596,4882,2453,
+
376  2106,3812,11078,12116,5242,4260,11142,8614,11764,12214,5256,4262,
+
377  4120,11122,5100,11262,5120,2487,5622,9581,8391,8221,2930,10952,
+
378  12098,6995,6266,9673,4893,699,3611,4027,5842,11368,1624,232,8811,
+
379  8281,1183,169,8802,3013,2186,5579,797,3625,4029,11109,1587,7249,
+
380  11569,8675,6506,2685,10917,12093,12261,12285,1755,7273,1039,1904,
+
381  272,3550,9285,3082,5707,6082,4380,7648,11626,5172,4250,9385,8363,
+
382  8217,4685,5936,848,8899,6538,934,1889,3781,9318,10109,10222,6727,
+
383  961,5404,772,5377,9546,8386,1198,8949,3034,2189,7335,4559,5918,2601,
+
384  10905,5069,9502,3113,7467,8089,11689,5181,9518,8382,2953,3933,4073,
+
385  4093,7607,8109,2914,5683,4323,11151,1593,10761,6804,972,3650,2277,
+
386  5592,4310,7638,9869,4921,703,1856,9043,4803,9464,1352,8971,11815,
+
387  5199,7765,6376,4422,7654,2849,407,8836,6529,7955,2892,9191,1313,
+
388  10721,12065,12257,1751,9028,8312,2943,2176,3822,546,78,8789,11789,
+
389  10462,12028,6985,4509,9422,1346,5459,4291,613,10621,6784,9747,3148,
+
390  7472,2823,5670,810,7138,8042,4660,7688,6365,6176,6149,2634,5643,
+
391  9584,10147,11983,5223,9524,11894,10477,8519,1217,3685,2282,326,
+
392  10580,3267,7489,4581,2410,5611,11335,6886,8006,8166,11700,3427,
+
393  11023,8597,10006,3185,455,65,5276,7776,4622,5927,7869,9902,11948,
+
394  5218,2501,5624,2559,10899,1557,1978,10816,10323,8497,4725,675,1852,
+
395  10798,12076,10503,3256,9243,3076,2195,10847,12083,10504,12034,10497
+
396 };
+
397 
+
398 static uint16_t const bitrev_table[PARAM_N] = {
+
399  0,512,256,768,128,640,384,896,64,576,320,832,192,704,448,960,32,544,288,800,160,672,416,928,96,608,352,864,224,736,480,992,
+
400  16,528,272,784,144,656,400,912,80,592,336,848,208,720,464,976,48,560,304,816,176,688,432,944,112,624,368,880,240,752,496,1008,
+
401  8,520,264,776,136,648,392,904,72,584,328,840,200,712,456,968,40,552,296,808,168,680,424,936,104,616,360,872,232,744,488,1000,
+
402  24,536,280,792,152,664,408,920,88,600,344,856,216,728,472,984,56,568,312,824,184,696,440,952,120,632,376,888,248,760,504,1016,
+
403  4,516,260,772,132,644,388,900,68,580,324,836,196,708,452,964,36,548,292,804,164,676,420,932,100,612,356,868,228,740,484,996,
+
404  20,532,276,788,148,660,404,916,84,596,340,852,212,724,468,980,52,564,308,820,180,692,436,948,116,628,372,884,244,756,500,1012,
+
405  12,524,268,780,140,652,396,908,76,588,332,844,204,716,460,972,44,556,300,812,172,684,428,940,108,620,364,876,236,748,492,1004,
+
406  28,540,284,796,156,668,412,924,92,604,348,860,220,732,476,988,60,572,316,828,188,700,444,956,124,636,380,892,252,764,508,1020,
+
407  2,514,258,770,130,642,386,898,66,578,322,834,194,706,450,962,34,546,290,802,162,674,418,930,98,610,354,866,226,738,482,994,
+
408  18,530,274,786,146,658,402,914,82,594,338,850,210,722,466,978,50,562,306,818,178,690,434,946,114,626,370,882,242,754,498,1010,
+
409  10,522,266,778,138,650,394,906,74,586,330,842,202,714,458,970,42,554,298,810,170,682,426,938,106,618,362,874,234,746,490,1002,
+
410  26,538,282,794,154,666,410,922,90,602,346,858,218,730,474,986,58,570,314,826,186,698,442,954,122,634,378,890,250,762,506,1018,
+
411  6,518,262,774,134,646,390,902,70,582,326,838,198,710,454,966,38,550,294,806,166,678,422,934,102,614,358,870,230,742,486,998,
+
412  22,534,278,790,150,662,406,918,86,598,342,854,214,726,470,982,54,566,310,822,182,694,438,950,118,630,374,886,246,758,502,1014,
+
413  14,526,270,782,142,654,398,910,78,590,334,846,206,718,462,974,46,558,302,814,174,686,430,942,110,622,366,878,238,750,494,1006,
+
414  30,542,286,798,158,670,414,926,94,606,350,862,222,734,478,990,62,574,318,830,190,702,446,958,126,638,382,894,254,766,510,1022,
+
415  1,513,257,769,129,641,385,897,65,577,321,833,193,705,449,961,33,545,289,801,161,673,417,929,97,609,353,865,225,737,481,993,
+
416  17,529,273,785,145,657,401,913,81,593,337,849,209,721,465,977,49,561,305,817,177,689,433,945,113,625,369,881,241,753,497,1009,
+
417  9,521,265,777,137,649,393,905,73,585,329,841,201,713,457,969,41,553,297,809,169,681,425,937,105,617,361,873,233,745,489,1001,
+
418  25,537,281,793,153,665,409,921,89,601,345,857,217,729,473,985,57,569,313,825,185,697,441,953,121,633,377,889,249,761,505,1017,
+
419  5,517,261,773,133,645,389,901,69,581,325,837,197,709,453,965,37,549,293,805,165,677,421,933,101,613,357,869,229,741,485,997,
+
420  21,533,277,789,149,661,405,917,85,597,341,853,213,725,469,981,53,565,309,821,181,693,437,949,117,629,373,885,245,757,501,1013,
+
421  13,525,269,781,141,653,397,909,77,589,333,845,205,717,461,973,45,557,301,813,173,685,429,941,109,621,365,877,237,749,493,1005,
+
422  29,541,285,797,157,669,413,925,93,605,349,861,221,733,477,989,61,573,317,829,189,701,445,957,125,637,381,893,253,765,509,1021,
+
423  3,515,259,771,131,643,387,899,67,579,323,835,195,707,451,963,35,547,291,803,163,675,419,931,99,611,355,867,227,739,483,995,
+
424  19,531,275,787,147,659,403,915,83,595,339,851,211,723,467,979,51,563,307,819,179,691,435,947,115,627,371,883,243,755,499,1011,
+
425  11,523,267,779,139,651,395,907,75,587,331,843,203,715,459,971,43,555,299,811,171,683,427,939,107,619,363,875,235,747,491,1003,
+
426  27,539,283,795,155,667,411,923,91,603,347,859,219,731,475,987,59,571,315,827,187,699,443,955,123,635,379,891,251,763,507,1019,
+
427  7,519,263,775,135,647,391,903,71,583,327,839,199,711,455,967,39,551,295,807,167,679,423,935,103,615,359,871,231,743,487,999,
+
428  23,535,279,791,151,663,407,919,87,599,343,855,215,727,471,983,55,567,311,823,183,695,439,951,119,631,375,887,247,759,503,1015,
+
429  15,527,271,783,143,655,399,911,79,591,335,847,207,719,463,975,47,559,303,815,175,687,431,943,111,623,367,879,239,751,495,1007,
+
430  31,543,287,799,159,671,415,927,95,607,351,863,223,735,479,991,63,575,319,831,191,703,447,959,127,639,383,895,255,767,511,1023
+
431 };
+
432 
+
433 /* Incomplete-reduction routines; for details on allowed input ranges
+
434  * and produced output ranges, see the description in the paper:
+
435  * https://cryptojedi.org/papers/#newhope */
+
436 
+
437 #define qinv 12287 // -inverse_mod(p,2^18)
+
438 #define rlog 18
+
439 
+
440 inline uint16_t montgomery_reduce(uint32_t a)
+
441 {
+
442  uint32_t u;
+
443 
+
444  u = (a * qinv);
+
445  u &= ((1<<rlog)-1);
+
446  u *= PARAM_Q;
+
447  a = a + u;
+
448  return a >> 18;
+
449 }
+
450 
+
451 inline uint16_t barrett_reduce(uint16_t a)
+
452 {
+
453  uint32_t u;
+
454 
+
455  u = ((uint32_t) a * 5) >> 16;
+
456  u *= PARAM_Q;
+
457  a -= u;
+
458  return a;
+
459 }
+
460 
+
461 static void bitrev_vector(uint16_t* poly)
+
462 {
+
463  unsigned int i,r;
+
464  uint16_t tmp;
+
465 
+
466  for(i = 0; i < PARAM_N; i++)
+
467  {
+
468  r = bitrev_table[i];
+
469  if (i < r)
+
470  {
+
471  tmp = poly[i];
+
472  poly[i] = poly[r];
+
473  poly[r] = tmp;
+
474  }
+
475  }
+
476 }
+
477 
+
478 static void mul_coefficients(uint16_t* poly, const uint16_t* factors)
+
479 {
+
480  unsigned int i;
+
481 
+
482  for(i = 0; i < PARAM_N; i++)
+
483  poly[i] = montgomery_reduce((poly[i] * factors[i]));
+
484 }
+
485 
+
486 /* GS_bo_to_no; omegas need to be in Montgomery domain */
+
487 static void ntt(uint16_t * a, const uint16_t* omega)
+
488 {
+
489  int i, start, j, jTwiddle, distance;
+
490  uint16_t temp, W;
+
491 
+
492 
+
493  for(i=0;i<10;i+=2)
+
494  {
+
495  // Even level
+
496  distance = (1<<i);
+
497  for(start = 0; start < distance;start++)
+
498  {
+
499  jTwiddle = 0;
+
500  for(j=start;j<PARAM_N-1;j+=2*distance)
+
501  {
+
502  W = omega[jTwiddle++];
+
503  temp = a[j];
+
504  a[j] = (temp + a[j + distance]); // Omit reduction (be lazy)
+
505  a[j + distance] = montgomery_reduce((W * ((uint32_t)temp + 3*PARAM_Q - a[j + distance])));
+
506  }
+
507  }
+
508 
+
509  // Odd level
+
510  distance <<= 1;
+
511  for(start = 0; start < distance;start++)
+
512  {
+
513  jTwiddle = 0;
+
514  for(j=start;j<PARAM_N-1;j+=2*distance)
+
515  {
+
516  W = omega[jTwiddle++];
+
517  temp = a[j];
+
518  a[j] = barrett_reduce((temp + a[j + distance]));
+
519  a[j + distance] = montgomery_reduce((W * ((uint32_t)temp + 3*PARAM_Q - a[j + distance])));
+
520  }
+
521  }
+
522  }
+
523 }
+
524 
+
525 static int32_t abs(int32_t v)
+
526 {
+
527  int32_t mask = v >> 31;
+
528  return (v ^ mask) - mask;
+
529 }
+
530 
+
531 static int32_t f(int32_t *v0, int32_t *v1, uint32_t x)
+
532 {
+
533  int32_t xit, t, r, b;
+
534 
+
535  // Next 6 lines compute t = x/PARAM_Q;
+
536  b = x*2730;
+
537  t = b >> 25;
+
538  b = x - t*12289;
+
539  b = 12288 - b;
+
540  b >>= 31;
+
541  t -= b;
+
542 
+
543  r = t & 1;
+
544  xit = (t>>1);
+
545  *v0 = xit+r; // v0 = round(x/(2*PARAM_Q))
+
546 
+
547  t -= 1;
+
548  r = t & 1;
+
549  *v1 = (t>>1)+r;
+
550 
+
551  return abs(x-((*v0)*2*PARAM_Q));
+
552 }
+
553 
+
554 static int32_t g(int32_t x)
+
555 {
+
556  int32_t t,c,b;
+
557 
+
558  // Next 6 lines compute t = x/(4*PARAM_Q);
+
559  b = x*2730;
+
560  t = b >> 27;
+
561  b = x - t*49156;
+
562  b = 49155 - b;
+
563  b >>= 31;
+
564  t -= b;
+
565 
+
566  c = t & 1;
+
567  t = (t >> 1) + c; // t = round(x/(8*PARAM_Q))
+
568 
+
569  t *= 8*PARAM_Q;
+
570 
+
571  return abs(t - x);
+
572 }
+
573 
+
574 static int16_t LDDecode(int32_t xi0, int32_t xi1, int32_t xi2, int32_t xi3)
+
575 {
+
576  int32_t t;
+
577 
+
578  t = g(xi0);
+
579  t += g(xi1);
+
580  t += g(xi2);
+
581  t += g(xi3);
+
582 
+
583  t -= 8*PARAM_Q;
+
584  t >>= 31;
+
585  return t&1;
+
586 }
+
587 
+
588 static void crypto_chacha20_set_key(uint32_t *block, const unsigned char *k, const unsigned char *n);
+
589 
+
590 static void helprec(uint16_t *c, const uint16_t *v, const unsigned char *seed, unsigned char nonce)
+
591 {
+
592  int32_t v0[4], v1[4], v_tmp[4], k;
+
593  unsigned char rbit;
+
594  unsigned char *rand;
+
595  unsigned char n[8];
+
596  uint32_t input[16];
+
597  uint32_t output[16];
+
598  int i;
+
599 
+
600  for(i=0;i<7;i++)
+
601  n[i] = 0;
+
602  n[7] = nonce;
+
603 
+
604  //crypto_stream_chacha20(rand,32,n,seed);
+
605  crypto_chacha20_set_key(input, seed, n);
+
606  ChaCha::hashCore(output, input, 20);
+
607  rand = (unsigned char *)output;
+
608 
+
609  for(i=0; i<256; i++)
+
610  {
+
611  rbit = (rand[i>>3] >> (i&7)) & 1;
+
612 
+
613  k = f(v0+0, v1+0, 8*v[ 0+i] + 4*rbit);
+
614  k += f(v0+1, v1+1, 8*v[256+i] + 4*rbit);
+
615  k += f(v0+2, v1+2, 8*v[512+i] + 4*rbit);
+
616  k += f(v0+3, v1+3, 8*v[768+i] + 4*rbit);
+
617 
+
618  k = (2*PARAM_Q-1-k) >> 31;
+
619 
+
620  v_tmp[0] = ((~k) & v0[0]) ^ (k & v1[0]);
+
621  v_tmp[1] = ((~k) & v0[1]) ^ (k & v1[1]);
+
622  v_tmp[2] = ((~k) & v0[2]) ^ (k & v1[2]);
+
623  v_tmp[3] = ((~k) & v0[3]) ^ (k & v1[3]);
+
624 
+
625  c[ 0+i] = (v_tmp[0] - v_tmp[3]) & 3;
+
626  c[256+i] = (v_tmp[1] - v_tmp[3]) & 3;
+
627  c[512+i] = (v_tmp[2] - v_tmp[3]) & 3;
+
628  c[768+i] = ( -k + 2*v_tmp[3]) & 3;
+
629  }
+
630 
+
631  clean(input);
+
632  clean(output);
+
633 }
+
634 
+
635 static void rec(unsigned char *key, const uint16_t *v, const uint16_t *c)
+
636 {
+
637  int i;
+
638  int32_t tmp[4];
+
639 
+
640  for(i=0;i<32;i++)
+
641  key[i] = 0;
+
642 
+
643  for(i=0; i<256; i++)
+
644  {
+
645  tmp[0] = 16*PARAM_Q + 8*(int32_t)v[ 0+i] - PARAM_Q * (2*c[ 0+i]+c[768+i]);
+
646  tmp[1] = 16*PARAM_Q + 8*(int32_t)v[256+i] - PARAM_Q * (2*c[256+i]+c[768+i]);
+
647  tmp[2] = 16*PARAM_Q + 8*(int32_t)v[512+i] - PARAM_Q * (2*c[512+i]+c[768+i]);
+
648  tmp[3] = 16*PARAM_Q + 8*(int32_t)v[768+i] - PARAM_Q * ( c[768+i]);
+
649 
+
650  key[i>>3] |= LDDecode(tmp[0], tmp[1], tmp[2], tmp[3]) << (i & 7);
+
651  }
+
652 }
+
653 
+
654 static void poly_frombytes(uint16_t *r, const unsigned char *a)
+
655 {
+
656  int i;
+
657  for(i=0;i<PARAM_N/4;i++)
+
658  {
+
659  r[4*i+0] = a[7*i+0] | (((uint16_t)a[7*i+1] & 0x3f) << 8);
+
660  r[4*i+1] = (a[7*i+1] >> 6) | (((uint16_t)a[7*i+2]) << 2) | (((uint16_t)a[7*i+3] & 0x0f) << 10);
+
661  r[4*i+2] = (a[7*i+3] >> 4) | (((uint16_t)a[7*i+4]) << 4) | (((uint16_t)a[7*i+5] & 0x03) << 12);
+
662  r[4*i+3] = (a[7*i+5] >> 2) | (((uint16_t)a[7*i+6]) << 6);
+
663  }
+
664 }
+
665 
+
666 static void poly_tobytes(unsigned char *r, const uint16_t *p)
+
667 {
+
668  int i;
+
669  uint16_t t0,t1,t2,t3,m;
+
670  int16_t c;
+
671  for(i=0;i<PARAM_N/4;i++)
+
672  {
+
673  t0 = barrett_reduce(p[4*i+0]); //Make sure that coefficients have only 14 bits
+
674  t1 = barrett_reduce(p[4*i+1]);
+
675  t2 = barrett_reduce(p[4*i+2]);
+
676  t3 = barrett_reduce(p[4*i+3]);
+
677 
+
678  m = t0 - PARAM_Q;
+
679  c = m;
+
680  c >>= 15;
+
681  t0 = m ^ ((t0^m)&c); // <Make sure that coefficients are in [0,q]
+
682 
+
683  m = t1 - PARAM_Q;
+
684  c = m;
+
685  c >>= 15;
+
686  t1 = m ^ ((t1^m)&c); // <Make sure that coefficients are in [0,q]
+
687 
+
688  m = t2 - PARAM_Q;
+
689  c = m;
+
690  c >>= 15;
+
691  t2 = m ^ ((t2^m)&c); // <Make sure that coefficients are in [0,q]
+
692 
+
693  m = t3 - PARAM_Q;
+
694  c = m;
+
695  c >>= 15;
+
696  t3 = m ^ ((t3^m)&c); // <Make sure that coefficients are in [0,q]
+
697 
+
698  r[7*i+0] = t0 & 0xff;
+
699  r[7*i+1] = (t0 >> 8) | (t1 << 6);
+
700  r[7*i+2] = (t1 >> 2);
+
701  r[7*i+3] = (t1 >> 10) | (t2 << 4);
+
702  r[7*i+4] = (t2 >> 4);
+
703  r[7*i+5] = (t2 >> 12) | (t3 << 2);
+
704  r[7*i+6] = (t3 >> 6);
+
705  }
+
706 }
+
707 
+
708 static void poly_pointwise(uint16_t *r, const uint16_t *a, const uint16_t *b)
+
709 {
+
710  int i;
+
711  uint16_t t;
+
712  for(i=0;i<PARAM_N;i++)
+
713  {
+
714  t = montgomery_reduce(3186*b[i]); /* t is now in Montgomery domain */
+
715  r[i] = montgomery_reduce(a[i] * t); /* r->coeffs[i] is back in normal domain */
+
716  }
+
717 }
+
718 
+
719 static void poly_add(uint16_t *r, const uint16_t *a, const uint16_t *b)
+
720 {
+
721  int i;
+
722  for(i=0;i<PARAM_N;i++)
+
723  r[i] = barrett_reduce(a[i] + b[i]);
+
724 }
+
725 
+
726 static void poly_ntt(uint16_t *r)
+
727 {
+
728  mul_coefficients(r, psis_bitrev_montgomery);
+
729  ntt(r, omegas_montgomery);
+
730 }
+
731 
+
732 static void poly_invntt(uint16_t *r)
+
733 {
+
734  bitrev_vector(r);
+
735  ntt(r, omegas_inv_montgomery);
+
736  mul_coefficients(r, psis_inv_montgomery);
+
737 }
+
738 
+
739 static void encode_a(unsigned char *r, const uint16_t *pk, const unsigned char *seed)
+
740 {
+
741  int i;
+
742  poly_tobytes(r, pk);
+
743  for(i=0;i<NEWHOPE_SEEDBYTES;i++)
+
744  r[POLY_BYTES+i] = seed[i];
+
745 }
+
746 
+
747 static void encode_b(unsigned char *r, const uint16_t *b, const uint16_t *c)
+
748 {
+
749  int i;
+
750  poly_tobytes(r,b);
+
751  for(i=0;i<PARAM_N/4;i++)
+
752  r[POLY_BYTES+i] = c[4*i] | (c[4*i+1] << 2) | (c[4*i+2] << 4) | (c[4*i+3] << 6);
+
753 }
+
754 
+
755 static void decode_b_2nd_half(uint16_t *c, const unsigned char *r)
+
756 {
+
757  int i;
+
758  for(i=0;i<PARAM_N/4;i++)
+
759  {
+
760  c[4*i+0] = r[POLY_BYTES+i] & 0x03;
+
761  c[4*i+1] = (r[POLY_BYTES+i] >> 2) & 0x03;
+
762  c[4*i+2] = (r[POLY_BYTES+i] >> 4) & 0x03;
+
763  c[4*i+3] = (r[POLY_BYTES+i] >> 6);
+
764  }
+
765 }
+
766 
+
767 #if NEWHOPE_TORREF
+
768 
+
769 #define _5q (5*PARAM_Q)
+
770 
+
771 #define compare_and_swap(x,i,j) \
+
772  c = _5q - 1 - x[16*(i)];\
+
773  c >>= 31;\
+
774  t = x[16*(i)] ^ x[16*(j)];\
+
775  t &= c;\
+
776  x[16*(i)] ^= t;\
+
777  x[16*(j)] ^= t;
+
778 
+
779 static void batcher84(uint16_t *x)
+
780 {
+
781  static uint8_t const swap_table[] = {
+
782  0, 1, 2, 3, 0, 2, 1, 3, 1, 2, 4, 5, 6, 7, 4, 6,
+
783  5, 7, 5, 6, 0, 4, 2, 6, 2, 4, 1, 5, 3, 7, 3, 5,
+
784  1, 2, 3, 4, 5, 6, 8, 9, 10, 11, 8, 10, 9, 11, 9, 10,
+
785  12, 13, 14, 15, 12, 14, 13, 15, 13, 14, 8, 12, 10, 14, 10, 12,
+
786  9, 13, 11, 15, 11, 13, 9, 10, 11, 12, 13, 14, 0, 8, 4, 12,
+
787  4, 8, 2, 10, 6, 14, 6, 10, 2, 4, 6, 8, 10, 12, 1, 9,
+
788  5, 13, 5, 9, 3, 11, 7, 15, 7, 11, 3, 5, 7, 9, 11, 13,
+
789  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 16, 17,
+
790  18, 19, 16, 18, 17, 19, 17, 18, 20, 21, 22, 23, 20, 22, 21, 23,
+
791  21, 22, 16, 20, 18, 22, 18, 20, 17, 21, 19, 23, 19, 21, 17, 18,
+
792  19, 20, 21, 22, 24, 25, 26, 27, 24, 26, 25, 27, 25, 26, 28, 29,
+
793  30, 31, 28, 30, 29, 31, 29, 30, 24, 28, 26, 30, 26, 28, 25, 29,
+
794  27, 31, 27, 29, 25, 26, 27, 28, 29, 30, 16, 24, 20, 28, 20, 24,
+
795  18, 26, 22, 30, 22, 26, 18, 20, 22, 24, 26, 28, 17, 25, 21, 29,
+
796  21, 25, 19, 27, 23, 31, 23, 27, 19, 21, 23, 25, 27, 29, 17, 18,
+
797  19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 16, 8, 24,
+
798  8, 16, 4, 20, 12, 28, 12, 20, 4, 8, 12, 16, 20, 24, 2, 18,
+
799  10, 26, 10, 18, 6, 22, 14, 30, 14, 22, 6, 10, 14, 18, 22, 26,
+
800  2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 1, 17,
+
801  9, 25, 9, 17, 5, 21, 13, 29, 13, 21, 5, 9, 13, 17, 21, 25,
+
802  3, 19, 11, 27, 11, 19, 7, 23, 15, 31, 15, 23, 7, 11, 15, 19,
+
803  23, 27, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29,
+
804  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+
805  17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 32, 33,
+
806  34, 35, 32, 34, 33, 35, 33, 34, 36, 37, 38, 39, 36, 38, 37, 39,
+
807  37, 38, 32, 36, 34, 38, 34, 36, 33, 37, 35, 39, 35, 37, 33, 34,
+
808  35, 36, 37, 38, 40, 41, 42, 43, 40, 42, 41, 43, 41, 42, 44, 45,
+
809  46, 47, 44, 46, 45, 47, 45, 46, 40, 44, 42, 46, 42, 44, 41, 45,
+
810  43, 47, 43, 45, 41, 42, 43, 44, 45, 46, 32, 40, 36, 44, 36, 40,
+
811  34, 42, 38, 46, 38, 42, 34, 36, 38, 40, 42, 44, 33, 41, 37, 45,
+
812  37, 41, 35, 43, 39, 47, 39, 43, 35, 37, 39, 41, 43, 45, 33, 34,
+
813  35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 48, 49, 50, 51,
+
814  48, 50, 49, 51, 49, 50, 52, 53, 54, 55, 52, 54, 53, 55, 53, 54,
+
815  48, 52, 50, 54, 50, 52, 49, 53, 51, 55, 51, 53, 49, 50, 51, 52,
+
816  53, 54, 56, 57, 58, 59, 56, 58, 57, 59, 57, 58, 60, 61, 62, 63,
+
817  60, 62, 61, 63, 61, 62, 56, 60, 58, 62, 58, 60, 57, 61, 59, 63,
+
818  59, 61, 57, 58, 59, 60, 61, 62, 48, 56, 52, 60, 52, 56, 50, 58,
+
819  54, 62, 54, 58, 50, 52, 54, 56, 58, 60, 49, 57, 53, 61, 53, 57,
+
820  51, 59, 55, 63, 55, 59, 51, 53, 55, 57, 59, 61, 49, 50, 51, 52,
+
821  53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 32, 48, 40, 56, 40, 48,
+
822  36, 52, 44, 60, 44, 52, 36, 40, 44, 48, 52, 56, 34, 50, 42, 58,
+
823  42, 50, 38, 54, 46, 62, 46, 54, 38, 42, 46, 50, 54, 58, 34, 36,
+
824  38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 33, 49, 41, 57,
+
825  41, 49, 37, 53, 45, 61, 45, 53, 37, 41, 45, 49, 53, 57, 35, 51,
+
826  43, 59, 43, 51, 39, 55, 47, 63, 47, 55, 39, 43, 47, 51, 55, 59,
+
827  35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 33, 34,
+
828  35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+
829  51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 0, 32, 16, 48,
+
830  16, 32, 8, 40, 24, 56, 24, 40, 8, 16, 24, 32, 40, 48, 4, 36,
+
831  20, 52, 20, 36, 12, 44, 28, 60, 28, 44, 12, 20, 28, 36, 44, 52,
+
832  4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 2, 34,
+
833  18, 50, 18, 34, 10, 42, 26, 58, 26, 42, 10, 18, 26, 34, 42, 50,
+
834  6, 38, 22, 54, 22, 38, 14, 46, 30, 62, 30, 46, 14, 22, 30, 38,
+
835  46, 54, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42, 46, 50, 54, 58,
+
836  2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32,
+
837  34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 1, 33,
+
838  17, 49, 17, 33, 9, 41, 25, 57, 25, 41, 9, 17, 25, 33, 41, 49,
+
839  5, 37, 21, 53, 21, 37, 13, 45, 29, 61, 29, 45, 13, 21, 29, 37,
+
840  45, 53, 5, 9, 13, 17, 21, 25, 29, 33, 37, 41, 45, 49, 53, 57,
+
841  3, 35, 19, 51, 19, 35, 11, 43, 27, 59, 27, 43, 11, 19, 27, 35,
+
842  43, 51, 7, 39, 23, 55, 23, 39, 15, 47, 31, 63, 31, 47, 15, 23,
+
843  31, 39, 47, 55, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51,
+
844  55, 59, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29,
+
845  31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61,
+
846  1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+
847  17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32,
+
848  33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
+
849  49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 64, 65,
+
850  66, 67, 64, 66, 65, 67, 65, 66, 68, 69, 70, 71, 68, 70, 69, 71,
+
851  69, 70, 64, 68, 66, 70, 66, 68, 65, 69, 67, 71, 67, 69, 65, 66,
+
852  67, 68, 69, 70, 72, 73, 74, 75, 72, 74, 73, 75, 73, 74, 76, 77,
+
853  78, 79, 76, 78, 77, 79, 77, 78, 72, 76, 74, 78, 74, 76, 73, 77,
+
854  75, 79, 75, 77, 73, 74, 75, 76, 77, 78, 64, 72, 68, 76, 68, 72,
+
855  66, 74, 70, 78, 70, 74, 66, 68, 70, 72, 74, 76, 65, 73, 69, 77,
+
856  69, 73, 67, 75, 71, 79, 71, 75, 67, 69, 71, 73, 75, 77, 65, 66,
+
857  67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 80, 81, 82, 83,
+
858  80, 82, 81, 83, 81, 82, 81, 82, 81, 82, 64, 80, 72, 80, 68, 72,
+
859  76, 80, 66, 82, 74, 82, 70, 74, 78, 82, 66, 68, 70, 72, 74, 76,
+
860  78, 80, 65, 81, 73, 81, 69, 73, 77, 81, 67, 83, 75, 83, 71, 75,
+
861  79, 83, 67, 69, 71, 73, 75, 77, 79, 81, 65, 66, 67, 68, 69, 70,
+
862  71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 72, 80, 68, 72,
+
863  76, 80, 74, 82, 70, 74, 78, 82, 66, 68, 70, 72, 74, 76, 78, 80,
+
864  73, 81, 69, 73, 77, 81, 75, 83, 71, 75, 79, 83, 67, 69, 71, 73,
+
865  75, 77, 79, 81, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
+
866  77, 78, 79, 80, 81, 82, 0, 64, 32, 64, 16, 80, 48, 80, 16, 32,
+
867  48, 64, 8, 72, 40, 72, 24, 40, 56, 72, 8, 16, 24, 32, 40, 48,
+
868  56, 64, 72, 80, 4, 68, 36, 68, 20, 36, 52, 68, 12, 76, 44, 76,
+
869  28, 44, 60, 76, 12, 20, 28, 36, 44, 52, 60, 68, 4, 8, 12, 16,
+
870  20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80,
+
871  2, 66, 34, 66, 18, 82, 50, 82, 18, 34, 50, 66, 10, 74, 42, 74,
+
872  26, 42, 58, 74, 10, 18, 26, 34, 42, 50, 58, 66, 74, 82, 6, 70,
+
873  38, 70, 22, 38, 54, 70, 14, 78, 46, 78, 30, 46, 62, 78, 14, 22,
+
874  30, 38, 46, 54, 62, 70, 6, 10, 14, 18, 22, 26, 30, 34, 38, 42,
+
875  46, 50, 54, 58, 62, 66, 70, 74, 78, 82, 2, 4, 6, 8, 10, 12,
+
876  14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44,
+
877  46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76,
+
878  78, 80, 1, 65, 33, 65, 17, 81, 49, 81, 17, 33, 49, 65, 9, 73,
+
879  41, 73, 25, 41, 57, 73, 9, 17, 25, 33, 41, 49, 57, 65, 73, 81,
+
880  5, 69, 37, 69, 21, 37, 53, 69, 13, 77, 45, 77, 29, 45, 61, 77,
+
881  13, 21, 29, 37, 45, 53, 61, 69, 5, 9, 13, 17, 21, 25, 29, 33,
+
882  37, 41, 45, 49, 53, 57, 61, 65, 69, 73, 77, 81, 3, 67, 35, 67,
+
883  19, 83, 51, 83, 19, 35, 51, 67, 11, 75, 43, 75, 27, 43, 59, 75,
+
884  11, 19, 27, 35, 43, 51, 59, 67, 75, 83, 7, 71, 39, 71, 23, 39,
+
885  55, 71, 15, 79, 47, 79, 31, 47, 63, 79, 15, 23, 31, 39, 47, 55,
+
886  63, 71, 7, 11, 15, 19, 23, 27, 31, 35, 39, 43, 47, 51, 55, 59,
+
887  63, 67, 71, 75, 79, 83, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21,
+
888  23, 25, 27, 29, 31, 33, 35, 37, 39, 41, 43, 45, 47, 49, 51, 53,
+
889  55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 1, 2,
+
890  3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
+
891  19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
+
892  35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
+
893  51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
+
894  67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82
+
895  };
+
896  unsigned index, i, j;
+
897  int32_t c;
+
898  uint16_t t;
+
899  for (index = 0; index < sizeof(swap_table); index += 2) {
+
900  i = swap_table[index];
+
901  j = swap_table[index + 1];
+
902  compare_and_swap(x, i, j);
+
903  }
+
904 }
+
905 
+
906 static int discardtopoly(uint16_t *x)
+
907 {
+
908  int32_t i, r=0;
+
909 
+
910  for(i=0;i<16;i++)
+
911  batcher84(x+i);
+
912 
+
913  // Check whether we're safe:
+
914  for(i=1008;i<1024;i++)
+
915  r |= 61444 - x[i];
+
916  if(r >>= 31) return -1;
+
917 
+
918  return 0;
+
919 }
+
920 
+
921 #endif // NEWHOPE_TORREF
+
922 
+
923 // End of public domain code imported from the C reference code.
+
924 
+
925 // Formats the ChaCha20 input block using a key and nonce.
+
926 static void crypto_chacha20_set_key(uint32_t *block, const unsigned char *k, const unsigned char *n)
+
927 {
+
928  static const char tag256[] = "expand 32-byte k";
+
929  memcpy(block, tag256, 16);
+
930  memcpy(block + 4, k, 32);
+
931  memset(block + 12, 0, 8);
+
932  if (n)
+
933  memcpy(block + 14, n, 8);
+
934  else
+
935  memset(block + 14, 0, 8);
+
936 }
+
937 
+
938 static void poly_uniform(uint16_t *a, const unsigned char *seed)
+
939 {
+
940  SHAKE128 shake;
+
941  int ctr = 0;
+
942  int posn = PARAM_N;
+
943  uint16_t val;
+
944 
+
945  // Absorb the seed material into the SHAKE128 object.
+
946  shake.update(seed, NEWHOPE_SEEDBYTES);
+
947 
+
948  while (ctr < PARAM_N) {
+
949  // Extract data from the SHAKE128 object directly into "a".
+
950  if (posn >= PARAM_N) {
+
951  shake.extend((uint8_t *)(a + ctr),
+
952  (PARAM_N - ctr) * sizeof(uint16_t));
+
953  posn = ctr;
+
954  }
+
955 
+
956  // Process as much of the data as we can, discarding values
+
957  // that are greater than or equal to 5 * PARAM_Q.
+
958  while (posn < PARAM_N) {
+
959  val = a[posn++];
+
960  if (val < (5 * PARAM_Q))
+
961  a[ctr++] = val;
+
962  }
+
963  }
+
964 }
+
965 
+
966 #if NEWHOPE_TORREF
+
967 
+
968 // Extended version of NewHopePoly that can hold the complete
+
969 // intermediate state for poly_uniform_torref(). This allows us
+
970 // to generate the polynomial in-place and save 2k of stack space.
+
971 class NewHopePolyExtended
+
972 {
+
973 public:
+
974  ~NewHopePolyExtended() { clean(coeffs); }
+
975 
+
976  uint16_t coeffs[84 * 16];
+
977 };
+
978 
+
979 static void poly_uniform_torref(uint16_t *a, const unsigned char *seed)
+
980 {
+
981  SHAKE128 shake;
+
982  shake.update(seed, 32);
+
983  do {
+
984  shake.extend((uint8_t *)a, 84 * 16 * sizeof(uint16_t));
+
985  } while (discardtopoly(a));
+
986 }
+
987 
+
988 #else // !NEWHOPE_TORREF
+
989 
+
990 typedef NewHopePoly NewHopePolyExtended;
+
991 
+
992 static void poly_uniform_torref(uint16_t *a, const unsigned char *seed)
+
993 {
+
994  poly_uniform(a, seed);
+
995 }
+
996 
+
997 #endif // NEWHOPE_TORREF
+
998 
+
999 static void poly_getnoise(uint16_t *r, unsigned char *seed, unsigned char nonce)
+
1000 {
+
1001  uint32_t input[16];
+
1002  uint32_t buf[16];
+
1003  int i, j;
+
1004  uint32_t a, b;
+
1005 
+
1006  // Note: The rest of this function assumes that we are running on a
+
1007  // little-endian CPU. Since we're generating random noise from a
+
1008  // random seed, it doesn't actually matter what the endian-ness is
+
1009  // as it will be just as random in both directions. It's only a
+
1010  // problem for verifying fixed test vectors.
+
1011 
+
1012  crypto_chacha20_set_key(input, seed, 0);
+
1013  input[14] = nonce; // Assumes little-endian.
+
1014 
+
1015  for (i = 0; i < PARAM_N; ++i) {
+
1016  // Generate a new block of random data if necessary.
+
1017  j = i % 16;
+
1018  if (j == 0) {
+
1019  ChaCha::hashCore(buf, input, 20);
+
1020  ++(input[12]); // Assumes little-endian.
+
1021  }
+
1022 
+
1023  // This is a slightly more efficient way to count bits than in
+
1024  // the reference C implementation. The technique is from:
+
1025  // https://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
+
1026  a = buf[j] & 0xFFFF; // Assumes little-endian.
+
1027  a = a - ((a >> 1) & 0x5555);
+
1028  a = (a & 0x3333) + ((a >> 2) & 0x3333);
+
1029  a = ((a >> 4) + a) & 0x0F0F;
+
1030  a = ((a >> 8) + a) & 0x00FF;
+
1031 
+
1032  b = (buf[j] >> 16) & 0xFFFF; // Assumes little-endian.
+
1033  b = b - ((b >> 1) & 0x5555);
+
1034  b = (b & 0x3333) + ((b >> 2) & 0x3333);
+
1035  b = ((b >> 4) + b) & 0x0F0F;
+
1036  b = ((b >> 8) + b) & 0x00FF;
+
1037 
+
1038  r[i] = a + PARAM_Q - b;
+
1039  }
+
1040 
+
1041  clean(input);
+
1042  clean(buf);
+
1043 }
+
1044 
+
1045 static void sha3256(unsigned char *output, const unsigned char *input, unsigned int inputByteLen)
+
1046 {
+
1047  SHA3_256 sha3;
+
1048  sha3.update(input, inputByteLen);
+
1049  sha3.finalize(output, 32);
+
1050 }
+
1051 
+ +
1058 {
+
1059 }
+
1060 
+ +
1065 {
+
1066  clean(coeffs);
+
1067 }
+
1068 
+ +
1073 {
+
1074  clean(coeffs);
+
1075 }
+
1076 
+
1111 void NewHope::keygen(uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk,
+
1112  Variant variant, const uint8_t *random_seed)
+
1113 {
+
1114  NewHopePolyExtended a;
+
1115  NewHopePoly pk;
+
1116  uint8_t seed[NEWHOPE_SEEDBYTES];
+
1117  uint8_t noiseseed[32];
+
1118 
+
1119  if (!random_seed) {
+
1120  RNG.rand(seed, NEWHOPE_SEEDBYTES);
+
1121  RNG.rand(noiseseed, 32);
+
1122  } else {
+
1123  memcpy(seed, random_seed, NEWHOPE_SEEDBYTES);
+
1124  memcpy(noiseseed, random_seed + NEWHOPE_SEEDBYTES, 32);
+
1125  }
+
1126  sha3256(seed, seed, NEWHOPE_SEEDBYTES);
+
1127 
+
1128  // The order of calls is rearranged compared to the reference C version.
+
1129  // This allows us to get away with two temporary poly objects (a, pk)
+
1130  // instead of four (a, e, r, pk). This saves 4k of stack space.
+
1131 
+
1132  if (variant == Ref)
+
1133  poly_uniform(a.coeffs, seed);
+
1134  else
+
1135  poly_uniform_torref(a.coeffs, seed);
+
1136 
+
1137  poly_getnoise(sk.coeffs, noiseseed, 0);
+
1138  poly_ntt(sk.coeffs);
+
1139 
+
1140  poly_pointwise(pk.coeffs, sk.coeffs, a.coeffs);
+
1141 
+
1142  poly_getnoise(a.coeffs, noiseseed, 1);
+
1143  poly_ntt(a.coeffs);
+
1144 
+
1145  poly_add(pk.coeffs, a.coeffs, pk.coeffs);
+
1146 
+
1147  encode_a(send, pk.coeffs, seed);
+
1148 
+
1149  clean(seed);
+
1150  clean(noiseseed);
+
1151 }
+
1152 
+
1170 void NewHope::sharedb(uint8_t shared_key[NEWHOPE_SHAREDBYTES],
+
1171  uint8_t send[NEWHOPE_SENDBBYTES],
+
1172  uint8_t received[NEWHOPE_SENDABYTES],
+
1173  Variant variant, const uint8_t *random_seed)
+
1174 {
+
1175  NewHopePolyExtended a;
+
1176  NewHopePoly v, bp;
+
1177  unsigned char noiseseed[32];
+
1178 
+
1179  if (!random_seed)
+
1180  RNG.rand(noiseseed, 32);
+
1181  else
+
1182  memcpy(noiseseed, random_seed, 32);
+
1183 
+
1184  // The order of calls is rearranged compared to the reference C version.
+
1185  // This allows us to get away with 3 temporary poly objects (v, a, bp)
+
1186  // instead of 8 (sp, ep, v, a, pka, c, epp, bp). Saves 10k of stack space.
+
1187 
+
1188  if (variant == Ref)
+
1189  poly_uniform(a.coeffs, received + POLY_BYTES);
+
1190  else
+
1191  poly_uniform_torref(a.coeffs, received + POLY_BYTES);
+
1192 
+
1193  poly_getnoise(v.coeffs, noiseseed, 0);
+
1194  poly_ntt(v.coeffs);
+
1195 
+
1196  poly_pointwise(bp.coeffs, a.coeffs, v.coeffs);
+
1197 
+
1198  poly_getnoise(a.coeffs, noiseseed, 1);
+
1199  poly_ntt(a.coeffs);
+
1200 
+
1201  poly_add(bp.coeffs, bp.coeffs, a.coeffs);
+
1202 
+
1203  poly_frombytes(a.coeffs, received);
+
1204 
+
1205  poly_pointwise(v.coeffs, a.coeffs, v.coeffs);
+
1206  poly_invntt(v.coeffs);
+
1207 
+
1208  poly_getnoise(a.coeffs, noiseseed, 2);
+
1209  poly_add(v.coeffs, v.coeffs, a.coeffs);
+
1210 
+
1211  helprec(a.coeffs, v.coeffs, noiseseed, 3);
+
1212 
+
1213  encode_b(send, bp.coeffs, a.coeffs);
+
1214 
+
1215  rec(shared_key, v.coeffs, a.coeffs);
+
1216 
+
1217  sha3256(shared_key, shared_key, 32);
+
1218 
+
1219  clean(noiseseed);
+
1220 }
+
1221 
+
1231 void NewHope::shareda(uint8_t shared_key[NEWHOPE_SHAREDBYTES],
+
1232  const NewHopePoly &sk,
+
1233  uint8_t received[NEWHOPE_SENDBBYTES])
+
1234 {
+
1235  NewHopePoly v, bp;
+
1236 
+
1237  // The order of calls is rearranged compared to the reference C version.
+
1238  // This allows us to get away with two temporary poly objects (v, bp)
+
1239  // instead of three (v, bp, c). This saves 2k of stack space.
+
1240 
+
1241  poly_frombytes(bp.coeffs, received);
+
1242 
+
1243  poly_pointwise(v.coeffs, sk.coeffs, bp.coeffs);
+
1244  poly_invntt(v.coeffs);
+
1245 
+
1246  decode_b_2nd_half(bp.coeffs, received);
+
1247 
+
1248  rec(shared_key, v.coeffs, bp.coeffs);
+
1249 
+
1250  sha3256(shared_key, shared_key, 32);
+
1251 }
+
~NewHopePoly()
Clears sensitive data and destroys this "poly" object.
Definition: NewHope.cpp:1064
+
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
+
Variant
Describes the variant of the New Hope algorithm to implement.
Definition: NewHope.h:55
+
SHAKE Extendable-Output Function (XOF) with 128-bit security.
Definition: SHAKE.h:52
+
static void keygen(uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk, Variant variant=Ref, const uint8_t *random_seed=0)
Generates the key pair for Alice in a New Hope key exchange.
Definition: NewHope.cpp:1111
+
void clear()
Clears sensitive data in this "poly" object.
Definition: NewHope.cpp:1072
+
static void sharedb(uint8_t shared_key[NEWHOPE_SHAREDBYTES], uint8_t send[NEWHOPE_SENDBBYTES], uint8_t received[NEWHOPE_SENDABYTES], Variant variant=Ref, const uint8_t *random_seed=0)
Generates the public key and shared secret for Bob.
Definition: NewHope.cpp:1170
+
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA3.cpp:71
+
NewHopePoly()
Constructs a new "poly" object for the NewHope algorithm.
Definition: NewHope.cpp:1057
+
NewHope polynomial representation.
Definition: NewHope.h:34
+
void update(const void *data, size_t len)
Updates the XOF with more data.
Definition: SHAKE.cpp:64
+
static void shareda(uint8_t shared_key[NEWHOPE_SHAREDBYTES], const NewHopePoly &sk, uint8_t received[NEWHOPE_SENDBBYTES])
Generates the shared secret for Alice.
Definition: NewHope.cpp:1231
+
static void hashCore(uint32_t *output, const uint32_t *input, uint8_t rounds)
Executes the ChaCha hash core on an input memory block.
Definition: ChaCha.cpp:253
+
SHA3-256 hash algorithm.
Definition: SHA3.h:29
+
The standard "reference" version of the New Hope algorithm.
Definition: NewHope.h:57
+
void extend(uint8_t *data, size_t len)
Generates extendable output from this XOF.
Definition: SHAKE.cpp:71
+
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA3.cpp:66
+
+ + + + diff --git a/NewHope_8h_source.html b/NewHope_8h_source.html new file mode 100644 index 00000000..054fb63d --- /dev/null +++ b/NewHope_8h_source.html @@ -0,0 +1,182 @@ + + + + + + +ArduinoLibs: NewHope.h Source File + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
+ + +
+ +
+ + +
+
+
+
NewHope.h
+
+
+
1 /*
+
2  * Copyright (C) 2016 Southern Storm Software, Pty Ltd.
+
3  *
+
4  * Permission is hereby granted, free of charge, to any person obtaining a
+
5  * copy of this software and associated documentation files (the "Software"),
+
6  * to deal in the Software without restriction, including without limitation
+
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+
8  * and/or sell copies of the Software, and to permit persons to whom the
+
9  * Software is furnished to do so, subject to the following conditions:
+
10  *
+
11  * The above copyright notice and this permission notice shall be included
+
12  * in all copies or substantial portions of the Software.
+
13  *
+
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+
15  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+
16  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+
17  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+
18  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+
19  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+
20  * DEALINGS IN THE SOFTWARE.
+
21  */
+
22 
+
23 #ifndef CRYPTO_NEWHOPE_h
+
24 #define CRYPTO_NEWHOPE_h
+
25 
+
26 #include <inttypes.h>
+
27 
+
28 #define NEWHOPE_SENDABYTES 1824
+
29 #define NEWHOPE_SENDBBYTES 2048
+
30 #define NEWHOPE_SHAREDBYTES 32
+
31 
+
32 class NewHope;
+
33 
+ +
35 {
+
36 public:
+
37  NewHopePoly();
+
38  ~NewHopePoly();
+
39 
+
40  void clear();
+
41 
+
42 private:
+
43  uint16_t coeffs[1024];
+
44 
+
45  friend class NewHope;
+
46 };
+
47 
+
48 class NewHope
+
49 {
+
50 private:
+
51  NewHope() {}
+
52  ~NewHope() {}
+
53 
+
54 public:
+
55  enum Variant
+
56  {
+
57  Ref,
+ +
59  };
+
60 
+
61  static void keygen(uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk,
+
62  Variant variant = Ref, const uint8_t *random_seed = 0);
+
63  static void sharedb(uint8_t shared_key[NEWHOPE_SHAREDBYTES],
+
64  uint8_t send[NEWHOPE_SENDBBYTES],
+
65  uint8_t received[NEWHOPE_SENDABYTES],
+
66  Variant variant = Ref, const uint8_t *random_seed = 0);
+
67  static void shareda(uint8_t shared_key[NEWHOPE_SHAREDBYTES],
+
68  const NewHopePoly &sk,
+
69  uint8_t received[NEWHOPE_SENDBBYTES]);
+
70 };
+
71 
+
72 #endif
+
The alternative "torref" version of the New Hope algorithm.
Definition: NewHope.h:58
+
~NewHopePoly()
Clears sensitive data and destroys this "poly" object.
Definition: NewHope.cpp:1064
+
Variant
Describes the variant of the New Hope algorithm to implement.
Definition: NewHope.h:55
+
NewHope post-quantum key exchange algorithm.
Definition: NewHope.h:48
+
static void keygen(uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk, Variant variant=Ref, const uint8_t *random_seed=0)
Generates the key pair for Alice in a New Hope key exchange.
Definition: NewHope.cpp:1111
+
void clear()
Clears sensitive data in this "poly" object.
Definition: NewHope.cpp:1072
+
static void sharedb(uint8_t shared_key[NEWHOPE_SHAREDBYTES], uint8_t send[NEWHOPE_SENDBBYTES], uint8_t received[NEWHOPE_SENDABYTES], Variant variant=Ref, const uint8_t *random_seed=0)
Generates the public key and shared secret for Bob.
Definition: NewHope.cpp:1170
+
NewHopePoly()
Constructs a new "poly" object for the NewHope algorithm.
Definition: NewHope.cpp:1057
+
NewHope polynomial representation.
Definition: NewHope.h:34
+
static void shareda(uint8_t shared_key[NEWHOPE_SHAREDBYTES], const NewHopePoly &sk, uint8_t received[NEWHOPE_SENDBBYTES])
Generates the shared secret for Alice.
Definition: NewHope.cpp:1231
+
The standard "reference" version of the New Hope algorithm.
Definition: NewHope.h:57
+
+ + + + diff --git a/NoiseSource_8cpp_source.html b/NoiseSource_8cpp_source.html index 50151cf4..c5a4fd8a 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 f53ac991..5d865d90 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 33964c3e..f5548d7a 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 9e17eb52..661297e7 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 6cedb99a..daca6861 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 350a9973..ed39b331 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/P521_8cpp_source.html b/P521_8cpp_source.html index a05f6df3..b938c501 100644 --- a/P521_8cpp_source.html +++ b/P521_8cpp_source.html @@ -116,1225 +116,1224 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
26 #include "SHA512.h"
27 #include "utility/LimbUtil.h"
28 #include <string.h>
-
29 #include <Arduino.h>
-
30 
-
49 // Number of limbs that are needed to represent a 521-bit number.
-
50 #define NUM_LIMBS_521BIT NUM_LIMBS_BITS(521)
-
51 
-
52 // Number of limbs that are needed to represent a 1042-bit number.
-
53 // To simply things we also require that this be twice the size of
-
54 // NUM_LIMB_521BIT which involves a little wastage at the high end
-
55 // of one extra limb for 8-bit and 32-bit limbs. There is no
-
56 // wastage for 16-bit limbs.
-
57 #define NUM_LIMBS_1042BIT (NUM_LIMBS_BITS(521) * 2)
-
58 
-
59 // The overhead of clean() calls in mul(), etc can add up to a lot of
-
60 // processing time. Only do such cleanups if strict mode has been enabled.
-
61 #if defined(P521_STRICT_CLEAN)
-
62 #define strict_clean(x) clean(x)
-
63 #else
-
64 #define strict_clean(x) do { ; } while (0)
-
65 #endif
-
66 
-
67 // Expand the partial 9-bit left over limb at the top of a 521-bit number.
-
68 #if BIGNUMBER_LIMB_8BIT
-
69 #define LIMB_PARTIAL(value) ((uint8_t)(value)), \
-
70  ((uint8_t)((value) >> 8))
-
71 #else
-
72 #define LIMB_PARTIAL(value) (value)
-
73 #endif
-
74 
-
77 // The group order "q" value from RFC 4754 and RFC 5903. This is the
-
78 // same as the "n" value from Appendix D.1.2.5 of NIST FIPS 186-4.
-
79 static limb_t const P521_q[NUM_LIMBS_521BIT] PROGMEM = {
-
80  LIMB(0x91386409), LIMB(0xbb6fb71e), LIMB(0x899c47ae), LIMB(0x3bb5c9b8),
-
81  LIMB(0xf709a5d0), LIMB(0x7fcc0148), LIMB(0xbf2f966b), LIMB(0x51868783),
-
82  LIMB(0xfffffffa), LIMB(0xffffffff), LIMB(0xffffffff), LIMB(0xffffffff),
-
83  LIMB(0xffffffff), LIMB(0xffffffff), LIMB(0xffffffff), LIMB(0xffffffff),
-
84  LIMB_PARTIAL(0x1ff)
-
85 };
-
86 
-
87 // The "b" value from Appendix D.1.2.5 of NIST FIPS 186-4.
-
88 static limb_t const P521_b[NUM_LIMBS_521BIT] PROGMEM = {
-
89  LIMB(0x6b503f00), LIMB(0xef451fd4), LIMB(0x3d2c34f1), LIMB(0x3573df88),
-
90  LIMB(0x3bb1bf07), LIMB(0x1652c0bd), LIMB(0xec7e937b), LIMB(0x56193951),
-
91  LIMB(0x8ef109e1), LIMB(0xb8b48991), LIMB(0x99b315f3), LIMB(0xa2da725b),
-
92  LIMB(0xb68540ee), LIMB(0x929a21a0), LIMB(0x8e1c9a1f), LIMB(0x953eb961),
-
93  LIMB_PARTIAL(0x051)
-
94 };
-
95 
-
96 // The "Gx" value from Appendix D.1.2.5 of NIST FIPS 186-4.
-
97 static limb_t const P521_Gx[NUM_LIMBS_521BIT] PROGMEM = {
-
98  LIMB(0xc2e5bd66), LIMB(0xf97e7e31), LIMB(0x856a429b), LIMB(0x3348b3c1),
-
99  LIMB(0xa2ffa8de), LIMB(0xfe1dc127), LIMB(0xefe75928), LIMB(0xa14b5e77),
-
100  LIMB(0x6b4d3dba), LIMB(0xf828af60), LIMB(0x053fb521), LIMB(0x9c648139),
-
101  LIMB(0x2395b442), LIMB(0x9e3ecb66), LIMB(0x0404e9cd), LIMB(0x858e06b7),
-
102  LIMB_PARTIAL(0x0c6)
-
103 };
-
104 
-
105 // The "Gy" value from Appendix D.1.2.5 of NIST FIPS 186-4.
-
106 static limb_t const P521_Gy[NUM_LIMBS_521BIT] PROGMEM = {
-
107  LIMB(0x9fd16650), LIMB(0x88be9476), LIMB(0xa272c240), LIMB(0x353c7086),
-
108  LIMB(0x3fad0761), LIMB(0xc550b901), LIMB(0x5ef42640), LIMB(0x97ee7299),
-
109  LIMB(0x273e662c), LIMB(0x17afbd17), LIMB(0x579b4468), LIMB(0x98f54449),
-
110  LIMB(0x2c7d1bd9), LIMB(0x5c8a5fb4), LIMB(0x9a3bc004), LIMB(0x39296a78),
-
111  LIMB_PARTIAL(0x118)
-
112 };
-
113 
-
136 bool P521::eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
-
137 {
-
138  limb_t x[NUM_LIMBS_521BIT];
-
139  limb_t y[NUM_LIMBS_521BIT];
-
140  bool ok;
-
141 
-
142  // Unpack the curve point from the parameters and validate it.
-
143  if (point) {
-
144  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, point, 66);
-
145  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, point + 66, 66);
-
146  ok = validate(x, y);
-
147  } else {
-
148  memcpy_P(x, P521_Gx, sizeof(x));
-
149  memcpy_P(y, P521_Gy, sizeof(y));
-
150  ok = true;
-
151  }
-
152 
-
153  // Evaluate the curve function.
-
154  evaluate(x, y, f);
-
155 
-
156  // Pack the answer into the result array.
-
157  BigNumberUtil::packBE(result, 66, x, NUM_LIMBS_521BIT);
-
158  BigNumberUtil::packBE(result + 66, 66, y, NUM_LIMBS_521BIT);
-
159 
-
160  // Clean up.
-
161  clean(x);
-
162  clean(y);
-
163  return ok;
-
164 }
-
165 
-
209 void P521::dh1(uint8_t k[132], uint8_t f[66])
-
210 {
-
211  generatePrivateKey(f);
-
212  derivePublicKey(k, f);
-
213 }
-
214 
-
230 bool P521::dh2(const uint8_t k[132], uint8_t f[66])
-
231 {
-
232  // Unpack the (x, y) point from k.
-
233  limb_t x[NUM_LIMBS_521BIT];
-
234  limb_t y[NUM_LIMBS_521BIT];
-
235  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, k, 66);
-
236  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, k + 66, 66);
-
237 
-
238  // Validate the curve point. We keep going to preserve the timing.
-
239  bool ok = validate(x, y);
-
240 
-
241  // Evaluate the curve function.
-
242  evaluate(x, y, f);
-
243 
-
244  // The secret key is the x component of the final value.
-
245  BigNumberUtil::packBE(f, 66, x, NUM_LIMBS_521BIT);
-
246 
-
247  // Clean up.
-
248  clean(x);
-
249  clean(y);
-
250  return ok;
-
251 }
-
252 
-
277 void P521::sign(uint8_t signature[132], const uint8_t privateKey[66],
-
278  const void *message, size_t len, Hash *hash)
-
279 {
-
280  uint8_t hm[66];
-
281  uint8_t k[66];
-
282  limb_t x[NUM_LIMBS_521BIT];
-
283  limb_t y[NUM_LIMBS_521BIT];
-
284  limb_t t[NUM_LIMBS_521BIT];
-
285  uint64_t count = 0;
-
286 
-
287  // Format the incoming message, hashing it if necessary.
-
288  if (hash) {
-
289  // Hash the message.
-
290  hash->reset();
-
291  hash->update(message, len);
-
292  len = hash->hashSize();
-
293  if (len > 64)
-
294  len = 64;
-
295  memset(hm, 0, 66 - len);
-
296  hash->finalize(hm + 66 - len, len);
-
297  } else {
-
298  // The message is the hash.
-
299  if (len > 64)
-
300  len = 64;
-
301  memset(hm, 0, 66 - len);
-
302  memcpy(hm + 66 - len, message, len);
-
303  }
-
304 
-
305  // Keep generating k values until both r and s are non-zero.
-
306  for (;;) {
-
307  // Generate the k value deterministically according to RFC 6979.
-
308  if (hash)
-
309  generateK(k, hm, privateKey, hash, count);
-
310  else
-
311  generateK(k, hm, privateKey, count);
-
312 
-
313  // Generate r = kG.x mod q.
-
314  memcpy_P(x, P521_Gx, sizeof(x));
-
315  memcpy_P(y, P521_Gy, sizeof(y));
-
316  evaluate(x, y, k);
-
317  BigNumberUtil::reduceQuick_P(x, x, P521_q, NUM_LIMBS_521BIT);
-
318  BigNumberUtil::packBE(signature, 66, x, NUM_LIMBS_521BIT);
-
319 
-
320  // If r is zero, then we need to generate a new k value.
-
321  // This is utterly improbable, but let's be safe anyway.
-
322  if (BigNumberUtil::isZero(x, NUM_LIMBS_521BIT)) {
-
323  ++count;
-
324  continue;
-
325  }
-
326 
-
327  // Generate s = (privateKey * r + hm) / k mod q.
-
328  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, privateKey, 66);
-
329  mulQ(y, y, x);
-
330  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, hm, 66);
-
331  BigNumberUtil::add(x, x, y, NUM_LIMBS_521BIT);
-
332  BigNumberUtil::reduceQuick_P(x, x, P521_q, NUM_LIMBS_521BIT);
-
333  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, k, 66);
-
334  recipQ(t, y);
-
335  mulQ(x, x, t);
-
336  BigNumberUtil::packBE(signature + 66, 66, x, NUM_LIMBS_521BIT);
-
337 
-
338  // Exit the loop if s is non-zero.
-
339  if (!BigNumberUtil::isZero(x, NUM_LIMBS_521BIT))
-
340  break;
-
341 
-
342  // We need to generate a new k value according to RFC 6979.
-
343  // This is utterly improbable, but let's be safe anyway.
-
344  ++count;
-
345  }
-
346 
-
347  // Clean up.
-
348  clean(hm);
-
349  clean(k);
-
350  clean(x);
-
351  clean(y);
-
352  clean(t);
-
353 }
-
354 
-
374 bool P521::verify(const uint8_t signature[132],
-
375  const uint8_t publicKey[132],
-
376  const void *message, size_t len, Hash *hash)
-
377 {
-
378  limb_t x[NUM_LIMBS_521BIT];
-
379  limb_t y[NUM_LIMBS_521BIT];
-
380  limb_t r[NUM_LIMBS_521BIT];
-
381  limb_t s[NUM_LIMBS_521BIT];
-
382  limb_t u1[NUM_LIMBS_521BIT];
-
383  limb_t u2[NUM_LIMBS_521BIT];
-
384  uint8_t t[66];
-
385  bool ok = false;
-
386 
-
387  // Because we are operating on public values, we don't need to
-
388  // be as strict about constant time. Bail out early if there
-
389  // is a problem with the parameters.
-
390 
-
391  // Unpack the signature. The values must be between 1 and q - 1.
-
392  BigNumberUtil::unpackBE(r, NUM_LIMBS_521BIT, signature, 66);
-
393  BigNumberUtil::unpackBE(s, NUM_LIMBS_521BIT, signature + 66, 66);
-
394  if (BigNumberUtil::isZero(r, NUM_LIMBS_521BIT) ||
-
395  BigNumberUtil::isZero(s, NUM_LIMBS_521BIT) ||
-
396  !BigNumberUtil::sub_P(x, r, P521_q, NUM_LIMBS_521BIT) ||
-
397  !BigNumberUtil::sub_P(x, s, P521_q, NUM_LIMBS_521BIT)) {
-
398  goto failed;
-
399  }
-
400 
-
401  // Unpack the public key and check that it is a valid curve point.
-
402  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, publicKey, 66);
-
403  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, publicKey + 66, 66);
-
404  if (!validate(x, y)) {
-
405  goto failed;
-
406  }
-
407 
-
408  // Hash the message to generate hm, which we store into u1.
-
409  if (hash) {
-
410  // Hash the message.
-
411  hash->reset();
-
412  hash->update(message, len);
-
413  len = hash->hashSize();
-
414  if (len > 64)
-
415  len = 64;
-
416  hash->finalize(u2, len);
-
417  BigNumberUtil::unpackBE(u1, NUM_LIMBS_521BIT, (uint8_t *)u2, len);
-
418  } else {
-
419  // The message is the hash.
-
420  if (len > 64)
-
421  len = 64;
-
422  BigNumberUtil::unpackBE(u1, NUM_LIMBS_521BIT, (uint8_t *)message, len);
-
423  }
-
424 
-
425  // Compute u1 = hm * s^-1 mod q and u2 = r * s^-1 mod q.
-
426  recipQ(u2, s);
-
427  mulQ(u1, u1, u2);
-
428  mulQ(u2, r, u2);
-
429 
-
430  // Compute the curve point R = u2 * publicKey + u1 * G.
-
431  BigNumberUtil::packBE(t, 66, u2, NUM_LIMBS_521BIT);
-
432  evaluate(x, y, t);
-
433  memcpy_P(u2, P521_Gx, sizeof(x));
-
434  memcpy_P(s, P521_Gy, sizeof(y));
-
435  BigNumberUtil::packBE(t, 66, u1, NUM_LIMBS_521BIT);
-
436  evaluate(u2, s, t);
-
437  addAffine(u2, s, x, y);
-
438 
-
439  // If R.x = r mod q, then the signature is valid.
-
440  BigNumberUtil::reduceQuick_P(u1, u2, P521_q, NUM_LIMBS_521BIT);
-
441  ok = secure_compare(u1, r, NUM_LIMBS_521BIT * sizeof(limb_t));
-
442 
-
443  // Clean up and exit.
-
444 failed:
-
445  clean(x);
-
446  clean(y);
-
447  clean(r);
-
448  clean(s);
-
449  clean(u1);
-
450  clean(u2);
-
451  clean(t);
-
452  return ok;
-
453 }
-
454 
-
467 void P521::generatePrivateKey(uint8_t privateKey[66])
-
468 {
-
469  // Generate a random 521-bit value for the private key. The value
-
470  // must be generated uniformly at random between 1 and q - 1 where q
-
471  // is the group order (RFC 6090). We use the recommended algorithm
-
472  // from Appendix B of RFC 6090: generate a random 521-bit value
-
473  // and discard it if it is not within the range 1 to q - 1.
-
474  limb_t x[NUM_LIMBS_521BIT];
-
475  do {
-
476  RNG.rand((uint8_t *)x, sizeof(x));
-
477 #if BIGNUMBER_LIMB_8BIT
-
478  x[NUM_LIMBS_521BIT - 1] &= 0x01;
-
479 #else
-
480  x[NUM_LIMBS_521BIT - 1] &= 0x1FF;
-
481 #endif
-
482  BigNumberUtil::packBE(privateKey, 66, x, NUM_LIMBS_521BIT);
-
483  } while (BigNumberUtil::isZero(x, NUM_LIMBS_521BIT) ||
-
484  !BigNumberUtil::sub_P(x, x, P521_q, NUM_LIMBS_521BIT));
-
485  clean(x);
-
486 }
-
487 
-
498 void P521::derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
-
499 {
-
500  // Evaluate the curve function starting with the generator.
-
501  limb_t x[NUM_LIMBS_521BIT];
-
502  limb_t y[NUM_LIMBS_521BIT];
-
503  memcpy_P(x, P521_Gx, sizeof(x));
-
504  memcpy_P(y, P521_Gy, sizeof(y));
-
505  evaluate(x, y, privateKey);
-
506 
-
507  // Pack the (x, y) point into the public key.
-
508  BigNumberUtil::packBE(publicKey, 66, x, NUM_LIMBS_521BIT);
-
509  BigNumberUtil::packBE(publicKey + 66, 66, y, NUM_LIMBS_521BIT);
-
510 
-
511  // Clean up.
-
512  clean(x);
-
513  clean(y);
-
514 }
-
515 
-
525 bool P521::isValidPrivateKey(const uint8_t privateKey[66])
-
526 {
-
527  // The value "q" as a byte array from most to least significant.
-
528  static uint8_t const P521_q_bytes[66] PROGMEM = {
-
529  0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+
29 
+
48 // Number of limbs that are needed to represent a 521-bit number.
+
49 #define NUM_LIMBS_521BIT NUM_LIMBS_BITS(521)
+
50 
+
51 // Number of limbs that are needed to represent a 1042-bit number.
+
52 // To simply things we also require that this be twice the size of
+
53 // NUM_LIMB_521BIT which involves a little wastage at the high end
+
54 // of one extra limb for 8-bit and 32-bit limbs. There is no
+
55 // wastage for 16-bit limbs.
+
56 #define NUM_LIMBS_1042BIT (NUM_LIMBS_BITS(521) * 2)
+
57 
+
58 // The overhead of clean() calls in mul(), etc can add up to a lot of
+
59 // processing time. Only do such cleanups if strict mode has been enabled.
+
60 #if defined(P521_STRICT_CLEAN)
+
61 #define strict_clean(x) clean(x)
+
62 #else
+
63 #define strict_clean(x) do { ; } while (0)
+
64 #endif
+
65 
+
66 // Expand the partial 9-bit left over limb at the top of a 521-bit number.
+
67 #if BIGNUMBER_LIMB_8BIT
+
68 #define LIMB_PARTIAL(value) ((uint8_t)(value)), \
+
69  ((uint8_t)((value) >> 8))
+
70 #else
+
71 #define LIMB_PARTIAL(value) (value)
+
72 #endif
+
73 
+
76 // The group order "q" value from RFC 4754 and RFC 5903. This is the
+
77 // same as the "n" value from Appendix D.1.2.5 of NIST FIPS 186-4.
+
78 static limb_t const P521_q[NUM_LIMBS_521BIT] PROGMEM = {
+
79  LIMB_PAIR(0x91386409, 0xbb6fb71e), LIMB_PAIR(0x899c47ae, 0x3bb5c9b8),
+
80  LIMB_PAIR(0xf709a5d0, 0x7fcc0148), LIMB_PAIR(0xbf2f966b, 0x51868783),
+
81  LIMB_PAIR(0xfffffffa, 0xffffffff), LIMB_PAIR(0xffffffff, 0xffffffff),
+
82  LIMB_PAIR(0xffffffff, 0xffffffff), LIMB_PAIR(0xffffffff, 0xffffffff),
+
83  LIMB_PARTIAL(0x1ff)
+
84 };
+
85 
+
86 // The "b" value from Appendix D.1.2.5 of NIST FIPS 186-4.
+
87 static limb_t const P521_b[NUM_LIMBS_521BIT] PROGMEM = {
+
88  LIMB_PAIR(0x6b503f00, 0xef451fd4), LIMB_PAIR(0x3d2c34f1, 0x3573df88),
+
89  LIMB_PAIR(0x3bb1bf07, 0x1652c0bd), LIMB_PAIR(0xec7e937b, 0x56193951),
+
90  LIMB_PAIR(0x8ef109e1, 0xb8b48991), LIMB_PAIR(0x99b315f3, 0xa2da725b),
+
91  LIMB_PAIR(0xb68540ee, 0x929a21a0), LIMB_PAIR(0x8e1c9a1f, 0x953eb961),
+
92  LIMB_PARTIAL(0x051)
+
93 };
+
94 
+
95 // The "Gx" value from Appendix D.1.2.5 of NIST FIPS 186-4.
+
96 static limb_t const P521_Gx[NUM_LIMBS_521BIT] PROGMEM = {
+
97  LIMB_PAIR(0xc2e5bd66, 0xf97e7e31), LIMB_PAIR(0x856a429b, 0x3348b3c1),
+
98  LIMB_PAIR(0xa2ffa8de, 0xfe1dc127), LIMB_PAIR(0xefe75928, 0xa14b5e77),
+
99  LIMB_PAIR(0x6b4d3dba, 0xf828af60), LIMB_PAIR(0x053fb521, 0x9c648139),
+
100  LIMB_PAIR(0x2395b442, 0x9e3ecb66), LIMB_PAIR(0x0404e9cd, 0x858e06b7),
+
101  LIMB_PARTIAL(0x0c6)
+
102 };
+
103 
+
104 // The "Gy" value from Appendix D.1.2.5 of NIST FIPS 186-4.
+
105 static limb_t const P521_Gy[NUM_LIMBS_521BIT] PROGMEM = {
+
106  LIMB_PAIR(0x9fd16650, 0x88be9476), LIMB_PAIR(0xa272c240, 0x353c7086),
+
107  LIMB_PAIR(0x3fad0761, 0xc550b901), LIMB_PAIR(0x5ef42640, 0x97ee7299),
+
108  LIMB_PAIR(0x273e662c, 0x17afbd17), LIMB_PAIR(0x579b4468, 0x98f54449),
+
109  LIMB_PAIR(0x2c7d1bd9, 0x5c8a5fb4), LIMB_PAIR(0x9a3bc004, 0x39296a78),
+
110  LIMB_PARTIAL(0x118)
+
111 };
+
112 
+
135 bool P521::eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
+
136 {
+
137  limb_t x[NUM_LIMBS_521BIT];
+
138  limb_t y[NUM_LIMBS_521BIT];
+
139  bool ok;
+
140 
+
141  // Unpack the curve point from the parameters and validate it.
+
142  if (point) {
+
143  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, point, 66);
+
144  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, point + 66, 66);
+
145  ok = validate(x, y);
+
146  } else {
+
147  memcpy_P(x, P521_Gx, sizeof(x));
+
148  memcpy_P(y, P521_Gy, sizeof(y));
+
149  ok = true;
+
150  }
+
151 
+
152  // Evaluate the curve function.
+
153  evaluate(x, y, f);
+
154 
+
155  // Pack the answer into the result array.
+
156  BigNumberUtil::packBE(result, 66, x, NUM_LIMBS_521BIT);
+
157  BigNumberUtil::packBE(result + 66, 66, y, NUM_LIMBS_521BIT);
+
158 
+
159  // Clean up.
+
160  clean(x);
+
161  clean(y);
+
162  return ok;
+
163 }
+
164 
+
208 void P521::dh1(uint8_t k[132], uint8_t f[66])
+
209 {
+
210  generatePrivateKey(f);
+
211  derivePublicKey(k, f);
+
212 }
+
213 
+
229 bool P521::dh2(const uint8_t k[132], uint8_t f[66])
+
230 {
+
231  // Unpack the (x, y) point from k.
+
232  limb_t x[NUM_LIMBS_521BIT];
+
233  limb_t y[NUM_LIMBS_521BIT];
+
234  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, k, 66);
+
235  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, k + 66, 66);
+
236 
+
237  // Validate the curve point. We keep going to preserve the timing.
+
238  bool ok = validate(x, y);
+
239 
+
240  // Evaluate the curve function.
+
241  evaluate(x, y, f);
+
242 
+
243  // The secret key is the x component of the final value.
+
244  BigNumberUtil::packBE(f, 66, x, NUM_LIMBS_521BIT);
+
245 
+
246  // Clean up.
+
247  clean(x);
+
248  clean(y);
+
249  return ok;
+
250 }
+
251 
+
276 void P521::sign(uint8_t signature[132], const uint8_t privateKey[66],
+
277  const void *message, size_t len, Hash *hash)
+
278 {
+
279  uint8_t hm[66];
+
280  uint8_t k[66];
+
281  limb_t x[NUM_LIMBS_521BIT];
+
282  limb_t y[NUM_LIMBS_521BIT];
+
283  limb_t t[NUM_LIMBS_521BIT];
+
284  uint64_t count = 0;
+
285 
+
286  // Format the incoming message, hashing it if necessary.
+
287  if (hash) {
+
288  // Hash the message.
+
289  hash->reset();
+
290  hash->update(message, len);
+
291  len = hash->hashSize();
+
292  if (len > 64)
+
293  len = 64;
+
294  memset(hm, 0, 66 - len);
+
295  hash->finalize(hm + 66 - len, len);
+
296  } else {
+
297  // The message is the hash.
+
298  if (len > 64)
+
299  len = 64;
+
300  memset(hm, 0, 66 - len);
+
301  memcpy(hm + 66 - len, message, len);
+
302  }
+
303 
+
304  // Keep generating k values until both r and s are non-zero.
+
305  for (;;) {
+
306  // Generate the k value deterministically according to RFC 6979.
+
307  if (hash)
+
308  generateK(k, hm, privateKey, hash, count);
+
309  else
+
310  generateK(k, hm, privateKey, count);
+
311 
+
312  // Generate r = kG.x mod q.
+
313  memcpy_P(x, P521_Gx, sizeof(x));
+
314  memcpy_P(y, P521_Gy, sizeof(y));
+
315  evaluate(x, y, k);
+
316  BigNumberUtil::reduceQuick_P(x, x, P521_q, NUM_LIMBS_521BIT);
+
317  BigNumberUtil::packBE(signature, 66, x, NUM_LIMBS_521BIT);
+
318 
+
319  // If r is zero, then we need to generate a new k value.
+
320  // This is utterly improbable, but let's be safe anyway.
+
321  if (BigNumberUtil::isZero(x, NUM_LIMBS_521BIT)) {
+
322  ++count;
+
323  continue;
+
324  }
+
325 
+
326  // Generate s = (privateKey * r + hm) / k mod q.
+
327  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, privateKey, 66);
+
328  mulQ(y, y, x);
+
329  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, hm, 66);
+
330  BigNumberUtil::add(x, x, y, NUM_LIMBS_521BIT);
+
331  BigNumberUtil::reduceQuick_P(x, x, P521_q, NUM_LIMBS_521BIT);
+
332  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, k, 66);
+
333  recipQ(t, y);
+
334  mulQ(x, x, t);
+
335  BigNumberUtil::packBE(signature + 66, 66, x, NUM_LIMBS_521BIT);
+
336 
+
337  // Exit the loop if s is non-zero.
+
338  if (!BigNumberUtil::isZero(x, NUM_LIMBS_521BIT))
+
339  break;
+
340 
+
341  // We need to generate a new k value according to RFC 6979.
+
342  // This is utterly improbable, but let's be safe anyway.
+
343  ++count;
+
344  }
+
345 
+
346  // Clean up.
+
347  clean(hm);
+
348  clean(k);
+
349  clean(x);
+
350  clean(y);
+
351  clean(t);
+
352 }
+
353 
+
373 bool P521::verify(const uint8_t signature[132],
+
374  const uint8_t publicKey[132],
+
375  const void *message, size_t len, Hash *hash)
+
376 {
+
377  limb_t x[NUM_LIMBS_521BIT];
+
378  limb_t y[NUM_LIMBS_521BIT];
+
379  limb_t r[NUM_LIMBS_521BIT];
+
380  limb_t s[NUM_LIMBS_521BIT];
+
381  limb_t u1[NUM_LIMBS_521BIT];
+
382  limb_t u2[NUM_LIMBS_521BIT];
+
383  uint8_t t[66];
+
384  bool ok = false;
+
385 
+
386  // Because we are operating on public values, we don't need to
+
387  // be as strict about constant time. Bail out early if there
+
388  // is a problem with the parameters.
+
389 
+
390  // Unpack the signature. The values must be between 1 and q - 1.
+
391  BigNumberUtil::unpackBE(r, NUM_LIMBS_521BIT, signature, 66);
+
392  BigNumberUtil::unpackBE(s, NUM_LIMBS_521BIT, signature + 66, 66);
+
393  if (BigNumberUtil::isZero(r, NUM_LIMBS_521BIT) ||
+
394  BigNumberUtil::isZero(s, NUM_LIMBS_521BIT) ||
+
395  !BigNumberUtil::sub_P(x, r, P521_q, NUM_LIMBS_521BIT) ||
+
396  !BigNumberUtil::sub_P(x, s, P521_q, NUM_LIMBS_521BIT)) {
+
397  goto failed;
+
398  }
+
399 
+
400  // Unpack the public key and check that it is a valid curve point.
+
401  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, publicKey, 66);
+
402  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, publicKey + 66, 66);
+
403  if (!validate(x, y)) {
+
404  goto failed;
+
405  }
+
406 
+
407  // Hash the message to generate hm, which we store into u1.
+
408  if (hash) {
+
409  // Hash the message.
+
410  hash->reset();
+
411  hash->update(message, len);
+
412  len = hash->hashSize();
+
413  if (len > 64)
+
414  len = 64;
+
415  hash->finalize(u2, len);
+
416  BigNumberUtil::unpackBE(u1, NUM_LIMBS_521BIT, (uint8_t *)u2, len);
+
417  } else {
+
418  // The message is the hash.
+
419  if (len > 64)
+
420  len = 64;
+
421  BigNumberUtil::unpackBE(u1, NUM_LIMBS_521BIT, (uint8_t *)message, len);
+
422  }
+
423 
+
424  // Compute u1 = hm * s^-1 mod q and u2 = r * s^-1 mod q.
+
425  recipQ(u2, s);
+
426  mulQ(u1, u1, u2);
+
427  mulQ(u2, r, u2);
+
428 
+
429  // Compute the curve point R = u2 * publicKey + u1 * G.
+
430  BigNumberUtil::packBE(t, 66, u2, NUM_LIMBS_521BIT);
+
431  evaluate(x, y, t);
+
432  memcpy_P(u2, P521_Gx, sizeof(x));
+
433  memcpy_P(s, P521_Gy, sizeof(y));
+
434  BigNumberUtil::packBE(t, 66, u1, NUM_LIMBS_521BIT);
+
435  evaluate(u2, s, t);
+
436  addAffine(u2, s, x, y);
+
437 
+
438  // If R.x = r mod q, then the signature is valid.
+
439  BigNumberUtil::reduceQuick_P(u1, u2, P521_q, NUM_LIMBS_521BIT);
+
440  ok = secure_compare(u1, r, NUM_LIMBS_521BIT * sizeof(limb_t));
+
441 
+
442  // Clean up and exit.
+
443 failed:
+
444  clean(x);
+
445  clean(y);
+
446  clean(r);
+
447  clean(s);
+
448  clean(u1);
+
449  clean(u2);
+
450  clean(t);
+
451  return ok;
+
452 }
+
453 
+
466 void P521::generatePrivateKey(uint8_t privateKey[66])
+
467 {
+
468  // Generate a random 521-bit value for the private key. The value
+
469  // must be generated uniformly at random between 1 and q - 1 where q
+
470  // is the group order (RFC 6090). We use the recommended algorithm
+
471  // from Appendix B of RFC 6090: generate a random 521-bit value
+
472  // and discard it if it is not within the range 1 to q - 1.
+
473  limb_t x[NUM_LIMBS_521BIT];
+
474  do {
+
475  RNG.rand((uint8_t *)x, sizeof(x));
+
476 #if BIGNUMBER_LIMB_8BIT
+
477  x[NUM_LIMBS_521BIT - 1] &= 0x01;
+
478 #else
+
479  x[NUM_LIMBS_521BIT - 1] &= 0x1FF;
+
480 #endif
+
481  BigNumberUtil::packBE(privateKey, 66, x, NUM_LIMBS_521BIT);
+
482  } while (BigNumberUtil::isZero(x, NUM_LIMBS_521BIT) ||
+
483  !BigNumberUtil::sub_P(x, x, P521_q, NUM_LIMBS_521BIT));
+
484  clean(x);
+
485 }
+
486 
+
497 void P521::derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
+
498 {
+
499  // Evaluate the curve function starting with the generator.
+
500  limb_t x[NUM_LIMBS_521BIT];
+
501  limb_t y[NUM_LIMBS_521BIT];
+
502  memcpy_P(x, P521_Gx, sizeof(x));
+
503  memcpy_P(y, P521_Gy, sizeof(y));
+
504  evaluate(x, y, privateKey);
+
505 
+
506  // Pack the (x, y) point into the public key.
+
507  BigNumberUtil::packBE(publicKey, 66, x, NUM_LIMBS_521BIT);
+
508  BigNumberUtil::packBE(publicKey + 66, 66, y, NUM_LIMBS_521BIT);
+
509 
+
510  // Clean up.
+
511  clean(x);
+
512  clean(y);
+
513 }
+
514 
+
524 bool P521::isValidPrivateKey(const uint8_t privateKey[66])
+
525 {
+
526  // The value "q" as a byte array from most to least significant.
+
527  static uint8_t const P521_q_bytes[66] PROGMEM = {
+
528  0x01, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+
529  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
530  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
531  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-
532  0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
-
533  0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F,
-
534  0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09,
-
535  0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C,
-
536  0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38,
-
537  0x64, 0x09
-
538  };
-
539  uint8_t zeroTest = 0;
-
540  uint8_t posn = 66;
-
541  uint16_t borrow = 0;
-
542  while (posn > 0) {
-
543  --posn;
-
544 
-
545  // Check for zero.
-
546  zeroTest |= privateKey[posn];
-
547 
-
548  // Subtract P521_q_bytes from the key. If there is no borrow,
-
549  // then the key value was greater than or equal to q.
-
550  borrow = ((uint16_t)(privateKey[posn])) -
-
551  pgm_read_byte(&(P521_q_bytes[posn])) -
-
552  ((borrow >> 8) & 0x01);
-
553  }
-
554  return zeroTest != 0 && borrow != 0;
-
555 }
-
556 
-
565 bool P521::isValidPublicKey(const uint8_t publicKey[132])
-
566 {
-
567  limb_t x[NUM_LIMBS_521BIT];
-
568  limb_t y[NUM_LIMBS_521BIT];
-
569  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, publicKey, 66);
-
570  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, publicKey + 66, 66);
-
571  bool ok = validate(x, y);
-
572  clean(x);
-
573  clean(y);
-
574  return ok;
-
575 }
-
576 
-
598 void P521::evaluate(limb_t *x, limb_t *y, const uint8_t f[66])
-
599 {
-
600  limb_t x1[NUM_LIMBS_521BIT];
-
601  limb_t y1[NUM_LIMBS_521BIT];
-
602  limb_t z1[NUM_LIMBS_521BIT];
-
603  limb_t x2[NUM_LIMBS_521BIT];
-
604  limb_t y2[NUM_LIMBS_521BIT];
-
605  limb_t z2[NUM_LIMBS_521BIT];
-
606 
-
607  // We want the input in Jacobian co-ordinates. The point (x, y, z)
-
608  // corresponds to the affine point (x / z^2, y / z^3), so if we set z
-
609  // to 1 we end up with Jacobian co-ordinates. Remember that z is 1
-
610  // and continue on.
-
611 
-
612  // Set the answer to the point-at-infinity initially (z = 0).
-
613  memset(x1, 0, sizeof(x1));
-
614  memset(y1, 0, sizeof(y1));
-
615  memset(z1, 0, sizeof(z1));
-
616 
-
617  // Special handling for the highest bit. We can skip dblPoint()/addPoint()
-
618  // and simply conditionally move (x, y, z) into (x1, y1, z1).
-
619  uint8_t select = (f[0] & 0x01);
-
620  cmove(select, x1, x);
-
621  cmove(select, y1, y);
-
622  cmove1(select, z1); // z = 1
-
623 
-
624  // Iterate over the remaining 520 bits of f from highest to lowest.
-
625  uint8_t mask = 0x80;
-
626  uint8_t fposn = 1;
-
627  for (uint16_t t = 520; t > 0; --t) {
-
628  // Double the answer.
-
629  dblPoint(x1, y1, z1, x1, y1, z1);
-
630 
-
631  // Add (x, y, z) to (x1, y1, z1) for the next 1 bit.
-
632  // We must always do this to preserve the overall timing.
-
633  // The z value is always 1 so we can omit that argument.
-
634  addPoint(x2, y2, z2, x1, y1, z1, x, y/*, z*/);
-
635 
-
636  // If the bit was 1, then move (x2, y2, z2) into (x1, y1, z1).
-
637  select = (f[fposn] & mask);
-
638  cmove(select, x1, x2);
-
639  cmove(select, y1, y2);
-
640  cmove(select, z1, z2);
-
641 
-
642  // Move onto the next bit.
-
643  mask >>= 1;
-
644  if (!mask) {
-
645  ++fposn;
-
646  mask = 0x80;
-
647  }
-
648  }
-
649 
-
650  // Convert from Jacobian co-ordinates back into affine co-ordinates.
-
651  // x = x1 * (z1^2)^-1, y = y1 * (z1^3)^-1.
-
652  recip(x2, z1);
-
653  square(y2, x2);
-
654  mul(x, x1, y2);
-
655  mul(y2, y2, x2);
-
656  mul(y, y1, y2);
-
657 
-
658  // Clean up.
-
659  clean(x1);
-
660  clean(y1);
-
661  clean(z1);
-
662  clean(x2);
-
663  clean(y2);
-
664  clean(z2);
-
665 }
-
666 
-
677 void P521::addAffine(limb_t *x1, limb_t *y1, const limb_t *x2, const limb_t *y2)
-
678 {
-
679  limb_t xout[NUM_LIMBS_521BIT];
-
680  limb_t yout[NUM_LIMBS_521BIT];
-
681  limb_t zout[NUM_LIMBS_521BIT];
-
682  limb_t z1[NUM_LIMBS_521BIT];
-
683 
-
684  // z1 = 1
-
685  z1[0] = 1;
-
686  memset(z1 + 1, 0, (NUM_LIMBS_521BIT - 1) * sizeof(limb_t));
-
687 
-
688  // Add the two points.
-
689  addPoint(xout, yout, zout, x1, y1, z1, x2, y2/*, z2*/);
-
690 
-
691  // Convert from Jacobian co-ordinates back into affine co-ordinates.
-
692  // x1 = xout * (zout^2)^-1, y1 = yout * (zout^3)^-1.
-
693  recip(z1, zout);
-
694  square(zout, z1);
-
695  mul(x1, xout, zout);
-
696  mul(zout, zout, z1);
-
697  mul(y1, yout, zout);
-
698 
-
699  // Clean up.
-
700  clean(xout);
-
701  clean(yout);
-
702  clean(zout);
-
703  clean(z1);
-
704 }
-
705 
-
715 bool P521::validate(const limb_t *x, const limb_t *y)
-
716 {
-
717  bool result;
-
718 
-
719  // If x or y is greater than or equal to 2^521 - 1, then the
-
720  // point is definitely not on the curve. Preserve timing by
-
721  // delaying the reporting of the result until later.
-
722  result = inRange(x);
-
723  result &= inRange(y);
-
724 
-
725  // We need to check that y^2 = x^3 - 3 * x + b mod 2^521 - 1.
-
726  limb_t t1[NUM_LIMBS_521BIT];
-
727  limb_t t2[NUM_LIMBS_521BIT];
-
728  square(t1, x);
-
729  mul(t1, t1, x);
-
730  mulLiteral(t2, x, 3);
-
731  sub(t1, t1, t2);
-
732  memcpy_P(t2, P521_b, sizeof(t2));
-
733  add(t1, t1, t2);
-
734  square(t2, y);
-
735  result &= secure_compare(t1, t2, sizeof(t1));
-
736  clean(t1);
-
737  clean(t2);
-
738  return result;
-
739 }
-
740 
-
749 bool P521::inRange(const limb_t *x)
-
750 {
-
751  // Do a trial subtraction of 2^521 - 1 from x, which is equivalent
-
752  // to adding 1 and subtracting 2^521. We only need the carry.
-
753  dlimb_t carry = 1;
-
754  limb_t word = 0;
-
755  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
756  carry += *x++;
-
757  word = (limb_t)carry;
-
758  carry >>= LIMB_BITS;
-
759  }
-
760 
-
761  // Determine the carry out from the low 521 bits.
-
762 #if BIGNUMBER_LIMB_8BIT
-
763  carry = (carry << 7) + (word >> 1);
-
764 #else
-
765  carry = (carry << (LIMB_BITS - 9)) + (word >> 9);
-
766 #endif
-
767 
-
768  // If the carry is zero, then x was in range. Otherwise it is out
-
769  // of range. Check for zero in a way that preserves constant timing.
-
770  word = (limb_t)(carry | (carry >> LIMB_BITS));
-
771  word = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - word) >> LIMB_BITS);
-
772  return (bool)word;
-
773 }
-
774 
-
784 void P521::reduce(limb_t *result, const limb_t *x)
-
785 {
-
786 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT
-
787  // According to NIST FIPS 186-4, we add the high 521 bits to the
-
788  // low 521 bits and then do a trial subtraction of 2^521 - 1.
-
789  // We do both in a single step. Subtracting 2^521 - 1 is equivalent
-
790  // to adding 1 and subtracting 2^521.
-
791  uint8_t index;
-
792  const limb_t *xl = x;
-
793  const limb_t *xh = x + NUM_LIMBS_521BIT;
-
794  limb_t *rr = result;
-
795  dlimb_t carry;
-
796  limb_t word = x[NUM_LIMBS_521BIT - 1];
-
797  carry = (word >> 9) + 1;
-
798  word &= 0x1FF;
-
799  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
-
800  carry += *xl++;
-
801  carry += ((dlimb_t)(*xh++)) << (LIMB_BITS - 9);
-
802  *rr++ = (limb_t)carry;
-
803  carry >>= LIMB_BITS;
-
804  }
-
805  carry += word;
-
806  carry += ((dlimb_t)(x[NUM_LIMBS_1042BIT - 1])) << (LIMB_BITS - 9);
-
807  word = (limb_t)carry;
-
808  *rr = word;
-
809 
-
810  // If the carry out was 1, then mask it off and we have the answer.
-
811  // If the carry out was 0, then we need to add 2^521 - 1 back again.
-
812  // To preserve the timing we perform a conditional subtract of 1 and
-
813  // then mask off the high bits.
-
814  carry = ((word >> 9) ^ 0x01) & 0x01;
-
815  rr = result;
-
816  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
817  carry = ((dlimb_t)(*rr)) - carry;
-
818  *rr++ = (limb_t)carry;
-
819  carry = (carry >> LIMB_BITS) & 0x01;
-
820  }
-
821  *(--rr) &= 0x1FF;
-
822 #elif BIGNUMBER_LIMB_8BIT
-
823  // Same as above, but for 8-bit limbs.
-
824  uint8_t index;
-
825  const limb_t *xl = x;
-
826  const limb_t *xh = x + NUM_LIMBS_521BIT;
-
827  limb_t *rr = result;
-
828  dlimb_t carry;
-
829  limb_t word = x[NUM_LIMBS_521BIT - 1];
-
830  carry = (word >> 1) + 1;
-
831  word &= 0x01;
-
832  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
-
833  carry += *xl++;
-
834  carry += ((dlimb_t)(*xh++)) << 7;
-
835  *rr++ = (limb_t)carry;
-
836  carry >>= LIMB_BITS;
-
837  }
-
838  carry += word;
-
839  carry += ((dlimb_t)(x[NUM_LIMBS_1042BIT - 1])) << 1;
-
840  word = (limb_t)carry;
-
841  *rr = word;
-
842  carry = ((word >> 1) ^ 0x01) & 0x01;
-
843  rr = result;
-
844  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
845  carry = ((dlimb_t)(*rr)) - carry;
-
846  *rr++ = (limb_t)carry;
-
847  carry = (carry >> LIMB_BITS) & 0x01;
-
848  }
-
849  *(--rr) &= 0x01;
-
850 #else
-
851  #error "Don't know how to reduce values mod 2^521 - 1"
-
852 #endif
-
853 }
-
854 
-
867 void P521::reduceQuick(limb_t *x)
-
868 {
-
869  // Perform a trial subtraction of 2^521 - 1 from x. This is
-
870  // equivalent to adding 1 and subtracting 2^521 - 1.
-
871  uint8_t index;
-
872  limb_t *xx = x;
-
873  dlimb_t carry = 1;
-
874  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
875  carry += *xx;
-
876  *xx++ = (limb_t)carry;
-
877  carry >>= LIMB_BITS;
-
878  }
-
879 
-
880  // If the carry out was 1, then mask it off and we have the answer.
-
881  // If the carry out was 0, then we need to add 2^521 - 1 back again.
-
882  // To preserve the timing we perform a conditional subtract of 1 and
-
883  // then mask off the high bits.
-
884 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT
-
885  carry = ((x[NUM_LIMBS_521BIT - 1] >> 9) ^ 0x01) & 0x01;
-
886  xx = x;
-
887  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
888  carry = ((dlimb_t)(*xx)) - carry;
-
889  *xx++ = (limb_t)carry;
-
890  carry = (carry >> LIMB_BITS) & 0x01;
-
891  }
-
892  *(--xx) &= 0x1FF;
-
893 #elif BIGNUMBER_LIMB_8BIT
-
894  carry = ((x[NUM_LIMBS_521BIT - 1] >> 1) ^ 0x01) & 0x01;
-
895  xx = x;
-
896  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
897  carry = ((dlimb_t)(*xx)) - carry;
-
898  *xx++ = (limb_t)carry;
-
899  carry = (carry >> LIMB_BITS) & 0x01;
-
900  }
-
901  *(--xx) &= 0x01;
-
902 #endif
-
903 }
-
904 
-
917 void P521::mulNoReduce(limb_t *result, const limb_t *x, const limb_t *y)
-
918 {
-
919  uint8_t i, j;
-
920  dlimb_t carry;
-
921  limb_t word;
-
922  const limb_t *yy;
-
923  limb_t *rr;
-
924 
-
925  // Multiply the lowest word of x by y.
-
926  carry = 0;
-
927  word = x[0];
-
928  yy = y;
-
929  rr = result;
-
930  for (i = 0; i < NUM_LIMBS_521BIT; ++i) {
-
931  carry += ((dlimb_t)(*yy++)) * word;
-
932  *rr++ = (limb_t)carry;
-
933  carry >>= LIMB_BITS;
-
934  }
-
935  *rr = (limb_t)carry;
-
936 
-
937  // Multiply and add the remaining words of x by y.
-
938  for (i = 1; i < NUM_LIMBS_521BIT; ++i) {
-
939  word = x[i];
-
940  carry = 0;
-
941  yy = y;
-
942  rr = result + i;
-
943  for (j = 0; j < NUM_LIMBS_521BIT; ++j) {
-
944  carry += ((dlimb_t)(*yy++)) * word;
-
945  carry += *rr;
-
946  *rr++ = (limb_t)carry;
-
947  carry >>= LIMB_BITS;
-
948  }
-
949  *rr = (limb_t)carry;
-
950  }
-
951 }
-
952 
-
963 void P521::mul(limb_t *result, const limb_t *x, const limb_t *y)
-
964 {
-
965  limb_t temp[NUM_LIMBS_1042BIT];
-
966  mulNoReduce(temp, x, y);
-
967  reduce(result, temp);
-
968  strict_clean(temp);
-
969 }
-
970 
-
990 void P521::mulLiteral(limb_t *result, const limb_t *x, limb_t y)
-
991 {
-
992  uint8_t index;
-
993  dlimb_t carry = 0;
-
994  const limb_t *xx = x;
-
995  limb_t *rr = result;
-
996 
-
997  // Multiply x by the literal and put it into the result array.
-
998  // We assume that y is small enough that overflow from the
-
999  // highest limb will not occur during this process.
-
1000  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
1001  carry += ((dlimb_t)(*xx++)) * y;
-
1002  *rr++ = (limb_t)carry;
-
1003  carry >>= LIMB_BITS;
-
1004  }
-
1005 
-
1006  // Reduce the value modulo 2^521 - 1. The high half is only a
-
1007  // single limb, so we can short-cut some of reduce() here.
-
1008 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT
-
1009  limb_t word = result[NUM_LIMBS_521BIT - 1];
-
1010  carry = (word >> 9) + 1;
-
1011  word &= 0x1FF;
-
1012  rr = result;
-
1013  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
-
1014  carry += *rr;
-
1015  *rr++ = (limb_t)carry;
-
1016  carry >>= LIMB_BITS;
-
1017  }
-
1018  carry += word;
-
1019  word = (limb_t)carry;
-
1020  *rr = word;
-
1021 
-
1022  // If the carry out was 1, then mask it off and we have the answer.
-
1023  // If the carry out was 0, then we need to add 2^521 - 1 back again.
-
1024  // To preserve the timing we perform a conditional subtract of 1 and
-
1025  // then mask off the high bits.
-
1026  carry = ((word >> 9) ^ 0x01) & 0x01;
-
1027  rr = result;
-
1028  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
1029  carry = ((dlimb_t)(*rr)) - carry;
-
1030  *rr++ = (limb_t)carry;
-
1031  carry = (carry >> LIMB_BITS) & 0x01;
-
1032  }
-
1033  *(--rr) &= 0x1FF;
-
1034 #elif BIGNUMBER_LIMB_8BIT
-
1035  // Same as above, but for 8-bit limbs.
-
1036  limb_t word = result[NUM_LIMBS_521BIT - 1];
-
1037  carry = (word >> 1) + 1;
-
1038  word &= 0x01;
-
1039  rr = result;
-
1040  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
-
1041  carry += *rr;
-
1042  *rr++ = (limb_t)carry;
-
1043  carry >>= LIMB_BITS;
-
1044  }
-
1045  carry += word;
-
1046  word = (limb_t)carry;
-
1047  *rr = word;
-
1048  carry = ((word >> 1) ^ 0x01) & 0x01;
-
1049  rr = result;
-
1050  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
1051  carry = ((dlimb_t)(*rr)) - carry;
-
1052  *rr++ = (limb_t)carry;
-
1053  carry = (carry >> LIMB_BITS) & 0x01;
-
1054  }
-
1055  *(--rr) &= 0x01;
-
1056 #endif
-
1057 }
-
1058 
-
1069 void P521::add(limb_t *result, const limb_t *x, const limb_t *y)
-
1070 {
-
1071  dlimb_t carry = 0;
-
1072  limb_t *rr = result;
-
1073  for (uint8_t posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
-
1074  carry += *x++;
-
1075  carry += *y++;
-
1076  *rr++ = (limb_t)carry;
-
1077  carry >>= LIMB_BITS;
-
1078  }
-
1079  reduceQuick(result);
-
1080 }
-
1081 
-
1092 void P521::sub(limb_t *result, const limb_t *x, const limb_t *y)
-
1093 {
-
1094  dlimb_t borrow;
-
1095  uint8_t posn;
-
1096  limb_t *rr = result;
-
1097 
-
1098  // Subtract y from x to generate the intermediate result.
-
1099  borrow = 0;
-
1100  for (posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
-
1101  borrow = ((dlimb_t)(*x++)) - (*y++) - ((borrow >> LIMB_BITS) & 0x01);
-
1102  *rr++ = (limb_t)borrow;
-
1103  }
-
1104 
-
1105  // If we had a borrow, then the result has gone negative and we
-
1106  // have to add 2^521 - 1 to the result to make it positive again.
-
1107  // The top bits of "borrow" will be all 1's if there is a borrow
-
1108  // or it will be all 0's if there was no borrow. Easiest is to
-
1109  // conditionally subtract 1 and then mask off the high bits.
-
1110  rr = result;
-
1111  borrow = (borrow >> LIMB_BITS) & 1U;
-
1112  borrow = ((dlimb_t)(*rr)) - borrow;
-
1113  *rr++ = (limb_t)borrow;
-
1114  for (posn = 1; posn < NUM_LIMBS_521BIT; ++posn) {
-
1115  borrow = ((dlimb_t)(*rr)) - ((borrow >> LIMB_BITS) & 0x01);
-
1116  *rr++ = (limb_t)borrow;
-
1117  }
-
1118 #if BIGNUMBER_LIMB_8BIT
-
1119  *(--rr) &= 0x01;
-
1120 #else
-
1121  *(--rr) &= 0x1FF;
-
1122 #endif
-
1123 }
-
1124 
-
1140 void P521::dblPoint(limb_t *xout, limb_t *yout, limb_t *zout,
-
1141  const limb_t *xin, const limb_t *yin,
-
1142  const limb_t *zin)
-
1143 {
-
1144  limb_t alpha[NUM_LIMBS_521BIT];
-
1145  limb_t beta[NUM_LIMBS_521BIT];
-
1146  limb_t gamma[NUM_LIMBS_521BIT];
-
1147  limb_t delta[NUM_LIMBS_521BIT];
-
1148  limb_t tmp[NUM_LIMBS_521BIT];
-
1149 
-
1150  // Double the point. If it is the point at infinity (z = 0),
-
1151  // then zout will still be zero at the end of this process so
-
1152  // we don't need any special handling for that case.
-
1153  square(delta, zin); // delta = z^2
-
1154  square(gamma, yin); // gamma = y^2
-
1155  mul(beta, xin, gamma); // beta = x * gamma
-
1156  sub(tmp, xin, delta); // alpha = 3 * (x - delta) * (x + delta)
-
1157  mulLiteral(alpha, tmp, 3);
-
1158  add(tmp, xin, delta);
-
1159  mul(alpha, alpha, tmp);
-
1160  square(xout, alpha); // xout = alpha^2 - 8 * beta
-
1161  mulLiteral(tmp, beta, 8);
-
1162  sub(xout, xout, tmp);
-
1163  add(zout, yin, zin); // zout = (y + z)^2 - gamma - delta
-
1164  square(zout, zout);
-
1165  sub(zout, zout, gamma);
-
1166  sub(zout, zout, delta);
-
1167  mulLiteral(yout, beta, 4);// yout = alpha * (4 * beta - xout) - 8 * gamma^2
-
1168  sub(yout, yout, xout);
-
1169  mul(yout, alpha, yout);
-
1170  square(gamma, gamma);
-
1171  mulLiteral(gamma, gamma, 8);
-
1172  sub(yout, yout, gamma);
-
1173 
-
1174  // Clean up.
-
1175  strict_clean(alpha);
-
1176  strict_clean(beta);
-
1177  strict_clean(gamma);
-
1178  strict_clean(delta);
-
1179  strict_clean(tmp);
-
1180 }
-
1181 
-
1201 void P521::addPoint(limb_t *xout, limb_t *yout, limb_t *zout,
-
1202  const limb_t *x1, const limb_t *y1,
-
1203  const limb_t *z1, const limb_t *x2,
-
1204  const limb_t *y2)
-
1205 {
-
1206  limb_t z1z1[NUM_LIMBS_521BIT];
-
1207  limb_t u2[NUM_LIMBS_521BIT];
-
1208  limb_t s2[NUM_LIMBS_521BIT];
-
1209  limb_t h[NUM_LIMBS_521BIT];
-
1210  limb_t i[NUM_LIMBS_521BIT];
-
1211  limb_t j[NUM_LIMBS_521BIT];
-
1212  limb_t r[NUM_LIMBS_521BIT];
-
1213  limb_t v[NUM_LIMBS_521BIT];
-
1214 
-
1215  // Determine if the first value is the point-at-infinity identity element.
-
1216  // The second z value is always 1 so it cannot be the point-at-infinity.
-
1217  limb_t p1IsIdentity = BigNumberUtil::isZero(z1, NUM_LIMBS_521BIT);
-
1218 
-
1219  // Multiply the points, assuming that z2 = 1.
-
1220  square(z1z1, z1); // z1z1 = z1^2
-
1221  mul(u2, x2, z1z1); // u2 = x2 * z1z1
-
1222  mul(s2, y2, z1); // s2 = y2 * z1 * z1z1
-
1223  mul(s2, s2, z1z1);
-
1224  sub(h, u2, x1); // h = u2 - x1
-
1225  mulLiteral(i, h, 2); // i = (2 * h)^2
-
1226  square(i, i);
-
1227  sub(r, s2, y1); // r = 2 * (s2 - y1)
-
1228  add(r, r, r);
-
1229  mul(j, h, i); // j = h * i
-
1230  mul(v, x1, i); // v = x1 * i
-
1231  square(xout, r); // xout = r^2 - j - 2 * v
-
1232  sub(xout, xout, j);
+
532  0xFF, 0xFA, 0x51, 0x86, 0x87, 0x83, 0xBF, 0x2F,
+
533  0x96, 0x6B, 0x7F, 0xCC, 0x01, 0x48, 0xF7, 0x09,
+
534  0xA5, 0xD0, 0x3B, 0xB5, 0xC9, 0xB8, 0x89, 0x9C,
+
535  0x47, 0xAE, 0xBB, 0x6F, 0xB7, 0x1E, 0x91, 0x38,
+
536  0x64, 0x09
+
537  };
+
538  uint8_t zeroTest = 0;
+
539  uint8_t posn = 66;
+
540  uint16_t borrow = 0;
+
541  while (posn > 0) {
+
542  --posn;
+
543 
+
544  // Check for zero.
+
545  zeroTest |= privateKey[posn];
+
546 
+
547  // Subtract P521_q_bytes from the key. If there is no borrow,
+
548  // then the key value was greater than or equal to q.
+
549  borrow = ((uint16_t)(privateKey[posn])) -
+
550  pgm_read_byte(&(P521_q_bytes[posn])) -
+
551  ((borrow >> 8) & 0x01);
+
552  }
+
553  return zeroTest != 0 && borrow != 0;
+
554 }
+
555 
+
564 bool P521::isValidPublicKey(const uint8_t publicKey[132])
+
565 {
+
566  limb_t x[NUM_LIMBS_521BIT];
+
567  limb_t y[NUM_LIMBS_521BIT];
+
568  BigNumberUtil::unpackBE(x, NUM_LIMBS_521BIT, publicKey, 66);
+
569  BigNumberUtil::unpackBE(y, NUM_LIMBS_521BIT, publicKey + 66, 66);
+
570  bool ok = validate(x, y);
+
571  clean(x);
+
572  clean(y);
+
573  return ok;
+
574 }
+
575 
+
597 void P521::evaluate(limb_t *x, limb_t *y, const uint8_t f[66])
+
598 {
+
599  limb_t x1[NUM_LIMBS_521BIT];
+
600  limb_t y1[NUM_LIMBS_521BIT];
+
601  limb_t z1[NUM_LIMBS_521BIT];
+
602  limb_t x2[NUM_LIMBS_521BIT];
+
603  limb_t y2[NUM_LIMBS_521BIT];
+
604  limb_t z2[NUM_LIMBS_521BIT];
+
605 
+
606  // We want the input in Jacobian co-ordinates. The point (x, y, z)
+
607  // corresponds to the affine point (x / z^2, y / z^3), so if we set z
+
608  // to 1 we end up with Jacobian co-ordinates. Remember that z is 1
+
609  // and continue on.
+
610 
+
611  // Set the answer to the point-at-infinity initially (z = 0).
+
612  memset(x1, 0, sizeof(x1));
+
613  memset(y1, 0, sizeof(y1));
+
614  memset(z1, 0, sizeof(z1));
+
615 
+
616  // Special handling for the highest bit. We can skip dblPoint()/addPoint()
+
617  // and simply conditionally move (x, y, z) into (x1, y1, z1).
+
618  uint8_t select = (f[0] & 0x01);
+
619  cmove(select, x1, x);
+
620  cmove(select, y1, y);
+
621  cmove1(select, z1); // z = 1
+
622 
+
623  // Iterate over the remaining 520 bits of f from highest to lowest.
+
624  uint8_t mask = 0x80;
+
625  uint8_t fposn = 1;
+
626  for (uint16_t t = 520; t > 0; --t) {
+
627  // Double the answer.
+
628  dblPoint(x1, y1, z1, x1, y1, z1);
+
629 
+
630  // Add (x, y, z) to (x1, y1, z1) for the next 1 bit.
+
631  // We must always do this to preserve the overall timing.
+
632  // The z value is always 1 so we can omit that argument.
+
633  addPoint(x2, y2, z2, x1, y1, z1, x, y/*, z*/);
+
634 
+
635  // If the bit was 1, then move (x2, y2, z2) into (x1, y1, z1).
+
636  select = (f[fposn] & mask);
+
637  cmove(select, x1, x2);
+
638  cmove(select, y1, y2);
+
639  cmove(select, z1, z2);
+
640 
+
641  // Move onto the next bit.
+
642  mask >>= 1;
+
643  if (!mask) {
+
644  ++fposn;
+
645  mask = 0x80;
+
646  }
+
647  }
+
648 
+
649  // Convert from Jacobian co-ordinates back into affine co-ordinates.
+
650  // x = x1 * (z1^2)^-1, y = y1 * (z1^3)^-1.
+
651  recip(x2, z1);
+
652  square(y2, x2);
+
653  mul(x, x1, y2);
+
654  mul(y2, y2, x2);
+
655  mul(y, y1, y2);
+
656 
+
657  // Clean up.
+
658  clean(x1);
+
659  clean(y1);
+
660  clean(z1);
+
661  clean(x2);
+
662  clean(y2);
+
663  clean(z2);
+
664 }
+
665 
+
676 void P521::addAffine(limb_t *x1, limb_t *y1, const limb_t *x2, const limb_t *y2)
+
677 {
+
678  limb_t xout[NUM_LIMBS_521BIT];
+
679  limb_t yout[NUM_LIMBS_521BIT];
+
680  limb_t zout[NUM_LIMBS_521BIT];
+
681  limb_t z1[NUM_LIMBS_521BIT];
+
682 
+
683  // z1 = 1
+
684  z1[0] = 1;
+
685  memset(z1 + 1, 0, (NUM_LIMBS_521BIT - 1) * sizeof(limb_t));
+
686 
+
687  // Add the two points.
+
688  addPoint(xout, yout, zout, x1, y1, z1, x2, y2/*, z2*/);
+
689 
+
690  // Convert from Jacobian co-ordinates back into affine co-ordinates.
+
691  // x1 = xout * (zout^2)^-1, y1 = yout * (zout^3)^-1.
+
692  recip(z1, zout);
+
693  square(zout, z1);
+
694  mul(x1, xout, zout);
+
695  mul(zout, zout, z1);
+
696  mul(y1, yout, zout);
+
697 
+
698  // Clean up.
+
699  clean(xout);
+
700  clean(yout);
+
701  clean(zout);
+
702  clean(z1);
+
703 }
+
704 
+
714 bool P521::validate(const limb_t *x, const limb_t *y)
+
715 {
+
716  bool result;
+
717 
+
718  // If x or y is greater than or equal to 2^521 - 1, then the
+
719  // point is definitely not on the curve. Preserve timing by
+
720  // delaying the reporting of the result until later.
+
721  result = inRange(x);
+
722  result &= inRange(y);
+
723 
+
724  // We need to check that y^2 = x^3 - 3 * x + b mod 2^521 - 1.
+
725  limb_t t1[NUM_LIMBS_521BIT];
+
726  limb_t t2[NUM_LIMBS_521BIT];
+
727  square(t1, x);
+
728  mul(t1, t1, x);
+
729  mulLiteral(t2, x, 3);
+
730  sub(t1, t1, t2);
+
731  memcpy_P(t2, P521_b, sizeof(t2));
+
732  add(t1, t1, t2);
+
733  square(t2, y);
+
734  result &= secure_compare(t1, t2, sizeof(t1));
+
735  clean(t1);
+
736  clean(t2);
+
737  return result;
+
738 }
+
739 
+
748 bool P521::inRange(const limb_t *x)
+
749 {
+
750  // Do a trial subtraction of 2^521 - 1 from x, which is equivalent
+
751  // to adding 1 and subtracting 2^521. We only need the carry.
+
752  dlimb_t carry = 1;
+
753  limb_t word = 0;
+
754  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
755  carry += *x++;
+
756  word = (limb_t)carry;
+
757  carry >>= LIMB_BITS;
+
758  }
+
759 
+
760  // Determine the carry out from the low 521 bits.
+
761 #if BIGNUMBER_LIMB_8BIT
+
762  carry = (carry << 7) + (word >> 1);
+
763 #else
+
764  carry = (carry << (LIMB_BITS - 9)) + (word >> 9);
+
765 #endif
+
766 
+
767  // If the carry is zero, then x was in range. Otherwise it is out
+
768  // of range. Check for zero in a way that preserves constant timing.
+
769  word = (limb_t)(carry | (carry >> LIMB_BITS));
+
770  word = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - word) >> LIMB_BITS);
+
771  return (bool)word;
+
772 }
+
773 
+
783 void P521::reduce(limb_t *result, const limb_t *x)
+
784 {
+
785 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT || BIGNUMBER_LIMB_64BIT
+
786  // According to NIST FIPS 186-4, we add the high 521 bits to the
+
787  // low 521 bits and then do a trial subtraction of 2^521 - 1.
+
788  // We do both in a single step. Subtracting 2^521 - 1 is equivalent
+
789  // to adding 1 and subtracting 2^521.
+
790  uint8_t index;
+
791  const limb_t *xl = x;
+
792  const limb_t *xh = x + NUM_LIMBS_521BIT;
+
793  limb_t *rr = result;
+
794  dlimb_t carry;
+
795  limb_t word = x[NUM_LIMBS_521BIT - 1];
+
796  carry = (word >> 9) + 1;
+
797  word &= 0x1FF;
+
798  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
+
799  carry += *xl++;
+
800  carry += ((dlimb_t)(*xh++)) << (LIMB_BITS - 9);
+
801  *rr++ = (limb_t)carry;
+
802  carry >>= LIMB_BITS;
+
803  }
+
804  carry += word;
+
805  carry += ((dlimb_t)(x[NUM_LIMBS_1042BIT - 1])) << (LIMB_BITS - 9);
+
806  word = (limb_t)carry;
+
807  *rr = word;
+
808 
+
809  // If the carry out was 1, then mask it off and we have the answer.
+
810  // If the carry out was 0, then we need to add 2^521 - 1 back again.
+
811  // To preserve the timing we perform a conditional subtract of 1 and
+
812  // then mask off the high bits.
+
813  carry = ((word >> 9) ^ 0x01) & 0x01;
+
814  rr = result;
+
815  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
816  carry = ((dlimb_t)(*rr)) - carry;
+
817  *rr++ = (limb_t)carry;
+
818  carry = (carry >> LIMB_BITS) & 0x01;
+
819  }
+
820  *(--rr) &= 0x1FF;
+
821 #elif BIGNUMBER_LIMB_8BIT
+
822  // Same as above, but for 8-bit limbs.
+
823  uint8_t index;
+
824  const limb_t *xl = x;
+
825  const limb_t *xh = x + NUM_LIMBS_521BIT;
+
826  limb_t *rr = result;
+
827  dlimb_t carry;
+
828  limb_t word = x[NUM_LIMBS_521BIT - 1];
+
829  carry = (word >> 1) + 1;
+
830  word &= 0x01;
+
831  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
+
832  carry += *xl++;
+
833  carry += ((dlimb_t)(*xh++)) << 7;
+
834  *rr++ = (limb_t)carry;
+
835  carry >>= LIMB_BITS;
+
836  }
+
837  carry += word;
+
838  carry += ((dlimb_t)(x[NUM_LIMBS_1042BIT - 1])) << 1;
+
839  word = (limb_t)carry;
+
840  *rr = word;
+
841  carry = ((word >> 1) ^ 0x01) & 0x01;
+
842  rr = result;
+
843  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
844  carry = ((dlimb_t)(*rr)) - carry;
+
845  *rr++ = (limb_t)carry;
+
846  carry = (carry >> LIMB_BITS) & 0x01;
+
847  }
+
848  *(--rr) &= 0x01;
+
849 #else
+
850  #error "Don't know how to reduce values mod 2^521 - 1"
+
851 #endif
+
852 }
+
853 
+
866 void P521::reduceQuick(limb_t *x)
+
867 {
+
868  // Perform a trial subtraction of 2^521 - 1 from x. This is
+
869  // equivalent to adding 1 and subtracting 2^521 - 1.
+
870  uint8_t index;
+
871  limb_t *xx = x;
+
872  dlimb_t carry = 1;
+
873  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
874  carry += *xx;
+
875  *xx++ = (limb_t)carry;
+
876  carry >>= LIMB_BITS;
+
877  }
+
878 
+
879  // If the carry out was 1, then mask it off and we have the answer.
+
880  // If the carry out was 0, then we need to add 2^521 - 1 back again.
+
881  // To preserve the timing we perform a conditional subtract of 1 and
+
882  // then mask off the high bits.
+
883 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT || BIGNUMBER_LIMB_64BIT
+
884  carry = ((x[NUM_LIMBS_521BIT - 1] >> 9) ^ 0x01) & 0x01;
+
885  xx = x;
+
886  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
887  carry = ((dlimb_t)(*xx)) - carry;
+
888  *xx++ = (limb_t)carry;
+
889  carry = (carry >> LIMB_BITS) & 0x01;
+
890  }
+
891  *(--xx) &= 0x1FF;
+
892 #elif BIGNUMBER_LIMB_8BIT
+
893  carry = ((x[NUM_LIMBS_521BIT - 1] >> 1) ^ 0x01) & 0x01;
+
894  xx = x;
+
895  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
896  carry = ((dlimb_t)(*xx)) - carry;
+
897  *xx++ = (limb_t)carry;
+
898  carry = (carry >> LIMB_BITS) & 0x01;
+
899  }
+
900  *(--xx) &= 0x01;
+
901 #endif
+
902 }
+
903 
+
916 void P521::mulNoReduce(limb_t *result, const limb_t *x, const limb_t *y)
+
917 {
+
918  uint8_t i, j;
+
919  dlimb_t carry;
+
920  limb_t word;
+
921  const limb_t *yy;
+
922  limb_t *rr;
+
923 
+
924  // Multiply the lowest word of x by y.
+
925  carry = 0;
+
926  word = x[0];
+
927  yy = y;
+
928  rr = result;
+
929  for (i = 0; i < NUM_LIMBS_521BIT; ++i) {
+
930  carry += ((dlimb_t)(*yy++)) * word;
+
931  *rr++ = (limb_t)carry;
+
932  carry >>= LIMB_BITS;
+
933  }
+
934  *rr = (limb_t)carry;
+
935 
+
936  // Multiply and add the remaining words of x by y.
+
937  for (i = 1; i < NUM_LIMBS_521BIT; ++i) {
+
938  word = x[i];
+
939  carry = 0;
+
940  yy = y;
+
941  rr = result + i;
+
942  for (j = 0; j < NUM_LIMBS_521BIT; ++j) {
+
943  carry += ((dlimb_t)(*yy++)) * word;
+
944  carry += *rr;
+
945  *rr++ = (limb_t)carry;
+
946  carry >>= LIMB_BITS;
+
947  }
+
948  *rr = (limb_t)carry;
+
949  }
+
950 }
+
951 
+
962 void P521::mul(limb_t *result, const limb_t *x, const limb_t *y)
+
963 {
+
964  limb_t temp[NUM_LIMBS_1042BIT];
+
965  mulNoReduce(temp, x, y);
+
966  reduce(result, temp);
+
967  strict_clean(temp);
+
968 }
+
969 
+
989 void P521::mulLiteral(limb_t *result, const limb_t *x, limb_t y)
+
990 {
+
991  uint8_t index;
+
992  dlimb_t carry = 0;
+
993  const limb_t *xx = x;
+
994  limb_t *rr = result;
+
995 
+
996  // Multiply x by the literal and put it into the result array.
+
997  // We assume that y is small enough that overflow from the
+
998  // highest limb will not occur during this process.
+
999  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
1000  carry += ((dlimb_t)(*xx++)) * y;
+
1001  *rr++ = (limb_t)carry;
+
1002  carry >>= LIMB_BITS;
+
1003  }
+
1004 
+
1005  // Reduce the value modulo 2^521 - 1. The high half is only a
+
1006  // single limb, so we can short-cut some of reduce() here.
+
1007 #if BIGNUMBER_LIMB_16BIT || BIGNUMBER_LIMB_32BIT || BIGNUMBER_LIMB_64BIT
+
1008  limb_t word = result[NUM_LIMBS_521BIT - 1];
+
1009  carry = (word >> 9) + 1;
+
1010  word &= 0x1FF;
+
1011  rr = result;
+
1012  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
+
1013  carry += *rr;
+
1014  *rr++ = (limb_t)carry;
+
1015  carry >>= LIMB_BITS;
+
1016  }
+
1017  carry += word;
+
1018  word = (limb_t)carry;
+
1019  *rr = word;
+
1020 
+
1021  // If the carry out was 1, then mask it off and we have the answer.
+
1022  // If the carry out was 0, then we need to add 2^521 - 1 back again.
+
1023  // To preserve the timing we perform a conditional subtract of 1 and
+
1024  // then mask off the high bits.
+
1025  carry = ((word >> 9) ^ 0x01) & 0x01;
+
1026  rr = result;
+
1027  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
1028  carry = ((dlimb_t)(*rr)) - carry;
+
1029  *rr++ = (limb_t)carry;
+
1030  carry = (carry >> LIMB_BITS) & 0x01;
+
1031  }
+
1032  *(--rr) &= 0x1FF;
+
1033 #elif BIGNUMBER_LIMB_8BIT
+
1034  // Same as above, but for 8-bit limbs.
+
1035  limb_t word = result[NUM_LIMBS_521BIT - 1];
+
1036  carry = (word >> 1) + 1;
+
1037  word &= 0x01;
+
1038  rr = result;
+
1039  for (index = 0; index < (NUM_LIMBS_521BIT - 1); ++index) {
+
1040  carry += *rr;
+
1041  *rr++ = (limb_t)carry;
+
1042  carry >>= LIMB_BITS;
+
1043  }
+
1044  carry += word;
+
1045  word = (limb_t)carry;
+
1046  *rr = word;
+
1047  carry = ((word >> 1) ^ 0x01) & 0x01;
+
1048  rr = result;
+
1049  for (index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
1050  carry = ((dlimb_t)(*rr)) - carry;
+
1051  *rr++ = (limb_t)carry;
+
1052  carry = (carry >> LIMB_BITS) & 0x01;
+
1053  }
+
1054  *(--rr) &= 0x01;
+
1055 #endif
+
1056 }
+
1057 
+
1068 void P521::add(limb_t *result, const limb_t *x, const limb_t *y)
+
1069 {
+
1070  dlimb_t carry = 0;
+
1071  limb_t *rr = result;
+
1072  for (uint8_t posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
+
1073  carry += *x++;
+
1074  carry += *y++;
+
1075  *rr++ = (limb_t)carry;
+
1076  carry >>= LIMB_BITS;
+
1077  }
+
1078  reduceQuick(result);
+
1079 }
+
1080 
+
1091 void P521::sub(limb_t *result, const limb_t *x, const limb_t *y)
+
1092 {
+
1093  dlimb_t borrow;
+
1094  uint8_t posn;
+
1095  limb_t *rr = result;
+
1096 
+
1097  // Subtract y from x to generate the intermediate result.
+
1098  borrow = 0;
+
1099  for (posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
+
1100  borrow = ((dlimb_t)(*x++)) - (*y++) - ((borrow >> LIMB_BITS) & 0x01);
+
1101  *rr++ = (limb_t)borrow;
+
1102  }
+
1103 
+
1104  // If we had a borrow, then the result has gone negative and we
+
1105  // have to add 2^521 - 1 to the result to make it positive again.
+
1106  // The top bits of "borrow" will be all 1's if there is a borrow
+
1107  // or it will be all 0's if there was no borrow. Easiest is to
+
1108  // conditionally subtract 1 and then mask off the high bits.
+
1109  rr = result;
+
1110  borrow = (borrow >> LIMB_BITS) & 1U;
+
1111  borrow = ((dlimb_t)(*rr)) - borrow;
+
1112  *rr++ = (limb_t)borrow;
+
1113  for (posn = 1; posn < NUM_LIMBS_521BIT; ++posn) {
+
1114  borrow = ((dlimb_t)(*rr)) - ((borrow >> LIMB_BITS) & 0x01);
+
1115  *rr++ = (limb_t)borrow;
+
1116  }
+
1117 #if BIGNUMBER_LIMB_8BIT
+
1118  *(--rr) &= 0x01;
+
1119 #else
+
1120  *(--rr) &= 0x1FF;
+
1121 #endif
+
1122 }
+
1123 
+
1139 void P521::dblPoint(limb_t *xout, limb_t *yout, limb_t *zout,
+
1140  const limb_t *xin, const limb_t *yin,
+
1141  const limb_t *zin)
+
1142 {
+
1143  limb_t alpha[NUM_LIMBS_521BIT];
+
1144  limb_t beta[NUM_LIMBS_521BIT];
+
1145  limb_t gamma[NUM_LIMBS_521BIT];
+
1146  limb_t delta[NUM_LIMBS_521BIT];
+
1147  limb_t tmp[NUM_LIMBS_521BIT];
+
1148 
+
1149  // Double the point. If it is the point at infinity (z = 0),
+
1150  // then zout will still be zero at the end of this process so
+
1151  // we don't need any special handling for that case.
+
1152  square(delta, zin); // delta = z^2
+
1153  square(gamma, yin); // gamma = y^2
+
1154  mul(beta, xin, gamma); // beta = x * gamma
+
1155  sub(tmp, xin, delta); // alpha = 3 * (x - delta) * (x + delta)
+
1156  mulLiteral(alpha, tmp, 3);
+
1157  add(tmp, xin, delta);
+
1158  mul(alpha, alpha, tmp);
+
1159  square(xout, alpha); // xout = alpha^2 - 8 * beta
+
1160  mulLiteral(tmp, beta, 8);
+
1161  sub(xout, xout, tmp);
+
1162  add(zout, yin, zin); // zout = (y + z)^2 - gamma - delta
+
1163  square(zout, zout);
+
1164  sub(zout, zout, gamma);
+
1165  sub(zout, zout, delta);
+
1166  mulLiteral(yout, beta, 4);// yout = alpha * (4 * beta - xout) - 8 * gamma^2
+
1167  sub(yout, yout, xout);
+
1168  mul(yout, alpha, yout);
+
1169  square(gamma, gamma);
+
1170  mulLiteral(gamma, gamma, 8);
+
1171  sub(yout, yout, gamma);
+
1172 
+
1173  // Clean up.
+
1174  strict_clean(alpha);
+
1175  strict_clean(beta);
+
1176  strict_clean(gamma);
+
1177  strict_clean(delta);
+
1178  strict_clean(tmp);
+
1179 }
+
1180 
+
1200 void P521::addPoint(limb_t *xout, limb_t *yout, limb_t *zout,
+
1201  const limb_t *x1, const limb_t *y1,
+
1202  const limb_t *z1, const limb_t *x2,
+
1203  const limb_t *y2)
+
1204 {
+
1205  limb_t z1z1[NUM_LIMBS_521BIT];
+
1206  limb_t u2[NUM_LIMBS_521BIT];
+
1207  limb_t s2[NUM_LIMBS_521BIT];
+
1208  limb_t h[NUM_LIMBS_521BIT];
+
1209  limb_t i[NUM_LIMBS_521BIT];
+
1210  limb_t j[NUM_LIMBS_521BIT];
+
1211  limb_t r[NUM_LIMBS_521BIT];
+
1212  limb_t v[NUM_LIMBS_521BIT];
+
1213 
+
1214  // Determine if the first value is the point-at-infinity identity element.
+
1215  // The second z value is always 1 so it cannot be the point-at-infinity.
+
1216  limb_t p1IsIdentity = BigNumberUtil::isZero(z1, NUM_LIMBS_521BIT);
+
1217 
+
1218  // Multiply the points, assuming that z2 = 1.
+
1219  square(z1z1, z1); // z1z1 = z1^2
+
1220  mul(u2, x2, z1z1); // u2 = x2 * z1z1
+
1221  mul(s2, y2, z1); // s2 = y2 * z1 * z1z1
+
1222  mul(s2, s2, z1z1);
+
1223  sub(h, u2, x1); // h = u2 - x1
+
1224  mulLiteral(i, h, 2); // i = (2 * h)^2
+
1225  square(i, i);
+
1226  sub(r, s2, y1); // r = 2 * (s2 - y1)
+
1227  add(r, r, r);
+
1228  mul(j, h, i); // j = h * i
+
1229  mul(v, x1, i); // v = x1 * i
+
1230  square(xout, r); // xout = r^2 - j - 2 * v
+
1231  sub(xout, xout, j);
+
1232  sub(xout, xout, v);
1233  sub(xout, xout, v);
-
1234  sub(xout, xout, v);
-
1235  sub(yout, v, xout); // yout = r * (v - xout) - 2 * y1 * j
-
1236  mul(yout, r, yout);
-
1237  mul(j, y1, j);
+
1234  sub(yout, v, xout); // yout = r * (v - xout) - 2 * y1 * j
+
1235  mul(yout, r, yout);
+
1236  mul(j, y1, j);
+
1237  sub(yout, yout, j);
1238  sub(yout, yout, j);
-
1239  sub(yout, yout, j);
-
1240  mul(zout, z1, h); // zout = 2 * z1 * h
-
1241  add(zout, zout, zout);
-
1242 
-
1243  // Select the answer to return. If (x1, y1, z1) was the identity,
-
1244  // then the answer is (x2, y2, z2). Otherwise it is (xout, yout, zout).
-
1245  // Conditionally move the second argument over the output if necessary.
-
1246  cmove(p1IsIdentity, xout, x2);
-
1247  cmove(p1IsIdentity, yout, y2);
-
1248  cmove1(p1IsIdentity, zout); // z2 = 1
-
1249 
-
1250  // Clean up.
-
1251  strict_clean(z1z1);
-
1252  strict_clean(u2);
-
1253  strict_clean(s2);
-
1254  strict_clean(h);
-
1255  strict_clean(i);
-
1256  strict_clean(j);
-
1257  strict_clean(r);
-
1258  strict_clean(v);
-
1259 }
-
1260 
-
1273 void P521::cmove(limb_t select, limb_t *x, const limb_t *y)
-
1274 {
-
1275  uint8_t posn;
-
1276  limb_t dummy;
-
1277  limb_t sel;
-
1278 
-
1279  // Turn "select" into an all-zeroes or all-ones mask. We don't care
-
1280  // which bit or bits is set in the original "select" value.
-
1281  sel = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - select) >> LIMB_BITS);
-
1282  --sel;
-
1283 
-
1284  // Move y into x based on "select".
-
1285  for (posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
-
1286  dummy = sel & (*x ^ *y++);
-
1287  *x++ ^= dummy;
-
1288  }
-
1289 }
-
1290 
-
1302 void P521::cmove1(limb_t select, limb_t *x)
-
1303 {
-
1304  uint8_t posn;
-
1305  limb_t dummy;
-
1306  limb_t sel;
-
1307 
-
1308  // Turn "select" into an all-zeroes or all-ones mask. We don't care
-
1309  // which bit or bits is set in the original "select" value.
-
1310  sel = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - select) >> LIMB_BITS);
-
1311  --sel;
-
1312 
-
1313  // Move 1 into x based on "select".
-
1314  dummy = sel & (*x ^ 1);
-
1315  *x++ ^= dummy;
-
1316  for (posn = 1; posn < NUM_LIMBS_521BIT; ++posn) {
-
1317  dummy = sel & *x;
-
1318  *x++ ^= dummy;
-
1319  }
-
1320 }
-
1321 
-
1330 void P521::recip(limb_t *result, const limb_t *x)
-
1331 {
-
1332  limb_t t1[NUM_LIMBS_521BIT];
-
1333 
-
1334  // The reciprocal is the same as x ^ (p - 2) where p = 2^521 - 1.
-
1335  // The big-endian hexadecimal expansion of (p - 2) is:
-
1336  // 01FF FFFFFFF FFFFFFFF ... FFFFFFFF FFFFFFFD
-
1337  //
-
1338  // The naive implementation needs to do 2 multiplications per 1 bit and
-
1339  // 1 multiplication per 0 bit. We can improve upon this by creating a
-
1340  // pattern 1111 and then shifting and multiplying to create 11111111,
-
1341  // and then 1111111111111111, and so on for the top 512-bits.
-
1342 
-
1343  // Build a 4-bit pattern 1111 in the result.
-
1344  square(result, x);
-
1345  mul(result, result, x);
-
1346  square(result, result);
-
1347  mul(result, result, x);
-
1348  square(result, result);
-
1349  mul(result, result, x);
-
1350 
-
1351  // Shift and multiply by increasing powers of two. This turns
-
1352  // 1111 into 11111111, and then 1111111111111111, and so on.
-
1353  for (size_t power = 4; power <= 256; power <<= 1) {
-
1354  square(t1, result);
-
1355  for (size_t temp = 1; temp < power; ++temp)
-
1356  square(t1, t1);
-
1357  mul(result, result, t1);
-
1358  }
-
1359 
-
1360  // Handle the 9 lowest bits of (p - 2), 111111101, from highest to lowest.
-
1361  for (uint8_t index = 0; index < 7; ++index) {
-
1362  square(result, result);
-
1363  mul(result, result, x);
-
1364  }
+
1239  mul(zout, z1, h); // zout = 2 * z1 * h
+
1240  add(zout, zout, zout);
+
1241 
+
1242  // Select the answer to return. If (x1, y1, z1) was the identity,
+
1243  // then the answer is (x2, y2, z2). Otherwise it is (xout, yout, zout).
+
1244  // Conditionally move the second argument over the output if necessary.
+
1245  cmove(p1IsIdentity, xout, x2);
+
1246  cmove(p1IsIdentity, yout, y2);
+
1247  cmove1(p1IsIdentity, zout); // z2 = 1
+
1248 
+
1249  // Clean up.
+
1250  strict_clean(z1z1);
+
1251  strict_clean(u2);
+
1252  strict_clean(s2);
+
1253  strict_clean(h);
+
1254  strict_clean(i);
+
1255  strict_clean(j);
+
1256  strict_clean(r);
+
1257  strict_clean(v);
+
1258 }
+
1259 
+
1272 void P521::cmove(limb_t select, limb_t *x, const limb_t *y)
+
1273 {
+
1274  uint8_t posn;
+
1275  limb_t dummy;
+
1276  limb_t sel;
+
1277 
+
1278  // Turn "select" into an all-zeroes or all-ones mask. We don't care
+
1279  // which bit or bits is set in the original "select" value.
+
1280  sel = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - select) >> LIMB_BITS);
+
1281  --sel;
+
1282 
+
1283  // Move y into x based on "select".
+
1284  for (posn = 0; posn < NUM_LIMBS_521BIT; ++posn) {
+
1285  dummy = sel & (*x ^ *y++);
+
1286  *x++ ^= dummy;
+
1287  }
+
1288 }
+
1289 
+
1301 void P521::cmove1(limb_t select, limb_t *x)
+
1302 {
+
1303  uint8_t posn;
+
1304  limb_t dummy;
+
1305  limb_t sel;
+
1306 
+
1307  // Turn "select" into an all-zeroes or all-ones mask. We don't care
+
1308  // which bit or bits is set in the original "select" value.
+
1309  sel = (limb_t)(((((dlimb_t)1) << LIMB_BITS) - select) >> LIMB_BITS);
+
1310  --sel;
+
1311 
+
1312  // Move 1 into x based on "select".
+
1313  dummy = sel & (*x ^ 1);
+
1314  *x++ ^= dummy;
+
1315  for (posn = 1; posn < NUM_LIMBS_521BIT; ++posn) {
+
1316  dummy = sel & *x;
+
1317  *x++ ^= dummy;
+
1318  }
+
1319 }
+
1320 
+
1329 void P521::recip(limb_t *result, const limb_t *x)
+
1330 {
+
1331  limb_t t1[NUM_LIMBS_521BIT];
+
1332 
+
1333  // The reciprocal is the same as x ^ (p - 2) where p = 2^521 - 1.
+
1334  // The big-endian hexadecimal expansion of (p - 2) is:
+
1335  // 01FF FFFFFFF FFFFFFFF ... FFFFFFFF FFFFFFFD
+
1336  //
+
1337  // The naive implementation needs to do 2 multiplications per 1 bit and
+
1338  // 1 multiplication per 0 bit. We can improve upon this by creating a
+
1339  // pattern 1111 and then shifting and multiplying to create 11111111,
+
1340  // and then 1111111111111111, and so on for the top 512-bits.
+
1341 
+
1342  // Build a 4-bit pattern 1111 in the result.
+
1343  square(result, x);
+
1344  mul(result, result, x);
+
1345  square(result, result);
+
1346  mul(result, result, x);
+
1347  square(result, result);
+
1348  mul(result, result, x);
+
1349 
+
1350  // Shift and multiply by increasing powers of two. This turns
+
1351  // 1111 into 11111111, and then 1111111111111111, and so on.
+
1352  for (size_t power = 4; power <= 256; power <<= 1) {
+
1353  square(t1, result);
+
1354  for (size_t temp = 1; temp < power; ++temp)
+
1355  square(t1, t1);
+
1356  mul(result, result, t1);
+
1357  }
+
1358 
+
1359  // Handle the 9 lowest bits of (p - 2), 111111101, from highest to lowest.
+
1360  for (uint8_t index = 0; index < 7; ++index) {
+
1361  square(result, result);
+
1362  mul(result, result, x);
+
1363  }
+
1364  square(result, result);
1365  square(result, result);
-
1366  square(result, result);
-
1367  mul(result, result, x);
-
1368 
-
1369  // Clean up.
-
1370  clean(t1);
-
1371 }
-
1372 
-
1381 void P521::reduceQ(limb_t *result, const limb_t *r)
-
1382 {
-
1383  // Algorithm from: http://en.wikipedia.org/wiki/Barrett_reduction
-
1384  //
-
1385  // We assume that r is less than or equal to (q - 1)^2.
-
1386  //
-
1387  // We want to compute result = r mod q. Find the smallest k such
-
1388  // that 2^k > q. In our case, k = 521. Then set m = floor(4^k / q)
-
1389  // and let r = r - q * floor(m * r / 4^k). This will be the result
-
1390  // or it will be at most one subtraction of q away from the result.
-
1391  //
-
1392  // Note: m is a 522-bit number, which fits in the same number of limbs
-
1393  // as a 521-bit number assuming that limbs are 8 bits or more in size.
-
1394  static limb_t const numM[NUM_LIMBS_521BIT] PROGMEM = {
-
1395  LIMB(0x6EC79BF7), LIMB(0x449048E1), LIMB(0x7663B851), LIMB(0xC44A3647),
-
1396  LIMB(0x08F65A2F), LIMB(0x8033FEB7), LIMB(0x40D06994), LIMB(0xAE79787C),
-
1397  LIMB(0x00000005), LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000),
-
1398  LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000), LIMB(0x00000000),
-
1399  LIMB_PARTIAL(0x200)
-
1400  };
-
1401  limb_t temp[NUM_LIMBS_1042BIT + NUM_LIMBS_521BIT];
-
1402  limb_t temp2[NUM_LIMBS_521BIT];
-
1403 
-
1404  // Multiply r by m.
-
1405  BigNumberUtil::mul_P(temp, r, NUM_LIMBS_1042BIT, numM, NUM_LIMBS_521BIT);
-
1406 
-
1407  // Compute (m * r / 4^521) = (m * r / 2^1042).
-
1408 #if BIGNUMBER_LIMB_8BIT || BIGNUMBER_LIMB_16BIT
-
1409  dlimb_t carry = temp[NUM_LIMBS_BITS(1040)] >> 2;
-
1410  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
1411  carry += ((dlimb_t)(temp[NUM_LIMBS_BITS(1040) + index + 1])) << (LIMB_BITS - 2);
-
1412  temp2[index] = (limb_t)carry;
-
1413  carry >>= LIMB_BITS;
-
1414  }
-
1415 #elif BIGNUMBER_LIMB_32BIT
-
1416  dlimb_t carry = temp[NUM_LIMBS_BITS(1024)] >> 18;
-
1417  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
-
1418  carry += ((dlimb_t)(temp[NUM_LIMBS_BITS(1024) + index + 1])) << 14;
-
1419  temp2[index] = (limb_t)carry;
-
1420  carry >>= LIMB_BITS;
-
1421  }
-
1422 #endif
-
1423 
-
1424  // Multiply (m * r) / 2^1042 by q and subtract it from r.
-
1425  // We can ignore the high words of the subtraction result
-
1426  // because they will all turn into zero after the subtraction.
-
1427  BigNumberUtil::mul_P(temp, temp2, NUM_LIMBS_521BIT,
-
1428  P521_q, NUM_LIMBS_521BIT);
-
1429  BigNumberUtil::sub(result, r, temp, NUM_LIMBS_521BIT);
-
1430 
-
1431  // Perform a trial subtraction of q from the result to reduce it.
-
1432  BigNumberUtil::reduceQuick_P(result, result, P521_q, NUM_LIMBS_521BIT);
-
1433 
-
1434  // Clean up and exit.
-
1435  clean(temp);
-
1436  clean(temp2);
-
1437 }
-
1438 
-
1449 void P521::mulQ(limb_t *result, const limb_t *x, const limb_t *y)
-
1450 {
-
1451  limb_t temp[NUM_LIMBS_1042BIT];
-
1452  mulNoReduce(temp, x, y);
-
1453  reduceQ(result, temp);
-
1454  strict_clean(temp);
-
1455 }
-
1456 
-
1465 void P521::recipQ(limb_t *result, const limb_t *x)
-
1466 {
-
1467  // Bottom 265 bits of q - 2. The top 256 bits are all-1's.
-
1468  static limb_t const P521_q_m2[] PROGMEM = {
-
1469  LIMB(0x91386407), LIMB(0xbb6fb71e), LIMB(0x899c47ae), LIMB(0x3bb5c9b8),
-
1470  LIMB(0xf709a5d0), LIMB(0x7fcc0148), LIMB(0xbf2f966b), LIMB(0x51868783),
-
1471  LIMB_PARTIAL(0x1fa)
-
1472  };
-
1473 
-
1474  // Raise x to the power of q - 2, mod q. We start with the top
-
1475  // 256 bits which are all-1's, using a similar technique to recip().
-
1476  limb_t t1[NUM_LIMBS_521BIT];
-
1477  mulQ(result, x, x);
-
1478  mulQ(result, result, x);
-
1479  mulQ(result, result, result);
-
1480  mulQ(result, result, x);
-
1481  mulQ(result, result, result);
-
1482  mulQ(result, result, x);
-
1483  for (size_t power = 4; power <= 128; power <<= 1) {
-
1484  mulQ(t1, result, result);
-
1485  for (size_t temp = 1; temp < power; ++temp)
-
1486  mulQ(t1, t1, t1);
-
1487  mulQ(result, result, t1);
-
1488  }
-
1489  clean(t1);
-
1490 
-
1491  // Deal with the bottom 265 bits from highest to lowest. Square for
-
1492  // each bit and multiply in x whenever there is a 1 bit. The timing
-
1493  // is based on the publicly-known constant q - 2, not on the value of x.
-
1494  size_t bit = 265;
-
1495  while (bit > 0) {
-
1496  --bit;
-
1497  mulQ(result, result, result);
-
1498  if (pgm_read_limb(&(P521_q_m2[bit / LIMB_BITS])) &
-
1499  (((limb_t)1) << (bit % LIMB_BITS))) {
-
1500  mulQ(result, result, x);
-
1501  }
-
1502  }
-
1503 }
-
1504 
-
1515 void P521::generateK(uint8_t k[66], const uint8_t hm[66],
-
1516  const uint8_t x[66], Hash *hash, uint64_t count)
-
1517 {
-
1518  size_t hlen = hash->hashSize();
-
1519  uint8_t V[64];
-
1520  uint8_t K[64];
-
1521  uint8_t marker;
-
1522 
-
1523  // If for some reason a hash function was supplied with more than
-
1524  // 512 bits of output, truncate hash values to the first 512 bits.
-
1525  // We cannot support more than this yet.
-
1526  if (hlen > 64)
-
1527  hlen = 64;
-
1528 
-
1529  // RFC 6979, Section 3.2, Step a. Hash the message, reduce modulo q,
-
1530  // and produce an octet string the same length as q, bits2octets(H(m)).
-
1531  // We support hashes up to 512 bits and q is a 521-bit number, so "hm"
-
1532  // is already the bits2octets(H(m)) value that we need.
-
1533 
-
1534  // Steps b and c. Set V to all-ones and K to all-zeroes.
-
1535  memset(V, 0x01, hlen);
-
1536  memset(K, 0x00, hlen);
-
1537 
-
1538  // Step d. K = HMAC_K(V || 0x00 || x || hm). We make a small
-
1539  // modification here to append the count value if it is non-zero.
-
1540  // We use this to generate a new k if we have to re-enter this
-
1541  // function because the previous one was rejected by sign().
-
1542  // This is slightly different to RFC 6979 which says that the
-
1543  // loop in step h below should be continued. That code path is
-
1544  // difficult to access, so instead modify K and V in steps d and f.
-
1545  // This alternative construction is compatible with the second
-
1546  // variant described in section 3.6 of RFC 6979.
-
1547  hash->resetHMAC(K, hlen);
-
1548  hash->update(V, hlen);
-
1549  marker = 0x00;
-
1550  hash->update(&marker, 1);
-
1551  hash->update(x, 66);
-
1552  hash->update(hm, 66);
-
1553  if (count)
-
1554  hash->update(&count, sizeof(count));
-
1555  hash->finalizeHMAC(K, hlen, K, hlen);
-
1556 
-
1557  // Step e. V = HMAC_K(V)
-
1558  hash->resetHMAC(K, hlen);
-
1559  hash->update(V, hlen);
-
1560  hash->finalizeHMAC(K, hlen, V, hlen);
-
1561 
-
1562  // Step f. K = HMAC_K(V || 0x01 || x || hm)
-
1563  hash->resetHMAC(K, hlen);
-
1564  hash->update(V, hlen);
-
1565  marker = 0x01;
-
1566  hash->update(&marker, 1);
-
1567  hash->update(x, 66);
-
1568  hash->update(hm, 66);
-
1569  if (count)
-
1570  hash->update(&count, sizeof(count));
-
1571  hash->finalizeHMAC(K, hlen, K, hlen);
-
1572 
-
1573  // Step g. V = HMAC_K(V)
-
1574  hash->resetHMAC(K, hlen);
-
1575  hash->update(V, hlen);
-
1576  hash->finalizeHMAC(K, hlen, V, hlen);
-
1577 
-
1578  // Step h. Generate candidate k values until we find what we want.
-
1579  for (;;) {
-
1580  // Step h.1 and h.2. Generate a string of 66 bytes in length.
-
1581  // T = empty
-
1582  // while (len(T) < 66)
-
1583  // V = HMAC_K(V)
-
1584  // T = T || V
-
1585  size_t posn = 0;
-
1586  while (posn < 66) {
-
1587  size_t temp = 66 - posn;
-
1588  if (temp > hlen)
-
1589  temp = hlen;
-
1590  hash->resetHMAC(K, hlen);
-
1591  hash->update(V, hlen);
-
1592  hash->finalizeHMAC(K, hlen, V, hlen);
-
1593  memcpy(k + posn, V, temp);
-
1594  posn += temp;
-
1595  }
-
1596 
-
1597  // Step h.3. k = bits2int(T) and exit the loop if k is not in
-
1598  // the range 1 to q - 1. Note: We have to extract the 521 most
-
1599  // significant bits of T, which means shifting it right by seven
-
1600  // bits to put it into the correct form.
-
1601  for (posn = 65; posn > 0; --posn)
-
1602  k[posn] = (k[posn - 1] << 1) | (k[posn] >> 7);
-
1603  k[0] >>= 7;
-
1604  if (isValidPrivateKey(k))
-
1605  break;
-
1606 
-
1607  // Generate new K and V values and try again.
-
1608  // K = HMAC_K(V || 0x00)
-
1609  // V = HMAC_K(V)
-
1610  hash->resetHMAC(K, hlen);
-
1611  hash->update(V, hlen);
-
1612  marker = 0x00;
-
1613  hash->update(&marker, 1);
-
1614  hash->finalizeHMAC(K, hlen, K, hlen);
-
1615  hash->resetHMAC(K, hlen);
-
1616  hash->update(V, hlen);
-
1617  hash->finalizeHMAC(K, hlen, V, hlen);
-
1618  }
-
1619 
-
1620  // Clean up.
-
1621  clean(V);
-
1622  clean(K);
-
1623 }
-
1624 
-
1637 void P521::generateK(uint8_t k[66], const uint8_t hm[66],
-
1638  const uint8_t x[66], uint64_t count)
-
1639 {
-
1640  SHA512 hash;
-
1641  generateK(k, hm, x, &hash, count);
-
1642 }
-
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
-
P521::eval
static bool eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
Evaluates the curve function.
Definition: P521.cpp:136
-
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
-
P521::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[66])
Generates a private key for P-521 signing operations.
Definition: P521.cpp:467
-
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:541
+
1366  mul(result, result, x);
+
1367 
+
1368  // Clean up.
+
1369  clean(t1);
+
1370 }
+
1371 
+
1380 void P521::reduceQ(limb_t *result, const limb_t *r)
+
1381 {
+
1382  // Algorithm from: http://en.wikipedia.org/wiki/Barrett_reduction
+
1383  //
+
1384  // We assume that r is less than or equal to (q - 1)^2.
+
1385  //
+
1386  // We want to compute result = r mod q. Find the smallest k such
+
1387  // that 2^k > q. In our case, k = 521. Then set m = floor(4^k / q)
+
1388  // and let r = r - q * floor(m * r / 4^k). This will be the result
+
1389  // or it will be at most one subtraction of q away from the result.
+
1390  //
+
1391  // Note: m is a 522-bit number, which fits in the same number of limbs
+
1392  // as a 521-bit number assuming that limbs are 8 bits or more in size.
+
1393  static limb_t const numM[NUM_LIMBS_521BIT] PROGMEM = {
+
1394  LIMB_PAIR(0x6EC79BF7, 0x449048E1), LIMB_PAIR(0x7663B851, 0xC44A3647),
+
1395  LIMB_PAIR(0x08F65A2F, 0x8033FEB7), LIMB_PAIR(0x40D06994, 0xAE79787C),
+
1396  LIMB_PAIR(0x00000005, 0x00000000), LIMB_PAIR(0x00000000, 0x00000000),
+
1397  LIMB_PAIR(0x00000000, 0x00000000), LIMB_PAIR(0x00000000, 0x00000000),
+
1398  LIMB_PARTIAL(0x200)
+
1399  };
+
1400  limb_t temp[NUM_LIMBS_1042BIT + NUM_LIMBS_521BIT];
+
1401  limb_t temp2[NUM_LIMBS_521BIT];
+
1402 
+
1403  // Multiply r by m.
+
1404  BigNumberUtil::mul_P(temp, r, NUM_LIMBS_1042BIT, numM, NUM_LIMBS_521BIT);
+
1405 
+
1406  // Compute (m * r / 4^521) = (m * r / 2^1042).
+
1407 #if BIGNUMBER_LIMB_8BIT || BIGNUMBER_LIMB_16BIT
+
1408  dlimb_t carry = temp[NUM_LIMBS_BITS(1040)] >> 2;
+
1409  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
1410  carry += ((dlimb_t)(temp[NUM_LIMBS_BITS(1040) + index + 1])) << (LIMB_BITS - 2);
+
1411  temp2[index] = (limb_t)carry;
+
1412  carry >>= LIMB_BITS;
+
1413  }
+
1414 #elif BIGNUMBER_LIMB_32BIT || BIGNUMBER_LIMB_64BIT
+
1415  dlimb_t carry = temp[NUM_LIMBS_BITS(1024)] >> 18;
+
1416  for (uint8_t index = 0; index < NUM_LIMBS_521BIT; ++index) {
+
1417  carry += ((dlimb_t)(temp[NUM_LIMBS_BITS(1024) + index + 1])) << (LIMB_BITS - 18);
+
1418  temp2[index] = (limb_t)carry;
+
1419  carry >>= LIMB_BITS;
+
1420  }
+
1421 #endif
+
1422 
+
1423  // Multiply (m * r) / 2^1042 by q and subtract it from r.
+
1424  // We can ignore the high words of the subtraction result
+
1425  // because they will all turn into zero after the subtraction.
+
1426  BigNumberUtil::mul_P(temp, temp2, NUM_LIMBS_521BIT,
+
1427  P521_q, NUM_LIMBS_521BIT);
+
1428  BigNumberUtil::sub(result, r, temp, NUM_LIMBS_521BIT);
+
1429 
+
1430  // Perform a trial subtraction of q from the result to reduce it.
+
1431  BigNumberUtil::reduceQuick_P(result, result, P521_q, NUM_LIMBS_521BIT);
+
1432 
+
1433  // Clean up and exit.
+
1434  clean(temp);
+
1435  clean(temp2);
+
1436 }
+
1437 
+
1448 void P521::mulQ(limb_t *result, const limb_t *x, const limb_t *y)
+
1449 {
+
1450  limb_t temp[NUM_LIMBS_1042BIT];
+
1451  mulNoReduce(temp, x, y);
+
1452  reduceQ(result, temp);
+
1453  strict_clean(temp);
+
1454 }
+
1455 
+
1464 void P521::recipQ(limb_t *result, const limb_t *x)
+
1465 {
+
1466  // Bottom 265 bits of q - 2. The top 256 bits are all-1's.
+
1467  static limb_t const P521_q_m2[] PROGMEM = {
+
1468  LIMB_PAIR(0x91386407, 0xbb6fb71e), LIMB_PAIR(0x899c47ae, 0x3bb5c9b8),
+
1469  LIMB_PAIR(0xf709a5d0, 0x7fcc0148), LIMB_PAIR(0xbf2f966b, 0x51868783),
+
1470  LIMB_PARTIAL(0x1fa)
+
1471  };
+
1472 
+
1473  // Raise x to the power of q - 2, mod q. We start with the top
+
1474  // 256 bits which are all-1's, using a similar technique to recip().
+
1475  limb_t t1[NUM_LIMBS_521BIT];
+
1476  mulQ(result, x, x);
+
1477  mulQ(result, result, x);
+
1478  mulQ(result, result, result);
+
1479  mulQ(result, result, x);
+
1480  mulQ(result, result, result);
+
1481  mulQ(result, result, x);
+
1482  for (size_t power = 4; power <= 128; power <<= 1) {
+
1483  mulQ(t1, result, result);
+
1484  for (size_t temp = 1; temp < power; ++temp)
+
1485  mulQ(t1, t1, t1);
+
1486  mulQ(result, result, t1);
+
1487  }
+
1488  clean(t1);
+
1489 
+
1490  // Deal with the bottom 265 bits from highest to lowest. Square for
+
1491  // each bit and multiply in x whenever there is a 1 bit. The timing
+
1492  // is based on the publicly-known constant q - 2, not on the value of x.
+
1493  size_t bit = 265;
+
1494  while (bit > 0) {
+
1495  --bit;
+
1496  mulQ(result, result, result);
+
1497  if (pgm_read_limb(&(P521_q_m2[bit / LIMB_BITS])) &
+
1498  (((limb_t)1) << (bit % LIMB_BITS))) {
+
1499  mulQ(result, result, x);
+
1500  }
+
1501  }
+
1502 }
+
1503 
+
1514 void P521::generateK(uint8_t k[66], const uint8_t hm[66],
+
1515  const uint8_t x[66], Hash *hash, uint64_t count)
+
1516 {
+
1517  size_t hlen = hash->hashSize();
+
1518  uint8_t V[64];
+
1519  uint8_t K[64];
+
1520  uint8_t marker;
+
1521 
+
1522  // If for some reason a hash function was supplied with more than
+
1523  // 512 bits of output, truncate hash values to the first 512 bits.
+
1524  // We cannot support more than this yet.
+
1525  if (hlen > 64)
+
1526  hlen = 64;
+
1527 
+
1528  // RFC 6979, Section 3.2, Step a. Hash the message, reduce modulo q,
+
1529  // and produce an octet string the same length as q, bits2octets(H(m)).
+
1530  // We support hashes up to 512 bits and q is a 521-bit number, so "hm"
+
1531  // is already the bits2octets(H(m)) value that we need.
+
1532 
+
1533  // Steps b and c. Set V to all-ones and K to all-zeroes.
+
1534  memset(V, 0x01, hlen);
+
1535  memset(K, 0x00, hlen);
+
1536 
+
1537  // Step d. K = HMAC_K(V || 0x00 || x || hm). We make a small
+
1538  // modification here to append the count value if it is non-zero.
+
1539  // We use this to generate a new k if we have to re-enter this
+
1540  // function because the previous one was rejected by sign().
+
1541  // This is slightly different to RFC 6979 which says that the
+
1542  // loop in step h below should be continued. That code path is
+
1543  // difficult to access, so instead modify K and V in steps d and f.
+
1544  // This alternative construction is compatible with the second
+
1545  // variant described in section 3.6 of RFC 6979.
+
1546  hash->resetHMAC(K, hlen);
+
1547  hash->update(V, hlen);
+
1548  marker = 0x00;
+
1549  hash->update(&marker, 1);
+
1550  hash->update(x, 66);
+
1551  hash->update(hm, 66);
+
1552  if (count)
+
1553  hash->update(&count, sizeof(count));
+
1554  hash->finalizeHMAC(K, hlen, K, hlen);
+
1555 
+
1556  // Step e. V = HMAC_K(V)
+
1557  hash->resetHMAC(K, hlen);
+
1558  hash->update(V, hlen);
+
1559  hash->finalizeHMAC(K, hlen, V, hlen);
+
1560 
+
1561  // Step f. K = HMAC_K(V || 0x01 || x || hm)
+
1562  hash->resetHMAC(K, hlen);
+
1563  hash->update(V, hlen);
+
1564  marker = 0x01;
+
1565  hash->update(&marker, 1);
+
1566  hash->update(x, 66);
+
1567  hash->update(hm, 66);
+
1568  if (count)
+
1569  hash->update(&count, sizeof(count));
+
1570  hash->finalizeHMAC(K, hlen, K, hlen);
+
1571 
+
1572  // Step g. V = HMAC_K(V)
+
1573  hash->resetHMAC(K, hlen);
+
1574  hash->update(V, hlen);
+
1575  hash->finalizeHMAC(K, hlen, V, hlen);
+
1576 
+
1577  // Step h. Generate candidate k values until we find what we want.
+
1578  for (;;) {
+
1579  // Step h.1 and h.2. Generate a string of 66 bytes in length.
+
1580  // T = empty
+
1581  // while (len(T) < 66)
+
1582  // V = HMAC_K(V)
+
1583  // T = T || V
+
1584  size_t posn = 0;
+
1585  while (posn < 66) {
+
1586  size_t temp = 66 - posn;
+
1587  if (temp > hlen)
+
1588  temp = hlen;
+
1589  hash->resetHMAC(K, hlen);
+
1590  hash->update(V, hlen);
+
1591  hash->finalizeHMAC(K, hlen, V, hlen);
+
1592  memcpy(k + posn, V, temp);
+
1593  posn += temp;
+
1594  }
+
1595 
+
1596  // Step h.3. k = bits2int(T) and exit the loop if k is not in
+
1597  // the range 1 to q - 1. Note: We have to extract the 521 most
+
1598  // significant bits of T, which means shifting it right by seven
+
1599  // bits to put it into the correct form.
+
1600  for (posn = 65; posn > 0; --posn)
+
1601  k[posn] = (k[posn - 1] << 1) | (k[posn] >> 7);
+
1602  k[0] >>= 7;
+
1603  if (isValidPrivateKey(k))
+
1604  break;
+
1605 
+
1606  // Generate new K and V values and try again.
+
1607  // K = HMAC_K(V || 0x00)
+
1608  // V = HMAC_K(V)
+
1609  hash->resetHMAC(K, hlen);
+
1610  hash->update(V, hlen);
+
1611  marker = 0x00;
+
1612  hash->update(&marker, 1);
+
1613  hash->finalizeHMAC(K, hlen, K, hlen);
+
1614  hash->resetHMAC(K, hlen);
+
1615  hash->update(V, hlen);
+
1616  hash->finalizeHMAC(K, hlen, V, hlen);
+
1617  }
+
1618 
+
1619  // Clean up.
+
1620  clean(V);
+
1621  clean(K);
+
1622 }
+
1623 
+
1636 void P521::generateK(uint8_t k[66], const uint8_t hm[66],
+
1637  const uint8_t x[66], uint64_t count)
+
1638 {
+
1639  SHA512 hash;
+
1640  generateK(k, hm, x, &hash, count);
+
1641 }
+
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:734
+
P521::eval
static bool eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
Evaluates the curve function.
Definition: P521.cpp:135
+
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:495
+
P521::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[66])
Generates a private key for P-521 signing operations.
Definition: P521.cpp:466
+
BigNumberUtil::sub_P
static limb_t sub_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another where one is in program memory.
Definition: BigNumberUtil.cpp:655
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
-
P521::dh2
static bool dh2(const uint8_t k[132], uint8_t f[66])
Performs phase 2 of an ECDH key exchange using P-521.
Definition: P521.cpp:230
+
P521::dh2
static bool dh2(const uint8_t k[132], uint8_t f[66])
Performs phase 2 of an ECDH key exchange using P-521.
Definition: P521.cpp:229
Hash
Abstract base class for cryptographic hash algorithms.
Definition: Hash.h:29
Hash::finalizeHMAC
virtual void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)=0
Finalizes the HMAC hashing process and returns the hash.
-
P521::isValidPrivateKey
static bool isValidPrivateKey(const uint8_t privateKey[66])
Validates a private key value to ensure that it is between 1 and q - 1.
Definition: P521.cpp:525
+
P521::isValidPrivateKey
static bool isValidPrivateKey(const uint8_t privateKey[66])
Validates a private key value to ensure that it is between 1 and q - 1.
Definition: P521.cpp:524
SHA512
SHA-512 hash algorithm.
Definition: SHA512.h:30
-
P521::derivePublicKey
static void derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
Derives the public key from a private key for P-521 signing operations.
Definition: P521.cpp:498
-
P521::sign
static void sign(uint8_t signature[132], const uint8_t privateKey[66], const void *message, size_t len, Hash *hash=0)
Signs a message using a specific P-521 private key.
Definition: P521.cpp:277
-
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:408
+
P521::derivePublicKey
static void derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
Derives the public key from a private key for P-521 signing operations.
Definition: P521.cpp:497
+
P521::sign
static void sign(uint8_t signature[132], const uint8_t privateKey[66], const void *message, size_t len, Hash *hash=0)
Signs a message using a specific P-521 private key.
Definition: P521.cpp:276
+
BigNumberUtil::sub
static limb_t sub(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Subtracts one big number from another.
Definition: BigNumberUtil.cpp:522
Hash::reset
virtual void reset()=0
Resets the hash ready for a new hashing process.
-
P521::dh1
static void dh1(uint8_t k[132], uint8_t f[66])
Performs phase 1 of an ECDH key exchange using P-521.
Definition: P521.cpp:209
-
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:566
-
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:294
+
P521::dh1
static void dh1(uint8_t k[132], uint8_t f[66])
Performs phase 1 of an ECDH key exchange using P-521.
Definition: P521.cpp:208
+
BigNumberUtil::mul_P
static void mul_P(limb_t *result, const limb_t *x, size_t xcount, const limb_t *y, size_t ycount)
Multiplies two big numbers where one is in program memory.
Definition: BigNumberUtil.cpp:680
+
BigNumberUtil::packBE
static void packBE(uint8_t *bytes, size_t len, const limb_t *limbs, size_t count)
Packs the big-endian byte representation of a big number into a byte array.
Definition: BigNumberUtil.cpp:375
Hash::resetHMAC
virtual void resetHMAC(const void *key, size_t keyLen)=0
Resets the hash ready for a new HMAC hashing process.
-
P521::verify
static bool verify(const uint8_t signature[132], const uint8_t publicKey[132], const void *message, size_t len, Hash *hash=0)
Verifies a signature using a specific P-521 public key.
Definition: P521.cpp:374
-
P521::isValidPublicKey
static bool isValidPublicKey(const uint8_t publicKey[132])
Validates a public key to ensure that it is a valid curve point.
Definition: P521.cpp:565
-
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:134
+
P521::verify
static bool verify(const uint8_t signature[132], const uint8_t publicKey[132], const void *message, size_t len, Hash *hash=0)
Verifies a signature using a specific P-521 public key.
Definition: P521.cpp:373
+
P521::isValidPublicKey
static bool isValidPublicKey(const uint8_t publicKey[132])
Validates a public key to ensure that it is a valid curve point.
Definition: P521.cpp:564
+
BigNumberUtil::unpackBE
static void unpackBE(limb_t *limbs, size_t count, const uint8_t *bytes, size_t len)
Unpacks the big-endian byte representation of a big number into a limb array.
Definition: BigNumberUtil.cpp:163
Hash::hashSize
virtual size_t hashSize() const =0
Size of the hash result from finalize().
Hash::update
virtual void update(const void *data, size_t len)=0
Updates the hash with more data.
Hash::finalize
virtual void finalize(void *hash, size_t len)=0
Finalizes the hashing process and returns the hash.
-
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:647
+
BigNumberUtil::isZero
static limb_t isZero(const limb_t *x, size_t size)
Determine if a big number is zero.
Definition: BigNumberUtil.cpp:761
diff --git a/P521_8h_source.html b/P521_8h_source.html index 325e5121..51ef175b 100644 --- a/P521_8h_source.html +++ b/P521_8h_source.html @@ -200,22 +200,22 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
110 };
111 
112 #endif
-
P521::eval
static bool eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
Evaluates the curve function.
Definition: P521.cpp:136
+
P521::eval
static bool eval(uint8_t result[132], const uint8_t f[66], const uint8_t point[132])
Evaluates the curve function.
Definition: P521.cpp:135
P521
Elliptic curve operations with the NIST P-521 curve.
Definition: P521.h:30
-
P521::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[66])
Generates a private key for P-521 signing operations.
Definition: P521.cpp:467
-
P521::dh2
static bool dh2(const uint8_t k[132], uint8_t f[66])
Performs phase 2 of an ECDH key exchange using P-521.
Definition: P521.cpp:230
+
P521::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[66])
Generates a private key for P-521 signing operations.
Definition: P521.cpp:466
+
P521::dh2
static bool dh2(const uint8_t k[132], uint8_t f[66])
Performs phase 2 of an ECDH key exchange using P-521.
Definition: P521.cpp:229
Hash
Abstract base class for cryptographic hash algorithms.
Definition: Hash.h:29
-
P521::isValidPrivateKey
static bool isValidPrivateKey(const uint8_t privateKey[66])
Validates a private key value to ensure that it is between 1 and q - 1.
Definition: P521.cpp:525
-
P521::derivePublicKey
static void derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
Derives the public key from a private key for P-521 signing operations.
Definition: P521.cpp:498
-
P521::sign
static void sign(uint8_t signature[132], const uint8_t privateKey[66], const void *message, size_t len, Hash *hash=0)
Signs a message using a specific P-521 private key.
Definition: P521.cpp:277
-
P521::dh1
static void dh1(uint8_t k[132], uint8_t f[66])
Performs phase 1 of an ECDH key exchange using P-521.
Definition: P521.cpp:209
-
P521::verify
static bool verify(const uint8_t signature[132], const uint8_t publicKey[132], const void *message, size_t len, Hash *hash=0)
Verifies a signature using a specific P-521 public key.
Definition: P521.cpp:374
-
P521::isValidPublicKey
static bool isValidPublicKey(const uint8_t publicKey[132])
Validates a public key to ensure that it is a valid curve point.
Definition: P521.cpp:565
+
P521::isValidPrivateKey
static bool isValidPrivateKey(const uint8_t privateKey[66])
Validates a private key value to ensure that it is between 1 and q - 1.
Definition: P521.cpp:524
+
P521::derivePublicKey
static void derivePublicKey(uint8_t publicKey[132], const uint8_t privateKey[66])
Derives the public key from a private key for P-521 signing operations.
Definition: P521.cpp:497
+
P521::sign
static void sign(uint8_t signature[132], const uint8_t privateKey[66], const void *message, size_t len, Hash *hash=0)
Signs a message using a specific P-521 private key.
Definition: P521.cpp:276
+
P521::dh1
static void dh1(uint8_t k[132], uint8_t f[66])
Performs phase 1 of an ECDH key exchange using P-521.
Definition: P521.cpp:208
+
P521::verify
static bool verify(const uint8_t signature[132], const uint8_t publicKey[132], const void *message, size_t len, Hash *hash=0)
Verifies a signature using a specific P-521 public key.
Definition: P521.cpp:373
+
P521::isValidPublicKey
static bool isValidPublicKey(const uint8_t publicKey[132])
Validates a public key to ensure that it is a valid curve point.
Definition: P521.cpp:564
P521::isValidCurvePoint
static bool isValidCurvePoint(const uint8_t point[132])
Validates a point to ensure that it is on the curve.
Definition: P521.h:51
diff --git a/Poly1305_8cpp_source.html b/Poly1305_8cpp_source.html index a8ae9059..446c26b2 100644 --- a/Poly1305_8cpp_source.html +++ b/Poly1305_8cpp_source.html @@ -129,233 +129,236 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
72 #elif BIGNUMBER_LIMB_32BIT
73 #define lelimbtoh(x) (le32toh((x)))
74 #define htolelimb(x) (htole32((x)))
-
75 #endif
-
76 #if defined(CRYPTO_LITTLE_ENDIAN)
-
77 #define littleToHost(r,size) do { ; } while (0)
-
78 #else
-
79 #define littleToHost(r,size) \
-
80  do { \
-
81  for (uint8_t i = 0; i < (size); ++i) \
-
82  (r)[i] = lelimbtoh((r)[i]); \
-
83  } while (0)
-
84 #endif
-
85 
-
89 Poly1305::Poly1305()
-
90 {
-
91  state.chunkSize = 0;
-
92 }
-
93 
-
98 Poly1305::~Poly1305()
-
99 {
-
100  clean(state);
-
101 }
-
102 
-
110 void Poly1305::reset(const void *key)
-
111 {
-
112  // Copy the key into place and clear the bits we don't need.
-
113  uint8_t *r = (uint8_t *)state.r;
-
114  memcpy(r, key, 16);
-
115  r[3] &= 0x0F;
-
116  r[4] &= 0xFC;
-
117  r[7] &= 0x0F;
-
118  r[8] &= 0xFC;
-
119  r[11] &= 0x0F;
-
120  r[12] &= 0xFC;
-
121  r[15] &= 0x0F;
-
122 
-
123  // Convert into little-endian if necessary.
-
124  littleToHost(state.r, NUM_LIMBS_128BIT);
+
75 #elif BIGNUMBER_LIMB_64BIT
+
76 #define lelimbtoh(x) (le64toh((x)))
+
77 #define htolelimb(x) (htole64((x)))
+
78 #endif
+
79 #if defined(CRYPTO_LITTLE_ENDIAN)
+
80 #define littleToHost(r,size) do { ; } while (0)
+
81 #else
+
82 #define littleToHost(r,size) \
+
83  do { \
+
84  for (uint8_t i = 0; i < (size); ++i) \
+
85  (r)[i] = lelimbtoh((r)[i]); \
+
86  } while (0)
+
87 #endif
+
88 
+
92 Poly1305::Poly1305()
+
93 {
+
94  state.chunkSize = 0;
+
95 }
+
96 
+
101 Poly1305::~Poly1305()
+
102 {
+
103  clean(state);
+
104 }
+
105 
+
113 void Poly1305::reset(const void *key)
+
114 {
+
115  // Copy the key into place and clear the bits we don't need.
+
116  uint8_t *r = (uint8_t *)state.r;
+
117  memcpy(r, key, 16);
+
118  r[3] &= 0x0F;
+
119  r[4] &= 0xFC;
+
120  r[7] &= 0x0F;
+
121  r[8] &= 0xFC;
+
122  r[11] &= 0x0F;
+
123  r[12] &= 0xFC;
+
124  r[15] &= 0x0F;
125 
-
126  // Reset the hashing process.
-
127  state.chunkSize = 0;
-
128  memset(state.h, 0, sizeof(state.h));
-
129 }
-
130 
-
142 void Poly1305::update(const void *data, size_t len)
-
143 {
-
144  // Break the input up into 128-bit chunks and process each in turn.
-
145  const uint8_t *d = (const uint8_t *)data;
-
146  while (len > 0) {
-
147  uint8_t size = 16 - state.chunkSize;
-
148  if (size > len)
-
149  size = len;
-
150  memcpy(((uint8_t *)state.c) + state.chunkSize, d, size);
-
151  state.chunkSize += size;
-
152  len -= size;
-
153  d += size;
-
154  if (state.chunkSize == 16) {
-
155  littleToHost(state.c, NUM_LIMBS_128BIT);
-
156  state.c[NUM_LIMBS_128BIT] = 1;
-
157  processChunk();
-
158  state.chunkSize = 0;
-
159  }
-
160  }
-
161 }
-
162 
-
179 void Poly1305::finalize(const void *nonce, void *token, size_t len)
-
180 {
-
181  dlimb_t carry;
-
182  uint8_t i;
-
183  limb_t t[NUM_LIMBS_256BIT + 1];
-
184 
-
185  // Pad and flush the final chunk.
-
186  if (state.chunkSize > 0) {
-
187  uint8_t *c = (uint8_t *)state.c;
-
188  c[state.chunkSize] = 1;
-
189  memset(c + state.chunkSize + 1, 0, 16 - state.chunkSize - 1);
-
190  littleToHost(state.c, NUM_LIMBS_128BIT);
-
191  state.c[NUM_LIMBS_128BIT] = 0;
-
192  processChunk();
-
193  }
-
194 
-
195  // At this point, processChunk() has left h as a partially reduced
-
196  // result that is less than (2^130 - 5) * 6. Perform one more
-
197  // reduction and a trial subtraction to produce the final result.
-
198 
-
199  // Multiply the high bits of h by 5 and add them to the 130 low bits.
-
200  carry = (dlimb_t)((state.h[NUM_LIMBS_128BIT] >> 2) +
-
201  (state.h[NUM_LIMBS_128BIT] & ~((limb_t)3)));
-
202  state.h[NUM_LIMBS_128BIT] &= 0x0003;
-
203  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
204  carry += state.h[i];
-
205  state.h[i] = (limb_t)carry;
-
206  carry >>= LIMB_BITS;
-
207  }
-
208  state.h[i] += (limb_t)carry;
-
209 
-
210  // Subtract (2^130 - 5) from h by computing t = h + 5 - 2^130.
-
211  // The "minus 2^130" step is implicit.
-
212  carry = 5;
-
213  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
214  carry += state.h[i];
-
215  t[i] = (limb_t)carry;
-
216  carry >>= LIMB_BITS;
-
217  }
-
218 
-
219  // Borrow occurs if bit 2^130 of the previous t result is zero.
-
220  // Carefully turn this into a selection mask so we can select either
-
221  // h or t as the final result. We don't care about the highest word
-
222  // of the result because we are about to drop it in the next step.
-
223  // We have to do it this way to avoid giving away any information
-
224  // about the value of h in the instruction timing.
-
225  limb_t mask = (~((t[NUM_LIMBS_128BIT] >> 2) & 1)) + 1;
-
226  limb_t nmask = ~mask;
-
227  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
228  state.h[i] = (state.h[i] & nmask) | (t[i] & mask);
-
229  }
-
230 
-
231  // Add the encrypted nonce and format the final hash.
-
232  memcpy(state.c, nonce, 16);
-
233  littleToHost(state.c, NUM_LIMBS_128BIT);
-
234  carry = 0;
-
235  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
236  carry += state.h[i];
-
237  carry += state.c[i];
-
238  state.h[i] = htolelimb((limb_t)carry);
-
239  carry >>= LIMB_BITS;
-
240  }
-
241  if (len > 16)
-
242  len = 16;
-
243  memcpy(token, state.h, len);
-
244 }
-
245 
-
251 void Poly1305::pad()
-
252 {
-
253  if (state.chunkSize != 0) {
-
254  memset(((uint8_t *)state.c) + state.chunkSize, 0, 16 - state.chunkSize);
-
255  littleToHost(state.c, NUM_LIMBS_128BIT);
-
256  state.c[NUM_LIMBS_128BIT] = 1;
-
257  processChunk();
-
258  state.chunkSize = 0;
-
259  }
-
260 }
-
261 
-
265 void Poly1305::clear()
-
266 {
-
267  clean(state);
-
268 }
-
269 
-
273 void Poly1305::processChunk()
-
274 {
-
275  limb_t t[NUM_LIMBS_256BIT + 1];
-
276 
-
277  // Compute h = ((h + c) * r) mod (2^130 - 5).
-
278 
-
279  // Start with h += c. We assume that h is less than (2^130 - 5) * 6
-
280  // and that c is less than 2^129, so the result will be less than 2^133.
-
281  dlimb_t carry = 0;
-
282  uint8_t i, j;
-
283  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
284  carry += state.h[i];
-
285  carry += state.c[i];
-
286  state.h[i] = (limb_t)carry;
-
287  carry >>= LIMB_BITS;
-
288  }
-
289 
-
290  // Multiply h by r. We know that r is less than 2^124 because the
-
291  // top 4 bits were AND-ed off by reset(). That makes h * r less
-
292  // than 2^257. Which is less than the (2^130 - 6)^2 we want for
-
293  // the modulo reduction step that follows.
-
294  carry = 0;
-
295  limb_t word = state.r[0];
-
296  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
297  carry += ((dlimb_t)(state.h[i])) * word;
-
298  t[i] = (limb_t)carry;
-
299  carry >>= LIMB_BITS;
-
300  }
-
301  t[NUM_LIMBS_130BIT] = (limb_t)carry;
-
302  for (i = 1; i < NUM_LIMBS_128BIT; ++i) {
-
303  word = state.r[i];
-
304  carry = 0;
-
305  for (j = 0; j < NUM_LIMBS_130BIT; ++j) {
-
306  carry += ((dlimb_t)(state.h[j])) * word;
-
307  carry += t[i + j];
-
308  t[i + j] = (limb_t)carry;
-
309  carry >>= LIMB_BITS;
-
310  }
-
311  t[i + NUM_LIMBS_130BIT] = (limb_t)carry;
-
312  }
-
313 
-
314  // Reduce h * r modulo (2^130 - 5) by multiplying the high 130 bits by 5
-
315  // and adding them to the low 130 bits. See the explaination in the
-
316  // comments for Curve25519::reduce() for a description of how this works.
-
317  carry = ((dlimb_t)(t[NUM_LIMBS_128BIT] >> 2)) +
-
318  (t[NUM_LIMBS_128BIT] & ~((limb_t)3));
-
319  t[NUM_LIMBS_128BIT] &= 0x0003;
-
320  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
321  // Shift the next word of t up by (LIMB_BITS - 2) bits and then
-
322  // multiply it by 5. Breaking it down, we can add the results
-
323  // of shifting up by LIMB_BITS and shifting up by (LIMB_BITS - 2).
-
324  // The main wrinkle here is that this can result in an intermediate
-
325  // carry that is (LIMB_BITS * 2 + 1) bits in size which doesn't
-
326  // fit within a dlimb_t variable. However, we can defer adding
-
327  // (word << LIMB_BITS) until after the "carry >>= LIMB_BITS" step
-
328  // because it won't affect the low bits of the carry.
-
329  word = t[i + NUM_LIMBS_130BIT];
-
330  carry += ((dlimb_t)word) << (LIMB_BITS - 2);
-
331  carry += t[i];
-
332  state.h[i] = (limb_t)carry;
-
333  carry >>= LIMB_BITS;
-
334  carry += word;
-
335  }
-
336  state.h[i] = (limb_t)(carry + t[NUM_LIMBS_128BIT]);
-
337 
-
338  // At this point, h is either the answer of reducing modulo (2^130 - 5)
-
339  // or it is at most 5 subtractions away from the answer we want.
-
340  // Leave it as-is for now with h less than (2^130 - 5) * 6. It is
-
341  // still within a range where the next h * r step will not overflow.
-
342 }
-
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
-
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:142
-
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:251
-
Poly1305::~Poly1305
~Poly1305()
Destroys this Poly1305 message authenticator after clearing all sensitive information.
Definition: Poly1305.cpp:98
-
Poly1305::Poly1305
Poly1305()
Constructs a new Poly1305 message authenticator.
Definition: Poly1305.cpp:89
-
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
+
126  // Convert into little-endian if necessary.
+
127  littleToHost(state.r, NUM_LIMBS_128BIT);
+
128 
+
129  // Reset the hashing process.
+
130  state.chunkSize = 0;
+
131  memset(state.h, 0, sizeof(state.h));
+
132 }
+
133 
+
145 void Poly1305::update(const void *data, size_t len)
+
146 {
+
147  // Break the input up into 128-bit chunks and process each in turn.
+
148  const uint8_t *d = (const uint8_t *)data;
+
149  while (len > 0) {
+
150  uint8_t size = 16 - state.chunkSize;
+
151  if (size > len)
+
152  size = len;
+
153  memcpy(((uint8_t *)state.c) + state.chunkSize, d, size);
+
154  state.chunkSize += size;
+
155  len -= size;
+
156  d += size;
+
157  if (state.chunkSize == 16) {
+
158  littleToHost(state.c, NUM_LIMBS_128BIT);
+
159  state.c[NUM_LIMBS_128BIT] = 1;
+
160  processChunk();
+
161  state.chunkSize = 0;
+
162  }
+
163  }
+
164 }
+
165 
+
182 void Poly1305::finalize(const void *nonce, void *token, size_t len)
+
183 {
+
184  dlimb_t carry;
+
185  uint8_t i;
+
186  limb_t t[NUM_LIMBS_256BIT + 1];
+
187 
+
188  // Pad and flush the final chunk.
+
189  if (state.chunkSize > 0) {
+
190  uint8_t *c = (uint8_t *)state.c;
+
191  c[state.chunkSize] = 1;
+
192  memset(c + state.chunkSize + 1, 0, 16 - state.chunkSize - 1);
+
193  littleToHost(state.c, NUM_LIMBS_128BIT);
+
194  state.c[NUM_LIMBS_128BIT] = 0;
+
195  processChunk();
+
196  }
+
197 
+
198  // At this point, processChunk() has left h as a partially reduced
+
199  // result that is less than (2^130 - 5) * 6. Perform one more
+
200  // reduction and a trial subtraction to produce the final result.
+
201 
+
202  // Multiply the high bits of h by 5 and add them to the 130 low bits.
+
203  carry = (dlimb_t)((state.h[NUM_LIMBS_128BIT] >> 2) +
+
204  (state.h[NUM_LIMBS_128BIT] & ~((limb_t)3)));
+
205  state.h[NUM_LIMBS_128BIT] &= 0x0003;
+
206  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
+
207  carry += state.h[i];
+
208  state.h[i] = (limb_t)carry;
+
209  carry >>= LIMB_BITS;
+
210  }
+
211  state.h[i] += (limb_t)carry;
+
212 
+
213  // Subtract (2^130 - 5) from h by computing t = h + 5 - 2^130.
+
214  // The "minus 2^130" step is implicit.
+
215  carry = 5;
+
216  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
+
217  carry += state.h[i];
+
218  t[i] = (limb_t)carry;
+
219  carry >>= LIMB_BITS;
+
220  }
+
221 
+
222  // Borrow occurs if bit 2^130 of the previous t result is zero.
+
223  // Carefully turn this into a selection mask so we can select either
+
224  // h or t as the final result. We don't care about the highest word
+
225  // of the result because we are about to drop it in the next step.
+
226  // We have to do it this way to avoid giving away any information
+
227  // about the value of h in the instruction timing.
+
228  limb_t mask = (~((t[NUM_LIMBS_128BIT] >> 2) & 1)) + 1;
+
229  limb_t nmask = ~mask;
+
230  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
+
231  state.h[i] = (state.h[i] & nmask) | (t[i] & mask);
+
232  }
+
233 
+
234  // Add the encrypted nonce and format the final hash.
+
235  memcpy(state.c, nonce, 16);
+
236  littleToHost(state.c, NUM_LIMBS_128BIT);
+
237  carry = 0;
+
238  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
+
239  carry += state.h[i];
+
240  carry += state.c[i];
+
241  state.h[i] = htolelimb((limb_t)carry);
+
242  carry >>= LIMB_BITS;
+
243  }
+
244  if (len > 16)
+
245  len = 16;
+
246  memcpy(token, state.h, len);
+
247 }
+
248 
+
254 void Poly1305::pad()
+
255 {
+
256  if (state.chunkSize != 0) {
+
257  memset(((uint8_t *)state.c) + state.chunkSize, 0, 16 - state.chunkSize);
+
258  littleToHost(state.c, NUM_LIMBS_128BIT);
+
259  state.c[NUM_LIMBS_128BIT] = 1;
+
260  processChunk();
+
261  state.chunkSize = 0;
+
262  }
+
263 }
+
264 
+
268 void Poly1305::clear()
+
269 {
+
270  clean(state);
+
271 }
+
272 
+
276 void Poly1305::processChunk()
+
277 {
+
278  limb_t t[NUM_LIMBS_256BIT + 1];
+
279 
+
280  // Compute h = ((h + c) * r) mod (2^130 - 5).
+
281 
+
282  // Start with h += c. We assume that h is less than (2^130 - 5) * 6
+
283  // and that c is less than 2^129, so the result will be less than 2^133.
+
284  dlimb_t carry = 0;
+
285  uint8_t i, j;
+
286  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
+
287  carry += state.h[i];
+
288  carry += state.c[i];
+
289  state.h[i] = (limb_t)carry;
+
290  carry >>= LIMB_BITS;
+
291  }
+
292 
+
293  // Multiply h by r. We know that r is less than 2^124 because the
+
294  // top 4 bits were AND-ed off by reset(). That makes h * r less
+
295  // than 2^257. Which is less than the (2^130 - 6)^2 we want for
+
296  // the modulo reduction step that follows.
+
297  carry = 0;
+
298  limb_t word = state.r[0];
+
299  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
+
300  carry += ((dlimb_t)(state.h[i])) * word;
+
301  t[i] = (limb_t)carry;
+
302  carry >>= LIMB_BITS;
+
303  }
+
304  t[NUM_LIMBS_130BIT] = (limb_t)carry;
+
305  for (i = 1; i < NUM_LIMBS_128BIT; ++i) {
+
306  word = state.r[i];
+
307  carry = 0;
+
308  for (j = 0; j < NUM_LIMBS_130BIT; ++j) {
+
309  carry += ((dlimb_t)(state.h[j])) * word;
+
310  carry += t[i + j];
+
311  t[i + j] = (limb_t)carry;
+
312  carry >>= LIMB_BITS;
+
313  }
+
314  t[i + NUM_LIMBS_130BIT] = (limb_t)carry;
+
315  }
+
316 
+
317  // Reduce h * r modulo (2^130 - 5) by multiplying the high 130 bits by 5
+
318  // and adding them to the low 130 bits. See the explaination in the
+
319  // comments for Curve25519::reduce() for a description of how this works.
+
320  carry = ((dlimb_t)(t[NUM_LIMBS_128BIT] >> 2)) +
+
321  (t[NUM_LIMBS_128BIT] & ~((limb_t)3));
+
322  t[NUM_LIMBS_128BIT] &= 0x0003;
+
323  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
+
324  // Shift the next word of t up by (LIMB_BITS - 2) bits and then
+
325  // multiply it by 5. Breaking it down, we can add the results
+
326  // of shifting up by LIMB_BITS and shifting up by (LIMB_BITS - 2).
+
327  // The main wrinkle here is that this can result in an intermediate
+
328  // carry that is (LIMB_BITS * 2 + 1) bits in size which doesn't
+
329  // fit within a dlimb_t variable. However, we can defer adding
+
330  // (word << LIMB_BITS) until after the "carry >>= LIMB_BITS" step
+
331  // because it won't affect the low bits of the carry.
+
332  word = t[i + NUM_LIMBS_130BIT];
+
333  carry += ((dlimb_t)word) << (LIMB_BITS - 2);
+
334  carry += t[i];
+
335  state.h[i] = (limb_t)carry;
+
336  carry >>= LIMB_BITS;
+
337  carry += word;
+
338  }
+
339  state.h[i] = (limb_t)(carry + t[NUM_LIMBS_128BIT]);
+
340 
+
341  // At this point, h is either the answer of reducing modulo (2^130 - 5)
+
342  // or it is at most 5 subtractions away from the answer we want.
+
343  // Leave it as-is for now with h less than (2^130 - 5) * 6. It is
+
344  // still within a range where the next h * r step will not overflow.
+
345 }
+
Poly1305::finalize
void finalize(const void *nonce, void *token, size_t len)
Finalizes the authentication process and returns the token.
Definition: Poly1305.cpp:182
+
Poly1305::reset
void reset(const void *key)
Resets the Poly1305 message authenticator for a new session.
Definition: Poly1305.cpp:113
+
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:145
+
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:254
+
Poly1305::~Poly1305
~Poly1305()
Destroys this Poly1305 message authenticator after clearing all sensitive information.
Definition: Poly1305.cpp:101
+
Poly1305::Poly1305
Poly1305()
Constructs a new Poly1305 message authenticator.
Definition: Poly1305.cpp:92
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:268
diff --git a/Poly1305_8h_source.html b/Poly1305_8h_source.html index 5ea949bb..116c883b 100644 --- a/Poly1305_8h_source.html +++ b/Poly1305_8h_source.html @@ -143,17 +143,17 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
53 
54 #endif
Poly1305
Poly1305 message authenticator.
Definition: Poly1305.h:29
-
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
-
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:142
-
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:251
-
Poly1305::~Poly1305
~Poly1305()
Destroys this Poly1305 message authenticator after clearing all sensitive information.
Definition: Poly1305.cpp:98
-
Poly1305::Poly1305
Poly1305()
Constructs a new Poly1305 message authenticator.
Definition: Poly1305.cpp:89
-
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
+
Poly1305::finalize
void finalize(const void *nonce, void *token, size_t len)
Finalizes the authentication process and returns the token.
Definition: Poly1305.cpp:182
+
Poly1305::reset
void reset(const void *key)
Resets the Poly1305 message authenticator for a new session.
Definition: Poly1305.cpp:113
+
Poly1305::update
void update(const void *data, size_t len)
Updates the message authenticator with more data.
Definition: Poly1305.cpp:145
+
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:254
+
Poly1305::~Poly1305
~Poly1305()
Destroys this Poly1305 message authenticator after clearing all sensitive information.
Definition: Poly1305.cpp:101
+
Poly1305::Poly1305
Poly1305()
Constructs a new Poly1305 message authenticator.
Definition: Poly1305.cpp:92
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:268
diff --git a/PowerSave_8cpp_source.html b/PowerSave_8cpp_source.html index e62aebc0..802751db 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 b66e7f1c..569ae1eb 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 866a06ca..42143a75 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 b6e95ae0..7348ab38 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 e6185fe1..3f639dd0 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 7a0b79c3..012f3391 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 4b9d8ca0..b7a125bf 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 20576949..86df744f 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 5acbaea8..107e43ad 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 539d5efb..d7a211d8 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 252cff06..bfe5cacf 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 12e51cdc..f21d1139 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 19742da1..84307481 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 4e5931e6..f19116a4 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 4c069fdc..1cd063b1 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 86b44faa..7f301392 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 cb58192b..9e3b0fb7 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 ec5b8d52..81248518 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 96767eb3..f742a834 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 f4a84c25..3f9434f0 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 08f1ab8a..b488e993 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 a24217a4..9e9d205b 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 1f52ca2f..1a9e8cdc 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 ff8f32dc..8ce231d9 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 2852f700..b21c80f1 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 56c85db7..9351ade2 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 c860fb54..76a5f7cf 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 5a3faa41..86aad8e9 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 ad0f388c..1c181b69 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 b5095d42..75c3a123 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 db03d150..8d9d9cc7 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 fc56483f..d81d831d 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 1d10bddb..e4f735e9 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 b2c653e7..1ffe47ff 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 2f1daea4..e2ff5508 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 ce2e2274..8755aff4 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 9ea5ed30..a138f3ca 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 db4a495c..1690bdda 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 913ec891..5cd44b26 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 c75d153a..eef30bad 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 34a9f80d..8be4916f 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 cc6b215b..42dcb2c0 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 c78357e9..6bbefd78 100644 --- a/alarm_clock.html +++ b/alarm_clock.html @@ -140,7 +140,7 @@ Completed Clock diff --git a/annotated.html b/annotated.html index 010f4d0e..9db8a698 100644 --- a/annotated.html +++ b/annotated.html @@ -136,46 +136,48 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); oCListFieldField that manages selection from a static list of items oCLoginShellCommand-line shell access via a login shell oCMelodyPlays a melody on a digital output pin using tone() -oCNoiseSourceAbstract base class for random noise sources -oCOFBImplementation of the Output Feedback (OFB) mode for 128-bit block ciphers -oCOFBCommonConcrete base class to assist with implementing OFB for 128-bit block ciphers -oCOMACImplementation of the OMAC message authenticator -oCP521Elliptic curve operations with the NIST P-521 curve -oCPoly1305Poly1305 message authenticator -oCRingOscillatorNoiseSourceProcesses the signal from a ring oscillator based noise source -oCRNGClassPseudo random number generator suitable for cryptography -oCRTCBase class for realtime clock handlers -oCRTCAlarmStores alarm information from a realtime clock chip -oCRTCDateStores date information from a realtime clock chip -oCRTCTimeStores time information from a realtime clock chip -oCSHA256SHA-256 hash algorithm -oCSHA3_256SHA3-256 hash algorithm -oCSHA3_512SHA3-512 hash algorithm -oCSHA512SHA-512 hash algorithm -oCSHAKEAbstract base class for the SHAKE Extendable-Output Functions (XOFs) -oCSHAKE128SHAKE Extendable-Output Function (XOF) with 128-bit security -oCSHAKE256SHAKE Extendable-Output Function (XOF) with 256-bit security -oCShellCommand-line shell access -oCShellArgumentsConvenience class that encapsulates an array of shell command arguments -oCSoftI2CBit-banged implementation of an I2C master -oCSpeckSpeck block cipher with a 128-bit block size -oCSpeckSmallSpeck block cipher with a 128-bit block size (small-memory version) -oCSpeckTinySpeck block cipher with a 128-bit block size (tiny-memory version) -oCTerminalExtended stream interface for terminal operations -oCTextFieldField that displays a read-only text value -oCTimeFieldField that manages the display and editing of a time value -oCTransistorNoiseSourceProcesses the signal from a transistor-based noise source -oCXOFAbstract base class for Extendable-Output Functions (XOFs) -oCXTSImplementation of the XTS mode for 128-bit block ciphers -oCXTSCommonConcrete base class to assist with implementing XTS mode for 128-bit block ciphers -oCXTSSingleKeyImplementation of the single-key XTS mode for 128-bit block ciphers -\CXTSSingleKeyCommonConcrete base class to assist with implementing single-key XTS mode for 128-bit block ciphers +oCNewHopeNewHope post-quantum key exchange algorithm +oCNewHopePolyNewHope polynomial representation +oCNoiseSourceAbstract base class for random noise sources +oCOFBImplementation of the Output Feedback (OFB) mode for 128-bit block ciphers +oCOFBCommonConcrete base class to assist with implementing OFB for 128-bit block ciphers +oCOMACImplementation of the OMAC message authenticator +oCP521Elliptic curve operations with the NIST P-521 curve +oCPoly1305Poly1305 message authenticator +oCRingOscillatorNoiseSourceProcesses the signal from a ring oscillator based noise source +oCRNGClassPseudo random number generator suitable for cryptography +oCRTCBase class for realtime clock handlers +oCRTCAlarmStores alarm information from a realtime clock chip +oCRTCDateStores date information from a realtime clock chip +oCRTCTimeStores time information from a realtime clock chip +oCSHA256SHA-256 hash algorithm +oCSHA3_256SHA3-256 hash algorithm +oCSHA3_512SHA3-512 hash algorithm +oCSHA512SHA-512 hash algorithm +oCSHAKEAbstract base class for the SHAKE Extendable-Output Functions (XOFs) +oCSHAKE128SHAKE Extendable-Output Function (XOF) with 128-bit security +oCSHAKE256SHAKE Extendable-Output Function (XOF) with 256-bit security +oCShellCommand-line shell access +oCShellArgumentsConvenience class that encapsulates an array of shell command arguments +oCSoftI2CBit-banged implementation of an I2C master +oCSpeckSpeck block cipher with a 128-bit block size +oCSpeckSmallSpeck block cipher with a 128-bit block size (small-memory version) +oCSpeckTinySpeck block cipher with a 128-bit block size (tiny-memory version) +oCTerminalExtended stream interface for terminal operations +oCTextFieldField that displays a read-only text value +oCTimeFieldField that manages the display and editing of a time value +oCTransistorNoiseSourceProcesses the signal from a transistor-based noise source +oCXOFAbstract base class for Extendable-Output Functions (XOFs) +oCXTSImplementation of the XTS mode for 128-bit block ciphers +oCXTSCommonConcrete base class to assist with implementing XTS mode for 128-bit block ciphers +oCXTSSingleKeyImplementation of the single-key XTS mode for 128-bit block ciphers +\CXTSSingleKeyCommonConcrete base class to assist with implementing single-key XTS mode for 128-bit block ciphers diff --git a/blink-blink_8dox.html b/blink-blink_8dox.html index ff6a218c..6d5f6c10 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 986813d0..1382e9ee 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 77ac1bb0..95cd55d3 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 6d6224fc..d1c16b81 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 a867e848..a51f3baf 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 751a1721..9aabd98a 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 1f8999e8..0224c07a 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 570c4a78..2ddde122 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 8aae3c47..aaa3b25c 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 83c6ad29..fa4c465e 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 5e46bb31..1b3c030c 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 3a30b3fe..88502538 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 94ba73cc..6b6bea50 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 c200c0ca..c4d31ae1 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 6fc603bc..3096dbca 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 cec199ed..b279dde9 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 d0283c14..e933a3d2 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 8bd77f1e..54b000e4 100644 --- a/classAuthenticatedCipher.html +++ b/classAuthenticatedCipher.html @@ -351,7 +351,7 @@ virtual  diff --git a/classBLAKE2b-members.html b/classBLAKE2b-members.html index 2d1355ab..c83857b1 100644 --- a/classBLAKE2b-members.html +++ b/classBLAKE2b-members.html @@ -113,7 +113,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBLAKE2b.html b/classBLAKE2b.html index eb2bf8e0..297ec58c 100644 --- a/classBLAKE2b.html +++ b/classBLAKE2b.html @@ -600,7 +600,7 @@ Additional Inherited Members diff --git a/classBLAKE2s-members.html b/classBLAKE2s-members.html index d60ceb04..2af26e58 100644 --- a/classBLAKE2s-members.html +++ b/classBLAKE2s-members.html @@ -112,7 +112,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBLAKE2s.html b/classBLAKE2s.html index 0531bbba..e22815e3 100644 --- a/classBLAKE2s.html +++ b/classBLAKE2s.html @@ -600,7 +600,7 @@ Additional Inherited Members diff --git a/classBigNumberUtil-members.html b/classBigNumberUtil-members.html index f8f03763..d04fdcbd 100644 --- a/classBigNumberUtil-members.html +++ b/classBigNumberUtil-members.html @@ -106,7 +106,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBigNumberUtil.html b/classBigNumberUtil.html index 17da9b1c..781c5a96 100644 --- a/classBigNumberUtil.html +++ b/classBigNumberUtil.html @@ -143,7 +143,7 @@ Static Public Member Functions

Big numbers are represented as arrays of limb_t words, which may be 8 bits, 16 bits, or 32 bits in size depending upon how the library was configured. For AVR, 16 bit limbs usually give the best performance.

Limb arrays are ordered from the least significant word to the most significant.

-

Definition at line 59 of file BigNumberUtil.h.

+

Definition at line 71 of file BigNumberUtil.h.

Member Function Documentation

@@ -202,7 +202,7 @@ Static Public Member Functions
Returns
Returns 1 if there was a carry out or 0 if there was no carry out.
See Also
sub(), mul()
-

Definition at line 381 of file BigNumberUtil.cpp.

+

Definition at line 495 of file BigNumberUtil.cpp.

@@ -263,7 +263,7 @@ Static Public Member Functions
Returns
Returns 1 if there was a carry out or 0 if there was no carry out.
See Also
sub_P(), mul_P()
-

Definition at line 514 of file BigNumberUtil.cpp.

+

Definition at line 628 of file BigNumberUtil.cpp.

@@ -310,7 +310,7 @@ Static Public Member Functions
Returns
Returns 1 if x is zero or 0 otherwise.

This function attempts to make the determination in constant time.

-

Definition at line 647 of file BigNumberUtil.cpp.

+

Definition at line 761 of file BigNumberUtil.cpp.

@@ -377,7 +377,7 @@ Static Public Member Functions
See Also
mul_P()
-

Definition at line 432 of file BigNumberUtil.cpp.

+

Definition at line 546 of file BigNumberUtil.cpp.

@@ -444,7 +444,7 @@ Static Public Member Functions
See Also
mul()
-

Definition at line 566 of file BigNumberUtil.cpp.

+

Definition at line 680 of file BigNumberUtil.cpp.

@@ -505,7 +505,7 @@ Static Public Member Functions

If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.

See Also
unpackLE(), packBE()
-

Definition at line 294 of file BigNumberUtil.cpp.

+

Definition at line 375 of file BigNumberUtil.cpp.

@@ -566,7 +566,7 @@ Static Public Member Functions

If len is shorter than the length of limbs, then the number will be truncated to the least significant len bytes. If len is longer than the length of limbs, then the high bytes will be filled with zeroes.

See Also
unpackLE(), packBE()
-

Definition at line 208 of file BigNumberUtil.cpp.

+

Definition at line 264 of file BigNumberUtil.cpp.

@@ -627,7 +627,7 @@ Static Public Member Functions

It is assumed that x is less than y * 2 so that a single conditional subtraction will bring it down below y. The reduction is performed in constant time.

See Also
reduceQuick_P()
-

Definition at line 484 of file BigNumberUtil.cpp.

+

Definition at line 598 of file BigNumberUtil.cpp.

@@ -688,7 +688,7 @@ Static Public Member Functions

It is assumed that x is less than y * 2 so that a single conditional subtraction will bring it down below y. The reduction is performed in constant time.

See Also
reduceQuick()
-

Definition at line 620 of file BigNumberUtil.cpp.

+

Definition at line 734 of file BigNumberUtil.cpp.

@@ -749,7 +749,7 @@ Static Public Member Functions
Returns
Returns 1 if there was a borrow, or 0 if there was no borrow.
See Also
add(), mul()
-

Definition at line 408 of file BigNumberUtil.cpp.

+

Definition at line 522 of file BigNumberUtil.cpp.

@@ -810,7 +810,7 @@ Static Public Member Functions
Returns
Returns 1 if there was a borrow, or 0 if there was no borrow.
See Also
add_P(), mul_P()
-

Definition at line 541 of file BigNumberUtil.cpp.

+

Definition at line 655 of file BigNumberUtil.cpp.

@@ -871,7 +871,7 @@ Static Public Member Functions

If len is shorter than the length of limbs, then the high bytes will be filled with zeroes. If len is longer than the length of limbs, then the high bytes will be truncated and lost.

See Also
packBE(), unpackLE()
-

Definition at line 134 of file BigNumberUtil.cpp.

+

Definition at line 163 of file BigNumberUtil.cpp.

@@ -943,7 +943,7 @@ Static Public Member Functions diff --git a/classBitmap-members.html b/classBitmap-members.html index 5b3bdcb6..61c17cb7 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 e7837a65..5cb12f41 100644 --- a/classBitmap.html +++ b/classBitmap.html @@ -1745,7 +1745,7 @@ class DMD diff --git a/classBlinkLED-members.html b/classBlinkLED-members.html index e065b4bf..eaaacb03 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 eee03b96..db7ec0ae 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 9b243f1d..558b7e20 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 afb03ae1..f415ea6e 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 7ee24a98..65603459 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 49092d6e..22d787f1 100644 --- a/classBoolField.html +++ b/classBoolField.html @@ -506,7 +506,7 @@ LiquidCrystal *  diff --git a/classCBC-members.html b/classCBC-members.html index dad064de..28d36cd6 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 156546f9..4a5bc7c4 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 07908507..9f3e49c6 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 cde88453..a91f5ebc 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 65dd68cd..b553d63f 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 5ba50165..7f0211f8 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 d9c0641e..59731ac3 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 fd2c8ceb..4cb8621a 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 7a68aebe..0f18dd92 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 46c7698b..1308e09a 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 af0a9afc..9fd46e4c 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 602a7877..7eee6476 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 0423ea62..2d88ca35 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 e1a537f0..07826e38 100644 --- a/classChaCha.html +++ b/classChaCha.html @@ -673,7 +673,7 @@ class ChaChaPoly< diff --git a/classChaChaPoly-members.html b/classChaChaPoly-members.html index 28c9f6dd..1cb220c4 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 7f906bea..f8567d12 100644 --- a/classChaChaPoly.html +++ b/classChaChaPoly.html @@ -665,7 +665,7 @@ virtual  diff --git a/classCharlieplex-members.html b/classCharlieplex-members.html index 5264003e..c0929e72 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 fd1d76a0..d7983d2e 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 cd8035ab..ecea4605 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 a9d6221f..ceb0bdcc 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 9b3c5113..12f41dab 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 d0e09851..90efcd8a 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 5cfc7d50..c23fe146 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 889ada79..27770d56 100644 --- a/classCurve25519.html +++ b/classCurve25519.html @@ -118,7 +118,7 @@ class Ed25519

Detailed Description

Diffie-Hellman key agreement based on the elliptic curve modulo 2^255 - 19.

Note
The public functions in this class need a substantial amount of stack space to store intermediate results while the curve function is being evaluated. About 1k of free stack space is recommended for safety.
-

References: http://cr.yp.to/ecdh.html https://tools.ietf.org/html/draft-irtf-cfrg-curves-02

+

References: http://cr.yp.to/ecdh.html, RFC 7748

See Also
Ed25519

Definition at line 30 of file Curve25519.h.

@@ -185,7 +185,7 @@ class Ed25519
// The "k" value can now be used to generate session keys for encryption.
...
-

Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02

+

Reference: RFC 7748

See Also
dh2()

Definition at line 244 of file Curve25519.cpp.

@@ -233,7 +233,7 @@ class Ed25519
Returns
Returns true if the key exchange was successful, or false if the k value is invalid.
-

Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02

+

Reference: RFC 7748

See Also
dh1()

Definition at line 282 of file Curve25519.cpp.

@@ -289,7 +289,7 @@ class Ed25519

This function is provided to assist with implementating other algorithms with the curve. Normally applications should use dh1() and dh2() directly instead.

Returns
Returns true if the function was evaluated; false if x is not a proper member of the field modulo (2^255 - 19).
-

Reference: https://tools.ietf.org/html/draft-irtf-cfrg-curves-02

+

Reference: RFC 7748

See Also
dh1(), dh2()

Definition at line 79 of file Curve25519.cpp.

@@ -303,7 +303,7 @@ class Ed25519 diff --git a/classDMD-members.html b/classDMD-members.html index 7acd3353..cf45ca01 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 32a8d978..e52957aa 100644 --- a/classDMD.html +++ b/classDMD.html @@ -755,7 +755,7 @@ Multiple panels diff --git a/classDS1307RTC-members.html b/classDS1307RTC-members.html index bc6d5957..2527ed07 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 7d6fb3e2..a2f1e8b2 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 a218a4b8..4a7a7c77 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 44f7b39f..89473c4b 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 0dd2ebb5..125bee07 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 bd63654b..cc655f30 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 88019c1b..938ad209 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 3a776f76..42a4e2eb 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 e043ede8..b4b72c93 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 b7c6ba8d..ee1190e9 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 7a95fa4e..c3ffd5bf 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 55993a3b..b3a9d433 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 84bc37f8..f0519699 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 9945a2ff..eb6a11dd 100644 --- a/classEd25519.html +++ b/classEd25519.html @@ -132,7 +132,7 @@ Static Public Member Functions
...
}
Note
The public functions in this class need a substantial amount of stack space to store intermediate results while the curve function is being evaluated. About 1.5k of free stack space is recommended for safety.
-

References: https://tools.ietf.org/id/draft-josefsson-eddsa-ed25519-02.txt

+

References: https://tools.ietf.org/html/draft-irtf-cfrg-eddsa-05

See Also
Curve25519

Definition at line 29 of file Ed25519.h.

@@ -354,7 +354,7 @@ Static Public Member Functions diff --git a/classField-members.html b/classField-members.html index c01fdf92..a730e8ee 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 93b7cb6a..5b8b9401 100644 --- a/classField.html +++ b/classField.html @@ -424,7 +424,7 @@ class Form diff --git a/classForm-members.html b/classForm-members.html index 70e4c39e..827a7d4d 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 6ecbf436..bb63f64b 100644 --- a/classForm.html +++ b/classForm.html @@ -485,7 +485,7 @@ class Field diff --git a/classGCM-members.html b/classGCM-members.html index 83389761..ecaeb723 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 a2e7f8a9..1c66ea3a 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 c60c0397..c6c9320a 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 082f98fe..d77e9db5 100644 --- a/classGCMCommon.html +++ b/classGCMCommon.html @@ -736,7 +736,7 @@ Protected Member Functions diff --git a/classGF128-members.html b/classGF128-members.html index 7a36decf..3f6e772a 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 987db9c7..a9bdfde3 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 7e4b4b55..90a31952 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 eb043402..ef60061f 100644 --- a/classGHASH.html +++ b/classGHASH.html @@ -265,7 +265,7 @@ void  diff --git a/classHash-members.html b/classHash-members.html index 30d229b2..b5640d9e 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 4fb18434..28e98ed0 100644 --- a/classHash.html +++ b/classHash.html @@ -575,7 +575,7 @@ Protected Member Functions diff --git a/classI2CMaster-members.html b/classI2CMaster-members.html index b7dea458..19fd5b51 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 d20af435..eadf78bb 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 6bcdcfc1..e085c9d6 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 d05f3b3c..e0e85087 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 b7718022..a5ae02e6 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 2e055721..e1729b55 100644 --- a/classIntField.html +++ b/classIntField.html @@ -647,7 +647,7 @@ LiquidCrystal *  diff --git a/classKeccakCore-members.html b/classKeccakCore-members.html index 6b1a6d42..c3bb3b0c 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 b9585a31..5bfc35aa 100644 --- a/classKeccakCore.html +++ b/classKeccakCore.html @@ -475,7 +475,7 @@ void  diff --git a/classLCD-members.html b/classLCD-members.html index 510110e9..bd751f5d 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 796c9090..ac54cd64 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 e1cc7841..40ae5bb4 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 c619363a..d7753c77 100644 --- a/classListField.html +++ b/classListField.html @@ -411,7 +411,7 @@ LiquidCrystal *  diff --git a/classLoginShell-members.html b/classLoginShell-members.html index 02796f95..95df9b30 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 f7352c0a..d78d254d 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 fe67eb64..a6ac4f96 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 542e7a9c..b61a7ab6 100644 --- a/classMelody.html +++ b/classMelody.html @@ -371,7 +371,7 @@ bool  diff --git a/classNewHope-members.html b/classNewHope-members.html new file mode 100644 index 00000000..24480265 --- /dev/null +++ b/classNewHope-members.html @@ -0,0 +1,107 @@ + + + + + + +ArduinoLibs: Member List + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + + + + +
+ +
+ +
+
+
+
NewHope Member List
+
+
+ +

This is the complete list of members for NewHope, including all inherited members.

+ + + + + + + +
keygen(uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk, Variant variant=Ref, const uint8_t *random_seed=0)NewHopestatic
Ref enum valueNewHope
shareda(uint8_t shared_key[NEWHOPE_SHAREDBYTES], const NewHopePoly &sk, uint8_t received[NEWHOPE_SENDBBYTES])NewHopestatic
sharedb(uint8_t shared_key[NEWHOPE_SHAREDBYTES], uint8_t send[NEWHOPE_SENDBBYTES], uint8_t received[NEWHOPE_SENDABYTES], Variant variant=Ref, const uint8_t *random_seed=0)NewHopestatic
Torref enum valueNewHope
Variant enum nameNewHope
+ + + + diff --git a/classNewHope.html b/classNewHope.html new file mode 100644 index 00000000..1e8c4667 --- /dev/null +++ b/classNewHope.html @@ -0,0 +1,366 @@ + + + + + + +ArduinoLibs: NewHope Class Reference + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + + + + +
+ +
+ +
+
+ +
+
NewHope Class Reference
+
+
+ +

NewHope post-quantum key exchange algorithm. + More...

+ +

#include <NewHope.h>

+ + + + + +

+Public Types

enum  Variant { Ref, +Torref + }
 Describes the variant of the New Hope algorithm to implement. More...
 
+ + + + + + + + + + +

+Static Public Member Functions

static void keygen (uint8_t send[NEWHOPE_SENDABYTES], NewHopePoly &sk, Variant variant=Ref, const uint8_t *random_seed=0)
 Generates the key pair for Alice in a New Hope key exchange. More...
 
static void sharedb (uint8_t shared_key[NEWHOPE_SHAREDBYTES], uint8_t send[NEWHOPE_SENDBBYTES], uint8_t received[NEWHOPE_SENDABYTES], Variant variant=Ref, const uint8_t *random_seed=0)
 Generates the public key and shared secret for Bob. More...
 
static void shareda (uint8_t shared_key[NEWHOPE_SHAREDBYTES], const NewHopePoly &sk, uint8_t received[NEWHOPE_SENDBBYTES])
 Generates the shared secret for Alice. More...
 
+

Detailed Description

+

NewHope post-quantum key exchange algorithm.

+

New Hope is an ephemeral key exchange algorithm, similar to Diffie-Hellman, which is believed to be resistant to quantum computers.

+
Note
The functions in this class need up to 7k of stack space to store temporary intermediate values in addition to up to 4k of memory in the application to store public and private key parameters. Due to these memory requirements, this class is only suitable for use on high-end ARM-based Arduino variants like the Arduino Due. It won't fit in the available memory on AVR-based Arduino variants.
+

Key exchange occurs between two parties, Alice and Bob, and results in a 32-byte (256-bit) shared secret. Alice's public key is 1824 bytes in size and Bob's public key is 2048 bytes in size.

+

Alice, either the client or the server depending upon the application, generates a key pair as follows:

+
uint8_t alice_public[NEWHOPE_SENDABYTES];
+
NewHopePoly alice_private;
+
NewHope::keygen(alice_public, alice_private);
+

Alice's application sends the contents of alice_public to Bob, who then performs the following operations:

+
uint8_t bob_public[NEWHOPE_SENDABYTES];
+
uint8_t shared_secret[NEWHOPE_SHAREDBYTES];
+
NewHope::sharedb(shared_secret, bob_public, alice_public);
+

Bob's application sends the contents of bob_public to Alice, and can then begin encrypting session traffic with shared_secret or some transformed version of it.

+

When Alice's application receives bob_public, the application performs the folllowing final steps to generate her version of the shared secret:

+
uint8_t shared_secret[NEWHOPE_SHAREDBYTES];
+
NewHope::shareda(shared_secret, alice_private, bob_public);
+

In the New Hope paper there are two versions of the algorithm described, referred to as "ref" and "torref" in author's reference C code. This class implements "ref" by default, but it is possible to enable the "torref" variant with an extra parameter on the keygen() and sharedb() function calls:

+
NewHope::keygen(alice_public, alice_private, NewHope::Torref);
+
NewHope::sharedb(shared_secret, bob_public, alice_public, NewHope::Torref);
+

The shareda() function is the same for both "ref" and "torref".

+

The "ref" and "torref" variants are not binary-compatible. Public keys generated with one variant will not work with the other variant. The application author must make a decision as to which variant they need and then use it universally. The paper contains more information on why an application may want to use "torref" instead of "ref".

+

Reference: https://cryptojedi.org/crypto/#newhope

+ +

Definition at line 48 of file NewHope.h.

+

Member Enumeration Documentation

+ +
+
+ + + + +
enum NewHope::Variant
+
+ +

Describes the variant of the New Hope algorithm to implement.

+ + + +
Enumerator
Ref  +

The standard "reference" version of the New Hope algorithm.

+
Torref  +

The alternative "torref" version of the New Hope algorithm.

+
Note
The NewHope class can be compiled without support for "torref" to save memory. In that case, Torref is identical to Ref.
+
+ +

Definition at line 55 of file NewHope.h.

+ +
+
+

Member Function Documentation

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NewHope::keygen (uint8_t send[NEWHOPE_SENDABYTES],
NewHopePolysk,
Variant variant = Ref,
const uint8_t * random_seed = 0 
)
+
+static
+
+ +

Generates the key pair for Alice in a New Hope key exchange.

+
Parameters
+ + + + + +
sendThe public key value for Alice to be sent to Bob.
skThe secret key value for Alice to be passed to shareda() later.
variantThe variant of the New Hope algorithm to use, usually Ref.
random_seedPoints to 64 bytes of random data to use to generate the key pair. This is intended for test vectors only and should be set to NULL in real applications.
+
+
+

The send value should be sent to Bob over the communications link and then it can be discarded. The sk value must be retained until the later call to sharedb().

+
See Also
sharedb(), shareda()
+ +

Definition at line 1111 of file NewHope.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
void NewHope::shareda (uint8_t shared_key[NEWHOPE_SHAREDBYTES],
const NewHopePolysk,
uint8_t received[NEWHOPE_SENDBBYTES] 
)
+
+static
+
+ +

Generates the shared secret for Alice.

+
Parameters
+ + + + +
shared_keyThe shared secret key.
skAlice's secret private key which was generated by keygen().
receivedThe public key value that was received from Bob.
+
+
+
See Also
sharedb(), keygen()
+ +

Definition at line 1231 of file NewHope.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NewHope::sharedb (uint8_t shared_key[NEWHOPE_SHAREDBYTES],
uint8_t send[NEWHOPE_SENDBBYTES],
uint8_t received[NEWHOPE_SENDABYTES],
Variant variant = Ref,
const uint8_t * random_seed = 0 
)
+
+static
+
+ +

Generates the public key and shared secret for Bob.

+
Parameters
+ + + + + + +
shared_keyThe shared secret key.
sendThe public key value for Bob to be sent to Alice.
receivedThe public key value that was received from Alice.
variantThe variant of the New Hope algorithm to use, usually Ref.
random_seedPoints to 32 bytes of random data to use to generate the temporary private key for Bob. This is intended for test vectors only and should be set to NULL in real applications.
+
+
+

The send value should be sent to Alice over the communications link and then it can be discarded. Bob can immediately start encrypting session traffic with shared_key or some transformed version of it.

+
See Also
shareda(), keygen()
+ +

Definition at line 1170 of file NewHope.cpp.

+ +
+
+
The documentation for this class was generated from the following files: +
+ + + + diff --git a/classNewHopePoly-members.html b/classNewHopePoly-members.html new file mode 100644 index 00000000..7a793f7a --- /dev/null +++ b/classNewHopePoly-members.html @@ -0,0 +1,105 @@ + + + + + + +ArduinoLibs: Member List + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + + + + +
+ +
+ +
+
+
+
NewHopePoly Member List
+
+
+ +

This is the complete list of members for NewHopePoly, including all inherited members.

+ + + + + +
clear()NewHopePoly
NewHope (defined in NewHopePoly)NewHopePolyfriend
NewHopePoly()NewHopePoly
~NewHopePoly()NewHopePoly
+ + + + diff --git a/classNewHopePoly.html b/classNewHopePoly.html new file mode 100644 index 00000000..9e5c4ed3 --- /dev/null +++ b/classNewHopePoly.html @@ -0,0 +1,138 @@ + + + + + + +ArduinoLibs: NewHopePoly Class Reference + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + + + + +
+ +
+ +
+
+ +
+
NewHopePoly Class Reference
+
+
+ +

NewHope polynomial representation. + More...

+ +

#include <NewHope.h>

+ + + + + + + + + + + +

+Public Member Functions

NewHopePoly ()
 Constructs a new "poly" object for the NewHope algorithm.
 
~NewHopePoly ()
 Clears sensitive data and destroys this "poly" object.
 
+void clear ()
 Clears sensitive data in this "poly" object.
 
+ + + +

+Friends

+class NewHope
 
+

Detailed Description

+

NewHope polynomial representation.

+

Reference: https://cryptojedi.org/crypto/#newhope

+ +

Definition at line 34 of file NewHope.h.

+

The documentation for this class was generated from the following files: +
+ + + + diff --git a/classNoiseSource-members.html b/classNoiseSource-members.html index 35e43f94..9667b57c 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 2a866b4f..a2ee28fd 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 74c5c62d..32a52380 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 83164122..57439d7e 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 87bdbf61..7263cd29 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 f50c7fb8..f4d929e3 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 0e26ff88..609d87a5 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 96fd3c48..17af49ac 100644 --- a/classOMAC.html +++ b/classOMAC.html @@ -387,7 +387,7 @@ void  diff --git a/classP521-members.html b/classP521-members.html index 3f369212..689f461f 100644 --- a/classP521-members.html +++ b/classP521-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classP521.html b/classP521.html index f5f111bd..44483219 100644 --- a/classP521.html +++ b/classP521.html @@ -180,7 +180,7 @@ Static Public Member Functions
See Also
generatePrivateKey(), verify()
-

Definition at line 498 of file P521.cpp.

+

Definition at line 497 of file P521.cpp.

@@ -249,7 +249,7 @@ Static Public Member Functions

Reference: RFC 6090

See Also
dh2()
-

Definition at line 209 of file P521.cpp.

+

Definition at line 208 of file P521.cpp.

@@ -297,7 +297,7 @@ Static Public Member Functions

Reference: RFC 6090

See Also
dh1()
-

Definition at line 230 of file P521.cpp.

+

Definition at line 229 of file P521.cpp.

@@ -352,7 +352,7 @@ Static Public Member Functions

This function provides access to the raw curve operation for testing purposes. Normally an application would use a higher-level function like dh1(), dh2(), sign(), or verify().

See Also
dh1(), sign()
-

Definition at line 136 of file P521.cpp.

+

Definition at line 135 of file P521.cpp.

@@ -388,7 +388,7 @@ Static Public Member Functions

The private key is generated with RNG.rand(). It is the caller's responsibility to ensure that the global random number pool has sufficient entropy to generate the 521 bits of the key safely before calling this function.

See Also
derivePublicKey(), sign()
-

Definition at line 467 of file P521.cpp.

+

Definition at line 466 of file P521.cpp.

@@ -460,7 +460,7 @@ Static Public Member Functions
Returns
Returns true if privateKey is valid, false if not.
See Also
isValidPublicKey()
-

Definition at line 525 of file P521.cpp.

+

Definition at line 524 of file P521.cpp.

@@ -496,7 +496,7 @@ Static Public Member Functions
Returns
Returns true if publicKey is valid, false if not.
See Also
isValidPrivateKey()
-

Definition at line 565 of file P521.cpp.

+

Definition at line 564 of file P521.cpp.

@@ -566,7 +566,7 @@ Static Public Member Functions

References: RFC 6090, RFC 6979

See Also
verify(), generatePrivateKey()
-

Definition at line 277 of file P521.cpp.

+

Definition at line 276 of file P521.cpp.

@@ -635,7 +635,7 @@ Static Public Member Functions
Returns
Returns true if the signature is valid for message; or false if the publicKey or signature is not valid.
See Also
sign()
-

Definition at line 374 of file P521.cpp.

+

Definition at line 373 of file P521.cpp.

@@ -646,7 +646,7 @@ Static Public Member Functions diff --git a/classPoly1305-members.html b/classPoly1305-members.html index 4700b005..5b5b82c0 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 62f36506..a0716294 100644 --- a/classPoly1305.html +++ b/classPoly1305.html @@ -183,7 +183,7 @@ void finalize() is called again, then the returned token value is undefined. Call reset() first to start a new authentication process.

See Also
reset(), update()
-

Definition at line 179 of file Poly1305.cpp.

+

Definition at line 182 of file Poly1305.cpp.

@@ -203,7 +203,7 @@ void 
See Also
update()
-

Definition at line 251 of file Poly1305.cpp.

+

Definition at line 254 of file Poly1305.cpp.

@@ -230,7 +230,7 @@ void 
See Also
update(), finalize()
-

Definition at line 110 of file Poly1305.cpp.

+

Definition at line 113 of file Poly1305.cpp.

@@ -269,7 +269,7 @@ void finalize() has already been called, then the behavior of update() will be undefined. Call reset() first to start a new authentication process.

See Also
pad(), reset(), finalize()
-

Definition at line 142 of file Poly1305.cpp.

+

Definition at line 145 of file Poly1305.cpp.

@@ -280,7 +280,7 @@ void  diff --git a/classRNGClass-members.html b/classRNGClass-members.html index 9f0bdb56..9190c962 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 0e40a06a..14fba436 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 9f7bd4dc..bda101f6 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 6bd4c864..6b950711 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 390e78aa..24b514b7 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 cb61f6e1..448c16d0 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 ada092dd..2a204508 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 d9c0afb5..46c7f680 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 03bdab26..a286e0cd 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 670af728..4e31ce1e 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 66f32690..8e1c2ed0 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 36a9b131..207889b7 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 16e53b18..8c90203b 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 db6b742b..55c3e8d2 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 da76f5cd..b021df8d 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 b744e9ba..5f74609e 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 2601b96f..d95f57ee 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 2bd97f88..3f75a450 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 b8c1e6a9..44e676c1 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 5101430c..b1ff6cc4 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 28505dfe..dcd47d7f 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 54c172a9..cc303536 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 e5a8dca7..b69ec22b 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 0b4947cd..ca4024c8 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 04f1ff14..2faf88e3 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 33c29bd8..def857e9 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 8f378a62..c584c05b 100644 --- a/classShellArguments.html +++ b/classShellArguments.html @@ -182,7 +182,7 @@ class Shell diff --git a/classSoftI2C-members.html b/classSoftI2C-members.html index 4a8eb29b..06df92d2 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 96933e09..f766dd97 100644 --- a/classSoftI2C.html +++ b/classSoftI2C.html @@ -346,7 +346,7 @@ unsigned int  diff --git a/classSpeck-members.html b/classSpeck-members.html index d7bf76f4..60a9a970 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 bf5fd1c3..bde2f44c 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 083e8287..8c28b925 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 e0bf3b49..d294164e 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 50123c0f..8f62b1ed 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 0b8689db..b1ede11b 100644 --- a/classSpeckTiny.html +++ b/classSpeckTiny.html @@ -428,7 +428,7 @@ class SpeckSmall< diff --git a/classTerminal-members.html b/classTerminal-members.html index d0bea661..3b3fd4ab 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 dccd49a3..b1c594a6 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 b67610d2..4adffbcb 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 19af10d3..d6a5c630 100644 --- a/classTextField.html +++ b/classTextField.html @@ -343,7 +343,7 @@ LiquidCrystal *  diff --git a/classTimeField-members.html b/classTimeField-members.html index 2f37e43d..47627448 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 616bb446..c1b3dd19 100644 --- a/classTimeField.html +++ b/classTimeField.html @@ -541,7 +541,7 @@ LiquidCrystal *  diff --git a/classTransistorNoiseSource-members.html b/classTransistorNoiseSource-members.html index a9038924..d5e08fe4 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 75a53dc7..0a344d75 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 40f70497..ebda931f 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 f7e0258a..3892d96d 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 4786acd4..d549cb87 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 6004cf03..34282319 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 cc123610..0bc61f8a 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 879d6b9b..b91c5400 100644 --- a/classXTSCommon.html +++ b/classXTSCommon.html @@ -497,7 +497,7 @@ class XTSSingleKeyCommon diff --git a/classXTSSingleKey-members.html b/classXTSSingleKey-members.html index d60daa79..71bb7ecc 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 6ae95e6f..f9e26541 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 993d8486..f232a4e0 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 f473e8db..ab389d4f 100644 --- a/classXTSSingleKeyCommon.html +++ b/classXTSSingleKeyCommon.html @@ -257,7 +257,7 @@ Protected Member Functions diff --git a/classes.html b/classes.html index 3b394ae7..e1e2dc94 100644 --- a/classes.html +++ b/classes.html @@ -90,56 +90,56 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
A | B | C | D | E | F | G | H | I | K | L | M | N | O | P | R | S | T | X
- - - - - - + + + + + + - + - + + + + + - - - - - - + - - - - - - + + + + + - - + + + +
  A  
-
Charlieplex   GCMCommon   
  O  
-
SHAKE128   
ChaseLEDs   GF128   SHAKE256   
AES128   Cipher   GHASH   OFB   Shell   
AES192   CTR   
  H  
-
OFBCommon   ShellArguments   
AES256   CTRCommon   OMAC   SoftI2C   
AESCommon   Curve25519   Hash   
  P  
-
Speck   
AuthenticatedCipher   
  D  
+
ChaseLEDs   GF128   NoiseSource   SHAKE128   
Cipher   GHASH   
  O  
+
SHAKE256   
AES128   CTR   
  H  
+
Shell   
AES192   CTRCommon   OFB   ShellArguments   
AES256   Curve25519   Hash   OFBCommon   SoftI2C   
AESCommon   
  D  
  I  
+
OMAC   Speck   
AuthenticatedCipher   
  P  
SpeckSmall   
  B  
-
P521   SpeckTiny   
DMD   I2CMaster   Poly1305   
  T  
+
DMD   I2CMaster   SpeckTiny   
DS1307RTC   IntField   P521   
  T  
BigNumberUtil   DS1307RTC   IntField   
  R  
+
BigNumberUtil   DS3231RTC   IRreceiver   Poly1305   
Bitmap   DS3232RTC   
  K  
+
  R  
+
Terminal   
BLAKE2b   
  E  
+
TextField   
BLAKE2s   KeccakCore   RingOscillatorNoiseSource   TimeField   
BlinkLED   EAX   
  L  
+
RNGClass   TransistorNoiseSource   
BlockCipher   EAXCommon   RTC   
  X  
Bitmap   DS3231RTC   IRreceiver   Terminal   
BLAKE2b   DS3232RTC   
  K  
-
RingOscillatorNoiseSource   TextField   
BLAKE2s   
  E  
-
RNGClass   TimeField   
BlinkLED   KeccakCore   RTC   TransistorNoiseSource   
BlockCipher   EAX   
  L  
-
RTCAlarm   
  X  
-
BoolField   EAXCommon   RTCDate   
BoolField   Ed25519   LCD   RTCAlarm   
  C  
-
Ed25519   LCD   RTCTime   XOF   
EEPROM24   ListField   
  S  
-
XTS   
CBC   
  F  
-
LoginShell   XTSCommon   
CBCCommon   
  M  
-
SHA256   XTSSingleKey   
CFB   Field   SHA3_256   XTSSingleKeyCommon   
CFBCommon   Form   Melody   SHA3_512   
ChaCha   
  G  
+
EEPROM24   ListField   RTCDate   XOF   
  F  
+
LoginShell   RTCTime   XTS   
CBC   
  M  
+
  S  
+
XTSCommon   
CBCCommon   Field   XTSSingleKey   
CFB   Form   Melody   SHA256   XTSSingleKeyCommon   
CFBCommon   
  G  
  N  
-
SHA512   
ChaChaPoly   SHAKE   
GCM   NoiseSource   
SHA3_256   
ChaCha   SHA3_512   
ChaChaPoly   GCM   NewHope   SHA512   
Charlieplex   GCMCommon   NewHopePoly   SHAKE   
A | B | C | D | E | F | G | H | I | K | L | M | N | O | P | R | S | T | X
diff --git a/crypto-rng-ring_8dox.html b/crypto-rng-ring_8dox.html index cb9b996a..3ff2fd23 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 8bac64d9..db080c92 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 cda22153..87a46f6b 100644 --- a/crypto.html +++ b/crypto.html @@ -90,6 +90,7 @@ Supported Algorithms
  • Extendable output functions (XOF's): SHAKE128, SHAKE256
  • Message authenticators: Poly1305, GHASH, OMAC
  • Public key algorithms: Curve25519, Ed25519, P521
  • +
  • Post-quantum algorithms: NewHope
  • Random number generation: RNG, TransistorNoiseSource, RingOscillatorNoiseSource
  • 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.

    @@ -233,6 +234,7 @@ Performance on AVR P521::derivePublicKey()46290msDerive a public key from a private key

    Where a cipher supports more than one key size (such as ChaCha), the values are typically almost identical for 128-bit and 256-bit keys so only the maximum is shown above.

    +

    Due to the memory requirements, NewHope is not yet possible on AVR-based Arduino systems.

    Performance on ARM

    All figures are for the Arduino Due running at 84 MHz:

    @@ -361,11 +363,23 @@ Performance on ARM P521::verify()3423msDigital signature verification P521::derivePublicKey()1503msDerive a public key from a private key + +NewHope::keygen(), Ref29msGenerate key pair for Alice, Ref version + +NewHope::sharedb(), Ref40msGenerate shared secret and public key for Bob, Ref version + +NewHope::shareda(), Ref9msGenerate shared secret for Alice, Ref version + +NewHope::keygen(), Torref40msGenerate key pair for Alice, Torref version + +NewHope::sharedb(), Torref52msGenerate shared secret and public key for Bob, Torref version + +NewHope::shareda(), Torref9msGenerate shared secret for Alice, Torref version diff --git a/crypto_8dox.html b/crypto_8dox.html index 14626b55..6de4e090 100644 --- a/crypto_8dox.html +++ b/crypto_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/crypto_rng.html b/crypto_rng.html index f710d2ad..a59500a5 100644 --- a/crypto_rng.html +++ b/crypto_rng.html @@ -190,7 +190,7 @@ Destroying secret data diff --git a/crypto_rng_ring.html b/crypto_rng_ring.html index e3b989f2..e19f43ef 100644 --- a/crypto_rng_ring.html +++ b/crypto_rng_ring.html @@ -151,7 +151,7 @@ Connecting to the Arduino diff --git a/dir_1586d320a3b1e622174530fde769cda9.html b/dir_1586d320a3b1e622174530fde769cda9.html index 63b9e35d..82ef32d1 100644 --- a/dir_1586d320a3b1e622174530fde769cda9.html +++ b/dir_1586d320a3b1e622174530fde769cda9.html @@ -102,7 +102,7 @@ Files diff --git a/dir_1de32c476debcefedf4aa8bb43bea551.html b/dir_1de32c476debcefedf4aa8bb43bea551.html index 7c42f87f..e38178f5 100644 --- a/dir_1de32c476debcefedf4aa8bb43bea551.html +++ b/dir_1de32c476debcefedf4aa8bb43bea551.html @@ -106,7 +106,7 @@ Files diff --git a/dir_3dd03323535933fb3f714c41ff7a94da.html b/dir_3dd03323535933fb3f714c41ff7a94da.html index b26b6607..792f51c5 100644 --- a/dir_3dd03323535933fb3f714c41ff7a94da.html +++ b/dir_3dd03323535933fb3f714c41ff7a94da.html @@ -94,7 +94,7 @@ Files diff --git a/dir_470c03f38356b1f63943514897cb198b.html b/dir_470c03f38356b1f63943514897cb198b.html new file mode 100644 index 00000000..0d5b988b --- /dev/null +++ b/dir_470c03f38356b1f63943514897cb198b.html @@ -0,0 +1,102 @@ + + + + + + +ArduinoLibs: NewHope Directory Reference + + + + + + + + + +
    +
    + + + + + + +
    +
    ArduinoLibs +
    +
    +
    + + + + + + + + +
    + +
    + + +
    +
    +
    +
    NewHope Directory Reference
    +
    +
    + + + + + + +

    +Files

    file  NewHope.cpp [code]
     
    file  NewHope.h [code]
     
    +
    + + + + diff --git a/dir_48f64e79f12bd77ba047e9e436ec978c.html b/dir_48f64e79f12bd77ba047e9e436ec978c.html index 03be08c8..d156a062 100644 --- a/dir_48f64e79f12bd77ba047e9e436ec978c.html +++ b/dir_48f64e79f12bd77ba047e9e436ec978c.html @@ -122,7 +122,7 @@ Files diff --git a/dir_5e87a7229a108582288ef7eda1233dc3.html b/dir_5e87a7229a108582288ef7eda1233dc3.html index 3ea5c455..de9ea749 100644 --- a/dir_5e87a7229a108582288ef7eda1233dc3.html +++ b/dir_5e87a7229a108582288ef7eda1233dc3.html @@ -94,7 +94,7 @@ Files diff --git a/dir_6591a2127a29f6cea3994dcb5b0596d1.html b/dir_6591a2127a29f6cea3994dcb5b0596d1.html index 48745481..6f96fed4 100644 --- a/dir_6591a2127a29f6cea3994dcb5b0596d1.html +++ b/dir_6591a2127a29f6cea3994dcb5b0596d1.html @@ -106,7 +106,7 @@ Files diff --git a/dir_7e6ab9b017486261fe80629d442521f0.html b/dir_7e6ab9b017486261fe80629d442521f0.html index 9cd87dd3..e0e7fa7f 100644 --- a/dir_7e6ab9b017486261fe80629d442521f0.html +++ b/dir_7e6ab9b017486261fe80629d442521f0.html @@ -94,7 +94,7 @@ Files diff --git a/dir_9a34040863d1190c0e01b23e6b44de01.html b/dir_9a34040863d1190c0e01b23e6b44de01.html index 870d0bdc..d39f4ded 100644 --- a/dir_9a34040863d1190c0e01b23e6b44de01.html +++ b/dir_9a34040863d1190c0e01b23e6b44de01.html @@ -96,7 +96,7 @@ Files diff --git a/dir_bc0718b08fb2015b8e59c47b2805f60c.html b/dir_bc0718b08fb2015b8e59c47b2805f60c.html index 088d36cb..6d5ecdf2 100644 --- a/dir_bc0718b08fb2015b8e59c47b2805f60c.html +++ b/dir_bc0718b08fb2015b8e59c47b2805f60c.html @@ -100,6 +100,8 @@ Directories   directory  Melody   +directory  NewHope +  directory  PowerSave   directory  RingOscillatorNoiseSource @@ -114,7 +116,7 @@ Directories diff --git a/dir_be059bf9978ae156837504b1b8a7568c.html b/dir_be059bf9978ae156837504b1b8a7568c.html index 8556356e..8154eadd 100644 --- a/dir_be059bf9978ae156837504b1b8a7568c.html +++ b/dir_be059bf9978ae156837504b1b8a7568c.html @@ -94,7 +94,7 @@ Files diff --git a/dir_e2ce51835550ba18edf07a8311722290.html b/dir_e2ce51835550ba18edf07a8311722290.html index a18ce88d..c2a9e3d2 100644 --- a/dir_e2ce51835550ba18edf07a8311722290.html +++ b/dir_e2ce51835550ba18edf07a8311722290.html @@ -240,7 +240,7 @@ Files diff --git a/dir_f34881fcf60f680b800190d5274dfaea.html b/dir_f34881fcf60f680b800190d5274dfaea.html index 0176db87..0db013c9 100644 --- a/dir_f34881fcf60f680b800190d5274dfaea.html +++ b/dir_f34881fcf60f680b800190d5274dfaea.html @@ -106,7 +106,7 @@ Files diff --git a/dir_f9b96888882c2691b8eeaeafd1b9501d.html b/dir_f9b96888882c2691b8eeaeafd1b9501d.html index e1a35e0c..3df84dd5 100644 --- a/dir_f9b96888882c2691b8eeaeafd1b9501d.html +++ b/dir_f9b96888882c2691b8eeaeafd1b9501d.html @@ -102,7 +102,7 @@ Files diff --git a/dmd-demo_8dox.html b/dmd-demo_8dox.html index fa9285b0..9ea1a9d4 100644 --- a/dmd-demo_8dox.html +++ b/dmd-demo_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/dmd-running-figure_8dox.html b/dmd-running-figure_8dox.html index fc4fac17..a587e56c 100644 --- a/dmd-running-figure_8dox.html +++ b/dmd-running-figure_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/dmd_demo.html b/dmd_demo.html index 2be94e4f..39c8af39 100644 --- a/dmd_demo.html +++ b/dmd_demo.html @@ -236,7 +236,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/dmd_running_figure.html b/dmd_running_figure.html index 9b12ad37..481d98eb 100644 --- a/dmd_running_figure.html +++ b/dmd_running_figure.html @@ -430,7 +430,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/files.html b/files.html index 97938539..6175aa46 100644 --- a/files.html +++ b/files.html @@ -173,63 +173,65 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); o*Melody.cpp o*Melody.h o*Mono5x7.h -o*NoiseSource.cpp -o*NoiseSource.h -o*OFB.cpp -o*OFB.h -o*OMAC.cpp -o*OMAC.h -o*P521.cpp -o*P521.h -o*Poly1305.cpp -o*Poly1305.h -o*PowerSave.cpp -o*PowerSave.h -o*RC5.h -o*RingOscillatorNoiseSource.cpp -o*RingOscillatorNoiseSource.h -o*RNG.cpp -o*RNG.h -o*RTC.cpp -o*RTC.h -o*SHA256.cpp -o*SHA256.h -o*SHA3.cpp -o*SHA3.h -o*SHA512.cpp -o*SHA512.h -o*SHAKE.cpp -o*SHAKE.h -o*Shell.cpp -o*Shell.h -o*SoftI2C.cpp -o*SoftI2C.h -o*Speck.cpp -o*Speck.h -o*SpeckSmall.cpp -o*SpeckSmall.h -o*SpeckTiny.cpp -o*SpeckTiny.h -o*TelnetDefs.h -o*Terminal.cpp -o*Terminal.h -o*TextField.cpp -o*TextField.h -o*TimeField.cpp -o*TimeField.h -o*TransistorNoiseSource.cpp -o*TransistorNoiseSource.h -o*USBKeysExtra.h -o*XOF.cpp -o*XOF.h -o*XTS.cpp -\*XTS.h +o*NewHope.cpp +o*NewHope.h +o*NoiseSource.cpp +o*NoiseSource.h +o*OFB.cpp +o*OFB.h +o*OMAC.cpp +o*OMAC.h +o*P521.cpp +o*P521.h +o*Poly1305.cpp +o*Poly1305.h +o*PowerSave.cpp +o*PowerSave.h +o*RC5.h +o*RingOscillatorNoiseSource.cpp +o*RingOscillatorNoiseSource.h +o*RNG.cpp +o*RNG.h +o*RTC.cpp +o*RTC.h +o*SHA256.cpp +o*SHA256.h +o*SHA3.cpp +o*SHA3.h +o*SHA512.cpp +o*SHA512.h +o*SHAKE.cpp +o*SHAKE.h +o*Shell.cpp +o*Shell.h +o*SoftI2C.cpp +o*SoftI2C.h +o*Speck.cpp +o*Speck.h +o*SpeckSmall.cpp +o*SpeckSmall.h +o*SpeckTiny.cpp +o*SpeckTiny.h +o*TelnetDefs.h +o*Terminal.cpp +o*Terminal.h +o*TextField.cpp +o*TextField.h +o*TimeField.cpp +o*TimeField.h +o*TransistorNoiseSource.cpp +o*TransistorNoiseSource.h +o*USBKeysExtra.h +o*XOF.cpp +o*XOF.h +o*XTS.cpp +\*XTS.h diff --git a/functions.html b/functions.html index 7541ab4d..d540bcbe 100644 --- a/functions.html +++ b/functions.html @@ -193,7 +193,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_b.html b/functions_b.html index df4cd959..9b2b70d4 100644 --- a/functions_b.html +++ b/functions_b.html @@ -208,7 +208,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_c.html b/functions_c.html index 4ded830a..e9e07704 100644 --- a/functions_c.html +++ b/functions_c.html @@ -186,6 +186,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , GHASH , Hash , KeccakCore +, NewHopePoly , OFBCommon , OMAC , Poly1305 @@ -206,13 +207,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • Color : Bitmap +, Terminal
  • color() : Terminal
  • -
  • Color -: Terminal -
  • columns() : Terminal
  • @@ -263,7 +262,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_d.html b/functions_d.html index 06209f25..27efeb07 100644 --- a/functions_d.html +++ b/functions_d.html @@ -300,7 +300,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_e.html b/functions_e.html index 31d402bb..261caa1e 100644 --- a/functions_e.html +++ b/functions_e.html @@ -219,7 +219,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_enum.html b/functions_enum.html index 113032f8..58db6220 100644 --- a/functions_enum.html +++ b/functions_enum.html @@ -107,11 +107,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • ScreenSaverMode : LCD
  • +
  • Variant +: NewHope +
  • diff --git a/functions_eval.html b/functions_eval.html index 99593704..f4e5febd 100644 --- a/functions_eval.html +++ b/functions_eval.html @@ -146,12 +146,18 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • Red : Terminal
  • +
  • Ref +: NewHope +
  • Serial : Terminal
  • Telnet : Terminal
  • +
  • Torref +: NewHope +
  • White : Terminal
  • @@ -162,7 +168,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_f.html b/functions_f.html index 78eb0304..4f8959a8 100644 --- a/functions_f.html +++ b/functions_f.html @@ -165,12 +165,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • flush() : Terminal
  • -
  • font() -: Bitmap -
  • Font : Bitmap
  • +
  • font() +: Bitmap +
  • form() : Field
  • @@ -187,7 +187,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func.html b/functions_func.html index 08151e76..c9cfad92 100644 --- a/functions_func.html +++ b/functions_func.html @@ -186,7 +186,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_b.html b/functions_func_b.html index 825ad43c..030d3982 100644 --- a/functions_func_b.html +++ b/functions_func_b.html @@ -194,7 +194,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_c.html b/functions_func_c.html index 97319852..8d66d4f3 100644 --- a/functions_func_c.html +++ b/functions_func_c.html @@ -185,6 +185,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , GHASH , Hash , KeccakCore +, NewHopePoly , OFBCommon , OMAC , Poly1305 @@ -253,7 +254,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_d.html b/functions_func_d.html index 0f1f3d19..bbc69d0e 100644 --- a/functions_func_d.html +++ b/functions_func_d.html @@ -262,7 +262,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_e.html b/functions_func_e.html index db5e22d0..61889e5c 100644 --- a/functions_func_e.html +++ b/functions_func_e.html @@ -218,7 +218,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_f.html b/functions_func_f.html index 263aa0ed..1a9a3d57 100644 --- a/functions_func_f.html +++ b/functions_func_f.html @@ -180,7 +180,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_g.html b/functions_func_g.html index 5735a58e..45530e12 100644 --- a/functions_func_g.html +++ b/functions_func_g.html @@ -144,7 +144,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_h.html b/functions_func_h.html index ed7f0047..f4d10de3 100644 --- a/functions_func_h.html +++ b/functions_func_h.html @@ -161,7 +161,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_i.html b/functions_func_i.html index e392c28a..92b95884 100644 --- a/functions_func_i.html +++ b/functions_func_i.html @@ -202,7 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_k.html b/functions_func_k.html index a5d799d6..86158711 100644 --- a/functions_func_k.html +++ b/functions_func_k.html @@ -127,6 +127,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • KeccakCore() : KeccakCore
  • +
  • keygen() +: NewHope +
  • keySize() : AES128 , AES192 @@ -150,7 +153,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_l.html b/functions_func_l.html index 36a01319..839ec4bf 100644 --- a/functions_func_l.html +++ b/functions_func_l.html @@ -131,7 +131,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : Field
  • LCD() -: LCD +: LCD
  • led() : Charlieplex @@ -157,7 +157,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_m.html b/functions_func_m.html index 2dd7bad6..1ba714db 100644 --- a/functions_func_m.html +++ b/functions_func_m.html @@ -160,7 +160,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_n.html b/functions_func_n.html index ff11de95..455461f7 100644 --- a/functions_func_n.html +++ b/functions_func_n.html @@ -124,6 +124,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');  

    - n -

      +
    • NewHopePoly() +: NewHopePoly +
    • nextField() : Form
    • @@ -143,7 +146,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_o.html b/functions_func_o.html index 9837daac..a93116cb 100644 --- a/functions_func_o.html +++ b/functions_func_o.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_p.html b/functions_func_p.html index 22e0cc68..25d36836 100644 --- a/functions_func_p.html +++ b/functions_func_p.html @@ -179,7 +179,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_r.html b/functions_func_r.html index adef9bfe..84ad53e6 100644 --- a/functions_func_r.html +++ b/functions_func_r.html @@ -228,7 +228,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_s.html b/functions_func_s.html index 62fbd573..6d0ad93d 100644 --- a/functions_func_s.html +++ b/functions_func_s.html @@ -336,6 +336,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    • SHAKE256() : SHAKE256
    • +
    • shareda() +: NewHope +
    • +
    • sharedb() +: NewHope +
    • Shell() : Shell
    • @@ -421,7 +427,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_t.html b/functions_func_t.html index a2c43707..2625c913 100644 --- a/functions_func_t.html +++ b/functions_func_t.html @@ -161,7 +161,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_u.html b/functions_func_u.html index 8c0c15bb..101966ce 100644 --- a/functions_func_u.html +++ b/functions_func_u.html @@ -167,7 +167,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_v.html b/functions_func_v.html index 6e5b52f7..b4798052 100644 --- a/functions_func_v.html +++ b/functions_func_v.html @@ -139,7 +139,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_w.html b/functions_func_w.html index 5147e1da..2febc323 100644 --- a/functions_func_w.html +++ b/functions_func_w.html @@ -166,7 +166,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_x.html b/functions_func_x.html index f559a171..96d60fcb 100644 --- a/functions_func_x.html +++ b/functions_func_x.html @@ -143,7 +143,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_func_~.html b/functions_func_~.html index d84fb33a..59cccefd 100644 --- a/functions_func_~.html +++ b/functions_func_~.html @@ -181,6 +181,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    • ~LoginShell() : LoginShell
    • +
    • ~NewHopePoly() +: NewHopePoly +
    • ~NoiseSource() : NoiseSource
    • @@ -242,7 +245,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_g.html b/functions_g.html index aef1ce68..aa17da74 100644 --- a/functions_g.html +++ b/functions_g.html @@ -148,7 +148,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_h.html b/functions_h.html index 89cfc50f..eb5d0c38 100644 --- a/functions_h.html +++ b/functions_h.html @@ -166,7 +166,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_i.html b/functions_i.html index 0c3e5661..ba9d4f1b 100644 --- a/functions_i.html +++ b/functions_i.html @@ -206,7 +206,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_k.html b/functions_k.html index 16d2a342..df75da8b 100644 --- a/functions_k.html +++ b/functions_k.html @@ -128,6 +128,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    • KeccakCore() : KeccakCore
    • +
    • keygen() +: NewHope +
    • keySize() : AES128 , AES192 @@ -151,7 +154,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_l.html b/functions_l.html index 94848bb6..e70a612f 100644 --- a/functions_l.html +++ b/functions_l.html @@ -132,7 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : Field
    • LCD() -: LCD +: LCD
    • led() : Charlieplex @@ -161,7 +161,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_m.html b/functions_m.html index efb77552..e122a7ad 100644 --- a/functions_m.html +++ b/functions_m.html @@ -151,12 +151,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
    • minValue() : IntField
    • -
    • Mode -: Terminal -
    • mode() : Terminal
    • +
    • Mode +: Terminal +
    • month : RTCDate
    • @@ -174,7 +174,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_n.html b/functions_n.html index ec9bde3a..af1e8cfd 100644 --- a/functions_n.html +++ b/functions_n.html @@ -125,6 +125,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      Here is a list of all documented class members with links to the class documentation for each member:

      - n -

        +
      • NewHopePoly() +: NewHopePoly +
      • nextField() : Form
      • @@ -150,7 +153,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_o.html b/functions_o.html index 9d6b99f6..a6954655 100644 --- a/functions_o.html +++ b/functions_o.html @@ -150,7 +150,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_p.html b/functions_p.html index 77e0d2a9..012f91ba 100644 --- a/functions_p.html +++ b/functions_p.html @@ -183,7 +183,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_r.html b/functions_r.html index 0da67735..50016de8 100644 --- a/functions_r.html +++ b/functions_r.html @@ -177,6 +177,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      • reduceQuick_P() : BigNumberUtil
      • +
      • Ref +: NewHope +
      • refresh() : Charlieplex , DMD @@ -232,7 +235,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_rela.html b/functions_rela.html index 63fa06e2..e3dd103a 100644 --- a/functions_rela.html +++ b/functions_rela.html @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_s.html b/functions_s.html index 9d6cda88..cd42bb47 100644 --- a/functions_s.html +++ b/functions_s.html @@ -350,6 +350,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      • SHAKE256() : SHAKE256
      • +
      • shareda() +: NewHope +
      • +
      • sharedb() +: NewHope +
      • Shell() : Shell
      • @@ -438,7 +444,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_t.html b/functions_t.html index ffdd7297..e7b88fd6 100644 --- a/functions_t.html +++ b/functions_t.html @@ -152,6 +152,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      • TimeField() : TimeField
      • +
      • Torref +: NewHope +
      • TransistorNoiseSource() : TransistorNoiseSource
      • @@ -165,7 +168,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_type.html b/functions_type.html index 5479c20f..1cd3090a 100644 --- a/functions_type.html +++ b/functions_type.html @@ -108,7 +108,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_u.html b/functions_u.html index 750821d3..7956e063 100644 --- a/functions_u.html +++ b/functions_u.html @@ -168,7 +168,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_v.html b/functions_v.html index c60b8acb..36593171 100644 --- a/functions_v.html +++ b/functions_v.html @@ -132,6 +132,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , TextField , TimeField +
      • Variant +: NewHope +
      • verify() : Ed25519 , P521 @@ -140,7 +143,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_vars.html b/functions_vars.html index 227ab5c1..bfd668e7 100644 --- a/functions_vars.html +++ b/functions_vars.html @@ -157,7 +157,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_w.html b/functions_w.html index 0d86c046..934c4911 100644 --- a/functions_w.html +++ b/functions_w.html @@ -174,7 +174,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_x.html b/functions_x.html index b77e0342..eaa4cf7b 100644 --- a/functions_x.html +++ b/functions_x.html @@ -144,7 +144,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_y.html b/functions_y.html index aa5d11ff..a69e99a1 100644 --- a/functions_y.html +++ b/functions_y.html @@ -135,7 +135,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_~.html b/functions_~.html index 6332cbc6..6d38c3aa 100644 --- a/functions_~.html +++ b/functions_~.html @@ -182,6 +182,9 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
      • ~LoginShell() : LoginShell
      • +
      • ~NewHopePoly() +: NewHopePoly +
      • ~NoiseSource() : NoiseSource
      • @@ -243,7 +246,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/group__power__save.html b/group__power__save.html index b6bee944..d7752e51 100644 --- a/group__power__save.html +++ b/group__power__save.html @@ -201,7 +201,7 @@ void  diff --git a/hierarchy.html b/hierarchy.html index ac6ab4eb..5b330445 100644 --- a/hierarchy.html +++ b/hierarchy.html @@ -145,39 +145,41 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); oCLiquidCrystal |\CLCDEnhanced library for Freetronics 16x2 LCD shields oCMelodyPlays a melody on a digital output pin using tone() -oCNoiseSourceAbstract base class for random noise sources -|oCRingOscillatorNoiseSourceProcesses the signal from a ring oscillator based noise source -|\CTransistorNoiseSourceProcesses the signal from a transistor-based noise source -oCOMACImplementation of the OMAC message authenticator -oCP521Elliptic curve operations with the NIST P-521 curve -oCPoly1305Poly1305 message authenticator -oCRNGClassPseudo random number generator suitable for cryptography -oCRTCBase class for realtime clock handlers -|oCDS1307RTCCommunicates with a DS1307 realtime clock chip via I2C -|oCDS3231RTCCommunicates with a DS3231 realtime clock chip via I2C -|\CDS3232RTCCommunicates with a DS3232 realtime clock chip via I2C -oCRTCAlarmStores alarm information from a realtime clock chip -oCRTCDateStores date information from a realtime clock chip -oCRTCTimeStores time information from a realtime clock chip -oCShellArgumentsConvenience class that encapsulates an array of shell command arguments -oCStream -|\CTerminalExtended stream interface for terminal operations -| \CShellCommand-line shell access -|  \CLoginShellCommand-line shell access via a login shell -oCXOFAbstract base class for Extendable-Output Functions (XOFs) -|\CSHAKEAbstract base class for the SHAKE Extendable-Output Functions (XOFs) -| oCSHAKE128SHAKE Extendable-Output Function (XOF) with 128-bit security -| \CSHAKE256SHAKE Extendable-Output Function (XOF) with 256-bit security -\CXTSCommonConcrete base class to assist with implementing XTS mode for 128-bit block ciphers - oCXTS< T1, T2 >Implementation of the XTS mode for 128-bit block ciphers - \CXTSSingleKeyCommonConcrete base class to assist with implementing single-key XTS mode for 128-bit block ciphers -  \CXTSSingleKey< T >Implementation of the single-key XTS mode for 128-bit block ciphers +oCNewHopeNewHope post-quantum key exchange algorithm +oCNewHopePolyNewHope polynomial representation +oCNoiseSourceAbstract base class for random noise sources +|oCRingOscillatorNoiseSourceProcesses the signal from a ring oscillator based noise source +|\CTransistorNoiseSourceProcesses the signal from a transistor-based noise source +oCOMACImplementation of the OMAC message authenticator +oCP521Elliptic curve operations with the NIST P-521 curve +oCPoly1305Poly1305 message authenticator +oCRNGClassPseudo random number generator suitable for cryptography +oCRTCBase class for realtime clock handlers +|oCDS1307RTCCommunicates with a DS1307 realtime clock chip via I2C +|oCDS3231RTCCommunicates with a DS3231 realtime clock chip via I2C +|\CDS3232RTCCommunicates with a DS3232 realtime clock chip via I2C +oCRTCAlarmStores alarm information from a realtime clock chip +oCRTCDateStores date information from a realtime clock chip +oCRTCTimeStores time information from a realtime clock chip +oCShellArgumentsConvenience class that encapsulates an array of shell command arguments +oCStream +|\CTerminalExtended stream interface for terminal operations +| \CShellCommand-line shell access +|  \CLoginShellCommand-line shell access via a login shell +oCXOFAbstract base class for Extendable-Output Functions (XOFs) +|\CSHAKEAbstract base class for the SHAKE Extendable-Output Functions (XOFs) +| oCSHAKE128SHAKE Extendable-Output Function (XOF) with 128-bit security +| \CSHAKE256SHAKE Extendable-Output Function (XOF) with 256-bit security +\CXTSCommonConcrete base class to assist with implementing XTS mode for 128-bit block ciphers + oCXTS< T1, T2 >Implementation of the XTS mode for 128-bit block ciphers + \CXTSSingleKeyCommonConcrete base class to assist with implementing single-key XTS mode for 128-bit block ciphers +  \CXTSSingleKey< T >Implementation of the single-key XTS mode for 128-bit block ciphers diff --git a/index.html b/index.html index 98df16a7..f6edc0b5 100644 --- a/index.html +++ b/index.html @@ -136,6 +136,7 @@ Cryptographic Library
      • Extendable output functions (XOF's): SHAKE128, SHAKE256
      • Message authenticators: Poly1305, GHASH, OMAC
      • Public key algorithms: Curve25519, Ed25519, P521
      • +
      • Post-quantum algorithms: NewHope
      • Random number generation: RNG, TransistorNoiseSource, RingOscillatorNoiseSource

      More information can be found on the Cryptographic Library page.

      @@ -164,7 +165,7 @@ Other diff --git a/ir-dumpir_8dox.html b/ir-dumpir_8dox.html index 701e3f6b..c4d36977 100644 --- a/ir-dumpir_8dox.html +++ b/ir-dumpir_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ir-snake_8dox.html b/ir-snake_8dox.html index 4ecad919..86452726 100644 --- a/ir-snake_8dox.html +++ b/ir-snake_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ir_dumpir.html b/ir_dumpir.html index 472ed1d8..1969672b 100644 --- a/ir_dumpir.html +++ b/ir_dumpir.html @@ -283,7 +283,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/ir_snake.html b/ir_snake.html index a56410ba..ee36b47c 100644 --- a/ir_snake.html +++ b/ir_snake.html @@ -273,7 +273,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/lcd-form_8dox.html b/lcd-form_8dox.html index 652f2249..0c83b65e 100644 --- a/lcd-form_8dox.html +++ b/lcd-form_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/lcd-helloworld_8dox.html b/lcd-helloworld_8dox.html index 4df58411..b50f10c4 100644 --- a/lcd-helloworld_8dox.html +++ b/lcd-helloworld_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/lcd_form.html b/lcd_form.html index f7714491..2a4457c6 100644 --- a/lcd_form.html +++ b/lcd_form.html @@ -216,7 +216,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/lcd_hello_world.html b/lcd_hello_world.html index 0a36d64d..74cf2c66 100644 --- a/lcd_hello_world.html +++ b/lcd_hello_world.html @@ -166,7 +166,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/mainpage_8dox.html b/mainpage_8dox.html index 6315bf2a..82869440 100644 --- a/mainpage_8dox.html +++ b/mainpage_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/modules.html b/modules.html index 8825cd1a..59a5aa0d 100644 --- a/modules.html +++ b/modules.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/pages.html b/pages.html index 177f5216..464aebd8 100644 --- a/pages.html +++ b/pages.html @@ -102,7 +102,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/search/all_10.js b/search/all_10.js index a18703d9..fa2fe0ca 100644 --- a/search/all_10.js +++ b/search/all_10.js @@ -64,6 +64,8 @@ var searchData= ['shake',['SHAKE',['../classSHAKE.html',1,'SHAKE'],['../classSHAKE.html#a9346e4d53a9d7d686911ab772fc23387',1,'SHAKE::SHAKE()']]], ['shake128',['SHAKE128',['../classSHAKE128.html',1,'SHAKE128'],['../classSHAKE128.html#a7d9d435780157e944eea931b3a13df0d',1,'SHAKE128::SHAKE128()']]], ['shake256',['SHAKE256',['../classSHAKE256.html',1,'SHAKE256'],['../classSHAKE256.html#abbc01bc6798da9479e2da105f6661c22',1,'SHAKE256::SHAKE256()']]], + ['shareda',['shareda',['../classNewHope.html#ae490ebcfcbc18179b03c1a1ae8874458',1,'NewHope']]], + ['sharedb',['sharedb',['../classNewHope.html#a2f09529f5f73cf9763c28b58b13bbd14',1,'NewHope']]], ['shell',['Shell',['../classShell.html',1,'Shell'],['../classShell.html#ad613444a902075e8fd26b1f51c4d3b63',1,'Shell::Shell()']]], ['shell_2dserial_2edox',['shell-serial.dox',['../shell-serial_8dox.html',1,'']]], ['shell_2dtelnet_2edox',['shell-telnet.dox',['../shell-telnet_8dox.html',1,'']]], diff --git a/search/all_11.js b/search/all_11.js index e6289d1b..869ed171 100644 --- a/search/all_11.js +++ b/search/all_11.js @@ -9,6 +9,7 @@ var searchData= ['textheight',['textHeight',['../classBitmap.html#a628bb694fcfe6eab619a4f1e152d41c4',1,'Bitmap']]], ['textwidth',['textWidth',['../classBitmap.html#a0f7607b1c7867987f4500d490a666e8a',1,'Bitmap::textWidth(const char *str, int len=-1) const '],['../classBitmap.html#a8ca70aa0f8f722a228358bffe794e925',1,'Bitmap::textWidth(const String &str, int start=0, int len=-1) const ']]], ['timefield',['TimeField',['../classTimeField.html',1,'TimeField'],['../classTimeField.html#a138e2425379705828a87eb2d8a836431',1,'TimeField::TimeField(const String &label)'],['../classTimeField.html#a87f222bc098367963ed21a7edc4624de',1,'TimeField::TimeField(Form &form, const String &label, int maxHours, bool readOnly)']]], + ['torref',['Torref',['../classNewHope.html#a679601da301134f037c3a5786bd7085fae270e706968a8e01e5c1cb40422b22c6',1,'NewHope']]], ['transistornoisesource',['TransistorNoiseSource',['../classTransistorNoiseSource.html',1,'TransistorNoiseSource'],['../classTransistorNoiseSource.html#a05bab61c301a5397021048c95ca3107d',1,'TransistorNoiseSource::TransistorNoiseSource()']]], ['truelabel',['trueLabel',['../classBoolField.html#a9972030beec6e007b556c6eb652e163d',1,'BoolField']]], ['tweaksize',['tweakSize',['../classXTSCommon.html#afb3ebf14c7879bcbc92e3d6cc70b19a9',1,'XTSCommon']]] diff --git a/search/all_13.js b/search/all_13.js index d2749342..86204723 100644 --- a/search/all_13.js +++ b/search/all_13.js @@ -1,5 +1,6 @@ var searchData= [ ['value',['value',['../classBoolField.html#a9147826437fbaf9b29eda9dee9e37b39',1,'BoolField::value()'],['../classIntField.html#a2fb650827ce8cb4662253bb6c32acb52',1,'IntField::value()'],['../classListField.html#aab8477757cd89bacd242c85bac2dccb1',1,'ListField::value()'],['../classTextField.html#a124764b6fc7c19aaf683f72cd42636b1',1,'TextField::value()'],['../classTimeField.html#a400aaa72a83b3b872e1de1c3af1a240f',1,'TimeField::value()']]], + ['variant',['Variant',['../classNewHope.html#a679601da301134f037c3a5786bd7085f',1,'NewHope']]], ['verify',['verify',['../classEd25519.html#ae3e2fc405c9cd8cb1d3ab9b8b452d3e4',1,'Ed25519::verify()'],['../classP521.html#ab075909f5cecbb801c6b7c41f20de223',1,'P521::verify()']]] ]; diff --git a/search/all_17.js b/search/all_17.js index daef7e68..a3323192 100644 --- a/search/all_17.js +++ b/search/all_17.js @@ -19,6 +19,7 @@ var searchData= ['_7ehash',['~Hash',['../classHash.html#a4e4b4797dda8678aaed058bae155813e',1,'Hash']]], ['_7ekeccakcore',['~KeccakCore',['../classKeccakCore.html#a4579e3a9b24f1d615fa8d660c23e77a4',1,'KeccakCore']]], ['_7eloginshell',['~LoginShell',['../classLoginShell.html#aaae466b141c9ea50870b66509402a2f9',1,'LoginShell']]], + ['_7enewhopepoly',['~NewHopePoly',['../classNewHopePoly.html#ad7c3c83cb078be4e6f136eeea7e21250',1,'NewHopePoly']]], ['_7enoisesource',['~NoiseSource',['../classNoiseSource.html#a4eca1e894a5d719fb9bf4df34a791cdb',1,'NoiseSource']]], ['_7eofbcommon',['~OFBCommon',['../classOFBCommon.html#aae7435157e51bf977d3481e94e17ae01',1,'OFBCommon']]], ['_7eomac',['~OMAC',['../classOMAC.html#a6bb2222c997608ec68b25831da965e8f',1,'OMAC']]], diff --git a/search/all_2.js b/search/all_2.js index 2699e89c..8021347b 100644 --- a/search/all_2.js +++ b/search/all_2.js @@ -15,9 +15,9 @@ var searchData= ['chaseleds',['ChaseLEDs',['../classChaseLEDs.html',1,'ChaseLEDs'],['../classChaseLEDs.html#ab6bb3da371d3730a6552e93a9b2eab78',1,'ChaseLEDs::ChaseLEDs()']]], ['checktag',['checkTag',['../classAuthenticatedCipher.html#a4bb33d194e2c7d30c4e5a713e59786ff',1,'AuthenticatedCipher::checkTag()'],['../classChaChaPoly.html#aeffb3e0df0b4da03f72f30251243d953',1,'ChaChaPoly::checkTag()'],['../classEAXCommon.html#a72c403f52cefab57566bc5f634c1b963',1,'EAXCommon::checkTag()'],['../classGCMCommon.html#a70229be2fe2274c4109fe7511481075a',1,'GCMCommon::checkTag()']]], ['cipher',['Cipher',['../classCipher.html',1,'Cipher'],['../classCipher.html#a6a61077eca3ccd5900f92ceac58fb09c',1,'Cipher::Cipher()']]], - ['clear',['clear',['../classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1',1,'Bitmap::clear()'],['../classAESCommon.html#a83e43f7d07e31d90fd7b768a93ecfce6',1,'AESCommon::clear()'],['../classBLAKE2b.html#a21623759bd381285ebf7e75a00c9c8a9',1,'BLAKE2b::clear()'],['../classBLAKE2s.html#a0848885f52df51dc53949d32a206e72d',1,'BLAKE2s::clear()'],['../classBlockCipher.html#a6f27d46e9dfa7761d014d828ad5f955b',1,'BlockCipher::clear()'],['../classCBCCommon.html#a7befadfe7384e0e857a96a59bf3845e9',1,'CBCCommon::clear()'],['../classCFBCommon.html#a847d320b0fe7f329385f26511b42c40d',1,'CFBCommon::clear()'],['../classChaCha.html#af533905f679066c41f4d6cd76bddb4cb',1,'ChaCha::clear()'],['../classChaChaPoly.html#a2d7fc3fd05a0b6c7c9c21fff6e939c9a',1,'ChaChaPoly::clear()'],['../classCipher.html#a4b7c3965646441a70d9ab934a7c92ab1',1,'Cipher::clear()'],['../classCTRCommon.html#ac0d6381c02fe2a8a017ad66d006a6ef2',1,'CTRCommon::clear()'],['../classEAXCommon.html#afa88b0f589e09103e9c69ace081db0af',1,'EAXCommon::clear()'],['../classGCMCommon.html#a06868ebd67a571aa68d88d5d072cece9',1,'GCMCommon::clear()'],['../classGHASH.html#a4b1ee789debf56f7f24807960ef0556e',1,'GHASH::clear()'],['../classHash.html#a4a959469433cd9348ab7f3ac6228bb34',1,'Hash::clear()'],['../classKeccakCore.html#aeff1df56e4a3103c99c1fe4307e60c66',1,'KeccakCore::clear()'],['../classOFBCommon.html#a55bf2396beb91c457bfc4c20ef5c8123',1,'OFBCommon::clear()'],['../classOMAC.html#a072715dbda39dc9c360cfcaab31d6aa7',1,'OMAC::clear()'],['../classPoly1305.html#ae3f3392b9a2bd0f3472e7e50dd7e21dd',1,'Poly1305::clear()'],['../classSHA256.html#add0d1649d533b27005ccd8508398c689',1,'SHA256::clear()'],['../classSHA3__256.html#a531467f995ef6fc901ad8c2b5776a8d1',1,'SHA3_256::clear()'],['../classSHA3__512.html#acfbc5e9b4d394f011d5132a2b156d260',1,'SHA3_512::clear()'],['../classSHA512.html#a0a9104dce5f099aeba216e5fbcb1ee1a',1,'SHA512::clear()'],['../classSHAKE.html#ab86f52425c1d5b0e5c924b4f96121fe0',1,'SHAKE::clear()'],['../classSpeck.html#aa3866273282addabb9d3703c41fdc95f',1,'Speck::clear()'],['../classSpeckSmall.html#aa93d9f0b5153425dc04e8fb8faff7513',1,'SpeckSmall::clear()'],['../classSpeckTiny.html#a303ecc2639459e47c6eeb21991d52ccf',1,'SpeckTiny::clear()'],['../classXOF.html#ac34cb22f251642b58b3dd78a6480aff3',1,'XOF::clear()'],['../classXTSCommon.html#a96e3cb4a3d35dc4e3a5acbae19b4465b',1,'XTSCommon::clear()'],['../classTerminal.html#a4be741767b27739eec98901477e1c3d4',1,'Terminal::clear()']]], + ['clear',['clear',['../classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1',1,'Bitmap::clear()'],['../classAESCommon.html#a83e43f7d07e31d90fd7b768a93ecfce6',1,'AESCommon::clear()'],['../classBLAKE2b.html#a21623759bd381285ebf7e75a00c9c8a9',1,'BLAKE2b::clear()'],['../classBLAKE2s.html#a0848885f52df51dc53949d32a206e72d',1,'BLAKE2s::clear()'],['../classBlockCipher.html#a6f27d46e9dfa7761d014d828ad5f955b',1,'BlockCipher::clear()'],['../classCBCCommon.html#a7befadfe7384e0e857a96a59bf3845e9',1,'CBCCommon::clear()'],['../classCFBCommon.html#a847d320b0fe7f329385f26511b42c40d',1,'CFBCommon::clear()'],['../classChaCha.html#af533905f679066c41f4d6cd76bddb4cb',1,'ChaCha::clear()'],['../classChaChaPoly.html#a2d7fc3fd05a0b6c7c9c21fff6e939c9a',1,'ChaChaPoly::clear()'],['../classCipher.html#a4b7c3965646441a70d9ab934a7c92ab1',1,'Cipher::clear()'],['../classCTRCommon.html#ac0d6381c02fe2a8a017ad66d006a6ef2',1,'CTRCommon::clear()'],['../classEAXCommon.html#afa88b0f589e09103e9c69ace081db0af',1,'EAXCommon::clear()'],['../classGCMCommon.html#a06868ebd67a571aa68d88d5d072cece9',1,'GCMCommon::clear()'],['../classGHASH.html#a4b1ee789debf56f7f24807960ef0556e',1,'GHASH::clear()'],['../classHash.html#a4a959469433cd9348ab7f3ac6228bb34',1,'Hash::clear()'],['../classKeccakCore.html#aeff1df56e4a3103c99c1fe4307e60c66',1,'KeccakCore::clear()'],['../classOFBCommon.html#a55bf2396beb91c457bfc4c20ef5c8123',1,'OFBCommon::clear()'],['../classOMAC.html#a072715dbda39dc9c360cfcaab31d6aa7',1,'OMAC::clear()'],['../classPoly1305.html#ae3f3392b9a2bd0f3472e7e50dd7e21dd',1,'Poly1305::clear()'],['../classSHA256.html#add0d1649d533b27005ccd8508398c689',1,'SHA256::clear()'],['../classSHA3__256.html#a531467f995ef6fc901ad8c2b5776a8d1',1,'SHA3_256::clear()'],['../classSHA3__512.html#acfbc5e9b4d394f011d5132a2b156d260',1,'SHA3_512::clear()'],['../classSHA512.html#a0a9104dce5f099aeba216e5fbcb1ee1a',1,'SHA512::clear()'],['../classSHAKE.html#ab86f52425c1d5b0e5c924b4f96121fe0',1,'SHAKE::clear()'],['../classSpeck.html#aa3866273282addabb9d3703c41fdc95f',1,'Speck::clear()'],['../classSpeckSmall.html#aa93d9f0b5153425dc04e8fb8faff7513',1,'SpeckSmall::clear()'],['../classSpeckTiny.html#a303ecc2639459e47c6eeb21991d52ccf',1,'SpeckTiny::clear()'],['../classXOF.html#ac34cb22f251642b58b3dd78a6480aff3',1,'XOF::clear()'],['../classXTSCommon.html#a96e3cb4a3d35dc4e3a5acbae19b4465b',1,'XTSCommon::clear()'],['../classNewHopePoly.html#a842db1796a45ba78f279e008210df304',1,'NewHopePoly::clear()'],['../classTerminal.html#a4be741767b27739eec98901477e1c3d4',1,'Terminal::clear()']]], ['cleartoeol',['clearToEOL',['../classTerminal.html#aeb93d71925cdfb17065e7f1ef2e83414',1,'Terminal']]], - ['color',['color',['../classTerminal.html#ad1fc2be31d49124a1d32e8afddaa57b8',1,'Terminal::color(Color fg)'],['../classTerminal.html#ae22436e478a854e8b559fe73182bc329',1,'Terminal::color(Color fg, Color bg)'],['../classTerminal.html#a7a03a2e94316da7b2144dad5ba95ac20',1,'Terminal::Color()'],['../classBitmap.html#a88d386944a7017aa776a177b10d8b2ba',1,'Bitmap::Color()']]], + ['color',['Color',['../classTerminal.html#a7a03a2e94316da7b2144dad5ba95ac20',1,'Terminal::Color()'],['../classBitmap.html#a88d386944a7017aa776a177b10d8b2ba',1,'Bitmap::Color()'],['../classTerminal.html#ad1fc2be31d49124a1d32e8afddaa57b8',1,'Terminal::color(Color fg)'],['../classTerminal.html#ae22436e478a854e8b559fe73182bc329',1,'Terminal::color(Color fg, Color bg)']]], ['columns',['columns',['../classTerminal.html#aed25b5a884f89dcd2bb269a8e356e5d6',1,'Terminal']]], ['command',['command',['../classIRreceiver.html#a4b021592a2b089dc2f1e138a38506fda',1,'IRreceiver']]], ['computetag',['computeTag',['../classAuthenticatedCipher.html#a73fa4306053ed457e5c533b3127391c9',1,'AuthenticatedCipher::computeTag()'],['../classChaChaPoly.html#a92d850ad7027829e4072c43bd5028f95',1,'ChaChaPoly::computeTag()'],['../classEAXCommon.html#ab5a61bba48561d6e7e6b8bafc51d91e3',1,'EAXCommon::computeTag()'],['../classGCMCommon.html#a444634bd4469bb5d404ac882d1d8fdf4',1,'GCMCommon::computeTag()']]], diff --git a/search/all_5.js b/search/all_5.js index f295ffb2..5178e1b4 100644 --- a/search/all_5.js +++ b/search/all_5.js @@ -8,7 +8,7 @@ var searchData= ['firedalarm',['firedAlarm',['../classDS3231RTC.html#a6a5b3717ff65528de566c021eb821b94',1,'DS3231RTC::firedAlarm()'],['../classDS3232RTC.html#a79649f100a4562b9c1ba7c69e85cbca3',1,'DS3232RTC::firedAlarm()']]], ['flags',['flags',['../structRTCAlarm.html#a0f2ef7363cb60a26642d5295b77ca19e',1,'RTCAlarm']]], ['flush',['flush',['../classTerminal.html#a908cdfa64167279ed565d43b45470c3d',1,'Terminal']]], - ['font',['font',['../classBitmap.html#a7bf0a232b4bd12573cc570cc0edef47c',1,'Bitmap::font() const '],['../classBitmap.html#a456f7d6da03189c1e7148563a891b3cf',1,'Bitmap::Font()']]], + ['font',['Font',['../classBitmap.html#a456f7d6da03189c1e7148563a891b3cf',1,'Bitmap::Font()'],['../classBitmap.html#a7bf0a232b4bd12573cc570cc0edef47c',1,'Bitmap::font() const ']]], ['form',['Form',['../classForm.html',1,'Form'],['../classField.html#a27427319be1cc92db3128637d8884ee5',1,'Field::form()'],['../classForm.html#ad30836b22edde707a52d94090b716996',1,'Form::Form()']]], ['formathmackey',['formatHMACKey',['../classHash.html#ab6f40c9af91dc3d738d9fcce59af63cc',1,'Hash']]], ['fromrgb',['fromRGB',['../classDMD.html#a557412f734fc4596e1102bf71e110ea0',1,'DMD']]], diff --git a/search/all_9.js b/search/all_9.js index bfea1d41..eff2d137 100644 --- a/search/all_9.js +++ b/search/all_9.js @@ -1,5 +1,6 @@ var searchData= [ ['keccakcore',['KeccakCore',['../classKeccakCore.html',1,'KeccakCore'],['../classKeccakCore.html#a850c8e85bdb6b347411239716535d9c9',1,'KeccakCore::KeccakCore()']]], + ['keygen',['keygen',['../classNewHope.html#ae8f821867bce309220aee7a43c2d4f51',1,'NewHope']]], ['keysize',['keySize',['../classAES128.html#aa871832a156f0ea61b964e489670ae9d',1,'AES128::keySize()'],['../classAES192.html#ade28843e51e262b30eb55791c83fd791',1,'AES192::keySize()'],['../classAES256.html#af8ed6412bae6fc78274f60344899366a',1,'AES256::keySize()'],['../classBlockCipher.html#afde6004a859e015d877eab3c37042a0f',1,'BlockCipher::keySize()'],['../classCBCCommon.html#adb7daacfe2a4fca3d13b62b75372fe4e',1,'CBCCommon::keySize()'],['../classCFBCommon.html#a82899da983bc70bc8152ee67f424552e',1,'CFBCommon::keySize()'],['../classChaCha.html#af286083291fab2bd36dc7ad1f54d5cd7',1,'ChaCha::keySize()'],['../classChaChaPoly.html#a666760e68cb53f28ba0a8dc09039c0fb',1,'ChaChaPoly::keySize()'],['../classCipher.html#a4cea432ea0278c865441f17cbb88b1ab',1,'Cipher::keySize()'],['../classCTRCommon.html#a29ce8e13a302350397fc6790a686bea2',1,'CTRCommon::keySize()'],['../classEAXCommon.html#a027956913eecfa0bc760f20f3b62df29',1,'EAXCommon::keySize()'],['../classGCMCommon.html#a134ba35e740a18bee3c45502b4149eae',1,'GCMCommon::keySize()'],['../classOFBCommon.html#a76ea9f9ea9dd137778338813e534a8ce',1,'OFBCommon::keySize()'],['../classSpeck.html#a061e43c1363178cda088c3f46e07d87b',1,'Speck::keySize()'],['../classSpeckTiny.html#a5587909ba48776b01bbd40b339b1262e',1,'SpeckTiny::keySize()'],['../classXTSCommon.html#a2da350825a438355665683ab9eb57aa7',1,'XTSCommon::keySize()'],['../classXTSSingleKeyCommon.html#ac017d457a08001a3ea44a9900dee2b64',1,'XTSSingleKeyCommon::keySize()']]] ]; diff --git a/search/all_a.js b/search/all_a.js index 41efafab..bd27634d 100644 --- a/search/all_a.js +++ b/search/all_a.js @@ -1,7 +1,7 @@ var searchData= [ ['label',['label',['../classField.html#aaa861ef917130c989a955bc75c683afe',1,'Field']]], - ['lcd',['LCD',['../classLCD.html',1,'LCD'],['../classField.html#a5cf21bf958a71e51feac9e1bf9f599d1',1,'Field::lcd()'],['../classLCD.html#a00bb2db1390721abc7b24ac4b8c276c8',1,'LCD::LCD()'],['../classLCD.html#a067bc741cf27f143aba5d9f147908401',1,'LCD::LCD(uint8_t pin9)'],['../classLCD.html#a203d268bef6c61fa293562dbb0e9f51e',1,'LCD::LCD(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)']]], + ['lcd',['LCD',['../classLCD.html',1,'LCD'],['../classLCD.html#a00bb2db1390721abc7b24ac4b8c276c8',1,'LCD::LCD()'],['../classLCD.html#a067bc741cf27f143aba5d9f147908401',1,'LCD::LCD(uint8_t pin9)'],['../classLCD.html#a203d268bef6c61fa293562dbb0e9f51e',1,'LCD::LCD(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)'],['../classField.html#a5cf21bf958a71e51feac9e1bf9f599d1',1,'Field::lcd()']]], ['lcd_2dform_2edox',['lcd-form.dox',['../lcd-form_8dox.html',1,'']]], ['lcd_2dhelloworld_2edox',['lcd-helloworld.dox',['../lcd-helloworld_8dox.html',1,'']]], ['led',['led',['../classCharlieplex.html#a90fd09f24b62424b0b7b8bcdb0140b9d',1,'Charlieplex']]], diff --git a/search/all_b.js b/search/all_b.js index 8db2567e..61c4364e 100644 --- a/search/all_b.js +++ b/search/all_b.js @@ -9,7 +9,7 @@ var searchData= ['melody',['Melody',['../classMelody.html',1,'Melody'],['../classMelody.html#a9edc4165a49368dd5d78eedf982c38b9',1,'Melody::Melody()']]], ['minute',['minute',['../structRTCTime.html#acf2161ca037080dc4b767e636ad8db84',1,'RTCTime::minute()'],['../structRTCAlarm.html#ad9a75ceb4b4b3474baa66dd5466e62fe',1,'RTCAlarm::minute()']]], ['minvalue',['minValue',['../classIntField.html#af3dab3f2b46d29136d7a93ce46b0b8fb',1,'IntField']]], - ['mode',['Mode',['../classTerminal.html#a6fd7d021468962e9604bee0522b3a364',1,'Terminal::Mode()'],['../classTerminal.html#acbf591c7371acba52bcd84ba4a0ce5c8',1,'Terminal::mode() const ']]], + ['mode',['mode',['../classTerminal.html#acbf591c7371acba52bcd84ba4a0ce5c8',1,'Terminal::mode() const '],['../classTerminal.html#a6fd7d021468962e9604bee0522b3a364',1,'Terminal::Mode()']]], ['month',['month',['../structRTCDate.html#a6e6196059b36186041a5312400ea9202',1,'RTCDate']]], ['mul',['mul',['../classBigNumberUtil.html#a1c2c5484f2bf440ae292fd3dfd2d594f',1,'BigNumberUtil::mul()'],['../classGF128.html#a7d9a341a1715d37d25feba21627bc3ab',1,'GF128::mul()']]], ['mul_5fp',['mul_P',['../classBigNumberUtil.html#aacdee1806a239eb9e58753ef1ddb964a',1,'BigNumberUtil']]], diff --git a/search/all_c.js b/search/all_c.js index ae199e43..f98dfbd7 100644 --- a/search/all_c.js +++ b/search/all_c.js @@ -1,5 +1,7 @@ var searchData= [ + ['newhope',['NewHope',['../classNewHope.html',1,'']]], + ['newhopepoly',['NewHopePoly',['../classNewHopePoly.html',1,'NewHopePoly'],['../classNewHopePoly.html#aec9804046c753436ffbe88afd175bb39',1,'NewHopePoly::NewHopePoly()']]], ['nextfield',['nextField',['../classForm.html#a788a186ea4a7ebd75283a948ca45f4d1',1,'Form']]], ['no_5ftemperature',['NO_TEMPERATURE',['../classRTC.html#a9ed5480b362a83f1f45c4d3bcf7c3bf8',1,'RTC']]], ['nodisplay',['noDisplay',['../classLCD.html#af3974da6d988ba2d21c25135ada12108',1,'LCD']]], diff --git a/search/all_f.js b/search/all_f.js index 8233f1e7..5f1d4fed 100644 --- a/search/all_f.js +++ b/search/all_f.js @@ -14,6 +14,7 @@ var searchData= ['red',['Red',['../classTerminal.html#a7a03a2e94316da7b2144dad5ba95ac20af2687d41cae4cb8276778be71c1e1efb',1,'Terminal']]], ['reducequick',['reduceQuick',['../classBigNumberUtil.html#a5af5f50c91594183da4e079d76702d34',1,'BigNumberUtil']]], ['reducequick_5fp',['reduceQuick_P',['../classBigNumberUtil.html#a00c9cde0b626788a60552a6bc9ce058b',1,'BigNumberUtil']]], + ['ref',['Ref',['../classNewHope.html#a679601da301134f037c3a5786bd7085fa2326f3fd76345d5900834593a74f6596',1,'NewHope']]], ['refresh',['refresh',['../classCharlieplex.html#a3c961bfff866e400dad371f0376f096b',1,'Charlieplex::refresh()'],['../classDMD.html#a9e4bf2a9d247312d35c1401ff61261c8',1,'DMD::refresh()']]], ['registercommand',['registerCommand',['../classShell.html#a03dfba66a0125a8c02dd71b3f3b37870',1,'Shell']]], ['removefield',['removeField',['../classForm.html#a7abd717029f9b19ee7318470072cd697',1,'Form']]], diff --git a/search/classes_c.js b/search/classes_c.js index d53a9846..53946c31 100644 --- a/search/classes_c.js +++ b/search/classes_c.js @@ -1,4 +1,6 @@ var searchData= [ + ['newhope',['NewHope',['../classNewHope.html',1,'']]], + ['newhopepoly',['NewHopePoly',['../classNewHopePoly.html',1,'']]], ['noisesource',['NoiseSource',['../classNoiseSource.html',1,'']]] ]; diff --git a/search/enums_4.html b/search/enums_4.html new file mode 100644 index 00000000..99379142 --- /dev/null +++ b/search/enums_4.html @@ -0,0 +1,26 @@ + + + + + + + + + +
      +
      Loading...
      +
      + +
      Searching...
      +
      No Matches
      + +
      + + diff --git a/search/enums_4.js b/search/enums_4.js new file mode 100644 index 00000000..8f96a1a3 --- /dev/null +++ b/search/enums_4.js @@ -0,0 +1,4 @@ +var searchData= +[ + ['variant',['Variant',['../classNewHope.html#a679601da301134f037c3a5786bd7085f',1,'NewHope']]] +]; diff --git a/search/enumvalues_6.js b/search/enumvalues_6.js index 811efdbb..88fab2b1 100644 --- a/search/enumvalues_6.js +++ b/search/enumvalues_6.js @@ -1,4 +1,5 @@ var searchData= [ - ['red',['Red',['../classTerminal.html#a7a03a2e94316da7b2144dad5ba95ac20af2687d41cae4cb8276778be71c1e1efb',1,'Terminal']]] + ['red',['Red',['../classTerminal.html#a7a03a2e94316da7b2144dad5ba95ac20af2687d41cae4cb8276778be71c1e1efb',1,'Terminal']]], + ['ref',['Ref',['../classNewHope.html#a679601da301134f037c3a5786bd7085fa2326f3fd76345d5900834593a74f6596',1,'NewHope']]] ]; diff --git a/search/enumvalues_8.js b/search/enumvalues_8.js index 638c1dc8..344f898d 100644 --- a/search/enumvalues_8.js +++ b/search/enumvalues_8.js @@ -1,4 +1,5 @@ var searchData= [ - ['telnet',['Telnet',['../classTerminal.html#a6fd7d021468962e9604bee0522b3a364a71eb4637496b7a884384c4250f3289a7',1,'Terminal']]] + ['telnet',['Telnet',['../classTerminal.html#a6fd7d021468962e9604bee0522b3a364a71eb4637496b7a884384c4250f3289a7',1,'Terminal']]], + ['torref',['Torref',['../classNewHope.html#a679601da301134f037c3a5786bd7085fae270e706968a8e01e5c1cb40422b22c6',1,'NewHope']]] ]; diff --git a/search/functions_10.js b/search/functions_10.js index 2ed198db..c3d33f61 100644 --- a/search/functions_10.js +++ b/search/functions_10.js @@ -59,6 +59,8 @@ var searchData= ['shake',['SHAKE',['../classSHAKE.html#a9346e4d53a9d7d686911ab772fc23387',1,'SHAKE']]], ['shake128',['SHAKE128',['../classSHAKE128.html#a7d9d435780157e944eea931b3a13df0d',1,'SHAKE128']]], ['shake256',['SHAKE256',['../classSHAKE256.html#abbc01bc6798da9479e2da105f6661c22',1,'SHAKE256']]], + ['shareda',['shareda',['../classNewHope.html#ae490ebcfcbc18179b03c1a1ae8874458',1,'NewHope']]], + ['sharedb',['sharedb',['../classNewHope.html#a2f09529f5f73cf9763c28b58b13bbd14',1,'NewHope']]], ['shell',['Shell',['../classShell.html#ad613444a902075e8fd26b1f51c4d3b63',1,'Shell']]], ['shellcommandfunc',['ShellCommandFunc',['../classShell.html#ad5bac6a4033cd81e24c1345650bca744',1,'Shell']]], ['shellpasswordcheckfunc',['ShellPasswordCheckFunc',['../classLoginShell.html#adad54b04ec54d3577df4cd11944fff1d',1,'LoginShell']]], diff --git a/search/functions_16.js b/search/functions_16.js index daef7e68..a3323192 100644 --- a/search/functions_16.js +++ b/search/functions_16.js @@ -19,6 +19,7 @@ var searchData= ['_7ehash',['~Hash',['../classHash.html#a4e4b4797dda8678aaed058bae155813e',1,'Hash']]], ['_7ekeccakcore',['~KeccakCore',['../classKeccakCore.html#a4579e3a9b24f1d615fa8d660c23e77a4',1,'KeccakCore']]], ['_7eloginshell',['~LoginShell',['../classLoginShell.html#aaae466b141c9ea50870b66509402a2f9',1,'LoginShell']]], + ['_7enewhopepoly',['~NewHopePoly',['../classNewHopePoly.html#ad7c3c83cb078be4e6f136eeea7e21250',1,'NewHopePoly']]], ['_7enoisesource',['~NoiseSource',['../classNoiseSource.html#a4eca1e894a5d719fb9bf4df34a791cdb',1,'NoiseSource']]], ['_7eofbcommon',['~OFBCommon',['../classOFBCommon.html#aae7435157e51bf977d3481e94e17ae01',1,'OFBCommon']]], ['_7eomac',['~OMAC',['../classOMAC.html#a6bb2222c997608ec68b25831da965e8f',1,'OMAC']]], diff --git a/search/functions_2.js b/search/functions_2.js index 1b8d5303..751d4787 100644 --- a/search/functions_2.js +++ b/search/functions_2.js @@ -13,7 +13,7 @@ var searchData= ['chaseleds',['ChaseLEDs',['../classChaseLEDs.html#ab6bb3da371d3730a6552e93a9b2eab78',1,'ChaseLEDs']]], ['checktag',['checkTag',['../classAuthenticatedCipher.html#a4bb33d194e2c7d30c4e5a713e59786ff',1,'AuthenticatedCipher::checkTag()'],['../classChaChaPoly.html#aeffb3e0df0b4da03f72f30251243d953',1,'ChaChaPoly::checkTag()'],['../classEAXCommon.html#a72c403f52cefab57566bc5f634c1b963',1,'EAXCommon::checkTag()'],['../classGCMCommon.html#a70229be2fe2274c4109fe7511481075a',1,'GCMCommon::checkTag()']]], ['cipher',['Cipher',['../classCipher.html#a6a61077eca3ccd5900f92ceac58fb09c',1,'Cipher']]], - ['clear',['clear',['../classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1',1,'Bitmap::clear()'],['../classAESCommon.html#a83e43f7d07e31d90fd7b768a93ecfce6',1,'AESCommon::clear()'],['../classBLAKE2b.html#a21623759bd381285ebf7e75a00c9c8a9',1,'BLAKE2b::clear()'],['../classBLAKE2s.html#a0848885f52df51dc53949d32a206e72d',1,'BLAKE2s::clear()'],['../classBlockCipher.html#a6f27d46e9dfa7761d014d828ad5f955b',1,'BlockCipher::clear()'],['../classCBCCommon.html#a7befadfe7384e0e857a96a59bf3845e9',1,'CBCCommon::clear()'],['../classCFBCommon.html#a847d320b0fe7f329385f26511b42c40d',1,'CFBCommon::clear()'],['../classChaCha.html#af533905f679066c41f4d6cd76bddb4cb',1,'ChaCha::clear()'],['../classChaChaPoly.html#a2d7fc3fd05a0b6c7c9c21fff6e939c9a',1,'ChaChaPoly::clear()'],['../classCipher.html#a4b7c3965646441a70d9ab934a7c92ab1',1,'Cipher::clear()'],['../classCTRCommon.html#ac0d6381c02fe2a8a017ad66d006a6ef2',1,'CTRCommon::clear()'],['../classEAXCommon.html#afa88b0f589e09103e9c69ace081db0af',1,'EAXCommon::clear()'],['../classGCMCommon.html#a06868ebd67a571aa68d88d5d072cece9',1,'GCMCommon::clear()'],['../classGHASH.html#a4b1ee789debf56f7f24807960ef0556e',1,'GHASH::clear()'],['../classHash.html#a4a959469433cd9348ab7f3ac6228bb34',1,'Hash::clear()'],['../classKeccakCore.html#aeff1df56e4a3103c99c1fe4307e60c66',1,'KeccakCore::clear()'],['../classOFBCommon.html#a55bf2396beb91c457bfc4c20ef5c8123',1,'OFBCommon::clear()'],['../classOMAC.html#a072715dbda39dc9c360cfcaab31d6aa7',1,'OMAC::clear()'],['../classPoly1305.html#ae3f3392b9a2bd0f3472e7e50dd7e21dd',1,'Poly1305::clear()'],['../classSHA256.html#add0d1649d533b27005ccd8508398c689',1,'SHA256::clear()'],['../classSHA3__256.html#a531467f995ef6fc901ad8c2b5776a8d1',1,'SHA3_256::clear()'],['../classSHA3__512.html#acfbc5e9b4d394f011d5132a2b156d260',1,'SHA3_512::clear()'],['../classSHA512.html#a0a9104dce5f099aeba216e5fbcb1ee1a',1,'SHA512::clear()'],['../classSHAKE.html#ab86f52425c1d5b0e5c924b4f96121fe0',1,'SHAKE::clear()'],['../classSpeck.html#aa3866273282addabb9d3703c41fdc95f',1,'Speck::clear()'],['../classSpeckSmall.html#aa93d9f0b5153425dc04e8fb8faff7513',1,'SpeckSmall::clear()'],['../classSpeckTiny.html#a303ecc2639459e47c6eeb21991d52ccf',1,'SpeckTiny::clear()'],['../classXOF.html#ac34cb22f251642b58b3dd78a6480aff3',1,'XOF::clear()'],['../classXTSCommon.html#a96e3cb4a3d35dc4e3a5acbae19b4465b',1,'XTSCommon::clear()'],['../classTerminal.html#a4be741767b27739eec98901477e1c3d4',1,'Terminal::clear()']]], + ['clear',['clear',['../classBitmap.html#a839dc8fab05a5ebf7a6b2e61436b2fa1',1,'Bitmap::clear()'],['../classAESCommon.html#a83e43f7d07e31d90fd7b768a93ecfce6',1,'AESCommon::clear()'],['../classBLAKE2b.html#a21623759bd381285ebf7e75a00c9c8a9',1,'BLAKE2b::clear()'],['../classBLAKE2s.html#a0848885f52df51dc53949d32a206e72d',1,'BLAKE2s::clear()'],['../classBlockCipher.html#a6f27d46e9dfa7761d014d828ad5f955b',1,'BlockCipher::clear()'],['../classCBCCommon.html#a7befadfe7384e0e857a96a59bf3845e9',1,'CBCCommon::clear()'],['../classCFBCommon.html#a847d320b0fe7f329385f26511b42c40d',1,'CFBCommon::clear()'],['../classChaCha.html#af533905f679066c41f4d6cd76bddb4cb',1,'ChaCha::clear()'],['../classChaChaPoly.html#a2d7fc3fd05a0b6c7c9c21fff6e939c9a',1,'ChaChaPoly::clear()'],['../classCipher.html#a4b7c3965646441a70d9ab934a7c92ab1',1,'Cipher::clear()'],['../classCTRCommon.html#ac0d6381c02fe2a8a017ad66d006a6ef2',1,'CTRCommon::clear()'],['../classEAXCommon.html#afa88b0f589e09103e9c69ace081db0af',1,'EAXCommon::clear()'],['../classGCMCommon.html#a06868ebd67a571aa68d88d5d072cece9',1,'GCMCommon::clear()'],['../classGHASH.html#a4b1ee789debf56f7f24807960ef0556e',1,'GHASH::clear()'],['../classHash.html#a4a959469433cd9348ab7f3ac6228bb34',1,'Hash::clear()'],['../classKeccakCore.html#aeff1df56e4a3103c99c1fe4307e60c66',1,'KeccakCore::clear()'],['../classOFBCommon.html#a55bf2396beb91c457bfc4c20ef5c8123',1,'OFBCommon::clear()'],['../classOMAC.html#a072715dbda39dc9c360cfcaab31d6aa7',1,'OMAC::clear()'],['../classPoly1305.html#ae3f3392b9a2bd0f3472e7e50dd7e21dd',1,'Poly1305::clear()'],['../classSHA256.html#add0d1649d533b27005ccd8508398c689',1,'SHA256::clear()'],['../classSHA3__256.html#a531467f995ef6fc901ad8c2b5776a8d1',1,'SHA3_256::clear()'],['../classSHA3__512.html#acfbc5e9b4d394f011d5132a2b156d260',1,'SHA3_512::clear()'],['../classSHA512.html#a0a9104dce5f099aeba216e5fbcb1ee1a',1,'SHA512::clear()'],['../classSHAKE.html#ab86f52425c1d5b0e5c924b4f96121fe0',1,'SHAKE::clear()'],['../classSpeck.html#aa3866273282addabb9d3703c41fdc95f',1,'Speck::clear()'],['../classSpeckSmall.html#aa93d9f0b5153425dc04e8fb8faff7513',1,'SpeckSmall::clear()'],['../classSpeckTiny.html#a303ecc2639459e47c6eeb21991d52ccf',1,'SpeckTiny::clear()'],['../classXOF.html#ac34cb22f251642b58b3dd78a6480aff3',1,'XOF::clear()'],['../classXTSCommon.html#a96e3cb4a3d35dc4e3a5acbae19b4465b',1,'XTSCommon::clear()'],['../classNewHopePoly.html#a842db1796a45ba78f279e008210df304',1,'NewHopePoly::clear()'],['../classTerminal.html#a4be741767b27739eec98901477e1c3d4',1,'Terminal::clear()']]], ['cleartoeol',['clearToEOL',['../classTerminal.html#aeb93d71925cdfb17065e7f1ef2e83414',1,'Terminal']]], ['color',['color',['../classTerminal.html#ad1fc2be31d49124a1d32e8afddaa57b8',1,'Terminal::color(Color fg)'],['../classTerminal.html#ae22436e478a854e8b559fe73182bc329',1,'Terminal::color(Color fg, Color bg)']]], ['columns',['columns',['../classTerminal.html#aed25b5a884f89dcd2bb269a8e356e5d6',1,'Terminal']]], diff --git a/search/functions_9.js b/search/functions_9.js index b57fdf5c..12d7c18d 100644 --- a/search/functions_9.js +++ b/search/functions_9.js @@ -1,5 +1,6 @@ var searchData= [ ['keccakcore',['KeccakCore',['../classKeccakCore.html#a850c8e85bdb6b347411239716535d9c9',1,'KeccakCore']]], + ['keygen',['keygen',['../classNewHope.html#ae8f821867bce309220aee7a43c2d4f51',1,'NewHope']]], ['keysize',['keySize',['../classAES128.html#aa871832a156f0ea61b964e489670ae9d',1,'AES128::keySize()'],['../classAES192.html#ade28843e51e262b30eb55791c83fd791',1,'AES192::keySize()'],['../classAES256.html#af8ed6412bae6fc78274f60344899366a',1,'AES256::keySize()'],['../classBlockCipher.html#afde6004a859e015d877eab3c37042a0f',1,'BlockCipher::keySize()'],['../classCBCCommon.html#adb7daacfe2a4fca3d13b62b75372fe4e',1,'CBCCommon::keySize()'],['../classCFBCommon.html#a82899da983bc70bc8152ee67f424552e',1,'CFBCommon::keySize()'],['../classChaCha.html#af286083291fab2bd36dc7ad1f54d5cd7',1,'ChaCha::keySize()'],['../classChaChaPoly.html#a666760e68cb53f28ba0a8dc09039c0fb',1,'ChaChaPoly::keySize()'],['../classCipher.html#a4cea432ea0278c865441f17cbb88b1ab',1,'Cipher::keySize()'],['../classCTRCommon.html#a29ce8e13a302350397fc6790a686bea2',1,'CTRCommon::keySize()'],['../classEAXCommon.html#a027956913eecfa0bc760f20f3b62df29',1,'EAXCommon::keySize()'],['../classGCMCommon.html#a134ba35e740a18bee3c45502b4149eae',1,'GCMCommon::keySize()'],['../classOFBCommon.html#a76ea9f9ea9dd137778338813e534a8ce',1,'OFBCommon::keySize()'],['../classSpeck.html#a061e43c1363178cda088c3f46e07d87b',1,'Speck::keySize()'],['../classSpeckTiny.html#a5587909ba48776b01bbd40b339b1262e',1,'SpeckTiny::keySize()'],['../classXTSCommon.html#a2da350825a438355665683ab9eb57aa7',1,'XTSCommon::keySize()'],['../classXTSSingleKeyCommon.html#ac017d457a08001a3ea44a9900dee2b64',1,'XTSSingleKeyCommon::keySize()']]] ]; diff --git a/search/functions_a.js b/search/functions_a.js index f9b30a30..9b3cf49b 100644 --- a/search/functions_a.js +++ b/search/functions_a.js @@ -1,7 +1,7 @@ var searchData= [ ['label',['label',['../classField.html#aaa861ef917130c989a955bc75c683afe',1,'Field']]], - ['lcd',['lcd',['../classField.html#a5cf21bf958a71e51feac9e1bf9f599d1',1,'Field::lcd()'],['../classLCD.html#a00bb2db1390721abc7b24ac4b8c276c8',1,'LCD::LCD()'],['../classLCD.html#a067bc741cf27f143aba5d9f147908401',1,'LCD::LCD(uint8_t pin9)'],['../classLCD.html#a203d268bef6c61fa293562dbb0e9f51e',1,'LCD::LCD(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)']]], + ['lcd',['LCD',['../classLCD.html#a00bb2db1390721abc7b24ac4b8c276c8',1,'LCD::LCD()'],['../classLCD.html#a067bc741cf27f143aba5d9f147908401',1,'LCD::LCD(uint8_t pin9)'],['../classLCD.html#a203d268bef6c61fa293562dbb0e9f51e',1,'LCD::LCD(uint8_t rs, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3)'],['../classField.html#a5cf21bf958a71e51feac9e1bf9f599d1',1,'Field::lcd()']]], ['led',['led',['../classCharlieplex.html#a90fd09f24b62424b0b7b8bcdb0140b9d',1,'Charlieplex']]], ['listfield',['ListField',['../classListField.html#a118501da7edb0b0bc6b493734975b4e9',1,'ListField::ListField(const String &label)'],['../classListField.html#aa303898a1f74b52c1c4982653de488b7',1,'ListField::ListField(Form &form, const String &label, ListItems items, int value=0)']]], ['loginshell',['LoginShell',['../classLoginShell.html#a8a6e6c259bc6415eb9cfbb13980e31d4',1,'LoginShell']]], diff --git a/search/functions_c.js b/search/functions_c.js index 1802e35b..6781c4f5 100644 --- a/search/functions_c.js +++ b/search/functions_c.js @@ -1,5 +1,6 @@ var searchData= [ + ['newhopepoly',['NewHopePoly',['../classNewHopePoly.html#aec9804046c753436ffbe88afd175bb39',1,'NewHopePoly']]], ['nextfield',['nextField',['../classForm.html#a788a186ea4a7ebd75283a948ca45f4d1',1,'Form']]], ['nodisplay',['noDisplay',['../classLCD.html#af3974da6d988ba2d21c25135ada12108',1,'LCD']]], ['noisesource',['NoiseSource',['../classNoiseSource.html#a601479b7d8cc215f97f2f8a18d3ef4c2',1,'NoiseSource']]], diff --git a/search/search.js b/search/search.js index ab43ca64..8b12b0f3 100644 --- a/search/search.js +++ b/search/search.js @@ -13,7 +13,7 @@ var indexSectionsWithContent = 3: "abcdefghiklmnoprstuvwx~", 4: "abdfhimnswy", 5: "cfp", - 6: "cdms", + 6: "cdmsv", 7: "bcdglmrstwy", 8: "s", 9: "p", diff --git a/shell-serial_8dox.html b/shell-serial_8dox.html index 2030e26a..1a3ac39b 100644 --- a/shell-serial_8dox.html +++ b/shell-serial_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/shell-telnet_8dox.html b/shell-telnet_8dox.html index a974ac83..479ebb71 100644 --- a/shell-telnet_8dox.html +++ b/shell-telnet_8dox.html @@ -87,7 +87,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/shell_serial.html b/shell_serial.html index 59c2894a..87b937e6 100644 --- a/shell_serial.html +++ b/shell_serial.html @@ -156,7 +156,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/shell_telnet.html b/shell_telnet.html index 98d84c1b..7c34a552 100644 --- a/shell_telnet.html +++ b/shell_telnet.html @@ -165,7 +165,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/structRTCAlarm.html b/structRTCAlarm.html index 89603d9d..2eef2d9a 100644 --- a/structRTCAlarm.html +++ b/structRTCAlarm.html @@ -200,7 +200,7 @@ uint8_t  diff --git a/structRTCDate.html b/structRTCDate.html index ca81b210..2affe648 100644 --- a/structRTCDate.html +++ b/structRTCDate.html @@ -123,7 +123,7 @@ uint8_t  diff --git a/structRTCTime.html b/structRTCTime.html index 978065d4..a5b98107 100644 --- a/structRTCTime.html +++ b/structRTCTime.html @@ -123,7 +123,7 @@ uint8_t