[openssl-commits] [openssl] master update
Matt Caswell
matt at openssl.org
Mon Sep 10 16:32:36 UTC 2018
The branch master has been updated
via d689f313cc5ebe2763fb26d1e7f8cd53b7da6a4a (commit)
from 52307f94f8f3e5a1cd392f0a48802a24ccf73ba2 (commit)
- Log -----------------------------------------------------------------
commit d689f313cc5ebe2763fb26d1e7f8cd53b7da6a4a
Author: Matt Caswell <matt at openssl.org>
Date: Mon Sep 10 16:53:17 2018 +0100
Validate the SM2 digest len before use
Fixes a Coverity complaint.
Reviewed-by: Richard Levitte <levitte at openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7170)
-----------------------------------------------------------------------
Summary of changes:
crypto/sm2/sm2_pmeth.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/crypto/sm2/sm2_pmeth.c b/crypto/sm2/sm2_pmeth.c
index 3e42065..d187699 100644
--- a/crypto/sm2/sm2_pmeth.c
+++ b/crypto/sm2/sm2_pmeth.c
@@ -259,6 +259,7 @@ static int pkey_sm2_digest_custom(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
SM2_PKEY_CTX *smctx = ctx->data;
EC_KEY *ec = ctx->pkey->pkey.ec;
const EVP_MD *md = EVP_MD_CTX_md(mctx);
+ int mdlen = EVP_MD_size(md);
if (!smctx->id_set) {
/*
@@ -270,11 +271,16 @@ static int pkey_sm2_digest_custom(EVP_PKEY_CTX *ctx, EVP_MD_CTX *mctx)
return 0;
}
+ if (mdlen < 0) {
+ SM2err(SM2_F_PKEY_SM2_DIGEST_CUSTOM, SM2_R_INVALID_DIGEST);
+ return 0;
+ }
+
/* get hashed prefix 'z' of tbs message */
if (!sm2_compute_z_digest(z, md, smctx->id, smctx->id_len, ec))
return 0;
- return EVP_DigestUpdate(mctx, z, EVP_MD_size(md));
+ return EVP_DigestUpdate(mctx, z, (size_t)mdlen);
}
const EVP_PKEY_METHOD sm2_pkey_meth = {
More information about the openssl-commits
mailing list