diff --git a/AES128_8cpp_source.html b/AES128_8cpp_source.html index 4d84bfe2..9bedb6c1 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 6cf8dc68..fabfb25a 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 583402e4..b14d7fd7 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 69f3881d..47bae3e7 100644 --- a/AESCommon_8cpp_source.html +++ b/AESCommon_8cpp_source.html @@ -193,137 +193,137 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
129 
134 AESCommon::~AESCommon()
135 {
-
136  clean(state1);
-
137  clean(state2);
-
138 }
-
139 
-
144 size_t AESCommon::blockSize() const
-
145 {
-
146  return 16;
-
147 }
-
148 
-
149 // Constants to correct Galois multiplication for the high bits
-
150 // that are shifted out when multiplying by powers of two.
-
151 static uint8_t const K[8] = {
-
152  0x00,
-
153  0x1B,
-
154  (0x1B << 1),
-
155  (0x1B << 1) ^ 0x1B,
-
156  (0x1B << 2),
-
157  (0x1B << 2) ^ 0x1B,
-
158  (0x1B << 2) ^ (0x1B << 1),
-
159  (0x1B << 2) ^ (0x1B << 1) ^ 0x1B
-
160 };
-
161 
-
162 // Multiply x by 2 in the Galois field, to achieve the effect of the following:
-
163 //
-
164 // if (x & 0x80)
-
165 // return (x << 1) ^ 0x1B;
-
166 // else
-
167 // return (x << 1);
-
168 //
-
169 // However, we don't want to use runtime conditionals if we can help it
-
170 // to avoid leaking timing information from the implementation.
-
171 // In this case, multiplication is slightly faster than table lookup on AVR.
-
172 #define gmul2(x) (t = ((uint16_t)(x)) << 1, \
-
173  ((uint8_t)t) ^ (uint8_t)(0x1B * ((uint8_t)(t >> 8))))
-
174 
-
175 // Multiply x by 4 in the Galois field.
-
176 #define gmul4(x) (t = ((uint16_t)(x)) << 2, ((uint8_t)t) ^ K[t >> 8])
-
177 
-
178 // Multiply x by 8 in the Galois field.
-
179 #define gmul8(x) (t = ((uint16_t)(x)) << 3, ((uint8_t)t) ^ K[t >> 8])
-
180 
-
181 #define OUT(col, row) output[(col) * 4 + (row)]
-
182 #define IN(col, row) input[(col) * 4 + (row)]
-
183 
-
184 static void subBytesAndShiftRows(uint8_t *output, const uint8_t *input)
-
185 {
-
186  OUT(0, 0) = pgm_read_byte(sbox + IN(0, 0));
-
187  OUT(0, 1) = pgm_read_byte(sbox + IN(1, 1));
-
188  OUT(0, 2) = pgm_read_byte(sbox + IN(2, 2));
-
189  OUT(0, 3) = pgm_read_byte(sbox + IN(3, 3));
-
190  OUT(1, 0) = pgm_read_byte(sbox + IN(1, 0));
-
191  OUT(1, 1) = pgm_read_byte(sbox + IN(2, 1));
-
192  OUT(1, 2) = pgm_read_byte(sbox + IN(3, 2));
-
193  OUT(1, 3) = pgm_read_byte(sbox + IN(0, 3));
-
194  OUT(2, 0) = pgm_read_byte(sbox + IN(2, 0));
-
195  OUT(2, 1) = pgm_read_byte(sbox + IN(3, 1));
-
196  OUT(2, 2) = pgm_read_byte(sbox + IN(0, 2));
-
197  OUT(2, 3) = pgm_read_byte(sbox + IN(1, 3));
-
198  OUT(3, 0) = pgm_read_byte(sbox + IN(3, 0));
-
199  OUT(3, 1) = pgm_read_byte(sbox + IN(0, 1));
-
200  OUT(3, 2) = pgm_read_byte(sbox + IN(1, 2));
-
201  OUT(3, 3) = pgm_read_byte(sbox + IN(2, 3));
-
202 }
-
203 
-
204 static void inverseShiftRowsAndSubBytes(uint8_t *output, const uint8_t *input)
-
205 {
-
206  OUT(0, 0) = pgm_read_byte(sbox_inverse + IN(0, 0));
-
207  OUT(0, 1) = pgm_read_byte(sbox_inverse + IN(3, 1));
-
208  OUT(0, 2) = pgm_read_byte(sbox_inverse + IN(2, 2));
-
209  OUT(0, 3) = pgm_read_byte(sbox_inverse + IN(1, 3));
-
210  OUT(1, 0) = pgm_read_byte(sbox_inverse + IN(1, 0));
-
211  OUT(1, 1) = pgm_read_byte(sbox_inverse + IN(0, 1));
-
212  OUT(1, 2) = pgm_read_byte(sbox_inverse + IN(3, 2));
-
213  OUT(1, 3) = pgm_read_byte(sbox_inverse + IN(2, 3));
-
214  OUT(2, 0) = pgm_read_byte(sbox_inverse + IN(2, 0));
-
215  OUT(2, 1) = pgm_read_byte(sbox_inverse + IN(1, 1));
-
216  OUT(2, 2) = pgm_read_byte(sbox_inverse + IN(0, 2));
-
217  OUT(2, 3) = pgm_read_byte(sbox_inverse + IN(3, 3));
-
218  OUT(3, 0) = pgm_read_byte(sbox_inverse + IN(3, 0));
-
219  OUT(3, 1) = pgm_read_byte(sbox_inverse + IN(2, 1));
-
220  OUT(3, 2) = pgm_read_byte(sbox_inverse + IN(1, 2));
-
221  OUT(3, 3) = pgm_read_byte(sbox_inverse + IN(0, 3));
-
222 }
-
223 
-
224 static void mixColumn(uint8_t *output, uint8_t *input)
-
225 {
-
226  uint16_t t; // Needed by the gmul2 macro.
-
227  uint8_t a = input[0];
-
228  uint8_t b = input[1];
-
229  uint8_t c = input[2];
-
230  uint8_t d = input[3];
-
231  uint8_t a2 = gmul2(a);
-
232  uint8_t b2 = gmul2(b);
-
233  uint8_t c2 = gmul2(c);
-
234  uint8_t d2 = gmul2(d);
-
235  output[0] = a2 ^ b2 ^ b ^ c ^ d;
-
236  output[1] = a ^ b2 ^ c2 ^ c ^ d;
-
237  output[2] = a ^ b ^ c2 ^ d2 ^ d;
-
238  output[3] = a2 ^ a ^ b ^ c ^ d2;
-
239 }
-
240 
-
241 static void inverseMixColumn(uint8_t *output, const uint8_t *input)
-
242 {
-
243  uint16_t t; // Needed by the gmul2, gmul4, and gmul8 macros.
-
244  uint8_t a = input[0];
-
245  uint8_t b = input[1];
-
246  uint8_t c = input[2];
-
247  uint8_t d = input[3];
-
248  uint8_t a2 = gmul2(a);
-
249  uint8_t b2 = gmul2(b);
-
250  uint8_t c2 = gmul2(c);
-
251  uint8_t d2 = gmul2(d);
-
252  uint8_t a4 = gmul4(a);
-
253  uint8_t b4 = gmul4(b);
-
254  uint8_t c4 = gmul4(c);
-
255  uint8_t d4 = gmul4(d);
-
256  uint8_t a8 = gmul8(a);
-
257  uint8_t b8 = gmul8(b);
-
258  uint8_t c8 = gmul8(c);
-
259  uint8_t d8 = gmul8(d);
-
260  output[0] = a8 ^ a4 ^ a2 ^ b8 ^ b2 ^ b ^ c8 ^ c4 ^ c ^ d8 ^ d;
-
261  output[1] = a8 ^ a ^ b8 ^ b4 ^ b2 ^ c8 ^ c2 ^ c ^ d8 ^ d4 ^ d;
-
262  output[2] = a8 ^ a4 ^ a ^ b8 ^ b ^ c8 ^ c4 ^ c2 ^ d8 ^ d2 ^ d;
-
263  output[3] = a8 ^ a2 ^ a ^ b8 ^ b4 ^ b ^ c8 ^ c ^ d8 ^ d4 ^ d2;
-
264 }
-
265 
-
266 void AESCommon::encryptBlock(uint8_t *output, const uint8_t *input)
-
267 {
-
268  const uint8_t *roundKey = schedule;
-
269  uint8_t posn;
-
270  uint8_t round;
+
136 }
+
137 
+
142 size_t AESCommon::blockSize() const
+
143 {
+
144  return 16;
+
145 }
+
146 
+
147 // Constants to correct Galois multiplication for the high bits
+
148 // that are shifted out when multiplying by powers of two.
+
149 static uint8_t const K[8] = {
+
150  0x00,
+
151  0x1B,
+
152  (0x1B << 1),
+
153  (0x1B << 1) ^ 0x1B,
+
154  (0x1B << 2),
+
155  (0x1B << 2) ^ 0x1B,
+
156  (0x1B << 2) ^ (0x1B << 1),
+
157  (0x1B << 2) ^ (0x1B << 1) ^ 0x1B
+
158 };
+
159 
+
160 // Multiply x by 2 in the Galois field, to achieve the effect of the following:
+
161 //
+
162 // if (x & 0x80)
+
163 // return (x << 1) ^ 0x1B;
+
164 // else
+
165 // return (x << 1);
+
166 //
+
167 // However, we don't want to use runtime conditionals if we can help it
+
168 // to avoid leaking timing information from the implementation.
+
169 // In this case, multiplication is slightly faster than table lookup on AVR.
+
170 #define gmul2(x) (t = ((uint16_t)(x)) << 1, \
+
171  ((uint8_t)t) ^ (uint8_t)(0x1B * ((uint8_t)(t >> 8))))
+
172 
+
173 // Multiply x by 4 in the Galois field.
+
174 #define gmul4(x) (t = ((uint16_t)(x)) << 2, ((uint8_t)t) ^ K[t >> 8])
+
175 
+
176 // Multiply x by 8 in the Galois field.
+
177 #define gmul8(x) (t = ((uint16_t)(x)) << 3, ((uint8_t)t) ^ K[t >> 8])
+
178 
+
179 #define OUT(col, row) output[(col) * 4 + (row)]
+
180 #define IN(col, row) input[(col) * 4 + (row)]
+
181 
+
182 static void subBytesAndShiftRows(uint8_t *output, const uint8_t *input)
+
183 {
+
184  OUT(0, 0) = pgm_read_byte(sbox + IN(0, 0));
+
185  OUT(0, 1) = pgm_read_byte(sbox + IN(1, 1));
+
186  OUT(0, 2) = pgm_read_byte(sbox + IN(2, 2));
+
187  OUT(0, 3) = pgm_read_byte(sbox + IN(3, 3));
+
188  OUT(1, 0) = pgm_read_byte(sbox + IN(1, 0));
+
189  OUT(1, 1) = pgm_read_byte(sbox + IN(2, 1));
+
190  OUT(1, 2) = pgm_read_byte(sbox + IN(3, 2));
+
191  OUT(1, 3) = pgm_read_byte(sbox + IN(0, 3));
+
192  OUT(2, 0) = pgm_read_byte(sbox + IN(2, 0));
+
193  OUT(2, 1) = pgm_read_byte(sbox + IN(3, 1));
+
194  OUT(2, 2) = pgm_read_byte(sbox + IN(0, 2));
+
195  OUT(2, 3) = pgm_read_byte(sbox + IN(1, 3));
+
196  OUT(3, 0) = pgm_read_byte(sbox + IN(3, 0));
+
197  OUT(3, 1) = pgm_read_byte(sbox + IN(0, 1));
+
198  OUT(3, 2) = pgm_read_byte(sbox + IN(1, 2));
+
199  OUT(3, 3) = pgm_read_byte(sbox + IN(2, 3));
+
200 }
+
201 
+
202 static void inverseShiftRowsAndSubBytes(uint8_t *output, const uint8_t *input)
+
203 {
+
204  OUT(0, 0) = pgm_read_byte(sbox_inverse + IN(0, 0));
+
205  OUT(0, 1) = pgm_read_byte(sbox_inverse + IN(3, 1));
+
206  OUT(0, 2) = pgm_read_byte(sbox_inverse + IN(2, 2));
+
207  OUT(0, 3) = pgm_read_byte(sbox_inverse + IN(1, 3));
+
208  OUT(1, 0) = pgm_read_byte(sbox_inverse + IN(1, 0));
+
209  OUT(1, 1) = pgm_read_byte(sbox_inverse + IN(0, 1));
+
210  OUT(1, 2) = pgm_read_byte(sbox_inverse + IN(3, 2));
+
211  OUT(1, 3) = pgm_read_byte(sbox_inverse + IN(2, 3));
+
212  OUT(2, 0) = pgm_read_byte(sbox_inverse + IN(2, 0));
+
213  OUT(2, 1) = pgm_read_byte(sbox_inverse + IN(1, 1));
+
214  OUT(2, 2) = pgm_read_byte(sbox_inverse + IN(0, 2));
+
215  OUT(2, 3) = pgm_read_byte(sbox_inverse + IN(3, 3));
+
216  OUT(3, 0) = pgm_read_byte(sbox_inverse + IN(3, 0));
+
217  OUT(3, 1) = pgm_read_byte(sbox_inverse + IN(2, 1));
+
218  OUT(3, 2) = pgm_read_byte(sbox_inverse + IN(1, 2));
+
219  OUT(3, 3) = pgm_read_byte(sbox_inverse + IN(0, 3));
+
220 }
+
221 
+
222 static void mixColumn(uint8_t *output, uint8_t *input)
+
223 {
+
224  uint16_t t; // Needed by the gmul2 macro.
+
225  uint8_t a = input[0];
+
226  uint8_t b = input[1];
+
227  uint8_t c = input[2];
+
228  uint8_t d = input[3];
+
229  uint8_t a2 = gmul2(a);
+
230  uint8_t b2 = gmul2(b);
+
231  uint8_t c2 = gmul2(c);
+
232  uint8_t d2 = gmul2(d);
+
233  output[0] = a2 ^ b2 ^ b ^ c ^ d;
+
234  output[1] = a ^ b2 ^ c2 ^ c ^ d;
+
235  output[2] = a ^ b ^ c2 ^ d2 ^ d;
+
236  output[3] = a2 ^ a ^ b ^ c ^ d2;
+
237 }
+
238 
+
239 static void inverseMixColumn(uint8_t *output, const uint8_t *input)
+
240 {
+
241  uint16_t t; // Needed by the gmul2, gmul4, and gmul8 macros.
+
242  uint8_t a = input[0];
+
243  uint8_t b = input[1];
+
244  uint8_t c = input[2];
+
245  uint8_t d = input[3];
+
246  uint8_t a2 = gmul2(a);
+
247  uint8_t b2 = gmul2(b);
+
248  uint8_t c2 = gmul2(c);
+
249  uint8_t d2 = gmul2(d);
+
250  uint8_t a4 = gmul4(a);
+
251  uint8_t b4 = gmul4(b);
+
252  uint8_t c4 = gmul4(c);
+
253  uint8_t d4 = gmul4(d);
+
254  uint8_t a8 = gmul8(a);
+
255  uint8_t b8 = gmul8(b);
+
256  uint8_t c8 = gmul8(c);
+
257  uint8_t d8 = gmul8(d);
+
258  output[0] = a8 ^ a4 ^ a2 ^ b8 ^ b2 ^ b ^ c8 ^ c4 ^ c ^ d8 ^ d;
+
259  output[1] = a8 ^ a ^ b8 ^ b4 ^ b2 ^ c8 ^ c2 ^ c ^ d8 ^ d4 ^ d;
+
260  output[2] = a8 ^ a4 ^ a ^ b8 ^ b ^ c8 ^ c4 ^ c2 ^ d8 ^ d2 ^ d;
+
261  output[3] = a8 ^ a2 ^ a ^ b8 ^ b4 ^ b ^ c8 ^ c ^ d8 ^ d4 ^ d2;
+
262 }
+
263 
+
264 void AESCommon::encryptBlock(uint8_t *output, const uint8_t *input)
+
265 {
+
266  const uint8_t *roundKey = schedule;
+
267  uint8_t posn;
+
268  uint8_t round;
+
269  uint8_t state1[16];
+
270  uint8_t state2[16];
271 
272  // Copy the input into the state and XOR with the first round key.
273  for (posn = 0; posn < 16; ++posn)
@@ -353,35 +353,35 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
297  const uint8_t *roundKey = schedule + rounds * 16;
298  uint8_t round;
299  uint8_t posn;
-
300 
-
301  // Copy the input into the state and reverse the final round.
-
302  for (posn = 0; posn < 16; ++posn)
-
303  state1[posn] = input[posn] ^ roundKey[posn];
-
304  inverseShiftRowsAndSubBytes(state2, state1);
-
305 
-
306  // Perform all other rounds in reverse.
-
307  for (round = rounds; round > 1; --round) {
-
308  roundKey -= 16;
-
309  for (posn = 0; posn < 16; ++posn)
-
310  state2[posn] ^= roundKey[posn];
-
311  inverseMixColumn(state1, state2);
-
312  inverseMixColumn(state1 + 4, state2 + 4);
-
313  inverseMixColumn(state1 + 8, state2 + 8);
-
314  inverseMixColumn(state1 + 12, state2 + 12);
-
315  inverseShiftRowsAndSubBytes(state2, state1);
-
316  }
-
317 
-
318  // Reverse the initial round and create the output words.
-
319  roundKey -= 16;
-
320  for (posn = 0; posn < 16; ++posn)
-
321  output[posn] = state2[posn] ^ roundKey[posn];
-
322 }
-
323 
-
324 void AESCommon::clear()
-
325 {
-
326  clean(schedule, (rounds + 1) * 16);
-
327  clean(state1);
-
328  clean(state2);
+
300  uint8_t state1[16];
+
301  uint8_t state2[16];
+
302 
+
303  // Copy the input into the state and reverse the final round.
+
304  for (posn = 0; posn < 16; ++posn)
+
305  state1[posn] = input[posn] ^ roundKey[posn];
+
306  inverseShiftRowsAndSubBytes(state2, state1);
+
307 
+
308  // Perform all other rounds in reverse.
+
309  for (round = rounds; round > 1; --round) {
+
310  roundKey -= 16;
+
311  for (posn = 0; posn < 16; ++posn)
+
312  state2[posn] ^= roundKey[posn];
+
313  inverseMixColumn(state1, state2);
+
314  inverseMixColumn(state1 + 4, state2 + 4);
+
315  inverseMixColumn(state1 + 8, state2 + 8);
+
316  inverseMixColumn(state1 + 12, state2 + 12);
+
317  inverseShiftRowsAndSubBytes(state2, state1);
+
318  }
+
319 
+
320  // Reverse the initial round and create the output words.
+
321  roundKey -= 16;
+
322  for (posn = 0; posn < 16; ++posn)
+
323  output[posn] = state2[posn] ^ roundKey[posn];
+
324 }
+
325 
+
326 void AESCommon::clear()
+
327 {
+
328  clean(schedule, (rounds + 1) * 16);
329 }
330 
333 void AESCommon::keyScheduleCore(uint8_t *output, const uint8_t *input, uint8_t iteration)
@@ -408,14 +408,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
354 
AESCommon::decryptBlock
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
Definition: AESCommon.cpp:295
AESCommon::AESCommon
AESCommon()
Constructs an AES block cipher object.
Definition: AESCommon.cpp:125
-
AESCommon::blockSize
size_t blockSize() const
Size of an AES block in bytes.
Definition: AESCommon.cpp:144
+
AESCommon::blockSize
size_t blockSize() const
Size of an AES block in bytes.
Definition: AESCommon.cpp:142
AESCommon::~AESCommon
virtual ~AESCommon()
Destroys this AES block cipher object after clearing sensitive information.
Definition: AESCommon.cpp:134
-
AESCommon::clear
void clear()
Clears all security-sensitive state from this block cipher.
Definition: AESCommon.cpp:324
-
AESCommon::encryptBlock
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
Definition: AESCommon.cpp:266
+
AESCommon::clear
void clear()
Clears all security-sensitive state from this block cipher.
Definition: AESCommon.cpp:326
+
AESCommon::encryptBlock
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
Definition: AESCommon.cpp:264
diff --git a/AES_8h_source.html b/AES_8h_source.html index 39dc1902..4d3ddaaa 100644 --- a/AES_8h_source.html +++ b/AES_8h_source.html @@ -135,78 +135,75 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
46 
47  void keyScheduleCore(uint8_t *output, const uint8_t *input, uint8_t iteration);
48  void applySbox(uint8_t *output, const uint8_t *input);
-
51 private:
-
52  uint8_t state1[16];
-
53  uint8_t state2[16];
-
54 };
-
55 
-
56 class AES128 : public AESCommon
-
57 {
-
58 public:
-
59  AES128();
-
60  virtual ~AES128();
+
50 };
+
51 
+
52 class AES128 : public AESCommon
+
53 {
+
54 public:
+
55  AES128();
+
56  virtual ~AES128();
+
57 
+
58  size_t keySize() const;
+
59 
+
60  bool setKey(const uint8_t *key, size_t len);
61 
-
62  size_t keySize() const;
-
63 
-
64  bool setKey(const uint8_t *key, size_t len);
+
62 private:
+
63  uint8_t sched[176];
+
64 };
65 
-
66 private:
-
67  uint8_t sched[176];
-
68 };
-
69 
-
70 class AES192 : public AESCommon
-
71 {
-
72 public:
-
73  AES192();
-
74  virtual ~AES192();
+
66 class AES192 : public AESCommon
+
67 {
+
68 public:
+
69  AES192();
+
70  virtual ~AES192();
+
71 
+
72  size_t keySize() const;
+
73 
+
74  bool setKey(const uint8_t *key, size_t len);
75 
-
76  size_t keySize() const;
-
77 
-
78  bool setKey(const uint8_t *key, size_t len);
+
76 private:
+
77  uint8_t sched[208];
+
78 };
79 
-
80 private:
-
81  uint8_t sched[208];
-
82 };
-
83 
-
84 class AES256 : public AESCommon
-
85 {
-
86 public:
-
87  AES256();
-
88  virtual ~AES256();
+
80 class AES256 : public AESCommon
+
81 {
+
82 public:
+
83  AES256();
+
84  virtual ~AES256();
+
85 
+
86  size_t keySize() const;
+
87 
+
88  bool setKey(const uint8_t *key, size_t len);
89 
-
90  size_t keySize() const;
-
91 
-
92  bool setKey(const uint8_t *key, size_t len);
+
90 private:
+
91  uint8_t sched[240];
+
92 };
93 
-
94 private:
-
95  uint8_t sched[240];
-
96 };
-
97 
-
98 #endif
+
94 #endif
AESCommon::decryptBlock
void decryptBlock(uint8_t *output, const uint8_t *input)
Decrypts a single block using this cipher.
Definition: AESCommon.cpp:295
-
AES256
AES block cipher with 256-bit keys.
Definition: AES.h:84
+
AES256
AES block cipher with 256-bit keys.
Definition: AES.h:80
BlockCipher
Abstract base class for block ciphers.
Definition: BlockCipher.h:29
AESCommon::AESCommon
AESCommon()
Constructs an AES block cipher object.
Definition: AESCommon.cpp:125
AES128::keySize
size_t keySize() const
Size of a 128-bit AES key in bytes.
Definition: AES128.cpp:55
AES192::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: AES192.cpp:60
-
AESCommon::blockSize
size_t blockSize() const
Size of an AES block in bytes.
Definition: AESCommon.cpp:144
+
AESCommon::blockSize
size_t blockSize() const
Size of an AES block in bytes.
Definition: AESCommon.cpp:142
AESCommon::~AESCommon
virtual ~AESCommon()
Destroys this AES block cipher object after clearing sensitive information.
Definition: AESCommon.cpp:134
-
AESCommon::clear
void clear()
Clears all security-sensitive state from this block cipher.
Definition: AESCommon.cpp:324
+
AESCommon::clear
void clear()
Clears all security-sensitive state from this block cipher.
Definition: AESCommon.cpp:326
AES128::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: AES128.cpp:60
AES192::keySize
size_t keySize() const
Size of a 192-bit AES key in bytes.
Definition: AES192.cpp:55
-
AESCommon::encryptBlock
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
Definition: AESCommon.cpp:266
+
AESCommon::encryptBlock
void encryptBlock(uint8_t *output, const uint8_t *input)
Encrypts a single block using this cipher.
Definition: AESCommon.cpp:264
AES256::AES256
AES256()
Constructs an AES 256-bit block cipher with no initial key.
Definition: AES256.cpp:40
AESCommon
Abstract base class for AES block ciphers.
Definition: AES.h:28
AES256::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: AES256.cpp:60
-
AES128
AES block cipher with 128-bit keys.
Definition: AES.h:56
+
AES128
AES block cipher with 128-bit keys.
Definition: AES.h:52
AES256::keySize
size_t keySize() const
Size of a 256-bit AES key in bytes.
Definition: AES256.cpp:55
AES128::AES128
AES128()
Constructs an AES 128-bit block cipher with no initial key.
Definition: AES128.cpp:40
-
AES192
AES block cipher with 192-bit keys.
Definition: AES.h:70
+
AES192
AES block cipher with 192-bit keys.
Definition: AES.h:66
AES192::AES192
AES192()
Constructs an AES 192-bit block cipher with no initial key.
Definition: AES192.cpp:40
diff --git a/AuthenticatedCipher_8cpp_source.html b/AuthenticatedCipher_8cpp_source.html index e720d526..d1465a41 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 9dc470e0..9acfdb90 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 966ad70e..c32ca8bd 100644 --- a/BLAKE2b_8cpp_source.html +++ b/BLAKE2b_8cpp_source.html @@ -278,43 +278,44 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
216 void BLAKE2b::processChunk(uint64_t f0)
217 {
218  uint8_t index;
-
219 
-
220  // Byte-swap the message buffer into little-endian if necessary.
-
221 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
222  for (index = 0; index < 16; ++index)
-
223  state.m[index] = le64toh(state.m[index]);
-
224 #endif
-
225 
-
226  // Format the block to be hashed.
-
227  memcpy(state.v, state.h, sizeof(state.h));
-
228  state.v[8] = BLAKE2b_IV0;
-
229  state.v[9] = BLAKE2b_IV1;
-
230  state.v[10] = BLAKE2b_IV2;
-
231  state.v[11] = BLAKE2b_IV3;
-
232  state.v[12] = BLAKE2b_IV4 ^ state.lengthLow;
-
233  state.v[13] = BLAKE2b_IV5 ^ state.lengthHigh;
-
234  state.v[14] = BLAKE2b_IV6 ^ f0;
-
235  state.v[15] = BLAKE2b_IV7;
-
236 
-
237  // Perform the 12 BLAKE2b rounds.
-
238  for (index = 0; index < 12; ++index) {
-
239  // Column round.
-
240  quarterRound(state.v[0], state.v[4], state.v[8], state.v[12], 0);
-
241  quarterRound(state.v[1], state.v[5], state.v[9], state.v[13], 1);
-
242  quarterRound(state.v[2], state.v[6], state.v[10], state.v[14], 2);
-
243  quarterRound(state.v[3], state.v[7], state.v[11], state.v[15], 3);
-
244 
-
245  // Diagonal round.
-
246  quarterRound(state.v[0], state.v[5], state.v[10], state.v[15], 4);
-
247  quarterRound(state.v[1], state.v[6], state.v[11], state.v[12], 5);
-
248  quarterRound(state.v[2], state.v[7], state.v[8], state.v[13], 6);
-
249  quarterRound(state.v[3], state.v[4], state.v[9], state.v[14], 7);
-
250  }
-
251 
-
252  // Combine the new and old hash values.
-
253  for (index = 0; index < 8; ++index)
-
254  state.h[index] ^= (state.v[index] ^ state.v[index + 8]);
-
255 }
+
219  uint64_t v[16];
+
220 
+
221  // Byte-swap the message buffer into little-endian if necessary.
+
222 #if !defined(CRYPTO_LITTLE_ENDIAN)
+
223  for (index = 0; index < 16; ++index)
+
224  state.m[index] = le64toh(state.m[index]);
+
225 #endif
+
226 
+
227  // Format the block to be hashed.
+
228  memcpy(v, state.h, sizeof(state.h));
+
229  v[8] = BLAKE2b_IV0;
+
230  v[9] = BLAKE2b_IV1;
+
231  v[10] = BLAKE2b_IV2;
+
232  v[11] = BLAKE2b_IV3;
+
233  v[12] = BLAKE2b_IV4 ^ state.lengthLow;
+
234  v[13] = BLAKE2b_IV5 ^ state.lengthHigh;
+
235  v[14] = BLAKE2b_IV6 ^ f0;
+
236  v[15] = BLAKE2b_IV7;
+
237 
+
238  // Perform the 12 BLAKE2b rounds.
+
239  for (index = 0; index < 12; ++index) {
+
240  // Column round.
+
241  quarterRound(v[0], v[4], v[8], v[12], 0);
+
242  quarterRound(v[1], v[5], v[9], v[13], 1);
+
243  quarterRound(v[2], v[6], v[10], v[14], 2);
+
244  quarterRound(v[3], v[7], v[11], v[15], 3);
+
245 
+
246  // Diagonal round.
+
247  quarterRound(v[0], v[5], v[10], v[15], 4);
+
248  quarterRound(v[1], v[6], v[11], v[12], 5);
+
249  quarterRound(v[2], v[7], v[8], v[13], 6);
+
250  quarterRound(v[3], v[4], v[9], v[14], 7);
+
251  }
+
252 
+
253  // Combine the new and old hash values.
+
254  for (index = 0; index < 8; ++index)
+
255  state.h[index] ^= (v[index] ^ v[index + 8]);
+
256 }
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:143
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:81
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:159
@@ -330,7 +331,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2b_8h_source.html b/BLAKE2b_8h_source.html index 62041082..64adb158 100644 --- a/BLAKE2b_8h_source.html +++ b/BLAKE2b_8h_source.html @@ -138,16 +138,15 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
48  struct {
49  uint64_t h[8];
50  uint64_t m[16];
-
51  uint64_t v[16];
-
52  uint64_t lengthLow;
-
53  uint64_t lengthHigh;
-
54  uint8_t chunkSize;
-
55  } state;
-
56 
-
57  void processChunk(uint64_t f0);
-
58 };
-
59 
-
60 #endif
+
51  uint64_t lengthLow;
+
52  uint64_t lengthHigh;
+
53  uint8_t chunkSize;
+
54  } state;
+
55 
+
56  void processChunk(uint64_t f0);
+
57 };
+
58 
+
59 #endif
BLAKE2b::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: BLAKE2b.cpp:143
BLAKE2b::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: BLAKE2b.cpp:81
BLAKE2b::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2b.cpp:159
@@ -163,7 +162,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2s_8cpp_source.html b/BLAKE2s_8cpp_source.html index 0a3efeee..d12dbcd7 100644 --- a/BLAKE2s_8cpp_source.html +++ b/BLAKE2s_8cpp_source.html @@ -271,43 +271,44 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
209 void BLAKE2s::processChunk(uint32_t f0)
210 {
211  uint8_t index;
-
212 
-
213  // Byte-swap the message buffer into little-endian if necessary.
-
214 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
215  for (index = 0; index < 16; ++index)
-
216  state.m[index] = le32toh(state.m[index]);
-
217 #endif
-
218 
-
219  // Format the block to be hashed.
-
220  memcpy(state.v, state.h, sizeof(state.h));
-
221  state.v[8] = BLAKE2s_IV0;
-
222  state.v[9] = BLAKE2s_IV1;
-
223  state.v[10] = BLAKE2s_IV2;
-
224  state.v[11] = BLAKE2s_IV3;
-
225  state.v[12] = BLAKE2s_IV4 ^ (uint32_t)(state.length);
-
226  state.v[13] = BLAKE2s_IV5 ^ (uint32_t)(state.length >> 32);
-
227  state.v[14] = BLAKE2s_IV6 ^ f0;
-
228  state.v[15] = BLAKE2s_IV7;
-
229 
-
230  // Perform the 10 BLAKE2s rounds.
-
231  for (index = 0; index < 10; ++index) {
-
232  // Column round.
-
233  quarterRound(state.v[0], state.v[4], state.v[8], state.v[12], 0);
-
234  quarterRound(state.v[1], state.v[5], state.v[9], state.v[13], 1);
-
235  quarterRound(state.v[2], state.v[6], state.v[10], state.v[14], 2);
-
236  quarterRound(state.v[3], state.v[7], state.v[11], state.v[15], 3);
-
237 
-
238  // Diagonal round.
-
239  quarterRound(state.v[0], state.v[5], state.v[10], state.v[15], 4);
-
240  quarterRound(state.v[1], state.v[6], state.v[11], state.v[12], 5);
-
241  quarterRound(state.v[2], state.v[7], state.v[8], state.v[13], 6);
-
242  quarterRound(state.v[3], state.v[4], state.v[9], state.v[14], 7);
-
243  }
-
244 
-
245  // Combine the new and old hash values.
-
246  for (index = 0; index < 8; ++index)
-
247  state.h[index] ^= (state.v[index] ^ state.v[index + 8]);
-
248 }
+
212  uint32_t v[16];
+
213 
+
214  // Byte-swap the message buffer into little-endian if necessary.
+
215 #if !defined(CRYPTO_LITTLE_ENDIAN)
+
216  for (index = 0; index < 16; ++index)
+
217  state.m[index] = le32toh(state.m[index]);
+
218 #endif
+
219 
+
220  // Format the block to be hashed.
+
221  memcpy(v, state.h, sizeof(state.h));
+
222  v[8] = BLAKE2s_IV0;
+
223  v[9] = BLAKE2s_IV1;
+
224  v[10] = BLAKE2s_IV2;
+
225  v[11] = BLAKE2s_IV3;
+
226  v[12] = BLAKE2s_IV4 ^ (uint32_t)(state.length);
+
227  v[13] = BLAKE2s_IV5 ^ (uint32_t)(state.length >> 32);
+
228  v[14] = BLAKE2s_IV6 ^ f0;
+
229  v[15] = BLAKE2s_IV7;
+
230 
+
231  // Perform the 10 BLAKE2s rounds.
+
232  for (index = 0; index < 10; ++index) {
+
233  // Column round.
+
234  quarterRound(v[0], v[4], v[8], v[12], 0);
+
235  quarterRound(v[1], v[5], v[9], v[13], 1);
+
236  quarterRound(v[2], v[6], v[10], v[14], 2);
+
237  quarterRound(v[3], v[7], v[11], v[15], 3);
+
238 
+
239  // Diagonal round.
+
240  quarterRound(v[0], v[5], v[10], v[15], 4);
+
241  quarterRound(v[1], v[6], v[11], v[12], 5);
+
242  quarterRound(v[2], v[7], v[8], v[13], 6);
+
243  quarterRound(v[3], v[4], v[9], v[14], 7);
+
244  }
+
245 
+
246  // Combine the new and old hash values.
+
247  for (index = 0; index < 8; ++index)
+
248  state.h[index] ^= (v[index] ^ v[index + 8]);
+
249 }
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:56
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:61
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:154
@@ -322,7 +323,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BLAKE2s_8h_source.html b/BLAKE2s_8h_source.html index 02a486b8..0caa29aa 100644 --- a/BLAKE2s_8h_source.html +++ b/BLAKE2s_8h_source.html @@ -138,15 +138,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
48  struct {
49  uint32_t h[8];
50  uint32_t m[16];
-
51  uint32_t v[16];
-
52  uint64_t length;
-
53  uint8_t chunkSize;
-
54  } state;
-
55 
-
56  void processChunk(uint32_t f0);
-
57 };
-
58 
-
59 #endif
+
51  uint64_t length;
+
52  uint8_t chunkSize;
+
53  } state;
+
54 
+
55  void processChunk(uint32_t f0);
+
56 };
+
57 
+
58 #endif
BLAKE2s::~BLAKE2s
virtual ~BLAKE2s()
Destroys this BLAKE2s hash object after clearing sensitive information.
Definition: BLAKE2s.cpp:56
BLAKE2s::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: BLAKE2s.cpp:61
BLAKE2s::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: BLAKE2s.cpp:154
@@ -162,7 +161,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BigNumberUtil_8cpp_source.html b/BigNumberUtil_8cpp_source.html index 0dc557f7..4b9f92ce 100644 --- a/BigNumberUtil_8cpp_source.html +++ b/BigNumberUtil_8cpp_source.html @@ -557,7 +557,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/BigNumberUtil_8h_source.html b/BigNumberUtil_8h_source.html index 2d1f2c2e..adbbbbc4 100644 --- a/BigNumberUtil_8h_source.html +++ b/BigNumberUtil_8h_source.html @@ -199,7 +199,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Bitmap_8cpp_source.html b/Bitmap_8cpp_source.html index 50b188e0..ab7ffe7f 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 6e1d40f2..76cd2d2a 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 c4730d9b..d0aa31c9 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 a8278398..4ad01546 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 b3ebead4..20cc4246 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 e0338030..2dc62951 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 afd5a151..4bc423a6 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 4e25dcfe..99545348 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 ef82e6a6..9cee324d 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 d3228725..885a9557 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 2f16a148..045597d7 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 e55b3345..80a12c13 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 b3638cfe..74e6eb00 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 b3cf13da..70e8c026 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 4f2b277e..bdacc077 100644 --- a/ChaChaPoly_8cpp_source.html +++ b/ChaChaPoly_8cpp_source.html @@ -255,14 +255,14 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
ChaCha::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaCha.cpp:218
ChaChaPoly::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: ChaChaPoly.cpp:163
ChaChaPoly::decrypt
void decrypt(uint8_t *output, const uint8_t *input, size_t len)
Decrypts an input buffer and writes the plaintext to an output buffer.
Definition: ChaChaPoly.cpp:115
-
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:250
-
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:264
+
Poly1305::pad
void pad()
Pads the input stream with zero bytes to a multiple of 16.
Definition: Poly1305.cpp:251
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
ChaChaPoly::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: ChaChaPoly.cpp:79
ChaChaPoly::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: ChaChaPoly.cpp:149
diff --git a/ChaChaPoly_8h_source.html b/ChaChaPoly_8h_source.html index 52918691..17ba7295 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 c1579435..a7bb8fe8 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 86e0778d..b1839bbc 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 30e46de5..3529c7f3 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 f9721fc8..e88e7697 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 f5a801b8..4d1d34a7 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 1bb5f6f8..add50732 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 f980347d..eb4659ab 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 d50f0d55..fa724c5c 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 6789c024..7c65d6a8 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 f35d5581..49c37693 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 32f61e8a..40680165 100644 --- a/Curve25519_8cpp_source.html +++ b/Curve25519_8cpp_source.html @@ -803,7 +803,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
961  clean(y);
962  return false;
963 }
-
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:428
+
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:74
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
@@ -812,7 +812,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Curve25519_8h_source.html b/Curve25519_8h_source.html index d702e59d..4996a2d4 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 18a9d349..1f70623d 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 e5af6870..133c185f 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 fe8e1a78..58b1f999 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 8c5a9719..8bd7e396 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 804be8db..1a60bdc9 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 829ac9b2..fa4f25fa 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 9a696554..df0c1fce 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 fe8fd2ee..37d2e76b 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 245b8027..c34aac44 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 bd0c99af..e133cef0 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 f0b708e3..21018def 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 new file mode 100644 index 00000000..5c9c7faf --- /dev/null +++ b/EAX_8cpp_source.html @@ -0,0 +1,385 @@ + + + + + + +ArduinoLibs: EAX.cpp Source File + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ + +
+
+
+
EAX.cpp
+
+
+
1 /*
+
2  * Copyright (C) 2015 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 "EAX.h"
+
24 #include "Crypto.h"
+
25 #include <string.h>
+
26 
+ +
44  : blockCipher(0)
+
45 {
+
46  state.encPosn = 0;
+
47  state.authPosn = 0;
+
48  state.authMode = 0;
+
49 }
+
50 
+
51 EAXCommon::~EAXCommon()
+
52 {
+
53  clean(state);
+
54 }
+
55 
+
56 size_t EAXCommon::keySize() const
+
57 {
+
58  return blockCipher->keySize();
+
59 }
+
60 
+
61 size_t EAXCommon::ivSize() const
+
62 {
+
63  // Can use any size but 16 is recommended.
+
64  return 16;
+
65 }
+
66 
+
67 size_t EAXCommon::tagSize() const
+
68 {
+
69  // Tags can be up to 16 bytes in length.
+
70  return 16;
+
71 }
+
72 
+
73 bool EAXCommon::setKey(const uint8_t *key, size_t len)
+
74 {
+
75  return blockCipher->setKey(key, len);
+
76 }
+
77 
+
78 bool EAXCommon::setIV(const uint8_t *iv, size_t len)
+
79 {
+
80  // Must have at least 1 byte for the IV.
+
81  if (!len)
+
82  return false;
+
83 
+
84  // Hash the IV to create the initial nonce for CTR mode. Also creates B.
+
85  omacInitFirst(state.counter);
+
86  omacUpdate(state.counter, iv, len);
+
87  omacFinal(state.counter);
+
88 
+
89  // The tag is initially the nonce value. Will be XOR'ed with
+
90  // the hash of the authenticated and encrypted data later.
+
91  memcpy(state.tag, state.counter, 16);
+
92 
+
93  // Start the hashing context for the authenticated data.
+
94  omacInit(state.hash, 1);
+
95  state.encPosn = 16;
+
96  state.authMode = 1;
+
97 
+
98  // The EAX context is ready to go.
+
99  return true;
+
100 }
+
101 
+
102 void EAXCommon::encrypt(uint8_t *output, const uint8_t *input, size_t len)
+
103 {
+
104  if (state.authMode)
+
105  closeAuthData();
+
106  encryptCTR(output, input, len);
+
107  omacUpdate(state.hash, output, len);
+
108 }
+
109 
+
110 void EAXCommon::decrypt(uint8_t *output, const uint8_t *input, size_t len)
+
111 {
+
112  if (state.authMode)
+
113  closeAuthData();
+
114  omacUpdate(state.hash, input, len);
+
115  encryptCTR(output, input, len);
+
116 }
+
117 
+
118 void EAXCommon::addAuthData(const void *data, size_t len)
+
119 {
+
120  if (state.authMode)
+
121  omacUpdate(state.hash, (const uint8_t *)data, len);
+
122 }
+
123 
+
124 void EAXCommon::computeTag(void *tag, size_t len)
+
125 {
+
126  closeTag();
+
127  if (len > 16)
+
128  len = 16;
+
129  memcpy(tag, state.tag, len);
+
130 }
+
131 
+
132 bool EAXCommon::checkTag(const void *tag, size_t len)
+
133 {
+
134  // Can never match if the expected tag length is too long.
+
135  if (len > 16)
+
136  return false;
+
137 
+
138  // Compute the final tag and check it.
+
139  closeTag();
+
140  return secure_compare(state.tag, tag, len);
+
141 }
+
142 
+ +
144 {
+
145  clean(state);
+
146 }
+
147 
+
148 // Doubles a 128-bit value in the GF(2^128) field.
+
149 static void gfDouble(uint8_t value[16])
+
150 {
+
151  uint16_t temp = 0;
+
152  for (uint8_t index = 16; index > 0; ) {
+
153  --index;
+
154  temp |= (((uint16_t)(value[index])) << 1);
+
155  value[index] = (uint8_t)temp;
+
156  temp >>= 8;
+
157  }
+
158  value[15] ^= (uint8_t)((-temp) & 0x87);
+
159 }
+
160 
+
166 void EAXCommon::omacInitFirst(uint8_t omac[16])
+
167 {
+
168  // Start the OMAC context for the nonce. We assume that the
+
169  // data that follows will be at least 1 byte in length so that
+
170  // we can encrypt the zeroes now to derive the B value.
+
171  memset(omac, 0, 16);
+
172  blockCipher->encryptBlock(omac, omac);
+
173  state.authPosn = 0;
+
174 
+
175  // Generate the B value from the encrypted block of zeroes.
+
176  // We will need this later when finalising the OMAC hashes.
+
177  memcpy(state.b, omac, 16);
+
178  gfDouble(state.b);
+
179 }
+
180 
+
187 void EAXCommon::omacInit(uint8_t omac[16], uint8_t t)
+
188 {
+
189  memset(omac, 0, 15);
+
190  omac[15] = t;
+
191  state.authPosn = 16;
+
192 }
+
193 
+
201 void EAXCommon::omacUpdate(uint8_t omac[16], const uint8_t *data, size_t len)
+
202 {
+
203  while (len > 0) {
+
204  // Encrypt the current block if it is already full.
+
205  if (state.authPosn == 16) {
+
206  blockCipher->encryptBlock(omac, omac);
+
207  state.authPosn = 0;
+
208  }
+
209 
+
210  // XOR the incoming data with the current block.
+
211  uint8_t size = 16 - state.authPosn;
+
212  if (size > len)
+
213  size = (uint8_t)len;
+
214  for (uint8_t index = 0; index < size; ++index)
+
215  omac[(state.authPosn)++] ^= data[index];
+
216 
+
217  // Move onto the next block.
+
218  len -= size;
+
219  data += size;
+
220  }
+
221 }
+
222 
+
228 void EAXCommon::omacFinal(uint8_t omac[16])
+
229 {
+
230  // Apply padding if necessary.
+
231  if (state.authPosn != 16) {
+
232  // Need padding: XOR with P = 2 * B.
+
233  uint8_t p[16];
+
234  memcpy(p, state.b, 16);
+
235  gfDouble(p);
+
236  omac[state.authPosn] ^= 0x80;
+
237  for (uint8_t index = 0; index < 16; ++index)
+
238  omac[index] ^= p[index];
+
239  clean(p);
+
240  } else {
+
241  // No padding necessary: XOR with B.
+
242  for (uint8_t index = 0; index < 16; ++index)
+
243  omac[index] ^= state.b[index];
+
244  }
+
245 
+
246  // Encrypt the hash to get the final OMAC value.
+
247  blockCipher->encryptBlock(omac, omac);
+
248 }
+
249 
+
254 void EAXCommon::closeAuthData()
+
255 {
+
256  // Finalise the OMAC hash and XOR it with the final tag.
+
257  omacFinal(state.hash);
+
258  for (uint8_t index = 0; index < 16; ++index)
+
259  state.tag[index] ^= state.hash[index];
+
260  state.authMode = 0;
+
261 
+
262  // Initialise the hashing context for the ciphertext data.
+
263  omacInit(state.hash, 2);
+
264 }
+
265 
+
275 void EAXCommon::encryptCTR(uint8_t *output, const uint8_t *input, size_t len)
+
276 {
+
277  while (len > 0) {
+
278  // Do we need to start a new block?
+
279  if (state.encPosn == 16) {
+
280  // Encrypt the counter to create the next keystream block.
+
281  blockCipher->encryptBlock(state.stream, state.counter);
+
282  state.encPosn = 0;
+
283 
+
284  // Increment the counter, taking care not to reveal
+
285  // any timing information about the starting value.
+
286  // We iterate through the entire counter region even
+
287  // if we could stop earlier because a byte is non-zero.
+
288  uint16_t temp = 1;
+
289  uint8_t index = 16;
+
290  while (index > 0) {
+
291  --index;
+
292  temp += state.counter[index];
+
293  state.counter[index] = (uint8_t)temp;
+
294  temp >>= 8;
+
295  }
+
296  }
+
297 
+
298  // Encrypt/decrypt the current input block.
+
299  uint8_t size = 16 - state.encPosn;
+
300  if (size > len)
+
301  size = (uint8_t)len;
+
302  for (uint8_t index = 0; index < size; ++index)
+
303  output[index] = input[index] ^ state.stream[(state.encPosn)++];
+
304 
+
305  // Move onto the next block.
+
306  len -= size;
+
307  input += size;
+
308  output += size;
+
309  }
+
310 }
+
311 
+
312 void EAXCommon::closeTag()
+
313 {
+
314  // If we were only authenticating, then close off auth mode.
+
315  if (state.authMode)
+
316  closeAuthData();
+
317 
+
318  // Finalise the hash over the ciphertext and XOR with the final tag.
+
319  omacFinal(state.hash);
+
320  for (uint8_t index = 0; index < 16; ++index)
+
321  state.tag[index] ^= state.hash[index];
+
322 }
+
323 
+
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
Definition: EAX.cpp:78
+
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: EAX.cpp:110
+
size_t tagSize() const
Returns the size of the authentication tag.
Definition: EAX.cpp:67
+
EAXCommon()
Constructs a new cipher in EAX mode.
Definition: EAX.cpp:43
+
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: EAX.cpp:132
+
virtual void encryptBlock(uint8_t *output, const uint8_t *input)=0
Encrypts a single block using this cipher.
+
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: EAX.cpp:102
+
void clear()
Clears all security-sensitive state from this cipher.
Definition: EAX.cpp:143
+
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: EAX.cpp:73
+
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: EAX.cpp:124
+
virtual bool setKey(const uint8_t *key, size_t len)=0
Sets the key to use for future encryption and decryption operations.
+
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
Definition: EAX.cpp:61
+
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: EAX.cpp:118
+
size_t keySize() const
Default size of the key for this cipher, in bytes.
Definition: EAX.cpp:56
+
virtual size_t keySize() const =0
Default size of the key for this block cipher, in bytes.
+
+ + + + diff --git a/EAX_8h_source.html b/EAX_8h_source.html new file mode 100644 index 00000000..9f2e8d73 --- /dev/null +++ b/EAX_8h_source.html @@ -0,0 +1,205 @@ + + + + + + +ArduinoLibs: EAX.h Source File + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ + +
+
+
+
EAX.h
+
+
+
1 /*
+
2  * Copyright (C) 2015 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_EAX_h
+
24 #define CRYPTO_EAX_h
+
25 
+
26 #include "AuthenticatedCipher.h"
+
27 #include "BlockCipher.h"
+
28 
+ +
30 {
+
31 public:
+
32  virtual ~EAXCommon();
+
33 
+
34  size_t keySize() const;
+
35  size_t ivSize() const;
+
36  size_t tagSize() const;
+
37 
+
38  bool setKey(const uint8_t *key, size_t len);
+
39  bool setIV(const uint8_t *iv, size_t len);
+
40 
+
41  void encrypt(uint8_t *output, const uint8_t *input, size_t len);
+
42  void decrypt(uint8_t *output, const uint8_t *input, size_t len);
+
43 
+
44  void addAuthData(const void *data, size_t len);
+
45 
+
46  void computeTag(void *tag, size_t len);
+
47  bool checkTag(const void *tag, size_t len);
+
48 
+
49  void clear();
+
50 
+
51 protected:
+
52  EAXCommon();
+
53  void setBlockCipher(BlockCipher *cipher) { blockCipher = cipher; }
+
54 
+
55 private:
+
56  BlockCipher *blockCipher;
+
57  struct {
+
58  uint8_t counter[16];
+
59  uint8_t stream[16];
+
60  uint8_t tag[16];
+
61  uint8_t hash[16];
+
62  uint8_t b[16];
+
63  uint8_t encPosn;
+
64  uint8_t authPosn;
+
65  uint8_t authMode;
+
66  } state;
+
67 
+
68  void omacInitFirst(uint8_t omac[16]);
+
69  void omacInit(uint8_t omac[16], uint8_t t);
+
70  void omacUpdate(uint8_t omac[16], const uint8_t *data, size_t len);
+
71  void omacFinal(uint8_t omac[16]);
+
72 
+
73  void closeAuthData();
+
74  void encryptCTR(uint8_t *output, const uint8_t *input, size_t len);
+
75  void closeTag();
+
76 };
+
77 
+
78 template <typename T>
+
79 class EAX : public EAXCommon
+
80 {
+
81 public:
+
82  EAX() { setBlockCipher(&cipher); }
+
83 
+
84 private:
+
85  T cipher;
+
86 };
+
87 
+
88 #endif
+
bool setIV(const uint8_t *iv, size_t len)
Sets the initialization vector to use for future encryption and decryption operations.
Definition: EAX.cpp:78
+
Abstract base class for block ciphers.
Definition: BlockCipher.h:29
+
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: EAX.cpp:110
+
Abstract base class for authenticated ciphers.
+
size_t tagSize() const
Returns the size of the authentication tag.
Definition: EAX.cpp:67
+
EAXCommon()
Constructs a new cipher in EAX mode.
Definition: EAX.cpp:43
+
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: EAX.cpp:132
+
Concrete base class to assist with implementing EAX for 128-bit block ciphers.
Definition: EAX.h:29
+
EAX()
Constructs a new EAX object for the block cipher T.
Definition: EAX.h:82
+
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: EAX.cpp:102
+
void clear()
Clears all security-sensitive state from this cipher.
Definition: EAX.cpp:143
+
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: EAX.cpp:73
+
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: EAX.cpp:124
+
Implementation of the EAX authenticated cipher.
Definition: EAX.h:79
+
void setBlockCipher(BlockCipher *cipher)
Sets the block cipher to use for this EAX object.
Definition: EAX.h:53
+
size_t ivSize() const
Size of the initialization vector for this cipher, in bytes.
Definition: EAX.cpp:61
+
void addAuthData(const void *data, size_t len)
Adds extra data that will be authenticated but not encrypted.
Definition: EAX.cpp:118
+
size_t keySize() const
Default size of the key for this cipher, in bytes.
Definition: EAX.cpp:56
+
+ + + + diff --git a/EEPROM24_8cpp_source.html b/EEPROM24_8cpp_source.html index 54aec0cf..26e2b9a8 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 50bc6b95..ed752b8e 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 ad3636b4..56a7868d 100644 --- a/Ed25519_8cpp_source.html +++ b/Ed25519_8cpp_source.html @@ -557,7 +557,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
BigNumberUtil::reduceQuick_P
static void reduceQuick_P(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Reduces x modulo y using subtraction where y is in program memory.
Definition: BigNumberUtil.cpp:620
Ed25519::generatePrivateKey
static void generatePrivateKey(uint8_t privateKey[32])
Generates a private key for Ed25519 signing operations.
Definition: Ed25519.cpp:243
BigNumberUtil::add
static limb_t add(limb_t *result, const limb_t *x, const limb_t *y, size_t size)
Adds two big numbers.
Definition: BigNumberUtil.cpp:381
-
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:428
+
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
@@ -572,7 +572,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Ed25519_8h_source.html b/Ed25519_8h_source.html index 55e52a46..c9781fd4 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 b546046c..62d4693c 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 b8e18f1c..3f05b1fc 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 8e7b6ff8..bec44771 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 9a9d5c0c..3bac4385 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 5a136ae7..43ab987e 100644 --- a/GCM_8cpp_source.html +++ b/GCM_8cpp_source.html @@ -136,13 +136,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
65 
66 size_t GCMCommon::ivSize() const
67 {
-
68  return 16;
-
69 }
-
70 
-
71 size_t GCMCommon::tagSize() const
-
72 {
-
73  // The GCM specification recommends an IV size of 96 bits.
-
74  return 12;
+
68  // The GCM specification recommends an IV size of 96 bits.
+
69  return 12;
+
70 }
+
71 
+
72 size_t GCMCommon::tagSize() const
+
73 {
+
74  return 16;
75 }
76 
77 bool GCMCommon::setKey(const uint8_t *key, size_t len)
@@ -329,7 +329,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
263 
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:225
GCMCommon::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: GCM.cpp:77
-
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:71
+
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:72
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:145
GCMCommon::clear
void clear()
Clears all security-sensitive state from this cipher.
Definition: GCM.cpp:256
GCMCommon::checkTag
bool checkTag(const void *tag, size_t len)
Finalizes the decryption process and checks the authentication tag.
Definition: GCM.cpp:245
@@ -352,7 +352,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GCM_8h_source.html b/GCM_8h_source.html index ad5e6733..3a5ab22c 100644 --- a/GCM_8h_source.html +++ b/GCM_8h_source.html @@ -171,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
GCMCommon::computeTag
void computeTag(void *tag, size_t len)
Finalizes the encryption process and computes the authentication tag.
Definition: GCM.cpp:225
GCM
Implementation of the Galois Counter Mode (GCM).
Definition: GCM.h:71
GCMCommon::setKey
bool setKey(const uint8_t *key, size_t len)
Sets the key to use for future encryption and decryption operations.
Definition: GCM.cpp:77
-
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:71
+
GCMCommon::tagSize
size_t tagSize() const
Returns the size of the authentication tag.
Definition: GCM.cpp:72
GCMCommon::encrypt
void encrypt(uint8_t *output, const uint8_t *input, size_t len)
Encrypts an input buffer and writes the ciphertext to an output buffer.
Definition: GCM.cpp:145
BlockCipher
Abstract base class for block ciphers.
Definition: BlockCipher.h:29
GCM::GCM
GCM()
Constructs a new GCM object for the block cipher T.
Definition: GCM.h:74
@@ -191,7 +191,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GHASH_8cpp_source.html b/GHASH_8cpp_source.html index c6d77c36..3abab013 100644 --- a/GHASH_8cpp_source.html +++ b/GHASH_8cpp_source.html @@ -239,7 +239,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/GHASH_8h_source.html b/GHASH_8h_source.html index e5a182ce..e23604b9 100644 --- a/GHASH_8h_source.html +++ b/GHASH_8h_source.html @@ -152,7 +152,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Hash_8cpp_source.html b/Hash_8cpp_source.html index 3422526d..5b59020a 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 7790e2f7..ad0ae542 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 83c951f9..a7d04f62 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 e261e725..b5634b29 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 e65c7c74..016ac9b6 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 dd1f1df2..6d3533e6 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 ae33af84..917fda78 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 84b35b78..19245ab5 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 957b59ef..30dc0d88 100644 --- a/KeccakCore_8cpp_source.html +++ b/KeccakCore_8cpp_source.html @@ -117,248 +117,1848 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
27 #include "utility/ProgMemUtil.h"
28 #include <string.h>
29 
-
49 KeccakCore::KeccakCore()
-
50  : _blockSize(8)
-
51 {
-
52  memset(state.A, 0, sizeof(state.A));
-
53  state.inputSize = 0;
-
54  state.outputSize = 0;
-
55 }
-
56 
-
61 KeccakCore::~KeccakCore()
-
62 {
-
63  clean(state);
-
64 }
-
65 
-
71 size_t KeccakCore::capacity() const
-
72 {
-
73  return 1600 - ((size_t)_blockSize) * 8;
-
74 }
-
75 
-
89 void KeccakCore::setCapacity(size_t capacity)
-
90 {
-
91  _blockSize = (1600 - capacity) / 8;
-
92  reset();
-
93 }
-
94 
-
109 void KeccakCore::reset()
-
110 {
-
111  memset(state.A, 0, sizeof(state.A));
-
112  state.inputSize = 0;
-
113  state.outputSize = 0;
-
114 }
-
115 
-
128 void KeccakCore::update(const void *data, size_t size)
-
129 {
-
130  // Stop generating output while we incorporate the new data.
-
131  state.outputSize = 0;
-
132 
-
133  // Break the input up into chunks and process each in turn.
-
134  const uint8_t *d = (const uint8_t *)data;
-
135 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
136  uint64_t *Awords = &(state.A[0][0]);
-
137  uint8_t index, index2;
-
138 #endif
-
139  while (size > 0) {
-
140  uint8_t len = _blockSize - state.inputSize;
-
141  if (len > size)
-
142  len = size;
-
143 #if defined(CRYPTO_LITTLE_ENDIAN)
-
144  uint8_t *Abytes = ((uint8_t *)state.A) + state.inputSize;
+
42 #if !defined(CRYPTO_LITTLE_ENDIAN)
+
43 // All of the Arduino platforms we care about are little-endian.
+
44 #error "KeccakCore is not supported on big-endian platforms yet - todo"
+
45 #endif
+
46 
+
54 KeccakCore::KeccakCore()
+
55  : _blockSize(8)
+
56 {
+
57  memset(state.A, 0, sizeof(state.A));
+
58  state.inputSize = 0;
+
59  state.outputSize = 0;
+
60 }
+
61 
+
66 KeccakCore::~KeccakCore()
+
67 {
+
68  clean(state);
+
69 }
+
70 
+
76 size_t KeccakCore::capacity() const
+
77 {
+
78  return 1600 - ((size_t)_blockSize) * 8;
+
79 }
+
80 
+
94 void KeccakCore::setCapacity(size_t capacity)
+
95 {
+
96  _blockSize = (1600 - capacity) / 8;
+
97  reset();
+
98 }
+
99 
+
114 void KeccakCore::reset()
+
115 {
+
116  memset(state.A, 0, sizeof(state.A));
+
117  state.inputSize = 0;
+
118  state.outputSize = 0;
+
119 }
+
120 
+
133 void KeccakCore::update(const void *data, size_t size)
+
134 {
+
135  // Stop generating output while we incorporate the new data.
+
136  state.outputSize = 0;
+
137 
+
138  // Break the input up into chunks and process each in turn.
+
139  const uint8_t *d = (const uint8_t *)data;
+
140  while (size > 0) {
+
141  uint8_t len = _blockSize - state.inputSize;
+
142  if (len > size)
+
143  len = size;
+
144  uint8_t *Abytes = ((uint8_t *)state.A) + state.inputSize;
145  for (uint8_t posn = 0; posn < len; ++posn)
146  Abytes[posn] ^= d[posn];
-
147 #else
-
148  index2 = state.inputSize;
-
149  for (index = 0; index < len; ++index) {
-
150  Awords[index2 / 8] ^= (((uint64_t)d[index]) << ((index2 % 8) * 8));
-
151  ++index2;
-
152  }
-
153 #endif
-
154  state.inputSize += len;
-
155  size -= len;
-
156  d += len;
-
157  if (state.inputSize == _blockSize) {
-
158  keccakp();
-
159  state.inputSize = 0;
-
160  }
-
161  }
-
162 }
-
163 
-
174 void KeccakCore::pad(uint8_t tag)
-
175 {
-
176  // Padding for SHA3-NNN variants according to FIPS 202 appends "01",
-
177  // then another "1", then many zero bits, followed by a final "1".
-
178  // SHAKE appends "1111" first instead of "01". Note that SHA-3 numbers
-
179  // bits from the least significant, so appending "01" is equivalent
-
180  // to 0x02 for byte-aligned data, not 0x40.
-
181  uint8_t size = state.inputSize;
-
182  uint64_t *Awords = &(state.A[0][0]);
-
183  Awords[size / 8] ^= (((uint64_t)tag) << ((size % 8) * 8));
-
184  Awords[(_blockSize - 1) / 8] ^= 0x8000000000000000ULL;
-
185  keccakp();
-
186  state.inputSize = 0;
-
187  state.outputSize = 0;
-
188 }
-
189 
-
201 void KeccakCore::extract(void *data, size_t size)
-
202 {
-
203 #if !defined(CRYPTO_LITTLE_ENDIAN)
-
204  uint8_t index, index2;
-
205  const uint64_t *Awords = &(state.A[0][0]);
-
206 #endif
-
207 
-
208  // Stop accepting input while we are generating output.
-
209  state.inputSize = 0;
-
210 
-
211  // Copy the output data into the caller's return buffer.
-
212  uint8_t *d = (uint8_t *)data;
-
213  uint8_t tempSize;
-
214  while (size > 0) {
-
215  // Generate another output block if the current one has been exhausted.
-
216  if (state.outputSize >= _blockSize) {
-
217  keccakp();
-
218  state.outputSize = 0;
-
219  }
-
220 
-
221  // How many bytes can we copy this time around?
-
222  tempSize = _blockSize - state.outputSize;
-
223  if (tempSize > size)
-
224  tempSize = size;
-
225 
-
226  // Copy the partial output data into the caller's return buffer.
-
227 #if defined(CRYPTO_LITTLE_ENDIAN)
-
228  memcpy(d, ((uint8_t *)(state.A)) + state.outputSize, tempSize);
-
229 #else
-
230  index2 = state.outputSize;
-
231  for (index = 0; index < tempSize; ++index) {
-
232  d[index] = (uint8_t)(Awords[index2 / 8] >> ((index2 % 8) * 8));
-
233  ++index2;
-
234  }
-
235 #endif
-
236  state.outputSize += tempSize;
-
237  size -= tempSize;
-
238  d += tempSize;
-
239  }
-
240 }
-
241 
-
245 void KeccakCore::clear()
-
246 {
-
247  clean(state);
-
248 }
-
249 
-
263 void KeccakCore::setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
-
264 {
-
265  uint8_t *b = (uint8_t *)state.B;
-
266  size_t size = blockSize();
-
267  reset();
-
268  if (len <= size) {
-
269  memcpy(b, key, len);
-
270  } else {
-
271  update(key, len);
-
272  this->pad(0x06);
-
273  extract(b, hashSize);
-
274  len = hashSize;
-
275  reset();
-
276  }
-
277  memset(b + len, pad, size - len);
-
278  while (len > 0) {
-
279  *b++ ^= pad;
-
280  --len;
-
281  }
-
282  update(state.B, size);
-
283 }
-
284 
-
288 void KeccakCore::keccakp()
-
289 {
-
290  static const uint8_t addMod5Table[9] PROGMEM = {
-
291  0, 1, 2, 3, 4, 0, 1, 2, 3
-
292  };
-
293  #define addMod5(x, y) (pgm_read_byte(&(addMod5Table[(x) + (y)])))
-
294  uint64_t D;
-
295  uint8_t index, index2;
-
296  for (uint8_t round = 0; round < 24; ++round) {
-
297  // Step mapping theta. The specification mentions two temporary
-
298  // arrays of size 5 called C and D. To save a bit of memory,
-
299  // we use the first row of B to store C and compute D on the fly.
-
300  for (index = 0; index < 5; ++index) {
-
301  state.B[0][index] = state.A[0][index] ^ state.A[1][index] ^
-
302  state.A[2][index] ^ state.A[3][index] ^
-
303  state.A[4][index];
-
304  }
-
305  for (index = 0; index < 5; ++index) {
-
306  D = state.B[0][addMod5(index, 4)] ^
-
307  leftRotate1_64(state.B[0][addMod5(index, 1)]);
-
308  for (index2 = 0; index2 < 5; ++index2)
-
309  state.A[index2][index] ^= D;
-
310  }
-
311 
-
312  // Step mapping rho and pi combined into a single step.
-
313  // Rotate all lanes by a specific offset and rearrange.
-
314  state.B[0][0] = state.A[0][0];
-
315  state.B[1][0] = leftRotate28_64(state.A[0][3]);
-
316  state.B[2][0] = leftRotate1_64 (state.A[0][1]);
-
317  state.B[3][0] = leftRotate27_64(state.A[0][4]);
-
318  state.B[4][0] = leftRotate62_64(state.A[0][2]);
-
319  state.B[0][1] = leftRotate44_64(state.A[1][1]);
-
320  state.B[1][1] = leftRotate20_64(state.A[1][4]);
-
321  state.B[2][1] = leftRotate6_64 (state.A[1][2]);
-
322  state.B[3][1] = leftRotate36_64(state.A[1][0]);
-
323  state.B[4][1] = leftRotate55_64(state.A[1][3]);
-
324  state.B[0][2] = leftRotate43_64(state.A[2][2]);
-
325  state.B[1][2] = leftRotate3_64 (state.A[2][0]);
-
326  state.B[2][2] = leftRotate25_64(state.A[2][3]);
-
327  state.B[3][2] = leftRotate10_64(state.A[2][1]);
-
328  state.B[4][2] = leftRotate39_64(state.A[2][4]);
-
329  state.B[0][3] = leftRotate21_64(state.A[3][3]);
-
330  state.B[1][3] = leftRotate45_64(state.A[3][1]);
-
331  state.B[2][3] = leftRotate8_64 (state.A[3][4]);
-
332  state.B[3][3] = leftRotate15_64(state.A[3][2]);
-
333  state.B[4][3] = leftRotate41_64(state.A[3][0]);
-
334  state.B[0][4] = leftRotate14_64(state.A[4][4]);
-
335  state.B[1][4] = leftRotate61_64(state.A[4][2]);
-
336  state.B[2][4] = leftRotate18_64(state.A[4][0]);
-
337  state.B[3][4] = leftRotate56_64(state.A[4][3]);
-
338  state.B[4][4] = leftRotate2_64 (state.A[4][1]);
-
339 
-
340  // Step mapping chi. Combine each lane with two other lanes in its row.
-
341  for (index = 0; index < 5; ++index) {
-
342  for (index2 = 0; index2 < 5; ++index2) {
-
343  state.A[index2][index] =
-
344  state.B[index2][index] ^
-
345  ((~state.B[index2][addMod5(index, 1)]) &
-
346  state.B[index2][addMod5(index, 2)]);
-
347  }
-
348  }
-
349 
-
350  // Step mapping iota. XOR A[0][0] with the round constant.
-
351  static uint64_t const RC[24] PROGMEM = {
-
352  0x0000000000000001ULL, 0x0000000000008082ULL, 0x800000000000808AULL,
-
353  0x8000000080008000ULL, 0x000000000000808BULL, 0x0000000080000001ULL,
-
354  0x8000000080008081ULL, 0x8000000000008009ULL, 0x000000000000008AULL,
-
355  0x0000000000000088ULL, 0x0000000080008009ULL, 0x000000008000000AULL,
-
356  0x000000008000808BULL, 0x800000000000008BULL, 0x8000000000008089ULL,
-
357  0x8000000000008003ULL, 0x8000000000008002ULL, 0x8000000000000080ULL,
-
358  0x000000000000800AULL, 0x800000008000000AULL, 0x8000000080008081ULL,
-
359  0x8000000000008080ULL, 0x0000000080000001ULL, 0x8000000080008008ULL
-
360  };
-
361  state.A[0][0] ^= pgm_read_qword(RC + round);
-
362  }
-
363 }
+
147  state.inputSize += len;
+
148  size -= len;
+
149  d += len;
+
150  if (state.inputSize == _blockSize) {
+
151  keccakp();
+
152  state.inputSize = 0;
+
153  }
+
154  }
+
155 }
+
156 
+
167 void KeccakCore::pad(uint8_t tag)
+
168 {
+
169  // Padding for SHA3-NNN variants according to FIPS 202 appends "01",
+
170  // then another "1", then many zero bits, followed by a final "1".
+
171  // SHAKE appends "1111" first instead of "01". Note that SHA-3 numbers
+
172  // bits from the least significant, so appending "01" is equivalent
+
173  // to 0x02 for byte-aligned data, not 0x40.
+
174  uint8_t size = state.inputSize;
+
175  uint64_t *Awords = &(state.A[0][0]);
+
176  Awords[size / 8] ^= (((uint64_t)tag) << ((size % 8) * 8));
+
177  Awords[(_blockSize - 1) / 8] ^= 0x8000000000000000ULL;
+
178  keccakp();
+
179  state.inputSize = 0;
+
180  state.outputSize = 0;
+
181 }
+
182 
+
194 void KeccakCore::extract(void *data, size_t size)
+
195 {
+
196  // Stop accepting input while we are generating output.
+
197  state.inputSize = 0;
+
198 
+
199  // Copy the output data into the caller's return buffer.
+
200  uint8_t *d = (uint8_t *)data;
+
201  uint8_t tempSize;
+
202  while (size > 0) {
+
203  // Generate another output block if the current one has been exhausted.
+
204  if (state.outputSize >= _blockSize) {
+
205  keccakp();
+
206  state.outputSize = 0;
+
207  }
+
208 
+
209  // How many bytes can we copy this time around?
+
210  tempSize = _blockSize - state.outputSize;
+
211  if (tempSize > size)
+
212  tempSize = size;
+
213 
+
214  // Copy the partial output data into the caller's return buffer.
+
215  memcpy(d, ((uint8_t *)(state.A)) + state.outputSize, tempSize);
+
216  state.outputSize += tempSize;
+
217  size -= tempSize;
+
218  d += tempSize;
+
219  }
+
220 }
+
221 
+
225 void KeccakCore::clear()
+
226 {
+
227  clean(state);
+
228 }
+
229 
+
243 void KeccakCore::setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
+
244 {
+
245  uint8_t *Abytes = (uint8_t *)state.A;
+
246  size_t size = blockSize();
+
247  reset();
+
248  if (len <= size) {
+
249  // Because the state has just been reset, state.A is set to
+
250  // all-zeroes. We can copy the key directly into the state
+
251  // and then XOR the block with the pad value.
+
252  memcpy(Abytes, key, len);
+
253  } else {
+
254  // The key is larger than the block size. Hash it down.
+
255  // Afterwards, state.A will contain the first block of data
+
256  // to be extracted. We truncate it to the first "hashSize"
+
257  // bytes and XOR with the padding.
+
258  update(key, len);
+
259  this->pad(0x06);
+
260  memset(Abytes + hashSize, pad, size - hashSize);
+
261  memset(Abytes + size, 0, sizeof(state.A) - size);
+
262  size = hashSize;
+
263  }
+
264  while (size > 0) {
+
265  *Abytes++ ^= pad;
+
266  --size;
+
267  }
+
268  keccakp();
+
269 }
+
270 
+
274 void KeccakCore::keccakp()
+
275 {
+
276  uint64_t B[5][5];
+
277 #if defined(__AVR__)
+
278  // This assembly code was generated by the "genkeccak.c" program.
+
279  // Do not modify this code directly. Instead modify "genkeccak.c"
+
280  // and then re-generate the code here.
+
281  for (uint8_t round = 0; round < 24; ++round) {
+
282  __asm__ __volatile__ (
+
283  "push r29\n"
+
284  "push r28\n"
+
285  "mov r28,r26\n"
+
286  "mov r29,r27\n"
+
287 
+
288  // Step mapping theta. Compute C.
+
289  "ldi r20,5\n"
+
290  "100:\n"
+
291  "ld r8,Z\n"
+
292  "ldd r9,Z+1\n"
+
293  "ldd r10,Z+2\n"
+
294  "ldd r11,Z+3\n"
+
295  "ldd r12,Z+4\n"
+
296  "ldd r13,Z+5\n"
+
297  "ldd r14,Z+6\n"
+
298  "ldd r15,Z+7\n"
+
299  "ldi r19,4\n"
+
300  "101:\n"
+
301  "adiw r30,40\n"
+
302  "ld __tmp_reg__,Z\n"
+
303  "eor r8,__tmp_reg__\n"
+
304  "ldd __tmp_reg__,Z+1\n"
+
305  "eor r9,__tmp_reg__\n"
+
306  "ldd __tmp_reg__,Z+2\n"
+
307  "eor r10,__tmp_reg__\n"
+
308  "ldd __tmp_reg__,Z+3\n"
+
309  "eor r11,__tmp_reg__\n"
+
310  "ldd __tmp_reg__,Z+4\n"
+
311  "eor r12,__tmp_reg__\n"
+
312  "ldd __tmp_reg__,Z+5\n"
+
313  "eor r13,__tmp_reg__\n"
+
314  "ldd __tmp_reg__,Z+6\n"
+
315  "eor r14,__tmp_reg__\n"
+
316  "ldd __tmp_reg__,Z+7\n"
+
317  "eor r15,__tmp_reg__\n"
+
318  "dec r19\n"
+
319  "brne 101b\n"
+
320  "st X+,r8\n"
+
321  "st X+,r9\n"
+
322  "st X+,r10\n"
+
323  "st X+,r11\n"
+
324  "st X+,r12\n"
+
325  "st X+,r13\n"
+
326  "st X+,r14\n"
+
327  "st X+,r15\n"
+
328  "subi r30,152\n"
+
329  "sbc r31,__zero_reg__\n"
+
330  "dec r20\n"
+
331  "brne 100b\n"
+
332  "sbiw r30,40\n"
+
333  "sbiw r26,40\n"
+
334 
+
335  // Step mapping theta. Compute D and XOR with A.
+
336  "ldd r8,Y+8\n"
+
337  "ldd r9,Y+9\n"
+
338  "ldd r10,Y+10\n"
+
339  "ldd r11,Y+11\n"
+
340  "ldd r12,Y+12\n"
+
341  "ldd r13,Y+13\n"
+
342  "ldd r14,Y+14\n"
+
343  "ldd r15,Y+15\n"
+
344  "lsl r8\n"
+
345  "rol r9\n"
+
346  "rol r10\n"
+
347  "rol r11\n"
+
348  "rol r12\n"
+
349  "rol r13\n"
+
350  "rol r14\n"
+
351  "rol r15\n"
+
352  "adc r8, __zero_reg__\n"
+
353  "ldd __tmp_reg__,Y+32\n"
+
354  "eor r8,__tmp_reg__\n"
+
355  "ldd __tmp_reg__,Y+33\n"
+
356  "eor r9,__tmp_reg__\n"
+
357  "ldd __tmp_reg__,Y+34\n"
+
358  "eor r10,__tmp_reg__\n"
+
359  "ldd __tmp_reg__,Y+35\n"
+
360  "eor r11,__tmp_reg__\n"
+
361  "ldd __tmp_reg__,Y+36\n"
+
362  "eor r12,__tmp_reg__\n"
+
363  "ldd __tmp_reg__,Y+37\n"
+
364  "eor r13,__tmp_reg__\n"
+
365  "ldd __tmp_reg__,Y+38\n"
+
366  "eor r14,__tmp_reg__\n"
+
367  "ldd __tmp_reg__,Y+39\n"
+
368  "eor r15,__tmp_reg__\n"
+
369  "ldi r19,5\n"
+
370  "103:\n"
+
371  "ld __tmp_reg__,Z\n"
+
372  "eor __tmp_reg__,r8\n"
+
373  "st Z,__tmp_reg__\n"
+
374  "ldd __tmp_reg__,Z+1\n"
+
375  "eor __tmp_reg__,r9\n"
+
376  "std Z+1,__tmp_reg__\n"
+
377  "ldd __tmp_reg__,Z+2\n"
+
378  "eor __tmp_reg__,r10\n"
+
379  "std Z+2,__tmp_reg__\n"
+
380  "ldd __tmp_reg__,Z+3\n"
+
381  "eor __tmp_reg__,r11\n"
+
382  "std Z+3,__tmp_reg__\n"
+
383  "ldd __tmp_reg__,Z+4\n"
+
384  "eor __tmp_reg__,r12\n"
+
385  "std Z+4,__tmp_reg__\n"
+
386  "ldd __tmp_reg__,Z+5\n"
+
387  "eor __tmp_reg__,r13\n"
+
388  "std Z+5,__tmp_reg__\n"
+
389  "ldd __tmp_reg__,Z+6\n"
+
390  "eor __tmp_reg__,r14\n"
+
391  "std Z+6,__tmp_reg__\n"
+
392  "ldd __tmp_reg__,Z+7\n"
+
393  "eor __tmp_reg__,r15\n"
+
394  "std Z+7,__tmp_reg__\n"
+
395  "adiw r30,40\n"
+
396  "dec r19\n"
+
397  "brne 103b\n"
+
398  "subi r30,192\n"
+
399  "sbc r31,__zero_reg__\n"
+
400  "ldd r8,Y+16\n"
+
401  "ldd r9,Y+17\n"
+
402  "ldd r10,Y+18\n"
+
403  "ldd r11,Y+19\n"
+
404  "ldd r12,Y+20\n"
+
405  "ldd r13,Y+21\n"
+
406  "ldd r14,Y+22\n"
+
407  "ldd r15,Y+23\n"
+
408  "lsl r8\n"
+
409  "rol r9\n"
+
410  "rol r10\n"
+
411  "rol r11\n"
+
412  "rol r12\n"
+
413  "rol r13\n"
+
414  "rol r14\n"
+
415  "rol r15\n"
+
416  "adc r8, __zero_reg__\n"
+
417  "ld __tmp_reg__,Y\n"
+
418  "eor r8,__tmp_reg__\n"
+
419  "ldd __tmp_reg__,Y+1\n"
+
420  "eor r9,__tmp_reg__\n"
+
421  "ldd __tmp_reg__,Y+2\n"
+
422  "eor r10,__tmp_reg__\n"
+
423  "ldd __tmp_reg__,Y+3\n"
+
424  "eor r11,__tmp_reg__\n"
+
425  "ldd __tmp_reg__,Y+4\n"
+
426  "eor r12,__tmp_reg__\n"
+
427  "ldd __tmp_reg__,Y+5\n"
+
428  "eor r13,__tmp_reg__\n"
+
429  "ldd __tmp_reg__,Y+6\n"
+
430  "eor r14,__tmp_reg__\n"
+
431  "ldd __tmp_reg__,Y+7\n"
+
432  "eor r15,__tmp_reg__\n"
+
433  "ldi r19,5\n"
+
434  "104:\n"
+
435  "ld __tmp_reg__,Z\n"
+
436  "eor __tmp_reg__,r8\n"
+
437  "st Z,__tmp_reg__\n"
+
438  "ldd __tmp_reg__,Z+1\n"
+
439  "eor __tmp_reg__,r9\n"
+
440  "std Z+1,__tmp_reg__\n"
+
441  "ldd __tmp_reg__,Z+2\n"
+
442  "eor __tmp_reg__,r10\n"
+
443  "std Z+2,__tmp_reg__\n"
+
444  "ldd __tmp_reg__,Z+3\n"
+
445  "eor __tmp_reg__,r11\n"
+
446  "std Z+3,__tmp_reg__\n"
+
447  "ldd __tmp_reg__,Z+4\n"
+
448  "eor __tmp_reg__,r12\n"
+
449  "std Z+4,__tmp_reg__\n"
+
450  "ldd __tmp_reg__,Z+5\n"
+
451  "eor __tmp_reg__,r13\n"
+
452  "std Z+5,__tmp_reg__\n"
+
453  "ldd __tmp_reg__,Z+6\n"
+
454  "eor __tmp_reg__,r14\n"
+
455  "std Z+6,__tmp_reg__\n"
+
456  "ldd __tmp_reg__,Z+7\n"
+
457  "eor __tmp_reg__,r15\n"
+
458  "std Z+7,__tmp_reg__\n"
+
459  "adiw r30,40\n"
+
460  "dec r19\n"
+
461  "brne 104b\n"
+
462  "subi r30,192\n"
+
463  "sbc r31,__zero_reg__\n"
+
464  "ldd r8,Y+24\n"
+
465  "ldd r9,Y+25\n"
+
466  "ldd r10,Y+26\n"
+
467  "ldd r11,Y+27\n"
+
468  "ldd r12,Y+28\n"
+
469  "ldd r13,Y+29\n"
+
470  "ldd r14,Y+30\n"
+
471  "ldd r15,Y+31\n"
+
472  "lsl r8\n"
+
473  "rol r9\n"
+
474  "rol r10\n"
+
475  "rol r11\n"
+
476  "rol r12\n"
+
477  "rol r13\n"
+
478  "rol r14\n"
+
479  "rol r15\n"
+
480  "adc r8, __zero_reg__\n"
+
481  "ldd __tmp_reg__,Y+8\n"
+
482  "eor r8,__tmp_reg__\n"
+
483  "ldd __tmp_reg__,Y+9\n"
+
484  "eor r9,__tmp_reg__\n"
+
485  "ldd __tmp_reg__,Y+10\n"
+
486  "eor r10,__tmp_reg__\n"
+
487  "ldd __tmp_reg__,Y+11\n"
+
488  "eor r11,__tmp_reg__\n"
+
489  "ldd __tmp_reg__,Y+12\n"
+
490  "eor r12,__tmp_reg__\n"
+
491  "ldd __tmp_reg__,Y+13\n"
+
492  "eor r13,__tmp_reg__\n"
+
493  "ldd __tmp_reg__,Y+14\n"
+
494  "eor r14,__tmp_reg__\n"
+
495  "ldd __tmp_reg__,Y+15\n"
+
496  "eor r15,__tmp_reg__\n"
+
497  "ldi r19,5\n"
+
498  "105:\n"
+
499  "ld __tmp_reg__,Z\n"
+
500  "eor __tmp_reg__,r8\n"
+
501  "st Z,__tmp_reg__\n"
+
502  "ldd __tmp_reg__,Z+1\n"
+
503  "eor __tmp_reg__,r9\n"
+
504  "std Z+1,__tmp_reg__\n"
+
505  "ldd __tmp_reg__,Z+2\n"
+
506  "eor __tmp_reg__,r10\n"
+
507  "std Z+2,__tmp_reg__\n"
+
508  "ldd __tmp_reg__,Z+3\n"
+
509  "eor __tmp_reg__,r11\n"
+
510  "std Z+3,__tmp_reg__\n"
+
511  "ldd __tmp_reg__,Z+4\n"
+
512  "eor __tmp_reg__,r12\n"
+
513  "std Z+4,__tmp_reg__\n"
+
514  "ldd __tmp_reg__,Z+5\n"
+
515  "eor __tmp_reg__,r13\n"
+
516  "std Z+5,__tmp_reg__\n"
+
517  "ldd __tmp_reg__,Z+6\n"
+
518  "eor __tmp_reg__,r14\n"
+
519  "std Z+6,__tmp_reg__\n"
+
520  "ldd __tmp_reg__,Z+7\n"
+
521  "eor __tmp_reg__,r15\n"
+
522  "std Z+7,__tmp_reg__\n"
+
523  "adiw r30,40\n"
+
524  "dec r19\n"
+
525  "brne 105b\n"
+
526  "subi r30,192\n"
+
527  "sbc r31,__zero_reg__\n"
+
528  "ldd r8,Y+32\n"
+
529  "ldd r9,Y+33\n"
+
530  "ldd r10,Y+34\n"
+
531  "ldd r11,Y+35\n"
+
532  "ldd r12,Y+36\n"
+
533  "ldd r13,Y+37\n"
+
534  "ldd r14,Y+38\n"
+
535  "ldd r15,Y+39\n"
+
536  "lsl r8\n"
+
537  "rol r9\n"
+
538  "rol r10\n"
+
539  "rol r11\n"
+
540  "rol r12\n"
+
541  "rol r13\n"
+
542  "rol r14\n"
+
543  "rol r15\n"
+
544  "adc r8, __zero_reg__\n"
+
545  "ldd __tmp_reg__,Y+16\n"
+
546  "eor r8,__tmp_reg__\n"
+
547  "ldd __tmp_reg__,Y+17\n"
+
548  "eor r9,__tmp_reg__\n"
+
549  "ldd __tmp_reg__,Y+18\n"
+
550  "eor r10,__tmp_reg__\n"
+
551  "ldd __tmp_reg__,Y+19\n"
+
552  "eor r11,__tmp_reg__\n"
+
553  "ldd __tmp_reg__,Y+20\n"
+
554  "eor r12,__tmp_reg__\n"
+
555  "ldd __tmp_reg__,Y+21\n"
+
556  "eor r13,__tmp_reg__\n"
+
557  "ldd __tmp_reg__,Y+22\n"
+
558  "eor r14,__tmp_reg__\n"
+
559  "ldd __tmp_reg__,Y+23\n"
+
560  "eor r15,__tmp_reg__\n"
+
561  "ldi r19,5\n"
+
562  "106:\n"
+
563  "ld __tmp_reg__,Z\n"
+
564  "eor __tmp_reg__,r8\n"
+
565  "st Z,__tmp_reg__\n"
+
566  "ldd __tmp_reg__,Z+1\n"
+
567  "eor __tmp_reg__,r9\n"
+
568  "std Z+1,__tmp_reg__\n"
+
569  "ldd __tmp_reg__,Z+2\n"
+
570  "eor __tmp_reg__,r10\n"
+
571  "std Z+2,__tmp_reg__\n"
+
572  "ldd __tmp_reg__,Z+3\n"
+
573  "eor __tmp_reg__,r11\n"
+
574  "std Z+3,__tmp_reg__\n"
+
575  "ldd __tmp_reg__,Z+4\n"
+
576  "eor __tmp_reg__,r12\n"
+
577  "std Z+4,__tmp_reg__\n"
+
578  "ldd __tmp_reg__,Z+5\n"
+
579  "eor __tmp_reg__,r13\n"
+
580  "std Z+5,__tmp_reg__\n"
+
581  "ldd __tmp_reg__,Z+6\n"
+
582  "eor __tmp_reg__,r14\n"
+
583  "std Z+6,__tmp_reg__\n"
+
584  "ldd __tmp_reg__,Z+7\n"
+
585  "eor __tmp_reg__,r15\n"
+
586  "std Z+7,__tmp_reg__\n"
+
587  "adiw r30,40\n"
+
588  "dec r19\n"
+
589  "brne 106b\n"
+
590  "subi r30,192\n"
+
591  "sbc r31,__zero_reg__\n"
+
592  "ld r8,Y\n"
+
593  "ldd r9,Y+1\n"
+
594  "ldd r10,Y+2\n"
+
595  "ldd r11,Y+3\n"
+
596  "ldd r12,Y+4\n"
+
597  "ldd r13,Y+5\n"
+
598  "ldd r14,Y+6\n"
+
599  "ldd r15,Y+7\n"
+
600  "lsl r8\n"
+
601  "rol r9\n"
+
602  "rol r10\n"
+
603  "rol r11\n"
+
604  "rol r12\n"
+
605  "rol r13\n"
+
606  "rol r14\n"
+
607  "rol r15\n"
+
608  "adc r8, __zero_reg__\n"
+
609  "ldd __tmp_reg__,Y+24\n"
+
610  "eor r8,__tmp_reg__\n"
+
611  "ldd __tmp_reg__,Y+25\n"
+
612  "eor r9,__tmp_reg__\n"
+
613  "ldd __tmp_reg__,Y+26\n"
+
614  "eor r10,__tmp_reg__\n"
+
615  "ldd __tmp_reg__,Y+27\n"
+
616  "eor r11,__tmp_reg__\n"
+
617  "ldd __tmp_reg__,Y+28\n"
+
618  "eor r12,__tmp_reg__\n"
+
619  "ldd __tmp_reg__,Y+29\n"
+
620  "eor r13,__tmp_reg__\n"
+
621  "ldd __tmp_reg__,Y+30\n"
+
622  "eor r14,__tmp_reg__\n"
+
623  "ldd __tmp_reg__,Y+31\n"
+
624  "eor r15,__tmp_reg__\n"
+
625  "ldi r19,5\n"
+
626  "107:\n"
+
627  "ld __tmp_reg__,Z\n"
+
628  "eor __tmp_reg__,r8\n"
+
629  "st Z,__tmp_reg__\n"
+
630  "ldd __tmp_reg__,Z+1\n"
+
631  "eor __tmp_reg__,r9\n"
+
632  "std Z+1,__tmp_reg__\n"
+
633  "ldd __tmp_reg__,Z+2\n"
+
634  "eor __tmp_reg__,r10\n"
+
635  "std Z+2,__tmp_reg__\n"
+
636  "ldd __tmp_reg__,Z+3\n"
+
637  "eor __tmp_reg__,r11\n"
+
638  "std Z+3,__tmp_reg__\n"
+
639  "ldd __tmp_reg__,Z+4\n"
+
640  "eor __tmp_reg__,r12\n"
+
641  "std Z+4,__tmp_reg__\n"
+
642  "ldd __tmp_reg__,Z+5\n"
+
643  "eor __tmp_reg__,r13\n"
+
644  "std Z+5,__tmp_reg__\n"
+
645  "ldd __tmp_reg__,Z+6\n"
+
646  "eor __tmp_reg__,r14\n"
+
647  "std Z+6,__tmp_reg__\n"
+
648  "ldd __tmp_reg__,Z+7\n"
+
649  "eor __tmp_reg__,r15\n"
+
650  "std Z+7,__tmp_reg__\n"
+
651  "adiw r30,40\n"
+
652  "dec r19\n"
+
653  "brne 107b\n"
+
654  "subi r30,232\n"
+
655  "sbc r31,__zero_reg__\n"
+
656 
+
657  // Step mappings rho and pi combined into one step.
+
658 
+
659  // B[0][0] = A[0][0]
+
660  "ld r8,Z\n"
+
661  "ldd r9,Z+1\n"
+
662  "ldd r10,Z+2\n"
+
663  "ldd r11,Z+3\n"
+
664  "ldd r12,Z+4\n"
+
665  "ldd r13,Z+5\n"
+
666  "ldd r14,Z+6\n"
+
667  "ldd r15,Z+7\n"
+
668  "st X+,r8\n"
+
669  "st X+,r9\n"
+
670  "st X+,r10\n"
+
671  "st X+,r11\n"
+
672  "st X+,r12\n"
+
673  "st X+,r13\n"
+
674  "st X+,r14\n"
+
675  "st X+,r15\n"
+
676 
+
677  // B[1][0] = leftRotate28_64(A[0][3])
+
678  "adiw r26,32\n"
+
679  "ldd r8,Z+24\n"
+
680  "ldd r9,Z+25\n"
+
681  "ldd r10,Z+26\n"
+
682  "ldd r11,Z+27\n"
+
683  "ldd r12,Z+28\n"
+
684  "ldd r13,Z+29\n"
+
685  "ldd r14,Z+30\n"
+
686  "ldd r15,Z+31\n"
+
687  "lsl r8\n"
+
688  "rol r9\n"
+
689  "rol r10\n"
+
690  "rol r11\n"
+
691  "rol r12\n"
+
692  "rol r13\n"
+
693  "rol r14\n"
+
694  "rol r15\n"
+
695  "adc r8, __zero_reg__\n"
+
696  "lsl r8\n"
+
697  "rol r9\n"
+
698  "rol r10\n"
+
699  "rol r11\n"
+
700  "rol r12\n"
+
701  "rol r13\n"
+
702  "rol r14\n"
+
703  "rol r15\n"
+
704  "adc r8, __zero_reg__\n"
+
705  "lsl r8\n"
+
706  "rol r9\n"
+
707  "rol r10\n"
+
708  "rol r11\n"
+
709  "rol r12\n"
+
710  "rol r13\n"
+
711  "rol r14\n"
+
712  "rol r15\n"
+
713  "adc r8, __zero_reg__\n"
+
714  "lsl r8\n"
+
715  "rol r9\n"
+
716  "rol r10\n"
+
717  "rol r11\n"
+
718  "rol r12\n"
+
719  "rol r13\n"
+
720  "rol r14\n"
+
721  "rol r15\n"
+
722  "adc r8, __zero_reg__\n"
+
723  "st X+,r13\n"
+
724  "st X+,r14\n"
+
725  "st X+,r15\n"
+
726  "st X+,r8\n"
+
727  "st X+,r9\n"
+
728  "st X+,r10\n"
+
729  "st X+,r11\n"
+
730  "st X+,r12\n"
+
731 
+
732  // B[2][0] = leftRotate1_64(A[0][1])
+
733  "adiw r26,32\n"
+
734  "ldd r8,Z+8\n"
+
735  "ldd r9,Z+9\n"
+
736  "ldd r10,Z+10\n"
+
737  "ldd r11,Z+11\n"
+
738  "ldd r12,Z+12\n"
+
739  "ldd r13,Z+13\n"
+
740  "ldd r14,Z+14\n"
+
741  "ldd r15,Z+15\n"
+
742  "lsl r8\n"
+
743  "rol r9\n"
+
744  "rol r10\n"
+
745  "rol r11\n"
+
746  "rol r12\n"
+
747  "rol r13\n"
+
748  "rol r14\n"
+
749  "rol r15\n"
+
750  "adc r8, __zero_reg__\n"
+
751  "st X+,r8\n"
+
752  "st X+,r9\n"
+
753  "st X+,r10\n"
+
754  "st X+,r11\n"
+
755  "st X+,r12\n"
+
756  "st X+,r13\n"
+
757  "st X+,r14\n"
+
758  "st X+,r15\n"
+
759 
+
760  // B[3][0] = leftRotate27_64(A[0][4])
+
761  "adiw r26,32\n"
+
762  "ldd r8,Z+32\n"
+
763  "ldd r9,Z+33\n"
+
764  "ldd r10,Z+34\n"
+
765  "ldd r11,Z+35\n"
+
766  "ldd r12,Z+36\n"
+
767  "ldd r13,Z+37\n"
+
768  "ldd r14,Z+38\n"
+
769  "ldd r15,Z+39\n"
+
770  "lsl r8\n"
+
771  "rol r9\n"
+
772  "rol r10\n"
+
773  "rol r11\n"
+
774  "rol r12\n"
+
775  "rol r13\n"
+
776  "rol r14\n"
+
777  "rol r15\n"
+
778  "adc r8, __zero_reg__\n"
+
779  "lsl r8\n"
+
780  "rol r9\n"
+
781  "rol r10\n"
+
782  "rol r11\n"
+
783  "rol r12\n"
+
784  "rol r13\n"
+
785  "rol r14\n"
+
786  "rol r15\n"
+
787  "adc r8, __zero_reg__\n"
+
788  "lsl r8\n"
+
789  "rol r9\n"
+
790  "rol r10\n"
+
791  "rol r11\n"
+
792  "rol r12\n"
+
793  "rol r13\n"
+
794  "rol r14\n"
+
795  "rol r15\n"
+
796  "adc r8, __zero_reg__\n"
+
797  "st X+,r13\n"
+
798  "st X+,r14\n"
+
799  "st X+,r15\n"
+
800  "st X+,r8\n"
+
801  "st X+,r9\n"
+
802  "st X+,r10\n"
+
803  "st X+,r11\n"
+
804  "st X+,r12\n"
+
805 
+
806  // B[4][0] = leftRotate62_64(A[0][2])
+
807  "adiw r26,32\n"
+
808  "ldd r8,Z+16\n"
+
809  "ldd r9,Z+17\n"
+
810  "ldd r10,Z+18\n"
+
811  "ldd r11,Z+19\n"
+
812  "ldd r12,Z+20\n"
+
813  "ldd r13,Z+21\n"
+
814  "ldd r14,Z+22\n"
+
815  "ldd r15,Z+23\n"
+
816  "bst r8,0\n"
+
817  "ror r15\n"
+
818  "ror r14\n"
+
819  "ror r13\n"
+
820  "ror r12\n"
+
821  "ror r11\n"
+
822  "ror r10\n"
+
823  "ror r9\n"
+
824  "ror r8\n"
+
825  "bld r15,7\n"
+
826  "bst r8,0\n"
+
827  "ror r15\n"
+
828  "ror r14\n"
+
829  "ror r13\n"
+
830  "ror r12\n"
+
831  "ror r11\n"
+
832  "ror r10\n"
+
833  "ror r9\n"
+
834  "ror r8\n"
+
835  "bld r15,7\n"
+
836  "st X+,r8\n"
+
837  "st X+,r9\n"
+
838  "st X+,r10\n"
+
839  "st X+,r11\n"
+
840  "st X+,r12\n"
+
841  "st X+,r13\n"
+
842  "st X+,r14\n"
+
843  "st X+,r15\n"
+
844 
+
845  // B[0][1] = leftRotate44_64(A[1][1])
+
846  "subi r26,160\n"
+
847  "sbc r27,__zero_reg__\n"
+
848  "adiw r30,40\n"
+
849  "ldd r8,Z+8\n"
+
850  "ldd r9,Z+9\n"
+
851  "ldd r10,Z+10\n"
+
852  "ldd r11,Z+11\n"
+
853  "ldd r12,Z+12\n"
+
854  "ldd r13,Z+13\n"
+
855  "ldd r14,Z+14\n"
+
856  "ldd r15,Z+15\n"
+
857  "lsl r8\n"
+
858  "rol r9\n"
+
859  "rol r10\n"
+
860  "rol r11\n"
+
861  "rol r12\n"
+
862  "rol r13\n"
+
863  "rol r14\n"
+
864  "rol r15\n"
+
865  "adc r8, __zero_reg__\n"
+
866  "lsl r8\n"
+
867  "rol r9\n"
+
868  "rol r10\n"
+
869  "rol r11\n"
+
870  "rol r12\n"
+
871  "rol r13\n"
+
872  "rol r14\n"
+
873  "rol r15\n"
+
874  "adc r8, __zero_reg__\n"
+
875  "lsl r8\n"
+
876  "rol r9\n"
+
877  "rol r10\n"
+
878  "rol r11\n"
+
879  "rol r12\n"
+
880  "rol r13\n"
+
881  "rol r14\n"
+
882  "rol r15\n"
+
883  "adc r8, __zero_reg__\n"
+
884  "lsl r8\n"
+
885  "rol r9\n"
+
886  "rol r10\n"
+
887  "rol r11\n"
+
888  "rol r12\n"
+
889  "rol r13\n"
+
890  "rol r14\n"
+
891  "rol r15\n"
+
892  "adc r8, __zero_reg__\n"
+
893  "st X+,r11\n"
+
894  "st X+,r12\n"
+
895  "st X+,r13\n"
+
896  "st X+,r14\n"
+
897  "st X+,r15\n"
+
898  "st X+,r8\n"
+
899  "st X+,r9\n"
+
900  "st X+,r10\n"
+
901 
+
902  // B[1][1] = leftRotate20_64(A[1][4])
+
903  "adiw r26,32\n"
+
904  "ldd r8,Z+32\n"
+
905  "ldd r9,Z+33\n"
+
906  "ldd r10,Z+34\n"
+
907  "ldd r11,Z+35\n"
+
908  "ldd r12,Z+36\n"
+
909  "ldd r13,Z+37\n"
+
910  "ldd r14,Z+38\n"
+
911  "ldd r15,Z+39\n"
+
912  "lsl r8\n"
+
913  "rol r9\n"
+
914  "rol r10\n"
+
915  "rol r11\n"
+
916  "rol r12\n"
+
917  "rol r13\n"
+
918  "rol r14\n"
+
919  "rol r15\n"
+
920  "adc r8, __zero_reg__\n"
+
921  "lsl r8\n"
+
922  "rol r9\n"
+
923  "rol r10\n"
+
924  "rol r11\n"
+
925  "rol r12\n"
+
926  "rol r13\n"
+
927  "rol r14\n"
+
928  "rol r15\n"
+
929  "adc r8, __zero_reg__\n"
+
930  "lsl r8\n"
+
931  "rol r9\n"
+
932  "rol r10\n"
+
933  "rol r11\n"
+
934  "rol r12\n"
+
935  "rol r13\n"
+
936  "rol r14\n"
+
937  "rol r15\n"
+
938  "adc r8, __zero_reg__\n"
+
939  "lsl r8\n"
+
940  "rol r9\n"
+
941  "rol r10\n"
+
942  "rol r11\n"
+
943  "rol r12\n"
+
944  "rol r13\n"
+
945  "rol r14\n"
+
946  "rol r15\n"
+
947  "adc r8, __zero_reg__\n"
+
948  "st X+,r14\n"
+
949  "st X+,r15\n"
+
950  "st X+,r8\n"
+
951  "st X+,r9\n"
+
952  "st X+,r10\n"
+
953  "st X+,r11\n"
+
954  "st X+,r12\n"
+
955  "st X+,r13\n"
+
956 
+
957  // B[2][1] = leftRotate6_64(A[1][2])
+
958  "adiw r26,32\n"
+
959  "ldd r8,Z+16\n"
+
960  "ldd r9,Z+17\n"
+
961  "ldd r10,Z+18\n"
+
962  "ldd r11,Z+19\n"
+
963  "ldd r12,Z+20\n"
+
964  "ldd r13,Z+21\n"
+
965  "ldd r14,Z+22\n"
+
966  "ldd r15,Z+23\n"
+
967  "bst r8,0\n"
+
968  "ror r15\n"
+
969  "ror r14\n"
+
970  "ror r13\n"
+
971  "ror r12\n"
+
972  "ror r11\n"
+
973  "ror r10\n"
+
974  "ror r9\n"
+
975  "ror r8\n"
+
976  "bld r15,7\n"
+
977  "bst r8,0\n"
+
978  "ror r15\n"
+
979  "ror r14\n"
+
980  "ror r13\n"
+
981  "ror r12\n"
+
982  "ror r11\n"
+
983  "ror r10\n"
+
984  "ror r9\n"
+
985  "ror r8\n"
+
986  "bld r15,7\n"
+
987  "st X+,r15\n"
+
988  "st X+,r8\n"
+
989  "st X+,r9\n"
+
990  "st X+,r10\n"
+
991  "st X+,r11\n"
+
992  "st X+,r12\n"
+
993  "st X+,r13\n"
+
994  "st X+,r14\n"
+
995 
+
996  // B[3][1] = leftRotate36_64(A[1][0])
+
997  "adiw r26,32\n"
+
998  "ld r8,Z\n"
+
999  "ldd r9,Z+1\n"
+
1000  "ldd r10,Z+2\n"
+
1001  "ldd r11,Z+3\n"
+
1002  "ldd r12,Z+4\n"
+
1003  "ldd r13,Z+5\n"
+
1004  "ldd r14,Z+6\n"
+
1005  "ldd r15,Z+7\n"
+
1006  "lsl r8\n"
+
1007  "rol r9\n"
+
1008  "rol r10\n"
+
1009  "rol r11\n"
+
1010  "rol r12\n"
+
1011  "rol r13\n"
+
1012  "rol r14\n"
+
1013  "rol r15\n"
+
1014  "adc r8, __zero_reg__\n"
+
1015  "lsl r8\n"
+
1016  "rol r9\n"
+
1017  "rol r10\n"
+
1018  "rol r11\n"
+
1019  "rol r12\n"
+
1020  "rol r13\n"
+
1021  "rol r14\n"
+
1022  "rol r15\n"
+
1023  "adc r8, __zero_reg__\n"
+
1024  "lsl r8\n"
+
1025  "rol r9\n"
+
1026  "rol r10\n"
+
1027  "rol r11\n"
+
1028  "rol r12\n"
+
1029  "rol r13\n"
+
1030  "rol r14\n"
+
1031  "rol r15\n"
+
1032  "adc r8, __zero_reg__\n"
+
1033  "lsl r8\n"
+
1034  "rol r9\n"
+
1035  "rol r10\n"
+
1036  "rol r11\n"
+
1037  "rol r12\n"
+
1038  "rol r13\n"
+
1039  "rol r14\n"
+
1040  "rol r15\n"
+
1041  "adc r8, __zero_reg__\n"
+
1042  "st X+,r12\n"
+
1043  "st X+,r13\n"
+
1044  "st X+,r14\n"
+
1045  "st X+,r15\n"
+
1046  "st X+,r8\n"
+
1047  "st X+,r9\n"
+
1048  "st X+,r10\n"
+
1049  "st X+,r11\n"
+
1050 
+
1051  // B[4][1] = leftRotate55_64(A[1][3])
+
1052  "adiw r26,32\n"
+
1053  "ldd r8,Z+24\n"
+
1054  "ldd r9,Z+25\n"
+
1055  "ldd r10,Z+26\n"
+
1056  "ldd r11,Z+27\n"
+
1057  "ldd r12,Z+28\n"
+
1058  "ldd r13,Z+29\n"
+
1059  "ldd r14,Z+30\n"
+
1060  "ldd r15,Z+31\n"
+
1061  "bst r8,0\n"
+
1062  "ror r15\n"
+
1063  "ror r14\n"
+
1064  "ror r13\n"
+
1065  "ror r12\n"
+
1066  "ror r11\n"
+
1067  "ror r10\n"
+
1068  "ror r9\n"
+
1069  "ror r8\n"
+
1070  "bld r15,7\n"
+
1071  "st X+,r9\n"
+
1072  "st X+,r10\n"
+
1073  "st X+,r11\n"
+
1074  "st X+,r12\n"
+
1075  "st X+,r13\n"
+
1076  "st X+,r14\n"
+
1077  "st X+,r15\n"
+
1078  "st X+,r8\n"
+
1079 
+
1080  // B[0][2] = leftRotate43_64(A[2][2])
+
1081  "subi r26,160\n"
+
1082  "sbc r27,__zero_reg__\n"
+
1083  "adiw r30,40\n"
+
1084  "ldd r8,Z+16\n"
+
1085  "ldd r9,Z+17\n"
+
1086  "ldd r10,Z+18\n"
+
1087  "ldd r11,Z+19\n"
+
1088  "ldd r12,Z+20\n"
+
1089  "ldd r13,Z+21\n"
+
1090  "ldd r14,Z+22\n"
+
1091  "ldd r15,Z+23\n"
+
1092  "lsl r8\n"
+
1093  "rol r9\n"
+
1094  "rol r10\n"
+
1095  "rol r11\n"
+
1096  "rol r12\n"
+
1097  "rol r13\n"
+
1098  "rol r14\n"
+
1099  "rol r15\n"
+
1100  "adc r8, __zero_reg__\n"
+
1101  "lsl r8\n"
+
1102  "rol r9\n"
+
1103  "rol r10\n"
+
1104  "rol r11\n"
+
1105  "rol r12\n"
+
1106  "rol r13\n"
+
1107  "rol r14\n"
+
1108  "rol r15\n"
+
1109  "adc r8, __zero_reg__\n"
+
1110  "lsl r8\n"
+
1111  "rol r9\n"
+
1112  "rol r10\n"
+
1113  "rol r11\n"
+
1114  "rol r12\n"
+
1115  "rol r13\n"
+
1116  "rol r14\n"
+
1117  "rol r15\n"
+
1118  "adc r8, __zero_reg__\n"
+
1119  "st X+,r11\n"
+
1120  "st X+,r12\n"
+
1121  "st X+,r13\n"
+
1122  "st X+,r14\n"
+
1123  "st X+,r15\n"
+
1124  "st X+,r8\n"
+
1125  "st X+,r9\n"
+
1126  "st X+,r10\n"
+
1127 
+
1128  // B[1][2] = leftRotate3_64(A[2][0])
+
1129  "adiw r26,32\n"
+
1130  "ld r8,Z\n"
+
1131  "ldd r9,Z+1\n"
+
1132  "ldd r10,Z+2\n"
+
1133  "ldd r11,Z+3\n"
+
1134  "ldd r12,Z+4\n"
+
1135  "ldd r13,Z+5\n"
+
1136  "ldd r14,Z+6\n"
+
1137  "ldd r15,Z+7\n"
+
1138  "lsl r8\n"
+
1139  "rol r9\n"
+
1140  "rol r10\n"
+
1141  "rol r11\n"
+
1142  "rol r12\n"
+
1143  "rol r13\n"
+
1144  "rol r14\n"
+
1145  "rol r15\n"
+
1146  "adc r8, __zero_reg__\n"
+
1147  "lsl r8\n"
+
1148  "rol r9\n"
+
1149  "rol r10\n"
+
1150  "rol r11\n"
+
1151  "rol r12\n"
+
1152  "rol r13\n"
+
1153  "rol r14\n"
+
1154  "rol r15\n"
+
1155  "adc r8, __zero_reg__\n"
+
1156  "lsl r8\n"
+
1157  "rol r9\n"
+
1158  "rol r10\n"
+
1159  "rol r11\n"
+
1160  "rol r12\n"
+
1161  "rol r13\n"
+
1162  "rol r14\n"
+
1163  "rol r15\n"
+
1164  "adc r8, __zero_reg__\n"
+
1165  "st X+,r8\n"
+
1166  "st X+,r9\n"
+
1167  "st X+,r10\n"
+
1168  "st X+,r11\n"
+
1169  "st X+,r12\n"
+
1170  "st X+,r13\n"
+
1171  "st X+,r14\n"
+
1172  "st X+,r15\n"
+
1173 
+
1174  // B[2][2] = leftRotate25_64(A[2][3])
+
1175  "adiw r26,32\n"
+
1176  "ldd r8,Z+24\n"
+
1177  "ldd r9,Z+25\n"
+
1178  "ldd r10,Z+26\n"
+
1179  "ldd r11,Z+27\n"
+
1180  "ldd r12,Z+28\n"
+
1181  "ldd r13,Z+29\n"
+
1182  "ldd r14,Z+30\n"
+
1183  "ldd r15,Z+31\n"
+
1184  "lsl r8\n"
+
1185  "rol r9\n"
+
1186  "rol r10\n"
+
1187  "rol r11\n"
+
1188  "rol r12\n"
+
1189  "rol r13\n"
+
1190  "rol r14\n"
+
1191  "rol r15\n"
+
1192  "adc r8, __zero_reg__\n"
+
1193  "st X+,r13\n"
+
1194  "st X+,r14\n"
+
1195  "st X+,r15\n"
+
1196  "st X+,r8\n"
+
1197  "st X+,r9\n"
+
1198  "st X+,r10\n"
+
1199  "st X+,r11\n"
+
1200  "st X+,r12\n"
+
1201 
+
1202  // B[3][2] = leftRotate10_64(A[2][1])
+
1203  "adiw r26,32\n"
+
1204  "ldd r8,Z+8\n"
+
1205  "ldd r9,Z+9\n"
+
1206  "ldd r10,Z+10\n"
+
1207  "ldd r11,Z+11\n"
+
1208  "ldd r12,Z+12\n"
+
1209  "ldd r13,Z+13\n"
+
1210  "ldd r14,Z+14\n"
+
1211  "ldd r15,Z+15\n"
+
1212  "lsl r8\n"
+
1213  "rol r9\n"
+
1214  "rol r10\n"
+
1215  "rol r11\n"
+
1216  "rol r12\n"
+
1217  "rol r13\n"
+
1218  "rol r14\n"
+
1219  "rol r15\n"
+
1220  "adc r8, __zero_reg__\n"
+
1221  "lsl r8\n"
+
1222  "rol r9\n"
+
1223  "rol r10\n"
+
1224  "rol r11\n"
+
1225  "rol r12\n"
+
1226  "rol r13\n"
+
1227  "rol r14\n"
+
1228  "rol r15\n"
+
1229  "adc r8, __zero_reg__\n"
+
1230  "st X+,r15\n"
+
1231  "st X+,r8\n"
+
1232  "st X+,r9\n"
+
1233  "st X+,r10\n"
+
1234  "st X+,r11\n"
+
1235  "st X+,r12\n"
+
1236  "st X+,r13\n"
+
1237  "st X+,r14\n"
+
1238 
+
1239  // B[4][2] = leftRotate39_64(A[2][4])
+
1240  "adiw r26,32\n"
+
1241  "ldd r8,Z+32\n"
+
1242  "ldd r9,Z+33\n"
+
1243  "ldd r10,Z+34\n"
+
1244  "ldd r11,Z+35\n"
+
1245  "ldd r12,Z+36\n"
+
1246  "ldd r13,Z+37\n"
+
1247  "ldd r14,Z+38\n"
+
1248  "ldd r15,Z+39\n"
+
1249  "bst r8,0\n"
+
1250  "ror r15\n"
+
1251  "ror r14\n"
+
1252  "ror r13\n"
+
1253  "ror r12\n"
+
1254  "ror r11\n"
+
1255  "ror r10\n"
+
1256  "ror r9\n"
+
1257  "ror r8\n"
+
1258  "bld r15,7\n"
+
1259  "st X+,r11\n"
+
1260  "st X+,r12\n"
+
1261  "st X+,r13\n"
+
1262  "st X+,r14\n"
+
1263  "st X+,r15\n"
+
1264  "st X+,r8\n"
+
1265  "st X+,r9\n"
+
1266  "st X+,r10\n"
+
1267 
+
1268  // B[0][3] = leftRotate21_64(A[3][3])
+
1269  "subi r26,160\n"
+
1270  "sbc r27,__zero_reg__\n"
+
1271  "adiw r30,40\n"
+
1272  "ldd r8,Z+24\n"
+
1273  "ldd r9,Z+25\n"
+
1274  "ldd r10,Z+26\n"
+
1275  "ldd r11,Z+27\n"
+
1276  "ldd r12,Z+28\n"
+
1277  "ldd r13,Z+29\n"
+
1278  "ldd r14,Z+30\n"
+
1279  "ldd r15,Z+31\n"
+
1280  "bst r8,0\n"
+
1281  "ror r15\n"
+
1282  "ror r14\n"
+
1283  "ror r13\n"
+
1284  "ror r12\n"
+
1285  "ror r11\n"
+
1286  "ror r10\n"
+
1287  "ror r9\n"
+
1288  "ror r8\n"
+
1289  "bld r15,7\n"
+
1290  "bst r8,0\n"
+
1291  "ror r15\n"
+
1292  "ror r14\n"
+
1293  "ror r13\n"
+
1294  "ror r12\n"
+
1295  "ror r11\n"
+
1296  "ror r10\n"
+
1297  "ror r9\n"
+
1298  "ror r8\n"
+
1299  "bld r15,7\n"
+
1300  "bst r8,0\n"
+
1301  "ror r15\n"
+
1302  "ror r14\n"
+
1303  "ror r13\n"
+
1304  "ror r12\n"
+
1305  "ror r11\n"
+
1306  "ror r10\n"
+
1307  "ror r9\n"
+
1308  "ror r8\n"
+
1309  "bld r15,7\n"
+
1310  "st X+,r13\n"
+
1311  "st X+,r14\n"
+
1312  "st X+,r15\n"
+
1313  "st X+,r8\n"
+
1314  "st X+,r9\n"
+
1315  "st X+,r10\n"
+
1316  "st X+,r11\n"
+
1317  "st X+,r12\n"
+
1318 
+
1319  // B[1][3] = leftRotate45_64(A[3][1])
+
1320  "adiw r26,32\n"
+
1321  "ldd r8,Z+8\n"
+
1322  "ldd r9,Z+9\n"
+
1323  "ldd r10,Z+10\n"
+
1324  "ldd r11,Z+11\n"
+
1325  "ldd r12,Z+12\n"
+
1326  "ldd r13,Z+13\n"
+
1327  "ldd r14,Z+14\n"
+
1328  "ldd r15,Z+15\n"
+
1329  "bst r8,0\n"
+
1330  "ror r15\n"
+
1331  "ror r14\n"
+
1332  "ror r13\n"
+
1333  "ror r12\n"
+
1334  "ror r11\n"
+
1335  "ror r10\n"
+
1336  "ror r9\n"
+
1337  "ror r8\n"
+
1338  "bld r15,7\n"
+
1339  "bst r8,0\n"
+
1340  "ror r15\n"
+
1341  "ror r14\n"
+
1342  "ror r13\n"
+
1343  "ror r12\n"
+
1344  "ror r11\n"
+
1345  "ror r10\n"
+
1346  "ror r9\n"
+
1347  "ror r8\n"
+
1348  "bld r15,7\n"
+
1349  "bst r8,0\n"
+
1350  "ror r15\n"
+
1351  "ror r14\n"
+
1352  "ror r13\n"
+
1353  "ror r12\n"
+
1354  "ror r11\n"
+
1355  "ror r10\n"
+
1356  "ror r9\n"
+
1357  "ror r8\n"
+
1358  "bld r15,7\n"
+
1359  "st X+,r10\n"
+
1360  "st X+,r11\n"
+
1361  "st X+,r12\n"
+
1362  "st X+,r13\n"
+
1363  "st X+,r14\n"
+
1364  "st X+,r15\n"
+
1365  "st X+,r8\n"
+
1366  "st X+,r9\n"
+
1367 
+
1368  // B[2][3] = leftRotate8_64(A[3][4])
+
1369  "adiw r26,32\n"
+
1370  "ldd r8,Z+32\n"
+
1371  "ldd r9,Z+33\n"
+
1372  "ldd r10,Z+34\n"
+
1373  "ldd r11,Z+35\n"
+
1374  "ldd r12,Z+36\n"
+
1375  "ldd r13,Z+37\n"
+
1376  "ldd r14,Z+38\n"
+
1377  "ldd r15,Z+39\n"
+
1378  "st X+,r15\n"
+
1379  "st X+,r8\n"
+
1380  "st X+,r9\n"
+
1381  "st X+,r10\n"
+
1382  "st X+,r11\n"
+
1383  "st X+,r12\n"
+
1384  "st X+,r13\n"
+
1385  "st X+,r14\n"
+
1386 
+
1387  // B[3][3] = leftRotate15_64(A[3][2])
+
1388  "adiw r26,32\n"
+
1389  "ldd r8,Z+16\n"
+
1390  "ldd r9,Z+17\n"
+
1391  "ldd r10,Z+18\n"
+
1392  "ldd r11,Z+19\n"
+
1393  "ldd r12,Z+20\n"
+
1394  "ldd r13,Z+21\n"
+
1395  "ldd r14,Z+22\n"
+
1396  "ldd r15,Z+23\n"
+
1397  "bst r8,0\n"
+
1398  "ror r15\n"
+
1399  "ror r14\n"
+
1400  "ror r13\n"
+
1401  "ror r12\n"
+
1402  "ror r11\n"
+
1403  "ror r10\n"
+
1404  "ror r9\n"
+
1405  "ror r8\n"
+
1406  "bld r15,7\n"
+
1407  "st X+,r14\n"
+
1408  "st X+,r15\n"
+
1409  "st X+,r8\n"
+
1410  "st X+,r9\n"
+
1411  "st X+,r10\n"
+
1412  "st X+,r11\n"
+
1413  "st X+,r12\n"
+
1414  "st X+,r13\n"
+
1415 
+
1416  // B[4][3] = leftRotate41_64(A[3][0])
+
1417  "adiw r26,32\n"
+
1418  "ld r8,Z\n"
+
1419  "ldd r9,Z+1\n"
+
1420  "ldd r10,Z+2\n"
+
1421  "ldd r11,Z+3\n"
+
1422  "ldd r12,Z+4\n"
+
1423  "ldd r13,Z+5\n"
+
1424  "ldd r14,Z+6\n"
+
1425  "ldd r15,Z+7\n"
+
1426  "lsl r8\n"
+
1427  "rol r9\n"
+
1428  "rol r10\n"
+
1429  "rol r11\n"
+
1430  "rol r12\n"
+
1431  "rol r13\n"
+
1432  "rol r14\n"
+
1433  "rol r15\n"
+
1434  "adc r8, __zero_reg__\n"
+
1435  "st X+,r11\n"
+
1436  "st X+,r12\n"
+
1437  "st X+,r13\n"
+
1438  "st X+,r14\n"
+
1439  "st X+,r15\n"
+
1440  "st X+,r8\n"
+
1441  "st X+,r9\n"
+
1442  "st X+,r10\n"
+
1443 
+
1444  // B[0][4] = leftRotate14_64(A[4][4])
+
1445  "subi r26,160\n"
+
1446  "sbc r27,__zero_reg__\n"
+
1447  "adiw r30,40\n"
+
1448  "ldd r8,Z+32\n"
+
1449  "ldd r9,Z+33\n"
+
1450  "ldd r10,Z+34\n"
+
1451  "ldd r11,Z+35\n"
+
1452  "ldd r12,Z+36\n"
+
1453  "ldd r13,Z+37\n"
+
1454  "ldd r14,Z+38\n"
+
1455  "ldd r15,Z+39\n"
+
1456  "bst r8,0\n"
+
1457  "ror r15\n"
+
1458  "ror r14\n"
+
1459  "ror r13\n"
+
1460  "ror r12\n"
+
1461  "ror r11\n"
+
1462  "ror r10\n"
+
1463  "ror r9\n"
+
1464  "ror r8\n"
+
1465  "bld r15,7\n"
+
1466  "bst r8,0\n"
+
1467  "ror r15\n"
+
1468  "ror r14\n"
+
1469  "ror r13\n"
+
1470  "ror r12\n"
+
1471  "ror r11\n"
+
1472  "ror r10\n"
+
1473  "ror r9\n"
+
1474  "ror r8\n"
+
1475  "bld r15,7\n"
+
1476  "st X+,r14\n"
+
1477  "st X+,r15\n"
+
1478  "st X+,r8\n"
+
1479  "st X+,r9\n"
+
1480  "st X+,r10\n"
+
1481  "st X+,r11\n"
+
1482  "st X+,r12\n"
+
1483  "st X+,r13\n"
+
1484 
+
1485  // B[1][4] = leftRotate61_64(A[4][2])
+
1486  "adiw r26,32\n"
+
1487  "ldd r8,Z+16\n"
+
1488  "ldd r9,Z+17\n"
+
1489  "ldd r10,Z+18\n"
+
1490  "ldd r11,Z+19\n"
+
1491  "ldd r12,Z+20\n"
+
1492  "ldd r13,Z+21\n"
+
1493  "ldd r14,Z+22\n"
+
1494  "ldd r15,Z+23\n"
+
1495  "bst r8,0\n"
+
1496  "ror r15\n"
+
1497  "ror r14\n"
+
1498  "ror r13\n"
+
1499  "ror r12\n"
+
1500  "ror r11\n"
+
1501  "ror r10\n"
+
1502  "ror r9\n"
+
1503  "ror r8\n"
+
1504  "bld r15,7\n"
+
1505  "bst r8,0\n"
+
1506  "ror r15\n"
+
1507  "ror r14\n"
+
1508  "ror r13\n"
+
1509  "ror r12\n"
+
1510  "ror r11\n"
+
1511  "ror r10\n"
+
1512  "ror r9\n"
+
1513  "ror r8\n"
+
1514  "bld r15,7\n"
+
1515  "bst r8,0\n"
+
1516  "ror r15\n"
+
1517  "ror r14\n"
+
1518  "ror r13\n"
+
1519  "ror r12\n"
+
1520  "ror r11\n"
+
1521  "ror r10\n"
+
1522  "ror r9\n"
+
1523  "ror r8\n"
+
1524  "bld r15,7\n"
+
1525  "st X+,r8\n"
+
1526  "st X+,r9\n"
+
1527  "st X+,r10\n"
+
1528  "st X+,r11\n"
+
1529  "st X+,r12\n"
+
1530  "st X+,r13\n"
+
1531  "st X+,r14\n"
+
1532  "st X+,r15\n"
+
1533 
+
1534  // B[2][4] = leftRotate18_64(A[4][0])
+
1535  "adiw r26,32\n"
+
1536  "ld r8,Z\n"
+
1537  "ldd r9,Z+1\n"
+
1538  "ldd r10,Z+2\n"
+
1539  "ldd r11,Z+3\n"
+
1540  "ldd r12,Z+4\n"
+
1541  "ldd r13,Z+5\n"
+
1542  "ldd r14,Z+6\n"
+
1543  "ldd r15,Z+7\n"
+
1544  "lsl r8\n"
+
1545  "rol r9\n"
+
1546  "rol r10\n"
+
1547  "rol r11\n"
+
1548  "rol r12\n"
+
1549  "rol r13\n"
+
1550  "rol r14\n"
+
1551  "rol r15\n"
+
1552  "adc r8, __zero_reg__\n"
+
1553  "lsl r8\n"
+
1554  "rol r9\n"
+
1555  "rol r10\n"
+
1556  "rol r11\n"
+
1557  "rol r12\n"
+
1558  "rol r13\n"
+
1559  "rol r14\n"
+
1560  "rol r15\n"
+
1561  "adc r8, __zero_reg__\n"
+
1562  "st X+,r14\n"
+
1563  "st X+,r15\n"
+
1564  "st X+,r8\n"
+
1565  "st X+,r9\n"
+
1566  "st X+,r10\n"
+
1567  "st X+,r11\n"
+
1568  "st X+,r12\n"
+
1569  "st X+,r13\n"
+
1570 
+
1571  // B[3][4] = leftRotate56_64(A[4][3])
+
1572  "adiw r26,32\n"
+
1573  "ldd r8,Z+24\n"
+
1574  "ldd r9,Z+25\n"
+
1575  "ldd r10,Z+26\n"
+
1576  "ldd r11,Z+27\n"
+
1577  "ldd r12,Z+28\n"
+
1578  "ldd r13,Z+29\n"
+
1579  "ldd r14,Z+30\n"
+
1580  "ldd r15,Z+31\n"
+
1581  "st X+,r9\n"
+
1582  "st X+,r10\n"
+
1583  "st X+,r11\n"
+
1584  "st X+,r12\n"
+
1585  "st X+,r13\n"
+
1586  "st X+,r14\n"
+
1587  "st X+,r15\n"
+
1588  "st X+,r8\n"
+
1589 
+
1590  // B[4][4] = leftRotate2_64(A[4][1])
+
1591  "adiw r26,32\n"
+
1592  "ldd r8,Z+8\n"
+
1593  "ldd r9,Z+9\n"
+
1594  "ldd r10,Z+10\n"
+
1595  "ldd r11,Z+11\n"
+
1596  "ldd r12,Z+12\n"
+
1597  "ldd r13,Z+13\n"
+
1598  "ldd r14,Z+14\n"
+
1599  "ldd r15,Z+15\n"
+
1600  "lsl r8\n"
+
1601  "rol r9\n"
+
1602  "rol r10\n"
+
1603  "rol r11\n"
+
1604  "rol r12\n"
+
1605  "rol r13\n"
+
1606  "rol r14\n"
+
1607  "rol r15\n"
+
1608  "adc r8, __zero_reg__\n"
+
1609  "lsl r8\n"
+
1610  "rol r9\n"
+
1611  "rol r10\n"
+
1612  "rol r11\n"
+
1613  "rol r12\n"
+
1614  "rol r13\n"
+
1615  "rol r14\n"
+
1616  "rol r15\n"
+
1617  "adc r8, __zero_reg__\n"
+
1618  "st X+,r8\n"
+
1619  "st X+,r9\n"
+
1620  "st X+,r10\n"
+
1621  "st X+,r11\n"
+
1622  "st X+,r12\n"
+
1623  "st X+,r13\n"
+
1624  "st X+,r14\n"
+
1625  "st X+,r15\n"
+
1626  "subi r26,200\n"
+
1627  "sbc r27,__zero_reg__\n"
+
1628  "subi r30,160\n"
+
1629  "sbc r31,__zero_reg__\n"
+
1630 
+
1631  // Step mapping chi.
+
1632  "ldi r20,5\n"
+
1633  "50:\n"
+
1634  "ld r8,Y\n"
+
1635  "ldd r9,Y+8\n"
+
1636  "ldd r10,Y+16\n"
+
1637  "ldd r11,Y+24\n"
+
1638  "ldd r12,Y+32\n"
+
1639  "mov r13,r9\n"
+
1640  "com r13\n"
+
1641  "and r13,r10\n"
+
1642  "eor r13,r8\n"
+
1643  "mov r14,r10\n"
+
1644  "com r14\n"
+
1645  "and r14,r11\n"
+
1646  "eor r14,r9\n"
+
1647  "mov r15,r11\n"
+
1648  "com r15\n"
+
1649  "and r15,r12\n"
+
1650  "eor r15,r10\n"
+
1651  "mov r17,r12\n"
+
1652  "com r17\n"
+
1653  "and r17,r8\n"
+
1654  "eor r17,r11\n"
+
1655  "mov r16,r8\n"
+
1656  "com r16\n"
+
1657  "and r16,r9\n"
+
1658  "eor r16,r12\n"
+
1659  "st Z,r13\n"
+
1660  "std Z+8,r14\n"
+
1661  "std Z+16,r15\n"
+
1662  "std Z+24,r17\n"
+
1663  "std Z+32,r16\n"
+
1664  "ldd r8,Y+1\n"
+
1665  "ldd r9,Y+9\n"
+
1666  "ldd r10,Y+17\n"
+
1667  "ldd r11,Y+25\n"
+
1668  "ldd r12,Y+33\n"
+
1669  "mov r13,r9\n"
+
1670  "com r13\n"
+
1671  "and r13,r10\n"
+
1672  "eor r13,r8\n"
+
1673  "mov r14,r10\n"
+
1674  "com r14\n"
+
1675  "and r14,r11\n"
+
1676  "eor r14,r9\n"
+
1677  "mov r15,r11\n"
+
1678  "com r15\n"
+
1679  "and r15,r12\n"
+
1680  "eor r15,r10\n"
+
1681  "mov r17,r12\n"
+
1682  "com r17\n"
+
1683  "and r17,r8\n"
+
1684  "eor r17,r11\n"
+
1685  "mov r16,r8\n"
+
1686  "com r16\n"
+
1687  "and r16,r9\n"
+
1688  "eor r16,r12\n"
+
1689  "std Z+1,r13\n"
+
1690  "std Z+9,r14\n"
+
1691  "std Z+17,r15\n"
+
1692  "std Z+25,r17\n"
+
1693  "std Z+33,r16\n"
+
1694  "ldd r8,Y+2\n"
+
1695  "ldd r9,Y+10\n"
+
1696  "ldd r10,Y+18\n"
+
1697  "ldd r11,Y+26\n"
+
1698  "ldd r12,Y+34\n"
+
1699  "mov r13,r9\n"
+
1700  "com r13\n"
+
1701  "and r13,r10\n"
+
1702  "eor r13,r8\n"
+
1703  "mov r14,r10\n"
+
1704  "com r14\n"
+
1705  "and r14,r11\n"
+
1706  "eor r14,r9\n"
+
1707  "mov r15,r11\n"
+
1708  "com r15\n"
+
1709  "and r15,r12\n"
+
1710  "eor r15,r10\n"
+
1711  "mov r17,r12\n"
+
1712  "com r17\n"
+
1713  "and r17,r8\n"
+
1714  "eor r17,r11\n"
+
1715  "mov r16,r8\n"
+
1716  "com r16\n"
+
1717  "and r16,r9\n"
+
1718  "eor r16,r12\n"
+
1719  "std Z+2,r13\n"
+
1720  "std Z+10,r14\n"
+
1721  "std Z+18,r15\n"
+
1722  "std Z+26,r17\n"
+
1723  "std Z+34,r16\n"
+
1724  "ldd r8,Y+3\n"
+
1725  "ldd r9,Y+11\n"
+
1726  "ldd r10,Y+19\n"
+
1727  "ldd r11,Y+27\n"
+
1728  "ldd r12,Y+35\n"
+
1729  "mov r13,r9\n"
+
1730  "com r13\n"
+
1731  "and r13,r10\n"
+
1732  "eor r13,r8\n"
+
1733  "mov r14,r10\n"
+
1734  "com r14\n"
+
1735  "and r14,r11\n"
+
1736  "eor r14,r9\n"
+
1737  "mov r15,r11\n"
+
1738  "com r15\n"
+
1739  "and r15,r12\n"
+
1740  "eor r15,r10\n"
+
1741  "mov r17,r12\n"
+
1742  "com r17\n"
+
1743  "and r17,r8\n"
+
1744  "eor r17,r11\n"
+
1745  "mov r16,r8\n"
+
1746  "com r16\n"
+
1747  "and r16,r9\n"
+
1748  "eor r16,r12\n"
+
1749  "std Z+3,r13\n"
+
1750  "std Z+11,r14\n"
+
1751  "std Z+19,r15\n"
+
1752  "std Z+27,r17\n"
+
1753  "std Z+35,r16\n"
+
1754  "ldd r8,Y+4\n"
+
1755  "ldd r9,Y+12\n"
+
1756  "ldd r10,Y+20\n"
+
1757  "ldd r11,Y+28\n"
+
1758  "ldd r12,Y+36\n"
+
1759  "mov r13,r9\n"
+
1760  "com r13\n"
+
1761  "and r13,r10\n"
+
1762  "eor r13,r8\n"
+
1763  "mov r14,r10\n"
+
1764  "com r14\n"
+
1765  "and r14,r11\n"
+
1766  "eor r14,r9\n"
+
1767  "mov r15,r11\n"
+
1768  "com r15\n"
+
1769  "and r15,r12\n"
+
1770  "eor r15,r10\n"
+
1771  "mov r17,r12\n"
+
1772  "com r17\n"
+
1773  "and r17,r8\n"
+
1774  "eor r17,r11\n"
+
1775  "mov r16,r8\n"
+
1776  "com r16\n"
+
1777  "and r16,r9\n"
+
1778  "eor r16,r12\n"
+
1779  "std Z+4,r13\n"
+
1780  "std Z+12,r14\n"
+
1781  "std Z+20,r15\n"
+
1782  "std Z+28,r17\n"
+
1783  "std Z+36,r16\n"
+
1784  "ldd r8,Y+5\n"
+
1785  "ldd r9,Y+13\n"
+
1786  "ldd r10,Y+21\n"
+
1787  "ldd r11,Y+29\n"
+
1788  "ldd r12,Y+37\n"
+
1789  "mov r13,r9\n"
+
1790  "com r13\n"
+
1791  "and r13,r10\n"
+
1792  "eor r13,r8\n"
+
1793  "mov r14,r10\n"
+
1794  "com r14\n"
+
1795  "and r14,r11\n"
+
1796  "eor r14,r9\n"
+
1797  "mov r15,r11\n"
+
1798  "com r15\n"
+
1799  "and r15,r12\n"
+
1800  "eor r15,r10\n"
+
1801  "mov r17,r12\n"
+
1802  "com r17\n"
+
1803  "and r17,r8\n"
+
1804  "eor r17,r11\n"
+
1805  "mov r16,r8\n"
+
1806  "com r16\n"
+
1807  "and r16,r9\n"
+
1808  "eor r16,r12\n"
+
1809  "std Z+5,r13\n"
+
1810  "std Z+13,r14\n"
+
1811  "std Z+21,r15\n"
+
1812  "std Z+29,r17\n"
+
1813  "std Z+37,r16\n"
+
1814  "ldd r8,Y+6\n"
+
1815  "ldd r9,Y+14\n"
+
1816  "ldd r10,Y+22\n"
+
1817  "ldd r11,Y+30\n"
+
1818  "ldd r12,Y+38\n"
+
1819  "mov r13,r9\n"
+
1820  "com r13\n"
+
1821  "and r13,r10\n"
+
1822  "eor r13,r8\n"
+
1823  "mov r14,r10\n"
+
1824  "com r14\n"
+
1825  "and r14,r11\n"
+
1826  "eor r14,r9\n"
+
1827  "mov r15,r11\n"
+
1828  "com r15\n"
+
1829  "and r15,r12\n"
+
1830  "eor r15,r10\n"
+
1831  "mov r17,r12\n"
+
1832  "com r17\n"
+
1833  "and r17,r8\n"
+
1834  "eor r17,r11\n"
+
1835  "mov r16,r8\n"
+
1836  "com r16\n"
+
1837  "and r16,r9\n"
+
1838  "eor r16,r12\n"
+
1839  "std Z+6,r13\n"
+
1840  "std Z+14,r14\n"
+
1841  "std Z+22,r15\n"
+
1842  "std Z+30,r17\n"
+
1843  "std Z+38,r16\n"
+
1844  "ldd r8,Y+7\n"
+
1845  "ldd r9,Y+15\n"
+
1846  "ldd r10,Y+23\n"
+
1847  "ldd r11,Y+31\n"
+
1848  "ldd r12,Y+39\n"
+
1849  "mov r13,r9\n"
+
1850  "com r13\n"
+
1851  "and r13,r10\n"
+
1852  "eor r13,r8\n"
+
1853  "mov r14,r10\n"
+
1854  "com r14\n"
+
1855  "and r14,r11\n"
+
1856  "eor r14,r9\n"
+
1857  "mov r15,r11\n"
+
1858  "com r15\n"
+
1859  "and r15,r12\n"
+
1860  "eor r15,r10\n"
+
1861  "mov r17,r12\n"
+
1862  "com r17\n"
+
1863  "and r17,r8\n"
+
1864  "eor r17,r11\n"
+
1865  "mov r16,r8\n"
+
1866  "com r16\n"
+
1867  "and r16,r9\n"
+
1868  "eor r16,r12\n"
+
1869  "std Z+7,r13\n"
+
1870  "std Z+15,r14\n"
+
1871  "std Z+23,r15\n"
+
1872  "std Z+31,r17\n"
+
1873  "std Z+39,r16\n"
+
1874  "adiw r30,40\n"
+
1875  "adiw r28,40\n"
+
1876  "dec r20\n"
+
1877  "breq 51f\n"
+
1878  "rjmp 50b\n"
+
1879  "51:\n"
+
1880  "pop r28\n"
+
1881  "pop r29\n"
+
1882 
+
1883  // Done
+
1884  : : "x"(B), "z"(state.A)
+
1885  : "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
+
1886  "r16", "r17", "r18", "r19", "r20", "r21", "memory"
+
1887  );
+
1888 #else
+
1889  static const uint8_t addMod5Table[9] PROGMEM = {
+
1890  0, 1, 2, 3, 4, 0, 1, 2, 3
+
1891  };
+
1892  #define addMod5(x, y) (pgm_read_byte(&(addMod5Table[(x) + (y)])))
+
1893  uint64_t D;
+
1894  uint8_t index, index2;
+
1895  for (uint8_t round = 0; round < 24; ++round) {
+
1896  // Step mapping theta. The specification mentions two temporary
+
1897  // arrays of size 5 called C and D. To save a bit of memory,
+
1898  // we use the first row of B to store C and compute D on the fly.
+
1899  for (index = 0; index < 5; ++index) {
+
1900  B[0][index] = state.A[0][index] ^ state.A[1][index] ^
+
1901  state.A[2][index] ^ state.A[3][index] ^
+
1902  state.A[4][index];
+
1903  }
+
1904  for (index = 0; index < 5; ++index) {
+
1905  D = B[0][addMod5(index, 4)] ^
+
1906  leftRotate1_64(B[0][addMod5(index, 1)]);
+
1907  for (index2 = 0; index2 < 5; ++index2)
+
1908  state.A[index2][index] ^= D;
+
1909  }
+
1910 
+
1911  // Step mapping rho and pi combined into a single step.
+
1912  // Rotate all lanes by a specific offset and rearrange.
+
1913  B[0][0] = state.A[0][0];
+
1914  B[1][0] = leftRotate28_64(state.A[0][3]);
+
1915  B[2][0] = leftRotate1_64 (state.A[0][1]);
+
1916  B[3][0] = leftRotate27_64(state.A[0][4]);
+
1917  B[4][0] = leftRotate62_64(state.A[0][2]);
+
1918  B[0][1] = leftRotate44_64(state.A[1][1]);
+
1919  B[1][1] = leftRotate20_64(state.A[1][4]);
+
1920  B[2][1] = leftRotate6_64 (state.A[1][2]);
+
1921  B[3][1] = leftRotate36_64(state.A[1][0]);
+
1922  B[4][1] = leftRotate55_64(state.A[1][3]);
+
1923  B[0][2] = leftRotate43_64(state.A[2][2]);
+
1924  B[1][2] = leftRotate3_64 (state.A[2][0]);
+
1925  B[2][2] = leftRotate25_64(state.A[2][3]);
+
1926  B[3][2] = leftRotate10_64(state.A[2][1]);
+
1927  B[4][2] = leftRotate39_64(state.A[2][4]);
+
1928  B[0][3] = leftRotate21_64(state.A[3][3]);
+
1929  B[1][3] = leftRotate45_64(state.A[3][1]);
+
1930  B[2][3] = leftRotate8_64 (state.A[3][4]);
+
1931  B[3][3] = leftRotate15_64(state.A[3][2]);
+
1932  B[4][3] = leftRotate41_64(state.A[3][0]);
+
1933  B[0][4] = leftRotate14_64(state.A[4][4]);
+
1934  B[1][4] = leftRotate61_64(state.A[4][2]);
+
1935  B[2][4] = leftRotate18_64(state.A[4][0]);
+
1936  B[3][4] = leftRotate56_64(state.A[4][3]);
+
1937  B[4][4] = leftRotate2_64 (state.A[4][1]);
+
1938 
+
1939  // Step mapping chi. Combine each lane with two other lanes in its row.
+
1940  for (index = 0; index < 5; ++index) {
+
1941  for (index2 = 0; index2 < 5; ++index2) {
+
1942  state.A[index2][index] =
+
1943  B[index2][index] ^
+
1944  ((~B[index2][addMod5(index, 1)]) &
+
1945  B[index2][addMod5(index, 2)]);
+
1946  }
+
1947  }
+
1948 #endif
+
1949 
+
1950  // Step mapping iota. XOR A[0][0] with the round constant.
+
1951  static uint64_t const RC[24] PROGMEM = {
+
1952  0x0000000000000001ULL, 0x0000000000008082ULL, 0x800000000000808AULL,
+
1953  0x8000000080008000ULL, 0x000000000000808BULL, 0x0000000080000001ULL,
+
1954  0x8000000080008081ULL, 0x8000000000008009ULL, 0x000000000000008AULL,
+
1955  0x0000000000000088ULL, 0x0000000080008009ULL, 0x000000008000000AULL,
+
1956  0x000000008000808BULL, 0x800000000000008BULL, 0x8000000000008089ULL,
+
1957  0x8000000000008003ULL, 0x8000000000008002ULL, 0x8000000000000080ULL,
+
1958  0x000000000000800AULL, 0x800000008000000AULL, 0x8000000080008081ULL,
+
1959  0x8000000000008080ULL, 0x0000000080000001ULL, 0x8000000080008008ULL
+
1960  };
+
1961  state.A[0][0] ^= pgm_read_qword(RC + round);
+
1962  }
+
1963 }
KeccakCore::blockSize
size_t blockSize() const
Returns the input block size for the sponge function in bytes.
Definition: KeccakCore.h:38
-
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:263
-
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:89
-
KeccakCore::~KeccakCore
~KeccakCore()
Destroys this Keccak sponge function after clearing all sensitive information.
Definition: KeccakCore.cpp:61
-
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:201
-
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:174
-
KeccakCore::capacity
size_t capacity() const
Returns the capacity of the sponge function in bits.
Definition: KeccakCore.cpp:71
-
KeccakCore::KeccakCore
KeccakCore()
Constructs a new Keccak sponge function.
Definition: KeccakCore.cpp:49
-
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:128
-
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:245
-
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:109
+
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:243
+
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:94
+
KeccakCore::~KeccakCore
~KeccakCore()
Destroys this Keccak sponge function after clearing all sensitive information.
Definition: KeccakCore.cpp:66
+
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:194
+
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:167
+
KeccakCore::capacity
size_t capacity() const
Returns the capacity of the sponge function in bits.
Definition: KeccakCore.cpp:76
+
KeccakCore::KeccakCore
KeccakCore()
Constructs a new Keccak sponge function.
Definition: KeccakCore.cpp:54
+
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:133
+
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:225
+
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:114
diff --git a/KeccakCore_8h_source.html b/KeccakCore_8h_source.html index 194a58a3..7436cb60 100644 --- a/KeccakCore_8h_source.html +++ b/KeccakCore_8h_source.html @@ -141,32 +141,31 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
51 private:
52  struct {
53  uint64_t A[5][5];
-
54  uint64_t B[5][5];
-
55  uint8_t inputSize;
-
56  uint8_t outputSize;
-
57  } state;
-
58  uint8_t _blockSize;
-
59 
-
60  void keccakp();
-
61 };
-
62 
-
63 #endif
+
54  uint8_t inputSize;
+
55  uint8_t outputSize;
+
56  } state;
+
57  uint8_t _blockSize;
+
58 
+
59  void keccakp();
+
60 };
+
61 
+
62 #endif
KeccakCore::blockSize
size_t blockSize() const
Returns the input block size for the sponge function in bytes.
Definition: KeccakCore.h:38
-
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:263
-
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:89
-
KeccakCore::~KeccakCore
~KeccakCore()
Destroys this Keccak sponge function after clearing all sensitive information.
Definition: KeccakCore.cpp:61
-
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:201
-
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:174
-
KeccakCore::capacity
size_t capacity() const
Returns the capacity of the sponge function in bits.
Definition: KeccakCore.cpp:71
-
KeccakCore::KeccakCore
KeccakCore()
Constructs a new Keccak sponge function.
Definition: KeccakCore.cpp:49
-
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:128
-
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:245
-
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:109
+
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:243
+
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:94
+
KeccakCore::~KeccakCore
~KeccakCore()
Destroys this Keccak sponge function after clearing all sensitive information.
Definition: KeccakCore.cpp:66
+
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:194
+
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:167
+
KeccakCore::capacity
size_t capacity() const
Returns the capacity of the sponge function in bits.
Definition: KeccakCore.cpp:76
+
KeccakCore::KeccakCore
KeccakCore()
Constructs a new Keccak sponge function.
Definition: KeccakCore.cpp:54
+
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:133
+
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:225
+
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:114
KeccakCore
Keccak core sponge function.
Definition: KeccakCore.h:29
diff --git a/LCD_8cpp_source.html b/LCD_8cpp_source.html index effd3024..285df550 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 12f30da8..5af2daf2 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 8306dec1..ced40a97 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 ab7834ab..8af16a1d 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/Melody_8cpp_source.html b/Melody_8cpp_source.html index a0699d7c..bb2fd610 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 44e32604..ca5ef26a 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 feee223c..7c10821d 100644 --- a/Mono5x7_8h_source.html +++ b/Mono5x7_8h_source.html @@ -246,7 +246,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/NoiseSource_8cpp_source.html b/NoiseSource_8cpp_source.html index 038b8b5f..fddf7bca 100644 --- a/NoiseSource_8cpp_source.html +++ b/NoiseSource_8cpp_source.html @@ -134,11 +134,11 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
NoiseSource::added
virtual void added()
Called when the noise source is added to RNG with RNG.addNoiseSource().
Definition: NoiseSource.cpp:95
NoiseSource::output
virtual void output(const uint8_t *data, size_t len, unsigned int credit)
Called from subclasses to output noise to the global random number pool.
Definition: NoiseSource.cpp:117
NoiseSource::~NoiseSource
virtual ~NoiseSource()
Destroys this random noise source.
Definition: NoiseSource.cpp:43
-
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:538
+
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:618
diff --git a/NoiseSource_8h_source.html b/NoiseSource_8h_source.html index 1cf311a0..2f4ae863 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 9fabe972..db825db8 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 65b58cf1..e59ad248 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/Poly1305_8cpp_source.html b/Poly1305_8cpp_source.html index beec8efe..6fca2062 100644 --- a/Poly1305_8cpp_source.html +++ b/Poly1305_8cpp_source.html @@ -196,163 +196,166 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
180 {
181  dlimb_t carry;
182  uint8_t i;
-
183 
-
184  // Pad and flush the final chunk.
-
185  if (state.chunkSize > 0) {
-
186  uint8_t *c = (uint8_t *)state.c;
-
187  c[state.chunkSize] = 1;
-
188  memset(c + state.chunkSize + 1, 0, 16 - state.chunkSize - 1);
-
189  littleToHost(state.c, NUM_LIMBS_128BIT);
-
190  state.c[NUM_LIMBS_128BIT] = 0;
-
191  processChunk();
-
192  }
-
193 
-
194  // At this point, processChunk() has left h as a partially reduced
-
195  // result that is less than (2^130 - 5) * 6. Perform one more
-
196  // reduction and a trial subtraction to produce the final result.
-
197 
-
198  // Multiply the high bits of h by 5 and add them to the 130 low bits.
-
199  carry = (dlimb_t)((state.h[NUM_LIMBS_128BIT] >> 2) +
-
200  (state.h[NUM_LIMBS_128BIT] & ~((limb_t)3)));
-
201  state.h[NUM_LIMBS_128BIT] &= 0x0003;
-
202  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
203  carry += state.h[i];
-
204  state.h[i] = (limb_t)carry;
-
205  carry >>= LIMB_BITS;
-
206  }
-
207  state.h[i] += (limb_t)carry;
-
208 
-
209  // Subtract (2^130 - 5) from h by computing t = h + 5 - 2^130.
-
210  // The "minus 2^130" step is implicit.
-
211  carry = 5;
-
212  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
213  carry += state.h[i];
-
214  state.t[i] = (limb_t)carry;
-
215  carry >>= LIMB_BITS;
-
216  }
-
217 
-
218  // Borrow occurs if bit 2^130 of the previous t result is zero.
-
219  // Carefully turn this into a selection mask so we can select either
-
220  // h or t as the final result. We don't care about the highest word
-
221  // of the result because we are about to drop it in the next step.
-
222  // We have to do it this way to avoid giving away any information
-
223  // about the value of h in the instruction timing.
-
224  limb_t mask = (~((state.t[NUM_LIMBS_128BIT] >> 2) & 1)) + 1;
-
225  limb_t nmask = ~mask;
-
226  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
227  state.h[i] = (state.h[i] & nmask) | (state.t[i] & mask);
-
228  }
-
229 
-
230  // Add the encrypted nonce and format the final hash.
-
231  memcpy(state.c, nonce, 16);
-
232  littleToHost(state.c, NUM_LIMBS_128BIT);
-
233  carry = 0;
-
234  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
235  carry += state.h[i];
-
236  carry += state.c[i];
-
237  state.h[i] = htolelimb((limb_t)carry);
-
238  carry >>= LIMB_BITS;
-
239  }
-
240  if (len > 16)
-
241  len = 16;
-
242  memcpy(token, state.h, len);
-
243 }
-
244 
-
250 void Poly1305::pad()
-
251 {
-
252  if (state.chunkSize != 0) {
-
253  memset(((uint8_t *)state.c) + state.chunkSize, 0, 16 - state.chunkSize);
-
254  littleToHost(state.c, NUM_LIMBS_128BIT);
-
255  state.c[NUM_LIMBS_128BIT] = 1;
-
256  processChunk();
-
257  state.chunkSize = 0;
-
258  }
-
259 }
-
260 
-
264 void Poly1305::clear()
-
265 {
-
266  clean(state);
-
267 }
-
268 
-
272 void Poly1305::processChunk()
-
273 {
-
274  // Compute h = ((h + c) * r) mod (2^130 - 5).
-
275 
-
276  // Start with h += c. We assume that h is less than (2^130 - 5) * 6
-
277  // and that c is less than 2^129, so the result will be less than 2^133.
-
278  dlimb_t carry = 0;
-
279  uint8_t i, j;
-
280  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
281  carry += state.h[i];
-
282  carry += state.c[i];
-
283  state.h[i] = (limb_t)carry;
-
284  carry >>= LIMB_BITS;
-
285  }
-
286 
-
287  // Multiply h by r. We know that r is less than 2^124 because the
-
288  // top 4 bits were AND-ed off by reset(). That makes h * r less
-
289  // than 2^257. Which is less than the (2^130 - 6)^2 we want for
-
290  // the modulo reduction step that follows.
-
291  carry = 0;
-
292  limb_t word = state.r[0];
-
293  for (i = 0; i < NUM_LIMBS_130BIT; ++i) {
-
294  carry += ((dlimb_t)(state.h[i])) * word;
-
295  state.t[i] = (limb_t)carry;
-
296  carry >>= LIMB_BITS;
-
297  }
-
298  state.t[NUM_LIMBS_130BIT] = (limb_t)carry;
-
299  for (i = 1; i < NUM_LIMBS_128BIT; ++i) {
-
300  word = state.r[i];
-
301  carry = 0;
-
302  for (j = 0; j < NUM_LIMBS_130BIT; ++j) {
-
303  carry += ((dlimb_t)(state.h[j])) * word;
-
304  carry += state.t[i + j];
-
305  state.t[i + j] = (limb_t)carry;
-
306  carry >>= LIMB_BITS;
-
307  }
-
308  state.t[i + NUM_LIMBS_130BIT] = (limb_t)carry;
-
309  }
-
310 
-
311  // Reduce h * r modulo (2^130 - 5) by multiplying the high 130 bits by 5
-
312  // and adding them to the low 130 bits. See the explaination in the
-
313  // comments for Curve25519::reduce() for a description of how this works.
-
314  carry = ((dlimb_t)(state.t[NUM_LIMBS_128BIT] >> 2)) +
-
315  (state.t[NUM_LIMBS_128BIT] & ~((limb_t)3));
-
316  state.t[NUM_LIMBS_128BIT] &= 0x0003;
-
317  for (i = 0; i < NUM_LIMBS_128BIT; ++i) {
-
318  // Shift the next word of t up by (LIMB_BITS - 2) bits and then
-
319  // multiply it by 5. Breaking it down, we can add the results
-
320  // of shifting up by LIMB_BITS and shifting up by (LIMB_BITS - 2).
-
321  // The main wrinkle here is that this can result in an intermediate
-
322  // carry that is (LIMB_BITS * 2 + 1) bits in size which doesn't
-
323  // fit within a dlimb_t variable. However, we can defer adding
-
324  // (word << LIMB_BITS) until after the "carry >>= LIMB_BITS" step
-
325  // because it won't affect the low bits of the carry.
-
326  word = state.t[i + NUM_LIMBS_130BIT];
-
327  carry += ((dlimb_t)word) << (LIMB_BITS - 2);
-
328  carry += state.t[i];
-
329  state.h[i] = (limb_t)carry;
-
330  carry >>= LIMB_BITS;
-
331  carry += word;
-
332  }
-
333  state.h[i] = (limb_t)(carry + state.t[NUM_LIMBS_128BIT]);
-
334 
-
335  // At this point, h is either the answer of reducing modulo (2^130 - 5)
-
336  // or it is at most 5 subtractions away from the answer we want.
-
337  // Leave it as-is for now with h less than (2^130 - 5) * 6. It is
-
338  // still within a range where the next h * r step will not overflow.
-
339 }
+
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:250
+
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:264
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
diff --git a/Poly1305_8h_source.html b/Poly1305_8h_source.html index fccee2f8..d864dfa7 100644 --- a/Poly1305_8h_source.html +++ b/Poly1305_8h_source.html @@ -135,26 +135,25 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
45  limb_t h[(16 / sizeof(limb_t)) + 1];
46  limb_t c[(16 / sizeof(limb_t)) + 1];
47  limb_t r[(16 / sizeof(limb_t))];
-
48  limb_t t[(32 / sizeof(limb_t)) + 1];
-
49  uint8_t chunkSize;
-
50  } state;
-
51 
-
52  void processChunk();
-
53 };
-
54 
-
55 #endif
+
48  uint8_t chunkSize;
+
49  } state;
+
50 
+
51  void processChunk();
+
52 };
+
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:250
+
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:264
+
Poly1305::clear
void clear()
Clears the authenticator's state, removing all sensitive data.
Definition: Poly1305.cpp:265
diff --git a/PowerSave_8cpp_source.html b/PowerSave_8cpp_source.html index c6efa088..5ab3be07 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 42e76481..93028c84 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 2a98d0a6..7bf5b28c 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 0dd1d9a3..5b1cac1d 100644 --- a/RNG_8cpp_source.html +++ b/RNG_8cpp_source.html @@ -120,430 +120,538 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
30 // The Arduino Due does not have any EEPROM natively on the main chip.
31 // However, it does have a TRNG and flash memory.
32 #define RNG_DUE_TRNG 1
-
33 #else
-
34 #define RNG_EEPROM 1
-
35 #include <avr/eeprom.h>
-
36 #endif
-
37 #include <string.h>
-
38 
-
132 RNGClass RNG;
-
133 
-
139 // Number of ChaCha hash rounds to use for random number generation.
-
140 #define RNG_ROUNDS 20
-
141 
-
142 // Force a rekey after this many blocks of random data.
-
143 #define RNG_REKEY_BLOCKS 16
-
144 
-
145 // Maximum entropy credit that can be contained in the pool.
-
146 #define RNG_MAX_CREDITS 384
-
147 
-
150 // Tag for 256-bit ChaCha20 keys. This will always appear in the
-
151 // first 16 bytes of the block. The remaining 48 bytes are the seed.
-
152 static const char tagRNG[16] PROGMEM = {
-
153  'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
-
154  '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
-
155 };
-
156 
-
157 // Initialization seed. This is the ChaCha20 output of hashing
-
158 // "expand 32-byte k" followed by 48 bytes set to the numbers 1 to 48.
-
159 // The ChaCha20 output block is then truncated to the first 48 bytes.
-
160 //
-
161 // This value is intended to start the RNG in a semi-chaotic state if
-
162 // we don't have a previously saved seed in EEPROM.
-
163 static const uint8_t initRNG[48] PROGMEM = {
-
164  0xB0, 0x2A, 0xAE, 0x7D, 0xEE, 0xCB, 0xBB, 0xB1,
-
165  0xFC, 0x03, 0x6F, 0xDD, 0xDC, 0x7D, 0x76, 0x67,
-
166  0x0C, 0xE8, 0x1F, 0x0D, 0xA3, 0xA0, 0xAA, 0x1E,
-
167  0xB0, 0xBD, 0x72, 0x6B, 0x2B, 0x4C, 0x8A, 0x7E,
-
168  0x34, 0xFC, 0x37, 0x60, 0xF4, 0x1E, 0x22, 0xA0,
-
169  0x0B, 0xFB, 0x18, 0x84, 0x60, 0xA5, 0x77, 0x72
-
170 };
-
171 
-
182 RNGClass::RNGClass()
-
183  : address(0)
-
184  , credits(0)
-
185  , firstSave(1)
-
186  , timer(0)
-
187  , timeout(3600000UL) // 1 hour in milliseconds
-
188  , count(0)
-
189  , trngPosn(0)
-
190 {
-
191 }
-
192 
-
196 RNGClass::~RNGClass()
-
197 {
-
198 #if defined(RNG_DUE_TRNG)
-
199  // Disable the TRNG in the Arduino Due.
-
200  REG_TRNG_CR = TRNG_CR_KEY(0x524E47);
-
201 #endif
-
202  clean(block);
-
203  clean(stream);
-
204 }
-
205 
-
206 #if defined(RNG_DUE_TRNG)
-
207 
-
208 // Find the flash memory of interest. Allow for the possibility
-
209 // of other SAM-based Arduino variants in the future.
-
210 #if defined(IFLASH1_ADDR)
-
211 #define RNG_FLASH_ADDR IFLASH1_ADDR
-
212 #define RNG_FLASH_SIZE IFLASH1_SIZE
-
213 #define RNG_FLASH_PAGE_SIZE IFLASH1_PAGE_SIZE
-
214 #define RNG_EFC EFC1
-
215 #elif defined(IFLASH0_ADDR)
-
216 #define RNG_FLASH_ADDR IFLASH0_ADDR
-
217 #define RNG_FLASH_SIZE IFLASH0_SIZE
-
218 #define RNG_FLASH_PAGE_SIZE IFLASH0_PAGE_SIZE
-
219 #define RNG_EFC EFC0
-
220 #else
-
221 #define RNG_FLASH_ADDR IFLASH_ADDR
-
222 #define RNG_FLASH_SIZE IFLASH_SIZE
-
223 #define RNG_FLASH_PAGE_SIZE IFLASH_PAGE_SIZE
-
224 #define RNG_EFC EFC
-
225 #endif
-
226 
-
227 // Address of the flash page to use for saving the seed on the Due.
-
228 // All SAM variants have a page size of 256 bytes or greater so there is
-
229 // plenty of room for the 48 byte seed in the last page of flash memory.
-
230 #define RNG_SEED_ADDR (RNG_FLASH_ADDR + RNG_FLASH_SIZE - RNG_FLASH_PAGE_SIZE)
-
231 #define RNG_SEED_PAGE ((RNG_FLASH_SIZE / RNG_FLASH_PAGE_SIZE) - 1)
-
232 
-
233 // Stir in the unique identifier for the Arduino Due's CPU.
-
234 // This function must be in RAM because programs running out of
-
235 // flash memory are not allowed to access the unique identifier.
-
236 // Info from: http://forum.arduino.cc/index.php?topic=289190.0
-
237 __attribute__((section(".ramfunc")))
-
238 static void stirUniqueIdentifier(void)
-
239 {
-
240  uint32_t id[4];
-
241 
-
242  // Start Read Unique Identifier.
-
243  RNG_EFC->EEFC_FCR = (0x5A << 24) | EFC_FCMD_STUI;
-
244  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) != 0)
-
245  ; // do nothing until FRDY falls.
-
246 
-
247  // Read the identifier.
-
248  id[0] = *((const uint32_t *)RNG_FLASH_ADDR);
-
249  id[1] = *((const uint32_t *)(RNG_FLASH_ADDR + 4));
-
250  id[2] = *((const uint32_t *)(RNG_FLASH_ADDR + 8));
-
251  id[3] = *((const uint32_t *)(RNG_FLASH_ADDR + 12));
-
252 
-
253  // Stop Read Unique Identifier.
-
254  RNG_EFC->EEFC_FCR = (0x5A << 24) | EFC_FCMD_SPUI;
-
255  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) == 0)
-
256  ; // do nothing until FRDY rises.
+
33 #elif defined(__AVR__)
+
34 #define RNG_EEPROM 1 // Use EEPROM to save the seed.
+
35 #define RNG_WATCHDOG 1 // Harvest entropy from watchdog jitter.
+
36 #include <avr/eeprom.h>
+
37 #include <avr/wdt.h>
+
38 #endif
+
39 #include <string.h>
+
40 
+
134 RNGClass RNG;
+
135 
+
141 // Number of ChaCha hash rounds to use for random number generation.
+
142 #define RNG_ROUNDS 20
+
143 
+
144 // Force a rekey after this many blocks of random data.
+
145 #define RNG_REKEY_BLOCKS 16
+
146 
+
147 // Maximum entropy credit that can be contained in the pool.
+
148 #define RNG_MAX_CREDITS 384
+
149 
+
152 // Tag for 256-bit ChaCha20 keys. This will always appear in the
+
153 // first 16 bytes of the block. The remaining 48 bytes are the seed.
+
154 static const char tagRNG[16] PROGMEM = {
+
155  'e', 'x', 'p', 'a', 'n', 'd', ' ', '3',
+
156  '2', '-', 'b', 'y', 't', 'e', ' ', 'k'
+
157 };
+
158 
+
159 // Initialization seed. This is the ChaCha20 output of hashing
+
160 // "expand 32-byte k" followed by 48 bytes set to the numbers 1 to 48.
+
161 // The ChaCha20 output block is then truncated to the first 48 bytes.
+
162 //
+
163 // This value is intended to start the RNG in a semi-chaotic state if
+
164 // we don't have a previously saved seed in EEPROM.
+
165 static const uint8_t initRNG[48] PROGMEM = {
+
166  0xB0, 0x2A, 0xAE, 0x7D, 0xEE, 0xCB, 0xBB, 0xB1,
+
167  0xFC, 0x03, 0x6F, 0xDD, 0xDC, 0x7D, 0x76, 0x67,
+
168  0x0C, 0xE8, 0x1F, 0x0D, 0xA3, 0xA0, 0xAA, 0x1E,
+
169  0xB0, 0xBD, 0x72, 0x6B, 0x2B, 0x4C, 0x8A, 0x7E,
+
170  0x34, 0xFC, 0x37, 0x60, 0xF4, 0x1E, 0x22, 0xA0,
+
171  0x0B, 0xFB, 0x18, 0x84, 0x60, 0xA5, 0x77, 0x72
+
172 };
+
173 
+
174 #if defined(RNG_WATCHDOG)
+
175 
+
176 // Use jitter between the watchdog timer and the main CPU clock to
+
177 // harvest some entropy on AVR-based systems. This technique comes from:
+
178 //
+
179 // https://sites.google.com/site/astudyofentropy/project-definition/timer-jitter-entropy-sources/entropy-library
+
180 //
+
181 // The watchdog generates entropy very slowly - it can take around 32 seconds
+
182 // to generate 256 bits of entropy credit. This is a "better than nothing"
+
183 // entropy source but a real noise source is definitely recommended.
+
184 
+
185 // Helper macros for specific 32-bit shift counts.
+
186 #define leftShift3(value) ((value) << 3)
+
187 #define leftShift10(value) ((value) << 10)
+
188 #define leftShift15(value) ((value) << 15)
+
189 #define rightShift6(value) ((value) >> 6)
+
190 #define rightShift11(value) ((value) >> 11)
+
191 
+
192 static uint32_t volatile hash = 0;
+
193 static uint8_t volatile outBits = 0;
+
194 
+
195 // Watchdog interrupt handler. This fires off every 16ms. We collect
+
196 // 32 bits and then pass them off onto RNGClass::loop().
+
197 ISR(WDT_vect)
+
198 {
+
199  // Read the low byte of Timer 1. We assume that the timer was
+
200  // initialized by the Arduino startup code for PWM use or that the
+
201  // application is free-running Timer 1 for its own purposes.
+
202  // Timer 0 is used on systems that don't have a Timer 1.
+
203 #if defined(TCNT1L)
+
204  unsigned char value = TCNT1L;
+
205 #elif defined(TCNT0L)
+
206  unsigned char value = TCNT0L;
+
207 #else
+
208  unsigned char value = TCNT0;
+
209 #endif
+
210  // Use Jenkin's one-at-a-time hash function to scatter the entropy a bit.
+
211  // https://en.wikipedia.org/wiki/Jenkins_hash_function
+
212  hash += value;
+
213  hash += leftShift10(hash);
+
214  hash ^= rightShift6(hash);
+
215  ++outBits;
+
216 }
+
217 
+
218 #endif // RNG_WATCHDOG
+
219 
+
230 RNGClass::RNGClass()
+
231  : address(0)
+
232  , credits(0)
+
233  , firstSave(1)
+
234  , timer(0)
+
235  , timeout(3600000UL) // 1 hour in milliseconds
+
236  , count(0)
+
237  , trngPosn(0)
+
238 {
+
239 }
+
240 
+
244 RNGClass::~RNGClass()
+
245 {
+
246 #if defined(RNG_DUE_TRNG)
+
247  // Disable the TRNG in the Arduino Due.
+
248  REG_TRNG_CR = TRNG_CR_KEY(0x524E47);
+
249 #endif
+
250 #if defined(RNG_WATCHDOG)
+
251  // Disable interrupts and reset the watchdog.
+
252  cli();
+
253  wdt_reset();
+
254 
+
255  // Clear the "reset due to watchdog" flag.
+
256  MCUSR &= ~(1 << WDRF);
257 
-
258  // Stir the unique identifier into the entropy pool.
-
259  RNG.stir((uint8_t *)id, sizeof(id));
-
260 }
+
258  // Disable the watchdog.
+
259  _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
+
260  _WD_CONTROL_REG = 0;
261 
-
262 // Erases the flash page containing the seed and then writes the new seed.
-
263 // It is assumed the seed has already been loaded into the latch registers.
-
264 __attribute__((section(".ramfunc")))
-
265 static void eraseAndWriteSeed()
-
266 {
-
267  // Execute the "Erase and Write Page" command.
-
268  RNG_EFC->EEFC_FCR = (0x5A << 24) | (RNG_SEED_PAGE << 8) | EFC_FCMD_EWP;
-
269 
-
270  // Wait for the FRDY bit to be raised.
-
271  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) == 0)
-
272  ; // do nothing until FRDY rises.
-
273 }
-
274 
-
275 #endif
-
276 
-
296 void RNGClass::begin(const char *tag, int eepromAddress)
-
297 {
-
298  // Save the EEPROM address for use by save().
-
299  address = eepromAddress;
-
300 
-
301  // Initialize the ChaCha20 input block from the saved seed.
-
302  memcpy_P(block, tagRNG, sizeof(tagRNG));
-
303  memcpy_P(block + 4, initRNG, sizeof(initRNG));
-
304 #if defined(RNG_EEPROM)
-
305  if (eeprom_read_byte((const uint8_t *)address) == 'S') {
-
306  // We have a saved seed: XOR it with the initialization block.
-
307  for (int posn = 0; posn < 12; ++posn) {
-
308  block[posn + 4] ^=
-
309  eeprom_read_dword((const uint32_t *)(address + posn * 4 + 1));
-
310  }
-
311  }
-
312 #elif defined(RNG_DUE_TRNG)
-
313  // Do we have a seed saved in the last page of flash memory on the Due?
-
314  int posn, counter;
-
315  if (((const uint32_t *)RNG_SEED_ADDR)[0] == 'S') {
-
316  // XOR the saved seed with the initialization block.
-
317  for (posn = 0; posn < 12; ++posn)
-
318  block[posn + 4] ^= ((const uint32_t *)RNG_SEED_ADDR)[posn + 1];
-
319  }
+
262  // Re-enable interrupts. The watchdog should be stopped.
+
263  sei();
+
264 #endif
+
265  clean(block);
+
266  clean(stream);
+
267 }
+
268 
+
269 #if defined(RNG_DUE_TRNG)
+
270 
+
271 // Find the flash memory of interest. Allow for the possibility
+
272 // of other SAM-based Arduino variants in the future.
+
273 #if defined(IFLASH1_ADDR)
+
274 #define RNG_FLASH_ADDR IFLASH1_ADDR
+
275 #define RNG_FLASH_SIZE IFLASH1_SIZE
+
276 #define RNG_FLASH_PAGE_SIZE IFLASH1_PAGE_SIZE
+
277 #define RNG_EFC EFC1
+
278 #elif defined(IFLASH0_ADDR)
+
279 #define RNG_FLASH_ADDR IFLASH0_ADDR
+
280 #define RNG_FLASH_SIZE IFLASH0_SIZE
+
281 #define RNG_FLASH_PAGE_SIZE IFLASH0_PAGE_SIZE
+
282 #define RNG_EFC EFC0
+
283 #else
+
284 #define RNG_FLASH_ADDR IFLASH_ADDR
+
285 #define RNG_FLASH_SIZE IFLASH_SIZE
+
286 #define RNG_FLASH_PAGE_SIZE IFLASH_PAGE_SIZE
+
287 #define RNG_EFC EFC
+
288 #endif
+
289 
+
290 // Address of the flash page to use for saving the seed on the Due.
+
291 // All SAM variants have a page size of 256 bytes or greater so there is
+
292 // plenty of room for the 48 byte seed in the last page of flash memory.
+
293 #define RNG_SEED_ADDR (RNG_FLASH_ADDR + RNG_FLASH_SIZE - RNG_FLASH_PAGE_SIZE)
+
294 #define RNG_SEED_PAGE ((RNG_FLASH_SIZE / RNG_FLASH_PAGE_SIZE) - 1)
+
295 
+
296 // Stir in the unique identifier for the Arduino Due's CPU.
+
297 // This function must be in RAM because programs running out of
+
298 // flash memory are not allowed to access the unique identifier.
+
299 // Info from: http://forum.arduino.cc/index.php?topic=289190.0
+
300 __attribute__((section(".ramfunc")))
+
301 static void stirUniqueIdentifier(void)
+
302 {
+
303  uint32_t id[4];
+
304 
+
305  // Start Read Unique Identifier.
+
306  RNG_EFC->EEFC_FCR = (0x5A << 24) | EFC_FCMD_STUI;
+
307  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) != 0)
+
308  ; // do nothing until FRDY falls.
+
309 
+
310  // Read the identifier.
+
311  id[0] = *((const uint32_t *)RNG_FLASH_ADDR);
+
312  id[1] = *((const uint32_t *)(RNG_FLASH_ADDR + 4));
+
313  id[2] = *((const uint32_t *)(RNG_FLASH_ADDR + 8));
+
314  id[3] = *((const uint32_t *)(RNG_FLASH_ADDR + 12));
+
315 
+
316  // Stop Read Unique Identifier.
+
317  RNG_EFC->EEFC_FCR = (0x5A << 24) | EFC_FCMD_SPUI;
+
318  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) == 0)
+
319  ; // do nothing until FRDY rises.
320 
-
321  // If the device has just been reprogrammed, there will be no saved seed.
-
322  // XOR the initialization block with some output from the CPU's TRNG
-
323  // to permute the state in a first boot situation after reprogramming.
-
324  pmc_enable_periph_clk(ID_TRNG);
-
325  REG_TRNG_CR = TRNG_CR_KEY(0x524E47) | TRNG_CR_ENABLE;
-
326  REG_TRNG_IDR = TRNG_IDR_DATRDY; // Disable interrupts - we will poll.
-
327  for (posn = 0; posn < 12; ++posn) {
-
328  // According to the documentation the TRNG should produce a new
-
329  // 32-bit random value every 84 clock cycles. If it still hasn't
-
330  // produced a value after 200 iterations, then assume that the
-
331  // TRNG is not producing output and stop.
-
332  for (counter = 0; counter < 200; ++counter) {
-
333  if ((REG_TRNG_ISR & TRNG_ISR_DATRDY) != 0)
-
334  break;
-
335  }
-
336  if (counter >= 200)
-
337  break;
-
338  block[posn + 4] ^= REG_TRNG_ODATA;
-
339  }
-
340 #endif
-
341 
-
342  // No entropy credits for the saved seed.
-
343  credits = 0;
-
344 
-
345  // Trigger an automatic save once the entropy credits max out.
-
346  firstSave = 1;
-
347 
-
348  // Rekey the random number generator immediately.
-
349  rekey();
-
350 
-
351  // Stir in the supplied tag data but don't credit any entropy to it.
-
352  if (tag)
-
353  stir((const uint8_t *)tag, strlen(tag));
-
354 
-
355 #if defined(RNG_DUE_TRNG)
-
356  // Stir in the unique identifier for the CPU so that different
-
357  // devices will give different outputs even without seeding.
-
358  stirUniqueIdentifier();
-
359 #endif
-
360 
-
361  // Re-save the seed to obliterate the previous value and to ensure
-
362  // that if the system is reset without a call to save() that we won't
-
363  // accidentally generate the same sequence of random data again.
-
364  save();
-
365 }
-
366 
-
379 void RNGClass::addNoiseSource(NoiseSource &source)
-
380 {
-
381  #define MAX_NOISE_SOURCES (sizeof(noiseSources) / sizeof(noiseSources[0]))
-
382  if (count < MAX_NOISE_SOURCES) {
-
383  noiseSources[count++] = &source;
-
384  source.added();
-
385  }
-
386 }
-
387 
-
404 void RNGClass::setAutoSaveTime(uint16_t minutes)
-
405 {
-
406  if (!minutes)
-
407  minutes = 1; // Just in case.
-
408  timeout = ((uint32_t)minutes) * 60000U;
-
409 }
+
321  // Stir the unique identifier into the entropy pool.
+
322  RNG.stir((uint8_t *)id, sizeof(id));
+
323 }
+
324 
+
325 // Erases the flash page containing the seed and then writes the new seed.
+
326 // It is assumed the seed has already been loaded into the latch registers.
+
327 __attribute__((section(".ramfunc")))
+
328 static void eraseAndWriteSeed()
+
329 {
+
330  // Execute the "Erase and Write Page" command.
+
331  RNG_EFC->EEFC_FCR = (0x5A << 24) | (RNG_SEED_PAGE << 8) | EFC_FCMD_EWP;
+
332 
+
333  // Wait for the FRDY bit to be raised.
+
334  while ((RNG_EFC->EEFC_FSR & EEFC_FSR_FRDY) == 0)
+
335  ; // do nothing until FRDY rises.
+
336 }
+
337 
+
338 #endif
+
339 
+
359 void RNGClass::begin(const char *tag, int eepromAddress)
+
360 {
+
361  // Save the EEPROM address for use by save().
+
362  address = eepromAddress;
+
363 
+
364  // Initialize the ChaCha20 input block from the saved seed.
+
365  memcpy_P(block, tagRNG, sizeof(tagRNG));
+
366  memcpy_P(block + 4, initRNG, sizeof(initRNG));
+
367 #if defined(RNG_EEPROM)
+
368  if (eeprom_read_byte((const uint8_t *)address) == 'S') {
+
369  // We have a saved seed: XOR it with the initialization block.
+
370  for (int posn = 0; posn < 12; ++posn) {
+
371  block[posn + 4] ^=
+
372  eeprom_read_dword((const uint32_t *)(address + posn * 4 + 1));
+
373  }
+
374  }
+
375 #elif defined(RNG_DUE_TRNG)
+
376  // Do we have a seed saved in the last page of flash memory on the Due?
+
377  int posn, counter;
+
378  if (((const uint32_t *)RNG_SEED_ADDR)[0] == 'S') {
+
379  // XOR the saved seed with the initialization block.
+
380  for (posn = 0; posn < 12; ++posn)
+
381  block[posn + 4] ^= ((const uint32_t *)RNG_SEED_ADDR)[posn + 1];
+
382  }
+
383 
+
384  // If the device has just been reprogrammed, there will be no saved seed.
+
385  // XOR the initialization block with some output from the CPU's TRNG
+
386  // to permute the state in a first boot situation after reprogramming.
+
387  pmc_enable_periph_clk(ID_TRNG);
+
388  REG_TRNG_CR = TRNG_CR_KEY(0x524E47) | TRNG_CR_ENABLE;
+
389  REG_TRNG_IDR = TRNG_IDR_DATRDY; // Disable interrupts - we will poll.
+
390  for (posn = 0; posn < 12; ++posn) {
+
391  // According to the documentation the TRNG should produce a new
+
392  // 32-bit random value every 84 clock cycles. If it still hasn't
+
393  // produced a value after 200 iterations, then assume that the
+
394  // TRNG is not producing output and stop.
+
395  for (counter = 0; counter < 200; ++counter) {
+
396  if ((REG_TRNG_ISR & TRNG_ISR_DATRDY) != 0)
+
397  break;
+
398  }
+
399  if (counter >= 200)
+
400  break;
+
401  block[posn + 4] ^= REG_TRNG_ODATA;
+
402  }
+
403 #endif
+
404 
+
405  // No entropy credits for the saved seed.
+
406  credits = 0;
+
407 
+
408  // Trigger an automatic save once the entropy credits max out.
+
409  firstSave = 1;
410 
-
428 void RNGClass::rand(uint8_t *data, size_t len)
-
429 {
-
430  // Decrease the amount of entropy in the pool.
-
431  if (len > (credits / 8))
-
432  credits = 0;
-
433  else
-
434  credits -= len * 8;
-
435 
-
436  // Generate the random data.
-
437  uint8_t count = 0;
-
438  while (len > 0) {
-
439  // Force a rekey if we have generated too many blocks in this request.
-
440  if (count >= RNG_REKEY_BLOCKS) {
-
441  rekey();
-
442  count = 1;
-
443  } else {
-
444  ++count;
-
445  }
+
411  // Rekey the random number generator immediately.
+
412  rekey();
+
413 
+
414  // Stir in the supplied tag data but don't credit any entropy to it.
+
415  if (tag)
+
416  stir((const uint8_t *)tag, strlen(tag));
+
417 
+
418 #if defined(RNG_DUE_TRNG)
+
419  // Stir in the unique identifier for the CPU so that different
+
420  // devices will give different outputs even without seeding.
+
421  stirUniqueIdentifier();
+
422 #endif
+
423 
+
424 #if defined(RNG_WATCHDOG)
+
425  // Disable interrupts and reset the watchdog.
+
426  cli();
+
427  wdt_reset();
+
428 
+
429  // Clear the "reset due to watchdog" flag.
+
430  MCUSR &= ~(1 << WDRF);
+
431 
+
432  // Enable the watchdog with the smallest duration (16ms)
+
433  // and interrupt-only mode.
+
434  _WD_CONTROL_REG |= (1 << _WD_CHANGE_BIT) | (1 << WDE);
+
435  _WD_CONTROL_REG = (1 << WDIE);
+
436 
+
437  // Re-enable interrupts. The watchdog should be running.
+
438  sei();
+
439 #endif
+
440 
+
441  // Re-save the seed to obliterate the previous value and to ensure
+
442  // that if the system is reset without a call to save() that we won't
+
443  // accidentally generate the same sequence of random data again.
+
444  save();
+
445 }
446 
-
447  // Increment the low counter word and generate a new keystream block.
-
448  ++(block[12]);
-
449  ChaCha::hashCore(stream, block, RNG_ROUNDS);
-
450 
-
451  // Copy the data to the return buffer.
-
452  if (len < 64) {
-
453  memcpy(data, stream, len);
-
454  break;
-
455  } else {
-
456  memcpy(data, stream, 64);
-
457  data += 64;
-
458  len -= 64;
-
459  }
-
460  }
-
461 
-
462  // Force a rekey after every request.
-
463  rekey();
-
464 }
-
465 
-
505 bool RNGClass::available(size_t len) const
-
506 {
-
507  if (len >= (RNG_MAX_CREDITS / 8))
-
508  return credits >= RNG_MAX_CREDITS;
-
509  else
-
510  return len <= (credits / 8);
-
511 }
-
512 
-
538 void RNGClass::stir(const uint8_t *data, size_t len, unsigned int credit)
-
539 {
-
540  // Increase the entropy credit.
-
541  if ((credit / 8) >= len)
-
542  credit = len * 8;
-
543  if ((RNG_MAX_CREDITS - credits) > credit)
-
544  credits += credit;
-
545  else
-
546  credits = RNG_MAX_CREDITS;
-
547 
-
548  // Process the supplied input data.
-
549  if (len > 0) {
-
550  // XOR the data with the ChaCha input block in 48 byte
-
551  // chunks and rekey the ChaCha cipher for each chunk to mix
-
552  // the data in. This should scatter any "true entropy" in
-
553  // the input across the entire block.
-
554  while (len > 0) {
-
555  size_t templen = len;
-
556  if (templen > 48)
-
557  templen = 48;
-
558  uint8_t *output = ((uint8_t *)block) + 16;
-
559  len -= templen;
-
560  while (templen > 0) {
-
561  *output++ ^= *data++;
-
562  --templen;
-
563  }
-
564  rekey();
-
565  }
-
566  } else {
-
567  // There was no input data, so just force a rekey so we
-
568  // get some mixing of the state even without new data.
-
569  rekey();
-
570  }
-
571 
-
572  // Save if this is the first time we have reached max entropy.
-
573  // This provides some protection if the system is powered off before
-
574  // the first auto-save timeout occurs.
-
575  if (firstSave && credits >= RNG_MAX_CREDITS) {
-
576  firstSave = 0;
-
577  save();
-
578  }
-
579 }
-
580 
-
607 void RNGClass::save()
-
608 {
-
609  // Generate random data from the current state and save
-
610  // that as the seed. Then force a rekey.
-
611  ++(block[12]);
-
612  ChaCha::hashCore(stream, block, RNG_ROUNDS);
-
613 #if defined(RNG_EEPROM)
-
614  eeprom_write_block(stream, (void *)(address + 1), 48);
-
615  eeprom_update_byte((uint8_t *)address, 'S');
-
616 #elif defined(RNG_DUE_TRNG)
-
617  unsigned posn;
-
618  ((uint32_t *)(RNG_SEED_ADDR))[0] = 'S';
-
619  for (posn = 0; posn < 12; ++posn)
-
620  ((uint32_t *)(RNG_SEED_ADDR))[posn + 1] = stream[posn];
-
621  for (posn = 13; posn < (RNG_FLASH_PAGE_SIZE / 4); ++posn)
-
622  ((uint32_t *)(RNG_SEED_ADDR))[posn + 13] = 0xFFFFFFFF;
-
623  eraseAndWriteSeed();
-
624 #endif
-
625  rekey();
-
626  timer = millis();
-
627 }
-
628 
-
635 void RNGClass::loop()
-
636 {
-
637  // Stir in the entropy from all registered noise sources.
-
638  for (uint8_t posn = 0; posn < count; ++posn)
-
639  noiseSources[posn]->stir();
-
640 
-
641 #if defined(RNG_DUE_TRNG)
-
642  // If there is data available from the Arudino Due's TRNG, then XOR
-
643  // it with the state block and increase the entropy credit. We don't
-
644  // call stir() yet because that will seriously slow down the system
-
645  // given how fast the TRNG is. Instead we save up the XOR'ed TRNG
-
646  // data until the next rand() call and then hash it to generate the
-
647  // desired output.
-
648  //
-
649  // The CPU documentation claims that the TRNG output is very good so
-
650  // this should only make the pool more and more random as time goes on.
-
651  // However there is a risk that the CPU manufacturer was pressured by
-
652  // government or intelligence agencies to insert a back door that
-
653  // generates predictable output. Or the manufacturer was overly
-
654  // optimistic about their TRNG design and it is actually flawed in a
-
655  // way they don't realise.
-
656  //
-
657  // If you are concerned about such threats, then make sure to mix in
-
658  // data from other noise sources. By hashing together the TRNG with
-
659  // the other noise data, rand() should produce unpredictable data even
-
660  // if one of the sources is actually predictable.
-
661  if ((REG_TRNG_ISR & TRNG_ISR_DATRDY) != 0) {
-
662  block[4 + trngPosn] ^= REG_TRNG_ODATA;
-
663  if (++trngPosn >= 12)
-
664  trngPosn = 0;
-
665  if (credits < RNG_MAX_CREDITS) {
-
666  // Credit 1 bit of entropy for the word. The TRNG should be
-
667  // better than this but it is so fast that we want to collect
-
668  // up more data before passing it to the application.
-
669  ++credits;
-
670  }
-
671  }
-
672 #endif
-
673 
-
674  // Save the seed if the auto-save timer has expired.
-
675  if ((millis() - timer) >= timeout)
-
676  save();
-
677 }
-
678 
-
698 void RNGClass::destroy()
-
699 {
-
700  clean(block);
-
701  clean(stream);
-
702 #if defined(RNG_EEPROM)
-
703  for (int posn = 0; posn < SEED_SIZE; ++posn)
-
704  eeprom_write_byte((uint8_t *)(address + posn), 0xFF);
-
705 #elif defined(RNG_DUE_TRNG)
-
706  for (unsigned posn = 0; posn < (RNG_FLASH_PAGE_SIZE / 4); ++posn)
-
707  ((uint32_t *)(RNG_SEED_ADDR))[posn] = 0xFFFFFFFF;
-
708  eraseAndWriteSeed();
-
709 #endif
-
710 }
-
711 
-
715 void RNGClass::rekey()
+
459 void RNGClass::addNoiseSource(NoiseSource &source)
+
460 {
+
461  #define MAX_NOISE_SOURCES (sizeof(noiseSources) / sizeof(noiseSources[0]))
+
462  if (count < MAX_NOISE_SOURCES) {
+
463  noiseSources[count++] = &source;
+
464  source.added();
+
465  }
+
466 }
+
467 
+
484 void RNGClass::setAutoSaveTime(uint16_t minutes)
+
485 {
+
486  if (!minutes)
+
487  minutes = 1; // Just in case.
+
488  timeout = ((uint32_t)minutes) * 60000U;
+
489 }
+
490 
+
508 void RNGClass::rand(uint8_t *data, size_t len)
+
509 {
+
510  // Decrease the amount of entropy in the pool.
+
511  if (len > (credits / 8))
+
512  credits = 0;
+
513  else
+
514  credits -= len * 8;
+
515 
+
516  // Generate the random data.
+
517  uint8_t count = 0;
+
518  while (len > 0) {
+
519  // Force a rekey if we have generated too many blocks in this request.
+
520  if (count >= RNG_REKEY_BLOCKS) {
+
521  rekey();
+
522  count = 1;
+
523  } else {
+
524  ++count;
+
525  }
+
526 
+
527  // Increment the low counter word and generate a new keystream block.
+
528  ++(block[12]);
+
529  ChaCha::hashCore(stream, block, RNG_ROUNDS);
+
530 
+
531  // Copy the data to the return buffer.
+
532  if (len < 64) {
+
533  memcpy(data, stream, len);
+
534  break;
+
535  } else {
+
536  memcpy(data, stream, 64);
+
537  data += 64;
+
538  len -= 64;
+
539  }
+
540  }
+
541 
+
542  // Force a rekey after every request.
+
543  rekey();
+
544 }
+
545 
+
585 bool RNGClass::available(size_t len) const
+
586 {
+
587  if (len >= (RNG_MAX_CREDITS / 8))
+
588  return credits >= RNG_MAX_CREDITS;
+
589  else
+
590  return len <= (credits / 8);
+
591 }
+
592 
+
618 void RNGClass::stir(const uint8_t *data, size_t len, unsigned int credit)
+
619 {
+
620  // Increase the entropy credit.
+
621  if ((credit / 8) >= len && len)
+
622  credit = len * 8;
+
623  if ((RNG_MAX_CREDITS - credits) > credit)
+
624  credits += credit;
+
625  else
+
626  credits = RNG_MAX_CREDITS;
+
627 
+
628  // Process the supplied input data.
+
629  if (len > 0) {
+
630  // XOR the data with the ChaCha input block in 48 byte
+
631  // chunks and rekey the ChaCha cipher for each chunk to mix
+
632  // the data in. This should scatter any "true entropy" in
+
633  // the input across the entire block.
+
634  while (len > 0) {
+
635  size_t templen = len;
+
636  if (templen > 48)
+
637  templen = 48;
+
638  uint8_t *output = ((uint8_t *)block) + 16;
+
639  len -= templen;
+
640  while (templen > 0) {
+
641  *output++ ^= *data++;
+
642  --templen;
+
643  }
+
644  rekey();
+
645  }
+
646  } else {
+
647  // There was no input data, so just force a rekey so we
+
648  // get some mixing of the state even without new data.
+
649  rekey();
+
650  }
+
651 
+
652  // Save if this is the first time we have reached max entropy.
+
653  // This provides some protection if the system is powered off before
+
654  // the first auto-save timeout occurs.
+
655  if (firstSave && credits >= RNG_MAX_CREDITS) {
+
656  firstSave = 0;
+
657  save();
+
658  }
+
659 }
+
660 
+
687 void RNGClass::save()
+
688 {
+
689  // Generate random data from the current state and save
+
690  // that as the seed. Then force a rekey.
+
691  ++(block[12]);
+
692  ChaCha::hashCore(stream, block, RNG_ROUNDS);
+
693 #if defined(RNG_EEPROM)
+
694  eeprom_write_block(stream, (void *)(address + 1), 48);
+
695  eeprom_update_byte((uint8_t *)address, 'S');
+
696 #elif defined(RNG_DUE_TRNG)
+
697  unsigned posn;
+
698  ((uint32_t *)(RNG_SEED_ADDR))[0] = 'S';
+
699  for (posn = 0; posn < 12; ++posn)
+
700  ((uint32_t *)(RNG_SEED_ADDR))[posn + 1] = stream[posn];
+
701  for (posn = 13; posn < (RNG_FLASH_PAGE_SIZE / 4); ++posn)
+
702  ((uint32_t *)(RNG_SEED_ADDR))[posn + 13] = 0xFFFFFFFF;
+
703  eraseAndWriteSeed();
+
704 #endif
+
705  rekey();
+
706  timer = millis();
+
707 }
+
708 
+
715 void RNGClass::loop()
716 {
-
717  // Rekey the cipher for the next request by generating a new block.
-
718  // This is intended to make it difficult to wind the random number
-
719  // backwards if the state is captured later. The first 16 bytes of
-
720  // "block" remain set to "tagRNG".
-
721  ++(block[12]);
-
722  ChaCha::hashCore(stream, block, RNG_ROUNDS);
-
723  memcpy(block + 4, stream, 48);
-
724 
-
725  // Permute the high word of the counter using the system microsecond
-
726  // counter to introduce a little bit of non-stir randomness for each
-
727  // request. Note: If random data is requested on a predictable schedule
-
728  // then this may not help very much. It is still necessary to stir in
-
729  // high quality entropy data on a regular basis using stir().
-
730  block[13] ^= micros();
-
731 }
-
RNGClass::save
void save()
Saves the random seed to EEPROM.
Definition: RNG.cpp:607
-
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:428
-
RNGClass::begin
void begin(const char *tag, int eepromAddress)
Initializes the random number generator.
Definition: RNG.cpp:296
+
717  // Stir in the entropy from all registered noise sources.
+
718  for (uint8_t posn = 0; posn < count; ++posn)
+
719  noiseSources[posn]->stir();
+
720 
+
721 #if defined(RNG_DUE_TRNG)
+
722  // If there is data available from the Arudino Due's TRNG, then XOR
+
723  // it with the state block and increase the entropy credit. We don't
+
724  // call stir() yet because that will seriously slow down the system
+
725  // given how fast the TRNG is. Instead we save up the XOR'ed TRNG
+
726  // data until the next rand() call and then hash it to generate the
+
727  // desired output.
+
728  //
+
729  // The CPU documentation claims that the TRNG output is very good so
+
730  // this should only make the pool more and more random as time goes on.
+
731  // However there is a risk that the CPU manufacturer was pressured by
+
732  // government or intelligence agencies to insert a back door that
+
733  // generates predictable output. Or the manufacturer was overly
+
734  // optimistic about their TRNG design and it is actually flawed in a
+
735  // way they don't realise.
+
736  //
+
737  // If you are concerned about such threats, then make sure to mix in
+
738  // data from other noise sources. By hashing together the TRNG with
+
739  // the other noise data, rand() should produce unpredictable data even
+
740  // if one of the sources is actually predictable.
+
741  if ((REG_TRNG_ISR & TRNG_ISR_DATRDY) != 0) {
+
742  block[4 + trngPosn] ^= REG_TRNG_ODATA;
+
743  if (++trngPosn >= 12)
+
744  trngPosn = 0;
+
745  if (credits < RNG_MAX_CREDITS) {
+
746  // Credit 1 bit of entropy for the word. The TRNG should be
+
747  // better than this but it is so fast that we want to collect
+
748  // up more data before passing it to the application.
+
749  ++credits;
+
750  }
+
751  }
+
752 #elif defined(RNG_WATCHDOG)
+
753  // Read the 32 bit buffer from the WDT interrupt.
+
754  cli();
+
755  if (outBits >= 32) {
+
756  uint32_t value = hash;
+
757  hash = 0;
+
758  outBits = 0;
+
759  sei();
+
760 
+
761  // Final steps of the Jenkin's one-at-a-time hash function.
+
762  // https://en.wikipedia.org/wiki/Jenkins_hash_function
+
763  value += leftShift3(value);
+
764  value ^= rightShift11(value);
+
765  value += leftShift15(value);
+
766 
+
767  // XOR the word with the state. Stir once we accumulate 48 bytes,
+
768  // which happens about once every 6.4 seconds.
+
769  block[4 + trngPosn] ^= value;
+
770  if (++trngPosn >= 12) {
+
771  trngPosn = 0;
+
772 
+
773  // Credit 1 bit of entropy for each byte of input. It can take
+
774  // between 30 and 40 seconds to accumulate 256 bits of credit.
+
775  stir(0, 0, 48);
+
776  }
+
777  } else {
+
778  sei();
+
779  }
+
780 #endif
+
781 
+
782  // Save the seed if the auto-save timer has expired.
+
783  if ((millis() - timer) >= timeout)
+
784  save();
+
785 }
+
786 
+
806 void RNGClass::destroy()
+
807 {
+
808  clean(block);
+
809  clean(stream);
+
810 #if defined(RNG_EEPROM)
+
811  for (int posn = 0; posn < SEED_SIZE; ++posn)
+
812  eeprom_write_byte((uint8_t *)(address + posn), 0xFF);
+
813 #elif defined(RNG_DUE_TRNG)
+
814  for (unsigned posn = 0; posn < (RNG_FLASH_PAGE_SIZE / 4); ++posn)
+
815  ((uint32_t *)(RNG_SEED_ADDR))[posn] = 0xFFFFFFFF;
+
816  eraseAndWriteSeed();
+
817 #endif
+
818 }
+
819 
+
823 void RNGClass::rekey()
+
824 {
+
825  // Rekey the cipher for the next request by generating a new block.
+
826  // This is intended to make it difficult to wind the random number
+
827  // backwards if the state is captured later. The first 16 bytes of
+
828  // "block" remain set to "tagRNG".
+
829  ++(block[12]);
+
830  ChaCha::hashCore(stream, block, RNG_ROUNDS);
+
831  memcpy(block + 4, stream, 48);
+
832 
+
833  // Permute the high word of the counter using the system microsecond
+
834  // counter to introduce a little bit of non-stir randomness for each
+
835  // request. Note: If random data is requested on a predictable schedule
+
836  // then this may not help very much. It is still necessary to stir in
+
837  // high quality entropy data on a regular basis using stir().
+
838  block[13] ^= micros();
+
839 }
+
RNGClass::save
void save()
Saves the random seed to EEPROM.
Definition: RNG.cpp:687
+
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
+
RNGClass::begin
void begin(const char *tag, int eepromAddress)
Initializes the random number generator.
Definition: RNG.cpp:359
NoiseSource
Abstract base class for random noise sources.
Definition: NoiseSource.h:29
-
RNGClass::~RNGClass
~RNGClass()
Destroys this random number generator instance.
Definition: RNG.cpp:196
+
RNGClass::~RNGClass
~RNGClass()
Destroys this random number generator instance.
Definition: RNG.cpp:244
NoiseSource::added
virtual void added()
Called when the noise source is added to RNG with RNG.addNoiseSource().
Definition: NoiseSource.cpp:95
-
RNGClass::addNoiseSource
void addNoiseSource(NoiseSource &source)
Adds a noise source to the random number generator.
Definition: RNG.cpp:379
-
RNGClass::RNGClass
RNGClass()
Constructs a new random number generator instance.
Definition: RNG.cpp:182
-
RNGClass::destroy
void destroy()
Destroys the data in the random number pool and the saved seed in EEPROM.
Definition: RNG.cpp:698
-
RNGClass::available
bool available(size_t len) const
Determine if there is sufficient entropy available for a specific request size.
Definition: RNG.cpp:505
-
RNGClass::loop
void loop()
Run periodic housekeeping tasks on the random number generator.
Definition: RNG.cpp:635
+
RNGClass::addNoiseSource
void addNoiseSource(NoiseSource &source)
Adds a noise source to the random number generator.
Definition: RNG.cpp:459
+
RNGClass::RNGClass
RNGClass()
Constructs a new random number generator instance.
Definition: RNG.cpp:230
+
RNGClass::destroy
void destroy()
Destroys the data in the random number pool and the saved seed in EEPROM.
Definition: RNG.cpp:806
+
RNGClass::available
bool available(size_t len) const
Determine if there is sufficient entropy available for a specific request size.
Definition: RNG.cpp:585
+
RNGClass::loop
void loop()
Run periodic housekeeping tasks on the random number generator.
Definition: RNG.cpp:715
RNGClass
Pseudo random number generator suitable for cryptography.
Definition: RNG.h:31
RNGClass::SEED_SIZE
static const int SEED_SIZE
Size of a saved random number seed in EEPROM space.
Definition: RNG.h:53
ChaCha::hashCore
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
-
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:538
-
RNGClass::setAutoSaveTime
void setAutoSaveTime(uint16_t minutes)
Sets the amount of time between automatic seed saves.
Definition: RNG.cpp:404
+
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:618
+
RNGClass::setAutoSaveTime
void setAutoSaveTime(uint16_t minutes)
Sets the amount of time between automatic seed saves.
Definition: RNG.cpp:484
diff --git a/RNG_8h_source.html b/RNG_8h_source.html index 9c0fd91e..54513a46 100644 --- a/RNG_8h_source.html +++ b/RNG_8h_source.html @@ -160,24 +160,24 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
70 extern RNGClass RNG;
71 
72 #endif
-
RNGClass::save
void save()
Saves the random seed to EEPROM.
Definition: RNG.cpp:607
-
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:428
-
RNGClass::begin
void begin(const char *tag, int eepromAddress)
Initializes the random number generator.
Definition: RNG.cpp:296
+
RNGClass::save
void save()
Saves the random seed to EEPROM.
Definition: RNG.cpp:687
+
RNGClass::rand
void rand(uint8_t *data, size_t len)
Generates random bytes into a caller-supplied buffer.
Definition: RNG.cpp:508
+
RNGClass::begin
void begin(const char *tag, int eepromAddress)
Initializes the random number generator.
Definition: RNG.cpp:359
NoiseSource
Abstract base class for random noise sources.
Definition: NoiseSource.h:29
-
RNGClass::~RNGClass
~RNGClass()
Destroys this random number generator instance.
Definition: RNG.cpp:196
-
RNGClass::addNoiseSource
void addNoiseSource(NoiseSource &source)
Adds a noise source to the random number generator.
Definition: RNG.cpp:379
-
RNGClass::RNGClass
RNGClass()
Constructs a new random number generator instance.
Definition: RNG.cpp:182
-
RNGClass::destroy
void destroy()
Destroys the data in the random number pool and the saved seed in EEPROM.
Definition: RNG.cpp:698
-
RNGClass::available
bool available(size_t len) const
Determine if there is sufficient entropy available for a specific request size.
Definition: RNG.cpp:505
-
RNGClass::loop
void loop()
Run periodic housekeeping tasks on the random number generator.
Definition: RNG.cpp:635
+
RNGClass::~RNGClass
~RNGClass()
Destroys this random number generator instance.
Definition: RNG.cpp:244
+
RNGClass::addNoiseSource
void addNoiseSource(NoiseSource &source)
Adds a noise source to the random number generator.
Definition: RNG.cpp:459
+
RNGClass::RNGClass
RNGClass()
Constructs a new random number generator instance.
Definition: RNG.cpp:230
+
RNGClass::destroy
void destroy()
Destroys the data in the random number pool and the saved seed in EEPROM.
Definition: RNG.cpp:806
+
RNGClass::available
bool available(size_t len) const
Determine if there is sufficient entropy available for a specific request size.
Definition: RNG.cpp:585
+
RNGClass::loop
void loop()
Run periodic housekeeping tasks on the random number generator.
Definition: RNG.cpp:715
RNGClass
Pseudo random number generator suitable for cryptography.
Definition: RNG.h:31
RNGClass::SEED_SIZE
static const int SEED_SIZE
Size of a saved random number seed in EEPROM space.
Definition: RNG.h:53
-
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:538
-
RNGClass::setAutoSaveTime
void setAutoSaveTime(uint16_t minutes)
Sets the amount of time between automatic seed saves.
Definition: RNG.cpp:404
+
RNGClass::stir
void stir(const uint8_t *data, size_t len, unsigned int credit=0)
Stirs additional entropy data into the random pool.
Definition: RNG.cpp:618
+
RNGClass::setAutoSaveTime
void setAutoSaveTime(uint16_t minutes)
Sets the amount of time between automatic seed saves.
Definition: RNG.cpp:484
diff --git a/RTC_8cpp_source.html b/RTC_8cpp_source.html index 25ac6a38..9f46861b 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 77ce3022..a0a0d8ac 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 61eca464..a0a2318e 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 b1257ef8..78d198d4 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/SHA1_8cpp_source.html b/SHA1_8cpp_source.html deleted file mode 100644 index 9ca9ab9a..00000000 --- a/SHA1_8cpp_source.html +++ /dev/null @@ -1,331 +0,0 @@ - - - - - - -ArduinoLibs: SHA1.cpp Source File - - - - - - - - - -
-
- - - - - - -
-
ArduinoLibs -
-
-
- - - - - - -
- All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
- - -
- -
- - -
-
-
-
SHA1.cpp
-
-
-
1 /*
-
2  * Copyright (C) 2015 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 "SHA1.h"
-
24 #include "Crypto.h"
-
25 #include "utility/RotateUtil.h"
-
26 #include "utility/EndianUtil.h"
-
27 #include <string.h>
-
28 
- -
42 {
-
43  reset();
-
44 }
-
45 
- -
50 {
-
51  clean(state);
-
52 }
-
53 
-
54 size_t SHA1::hashSize() const
-
55 {
-
56  return 20;
-
57 }
-
58 
-
59 size_t SHA1::blockSize() const
-
60 {
-
61  return 64;
-
62 }
-
63 
- -
65 {
-
66  state.h[0] = 0x67452301;
-
67  state.h[1] = 0xEFCDAB89;
-
68  state.h[2] = 0x98BADCFE;
-
69  state.h[3] = 0x10325476;
-
70  state.h[4] = 0xC3D2E1F0;
-
71  state.chunkSize = 0;
-
72  state.length = 0;
-
73 }
-
74 
-
75 void SHA1::update(const void *data, size_t len)
-
76 {
-
77  // Update the total length (in bits, not bytes).
-
78  state.length += ((uint64_t)len) << 3;
-
79 
-
80  // Break the input up into 512-bit chunks and process each in turn.
-
81  const uint8_t *d = (const uint8_t *)data;
-
82  while (len > 0) {
-
83  uint8_t size = 64 - state.chunkSize;
-
84  if (size > len)
-
85  size = len;
-
86  memcpy(((uint8_t *)state.w) + state.chunkSize, d, size);
-
87  state.chunkSize += size;
-
88  len -= size;
-
89  d += size;
-
90  if (state.chunkSize == 64) {
-
91  processChunk();
-
92  state.chunkSize = 0;
-
93  }
-
94  }
-
95 }
-
96 
-
97 void SHA1::finalize(void *hash, size_t len)
-
98 {
-
99  // Pad the last chunk. We may need two padding chunks if there
-
100  // isn't enough room in the first for the padding and length.
-
101  uint8_t *wbytes = (uint8_t *)state.w;
-
102  if (state.chunkSize <= (64 - 9)) {
-
103  wbytes[state.chunkSize] = 0x80;
-
104  memset(wbytes + state.chunkSize + 1, 0x00, 64 - 8 - (state.chunkSize + 1));
-
105  state.w[14] = htobe32((uint32_t)(state.length >> 32));
-
106  state.w[15] = htobe32((uint32_t)state.length);
-
107  processChunk();
-
108  } else {
-
109  wbytes[state.chunkSize] = 0x80;
-
110  memset(wbytes + state.chunkSize + 1, 0x00, 64 - (state.chunkSize + 1));
-
111  processChunk();
-
112  memset(wbytes, 0x00, 64 - 8);
-
113  state.w[14] = htobe32((uint32_t)(state.length >> 32));
-
114  state.w[15] = htobe32((uint32_t)state.length);
-
115  processChunk();
-
116  }
-
117 
-
118  // Convert the result into big endian and return it.
-
119  for (uint8_t posn = 0; posn < 5; ++posn)
-
120  state.w[posn] = htobe32(state.h[posn]);
-
121 
-
122  // Copy the hash to the caller's return buffer.
-
123  if (len > 20)
-
124  len = 20;
-
125  memcpy(hash, state.w, len);
-
126 }
-
127 
- -
129 {
-
130  clean(state);
-
131  reset();
-
132 }
-
133 
-
134 void SHA1::resetHMAC(const void *key, size_t keyLen)
-
135 {
-
136  formatHMACKey(state.w, key, keyLen, 0x36);
-
137  state.length += 64 * 8;
-
138  processChunk();
-
139 }
-
140 
-
141 void SHA1::finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
-
142 {
-
143  uint8_t temp[20];
-
144  finalize(temp, sizeof(temp));
-
145  formatHMACKey(state.w, key, keyLen, 0x5C);
-
146  state.length += 64 * 8;
-
147  processChunk();
-
148  update(temp, sizeof(temp));
-
149  finalize(hash, hashLen);
-
150  clean(temp);
-
151 }
-
152 
-
158 void SHA1::processChunk()
-
159 {
-
160  uint8_t index;
-
161 
-
162  // Convert the first 16 words from big endian to host byte order.
-
163  for (index = 0; index < 16; ++index)
-
164  state.w[index] = be32toh(state.w[index]);
-
165 
-
166  // Initialize the hash value for this chunk.
-
167  uint32_t a = state.h[0];
-
168  uint32_t b = state.h[1];
-
169  uint32_t c = state.h[2];
-
170  uint32_t d = state.h[3];
-
171  uint32_t e = state.h[4];
-
172 
-
173  // Perform the first 16 rounds of the compression function main loop.
-
174  uint32_t temp;
-
175  for (index = 0; index < 16; ++index) {
-
176  temp = leftRotate5(a) + ((b & c) | ((~b) & d)) + e + 0x5A827999 + state.w[index];
-
177  e = d;
-
178  d = c;
-
179  c = leftRotate30(b);
-
180  b = a;
-
181  a = temp;
-
182  }
-
183 
-
184  // Perform the 64 remaining rounds. We expand the first 16 words to
-
185  // 80 in-place in the "w" array. This saves 256 bytes of memory
-
186  // that would have otherwise need to be allocated to the "w" array.
-
187  for (; index < 20; ++index) {
-
188  temp = state.w[index & 0x0F] = leftRotate1
-
189  (state.w[(index - 3) & 0x0F] ^ state.w[(index - 8) & 0x0F] ^
-
190  state.w[(index - 14) & 0x0F] ^ state.w[(index - 16) & 0x0F]);
-
191  temp = leftRotate5(a) + ((b & c) | ((~b) & d)) + e + 0x5A827999 + temp;
-
192  e = d;
-
193  d = c;
-
194  c = leftRotate30(b);
-
195  b = a;
-
196  a = temp;
-
197  }
-
198  for (; index < 40; ++index) {
-
199  temp = state.w[index & 0x0F] = leftRotate1
-
200  (state.w[(index - 3) & 0x0F] ^ state.w[(index - 8) & 0x0F] ^
-
201  state.w[(index - 14) & 0x0F] ^ state.w[(index - 16) & 0x0F]);
-
202  temp = leftRotate5(a) + (b ^ c ^ d) + e + 0x6ED9EBA1 + temp;
-
203  e = d;
-
204  d = c;
-
205  c = leftRotate30(b);
-
206  b = a;
-
207  a = temp;
-
208  }
-
209  for (; index < 60; ++index) {
-
210  temp = state.w[index & 0x0F] = leftRotate1
-
211  (state.w[(index - 3) & 0x0F] ^ state.w[(index - 8) & 0x0F] ^
-
212  state.w[(index - 14) & 0x0F] ^ state.w[(index - 16) & 0x0F]);
-
213  temp = leftRotate5(a) + ((b & c) | (b & d) | (c & d)) + e + 0x8F1BBCDC + temp;
-
214  e = d;
-
215  d = c;
-
216  c = leftRotate30(b);
-
217  b = a;
-
218  a = temp;
-
219  }
-
220  for (; index < 80; ++index) {
-
221  temp = state.w[index & 0x0F] = leftRotate1
-
222  (state.w[(index - 3) & 0x0F] ^ state.w[(index - 8) & 0x0F] ^
-
223  state.w[(index - 14) & 0x0F] ^ state.w[(index - 16) & 0x0F]);
-
224  temp = leftRotate5(a) + (b ^ c ^ d) + e + 0xCA62C1D6 + temp;
-
225  e = d;
-
226  d = c;
-
227  c = leftRotate30(b);
-
228  b = a;
-
229  a = temp;
-
230  }
-
231 
-
232  // Add this chunk's hash to the result so far.
-
233  state.h[0] += a;
-
234  state.h[1] += b;
-
235  state.h[2] += c;
-
236  state.h[3] += d;
-
237  state.h[4] += e;
-
238 
-
239  // Attempt to clean up the stack.
-
240  a = b = c = d = e = temp = 0;
-
241 }
-
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: SHA1.cpp:134
-
virtual ~SHA1()
Destroys this SHA-1 hash object after clearing sensitive information.
Definition: SHA1.cpp:49
-
void reset()
Resets the hash ready for a new hashing process.
Definition: SHA1.cpp:64
-
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA1.cpp:75
-
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: SHA1.cpp:128
-
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: SHA1.cpp:59
-
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA1.cpp:97
-
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: SHA1.cpp:141
-
size_t hashSize() const
Size of the hash result from finalize().
Definition: SHA1.cpp:54
-
SHA1()
Constructs a SHA-1 hash object.
Definition: SHA1.cpp:41
-
void formatHMACKey(void *block, const void *key, size_t len, uint8_t pad)
Formats a HMAC key into a block.
Definition: Hash.cpp:162
-
- - - - diff --git a/SHA1_8h_source.html b/SHA1_8h_source.html deleted file mode 100644 index 5e86e6f4..00000000 --- a/SHA1_8h_source.html +++ /dev/null @@ -1,168 +0,0 @@ - - - - - - -ArduinoLibs: SHA1.h Source File - - - - - - - - - -
-
- - - - - - -
-
ArduinoLibs -
-
-
- - - - - - -
- All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
- - -
- -
- - -
-
-
-
SHA1.h
-
-
-
1 /*
-
2  * Copyright (C) 2015 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_SHA1_h
-
24 #define CRYPTO_SHA1_h
-
25 
-
26 #include "Hash.h"
-
27 
-
28 class SHA1 : public Hash
-
29 {
-
30 public:
-
31  SHA1();
-
32  virtual ~SHA1();
-
33 
-
34  size_t hashSize() const;
-
35  size_t blockSize() const;
-
36 
-
37  void reset();
-
38  void update(const void *data, size_t len);
-
39  void finalize(void *hash, size_t len);
-
40 
-
41  void clear();
-
42 
-
43  void resetHMAC(const void *key, size_t keyLen);
-
44  void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen);
-
45 
-
46 private:
-
47  struct {
-
48  uint32_t h[5];
-
49  uint32_t w[16];
-
50  uint64_t length;
-
51  uint8_t chunkSize;
-
52  } state;
-
53 
-
54  void processChunk();
-
55 };
-
56 
-
57 #endif
-
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: SHA1.cpp:134
-
virtual ~SHA1()
Destroys this SHA-1 hash object after clearing sensitive information.
Definition: SHA1.cpp:49
-
void reset()
Resets the hash ready for a new hashing process.
Definition: SHA1.cpp:64
-
Abstract base class for cryptographic hash algorithms.
Definition: Hash.h:29
-
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA1.cpp:75
-
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: SHA1.cpp:128
-
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: SHA1.cpp:59
-
SHA-1 hash algorithm.
Definition: SHA1.h:28
-
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA1.cpp:97
-
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: SHA1.cpp:141
-
size_t hashSize() const
Size of the hash result from finalize().
Definition: SHA1.cpp:54
-
SHA1()
Constructs a SHA-1 hash object.
Definition: SHA1.cpp:41
-
- - - - diff --git a/SHA256_8cpp_source.html b/SHA256_8cpp_source.html index d37791eb..aa65238f 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 2bc9d892..a9d2f5b0 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 c8e78852..232d825e 100644 --- a/SHA3_8cpp_source.html +++ b/SHA3_8cpp_source.html @@ -232,32 +232,32 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
SHA3_256::~SHA3_256
virtual ~SHA3_256()
Destroys this hash object after clearing sensitive information.
Definition: SHA3.cpp:46
SHA3_256::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: SHA3.cpp:83
SHA3_512::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: SHA3.cpp:123
-
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:263
+
KeccakCore::setHMACKey
void setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)
Sets a HMAC key for a Keccak-based hash algorithm.
Definition: KeccakCore.cpp:243
SHA3_256::SHA3_256
SHA3_256()
Constructs a new SHA3-256 hash object.
Definition: SHA3.cpp:38
SHA3_256::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: SHA3.cpp:88
SHA3_512::~SHA3_512
virtual ~SHA3_512()
Destroys this hash object after clearing sensitive information.
Definition: SHA3.cpp:118
SHA3_256::hashSize
size_t hashSize() const
Size of the hash result from finalize().
Definition: SHA3.cpp:51
SHA3_512::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA3.cpp:143
SHA3_512::reset
void reset()
Resets the hash ready for a new hashing process.
Definition: SHA3.cpp:133
-
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:89
+
KeccakCore::setCapacity
void setCapacity(size_t capacity)
Sets the capacity of the Keccak sponge function in bits.
Definition: KeccakCore.cpp:94
SHA3_512::finalizeHMAC
void finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)
Finalizes the HMAC hashing process and returns the hash.
Definition: SHA3.cpp:160
SHA3_256::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: SHA3.cpp:56
-
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:201
+
KeccakCore::extract
void extract(void *data, size_t size)
Extracts data from the Keccak sponge function.
Definition: KeccakCore.cpp:194
SHA3_512::resetHMAC
void resetHMAC(const void *key, size_t keyLen)
Resets the hash ready for a new HMAC hashing process.
Definition: SHA3.cpp:155
SHA3_512::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: SHA3.cpp:150
-
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:174
+
KeccakCore::pad
void pad(uint8_t tag)
Pads the last block of input data to blockSize().
Definition: KeccakCore.cpp:167
SHA3_512::blockSize
size_t blockSize() const
Size of the internal block used by the hash algorithm.
Definition: SHA3.cpp:128
SHA3_512::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA3.cpp:138
-
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:128
-
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:245
+
KeccakCore::update
void update(const void *data, size_t size)
Updates the Keccak sponge function with more input data.
Definition: KeccakCore.cpp:133
+
KeccakCore::clear
void clear()
Clears all sensitive data from this object.
Definition: KeccakCore.cpp:225
SHA3_256::finalize
void finalize(void *hash, size_t len)
Finalizes the hashing process and returns the hash.
Definition: SHA3.cpp:71
-
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:109
+
KeccakCore::reset
void reset()
Resets the Keccak sponge function ready for a new session.
Definition: KeccakCore.cpp:114
SHA3_256::update
void update(const void *data, size_t len)
Updates the hash with more data.
Definition: SHA3.cpp:66
SHA3_256::clear
void clear()
Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing ...
Definition: SHA3.cpp:78
diff --git a/SHA3_8h_source.html b/SHA3_8h_source.html index 1def1142..f852238a 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 b072d79a..2ac5dc97 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 ac6af27a..991a8c5f 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/SoftI2C_8cpp_source.html b/SoftI2C_8cpp_source.html index 38684042..5739e28f 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 e4bbfa55..b749f955 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/SpeckLowMemory_8cpp_source.html b/SpeckLowMemory_8cpp_source.html index 8fc607f3..0a7ec637 100644 --- a/SpeckLowMemory_8cpp_source.html +++ b/SpeckLowMemory_8cpp_source.html @@ -596,7 +596,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/SpeckLowMemory_8h_source.html b/SpeckLowMemory_8h_source.html index 985a4fd4..42c7fe16 100644 --- a/SpeckLowMemory_8h_source.html +++ b/SpeckLowMemory_8h_source.html @@ -149,7 +149,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/Speck_8cpp_source.html b/Speck_8cpp_source.html index 33667867..cef0f78f 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 de4428bf..06e34031 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/TextField_8cpp_source.html b/TextField_8cpp_source.html index e9c44f73..d095fa0b 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 f29c7dc6..629c2821 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 6a19991d..79a5bd56 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 064bc327..59a9ae7a 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 32eaa7cc..91cc0e37 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 e4a556ac..c34a515b 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/alarm-clock_8dox.html b/alarm-clock_8dox.html index 923f5833..07182c54 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 ffac9cb5..0ba0140e 100644 --- a/alarm_clock.html +++ b/alarm_clock.html @@ -140,7 +140,7 @@ Completed Clock diff --git a/annotated.html b/annotated.html index 6f595398..c71918b7 100644 --- a/annotated.html +++ b/annotated.html @@ -117,48 +117,49 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); oCDS1307RTCCommunicates with a DS1307 realtime clock chip via I2C oCDS3231RTCCommunicates with a DS3231 realtime clock chip via I2C oCDS3232RTCCommunicates with a DS3232 realtime clock chip via I2C -oCEd25519Digital signatures based on the elliptic curve modulo 2^255 - 19 -oCEEPROM24Reading and writing EEPROM's from the 24LCXX family -oCFieldManages a single data input/output field within a Form -oCFormManager for a form containing data input/output fields -oCGCMImplementation of the Galois Counter Mode (GCM) -oCGCMCommonConcrete base class to assist with implementing GCM for 128-bit block ciphers -oCGHASHImplementation of the GHASH message authenticator -oCHashAbstract base class for cryptographic hash algorithms -oCI2CMasterAbstract base class for I2C master implementations -oCIntFieldField that manages the input of an integer value -oCIRreceiverManages the reception of RC-5 commands from an infrared remote control -oCKeccakCoreKeccak core sponge function -oCLCDEnhanced library for Freetronics 16x2 LCD shields -oCListFieldField that manages selection from a static list of items -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 -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 -oCSHA1SHA-1 hash algorithm -oCSHA256SHA-256 hash algorithm -oCSHA3_256SHA3-256 hash algorithm -oCSHA3_512SHA3-512 hash algorithm -oCSHA512SHA-512 hash algorithm -oCSoftI2CBit-banged implementation of an I2C master -oCSpeckSpeck block cipher with a 128-bit block size -oCSpeckLowMemorySpeck block cipher with a 128-bit block size (low-memory version) -oCTextFieldField that displays a read-only text value -oCTimeFieldField that manages the display and editing of a time value -\CTransistorNoiseSourceProcesses the signal from a transistor-based noise source +oCEAXImplementation of the EAX authenticated cipher +oCEAXCommonConcrete base class to assist with implementing EAX for 128-bit block ciphers +oCEd25519Digital signatures based on the elliptic curve modulo 2^255 - 19 +oCEEPROM24Reading and writing EEPROM's from the 24LCXX family +oCFieldManages a single data input/output field within a Form +oCFormManager for a form containing data input/output fields +oCGCMImplementation of the Galois Counter Mode (GCM) +oCGCMCommonConcrete base class to assist with implementing GCM for 128-bit block ciphers +oCGHASHImplementation of the GHASH message authenticator +oCHashAbstract base class for cryptographic hash algorithms +oCI2CMasterAbstract base class for I2C master implementations +oCIntFieldField that manages the input of an integer value +oCIRreceiverManages the reception of RC-5 commands from an infrared remote control +oCKeccakCoreKeccak core sponge function +oCLCDEnhanced library for Freetronics 16x2 LCD shields +oCListFieldField that manages selection from a static list of items +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 +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 +oCSoftI2CBit-banged implementation of an I2C master +oCSpeckSpeck block cipher with a 128-bit block size +oCSpeckLowMemorySpeck block cipher with a 128-bit block size (low-memory version) +oCTextFieldField that displays a read-only text value +oCTimeFieldField that manages the display and editing of a time value +\CTransistorNoiseSourceProcesses the signal from a transistor-based noise source diff --git a/blink-blink_8dox.html b/blink-blink_8dox.html index d70e7e96..6f66b10e 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 a60449a4..8f6ba52d 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 40a107f3..e4a08884 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 4407daba..799f6a51 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 a9bed3c8..ff934bd7 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 64b2e440..a079ff1c 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 1a93f151..a17a6489 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 3d9bb049..4d709762 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 5dd6acbd..5d242bc3 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 51c25e29..2f56e6b3 100644 --- a/classAES128.html +++ b/classAES128.html @@ -155,7 +155,7 @@ Additional Inherited Members

AES block cipher with 128-bit keys.

See Also
AES192, AES256
-

Definition at line 56 of file AES.h.

+

Definition at line 52 of file AES.h.

Constructor & Destructor Documentation

@@ -265,7 +265,7 @@ Additional Inherited Members
diff --git a/classAES192-members.html b/classAES192-members.html index 9f98a42e..63afb42b 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 3c0abaf4..f4257722 100644 --- a/classAES192.html +++ b/classAES192.html @@ -155,7 +155,7 @@ Additional Inherited Members

AES block cipher with 192-bit keys.

See Also
AES128, AES256
-

Definition at line 70 of file AES.h.

+

Definition at line 66 of file AES.h.

Constructor & Destructor Documentation

@@ -265,7 +265,7 @@ Additional Inherited Members
diff --git a/classAES256-members.html b/classAES256-members.html index 2c72bc4d..43d406ba 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 c722ae57..48b77861 100644 --- a/classAES256.html +++ b/classAES256.html @@ -155,7 +155,7 @@ Additional Inherited Members

AES block cipher with 256-bit keys.

See Also
AES128, AES192
-

Definition at line 84 of file AES.h.

+

Definition at line 80 of file AES.h.

Constructor & Destructor Documentation

@@ -265,7 +265,7 @@ Additional Inherited Members
diff --git a/classAESCommon-members.html b/classAESCommon-members.html index 5e3e8bbd..d6ee7c02 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 33f597f8..b249ba59 100644 --- a/classAESCommon.html +++ b/classAESCommon.html @@ -184,7 +184,7 @@ Protected Member Functions

Implements BlockCipher.

-

Definition at line 144 of file AESCommon.cpp.

+

Definition at line 142 of file AESCommon.cpp.

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

Implements BlockCipher.

-

Definition at line 324 of file AESCommon.cpp.

+

Definition at line 326 of file AESCommon.cpp.

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

Implements BlockCipher.

-

Definition at line 266 of file AESCommon.cpp.

+

Definition at line 264 of file AESCommon.cpp.

@@ -322,7 +322,7 @@ Protected Member Functions diff --git a/classAuthenticatedCipher-members.html b/classAuthenticatedCipher-members.html index d5999d0d..e0561749 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 f6ebfb4c..66bf9f15 100644 --- a/classAuthenticatedCipher.html +++ b/classAuthenticatedCipher.html @@ -101,10 +101,12 @@ Inheritance diagram for AuthenticatedCipher:
-Cipher +Cipher ChaChaPoly -GCMCommon -GCM< T > +EAXCommon +GCMCommon +EAX< T > +GCM< T >
@@ -213,7 +215,7 @@ virtual  - - - + +
encrypt() or decrypt(). That is, it is assumed that all extra data for authentication is available before the first payload data block and that it will be prepended to the payload for authentication. If the subclass needs to process the extra data after the payload, then it is responsible for saving data away until it is needed during computeTag() or checkTag().

This function can be called multiple times with separate extra data blocks for authentication. All such data will be concatenated into a single block for authentication purposes.

-

Implemented in ChaChaPoly, and GCMCommon.

+

Implemented in ChaChaPoly, GCMCommon, and EAXCommon.

@@ -262,7 +264,7 @@ virtual 
Note
Authenticated cipher modes usually require that if the tag could not be verified, then all of the data that was previously decrypted must be discarded. It is unwise to use the decrypted data for any purpose before it can be verified. Callers are responsible for ensuring that any data returned via previous calls to decrypt() is discarded if checkTag() returns false.
See Also
computeTag()
-

Implemented in ChaChaPoly, and GCMCommon.

+

Implemented in ChaChaPoly, GCMCommon, and EAXCommon.

@@ -308,7 +310,7 @@ virtual 
See Also
checkTag()
-

Implemented in ChaChaPoly, and GCMCommon.

+

Implemented in ChaChaPoly, GCMCommon, and EAXCommon.

@@ -338,7 +340,7 @@ virtual 
See Also
computeTag()
-

Implemented in ChaChaPoly, and GCMCommon.

+

Implemented in ChaChaPoly, GCMCommon, and EAXCommon.

@@ -349,7 +351,7 @@ virtual 
diff --git a/classAuthenticatedCipher.png b/classAuthenticatedCipher.png index 8dc80439..3dc82a1c 100644 Binary files a/classAuthenticatedCipher.png and b/classAuthenticatedCipher.png differ diff --git a/classBLAKE2b-members.html b/classBLAKE2b-members.html index 1e45ebba..ea831f9b 100644 --- a/classBLAKE2b-members.html +++ b/classBLAKE2b-members.html @@ -107,13 +107,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
reset(uint8_t outputLength)BLAKE2b
resetHMAC(const void *key, size_t keyLen)BLAKE2bvirtual
update(const void *data, size_t len)BLAKE2bvirtual
v (defined in BLAKE2b)BLAKE2b
~BLAKE2b()BLAKE2bvirtual
~Hash()Hashvirtual
~BLAKE2b()BLAKE2bvirtual
~Hash()Hashvirtual
diff --git a/classBLAKE2b.html b/classBLAKE2b.html index bb687e19..053ba75c 100644 --- a/classBLAKE2b.html +++ b/classBLAKE2b.html @@ -162,7 +162,7 @@ Additional Inherited Members

BLAKE2b hash algorithm.

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

Reference: https://blake2.net/

-
See Also
BLAKE2s, SHA512
+
See Also
BLAKE2s, SHA512, SHA3_512

Definition at line 28 of file BLAKE2b.h.

Member Function Documentation

@@ -536,7 +536,7 @@ Additional Inherited Members diff --git a/classBLAKE2s-members.html b/classBLAKE2s-members.html index fb2de65a..7c170946 100644 --- a/classBLAKE2s-members.html +++ b/classBLAKE2s-members.html @@ -106,13 +106,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); reset(uint8_t outputLength)BLAKE2s resetHMAC(const void *key, size_t keyLen)BLAKE2svirtual update(const void *data, size_t len)BLAKE2svirtual - v (defined in BLAKE2s)BLAKE2s - ~BLAKE2s()BLAKE2svirtual - ~Hash()Hashvirtual + ~BLAKE2s()BLAKE2svirtual + ~Hash()Hashvirtual diff --git a/classBLAKE2s.html b/classBLAKE2s.html index 5ef4fcaf..5cf01fcb 100644 --- a/classBLAKE2s.html +++ b/classBLAKE2s.html @@ -162,7 +162,7 @@ Additional Inherited Members

BLAKE2s hash algorithm.

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

Reference: https://blake2.net/

-
See Also
SHA256
+
See Also
BLAKE2b, SHA256, SHA3_256

Definition at line 28 of file BLAKE2s.h.

Member Function Documentation

@@ -536,7 +536,7 @@ Additional Inherited Members diff --git a/classBigNumberUtil-members.html b/classBigNumberUtil-members.html index 372dd5d4..b78dea75 100644 --- a/classBigNumberUtil-members.html +++ b/classBigNumberUtil-members.html @@ -105,7 +105,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classBigNumberUtil.html b/classBigNumberUtil.html index d857985b..e6e833c6 100644 --- a/classBigNumberUtil.html +++ b/classBigNumberUtil.html @@ -893,7 +893,7 @@ Static Public Member Functions diff --git a/classBitmap-members.html b/classBitmap-members.html index 29d83d0c..2e6d7a4d 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 a261d9ad..defa0877 100644 --- a/classBitmap.html +++ b/classBitmap.html @@ -1745,7 +1745,7 @@ class DMD diff --git a/classBlinkLED-members.html b/classBlinkLED-members.html index 9f78b5ac..76b18270 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 b6048e87..6f3cfd0d 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 a4dce064..e0b6c1e3 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 0532dfe6..d3332fee 100644 --- a/classBlockCipher.html +++ b/classBlockCipher.html @@ -409,7 +409,7 @@ Public Member Functions diff --git a/classBoolField-members.html b/classBoolField-members.html index a94e89f7..58cb3662 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 92b3ed49..35687165 100644 --- a/classBoolField.html +++ b/classBoolField.html @@ -506,7 +506,7 @@ LiquidCrystal *  diff --git a/classCBC-members.html b/classCBC-members.html index bd1923a9..2f50b766 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 b34570a8..54fe03b9 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 f3640508..d4a3660d 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 46969d60..989173c6 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 a9f0c0ee..6bb55f58 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 f4067d9a..9a21a838 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 0a897b12..99cbc7f6 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 e86cac32..aee96aaa 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 6d4cc8a3..6876dc92 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 e6528e66..969588a6 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 d58ac265..b5d23c36 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 2e98efb9..dc38280b 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 42f9d5c9..e43eeff0 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 c8612f85..6193a456 100644 --- a/classChaCha.html +++ b/classChaCha.html @@ -673,7 +673,7 @@ class ChaChaPoly< diff --git a/classChaChaPoly-members.html b/classChaChaPoly-members.html index 9dc444c5..343198f7 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 d7e9d94c..90afb7fe 100644 --- a/classChaChaPoly.html +++ b/classChaChaPoly.html @@ -665,7 +665,7 @@ virtual  diff --git a/classCharlieplex-members.html b/classCharlieplex-members.html index e8a55126..0d4e9be3 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 cfe3b962..3815c5c1 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 6d30310d..d47b69db 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 cc29d1be..0bd5f27f 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 c2f990b1..8bbc43b7 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 0f48f07f..83f2fc0e 100644 --- a/classCipher.html +++ b/classCipher.html @@ -101,19 +101,21 @@ Inheritance diagram for Cipher:
-AuthenticatedCipher -CBCCommon -CFBCommon -ChaCha -CTRCommon -OFBCommon +AuthenticatedCipher +CBCCommon +CFBCommon +ChaCha +CTRCommon +OFBCommon ChaChaPoly -GCMCommon -CBC< T > -CFB< T > -CTR< T > -OFB< T > -GCM< T > +EAXCommon +GCMCommon +CBC< T > +CFB< T > +CTR< T > +OFB< T > +EAX< T > +GCM< T >
@@ -209,7 +211,7 @@ Public Member Functions

Clears all security-sensitive state from this cipher.

Security-sensitive information includes key schedules, initialization vectors, and any temporary state that is used by encrypt() or decrypt() which is stored in the cipher itself.

-

Implemented in ChaChaPoly, GCMCommon, ChaCha, CTRCommon, CBCCommon, CFBCommon, and OFBCommon.

+

Implemented in ChaChaPoly, GCMCommon, ChaCha, EAXCommon, CTRCommon, CBCCommon, CFBCommon, and OFBCommon.

@@ -263,7 +265,7 @@ Public Member Functions

The decrypt() function can be called multiple times with different regions of the ciphertext data.

See Also
encrypt()
-

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, CBCCommon, CFBCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, EAXCommon, CBCCommon, CFBCommon, and OFBCommon.

@@ -317,7 +319,7 @@ Public Member Functions

The encrypt() function can be called multiple times with different regions of the plaintext data.

See Also
decrypt()
-

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, CBCCommon, CFBCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, EAXCommon, CBCCommon, CFBCommon, and OFBCommon.

@@ -345,7 +347,7 @@ Public Member Functions

Size of the initialization vector for this cipher, in bytes.

If the cipher does not need an initialization vector, this function will return zero.

-

Implemented in ChaCha, ChaChaPoly, GCMCommon, CBCCommon, CFBCommon, CTRCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, GCMCommon, CBCCommon, CFBCommon, CTRCommon, EAXCommon, and OFBCommon.

@@ -374,7 +376,7 @@ Public Member Functions

If the cipher supports variable-sized keys, keySize() indicates the default or recommended key size. The cipher may support other key sizes.

See Also
setKey(), ivSize()
-

Implemented in ChaCha, ChaChaPoly, GCMCommon, CBCCommon, CFBCommon, CTRCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, GCMCommon, CBCCommon, CFBCommon, CTRCommon, EAXCommon, and OFBCommon.

@@ -423,7 +425,7 @@ Public Member Functions
Note
The IV is not encoded into the output stream by encrypt(). The caller is responsible for communicating the IV to the other party.
See Also
ivSize()
-

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, CBCCommon, CFBCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, EAXCommon, CBCCommon, CFBCommon, and OFBCommon.

@@ -472,7 +474,7 @@ Public Member Functions

Calling setKey() resets the cipher. Any temporary data that was being retained for encrypting partial blocks will be abandoned.

See Also
keySize(), clear()
-

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, CBCCommon, CFBCommon, and OFBCommon.

+

Implemented in ChaCha, ChaChaPoly, CTRCommon, GCMCommon, EAXCommon, CBCCommon, CFBCommon, and OFBCommon.

@@ -483,7 +485,7 @@ Public Member Functions diff --git a/classCipher.png b/classCipher.png index 51c89007..53a4b2a9 100644 Binary files a/classCipher.png and b/classCipher.png differ diff --git a/classCurve25519-members.html b/classCurve25519-members.html index a77cc4af..63188369 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 8afcefaa..38a0b1c1 100644 --- a/classCurve25519.html +++ b/classCurve25519.html @@ -303,7 +303,7 @@ class Ed25519 diff --git a/classDMD-members.html b/classDMD-members.html index cfd05995..e5d9a444 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 490306e5..b3269e85 100644 --- a/classDMD.html +++ b/classDMD.html @@ -755,7 +755,7 @@ Multiple panels diff --git a/classDS1307RTC-members.html b/classDS1307RTC-members.html index 9fad2ba3..73b3f47c 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 abaca0a4..8ebdd4aa 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 ad85b6d3..fa8f5bd7 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 6e11c510..88d2ca00 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 f198a005..05f97cfa 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 7cdddf7c..9406beb9 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 new file mode 100644 index 00000000..6b92c7a4 --- /dev/null +++ b/classEAX-members.html @@ -0,0 +1,128 @@ + + + + + + +ArduinoLibs: Member List + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ +
+
+
+
EAX< T > Member List
+
+
+ +

This is the complete list of members for EAX< T >, including all inherited members.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
addAuthData(const void *data, size_t len)EAXCommonvirtual
AuthenticatedCipher()AuthenticatedCipher
authMode (defined in EAXCommon)EAXCommon
authPosn (defined in EAXCommon)EAXCommon
b (defined in EAXCommon)EAXCommon
checkTag(const void *tag, size_t len)EAXCommonvirtual
Cipher()Cipher
clear()EAXCommonvirtual
computeTag(void *tag, size_t len)EAXCommonvirtual
counter (defined in EAXCommon)EAXCommon
decrypt(uint8_t *output, const uint8_t *input, size_t len)EAXCommonvirtual
EAX()EAX< T >inline
EAXCommon()EAXCommonprotected
encPosn (defined in EAXCommon)EAXCommon
encrypt(uint8_t *output, const uint8_t *input, size_t len)EAXCommonvirtual
hash (defined in EAXCommon)EAXCommon
ivSize() const EAXCommonvirtual
keySize() const EAXCommonvirtual
setBlockCipher(BlockCipher *cipher)EAXCommoninlineprotected
setIV(const uint8_t *iv, size_t len)EAXCommonvirtual
setKey(const uint8_t *key, size_t len)EAXCommonvirtual
stream (defined in EAXCommon)EAXCommon
tag (defined in EAXCommon)EAXCommon
tagSize() const EAXCommonvirtual
~AuthenticatedCipher()AuthenticatedCiphervirtual
~Cipher()Ciphervirtual
~EAXCommon() (defined in EAXCommon)EAXCommonvirtual
+ + + + diff --git a/classEAX.html b/classEAX.html new file mode 100644 index 00000000..6e7bf5fd --- /dev/null +++ b/classEAX.html @@ -0,0 +1,227 @@ + + + + + + +ArduinoLibs: EAX< T > Class Template Reference + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ +
+
+
+Public Member Functions | +List of all members
+
+
EAX< T > Class Template Reference
+
+
+ +

Implementation of the EAX authenticated cipher. + More...

+ +

#include <EAX.h>

+
+Inheritance diagram for EAX< T >:
+
+
+ + +EAXCommon +AuthenticatedCipher +Cipher + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

EAX ()
 Constructs a new EAX object for the block cipher T.
 
- Public Member Functions inherited from EAXCommon
size_t keySize () const
 Default size of the key for this cipher, in bytes. More...
 
size_t ivSize () const
 Size of the initialization vector for this cipher, in bytes. More...
 
size_t tagSize () const
 Returns the size of the authentication tag. More...
 
bool setKey (const uint8_t *key, size_t len)
 Sets the key to use for future encryption and decryption operations. More...
 
bool setIV (const uint8_t *iv, size_t len)
 Sets the initialization vector to use for future encryption and decryption operations. More...
 
void encrypt (uint8_t *output, const uint8_t *input, size_t len)
 Encrypts an input buffer and writes the ciphertext to an output buffer. More...
 
void decrypt (uint8_t *output, const uint8_t *input, size_t len)
 Decrypts an input buffer and writes the plaintext to an output buffer. More...
 
void addAuthData (const void *data, size_t len)
 Adds extra data that will be authenticated but not encrypted. More...
 
void computeTag (void *tag, size_t len)
 Finalizes the encryption process and computes the authentication tag. More...
 
bool checkTag (const void *tag, size_t len)
 Finalizes the decryption process and checks the authentication tag. More...
 
void clear ()
 Clears all security-sensitive state from this cipher. More...
 
- Public Member Functions inherited from AuthenticatedCipher
AuthenticatedCipher ()
 Constructs a new authenticated cipher.
 
+virtual ~AuthenticatedCipher ()
 Destroys this authenticated cipher.
 
- Public Member Functions inherited from Cipher
Cipher ()
 Constructs a new cipher object.
 
virtual ~Cipher ()
 Destroys this cipher object. More...
 
+ + + + + + + + +

+Additional Inherited Members

- Protected Member Functions inherited from EAXCommon
 EAXCommon ()
 Constructs a new cipher in EAX mode. More...
 
void setBlockCipher (BlockCipher *cipher)
 Sets the block cipher to use for this EAX object. More...
 
+

Detailed Description

+

template<typename T>
+class EAX< T >

+ +

Implementation of the EAX authenticated cipher.

+

EAX mode converts a block cipher into an authenticated cipher that uses the block cipher T to encrypt and authenticate.

+

The size of the key is determined by the underlying block cipher T. The IV is recommended to be 128 bits (16 bytes) in length, but other lengths are supported as well. The default tagSize() is 128 bits (16 bytes) but the EAX specification does allow smaller tag sizes.

+

The template parameter T must be a concrete subclass of BlockCipher indicating the specific block cipher to use. The block cipher must have a block size of 128 bits. For example, the following creates a EAX object using AES256 as the underlying cipher and then uses it to encrypt and authenticate a plaintext block:

+
+
eax.setKey(key, sizeof(key));
+
eax.setIV(iv, sizeof(iv));
+
eax.addAuthData(adata, sizeof(adata));
+
eax.encrypt(ciphertext, plaintext, sizeof(plaintext));
+
eax.computeTag(tag, sizeof(tag));
+

The decryption process is almost identical to convert a ciphertext and tag back into plaintext and then check the tag:

+
+
eax.setKey(key, sizeof(key));
+
eax.setIV(iv, sizeof(iv));
+
eax.addAuthData(adata, sizeof(adata));
+
eax.decrypt(ciphertext, plaintext, sizeof(plaintext));
+
if (!eax.checkTag(tag, sizeof(tag))) {
+
// The data was invalid - do not use it.
+
...
+
}
+

The EAX class can also be used to implement message authentication by omitting the plaintext:

+
+
eax.setKey(key, sizeof(key));
+
eax.setIV(iv, sizeof(iv));
+
eax.addAuthData(adata1, sizeof(adata1));
+
eax.addAuthData(adata2, sizeof(adata1));
+
...
+
eax.addAuthData(adataN, sizeof(adataN));
+
eax.computeTag(tag, sizeof(tag));
+

References: https://en.wikipedia.org/wiki/EAX_mode, http://web.cs.ucdavis.edu/~rogaway/papers/eax.html

+
See Also
EAXCommon, GCM
+ +

Definition at line 79 of file EAX.h.

+

The documentation for this class was generated from the following files: +
+ + + + diff --git a/classEAX.png b/classEAX.png new file mode 100644 index 00000000..5d8cacbc Binary files /dev/null and b/classEAX.png differ diff --git a/classEAXCommon-members.html b/classEAXCommon-members.html new file mode 100644 index 00000000..d0e2e60b --- /dev/null +++ b/classEAXCommon-members.html @@ -0,0 +1,127 @@ + + + + + + +ArduinoLibs: Member List + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ +
+
+
+
EAXCommon Member List
+
+
+ +

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

+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
addAuthData(const void *data, size_t len)EAXCommonvirtual
AuthenticatedCipher()AuthenticatedCipher
authMode (defined in EAXCommon)EAXCommon
authPosn (defined in EAXCommon)EAXCommon
b (defined in EAXCommon)EAXCommon
checkTag(const void *tag, size_t len)EAXCommonvirtual
Cipher()Cipher
clear()EAXCommonvirtual
computeTag(void *tag, size_t len)EAXCommonvirtual
counter (defined in EAXCommon)EAXCommon
decrypt(uint8_t *output, const uint8_t *input, size_t len)EAXCommonvirtual
EAXCommon()EAXCommonprotected
encPosn (defined in EAXCommon)EAXCommon
encrypt(uint8_t *output, const uint8_t *input, size_t len)EAXCommonvirtual
hash (defined in EAXCommon)EAXCommon
ivSize() const EAXCommonvirtual
keySize() const EAXCommonvirtual
setBlockCipher(BlockCipher *cipher)EAXCommoninlineprotected
setIV(const uint8_t *iv, size_t len)EAXCommonvirtual
setKey(const uint8_t *key, size_t len)EAXCommonvirtual
stream (defined in EAXCommon)EAXCommon
tag (defined in EAXCommon)EAXCommon
tagSize() const EAXCommonvirtual
~AuthenticatedCipher()AuthenticatedCiphervirtual
~Cipher()Ciphervirtual
~EAXCommon() (defined in EAXCommon)EAXCommonvirtual
+ + + + diff --git a/classEAXCommon.html b/classEAXCommon.html new file mode 100644 index 00000000..eae2a79b --- /dev/null +++ b/classEAXCommon.html @@ -0,0 +1,740 @@ + + + + + + +ArduinoLibs: EAXCommon Class Reference + + + + + + + + + +
+
+ + + + + + +
+
ArduinoLibs +
+
+
+ + + + + + +
+ All Classes Files Functions Variables Typedefs Enumerations Enumerator Groups Pages
+ + +
+ +
+ +
+
+
+Public Member Functions | +Protected Member Functions | +List of all members
+
+
EAXCommon Class Reference
+
+
+ +

Concrete base class to assist with implementing EAX for 128-bit block ciphers. + More...

+ +

#include <EAX.h>

+
+Inheritance diagram for EAXCommon:
+
+
+ + +AuthenticatedCipher +Cipher +EAX< T > + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Public Member Functions

size_t keySize () const
 Default size of the key for this cipher, in bytes. More...
 
size_t ivSize () const
 Size of the initialization vector for this cipher, in bytes. More...
 
size_t tagSize () const
 Returns the size of the authentication tag. More...
 
bool setKey (const uint8_t *key, size_t len)
 Sets the key to use for future encryption and decryption operations. More...
 
bool setIV (const uint8_t *iv, size_t len)
 Sets the initialization vector to use for future encryption and decryption operations. More...
 
void encrypt (uint8_t *output, const uint8_t *input, size_t len)
 Encrypts an input buffer and writes the ciphertext to an output buffer. More...
 
void decrypt (uint8_t *output, const uint8_t *input, size_t len)
 Decrypts an input buffer and writes the plaintext to an output buffer. More...
 
void addAuthData (const void *data, size_t len)
 Adds extra data that will be authenticated but not encrypted. More...
 
void computeTag (void *tag, size_t len)
 Finalizes the encryption process and computes the authentication tag. More...
 
bool checkTag (const void *tag, size_t len)
 Finalizes the decryption process and checks the authentication tag. More...
 
void clear ()
 Clears all security-sensitive state from this cipher. More...
 
- Public Member Functions inherited from AuthenticatedCipher
AuthenticatedCipher ()
 Constructs a new authenticated cipher.
 
+virtual ~AuthenticatedCipher ()
 Destroys this authenticated cipher.
 
- Public Member Functions inherited from Cipher
Cipher ()
 Constructs a new cipher object.
 
virtual ~Cipher ()
 Destroys this cipher object. More...
 
+ + + + + + + +

+Protected Member Functions

 EAXCommon ()
 Constructs a new cipher in EAX mode. More...
 
void setBlockCipher (BlockCipher *cipher)
 Sets the block cipher to use for this EAX object. More...
 
+

Detailed Description

+

Concrete base class to assist with implementing EAX for 128-bit block ciphers.

+

References: https://en.wikipedia.org/wiki/EAX_mode, http://web.cs.ucdavis.edu/~rogaway/papers/eax.html

+
See Also
EAX
+ +

Definition at line 29 of file EAX.h.

+

Constructor & Destructor Documentation

+ +
+
+ + + + + +
+ + + + + + + +
EAXCommon::EAXCommon ()
+
+protected
+
+ +

Constructs a new cipher in EAX mode.

+

This constructor must be followed by a call to setBlockCipher().

+ +

Definition at line 43 of file EAX.cpp.

+ +
+
+

Member Function Documentation

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
void EAXCommon::addAuthData (const void * data,
size_t len 
)
+
+virtual
+
+ +

Adds extra data that will be authenticated but not encrypted.

+
Parameters
+ + + +
dataThe extra data to be authenticated.
lenThe number of bytes of extra data to be authenticated.
+
+
+

This function must be called before the first call to encrypt() or decrypt(). That is, it is assumed that all extra data for authentication is available before the first payload data block and that it will be prepended to the payload for authentication. If the subclass needs to process the extra data after the payload, then it is responsible for saving data away until it is needed during computeTag() or checkTag().

+

This function can be called multiple times with separate extra data blocks for authentication. All such data will be concatenated into a single block for authentication purposes.

+ +

Implements AuthenticatedCipher.

+ +

Definition at line 118 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
bool EAXCommon::checkTag (const void * tag,
size_t len 
)
+
+virtual
+
+ +

Finalizes the decryption process and checks the authentication tag.

+
Parameters
+ + + +
tagThe tag value from the incoming ciphertext to be checked.
lenThe length of the tag value in bytes, which may be less than tagSize().
+
+
+
Returns
Returns true if the tag is identical to the first len bytes of the authentication tag that was calculated during the decryption process. Returns false otherwise.
+

This function must be called after the final block of ciphertext is passed to decrypt() to determine if the data could be authenticated.

+
Note
Authenticated cipher modes usually require that if the tag could not be verified, then all of the data that was previously decrypted must be discarded. It is unwise to use the decrypted data for any purpose before it can be verified. Callers are responsible for ensuring that any data returned via previous calls to decrypt() is discarded if checkTag() returns false.
+
See Also
computeTag()
+ +

Implements AuthenticatedCipher.

+ +

Definition at line 132 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + +
void EAXCommon::clear ()
+
+virtual
+
+ +

Clears all security-sensitive state from this cipher.

+

Security-sensitive information includes key schedules, initialization vectors, and any temporary state that is used by encrypt() or decrypt() which is stored in the cipher itself.

+ +

Implements Cipher.

+ +

Definition at line 143 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
void EAXCommon::computeTag (void * tag,
size_t len 
)
+
+virtual
+
+ +

Finalizes the encryption process and computes the authentication tag.

+
Parameters
+ + + +
tagPoints to the buffer to write the tag to.
lenThe length of the tag, which may be less than tagSize() to truncate the tag to the first len bytes.
+
+
+
See Also
checkTag()
+ +

Implements AuthenticatedCipher.

+ +

Definition at line 124 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
void EAXCommon::decrypt (uint8_t * output,
const uint8_t * input,
size_t len 
)
+
+virtual
+
+ +

Decrypts an input buffer and writes the plaintext to an output buffer.

+
Parameters
+ + + + +
outputThe output buffer to write to, which may be the same buffer as input. The output buffer must have at least as many bytes as the input buffer.
inputThe input buffer to read from.
lenThe number of bytes to decrypt.
+
+
+

The decrypt() function can be called multiple times with different regions of the ciphertext data.

+
See Also
encrypt()
+ +

Implements Cipher.

+ +

Definition at line 110 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
void EAXCommon::encrypt (uint8_t * output,
const uint8_t * input,
size_t len 
)
+
+virtual
+
+ +

Encrypts an input buffer and writes the ciphertext to an output buffer.

+
Parameters
+ + + + +
outputThe output buffer to write to, which may be the same buffer as input. The output buffer must have at least as many bytes as the input buffer.
inputThe input buffer to read from.
lenThe number of bytes to encrypt.
+
+
+

The encrypt() function can be called multiple times with different regions of the plaintext data.

+
See Also
decrypt()
+ +

Implements Cipher.

+ +

Definition at line 102 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + +
size_t EAXCommon::ivSize () const
+
+virtual
+
+ +

Size of the initialization vector for this cipher, in bytes.

+

If the cipher does not need an initialization vector, this function will return zero.

+ +

Implements Cipher.

+ +

Definition at line 61 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + +
size_t EAXCommon::keySize () const
+
+virtual
+
+ +

Default size of the key for this cipher, in bytes.

+

If the cipher supports variable-sized keys, keySize() indicates the default or recommended key size. The cipher may support other key sizes.

+
See Also
setKey(), ivSize()
+ +

Implements Cipher.

+ +

Definition at line 56 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + +
void EAXCommon::setBlockCipher (BlockCiphercipher)
+
+inlineprotected
+
+ +

Sets the block cipher to use for this EAX object.

+
Parameters
+ + +
cipherThe block cipher to use to implement EAX mode. This object must have a block size of 128 bits (16 bytes).
+
+
+ +

Definition at line 53 of file EAX.h.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
bool EAXCommon::setIV (const uint8_t * iv,
size_t len 
)
+
+virtual
+
+ +

Sets the initialization vector to use for future encryption and decryption operations.

+
Parameters
+ + + +
ivThe initialization vector to use.
lenThe length of the initialization vector in bytes.
+
+
+
Returns
Returns false if the length is not supported.
+

Initialization vectors should be set before the first call to encrypt() or decrypt() after a setKey() call. If the initialization vector is changed after encryption or decryption begins, then the behaviour is undefined.

+
Note
The IV is not encoded into the output stream by encrypt(). The caller is responsible for communicating the IV to the other party.
+
See Also
ivSize()
+ +

Implements Cipher.

+ +

Definition at line 78 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + +
bool EAXCommon::setKey (const uint8_t * key,
size_t len 
)
+
+virtual
+
+ +

Sets the key to use for future encryption and decryption operations.

+
Parameters
+ + + +
keyThe key to use.
lenThe length of the key in bytes.
+
+
+
Returns
Returns false if the key length is not supported, or the key is somehow "weak" and unusable by this cipher.
+

Use clear() or the destructor to remove the key and any other sensitive data from the object once encryption or decryption is complete.

+

Calling setKey() resets the cipher. Any temporary data that was being retained for encrypting partial blocks will be abandoned.

+
See Also
keySize(), clear()
+ +

Implements Cipher.

+ +

Definition at line 73 of file EAX.cpp.

+ +
+
+ +
+
+ + + + + +
+ + + + + + + +
size_t EAXCommon::tagSize () const
+
+virtual
+
+ +

Returns the size of the authentication tag.

+
Returns
The size of the authentication tag in bytes.
+

By default this function should return the largest tag size supported by the authenticated cipher.

+
See Also
computeTag()
+ +

Implements AuthenticatedCipher.

+ +

Definition at line 67 of file EAX.cpp.

+ +
+
+
The documentation for this class was generated from the following files: +
+ + + + diff --git a/classEAXCommon.png b/classEAXCommon.png new file mode 100644 index 00000000..c0c29688 Binary files /dev/null and b/classEAXCommon.png differ diff --git a/classEEPROM24-members.html b/classEEPROM24-members.html index efe962e0..002e2019 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 d9bf73db..2a093354 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 2aeecaf4..a45d697c 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 157d3a07..3ba08741 100644 --- a/classEd25519.html +++ b/classEd25519.html @@ -354,7 +354,7 @@ Static Public Member Functions diff --git a/classField-members.html b/classField-members.html index f6486cc7..a73c694a 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 d4d080ee..a277e4f1 100644 --- a/classField.html +++ b/classField.html @@ -424,7 +424,7 @@ class Form diff --git a/classForm-members.html b/classForm-members.html index 9ecc3de9..11a5b1b3 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 809ed08a..ae6d5bd2 100644 --- a/classForm.html +++ b/classForm.html @@ -485,7 +485,7 @@ class Field diff --git a/classGCM-members.html b/classGCM-members.html index 15dd61f0..6ca8bacd 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 17e39323..463675e0 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 e3d76c1f..6aba218d 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 5722b8cb..341ba8c0 100644 --- a/classGCMCommon.html +++ b/classGCMCommon.html @@ -725,7 +725,7 @@ Protected Member Functions

Implements AuthenticatedCipher.

-

Definition at line 71 of file GCM.cpp.

+

Definition at line 72 of file GCM.cpp.

@@ -736,7 +736,7 @@ Protected Member Functions diff --git a/classGHASH-members.html b/classGHASH-members.html index 3ff5c23e..8b3f124b 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 254bc581..f7f1d280 100644 --- a/classGHASH.html +++ b/classGHASH.html @@ -265,7 +265,7 @@ void  diff --git a/classHash-members.html b/classHash-members.html index b910e544..cf711bd1 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 09d9ebb9..052cb6cb 100644 --- a/classHash.html +++ b/classHash.html @@ -104,11 +104,10 @@ Inheritance diagram for Hash: BLAKE2b BLAKE2s -SHA1 -SHA256 -SHA3_256 -SHA3_512 -SHA512 +SHA256 +SHA3_256 +SHA3_512 +SHA512 @@ -154,7 +153,7 @@ Protected Member Functions

Detailed Description

Abstract base class for cryptographic hash algorithms.

-
See Also
SHA1, SHA256
+
See Also
SHA256, SHA3_256, BLAKE2s

Definition at line 29 of file Hash.h.

Constructor & Destructor Documentation

@@ -212,7 +211,7 @@ Protected Member Functions

Size of the internal block used by the hash algorithm.

See Also
update(), hashSize()
-

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

+

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

@@ -240,7 +239,7 @@ Protected Member Functions

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

See Also
reset()
-

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

+

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

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

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

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

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

+

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

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

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

+

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

@@ -436,7 +435,7 @@ Protected Member Functions

Size of the hash result from finalize().

See Also
finalize(), blockSize()
-

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

+

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

@@ -464,7 +463,7 @@ Protected Member Functions

Resets the hash ready for a new hashing process.

See Also
update(), finalize(), resetHMAC()
-

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

+

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

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

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

See Also
finalizeHMAC(), reset()
-

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

+

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

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

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

See Also
reset(), finalize()
-

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

+

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

@@ -576,7 +575,7 @@ Protected Member Functions diff --git a/classHash.png b/classHash.png index 9324f7da..92917b4e 100644 Binary files a/classHash.png and b/classHash.png differ diff --git a/classI2CMaster-members.html b/classI2CMaster-members.html index 4fc8fc2a..fe32c131 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 e07338cf..e8824357 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 ff257a6b..8c61eeac 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 a21346b9..38a49001 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 31c3a5b8..7ef8fe1a 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 081380b2..e0e98a37 100644 --- a/classIntField.html +++ b/classIntField.html @@ -647,7 +647,7 @@ LiquidCrystal *  diff --git a/classKeccakCore-members.html b/classKeccakCore-members.html index 17604277..b46fe3b5 100644 --- a/classKeccakCore-members.html +++ b/classKeccakCore-members.html @@ -91,24 +91,23 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');

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

- - - - - - - - - - - - - - + + + + + + + + + + + + +
A (defined in KeccakCore)KeccakCore
B (defined in KeccakCore)KeccakCore
blockSize() const KeccakCoreinline
capacity() const KeccakCore
clear()KeccakCore
extract(void *data, size_t size)KeccakCore
inputSize (defined in KeccakCore)KeccakCore
KeccakCore()KeccakCore
outputSize (defined in KeccakCore)KeccakCore
pad(uint8_t tag)KeccakCore
reset()KeccakCore
setCapacity(size_t capacity)KeccakCore
setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)KeccakCore
update(const void *data, size_t size)KeccakCore
~KeccakCore()KeccakCore
blockSize() const KeccakCoreinline
capacity() const KeccakCore
clear()KeccakCore
extract(void *data, size_t size)KeccakCore
inputSize (defined in KeccakCore)KeccakCore
KeccakCore()KeccakCore
outputSize (defined in KeccakCore)KeccakCore
pad(uint8_t tag)KeccakCore
reset()KeccakCore
setCapacity(size_t capacity)KeccakCore
setHMACKey(const void *key, size_t len, uint8_t pad, size_t hashSize)KeccakCore
update(const void *data, size_t size)KeccakCore
~KeccakCore()KeccakCore
diff --git a/classKeccakCore.html b/classKeccakCore.html index 2c057de8..df4d18b2 100644 --- a/classKeccakCore.html +++ b/classKeccakCore.html @@ -158,7 +158,7 @@ void capacity() will initially be set to 1536, which normally won't be of much use to the caller. The constructor should be followed by a call to setCapacity() to select the capacity of interest.

-

Definition at line 49 of file KeccakCore.cpp.

+

Definition at line 54 of file KeccakCore.cpp.

@@ -208,7 +208,7 @@ void 
See Also
setCapacity(), blockSize()
-

Definition at line 71 of file KeccakCore.cpp.

+

Definition at line 76 of file KeccakCore.cpp.

@@ -247,7 +247,7 @@ void blockSize() bytes are required, the sponge function will be invoked to generate additional data.

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

Definition at line 201 of file KeccakCore.cpp.

+

Definition at line 194 of file KeccakCore.cpp.

@@ -275,7 +275,7 @@ void 
See Also
update(), extract()
-

Definition at line 174 of file KeccakCore.cpp.

+

Definition at line 167 of file KeccakCore.cpp.

@@ -295,7 +295,7 @@ void 
See Also
update(), extract()
-

Definition at line 109 of file KeccakCore.cpp.

+

Definition at line 114 of file KeccakCore.cpp.

@@ -323,7 +323,7 @@ void 
Note
It is possible to create a sponge function with this constructor that doesn't strictly conform with the capacity and hash size constraints defined in the relevant standards. It is the responsibility of callers to only use standard parameter combinations.
See Also
capacity(), blockSize()
-

Definition at line 89 of file KeccakCore.cpp.

+

Definition at line 94 of file KeccakCore.cpp.

@@ -375,7 +375,7 @@ void Hash::resetHMAC() and Hash::finalizeHMAC() by directly formatting the HMAC key into the internal block buffer and resetting the hash.

-

Definition at line 263 of file KeccakCore.cpp.

+

Definition at line 243 of file KeccakCore.cpp.

@@ -414,7 +414,7 @@ void blockSize() bytes of input data have been accumulated. Call pad() after the last block to finalize the input before calling extract().

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

Definition at line 128 of file KeccakCore.cpp.

+

Definition at line 133 of file KeccakCore.cpp.

@@ -425,7 +425,7 @@ void  diff --git a/classLCD-members.html b/classLCD-members.html index 3bf965f9..2ed20ff7 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 845740ef..39ca7fa0 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 ec48abf0..5ca0542c 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 d672ec9e..c69314ef 100644 --- a/classListField.html +++ b/classListField.html @@ -411,7 +411,7 @@ LiquidCrystal *  diff --git a/classMelody-members.html b/classMelody-members.html index 97737e95..bbc1916f 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 60ab731a..2700bed7 100644 --- a/classMelody.html +++ b/classMelody.html @@ -371,7 +371,7 @@ bool  diff --git a/classNoiseSource-members.html b/classNoiseSource-members.html index 9d6699a0..52b0b3bb 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 608a5aa7..6cc99925 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 ed161d3a..ecb3def8 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 29a3542f..6c75248c 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 cc8bec1c..814ca717 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 5c5cb936..e23c4c5d 100644 --- a/classOFBCommon.html +++ b/classOFBCommon.html @@ -534,7 +534,7 @@ Protected Member Functions diff --git a/classPoly1305-members.html b/classPoly1305-members.html index 46ebd2bd..7c685429 100644 --- a/classPoly1305-members.html +++ b/classPoly1305-members.html @@ -99,13 +99,12 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); Poly1305()Poly1305 r (defined in Poly1305)Poly1305 reset(const void *key)Poly1305 - t (defined in Poly1305)Poly1305 - update(const void *data, size_t len)Poly1305 - ~Poly1305()Poly1305 + update(const void *data, size_t len)Poly1305 + ~Poly1305()Poly1305 diff --git a/classPoly1305.html b/classPoly1305.html index c22af4f5..0c3a18e3 100644 --- a/classPoly1305.html +++ b/classPoly1305.html @@ -203,7 +203,7 @@ void 
See Also
update()
-

Definition at line 250 of file Poly1305.cpp.

+

Definition at line 251 of file Poly1305.cpp.

@@ -280,7 +280,7 @@ void  diff --git a/classRNGClass-members.html b/classRNGClass-members.html index 836d7a49..e1ac6a46 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 975e4e0b..47fe9e9d 100644 --- a/classRNGClass.html +++ b/classRNGClass.html @@ -212,7 +212,7 @@ static const int begin() to properly initialize the random number generator.

See Also
begin()
-

Definition at line 182 of file RNG.cpp.

+

Definition at line 230 of file RNG.cpp.

@@ -241,7 +241,7 @@ static const int NoiseSource::stir() directly.

See Also
loop(), begin()
-

Definition at line 379 of file RNG.cpp.

+

Definition at line 459 of file RNG.cpp.

@@ -284,7 +284,7 @@ static const int 
See Also
rand()
-

Definition at line 505 of file RNG.cpp.

+

Definition at line 585 of file RNG.cpp.

@@ -324,7 +324,7 @@ static const int 
See Also
addNoiseSource(), stir(), save()
-

Definition at line 296 of file RNG.cpp.

+

Definition at line 359 of file RNG.cpp.

@@ -347,7 +347,7 @@ static const int 
Note
The rand() and save() functions take some care to manage the random number pool in a way that makes prediction of past outputs from a captured state very difficult. Future outputs may be predictable if noise or other high-entropy data is not mixed in with stir() on a regular basis.
See Also
begin()
-

Definition at line 698 of file RNG.cpp.

+

Definition at line 806 of file RNG.cpp.

@@ -367,7 +367,7 @@ static const int  -

Definition at line 635 of file RNG.cpp.

+

Definition at line 715 of file RNG.cpp.

@@ -407,7 +407,7 @@ static const int available() function can be polled to determine when sufficient entropy is available.

See Also
available(), stir()
-

Definition at line 428 of file RNG.cpp.

+

Definition at line 508 of file RNG.cpp.

@@ -431,7 +431,7 @@ static const int stir() in new noise data at startup.

See Also
loop(), stir()
-

Definition at line 607 of file RNG.cpp.

+

Definition at line 687 of file RNG.cpp.

@@ -460,7 +460,7 @@ static const int 
See Also
save(), stir()
-

Definition at line 404 of file RNG.cpp.

+

Definition at line 484 of file RNG.cpp.

@@ -508,7 +508,7 @@ static const int 
See Also
loop()
-

Definition at line 538 of file RNG.cpp.

+

Definition at line 618 of file RNG.cpp.

@@ -519,7 +519,7 @@ static const int  diff --git a/classRTC-members.html b/classRTC-members.html index fc01cf6e..d415e608 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 567c9e37..db18f5f8 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 65d15a30..a1c7ee65 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 cadee281..58028c8b 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 e4d37463..17beac69 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 b8071b93..21e465e7 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 589284b1..9bc0371c 100644 --- a/classRingOscillatorNoiseSource.html +++ b/classRingOscillatorNoiseSource.html @@ -253,7 +253,7 @@ Additional Inherited Members diff --git a/classSHA1-members.html b/classSHA1-members.html deleted file mode 100644 index eb40d872..00000000 --- a/classSHA1-members.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - -ArduinoLibs: Member List - - - - - - - - - -
-
- - - - - - -
-
ArduinoLibs -
-
-
- - - - - - - - - -
- -
- -
-
-
-
SHA1 Member List
-
-
- -

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

- - - - - - - - - - - - - - - - - - -
blockSize() const SHA1virtual
chunkSize (defined in SHA1)SHA1
clear()SHA1virtual
finalize(void *hash, size_t len)SHA1virtual
finalizeHMAC(const void *key, size_t keyLen, void *hash, size_t hashLen)SHA1virtual
formatHMACKey(void *block, const void *key, size_t len, uint8_t pad)Hashprotected
h (defined in SHA1)SHA1
Hash()Hash
hashSize() const SHA1virtual
length (defined in SHA1)SHA1
reset()SHA1virtual
resetHMAC(const void *key, size_t keyLen)SHA1virtual
SHA1()SHA1
update(const void *data, size_t len)SHA1virtual
w (defined in SHA1)SHA1
~Hash()Hashvirtual
~SHA1()SHA1virtual
- - - - diff --git a/classSHA1.html b/classSHA1.html deleted file mode 100644 index 3ac73def..00000000 --- a/classSHA1.html +++ /dev/null @@ -1,514 +0,0 @@ - - - - - - -ArduinoLibs: SHA1 Class Reference - - - - - - - - - -
-
- - - - - - -
-
ArduinoLibs -
-
-
- - - - - - - - - -
- -
- -
-
- -
-
SHA1 Class Reference
-
-
- -

SHA-1 hash algorithm. - More...

- -

#include <SHA1.h>

-
-Inheritance diagram for SHA1:
-
-
- - -Hash - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

-Public Member Functions

SHA1 ()
 Constructs a SHA-1 hash object.
 
-virtual ~SHA1 ()
 Destroys this SHA-1 hash object after clearing sensitive information.
 
size_t hashSize () const
 Size of the hash result from finalize(). More...
 
size_t blockSize () const
 Size of the internal block used by the hash algorithm. More...
 
void reset ()
 Resets the hash ready for a new hashing process. More...
 
void update (const void *data, size_t len)
 Updates the hash with more data. More...
 
void finalize (void *hash, size_t len)
 Finalizes the hashing process and returns the hash. More...
 
void clear ()
 Clears the hash state, removing all sensitive data, and then resets the hash ready for a new hashing process. More...
 
void resetHMAC (const void *key, size_t keyLen)
 Resets the hash ready for a new HMAC hashing process. More...
 
void finalizeHMAC (const void *key, size_t keyLen, void *hash, size_t hashLen)
 Finalizes the HMAC hashing process and returns the hash. More...
 
- Public Member Functions inherited from Hash
Hash ()
 Constructs a new hash object.
 
virtual ~Hash ()
 Destroys this hash object. More...
 
- - - - - -

-Additional Inherited Members

- Protected Member Functions inherited from Hash
void formatHMACKey (void *block, const void *key, size_t len, uint8_t pad)
 Formats a HMAC key into a block. More...
 
-

Detailed Description

-

SHA-1 hash algorithm.

-

Reference: http://en.wikipedia.org/wiki/SHA-1

-
See Also
SHA256, SHA512
- -

Definition at line 28 of file SHA1.h.

-

Member Function Documentation

- -
-
- - - - - -
- - - - - - - -
size_t SHA1::blockSize () const
-
-virtual
-
- -

Size of the internal block used by the hash algorithm.

-
See Also
update(), hashSize()
- -

Implements Hash.

- -

Definition at line 59 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - -
void SHA1::clear ()
-
-virtual
-
- -

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

-
See Also
reset()
- -

Implements Hash.

- -

Definition at line 128 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
void SHA1::finalize (void * hash,
size_t len 
)
-
-virtual
-
- -

Finalizes the hashing process and returns the hash.

-
Parameters
- - - -
hashThe buffer to return the hash value in.
lenThe length of the hash buffer, normally hashSize().
-
-
-

If len is less than hashSize(), then the hash value will be truncated to the first len bytes. If len is greater than hashSize(), then the remaining bytes will left unchanged.

-

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

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

Implements Hash.

- -

Definition at line 97 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void SHA1::finalizeHMAC (const void * key,
size_t keyLen,
void * hash,
size_t hashLen 
)
-
-virtual
-
- -

Finalizes the HMAC hashing process and returns the hash.

-
Parameters
- - - - - -
keyPoints to the HMAC key for the hashing process. The contents of this array must be identical to the value passed to resetHMAC().
keyLenSize of the HMAC key in bytes.
hashThe buffer to return the hash value in.
hashLenThe length of the hash buffer, normally hashSize().
-
-
-
See Also
resetHMAC(), finalize()
- -

Implements Hash.

- -

Definition at line 141 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - -
size_t SHA1::hashSize () const
-
-virtual
-
- -

Size of the hash result from finalize().

-
See Also
finalize(), blockSize()
- -

Implements Hash.

- -

Definition at line 54 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - -
void SHA1::reset ()
-
-virtual
-
- -

Resets the hash ready for a new hashing process.

-
See Also
update(), finalize(), resetHMAC()
- -

Implements Hash.

- -

Definition at line 64 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
void SHA1::resetHMAC (const void * key,
size_t keyLen 
)
-
-virtual
-
- -

Resets the hash ready for a new HMAC hashing process.

-
Parameters
- - - -
keyPoints to the HMAC key for the hashing process.
keyLenSize of the HMAC key in bytes.
-
-
-

The following example computes a HMAC over a series of data blocks with a specific key:

-
hash.resetHMAC(key, sizeof(key));
-
hash.update(data1, sizeof(data1));
-
hash.update(data2, sizeof(data2));
-
...
-
hash.update(dataN, sizeof(dataN));
-
hash.finalizeHMAC(key, sizeof(key), hmac, sizeof(hmac));
-

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

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

Implements Hash.

- -

Definition at line 134 of file SHA1.cpp.

- -
-
- -
-
- - - - - -
- - - - - - - - - - - - - - - - - - -
void SHA1::update (const void * data,
size_t len 
)
-
-virtual
-
- -

Updates the hash with more data.

-
Parameters
- - - -
dataData to be hashed.
lenNumber of bytes of data to be hashed.
-
-
-

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

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

Implements Hash.

- -

Definition at line 75 of file SHA1.cpp.

- -
-
-
The documentation for this class was generated from the following files: -
- - - - diff --git a/classSHA1.png b/classSHA1.png deleted file mode 100644 index c68d93bd..00000000 Binary files a/classSHA1.png and /dev/null differ diff --git a/classSHA256-members.html b/classSHA256-members.html index 75d27f94..e0d65b5e 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 00a1b4d8..dc54c31d 100644 --- a/classSHA256.html +++ b/classSHA256.html @@ -158,7 +158,7 @@ Additional Inherited Members

Detailed Description

SHA-256 hash algorithm.

Reference: http://en.wikipedia.org/wiki/SHA-2

-
See Also
SHA512, SHA1, BLAKE2s
+
See Also
SHA512, SHA3_256, BLAKE2s

Definition at line 28 of file SHA256.h.

Member Function Documentation

@@ -506,7 +506,7 @@ Additional Inherited Members diff --git a/classSHA3__256-members.html b/classSHA3__256-members.html index 10d28ece..680fdd20 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 5ae57deb..9d731ad0 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 8888cbfc..7e9408fe 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 92e29ff6..b7677c15 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 a09ee1b7..0905602d 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 bce3479a..811f26be 100644 --- a/classSHA512.html +++ b/classSHA512.html @@ -165,7 +165,7 @@ Additional Inherited Members

Detailed Description

SHA-512 hash algorithm.

Reference: http://en.wikipedia.org/wiki/SHA-2

-
See Also
SHA256, SHA1
+
See Also
SHA256, SHA3_512, BLAKE2b

Definition at line 30 of file SHA512.h.

Member Function Documentation

@@ -513,7 +513,7 @@ Additional Inherited Members diff --git a/classSoftI2C-members.html b/classSoftI2C-members.html index e5b1b74c..a839f9c4 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 4b6cd6ac..c0fb66fe 100644 --- a/classSoftI2C.html +++ b/classSoftI2C.html @@ -346,7 +346,7 @@ unsigned int  diff --git a/classSpeck-members.html b/classSpeck-members.html index 9f41cd77..edc21fe1 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 0811ee51..bea388ec 100644 --- a/classSpeck.html +++ b/classSpeck.html @@ -415,7 +415,7 @@ Public Member Functions diff --git a/classSpeckLowMemory-members.html b/classSpeckLowMemory-members.html index 72b8cb49..9f22fa55 100644 --- a/classSpeckLowMemory-members.html +++ b/classSpeckLowMemory-members.html @@ -103,7 +103,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/classSpeckLowMemory.html b/classSpeckLowMemory.html index 53fd377a..ead14ce6 100644 --- a/classSpeckLowMemory.html +++ b/classSpeckLowMemory.html @@ -419,7 +419,7 @@ Public Member Functions diff --git a/classTextField-members.html b/classTextField-members.html index 6123006e..70a3b445 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 c3e53d70..da062e64 100644 --- a/classTextField.html +++ b/classTextField.html @@ -343,7 +343,7 @@ LiquidCrystal *  diff --git a/classTimeField-members.html b/classTimeField-members.html index 1118d044..4745d68e 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 25385f55..71448827 100644 --- a/classTimeField.html +++ b/classTimeField.html @@ -541,7 +541,7 @@ LiquidCrystal *  diff --git a/classTransistorNoiseSource-members.html b/classTransistorNoiseSource-members.html index 27ab6e68..6441770b 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 aef02892..97b3de4a 100644 --- a/classTransistorNoiseSource.html +++ b/classTransistorNoiseSource.html @@ -280,7 +280,7 @@ Additional Inherited Members diff --git a/classes.html b/classes.html index caff8127..eb4ef028 100644 --- a/classes.html +++ b/classes.html @@ -90,50 +90,53 @@ 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
- - - - - + - + + + + + - - - - - - - - + + + - - + - - + + + + + + + + + +
  A  
-
CFB   
  F  
-
  L  
-
RNGClass   
CFBCommon   RTC   
AES128   ChaCha   Field   LCD   RTCAlarm   
AES192   ChaChaPoly   Form   ListField   RTCDate   
AES256   Charlieplex   
  G  
-
  M  
-
RTCTime   
AESCommon   ChaseLEDs   
  S  
+
CFBCommon   
  F  
+
ListField   RTCTime   
ChaCha   
  M  
+
  S  
AuthenticatedCipher   Cipher   GCM   Melody   
AES128   ChaChaPoly   Field   
AES192   Charlieplex   Form   Melody   SHA256   
AES256   ChaseLEDs   
  G  
+
  N  
+
SHA3_256   
AESCommon   Cipher   SHA3_512   
AuthenticatedCipher   CTR   GCM   NoiseSource   SHA512   
  B  
-
CTR   GCMCommon   
  N  
-
SHA1   
CTRCommon   GHASH   SHA256   
BigNumberUtil   Curve25519   
  H  
-
NoiseSource   SHA3_256   
Bitmap   
  D  
-
  O  
-
SHA3_512   
BLAKE2b   Hash   SHA512   
BLAKE2s   DMD   
  I  
-
OFB   SoftI2C   
BlinkLED   DS1307RTC   OFBCommon   Speck   
BlockCipher   DS3231RTC   I2CMaster   
  P  
-
SpeckLowMemory   
BoolField   DS3232RTC   IntField   
  T  
+
CTRCommon   GCMCommon   
  O  
+
SoftI2C   
Curve25519   GHASH   Speck   
BigNumberUtil   
  D  
+
  H  
+
OFB   SpeckLowMemory   
Bitmap   OFBCommon   
  T  
  C  
-
  E  
-
IRreceiver   Poly1305   
  K  
-
  R  
+
BLAKE2b   DMD   Hash   
  P  
+
BLAKE2s   DS1307RTC   
  I  
TextField   
CBC   Ed25519   TimeField   
CBCCommon   EEPROM24   KeccakCore   RingOscillatorNoiseSource   TransistorNoiseSource   
BlinkLED   DS3231RTC   Poly1305   TimeField   
BlockCipher   DS3232RTC   I2CMaster   
  R  
+
TransistorNoiseSource   
BoolField   
  E  
+
IntField   
  C  
+
IRreceiver   RingOscillatorNoiseSource   
EAX   
  K  
+
RNGClass   
CBC   EAXCommon   RTC   
CBCCommon   Ed25519   KeccakCore   RTCAlarm   
CFB   EEPROM24   
  L  
+
RTCDate   
LCD   
A | B | C | D | E | F | G | H | I | K | L | M | N | O | P | R | S | T
diff --git a/crypto-rng-ring_8dox.html b/crypto-rng-ring_8dox.html index 7c989fb5..0811a1f4 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 8a377101..fd16d467 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 e4a40196..27d97c03 100644 --- a/crypto.html +++ b/crypto.html @@ -85,13 +85,13 @@ Supported Algorithms
  • Block ciphers: AES128, AES192, AES256, Speck
  • Block cipher modes: CTR, CFB, CBC, OFB, GCM
  • Stream ciphers: ChaCha
  • -
  • Authenticated encryption with associated data (AEAD): ChaChaPoly, GCM
  • -
  • Hash algorithms: SHA1, SHA256, SHA512, SHA3_256, SHA3_512, BLAKE2s, BLAKE2b (regular and HMAC modes)
  • +
  • Authenticated encryption with associated data (AEAD): ChaChaPoly, EAX, GCM
  • +
  • Hash algorithms: SHA256, SHA512, SHA3_256, SHA3_512, BLAKE2s, BLAKE2b (regular and HMAC modes)
  • Message authenticators: Poly1305, GHASH
  • Public key algorithms: Curve25519, Ed25519
  • 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 SHA1, SHA256, and SHA512 which save 256, 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.

    +

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

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

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

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

    @@ -109,11 +109,11 @@ Performance on AVR Encryption AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes) -AES128 (ECB mode)36.90us66.48us160.00us213 +AES128 (ECB mode)33.28us63.18us160.00us181 -AES192 (ECB mode)44.20us80.35us166.54us245 +AES192 (ECB mode)39.94us76.48us166.54us213 -AES256 (ECB mode)51.50us94.22us227.97us277 +AES256 (ECB mode)46.61us89.78us227.97us245 ChaCha (20 rounds)14.87us14.88us43.74us132 @@ -137,43 +137,45 @@ Performance on AVR AEAD AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes) -ChaChaPoly41.23us41.23us902.55us255 +ChaChaPoly41.20us41.19us902.36us221 -GCM<AES128>186.47us186.42us1388.43us316 +GCM<AES128>183.25us182.80us1272.73us284 -GCM<AES192>194.17us193.72us1628.67us348 +GCM<AES192>189.92us189.47us1492.60us316 -GCM<AES256>201.47us201.02us1923.78us380 +GCM<AES256>196.59us196.13us1767.33us348 + +EAX<AES128>71.14us71.14us1329.44us268 + +EAX<Speck> (128-bit key)26.01us26.01us735.46us362 + +EAX<SpeckLowMemory> (128-bit key)75.08us75.07us1243.66us122 Hash AlgorithmHashing (per byte)FinalizationState Size (bytes) -SHA121.90us1423.28us95 - SHA25643.85us2841.04us107 SHA512122.82us15953.42us211 -SHA3_256121.69us16486.33us405 +SHA3_25660.69us8180.24us205 -SHA3_512229.12us16502.34us405 +SHA3_512113.88us8196.34us205 -BLAKE2s18.54us1200.06us171 +BLAKE2s20.65us1335.25us107 -BLAKE2b50.70us6515.87us339 +BLAKE2b65.22us8375.36us211 Authentication AlgorithmHashing (per byte)FinalizationKey SetupState Size (bytes) -SHA1 (HMAC mode)21.90us4296.33us1420.24us95 - SHA256 (HMAC mode)43.85us8552.61us2836.49us107 -BLAKE2s (HMAC mode)18.54us3649.98us1214.81us171 +BLAKE2s (HMAC mode)20.65us4055.56us1350.00us107 -Poly130526.29us486.15us17.26us87 +Poly130526.26us489.11us17.06us53 GHASH148.14us17.09us21.87us33 @@ -201,11 +203,11 @@ Performance on ARM Encryption AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes) -AES128 (ECB mode)6.65us11.00us35.15us220 +AES128 (ECB mode)5.71us10.41us34.73us188 -AES192 (ECB mode)8.02us13.31us36.59us252 +AES192 (ECB mode)6.87us12.57us36.51us220 -AES256 (ECB mode)9.39us15.6350.19us284 +AES256 (ECB mode)8.04us14.7249.96us252 ChaCha (20 rounds)0.87us0.88us4.96us136 @@ -229,43 +231,45 @@ Performance on ARM AEAD AlgorithmEncryption (per byte)Decryption (per byte)Key SetupState Size (bytes) -ChaChaPoly1.66us1.66us45.02us280 +ChaChaPoly1.71us1.71us45.08us240 -GCM<AES128>11.01us10.92us247.90us344 +GCM<AES128>10.29us10.29us223.82us312 -GCM<AES192>12.40us12.31us294.07us376 +GCM<AES192>11.50us11.51us265.62us344 -GCM<AES256>13.73us13.64us347.40us408 +GCM<AES256>12.67us12.67us313.06us376 + +EAX<AES128>12.29us12.29us236.47us280 + +EAX<Speck> (128-bit key)2.65us2.65us79.46us384 + +EAX<SpeckLowMemory> (128-bit key)6.29us6.29us106.60us144 Hash AlgorithmHashing (per byte)FinalizationState Size (bytes) -SHA10.94us62.55us112 - SHA2561.15us76.60us120 SHA5122.87us370.37us224 -SHA3_2565.36us697.65us424 +SHA3_2565.64us735.29us224 -SHA3_5129.89us697.81us424 +SHA3_51210.42us735.49us224 -BLAKE2s0.76us50.88us184 +BLAKE2s0.72us48.24us120 -BLAKE2b1.33us170.93us352 +BLAKE2b1.29us165.28us224 Authentication AlgorithmHashing (per byte)FinalizationKey SetupState Size (bytes) -SHA1 (HMAC mode)0.94us193.92us65.09us112 - SHA256 (HMAC mode)1.15us238.98us80.44us120 -BLAKE2s (HMAC mode)0.76us165.64us59.92us184 +BLAKE2s (HMAC mode)0.72us157.75us57.18us120 -Poly13050.85us19.25us2.35us96 +Poly13050.81us19.01us2.57us60 GHASH4.37us1.50us4.37us36 @@ -288,7 +292,7 @@ Performance on ARM diff --git a/crypto_8dox.html b/crypto_8dox.html index 07edb915..99f59543 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 8fdd3001..4ee3c51b 100644 --- a/crypto_rng.html +++ b/crypto_rng.html @@ -103,6 +103,12 @@ Standard noise sources

    The transistor design needs an input voltage of 10 to 15 VDC to trigger the avalanche effect, which can sometimes be difficult in a 5V Arduino environment. The ring oscillator design can run at 5V but the quality of the noise is less than for the transistor design. The RingOscillatorNoiseSource class attempts to make up for this by collecting more input bits for the same amount of output entropy. See this page for more information on ring oscillators.

    For both of the standard noise sources, the system should have enough entropy to safely generate 256 bits of key material about 3 to 4 seconds after startup. This is sufficient to create a private key for Curve25519 for example.

    If you are unsure which noise source to use, then I suggest TransistorNoiseSource as Rob's design has had more review. Another approach is to mix multiple noise sources together to get the best of both worlds.

    +

    +Built-in entropy sources

    +

    Some entropy sources are built in and do not need to be provided via a NoiseSource object.

    +

    On the Arduino Due, the built-in True Random Number Generator (TRNG) is used to seed the random number generator in addition to any configured noise sources.

    +

    On AVR-based Arduino platforms (Uno, Nano, Mega, etc), jitter between the watchdog timer and the main CPU clock is used to harvest some entropy using a technique similar to that described here. This is not a high quality source of entropy but it is "better than nothing" if an external noise source is not available or practical. Entropy accumulates very slowly and it could take several minutes before the state is sufficiently random for safe use.

    +

    For security-critical applications it is very important to combine the built-in entropy sources with an external noise source.

    Initializing the random number generator

    To use the random number generator, both RNG and a noise source must first be initialized. We start by including the necessary libraries:

    @@ -184,7 +190,7 @@ Destroying secret data diff --git a/crypto_rng_ring.html b/crypto_rng_ring.html index ce003cbb..9afcd255 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 2a94585c..9ed82265 100644 --- a/dir_1586d320a3b1e622174530fde769cda9.html +++ b/dir_1586d320a3b1e622174530fde769cda9.html @@ -102,7 +102,7 @@ Files diff --git a/dir_3dd03323535933fb3f714c41ff7a94da.html b/dir_3dd03323535933fb3f714c41ff7a94da.html index 94b68de1..8a4de2aa 100644 --- a/dir_3dd03323535933fb3f714c41ff7a94da.html +++ b/dir_3dd03323535933fb3f714c41ff7a94da.html @@ -94,7 +94,7 @@ Files diff --git a/dir_48f64e79f12bd77ba047e9e436ec978c.html b/dir_48f64e79f12bd77ba047e9e436ec978c.html index dc34f8ff..f773f9a4 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 01377ff4..c63d2358 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 8cf1cfc0..a04af41e 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 d8178f9b..9e39f71f 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 8d8eae7d..214a0f86 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 479263a7..46829e78 100644 --- a/dir_bc0718b08fb2015b8e59c47b2805f60c.html +++ b/dir_bc0718b08fb2015b8e59c47b2805f60c.html @@ -112,7 +112,7 @@ Directories diff --git a/dir_be059bf9978ae156837504b1b8a7568c.html b/dir_be059bf9978ae156837504b1b8a7568c.html index 4fe6ff91..0720e79a 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 a0fcce9a..ec7a328a 100644 --- a/dir_e2ce51835550ba18edf07a8311722290.html +++ b/dir_e2ce51835550ba18edf07a8311722290.html @@ -148,6 +148,10 @@ Files   file  Curve25519.h [code]   +file  EAX.cpp [code] +  +file  EAX.h [code] +  file  Ed25519.cpp [code]   file  Ed25519.h [code] @@ -184,10 +188,6 @@ Files   file  RNG.h [code]   -file  SHA1.cpp [code] -  -file  SHA1.h [code] -  file  SHA256.cpp [code]   file  SHA256.h [code] @@ -212,7 +212,7 @@ Files diff --git a/dir_f34881fcf60f680b800190d5274dfaea.html b/dir_f34881fcf60f680b800190d5274dfaea.html index dd710d70..2793dfb8 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 21c842e6..4d161a8c 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 70f1a5f9..c1edf952 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 921a0a4a..2225bb44 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 5c6f1d41..d0d48aa0 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 01fac624..f564a97c 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 45028ddc..39043c74 100644 --- a/files.html +++ b/files.html @@ -138,52 +138,52 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); o*DS3231RTC.h o*DS3232RTC.cpp o*DS3232RTC.h -o*Ed25519.cpp -o*Ed25519.h -o*EEPROM24.cpp -o*EEPROM24.h -o*Field.cpp -o*Field.h -o*Form.cpp -o*Form.h -o*GCM.cpp -o*GCM.h -o*GHASH.cpp -o*GHASH.h -o*Hash.cpp -o*Hash.h -o*I2CMaster.cpp -o*I2CMaster.h -o*IntField.cpp -o*IntField.h -o*IRreceiver.cpp -o*IRreceiver.h -o*KeccakCore.cpp -o*KeccakCore.h -o*LCD.cpp -o*LCD.h -o*ListField.cpp -o*ListField.h -o*Melody.cpp -o*Melody.h -o*Mono5x7.h -o*NoiseSource.cpp -o*NoiseSource.h -o*OFB.cpp -o*OFB.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*SHA1.cpp -o*SHA1.h +o*EAX.cpp +o*EAX.h +o*Ed25519.cpp +o*Ed25519.h +o*EEPROM24.cpp +o*EEPROM24.h +o*Field.cpp +o*Field.h +o*Form.cpp +o*Form.h +o*GCM.cpp +o*GCM.h +o*GHASH.cpp +o*GHASH.h +o*Hash.cpp +o*Hash.h +o*I2CMaster.cpp +o*I2CMaster.h +o*IntField.cpp +o*IntField.h +o*IRreceiver.cpp +o*IRreceiver.h +o*KeccakCore.cpp +o*KeccakCore.h +o*LCD.cpp +o*LCD.h +o*ListField.cpp +o*ListField.h +o*Melody.cpp +o*Melody.h +o*Mono5x7.h +o*NoiseSource.cpp +o*NoiseSource.h +o*OFB.cpp +o*OFB.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 @@ -207,7 +207,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions.html b/functions.html index 97744c20..7208198a 100644 --- a/functions.html +++ b/functions.html @@ -132,6 +132,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • addAuthData() : AuthenticatedCipher , ChaChaPoly +, EAXCommon , GCMCommon
  • added() @@ -189,7 +190,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_b.html b/functions_b.html index 6d485140..499cdb36 100644 --- a/functions_b.html +++ b/functions_b.html @@ -163,7 +163,6 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , BlockCipher , Hash , KeccakCore -, SHA1 , SHA256 , SHA3_256 , SHA3_512 @@ -172,7 +171,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , SpeckLowMemory
  • BoolField() -: BoolField +: BoolField
  • byteCount() : DS1307RTC @@ -183,7 +182,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_c.html b/functions_c.html index 90845215..95b5dc95 100644 --- a/functions_c.html +++ b/functions_c.html @@ -161,6 +161,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • checkTag() : AuthenticatedCipher , ChaChaPoly +, EAXCommon , GCMCommon
  • Cipher() @@ -178,13 +179,13 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , ChaChaPoly , Cipher , CTRCommon +, EAXCommon , GCMCommon , GHASH , Hash , KeccakCore , OFBCommon , Poly1305 -, SHA1 , SHA256 , SHA3_256 , SHA3_512 @@ -201,6 +202,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search');
  • computeTag() : AuthenticatedCipher , ChaChaPoly +, EAXCommon , GCMCommon
  • copy() @@ -222,7 +224,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_d.html b/functions_d.html index 6a8f0f01..5edf8785 100644 --- a/functions_d.html +++ b/functions_d.html @@ -146,6 +146,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); , ChaChaPoly , Cipher , CTRCommon +, EAXCommon , GCMCommon , OFBCommon
  • @@ -229,7 +230,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : Bitmap
  • drawInvertedBitmap() -: Bitmap +: Bitmap
  • drawLine() : Bitmap @@ -238,7 +239,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); : Bitmap
  • drawText() -: Bitmap +: Bitmap
  • DS1307RTC() : DS1307RTC @@ -253,7 +254,7 @@ var searchBox = new SearchBox("searchBox", "search",false,'Search'); diff --git a/functions_e.html b/functions_e.html index f850ff83..44574634 100644 --- a/functions_e.html +++ b/functions_e.html @@ -123,6 +123,12 @@ 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:

    - e -