summaryrefslogtreecommitdiff
path: root/crypto/dsa/dsa_pmeth.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2015-04-30 14:16:07 +0100
committerDr. Stephen Henson <steve@openssl.org>2015-08-24 15:12:52 +0100
commit9d04f83410ac052aecf7a3031ad20f5237c02014 (patch)
tree892a1a912ce6c66bb3e2e489078f5a8e6597a03e /crypto/dsa/dsa_pmeth.c
parent9b86974e0c705ea321ddbc9a9d8562c894809e5b (diff)
downloadopenssl-new-9d04f83410ac052aecf7a3031ad20f5237c02014.tar.gz
Add DSA digest length checks.
Reviewed-by: Ben Laurie <ben@openssl.org>
Diffstat (limited to 'crypto/dsa/dsa_pmeth.c')
-rw-r--r--crypto/dsa/dsa_pmeth.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/crypto/dsa/dsa_pmeth.c b/crypto/dsa/dsa_pmeth.c
index 594583ffc8..1adab4f8ec 100644
--- a/crypto/dsa/dsa_pmeth.c
+++ b/crypto/dsa/dsa_pmeth.c
@@ -125,10 +125,15 @@ static int pkey_dsa_sign(EVP_PKEY_CTX *ctx, unsigned char *sig,
DSA_PKEY_CTX *dctx = ctx->data;
DSA *dsa = ctx->pkey->pkey.dsa;
- if (dctx->md)
+ if (dctx->md) {
+ if (tbslen != (size_t)EVP_MD_size(dctx->md))
+ return 0;
type = EVP_MD_type(dctx->md);
- else
+ } else {
+ if (tbslen != SHA_DIGEST_LENGTH)
+ return 0;
type = NID_sha1;
+ }
ret = DSA_sign(type, tbs, tbslen, sig, &sltmp, dsa);
@@ -146,10 +151,15 @@ static int pkey_dsa_verify(EVP_PKEY_CTX *ctx,
DSA_PKEY_CTX *dctx = ctx->data;
DSA *dsa = ctx->pkey->pkey.dsa;
- if (dctx->md)
+ if (dctx->md) {
+ if (tbslen != (size_t)EVP_MD_size(dctx->md))
+ return 0;
type = EVP_MD_type(dctx->md);
- else
+ } else {
+ if (tbslen != SHA_DIGEST_LENGTH)
+ return 0;
type = NID_sha1;
+ }
ret = DSA_verify(type, tbs, tbslen, sig, siglen, dsa);