sha256.h 1.3 KB

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