]> andersk Git - openssh.git/blobdiff - ssh-keygen.c
- deraadt@cvs.openbsd.org 2002/05/22 23:18:25
[openssh.git] / ssh-keygen.c
index d14c9900450efb7e3c56c3b239ed9a8a028c8d6f..250e53e14b1a316665b5645d914c47e3922538aa 100644 (file)
@@ -12,7 +12,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: ssh-keygen.c,v 1.95 2002/03/21 16:54:53 markus Exp $");
+RCSID("$OpenBSD: ssh-keygen.c,v 1.98 2002/03/27 22:21:45 markus Exp $");
 
 #include <openssl/evp.h>
 #include <openssl/pem.h>
@@ -290,6 +290,7 @@ do_convert_from_ssh2(struct passwd *pw)
 {
        Key *k;
        int blen;
+       u_int len;
        char line[1024], *p;
        u_char blob[8096];
        char encoded[8096];
@@ -334,6 +335,12 @@ do_convert_from_ssh2(struct passwd *pw)
                *p = '\0';
                strlcat(encoded, line, sizeof(encoded));
        }
+       len = strlen(encoded);
+       if (((len % 4) == 3) &&
+           (encoded[len-1] == '=') &&
+           (encoded[len-2] == '=') &&
+           (encoded[len-3] == '='))
+               encoded[len-3] = '\0';
        blen = uudecode(encoded, blob, sizeof(blob));
        if (blen < 0) {
                fprintf(stderr, "uudecode failed.\n");
@@ -416,14 +423,18 @@ do_upload(struct passwd *pw, const char *sc_reader_id)
 static void
 do_download(struct passwd *pw, const char *sc_reader_id)
 {
-       Key *pub = NULL;
+       Key **keys = NULL;
+       int i;
 
-       pub = sc_get_key(sc_reader_id);
-       if (pub == NULL)
+       keys = sc_get_keys(sc_reader_id, NULL);
+       if (keys == NULL)
                fatal("cannot read public key from smartcard");
-       key_write(pub, stdout);
-       key_free(pub);
-       fprintf(stdout, "\n");
+       for (i = 0; keys[i]; i++) {
+               key_write(keys[i], stdout);
+               key_free(keys[i]);
+               fprintf(stdout, "\n");
+       }
+       xfree(keys);
        exit(0);
 }
 #endif /* SMARTCARD */
This page took 0.049722 seconds and 4 git commands to generate.