skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

sha1_feed.c (493B)


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