[ssh-rsa.c]
     pad received signature with leading zeros, because RSA_verify expects
     a signature of RSA_size. the drafts says the signature is transmitted
     unpadded (e.g. putty does not pad), reported by anakin@pobox.com
This commit is contained in:
Ben Lindstrom 2002-06-06 20:55:04 +00:00
parent 01fff0c9d4
commit ceae9d1c33
2 changed files with 23 additions and 3 deletions

View File

@ -73,6 +73,11 @@
add comment: add comment:
key_verify returns 1 for a correct signature, 0 for an incorrect signature key_verify returns 1 for a correct signature, 0 for an incorrect signature
and -1 on error. and -1 on error.
- markus@cvs.openbsd.org 2002/05/31 13:20:50
[ssh-rsa.c]
pad received signature with leading zeros, because RSA_verify expects
a signature of RSA_size. the drafts says the signature is transmitted
unpadded (e.g. putty does not pad), reported by anakin@pobox.com
20020604 20020604
- (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed - (stevesk) [channels.c] bug #164 patch from YOSHIFUJI Hideaki (changed
@ -757,4 +762,4 @@
- (stevesk) entropy.c: typo in debug message - (stevesk) entropy.c: typo in debug message
- (djm) ssh-keygen -i needs seeded RNG; report from markus@ - (djm) ssh-keygen -i needs seeded RNG; report from markus@
$Id: ChangeLog,v 1.2164 2002/06/06 20:54:07 mouring Exp $ $Id: ChangeLog,v 1.2165 2002/06/06 20:55:04 mouring Exp $

View File

@ -23,7 +23,7 @@
*/ */
#include "includes.h" #include "includes.h"
RCSID("$OpenBSD: ssh-rsa.c,v 1.18 2002/04/02 20:11:38 markus Exp $"); RCSID("$OpenBSD: ssh-rsa.c,v 1.19 2002/05/31 13:20:50 markus Exp $");
#include <openssl/evp.h> #include <openssl/evp.h>
#include <openssl/err.h> #include <openssl/err.h>
@ -115,7 +115,7 @@ ssh_rsa_verify(
EVP_MD_CTX md; EVP_MD_CTX md;
char *ktype; char *ktype;
u_char digest[EVP_MAX_MD_SIZE], *sigblob; u_char digest[EVP_MAX_MD_SIZE], *sigblob;
u_int len, dlen; u_int len, dlen, modlen;
int rlen, ret, nid; int rlen, ret, nid;
if (key == NULL || key->type != KEY_RSA || key->rsa == NULL) { if (key == NULL || key->type != KEY_RSA || key->rsa == NULL) {
@ -145,6 +145,21 @@ ssh_rsa_verify(
xfree(sigblob); xfree(sigblob);
return -1; return -1;
} }
/* RSA_verify expects a signature of RSA_size */
modlen = RSA_size(key->rsa);
if (len > modlen) {
error("ssh_rsa_verify: len %d > modlen %d", len, modlen);
xfree(sigblob);
return -1;
} else if (len < modlen) {
int diff = modlen - len;
debug("ssh_rsa_verify: add padding: modlen %d > len %d",
modlen, len);
sigblob = xrealloc(sigblob, modlen);
memmove(sigblob + diff, sigblob, len);
memset(sigblob, 0, diff);
len = modlen;
}
nid = (datafellows & SSH_BUG_RSASIGMD5) ? NID_md5 : NID_sha1; nid = (datafellows & SSH_BUG_RSASIGMD5) ? NID_md5 : NID_sha1;
if ((evp_md = EVP_get_digestbynid(nid)) == NULL) { if ((evp_md = EVP_get_digestbynid(nid)) == NULL) {
error("ssh_rsa_verify: EVP_get_digestbynid %d failed", nid); error("ssh_rsa_verify: EVP_get_digestbynid %d failed", nid);