Break the if statement up into 2 if statements to avoid call
EVP_MD_get_size() twice.
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23959)
PROV_SM2_CTX *psm2ctx = (PROV_SM2_CTX *)vpsm2ctx;
unsigned char digest[EVP_MAX_MD_SIZE];
unsigned int dlen = 0;
+ int md_size;
- if (psm2ctx == NULL
- || psm2ctx->mdctx == NULL
- || EVP_MD_get_size(psm2ctx->md) <= 0
- || EVP_MD_get_size(psm2ctx->md) > (int)sizeof(digest))
+ if (psm2ctx == NULL || psm2ctx->mdctx == NULL)
+ return 0;
+
+ md_size = EVP_MD_get_size(psm2ctx->md);
+ if (md_size <= 0 || md_size > (int)sizeof(digest))
return 0;
if (!(sm2sig_compute_z_digest(psm2ctx)