sha.h 983 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #ifndef __sti_hash_fns_sha_h__
  2. #define __sti_hash_fns_sha_h__
  3. #include <stdint.h>
  4. typedef struct sha256_state {
  5. uint64_t length;
  6. uint32_t state[8];
  7. uint32_t curlen;
  8. unsigned char buf[64];
  9. } sha256_state;
  10. typedef struct sha512_state {
  11. uint64_t length;
  12. uint64_t state[8];
  13. uint32_t curlen;
  14. unsigned char buf[128];
  15. } sha512_state;
  16. // sha224 is a truncated sha256
  17. // sha384 is a truncated sha512
  18. // out is 256 bits/32 bytes
  19. // All in one go
  20. void sha256_sum(const void* in, uint32_t inlen, uint8_t* out32);
  21. void sha512_sum(const void* in, uint32_t inlen, uint8_t* out64);
  22. // block by block processing
  23. void sha256_init(sha256_state* md);
  24. void sha256_process(sha256_state* md, const void* in, uint32_t inlen);
  25. void sha256_done(sha256_state* md, void* out);
  26. void sha512_init(sha512_state* md);
  27. void sha512_process(sha512_state* md, const void* in, uint32_t inlen);
  28. void sha512_done(sha512_state* md, void* out);
  29. #endif // __sti_hash_fns_sha_h__