]> andersk Git - openssh.git/blobdiff - key.c
- markus@cvs.openbsd.org 2003/06/24 08:23:46
[openssh.git] / key.c
diff --git a/key.c b/key.c
index 718cd16c0cd7012c417cdb09a0bd6c794450f28e..b101e1b271c763b2467bc3bad5d5b04027e677d4 100644 (file)
--- a/key.c
+++ b/key.c
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 #include "includes.h"
-RCSID("$OpenBSD: key.c,v 1.46 2002/06/30 21:59:45 deraadt Exp $");
+RCSID("$OpenBSD: key.c,v 1.53 2003/06/24 08:23:46 markus Exp $");
 
 #include <openssl/evp.h>
 
 #include "xmalloc.h"
 #include "key.h"
 #include "rsa.h"
-#include "ssh-dss.h"
-#include "ssh-rsa.h"
 #include "uuencode.h"
 #include "buffer.h"
 #include "bufaux.h"
@@ -171,7 +169,7 @@ key_equal(Key *a, Key *b)
        return 0;
 }
 
-static u_char *
+u_char*
 key_fingerprint_raw(Key *k, enum fp_type dgst_type, u_int *dgst_raw_length)
 {
        const EVP_MD *md = NULL;
@@ -410,14 +408,14 @@ key_read(Key *ret, char **cpp)
        case KEY_DSA:
                space = strchr(cp, ' ');
                if (space == NULL) {
-                       debug3("key_read: no space");
+                       debug3("key_read: missing whitespace");
                        return -1;
                }
                *space = '\0';
                type = key_type_from_name(cp);
                *space = ' ';
                if (type == KEY_UNSPEC) {
-                       debug3("key_read: no key found");
+                       debug3("key_read: missing keytype");
                        return -1;
                }
                cp = space+1;
@@ -440,7 +438,7 @@ key_read(Key *ret, char **cpp)
                        xfree(blob);
                        return -1;
                }
-               k = key_from_blob(blob, n);
+               k = key_from_blob(blob, (u_int)n);
                xfree(blob);
                if (k == NULL) {
                        error("key_read: key_from_blob %s failed", cp);
@@ -494,7 +492,8 @@ key_write(Key *key, FILE *f)
 {
        int n, success = 0;
        u_int len, bits = 0;
-       u_char *blob, *uu;
+       u_char *blob;
+       char *uu;
 
        if (key->type == KEY_RSA1 && key->rsa != NULL) {
                /* size of modulus 'n' */
@@ -675,7 +674,7 @@ key_names_valid2(const char *names)
 }
 
 Key *
-key_from_blob(u_char *blob, int blen)
+key_from_blob(u_char *blob, u_int blen)
 {
        Buffer b;
        char *ktype;
@@ -729,7 +728,6 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp)
 {
        Buffer b;
        int len;
-       u_char *buf;
 
        if (key == NULL) {
                error("key_to_blob: key == NULL");
@@ -755,14 +753,14 @@ key_to_blob(Key *key, u_char **blobp, u_int *lenp)
                return 0;
        }
        len = buffer_len(&b);
-       buf = xmalloc(len);
-       memcpy(buf, buffer_ptr(&b), len);
-       memset(buffer_ptr(&b), 0, len);
-       buffer_free(&b);
        if (lenp != NULL)
                *lenp = len;
-       if (blobp != NULL)
-               *blobp = buf;
+       if (blobp != NULL) {
+               *blobp = xmalloc(len);
+               memcpy(*blobp, buffer_ptr(&b), len);
+       }
+       memset(buffer_ptr(&b), 0, len);
+       buffer_free(&b);
        return len;
 }
 
This page took 0.051652 seconds and 4 git commands to generate.