summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-rsa.c34
-rw-r--r--usr.bin/ssh/sshd.c3
2 files changed, 24 insertions, 13 deletions
diff --git a/usr.bin/ssh/ssh-rsa.c b/usr.bin/ssh/ssh-rsa.c
index 9de0e7b0890..a2153bd1ad5 100644
--- a/usr.bin/ssh/ssh-rsa.c
+++ b/usr.bin/ssh/ssh-rsa.c
@@ -23,7 +23,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-rsa.c,v 1.6 2001/02/08 19:30:52 itojun Exp $");
+RCSID("$OpenBSD: ssh-rsa.c,v 1.7 2001/03/27 10:34:08 markus Exp $");
#include <openssl/evp.h>
#include <openssl/err.h>
@@ -42,27 +42,32 @@ ssh_rsa_sign(
u_char **sigp, int *lenp,
u_char *data, int datalen)
{
- EVP_MD *evp_md = EVP_sha1();
+ const EVP_MD *evp_md;
EVP_MD_CTX md;
u_char *digest, *sig, *ret;
u_int slen, dlen, len;
- int ok;
+ int ok, nid;
Buffer b;
if (key == NULL || key->type != KEY_RSA || key->rsa == NULL) {
error("ssh_rsa_sign: no RSA key");
return -1;
}
- slen = RSA_size(key->rsa);
- sig = xmalloc(slen);
-
+ nid = NID_sha1;
+ if ((evp_md = EVP_get_digestbynid(nid)) == NULL) {
+ 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);
- ok = RSA_sign(NID_sha1, digest, dlen, sig, &len, key->rsa);
+ slen = RSA_size(key->rsa);
+ sig = xmalloc(slen);
+
+ ok = RSA_sign(nid, digest, dlen, sig, &len, key->rsa);
memset(digest, 'd', dlen);
xfree(digest);
@@ -108,13 +113,12 @@ ssh_rsa_verify(
u_char *data, int datalen)
{
Buffer b;
- EVP_MD *evp_md = EVP_sha1();
+ const EVP_MD *evp_md;
EVP_MD_CTX md;
char *ktype;
u_char *sigblob, *digest;
u_int len, dlen;
- int rlen;
- int ret;
+ int rlen, ret, nid;
if (key == NULL || key->type != KEY_RSA || key->rsa == NULL) {
error("ssh_rsa_verify: no RSA key");
@@ -139,17 +143,23 @@ ssh_rsa_verify(
rlen = buffer_len(&b);
buffer_free(&b);
if(rlen != 0) {
+ xfree(sigblob);
error("ssh_rsa_verify: remaining bytes in signature %d", rlen);
return -1;
}
-
+ nid = NID_sha1;
+ if ((evp_md = EVP_get_digestbynid(nid)) == NULL) {
+ xfree(sigblob);
+ error("ssh_rsa_verify: 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);
- ret = RSA_verify(NID_sha1, digest, dlen, sigblob, len, key->rsa);
+ ret = RSA_verify(nid, digest, dlen, sigblob, len, key->rsa);
memset(digest, 'd', dlen);
xfree(digest);
memset(sigblob, 's', len);
diff --git a/usr.bin/ssh/sshd.c b/usr.bin/ssh/sshd.c
index fcd531b31ef..7714cc76054 100644
--- a/usr.bin/ssh/sshd.c
+++ b/usr.bin/ssh/sshd.c
@@ -40,7 +40,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: sshd.c,v 1.179 2001/03/26 08:07:09 markus Exp $");
+RCSID("$OpenBSD: sshd.c,v 1.180 2001/03/27 10:34:08 markus Exp $");
#include <openssl/dh.h>
#include <openssl/bn.h>
@@ -635,6 +635,7 @@ main(int ac, char **av)
exit(1);
}
}
+ SSLeay_add_all_algorithms();
/*
* Force logging to stderr until we have loaded the private host