sha512_update.c (576B)
1 /* ISC license. */ 2 3 #include <string.h> 4 5 #include <skalibs/sha512.h> 6 #include "sha512-internal.h" 7 8 void sha512_update (SHA512Schedule *ctx, char const *buf, size_t len) 9 { 10 unsigned int pad = ctx->len & 0x7fU ; 11 ctx->len += len ; 12 if (pad && len >= 128 - pad) 13 { 14 memcpy((char *)ctx->buf + pad, buf, 128 - pad) ; 15 buf += 128 - pad ; len -= 128 - pad ; pad = 0 ; 16 sha512_transform(ctx, ctx->buf) ; 17 } 18 19 while (len >= 128) 20 { 21 sha512_transform(ctx, (unsigned char const *)buf) ; 22 buf += 128 ; len -= 128 ; 23 } 24 memcpy((char *)ctx->buf + pad, buf, len) ; 25 }