]> andersk Git - openssh.git/blobdiff - authfile.c
- (bal) auth1.c minor resync while looking at the code.
[openssh.git] / authfile.c
index de8b1022ee4a4232ca9d75798b35526ddd88e1d2..90618efdef8894db5fa5cbe60d929ad44ccdddfb 100644 (file)
@@ -36,7 +36,7 @@
  */
 
 #include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.48 2002/02/28 15:46:33 markus Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.52 2003/03/13 11:42:18 markus Exp $");
 
 #include <openssl/err.h>
 #include <openssl/evp.h>
@@ -232,12 +232,17 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
 {
        Buffer buffer;
        Key *pub;
+       struct stat st;
        char *cp;
        int i;
        off_t len;
 
-       len = lseek(fd, (off_t) 0, SEEK_END);
-       lseek(fd, (off_t) 0, SEEK_SET);
+       if (fstat(fd, &st) < 0) {
+               error("fstat for key file %.200s failed: %.100s",
+                   filename, strerror(errno));
+               return NULL;
+       }
+       len = st.st_size;
 
        buffer_init(&buffer);
        cp = buffer_append_space(&buffer, len);
@@ -270,7 +275,7 @@ key_load_public_rsa1(int fd, const char *filename, char **commentp)
        (void) buffer_get_int(&buffer);         /* reserved */
 
        /* Read the public key from the buffer. */
-       buffer_get_int(&buffer);
+       (void) buffer_get_int(&buffer);
        pub = key_new(KEY_RSA1);
        buffer_get_bignum(&buffer, pub->rsa->n);
        buffer_get_bignum(&buffer, pub->rsa->e);
@@ -318,9 +323,15 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        CipherContext ciphercontext;
        Cipher *cipher;
        Key *prv = NULL;
+       struct stat st;
 
-       len = lseek(fd, (off_t) 0, SEEK_END);
-       lseek(fd, (off_t) 0, SEEK_SET);
+       if (fstat(fd, &st) < 0) {
+               error("fstat for key file %.200s failed: %.100s",
+                   filename, strerror(errno));
+               close(fd);
+               return NULL;
+       }
+       len = st.st_size;
 
        buffer_init(&buffer);
        cp = buffer_append_space(&buffer, len);
@@ -357,7 +368,7 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        (void) buffer_get_int(&buffer); /* Reserved data. */
 
        /* Read the public key from the buffer. */
-       buffer_get_int(&buffer);
+       (void) buffer_get_int(&buffer);
        prv = key_new_private(KEY_RSA1);
 
        buffer_get_bignum(&buffer, prv->rsa->n);
@@ -410,6 +421,12 @@ key_load_private_rsa1(int fd, const char *filename, const char *passphrase,
        rsa_generate_additional_parameters(prv->rsa);
 
        buffer_free(&decrypted);
+
+       /* enable blinding */
+       if (RSA_blinding_on(prv->rsa, NULL) != 1) {
+               error("key_load_private_rsa1: RSA_blinding_on failed");
+               goto fail;
+       }
        close(fd);
        return prv;
 
@@ -421,7 +438,7 @@ fail:
        return NULL;
 }
 
-static Key *
+Key *
 key_load_private_pem(int fd, int type, const char *passphrase,
     char **commentp)
 {
@@ -449,6 +466,11 @@ key_load_private_pem(int fd, int type, const char *passphrase,
 #ifdef DEBUG_PK
                RSA_print_fp(stderr, prv->rsa, 8);
 #endif
+               if (RSA_blinding_on(prv->rsa, NULL) != 1) {
+                       error("key_load_private_pem: RSA_blinding_on failed");
+                       key_free(prv);
+                       prv = NULL;
+               }
        } else if (pk->type == EVP_PKEY_DSA &&
            (type == KEY_UNSPEC||type==KEY_DSA)) {
                prv = key_new(KEY_UNSPEC);
This page took 0.034313 seconds and 4 git commands to generate.