]> andersk Git - openssh.git/blobdiff - rsa.c
- OpenBSD CVS updates:
[openssh.git] / rsa.c
diff --git a/rsa.c b/rsa.c
index 90eced3c4da0268bf92a63ee3e5373b6364c16ee..5cc987df9116991cd10b14d81c5266da33e0d470 100644 (file)
--- a/rsa.c
+++ b/rsa.c
@@ -44,11 +44,25 @@ RCSID("$Id$");
 
 int rsa_verbose = 1;
 
+/*
+ * Seed OpenSSL's random number generator
+ */
+void
+seed_rng()
+{
+       char buf[64];
+
+       get_random_bytes(buf, sizeof(buf));
+       RAND_seed(buf, sizeof(buf));
+       memset(buf, 0, sizeof(buf));
+}
+
 int
 rsa_alive()
 {
        RSA *key;
 
+       seed_rng();
        key = RSA_generate_key(32, 3, NULL, NULL);
        if (key == NULL)
                return (0);
@@ -71,19 +85,6 @@ keygen_progress(int p, int n, void *arg)
        fflush(stdout);
 }
 
-/*
- * Seed OpenSSL's random number generator
- */
-void
-seed_rng()
-{
-       char buf[32];
-
-       get_random_bytes(buf, sizeof(buf));
-       RAND_seed(buf, sizeof(buf));
-       memset(buf, 0, sizeof(buf));
-}
-
 /*
  * Generates RSA public and private keys.  This initializes the data
  * structures; they should be freed with rsa_clear_private_key and
@@ -144,7 +145,7 @@ rsa_generate_key(RSA *prv, RSA *pub, unsigned int bits)
 void
 rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
 {
-       char *inbuf, *outbuf;
+       unsigned char *inbuf, *outbuf;
        int len, ilen, olen;
 
        if (BN_num_bits(key->e) < 2 || !BN_is_odd(key->e))
@@ -158,7 +159,7 @@ rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
        BN_bn2bin(in, inbuf);
 
        if ((len = RSA_public_encrypt(ilen, inbuf, outbuf, key,
-                                     RSA_PKCS1_PADDING)) <= 0)
+           RSA_PKCS1_PADDING)) <= 0)
                fatal("rsa_public_encrypt() failed");
 
        BN_bin2bn(outbuf, len, out);
@@ -172,7 +173,7 @@ rsa_public_encrypt(BIGNUM *out, BIGNUM *in, RSA *key)
 void
 rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
 {
-       char *inbuf, *outbuf;
+       unsigned char *inbuf, *outbuf;
        int len, ilen, olen;
 
        olen = BN_num_bytes(key->n);
@@ -183,7 +184,7 @@ rsa_private_decrypt(BIGNUM *out, BIGNUM *in, RSA *key)
        BN_bn2bin(in, inbuf);
 
        if ((len = RSA_private_decrypt(ilen, inbuf, outbuf, key,
-                                      RSA_SSLV23_PADDING)) <= 0)
+           RSA_PKCS1_PADDING)) <= 0)
                fatal("rsa_private_decrypt() failed");
 
        BN_bin2bn(outbuf, len, out);
This page took 0.038722 seconds and 4 git commands to generate.