sha256.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. /*********************************************************************
  2. * Filename: sha256.h
  3. * Author: Brad Conte (brad AT bradconte.com)
  4. * Copyright:
  5. * Disclaimer: This code is presented "as is" without any guarantees.
  6. * Details: Defines the API for the corresponding SHA1 implementation.
  7. *********************************************************************/
  8. #ifndef SHA256_H
  9. #define SHA256_H
  10. /*************************** HEADER FILES ***************************/
  11. #include <stddef.h>
  12. /****************************** MACROS ******************************/
  13. #define SHA256_BLOCK_SIZE 32 // SHA256 outputs a 32 byte digest
  14. /**************************** DATA TYPES ****************************/
  15. typedef unsigned char BYTE; // 8-bit byte
  16. typedef unsigned int WORD; // 32-bit word, change to "long" for 16-bit machines
  17. typedef struct {
  18. BYTE data[64];
  19. WORD datalen;
  20. unsigned long long bitlen;
  21. WORD state[8];
  22. } CRYAL_SHA256_CTX;
  23. /*********************** FUNCTION DECLARATIONS **********************/
  24. void sha256_init(CRYAL_SHA256_CTX *ctx);
  25. void sha256_update(CRYAL_SHA256_CTX *ctx, const BYTE data[], size_t len);
  26. void sha256_final(CRYAL_SHA256_CTX *ctx, BYTE hash[]);
  27. #endif // SHA256_H