summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/ssh-keygen.c
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-06-23 06:41:11 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-06-23 06:41:11 +0000
commitfb175880d9258c15b5ad6e47f07ab155216c393c (patch)
treeca28604e932680b7f2d795795f884b2096b90765 /usr.bin/ssh/ssh-keygen.c
parent2b1148b2768299b6234c567734a8481d882161f5 (diff)
try to decode ssh-3.0.0 private rsa keys
(allow migration to openssh, not vice versa), #910
Diffstat (limited to 'usr.bin/ssh/ssh-keygen.c')
-rw-r--r--usr.bin/ssh/ssh-keygen.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/usr.bin/ssh/ssh-keygen.c b/usr.bin/ssh/ssh-keygen.c
index 2083e872ac3..7efe8d6d66c 100644
--- a/usr.bin/ssh/ssh-keygen.c
+++ b/usr.bin/ssh/ssh-keygen.c
@@ -12,7 +12,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-keygen.c,v 1.61 2001/05/25 14:37:32 markus Exp $");
+RCSID("$OpenBSD: ssh-keygen.c,v 1.62 2001/06/23 06:41:10 markus Exp $");
#include <openssl/evp.h>
#include <openssl/pem.h>
@@ -183,7 +183,8 @@ do_convert_private_ssh2_from_blob(char *blob, int blen)
{
Buffer b;
Key *key = NULL;
- int ignore, magic, rlen, ktype;
+ int magic, rlen, ktype, i1, i2, i3, i4;
+ u_long e;
char *type, *cipher;
buffer_init(&b);
@@ -195,13 +196,13 @@ do_convert_private_ssh2_from_blob(char *blob, int blen)
buffer_free(&b);
return NULL;
}
- ignore = buffer_get_int(&b);
+ i1 = buffer_get_int(&b);
type = buffer_get_string(&b, NULL);
cipher = buffer_get_string(&b, NULL);
- ignore = buffer_get_int(&b);
- ignore = buffer_get_int(&b);
- ignore = buffer_get_int(&b);
-
+ i2 = buffer_get_int(&b);
+ i3 = buffer_get_int(&b);
+ i4 = buffer_get_int(&b);
+ debug("ignore (%d %d %d %d)", i1,i2,i3,i4);
if (strcmp(cipher, "none") != 0) {
error("unsupported cipher %s", cipher);
xfree(cipher);
@@ -231,7 +232,17 @@ do_convert_private_ssh2_from_blob(char *blob, int blen)
buffer_get_bignum_bits(&b, key->dsa->priv_key);
break;
case KEY_RSA:
- if (!BN_set_word(key->rsa->e, (u_long) buffer_get_char(&b))) {
+ e = buffer_get_char(&b);
+ debug("e %lx", e);
+ if (e < 30) {
+ e <<= 8;
+ e += buffer_get_char(&b);
+ debug("e %lx", e);
+ e <<= 8;
+ e += buffer_get_char(&b);
+ debug("e %lx", e);
+ }
+ if (!BN_set_word(key->rsa->e, e)) {
buffer_free(&b);
key_free(key);
return NULL;
@@ -254,8 +265,8 @@ do_convert_private_ssh2_from_blob(char *blob, int blen)
u_int slen;
u_char *sig, data[10] = "abcde12345";
- key_sign(key, &sig, &slen, data, sizeof data);
- key_verify(key, sig, slen, data, sizeof data);
+ key_sign(key, &sig, &slen, data, sizeof(data));
+ key_verify(key, sig, slen, data, sizeof(data));
xfree(sig);
}
#endif