sha256_feed.c (503B)
1 /* ISC license. */ 2 3 #include <stdint.h> 4 5 #include <skalibs/bytestr.h> 6 #include <skalibs/sha256.h> 7 #include "sha256-internal.h" 8 9 void sha256_feed (SHA256Schedule *ctx, unsigned char inb) 10 { 11 uint32_t tmp ; 12 ctx->in[ctx->b>>2] <<= 8 ; 13 ctx->in[ctx->b>>2] |= T8(inb) ; 14 if (++ctx->b >= 64) 15 { 16 sha256_transform(ctx->buf, ctx->in) ; 17 ctx->b = 0 ; 18 for (uint32_t i = 0; i < 16 ; i++) ctx->in[i] = 0 ; 19 } 20 tmp = ctx->bits[0] ; 21 ctx->bits[0] += 8 ; 22 if (tmp > ctx->bits[0]) ctx->bits[1]++ ; 23 }