hash: make blocklen and hashlen part of the implementation

This commit is contained in:
Lucas Gabriel Vuotto 2024-06-10 13:45:57 +00:00
parent 2b3e390bbf
commit 2ebe3467f8
3 changed files with 15 additions and 0 deletions

3
hash.h
View File

@ -26,6 +26,9 @@ struct lc_hash_impl {
void *(*ctx_new)(void);
void (*ctx_free)(void *);
size_t blocklen;
size_t hashlen;
};
struct lc_hash_ctx {

View File

@ -266,6 +266,9 @@ static struct lc_hash_impl sha224_impl = {
.ctx_new = &sha224_sha256_ctx_new,
.ctx_free = NULL,
.blocklen = LC_SHA224_BLOCKLEN,
.hashlen = LC_SHA224_HASHLEN,
};
static struct lc_hash_impl sha256_impl = {
@ -276,6 +279,9 @@ static struct lc_hash_impl sha256_impl = {
.ctx_new = &sha224_sha256_ctx_new,
.ctx_free = NULL,
.blocklen = LC_SHA256_BLOCKLEN,
.hashlen = LC_SHA256_HASHLEN,
};
const struct lc_hash_impl *

View File

@ -271,6 +271,9 @@ static struct lc_hash_impl sha384_impl = {
.ctx_new = &sha384_sha512_ctx_new,
.ctx_free = NULL,
.blocklen = LC_SHA384_BLOCKLEN,
.hashlen = LC_SHA384_HASHLEN,
};
static struct lc_hash_impl sha512_impl = {
@ -281,6 +284,9 @@ static struct lc_hash_impl sha512_impl = {
.ctx_new = &sha384_sha512_ctx_new,
.ctx_free = NULL,
.blocklen = LC_SHA512_BLOCKLEN,
.hashlen = LC_SHA512_HASHLEN,
};
const struct lc_hash_impl *