sha256.h 875 B

1234567891011121314151617181920212223242526272829303132
  1. /* sha.h sha256 and sha224 hash functions */
  2. #ifndef SHA256_H
  3. #define SHA256_H
  4. #include "ustd.h"
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. #define sha256_block_size 64
  9. #define sha256_hash_size 32
  10. #define sha224_hash_size 28
  11. /* algorithm context */
  12. typedef struct sha256_ctx
  13. {
  14. unsigned message[16]; /* 512-bit buffer for leftovers */
  15. uint64_t length; /* number of processed bytes */
  16. unsigned hash[8]; /* 256-bit algorithm internal hashing state */
  17. unsigned digest_length; /* length of the algorithm digest in bytes */
  18. } sha256_ctx;
  19. void rhash_sha224_init(sha256_ctx *ctx);
  20. void rhash_sha256_init(sha256_ctx *ctx);
  21. void rhash_sha256_update(sha256_ctx *ctx, const unsigned char* data, size_t length);
  22. void rhash_sha256_final(sha256_ctx *ctx, unsigned char result[32]);
  23. #ifdef __cplusplus
  24. } /* extern "C" */
  25. #endif /* __cplusplus */
  26. #endif /* SHA256_H */