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 /crypto | |
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 'crypto')
-rw-r--r-- | crypto/evp/mac_lib.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/crypto/evp/mac_lib.c b/crypto/evp/mac_lib.c index eef37e882c..9356595efd 100644 --- a/crypto/evp/mac_lib.c +++ b/crypto/evp/mac_lib.c @@ -82,14 +82,14 @@ EVP_MAC *EVP_MAC_CTX_mac(EVP_MAC_CTX *ctx) return ctx->meth; } -size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx) +static size_t get_size_t_ctx_param(EVP_MAC_CTX *ctx, const char *name) { size_t sz = 0; if (ctx->algctx != NULL) { OSSL_PARAM params[2] = { OSSL_PARAM_END, OSSL_PARAM_END }; - params[0] = OSSL_PARAM_construct_size_t(OSSL_MAC_PARAM_SIZE, &sz); + params[0] = OSSL_PARAM_construct_size_t(name, &sz); if (ctx->meth->get_ctx_params != NULL) { if (ctx->meth->get_ctx_params(ctx->algctx, params)) return sz; @@ -105,6 +105,16 @@ size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx) return 0; } +size_t EVP_MAC_CTX_get_mac_size(EVP_MAC_CTX *ctx) +{ + return get_size_t_ctx_param(ctx, OSSL_MAC_PARAM_SIZE); +} + +size_t EVP_MAC_CTX_get_block_size(EVP_MAC_CTX *ctx) +{ + return get_size_t_ctx_param(ctx, OSSL_MAC_PARAM_BLOCK_SIZE); +} + int EVP_MAC_init(EVP_MAC_CTX *ctx, const unsigned char *key, size_t keylen, const OSSL_PARAM params[]) { |