1 /* ISC license. */
2 
3 /* SHA256 routines */
4 /* Written by David Madore (<URL: http://www.madore.org/~david/ >) */
5 /* Adapted by Laurent Bercot. */
6 /* This version last modified 2010-01-08 */
7 
8 /* Note: these routines do not depend on endianness. */
9 
10 #ifndef SHA256_H
11 #define SHA256_H
12 
13 #include <sys/types.h>
14 #include <stdint.h>
15 
16 typedef struct SHA256Schedule_s SHA256Schedule, *SHA256Schedule_ref ;
17 struct SHA256Schedule_s
18 {
19   uint32_t buf[8] ;   /* The eight chaining variables */
20   uint32_t bits[2] ;  /* Count number of message bits */
21   uint32_t in[16] ;   /* Data being fed in */
22   unsigned int b ;  /* Our position within the 512 bits (always between 0 and 63) */
23 } ;
24 
25 #define SHA256_INIT() { .buf = { 0x6a09e667U, 0xbb67ae85U, 0x3c6ef372U, 0xa54ff53aU, 0x510e527fU, 0x9b05688cU, 0x1f83d9abU, 0x5be0cd19U }, .bits = { 0, 0 }, .in = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, .b = 0 }
26 extern void sha256_init (SHA256Schedule *) ;
27 extern void sha256_update (SHA256Schedule *, char const *, size_t) ;
28 extern void sha256_final (SHA256Schedule *, char *digest) ;
29 
30 #endif
31