esp32_crypto_hash.c
Go to the documentation of this file.
1 /**
2  * @file esp32_crypto_hash.c
3  * @brief ESP32 hash hardware accelerator
4  *
5  * @section License
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  *
9  * Copyright (C) 2010-2025 Oryx Embedded SARL. All rights reserved.
10  *
11  * This file is part of CycloneCRYPTO Open.
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software Foundation,
25  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26  *
27  * @author Oryx Embedded SARL (www.oryx-embedded.com)
28  * @version 2.5.2
29  **/
30 
31 //Switch to the appropriate trace level
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
33 
34 //Dependencies
35 #include "esp_crypto_lock.h"
36 #include "hal/sha_types.h"
37 #include "soc/hwcrypto_reg.h"
38 #include "soc/dport_access.h"
39 #include "esp_private/periph_ctrl.h"
40 #include "core/crypto.h"
43 #include "hash/hash_algorithms.h"
44 #include "debug.h"
45 
46 //Check crypto library configuration
47 #if (ESP32_CRYPTO_HASH_SUPPORT == ENABLED)
48 
49 
50 /**
51  * @brief SHA module initialization
52  **/
53 
54 void esp32ShaInit(void)
55 {
56 }
57 
58 
59 /**
60  * @brief Process data block
61  * @param[in] algo Hash algorithm
62  * @param[in] data Pointer to the data block
63  * @param[in,out] first First message block
64  **/
65 
66 void hashProcessDataBlock(uint32_t algo, const uint8_t *data, bool_t *first)
67 {
68  uint32_t temp;
69 
70  //Write the block to be processed in the data registers
71  temp = LOAD32BE(data);
72  DPORT_REG_WRITE(SHA_TEXT_BASE, temp);
73  temp = LOAD32BE(data + 4);
74  DPORT_REG_WRITE(SHA_TEXT_BASE + 4, temp);
75  temp = LOAD32BE(data + 8);
76  DPORT_REG_WRITE(SHA_TEXT_BASE + 8, temp);
77  temp = LOAD32BE(data + 12);
78  DPORT_REG_WRITE(SHA_TEXT_BASE + 12, temp);
79  temp = LOAD32BE(data + 16);
80  DPORT_REG_WRITE(SHA_TEXT_BASE + 16, temp);
81  temp = LOAD32BE(data + 20);
82  DPORT_REG_WRITE(SHA_TEXT_BASE + 20, temp);
83  temp = LOAD32BE(data + 24);
84  DPORT_REG_WRITE(SHA_TEXT_BASE + 24, temp);
85  temp = LOAD32BE(data + 28);
86  DPORT_REG_WRITE(SHA_TEXT_BASE + 28, temp);
87  temp = LOAD32BE(data + 32);
88  DPORT_REG_WRITE(SHA_TEXT_BASE + 32, temp);
89  temp = LOAD32BE(data + 36);
90  DPORT_REG_WRITE(SHA_TEXT_BASE + 36, temp);
91  temp = LOAD32BE(data + 40);
92  DPORT_REG_WRITE(SHA_TEXT_BASE + 40, temp);
93  temp = LOAD32BE(data + 44);
94  DPORT_REG_WRITE(SHA_TEXT_BASE + 44, temp);
95  temp = LOAD32BE(data + 48);
96  DPORT_REG_WRITE(SHA_TEXT_BASE + 48, temp);
97  temp = LOAD32BE(data + 52);
98  DPORT_REG_WRITE(SHA_TEXT_BASE + 52, temp);
99  temp = LOAD32BE(data + 56);
100  DPORT_REG_WRITE(SHA_TEXT_BASE + 56, temp);
101  temp = LOAD32BE(data + 60);
102  DPORT_REG_WRITE(SHA_TEXT_BASE + 60, temp);
103 
104  //128-octet data block?
105  if(algo == SHA2_384 || algo == SHA2_512)
106  {
107  temp = LOAD32BE(data + 64);
108  DPORT_REG_WRITE(SHA_TEXT_BASE + 64, temp);
109  temp = LOAD32BE(data + 68);
110  DPORT_REG_WRITE(SHA_TEXT_BASE + 68, temp);
111  temp = LOAD32BE(data + 72);
112  DPORT_REG_WRITE(SHA_TEXT_BASE + 72, temp);
113  temp = LOAD32BE(data + 76);
114  DPORT_REG_WRITE(SHA_TEXT_BASE + 76, temp);
115  temp = LOAD32BE(data + 80);
116  DPORT_REG_WRITE(SHA_TEXT_BASE + 80, temp);
117  temp = LOAD32BE(data + 84);
118  DPORT_REG_WRITE(SHA_TEXT_BASE + 84, temp);
119  temp = LOAD32BE(data + 88);
120  DPORT_REG_WRITE(SHA_TEXT_BASE + 88, temp);
121  temp = LOAD32BE(data + 92);
122  DPORT_REG_WRITE(SHA_TEXT_BASE + 92, temp);
123  temp = LOAD32BE(data + 96);
124  DPORT_REG_WRITE(SHA_TEXT_BASE + 96, temp);
125  temp = LOAD32BE(data + 100);
126  DPORT_REG_WRITE(SHA_TEXT_BASE + 100, temp);
127  temp = LOAD32BE(data + 104);
128  DPORT_REG_WRITE(SHA_TEXT_BASE + 104, temp);
129  temp = LOAD32BE(data + 108);
130  DPORT_REG_WRITE(SHA_TEXT_BASE + 108, temp);
131  temp = LOAD32BE(data + 112);
132  DPORT_REG_WRITE(SHA_TEXT_BASE + 112, temp);
133  temp = LOAD32BE(data + 116);
134  DPORT_REG_WRITE(SHA_TEXT_BASE + 116, temp);
135  temp = LOAD32BE(data + 120);
136  DPORT_REG_WRITE(SHA_TEXT_BASE + 120, temp);
137  temp = LOAD32BE(data + 124);
138  DPORT_REG_WRITE(SHA_TEXT_BASE + 124, temp);
139  }
140 
141  //SHA-1, SHA-256, SHA-384 and SHA-512 algorithms use different control
142  //registers
143  if(algo == SHA1)
144  {
145  //Start SHA-1 operation
146  if(*first)
147  {
148  DPORT_REG_WRITE(SHA_1_START_REG, 1);
149  }
150  else
151  {
152  DPORT_REG_WRITE(SHA_1_CONTINUE_REG, 1);
153  }
154 
155  //Wait for the operation to complete
156  while(DPORT_REG_READ(SHA_1_BUSY_REG) != 0)
157  {
158  }
159  }
160  else if(algo == SHA2_256)
161  {
162  //Start SHA-256 operation
163  if(*first)
164  {
165  DPORT_REG_WRITE(SHA_256_START_REG, 1);
166  }
167  else
168  {
169  DPORT_REG_WRITE(SHA_256_CONTINUE_REG, 1);
170  }
171 
172  //Wait for the operation to complete
173  while(DPORT_REG_READ(SHA_256_BUSY_REG) != 0)
174  {
175  }
176  }
177  else if(algo == SHA2_384)
178  {
179  //Start SHA-384 operation
180  if(*first)
181  {
182  DPORT_REG_WRITE(SHA_384_START_REG, 1);
183  }
184  else
185  {
186  DPORT_REG_WRITE(SHA_384_CONTINUE_REG, 1);
187  }
188 
189  //Wait for the operation to complete
190  while(DPORT_REG_READ(SHA_384_BUSY_REG) != 0)
191  {
192  }
193  }
194  else
195  {
196  //Start SHA-512 operation
197  if(*first)
198  {
199  DPORT_REG_WRITE(SHA_512_START_REG, 1);
200  }
201  else
202  {
203  DPORT_REG_WRITE(SHA_512_CONTINUE_REG, 1);
204  }
205 
206  //Wait for the operation to complete
207  while(DPORT_REG_READ(SHA_512_BUSY_REG) != 0)
208  {
209  }
210  }
211 
212  //Process subsequent message blocks
213  *first = FALSE;
214 }
215 
216 
217 #if (SHA1_SUPPORT == ENABLED)
218 
219 /**
220  * @brief Digest a message using SHA-1
221  * @param[in] data Pointer to the message being hashed
222  * @param[in] length Length of the message
223  * @param[out] digest Pointer to the calculated digest
224  * @return Error code
225  **/
226 
227 error_t sha1Compute(const void *data, size_t length, uint8_t *digest)
228 {
229  bool_t first;
230  size_t n;
231  uint32_t temp;
232  uint8_t buffer[64];
233 
234  //Acquire exclusive access to the SHA module
235  esp_crypto_sha_aes_lock_acquire();
236  //Enable SHA module
237  periph_module_enable(PERIPH_SHA_MODULE);
238 
239  //Process the first message block
240  first = TRUE;
241 
242  //Digest the message
243  for(n = length; n >= 64; n -= 64)
244  {
245  //Update hash value
246  hashProcessDataBlock(SHA1, data, &first);
247  //Advance the data pointer
248  data = (uint8_t *) data + 64;
249  }
250 
251  //Copy the partial block, is any
252  osMemset(buffer, 0, 64);
253  osMemcpy(buffer, data, n);
254 
255  //Append the first byte of the padding string
256  buffer[n] = 0x80;
257 
258  //Pad the message so that its length is congruent to 56 modulo 64
259  if(n >= 56)
260  {
261  hashProcessDataBlock(SHA1, buffer, &first);
262  osMemset(buffer, 0, 64);
263  }
264 
265  //Append the length of the original message
266  STORE64BE(length * 8, buffer + 56);
267 
268  //Process the final block
269  hashProcessDataBlock(SHA1, buffer, &first);
270 
271  //Compute SHA-1 digest
272  DPORT_REG_WRITE(SHA_1_LOAD_REG, 1);
273 
274  //Wait for the operation to complete
275  while(DPORT_REG_READ(SHA_1_BUSY_REG) != 0)
276  {
277  }
278 
279  //Save the resulting hash value
280  DPORT_INTERRUPT_DISABLE();
281  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE);
282  STORE32BE(temp, digest);
283  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 4);
284  STORE32BE(temp, digest + 4);
285  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 8);
286  STORE32BE(temp, digest + 8);
287  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 12);
288  STORE32BE(temp, digest + 12);
289  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 16);
290  STORE32BE(temp, digest + 16);
291  DPORT_INTERRUPT_RESTORE();
292 
293  //Disable SHA module
294  periph_module_disable(PERIPH_SHA_MODULE);
295  //Release exclusive access to the SHA module
296  esp_crypto_sha_aes_lock_release();
297 
298  //Sucessful processing
299  return NO_ERROR;
300 }
301 
302 #endif
303 #if (SHA256_SUPPORT == ENABLED)
304 
305 /**
306  * @brief Digest a message using SHA-256
307  * @param[in] data Pointer to the message being hashed
308  * @param[in] length Length of the message
309  * @param[out] digest Pointer to the calculated digest
310  * @return Error code
311  **/
312 
313 error_t sha256Compute(const void *data, size_t length, uint8_t *digest)
314 {
315  bool_t first;
316  size_t n;
317  uint32_t temp;
318  uint8_t buffer[64];
319 
320  //Acquire exclusive access to the SHA module
321  esp_crypto_sha_aes_lock_acquire();
322  //Enable SHA module
323  periph_module_enable(PERIPH_SHA_MODULE);
324 
325  //Process the first message block
326  first = TRUE;
327 
328  //Digest the message
329  for(n = length; n >= 64; n -= 64)
330  {
331  //Update hash value
332  hashProcessDataBlock(SHA2_256, data, &first);
333  //Advance the data pointer
334  data = (uint8_t *) data + 64;
335  }
336 
337  //Copy the partial block, is any
338  osMemset(buffer, 0, 64);
339  osMemcpy(buffer, data, n);
340 
341  //Append the first byte of the padding string
342  buffer[n] = 0x80;
343 
344  //Pad the message so that its length is congruent to 56 modulo 64
345  if(n >= 56)
346  {
347  hashProcessDataBlock(SHA2_256, buffer, &first);
348  osMemset(buffer, 0, 64);
349  }
350 
351  //Append the length of the original message
352  STORE64BE(length * 8, buffer + 56);
353 
354  //Process the final block
355  hashProcessDataBlock(SHA2_256, buffer, &first);
356 
357  //Compute SHA-256 digest
358  DPORT_REG_WRITE(SHA_256_LOAD_REG, 1);
359 
360  //Wait for the operation to complete
361  while(DPORT_REG_READ(SHA_256_BUSY_REG) != 0)
362  {
363  }
364 
365  //Save the resulting hash value
366  DPORT_INTERRUPT_DISABLE();
367  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE);
368  STORE32BE(temp, digest);
369  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 4);
370  STORE32BE(temp, digest + 4);
371  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 8);
372  STORE32BE(temp, digest + 8);
373  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 12);
374  STORE32BE(temp, digest + 12);
375  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 16);
376  STORE32BE(temp, digest + 16);
377  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 20);
378  STORE32BE(temp, digest + 20);
379  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 24);
380  STORE32BE(temp, digest + 24);
381  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 28);
382  STORE32BE(temp, digest + 28);
383  DPORT_INTERRUPT_RESTORE();
384 
385  //Disable SHA module
386  periph_module_disable(PERIPH_SHA_MODULE);
387  //Release exclusive access to the SHA module
388  esp_crypto_sha_aes_lock_release();
389 
390  //Sucessful processing
391  return NO_ERROR;
392 }
393 
394 #endif
395 #if (SHA384_SUPPORT == ENABLED)
396 
397 /**
398  * @brief Digest a message using SHA-384
399  * @param[in] data Pointer to the message being hashed
400  * @param[in] length Length of the message
401  * @param[out] digest Pointer to the calculated digest
402  * @return Error code
403  **/
404 
405 error_t sha384Compute(const void *data, size_t length, uint8_t *digest)
406 {
407  bool_t first;
408  size_t n;
409  uint32_t temp;
410  uint8_t buffer[128];
411 
412  //Acquire exclusive access to the SHA module
413  esp_crypto_sha_aes_lock_acquire();
414  //Enable SHA module
415  periph_module_enable(PERIPH_SHA_MODULE);
416 
417  //Process the first message block
418  first = TRUE;
419 
420  //Digest the message
421  for(n = length; n >= 128; n -= 128)
422  {
423  //Update hash value
424  hashProcessDataBlock(SHA2_384, data, &first);
425  //Advance the data pointer
426  data = (uint8_t *) data + 128;
427  }
428 
429  //Copy the partial block, is any
430  osMemset(buffer, 0, 128);
431  osMemcpy(buffer, data, n);
432 
433  //Append the first byte of the padding string
434  buffer[n] = 0x80;
435 
436  //Pad the message so that its length is congruent to 112 modulo 128
437  if(n >= 112)
438  {
439  hashProcessDataBlock(SHA2_384, buffer, &first);
440  osMemset(buffer, 0, 128);
441  }
442 
443  //Append the length of the original message
444  STORE64BE(length * 8, buffer + 120);
445 
446  //Process the final block
447  hashProcessDataBlock(SHA2_384, buffer, &first);
448 
449  //Compute SHA-384 digest
450  DPORT_REG_WRITE(SHA_384_LOAD_REG, 1);
451 
452  //Wait for the operation to complete
453  while(DPORT_REG_READ(SHA_384_BUSY_REG) != 0)
454  {
455  }
456 
457  //Save the resulting hash value
458  DPORT_INTERRUPT_DISABLE();
459  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE);
460  STORE32BE(temp, digest);
461  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 4);
462  STORE32BE(temp, digest + 4);
463  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 8);
464  STORE32BE(temp, digest + 8);
465  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 12);
466  STORE32BE(temp, digest + 12);
467  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 16);
468  STORE32BE(temp, digest + 16);
469  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 20);
470  STORE32BE(temp, digest + 20);
471  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 24);
472  STORE32BE(temp, digest + 24);
473  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 28);
474  STORE32BE(temp, digest + 28);
475  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 32);
476  STORE32BE(temp, digest + 32);
477  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 36);
478  STORE32BE(temp, digest + 36);
479  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 40);
480  STORE32BE(temp, digest + 40);
481  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 44);
482  STORE32BE(temp, digest + 44);
483  DPORT_INTERRUPT_RESTORE();
484 
485  //Disable SHA module
486  periph_module_disable(PERIPH_SHA_MODULE);
487  //Release exclusive access to the SHA module
488  esp_crypto_sha_aes_lock_release();
489 
490  //Sucessful processing
491  return NO_ERROR;
492 }
493 
494 #endif
495 #if (SHA512_SUPPORT == ENABLED)
496 
497 /**
498  * @brief Digest a message using SHA-512
499  * @param[in] data Pointer to the message being hashed
500  * @param[in] length Length of the message
501  * @param[out] digest Pointer to the calculated digest
502  * @return Error code
503  **/
504 
505 error_t sha512Compute(const void *data, size_t length, uint8_t *digest)
506 {
507  bool_t first;
508  size_t n;
509  uint32_t temp;
510  uint8_t buffer[128];
511 
512  //Acquire exclusive access to the SHA module
513  esp_crypto_sha_aes_lock_acquire();
514  //Enable SHA module
515  periph_module_enable(PERIPH_SHA_MODULE);
516 
517  //Process the first message block
518  first = TRUE;
519 
520  //Digest the message
521  for(n = length; n >= 128; n -= 128)
522  {
523  //Update hash value
524  hashProcessDataBlock(SHA2_512, data, &first);
525  //Advance the data pointer
526  data = (uint8_t *) data + 128;
527  }
528 
529  //Copy the partial block, is any
530  osMemset(buffer, 0, 128);
531  osMemcpy(buffer, data, n);
532 
533  //Append the first byte of the padding string
534  buffer[n] = 0x80;
535 
536  //Pad the message so that its length is congruent to 112 modulo 128
537  if(n >= 112)
538  {
539  hashProcessDataBlock(SHA2_512, buffer, &first);
540  osMemset(buffer, 0, 128);
541  }
542 
543  //Append the length of the original message
544  STORE64BE(length * 8, buffer + 120);
545 
546  //Process the final block
547  hashProcessDataBlock(SHA2_512, buffer, &first);
548 
549  //Compute SHA-512 digest
550  DPORT_REG_WRITE(SHA_512_LOAD_REG, 1);
551 
552  //Wait for the operation to complete
553  while(DPORT_REG_READ(SHA_512_BUSY_REG) != 0)
554  {
555  }
556 
557  //Save the resulting hash value
558  DPORT_INTERRUPT_DISABLE();
559  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE);
560  STORE32BE(temp, digest);
561  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 4);
562  STORE32BE(temp, digest + 4);
563  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 8);
564  STORE32BE(temp, digest + 8);
565  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 12);
566  STORE32BE(temp, digest + 12);
567  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 16);
568  STORE32BE(temp, digest + 16);
569  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 20);
570  STORE32BE(temp, digest + 20);
571  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 24);
572  STORE32BE(temp, digest + 24);
573  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 28);
574  STORE32BE(temp, digest + 28);
575  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 32);
576  STORE32BE(temp, digest + 32);
577  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 36);
578  STORE32BE(temp, digest + 36);
579  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 40);
580  STORE32BE(temp, digest + 40);
581  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 44);
582  STORE32BE(temp, digest + 44);
583  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 48);
584  STORE32BE(temp, digest + 48);
585  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 52);
586  STORE32BE(temp, digest + 52);
587  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 56);
588  STORE32BE(temp, digest + 56);
589  temp = DPORT_SEQUENCE_REG_READ(SHA_TEXT_BASE + 60);
590  STORE32BE(temp, digest + 60);
591  DPORT_INTERRUPT_RESTORE();
592 
593  //Disable SHA module
594  periph_module_disable(PERIPH_SHA_MODULE);
595  //Release exclusive access to the SHA module
596  esp_crypto_sha_aes_lock_release();
597 
598  //Sucessful processing
599  return NO_ERROR;
600 }
601 
602 #endif
603 #endif
error_t sha384Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using SHA-384.
int bool_t
Definition: compiler_port.h:61
#define LOAD32BE(p)
Definition: cpu_endian.h:210
#define TRUE
Definition: os_port.h:50
uint8_t data[]
Definition: ethernet.h:224
ESP32 hash hardware accelerator.
ESP32 hardware cryptographic accelerator.
#define FALSE
Definition: os_port.h:46
#define osMemcpy(dest, src, length)
Definition: os_port.h:144
error_t
Error codes.
Definition: error.h:43
void esp32ShaInit(void)
SHA module initialization.
General definitions for cryptographic algorithms.
uint8_t length
Definition: tcp.h:375
Collection of hash algorithms.
error_t sha256Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using SHA-256.
#define STORE64BE(a, p)
Definition: cpu_endian.h:322
void hashProcessDataBlock(uint32_t algo, const uint8_t *data, bool_t *first)
Process data block.
uint8_t n
error_t sha512Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using SHA-512.
#define osMemset(p, value, length)
Definition: os_port.h:138
#define STORE32BE(a, p)
Definition: cpu_endian.h:286
@ NO_ERROR
Success.
Definition: error.h:44
Debugging facilities.
error_t sha1Compute(const void *data, size_t length, uint8_t *digest)
Digest a message using SHA-1.