sha1_final.c (446B)
1 /* ISC license. */ 2 3 #include <skalibs/uint32.h> 4 #include <skalibs/sha1.h> 5 #include "sha1-internal.h" 6 7 void sha1_final (SHA1Schedule *ctx, char *digest) 8 { 9 char pack[8] ; 10 uint32_pack_big(pack, ctx->bits[1]) ; 11 uint32_pack_big(pack+4, ctx->bits[0]) ; 12 sha1_feed(ctx, 0x80) ; 13 while (ctx->b != 56) sha1_feed(ctx, 0) ; 14 sha1_update(ctx, pack, 8) ; 15 for (unsigned int i = 0 ; i < 5 ; i++) 16 uint32_pack_big(digest + (i<<2), ctx->buf[i]) ; 17 }