summaryrefslogtreecommitdiff
path: root/ssh-dss.c
diff options
context:
space:
mode:
authordjm <djm>2002-02-05 00:53:43 +0000
committerdjm <djm>2002-02-05 00:53:43 +0000
commitdcdf4e04d2680af1399e73f16325e2a8f7991179 (patch)
tree55d0b9d764ffd09593f7b0578b00093927d98de9 /ssh-dss.c
parent73f2f0285679786a9e08fc49dbac477144df00b4 (diff)
downloadopenssh-dcdf4e04d2680af1399e73f16325e2a8f7991179.tar.gz
- markus@cvs.openbsd.org 2002/01/25 21:42:11
[ssh-dss.c ssh-rsa.c] use static EVP_MAX_MD_SIZE buffers for EVP_DigestFinal; ok stevesk@ don't use evp_md->md_size, it's not public.
Diffstat (limited to 'ssh-dss.c')
-rw-r--r--ssh-dss.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/ssh-dss.c b/ssh-dss.c
index bd709a22..b81b8347 100644
--- a/ssh-dss.c
+++ b/ssh-dss.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-dss.c,v 1.11 2001/12/27 18:22:16 markus Exp $");
+RCSID("$OpenBSD: ssh-dss.c,v 1.12 2002/01/25 21:42:11 markus Exp $");
#include <openssl/bn.h>
#include <openssl/evp.h>
@@ -48,7 +48,7 @@ ssh_dss_sign(
DSA_SIG *sig;
EVP_MD *evp_md = EVP_sha1();
EVP_MD_CTX md;
- u_char *digest, *ret, sigblob[SIGBLOB_LEN];
+ u_char *ret, digest[EVP_MAX_MD_SIZE], sigblob[SIGBLOB_LEN];
u_int rlen, slen, len, dlen;
Buffer b;
@@ -56,16 +56,13 @@ ssh_dss_sign(
error("ssh_dss_sign: no DSA key");
return -1;
}
- dlen = evp_md->md_size;
- digest = xmalloc(dlen);
EVP_DigestInit(&md, evp_md);
EVP_DigestUpdate(&md, data, datalen);
- EVP_DigestFinal(&md, digest, NULL);
+ EVP_DigestFinal(&md, digest, &dlen);
sig = DSA_do_sign(digest, dlen, key->dsa);
+ memset(digest, 'd', sizeof(digest));
- memset(digest, 0, dlen);
- xfree(digest);
if (sig == NULL) {
error("ssh_dss_sign: sign failed");
return -1;
@@ -115,7 +112,7 @@ ssh_dss_verify(
DSA_SIG *sig;
EVP_MD *evp_md = EVP_sha1();
EVP_MD_CTX md;
- u_char *digest, *sigblob;
+ u_char digest[EVP_MAX_MD_SIZE], *sigblob;
u_int len, dlen;
int rlen, ret;
Buffer b;
@@ -173,16 +170,13 @@ ssh_dss_verify(
}
/* sha1 the data */
- dlen = evp_md->md_size;
- digest = xmalloc(dlen);
EVP_DigestInit(&md, evp_md);
EVP_DigestUpdate(&md, data, datalen);
- EVP_DigestFinal(&md, digest, NULL);
+ EVP_DigestFinal(&md, digest, &dlen);
ret = DSA_do_verify(digest, dlen, sig, key->dsa);
+ memset(digest, 'd', sizeof(digest));
- memset(digest, 0, dlen);
- xfree(digest);
DSA_SIG_free(sig);
debug("ssh_dss_verify: signature %s",