sha256.h 831 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #pragma once
  2. /* Based on linux source code */
  3. #ifdef __cplusplus
  4. extern "C" {
  5. #endif
  6. #include <switch/types.h>
  7. #define SHA256_DIGEST_SIZE 32
  8. #define SHA256_BLOCK_SIZE 64
  9. #define SHA256_H0 0x6a09e667UL
  10. #define SHA256_H1 0xbb67ae85UL
  11. #define SHA256_H2 0x3c6ef372UL
  12. #define SHA256_H3 0xa54ff53aUL
  13. #define SHA256_H4 0x510e527fUL
  14. #define SHA256_H5 0x9b05688cUL
  15. #define SHA256_H6 0x1f83d9abUL
  16. #define SHA256_H7 0x5be0cd19UL
  17. struct sha256_state {
  18. u32 state[SHA256_DIGEST_SIZE / 4];
  19. u64 count;
  20. u8 buf[SHA256_BLOCK_SIZE];
  21. };
  22. int sha256_init(struct sha256_state *sctx);
  23. int sha256_update(struct sha256_state *sctx, const void *data, size_t len);
  24. int sha256_finalize(struct sha256_state *sctx);
  25. int sha256_finish(struct sha256_state *sctx, void *out);
  26. #ifdef __cplusplus
  27. }
  28. #endif