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