diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2022-06-01 12:40:24 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2022-06-01 12:40:24 +0000 |
commit | e0c38ba95a293b747acee203ead11933a44a4c59 (patch) | |
tree | 7845c14e7c908c4bf15d898077309a12738a4961 /src/libstdcrypto/blake2s_update.c | |
parent | e88276fdec7b3b94ec939f5eb1c8def004ee3878 (diff) | |
download | skalibs-e0c38ba95a293b747acee203ead11933a44a4c59.tar.xz |
Add blake2s implementation to stdcrypto
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libstdcrypto/blake2s_update.c')
-rw-r--r-- | src/libstdcrypto/blake2s_update.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libstdcrypto/blake2s_update.c b/src/libstdcrypto/blake2s_update.c new file mode 100644 index 0000000..bf0639b --- /dev/null +++ b/src/libstdcrypto/blake2s_update.c @@ -0,0 +1,27 @@ + /* ISC license. */ + +#include <string.h> + +#include <skalibs/blake2s.h> +#include "blake2s-internal.h" + +void blake2s_update (blake2s_ctx *ctx, char const *s, size_t len) +{ + size_t w = 64 - ctx->buflen ; + if (!len) return ; + if (len > w) + { + memcpy(ctx->buf + ctx->buflen, s, w) ; + blake2s_transform(ctx, ctx->buf, 1, 64) ; + ctx->buflen = 0 ; + s += w ; len -= w ; + } + if (len > 64) + { + size_t n = (len+63)/64 - 1 ; + blake2s_transform(ctx, s, n, 64) ; + n <<= 6 ; s += n ; len -= n ; + } + memcpy(ctx->buf + ctx->buflen, s, len) ; + ctx->buflen += len ; +} |