summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-01-09 21:37:32 +0100
committerRichard Levitte <levitte@openssl.org>2020-01-19 02:47:46 +0100
commit0a054d2a0b1ccab07587185245455093454fe353 (patch)
tree639c462a4228fb3ee2342d4d1b54cc86ceb18b57 /apps
parented5cb1776b4759b745984c0c67c2d6453345c0a1 (diff)
APPS & TEST: Eliminate as much use of EVP_PKEY_size() as possible
Some uses were going against documented recommendations. Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/10798)
Diffstat (limited to 'apps')
-rw-r--r--apps/dgst.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/apps/dgst.c b/apps/dgst.c
index 21f0f01787..7a81cb28dc 100644
--- a/apps/dgst.c
+++ b/apps/dgst.c
@@ -541,11 +541,16 @@ int do_fp(BIO *out, unsigned char *buf, BIO *bp, int sep, int binout,
}
if (key != NULL) {
EVP_MD_CTX *ctx;
- int pkey_len;
+ size_t tmplen;
+
BIO_get_md_ctx(bp, &ctx);
- pkey_len = EVP_PKEY_size(key);
- if (pkey_len > BUFSIZE) {
- len = pkey_len;
+ if (!EVP_DigestSignFinal(ctx, NULL, &tmplen)) {
+ BIO_printf(bio_err, "Error Signing Data\n");
+ ERR_print_errors(bio_err);
+ goto end;
+ }
+ if (tmplen > BUFSIZE) {
+ len = tmplen;
sigbuf = app_malloc(len, "Signature buffer");
buf = sigbuf;
}