]> andersk Git - openssh.git/blobdiff - ssh-add.c
- (djm) Stop shadow expiry checking from preventing logins with NIS. Based
[openssh.git] / ssh-add.c
index d81510e1d63b64cec91da3f5eb4f39cdc2a12d28..661e1ffa92d7f2c623b4be8a1a9d007cbde1d6d1 100644 (file)
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -7,36 +7,41 @@
  */
 
 #include "includes.h"
-RCSID("$Id$");
+RCSID("$OpenBSD: ssh-add.c,v 1.17 2000/06/20 01:39:44 markus Exp $");
+
+#include <openssl/rsa.h>
+#include <openssl/dsa.h>
 
 #include "rsa.h"
 #include "ssh.h"
 #include "xmalloc.h"
 #include "authfd.h"
 #include "fingerprint.h"
+#include "key.h"
+#include "authfile.h"
 
 #ifdef HAVE___PROGNAME
 extern char *__progname;
 #else /* HAVE___PROGNAME */
-const char *__progname = "ssh-add";
+static const char *__progname = "ssh-add";
 #endif /* HAVE___PROGNAME */
 
 void
 delete_file(AuthenticationConnection *ac, const char *filename)
 {
-       RSA *key;
+       Key *public;
        char *comment;
 
-       key = RSA_new();
-       if (!load_public_key(filename, key, &comment)) {
+       public = key_new(KEY_RSA);
+       if (!load_public_key(filename, public, &comment)) {
                printf("Bad key file %s: %s\n", filename, strerror(errno));
                return;
        }
-       if (ssh_remove_identity(ac, key))
+       if (ssh_remove_identity(ac, public->rsa))
                fprintf(stderr, "Identity removed: %s (%s)\n", filename, comment);
        else
                fprintf(stderr, "Could not remove identity: %s\n", filename);
-       RSA_free(key);
+       key_free(public);
        xfree(comment);
 }
 
@@ -91,20 +96,19 @@ ssh_askpass(char *askpass, char *msg)
 void
 add_file(AuthenticationConnection *ac, const char *filename)
 {
-       RSA *key;
-       RSA *public_key;
+       Key *public;
+       Key *private;
        char *saved_comment, *comment, *askpass = NULL;
        char buf[1024], msg[1024];
        int success;
        int interactive = isatty(STDIN_FILENO);
 
-       key = RSA_new();
-       public_key = RSA_new();
-       if (!load_public_key(filename, public_key, &saved_comment)) {
+       public = key_new(KEY_RSA);
+       if (!load_public_key(filename, public, &saved_comment)) {
                printf("Bad key file %s: %s\n", filename, strerror(errno));
                return;
        }
-       RSA_free(public_key);
+       key_free(public);
 
        if (!interactive && getenv("DISPLAY")) {
                if (getenv(SSH_ASKPASS_ENV))
@@ -114,7 +118,8 @@ add_file(AuthenticationConnection *ac, const char *filename)
        }
 
        /* At first, try empty passphrase */
-       success = load_private_key(filename, "", key, &comment);
+       private = key_new(KEY_RSA);
+       success = load_private_key(filename, "", private, &comment);
        if (!success) {
                printf("Need passphrase for %.200s\n", filename);
                if (!interactive && askpass == NULL) {
@@ -135,7 +140,7 @@ add_file(AuthenticationConnection *ac, const char *filename)
                                xfree(saved_comment);
                                return;
                        }
-                       success = load_private_key(filename, pass, key, &comment);
+                       success = load_private_key(filename, pass, private, &comment);
                        memset(pass, 0, strlen(pass));
                        xfree(pass);
                        if (success)
@@ -145,11 +150,11 @@ add_file(AuthenticationConnection *ac, const char *filename)
        }
        xfree(saved_comment);
 
-       if (ssh_add_identity(ac, key, comment))
+       if (ssh_add_identity(ac, private->rsa, comment))
                fprintf(stderr, "Identity added: %s (%s)\n", filename, comment);
        else
                fprintf(stderr, "Could not add identity: %s\n", filename);
-       RSA_free(key);
+       key_free(private);
        xfree(comment);
 }
 
This page took 0.036811 seconds and 4 git commands to generate.