summaryrefslogtreecommitdiffstats
path: root/providers
diff options
context:
space:
mode:
authorJiasheng Jiang <jiasheng@purdue.edu>2024-03-25 14:16:51 +0000
committerNeil Horman <nhorman@openssl.org>2024-03-30 09:05:32 -0400
commit2b6f307721db97d9bd7ca5ad4abf12b90ef581cd (patch)
treef8e19e8b983c04a9536c0da9378cfb6efd6dcaf0 /providers
parent64963c8b7a11728b5d252420f56f82532c14076d (diff)
Break the if statement up into 2 if statements
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)
Diffstat (limited to 'providers')
-rw-r--r--providers/implementations/signature/sm2_sig.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/providers/implementations/signature/sm2_sig.c b/providers/implementations/signature/sm2_sig.c
index 6b8936b959..346172abc0 100644
--- a/providers/implementations/signature/sm2_sig.c
+++ b/providers/implementations/signature/sm2_sig.c
@@ -310,11 +310,13 @@ int sm2sig_digest_verify_final(void *vpsm2ctx, const unsigned char *sig,
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)