Reference implementations of PQC
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

48 wiersze
1.5 KiB

  1. #ifndef SHA2_H
  2. #define SHA2_H
  3. #include <stddef.h>
  4. #include <stdint.h>
  5. /* The incremental API allows hashing of individual input blocks; these blocks
  6. must be exactly 64 bytes each.
  7. Use the 'finalize' functions for any remaining bytes (possibly over 64). */
  8. typedef struct {
  9. uint8_t ctx[40];
  10. } sha224ctx;
  11. typedef struct {
  12. uint8_t ctx[40];
  13. } sha256ctx;
  14. typedef struct {
  15. uint8_t ctx[72];
  16. } sha384ctx;
  17. typedef struct {
  18. uint8_t ctx[72];
  19. } sha512ctx;
  20. void sha224_inc_init(sha224ctx *state);
  21. void sha224_inc_blocks(sha224ctx *state, const uint8_t *in, size_t inblocks);
  22. void sha224_inc_finalize(uint8_t *out, sha224ctx *state, const uint8_t *in, size_t inlen);
  23. void sha224(uint8_t *out, const uint8_t *in, size_t inlen);
  24. void sha256_inc_init(sha256ctx *state);
  25. void sha256_inc_blocks(sha256ctx *state, const uint8_t *in, size_t inblocks);
  26. void sha256_inc_finalize(uint8_t *out, sha256ctx *state, const uint8_t *in, size_t inlen);
  27. void sha256(uint8_t *out, const uint8_t *in, size_t inlen);
  28. void sha384_inc_init(sha384ctx *state);
  29. void sha384_inc_blocks(sha384ctx *state, const uint8_t *in, size_t inblocks);
  30. void sha384_inc_finalize(uint8_t *out, sha384ctx *state, const uint8_t *in, size_t inlen);
  31. void sha384(uint8_t *out, const uint8_t *in, size_t inlen);
  32. void sha512_inc_init(sha512ctx *state);
  33. void sha512_inc_blocks(sha512ctx *state, const uint8_t *in, size_t inblocks);
  34. void sha512_inc_finalize(uint8_t *out, sha512ctx *state, const uint8_t *in, size_t inlen);
  35. void sha512(uint8_t *out, const uint8_t *in, size_t inlen);
  36. #endif