summaryrefslogtreecommitdiff
path: root/ssh-rsa.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-rsa.c')
-rw-r--r--ssh-rsa.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/ssh-rsa.c b/ssh-rsa.c
index 3e66294e9..782279bad 100644
--- a/ssh-rsa.c
+++ b/ssh-rsa.c
@@ -23,7 +23,7 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26RCSID("$OpenBSD: ssh-rsa.c,v 1.20 2002/06/10 16:53:06 stevesk Exp $"); 26RCSID("$OpenBSD: ssh-rsa.c,v 1.21 2002/06/23 03:30:17 deraadt Exp $");
27 27
28#include <openssl/evp.h> 28#include <openssl/evp.h>
29#include <openssl/err.h> 29#include <openssl/err.h>
@@ -39,9 +39,7 @@ RCSID("$OpenBSD: ssh-rsa.c,v 1.20 2002/06/10 16:53:06 stevesk Exp $");
39 39
40/* RSASSA-PKCS1-v1_5 (PKCS #1 v2.0 signature) with SHA1 */ 40/* RSASSA-PKCS1-v1_5 (PKCS #1 v2.0 signature) with SHA1 */
41int 41int
42ssh_rsa_sign( 42ssh_rsa_sign(Key *key, u_char **sigp, u_int *lenp,
43 Key *key,
44 u_char **sigp, u_int *lenp,
45 u_char *data, u_int datalen) 43 u_char *data, u_int datalen)
46{ 44{
47 const EVP_MD *evp_md; 45 const EVP_MD *evp_md;
@@ -72,17 +70,18 @@ ssh_rsa_sign(
72 70
73 if (ok != 1) { 71 if (ok != 1) {
74 int ecode = ERR_get_error(); 72 int ecode = ERR_get_error();
75 error("ssh_rsa_sign: RSA_sign failed: %s", ERR_error_string(ecode, NULL)); 73 error("ssh_rsa_sign: RSA_sign failed: %s",
74 ERR_error_string(ecode, NULL));
76 xfree(sig); 75 xfree(sig);
77 return -1; 76 return -1;
78 } 77 }
79 if (len < slen) { 78 if (len < slen) {
80 int diff = slen - len; 79 int diff = slen - len;
81 debug("slen %d > len %d", slen, len); 80 debug("slen %u > len %u", slen, len);
82 memmove(sig + diff, sig, len); 81 memmove(sig + diff, sig, len);
83 memset(sig, 0, diff); 82 memset(sig, 0, diff);
84 } else if (len > slen) { 83 } else if (len > slen) {
85 error("ssh_rsa_sign: slen %d slen2 %d", slen, len); 84 error("ssh_rsa_sign: slen %u slen2 %u", slen, len);
86 xfree(sig); 85 xfree(sig);
87 return -1; 86 return -1;
88 } 87 }
@@ -105,9 +104,7 @@ ssh_rsa_sign(
105} 104}
106 105
107int 106int
108ssh_rsa_verify( 107ssh_rsa_verify(Key *key, u_char *signature, u_int signaturelen,
109 Key *key,
110 u_char *signature, u_int signaturelen,
111 u_char *data, u_int datalen) 108 u_char *data, u_int datalen)
112{ 109{
113 Buffer b; 110 Buffer b;
@@ -148,12 +145,12 @@ ssh_rsa_verify(
148 /* RSA_verify expects a signature of RSA_size */ 145 /* RSA_verify expects a signature of RSA_size */
149 modlen = RSA_size(key->rsa); 146 modlen = RSA_size(key->rsa);
150 if (len > modlen) { 147 if (len > modlen) {
151 error("ssh_rsa_verify: len %d > modlen %d", len, modlen); 148 error("ssh_rsa_verify: len %u > modlen %u", len, modlen);
152 xfree(sigblob); 149 xfree(sigblob);
153 return -1; 150 return -1;
154 } else if (len < modlen) { 151 } else if (len < modlen) {
155 int diff = modlen - len; 152 int diff = modlen - len;
156 debug("ssh_rsa_verify: add padding: modlen %d > len %d", 153 debug("ssh_rsa_verify: add padding: modlen %u > len %u",
157 modlen, len); 154 modlen, len);
158 sigblob = xrealloc(sigblob, modlen); 155 sigblob = xrealloc(sigblob, modlen);
159 memmove(sigblob + diff, sigblob, len); 156 memmove(sigblob + diff, sigblob, len);
@@ -176,7 +173,8 @@ ssh_rsa_verify(
176 xfree(sigblob); 173 xfree(sigblob);
177 if (ret == 0) { 174 if (ret == 0) {
178 int ecode = ERR_get_error(); 175 int ecode = ERR_get_error();
179 error("ssh_rsa_verify: RSA_verify failed: %s", ERR_error_string(ecode, NULL)); 176 error("ssh_rsa_verify: RSA_verify failed: %s",
177 ERR_error_string(ecode, NULL));
180 } 178 }
181 debug("ssh_rsa_verify: signature %scorrect", (ret==0) ? "in" : ""); 179 debug("ssh_rsa_verify: signature %scorrect", (ret==0) ? "in" : "");
182 return ret; 180 return ret;