morpheus-base

morpheus base system
git clone git://git.2f30.org/morpheus-base
Log | Files | Refs

sha256.h (615B)


      1 /* public domain sha256 implementation based on fips180-3 */
      2 
      3 struct sha256 {
      4 	uint64_t len;    /* processed message length */
      5 	uint32_t h[8];   /* hash state */
      6 	uint8_t buf[64]; /* message block buffer */
      7 };
      8 
      9 enum { SHA256_DIGEST_LENGTH = 32 };
     10 
     11 /* reset state */
     12 void sha256_init(void *ctx);
     13 /* process message */
     14 void sha256_update(void *ctx, const void *m, unsigned long len);
     15 /* get message digest */
     16 /* state is ruined after sum, keep a copy if multiple sum is needed */
     17 /* part of the message might be left in s, zero it if secrecy is needed */
     18 void sha256_sum(void *ctx, uint8_t md[SHA256_DIGEST_LENGTH]);