]> andersk Git - openssh.git/blobdiff - authfile.c
- jakob@cvs.openbsd.org 2001/08/02 16:14:05
[openssh.git] / authfile.c
index 2715bdef8c4e8929c89d2f4f935e30c5b805a153..b4b985c95a1f250fec8528ce1db9e798144b2cb0 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.33 2001/05/16 20:51:57 markus Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.37 2001/06/23 15:12:17 itojun Exp $");
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
@@ -62,7 +62,7 @@ static const char authfile_id_string[] =
  * passphrase.
  */
 
-int
+static int
 key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
     const char *comment)
 {
@@ -125,7 +125,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
        buffer_put_int(&encrypted, BN_num_bits(key->rsa->n));
        buffer_put_bignum(&encrypted, key->rsa->n);
        buffer_put_bignum(&encrypted, key->rsa->e);
-       buffer_put_string(&encrypted, comment, strlen(comment));
+       buffer_put_cstring(&encrypted, comment);
 
        /* Allocate space for the private part of the key in the buffer. */
        buffer_append_space(&encrypted, &cp, buffer_len(&buffer));
@@ -159,7 +159,7 @@ key_save_private_rsa1(Key *key, const char *filename, const char *passphrase,
 }
 
 /* save SSH v2 key in OpenSSL PEM format */
-int
+static int
 key_save_private_pem(Key *key, const char *filename, const char *_passphrase,
     const char *comment)
 {
@@ -226,7 +226,7 @@ key_save_private(Key *key, const char *filename, const char *passphrase,
  * otherwise.
  */
 
-Key *
+static Key *
 key_load_public_rsa1(int fd, const char *filename, char **commentp)
 {
        Buffer buffer;
@@ -306,7 +306,7 @@ key_load_public_type(int type, const char *filename, char **commentp)
  * Assumes we are called under uid of the owner of the file.
  */
 
-Key *
+static Key *
 key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
     char **commentp)
 {
@@ -430,7 +430,7 @@ fail:
        return NULL;
 }
 
-Key *
+static Key *
 key_load_private_pem(int fd, int type, const char *passphrase,
     char **commentp)
 {
@@ -481,7 +481,7 @@ key_load_private_pem(int fd, int type, const char *passphrase,
        return prv;
 }
 
-int
+static int
 key_perm_ok(int fd, const char *filename)
 {
        struct stat st;
@@ -543,7 +543,7 @@ Key *
 key_load_private(const char *filename, const char *passphrase,
     char **commentp)
 {
-       Key *pub;
+       Key *pub, *prv;
        int fd;
 
        fd = open(filename, O_RDONLY);
@@ -558,17 +558,20 @@ key_load_private(const char *filename, const char *passphrase,
        lseek(fd, (off_t) 0, SEEK_SET);         /* rewind */
        if (pub == NULL) {
                /* closes fd */
-               return key_load_private_pem(fd, KEY_UNSPEC, passphrase,
-                   commentp);
+               prv = key_load_private_pem(fd, KEY_UNSPEC, passphrase, NULL);
+               /* use the filename as a comment for PEM */
+               if (commentp && prv)
+                       *commentp = xstrdup(filename);
        } else {
                /* it's a SSH v1 key if the public key part is readable */
                key_free(pub);
                /* closes fd */
-               return key_load_private_rsa1(fd, filename, passphrase, NULL);
+               prv = key_load_private_rsa1(fd, filename, passphrase, NULL);
        }
+       return prv;
 }
 
-int
+static int
 key_try_load_public(Key *k, const char *filename, char **commentp)
 {
        FILE *f;
This page took 0.098312 seconds and 4 git commands to generate.