/* * Copyright (C) 2023 TU Dresden * * This file is subject to the terms and conditions of the GNU Lesser * General Public License v2.1. See the file LICENSE in the top level * directory for more details. */ /** * @ingroup sys_hashes * * @{ * @file * @brief SHA512/256 hash function implementation * * @author Mikolai Gütschow * * @} */ #include #include "hashes/sha512_256.h" void sha512_256_init(sha512_256_context_t *ctx) { /* Zero bits processed so far */ ctx->count[0] = ctx->count[1] = 0; /* Magic initialization constants */ ctx->state[0] = 0x22312194FC2BF72C; ctx->state[1] = 0x9F555FA3C84C64C2; ctx->state[2] = 0x2393B86B6F53B151; ctx->state[3] = 0x963877195940EABD; ctx->state[4] = 0x96283EE2A88EFFE3; ctx->state[5] = 0xBE5E1E2553863992; ctx->state[6] = 0x2B0199FC2C85B8AA; ctx->state[7] = 0x0EB72DDC81C52CA2; } void sha512_256(const void *data, size_t len, void *digest) { sha512_256_context_t c; assert(digest); sha512_256_init(&c); sha512_256_update(&c, data, len); sha512_256_final(&c, digest); }