summaryrefslogtreecommitdiff
path: root/ssh-rsa.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2002-02-05 11:53:43 +1100
committerDamien Miller <djm@mindrot.org>2002-02-05 11:53:43 +1100
commitc516e928cdaf2ea3dd666a79d4c89a942b242d68 (patch)
treeb34d1e8c6610fc9768f546a1557df1efe3a14a68 /ssh-rsa.c
parent3a8262ffcc04afca626d457da65fc1076681073c (diff)
downloadopenssh-git-c516e928cdaf2ea3dd666a79d4c89a942b242d68.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-rsa.c')
-rw-r--r--ssh-rsa.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/ssh-rsa.c b/ssh-rsa.c
index 27522ef6..c4339b95 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-rsa.c,v 1.14 2001/12/05 10:06:12 deraadt Exp $");
+RCSID("$OpenBSD: ssh-rsa.c,v 1.15 2002/01/25 21:42:11 markus Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -45,7 +45,7 @@ ssh_rsa_sign(
{
const EVP_MD *evp_md;
EVP_MD_CTX md;
- u_char *digest, *sig, *ret;
+ u_char digest[EVP_MAX_MD_SIZE], *sig, *ret;
u_int slen, dlen, len;
int ok, nid;
Buffer b;
@@ -63,18 +63,15 @@ ssh_rsa_sign(
error("ssh_rsa_sign: EVP_get_digestbynid %d failed", nid);
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);
slen = RSA_size(key->rsa);
sig = xmalloc(slen);
ok = RSA_sign(nid, digest, dlen, sig, &len, key->rsa);
- memset(digest, 'd', dlen);
- xfree(digest);
+ memset(digest, 'd', sizeof(digest));
if (ok != 1) {
int ecode = ERR_get_error();
@@ -120,7 +117,7 @@ ssh_rsa_verify(
const EVP_MD *evp_md;
EVP_MD_CTX md;
char *ktype;
- u_char *sigblob, *digest;
+ u_char digest[EVP_MAX_MD_SIZE], *sigblob;
u_int len, dlen;
int rlen, ret, nid;
@@ -161,15 +158,12 @@ ssh_rsa_verify(
xfree(sigblob);
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);
ret = RSA_verify(nid, digest, dlen, sigblob, len, key->rsa);
- memset(digest, 'd', dlen);
- xfree(digest);
+ memset(digest, 'd', sizeof(digest));
memset(sigblob, 's', len);
xfree(sigblob);
if (ret == 0) {