diff options
author | Pauli <pauli@openssl.org> | 2021-05-24 14:22:17 +1000 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-05-25 17:23:50 +1000 |
commit | eb1b66f00ca4e1fb6f9e815e8686768b6d81722d (patch) | |
tree | abe98cebf08f1f7eaa4c63fe72b7f8fc8948171c /providers/implementations/macs/kmac_prov.c | |
parent | 36b6db08fe3dbb58ba2a45a6170f21b5149dfe26 (diff) |
mac: add a getter for the MAC block size.
Fixes #12342
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15427)
Diffstat (limited to 'providers/implementations/macs/kmac_prov.c')
-rw-r--r-- | providers/implementations/macs/kmac_prov.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/providers/implementations/macs/kmac_prov.c b/providers/implementations/macs/kmac_prov.c index c95cf57ffb..4ee57ca1c2 100644 --- a/providers/implementations/macs/kmac_prov.c +++ b/providers/implementations/macs/kmac_prov.c @@ -239,13 +239,6 @@ static void *kmac_dup(void *vsrc) return dst; } -static size_t kmac_size(void *vmacctx) -{ - struct kmac_data_st *kctx = vmacctx; - - return kctx->out_len; -} - static int kmac_setkey(struct kmac_data_st *kctx, const unsigned char *key, size_t keylen) { @@ -361,6 +354,7 @@ static int kmac_final(void *vmacctx, unsigned char *out, size_t *outl, static const OSSL_PARAM known_gettable_ctx_params[] = { OSSL_PARAM_size_t(OSSL_MAC_PARAM_SIZE, NULL), + OSSL_PARAM_size_t(OSSL_MAC_PARAM_BLOCK_SIZE, NULL), OSSL_PARAM_END }; static const OSSL_PARAM *kmac_gettable_ctx_params(ossl_unused void *ctx, @@ -371,10 +365,19 @@ static const OSSL_PARAM *kmac_gettable_ctx_params(ossl_unused void *ctx, static int kmac_get_ctx_params(void *vmacctx, OSSL_PARAM params[]) { + struct kmac_data_st *kctx = vmacctx; OSSL_PARAM *p; + int sz; + + if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL + && !OSSL_PARAM_set_size_t(p, kctx->out_len)) + return 0; - if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_SIZE)) != NULL) - return OSSL_PARAM_set_size_t(p, kmac_size(vmacctx)); + if ((p = OSSL_PARAM_locate(params, OSSL_MAC_PARAM_BLOCK_SIZE)) != NULL) { + sz = EVP_MD_block_size(ossl_prov_digest_md(&kctx->digest)); + if (!OSSL_PARAM_set_int(p, sz)) + return 0; + } return 1; } |