From 3534b428629be185e096be99e3bd5fdfe32d5544 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Thu, 18 Sep 2014 18:55:44 +0000 Subject: initial commit with rc for skalibs-2.0.0.0 --- src/libstdcrypto/sha256_final.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/libstdcrypto/sha256_final.c (limited to 'src/libstdcrypto/sha256_final.c') diff --git a/src/libstdcrypto/sha256_final.c b/src/libstdcrypto/sha256_final.c new file mode 100644 index 0000000..58b938a --- /dev/null +++ b/src/libstdcrypto/sha256_final.c @@ -0,0 +1,31 @@ +/* ISC license. */ + +#include +#include +#include +#include "sha256-internal.h" + +void sha256_final (SHA256Schedule_ref ctx, char *digest) +{ + register unsigned int i = 0 ; + register unsigned char *p = (unsigned char *)digest ; + uint32 bits[2] = { ctx->bits[0], ctx->bits[1] } ; + + sha256_feed(ctx, 0x80) ; + while (ctx->b != 56) sha256_feed(ctx, 0) ; + sha256_feed(ctx, T8(bits[1]>>24)) ; + sha256_feed(ctx, T8(bits[1]>>16)) ; + sha256_feed(ctx, T8(bits[1]>>8)) ; + sha256_feed(ctx, T8(bits[1])) ; + sha256_feed(ctx, T8(bits[0]>>24)) ; + sha256_feed(ctx, T8(bits[0]>>16)) ; + sha256_feed(ctx, T8(bits[0]>>8)) ; + sha256_feed(ctx, T8(bits[0])) ; + for (; i < 8 ; i++) + { + *p++ = T8(ctx->buf[i]>>24) ; + *p++ = T8(ctx->buf[i]>>16) ; + *p++ = T8(ctx->buf[i]>>8) ; + *p++ = T8(ctx->buf[i]) ; + } +} -- cgit v1.2.3