]> andersk Git - openssh.git/blobdiff - authfile.c
- djm@cvs.openbsd.org 2010/01/30 02:54:53
[openssh.git] / authfile.c
index 735c6478096495fa392c74d1a1cdb8f73a405f90..2c615709da7a4dd2eec1896fbfcb00dc8ca91e62 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: authfile.c,v 1.76 2006/08/03 03:34:41 deraadt Exp $ */
+/* $OpenBSD: authfile.c,v 1.79 2010/01/12 00:16:47 dtucker Exp $ */
 /*
  * Author: Tatu Ylonen <ylo@cs.hut.fi>
  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -47,6 +47,9 @@
 #include <openssl/evp.h>
 #include <openssl/pem.h>
 
+/* compatibility with old or broken OpenSSL versions */
+#include "openbsd-compat/openssl-compat.h"
+
 #include <errno.h>
 #include <fcntl.h>
 #include <stdarg.h>
@@ -184,7 +187,11 @@ key_save_private_pem(Key *key, const char *filename, const char *_passphrase,
        int success = 0;
        int len = strlen(_passphrase);
        u_char *passphrase = (len > 0) ? (u_char *)_passphrase : NULL;
+#if (OPENSSL_VERSION_NUMBER < 0x00907000L)
        const EVP_CIPHER *cipher = (len > 0) ? EVP_des_ede3_cbc() : NULL;
+#else
+       const EVP_CIPHER *cipher = (len > 0) ? EVP_aes_128_cbc() : NULL;
+#endif
 
        if (len > 0 && len <= 4) {
                error("passphrase too short: have %d bytes, need > 4", len);
@@ -552,8 +559,13 @@ key_load_private_type(int type, const char *filename, const char *passphrase,
        int fd;
 
        fd = open(filename, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
+               debug("could not open key file '%s': %s", filename,
+                   strerror(errno));
+               if (perm_ok != NULL)
+                       *perm_ok = 0;
                return NULL;
+       }
        if (!key_perm_ok(fd, filename)) {
                if (perm_ok != NULL)
                        *perm_ok = 0;
@@ -588,8 +600,11 @@ key_load_private(const char *filename, const char *passphrase,
        int fd;
 
        fd = open(filename, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
+               debug("could not open key file '%s': %s", filename,
+                   strerror(errno));
                return NULL;
+       }
        if (!key_perm_ok(fd, filename)) {
                error("bad permissions: ignore key: %s", filename);
                close(fd);
This page took 0.035205 seconds and 4 git commands to generate.