sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

sha384.c (593B)


      1 /* public domain sha384 implementation based on fips180-3 */
      2 #include <stdint.h>
      3 #include "../sha384.h"
      4 
      5 extern void sha512_sum_n(void *, uint8_t *, int n);
      6 
      7 void
      8 sha384_init(void *ctx)
      9 {
     10 	struct sha384 *s = ctx;
     11 	s->len = 0;
     12 	s->h[0] = 0xcbbb9d5dc1059ed8ULL;
     13 	s->h[1] = 0x629a292a367cd507ULL;
     14 	s->h[2] = 0x9159015a3070dd17ULL;
     15 	s->h[3] = 0x152fecd8f70e5939ULL;
     16 	s->h[4] = 0x67332667ffc00b31ULL;
     17 	s->h[5] = 0x8eb44a8768581511ULL;
     18 	s->h[6] = 0xdb0c2e0d64f98fa7ULL;
     19 	s->h[7] = 0x47b5481dbefa4fa4ULL;
     20 }
     21 
     22 void
     23 sha384_sum(void *ctx, uint8_t md[SHA384_DIGEST_LENGTH])
     24 {
     25 	sha512_sum_n(ctx, md, 6);
     26 }