summaryrefslogtreecommitdiffstats
path: root/crypto.c
diff options
context:
space:
mode:
authorAdriaan de Jong <dejong@fox-it.com>2011-06-22 17:16:03 +0200
committerDavid Sommerseth <davids@redhat.com>2011-10-19 22:05:44 +0200
commit6825182b8137c036afcdc0e48397c0ea5ffc2404 (patch)
treeb65554fcab08105f5d8ad2866270c7630ee366d1 /crypto.c
parent0a18017472edb52c5535bc814c2aceaa2b562222 (diff)
downloadopenvpn-6825182b8137c036afcdc0e48397c0ea5ffc2404.tar.gz
openvpn-6825182b8137c036afcdc0e48397c0ea5ffc2404.tar.xz
openvpn-6825182b8137c036afcdc0e48397c0ea5ffc2404.zip
Refactored to rand_bytes for OpenSSL-independency
Signed-off-by: Adriaan de Jong <dejong@fox-it.com> Acked-by: David Sommerseth <davids@redhat.com> Signed-off-by: David Sommerseth <davids@redhat.com>
Diffstat (limited to 'crypto.c')
-rw-r--r--crypto.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/crypto.c b/crypto.c
index 5cfc34a..68b8564 100644
--- a/crypto.c
+++ b/crypto.c
@@ -6,6 +6,7 @@
* packet compression.
*
* Copyright (C) 2002-2010 OpenVPN Technologies, Inc. <sales@openvpn.net>
+ * Copyright (C) 2010 Fox Crypto B.V. <openvpn@fox-it.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2
@@ -803,8 +804,8 @@ generate_key_random (struct key *key, const struct key_type *kt)
if (kt->digest && kt->hmac_length > 0 && kt->hmac_length <= hmac_len)
hmac_len = kt->hmac_length;
}
- if (!RAND_bytes (key->cipher, cipher_len)
- || !RAND_bytes (key->hmac, hmac_len))
+ if (!rand_bytes (key->cipher, cipher_len)
+ || !rand_bytes (key->hmac, hmac_len))
msg (M_FATAL, "ERROR: Random number generator cannot obtain entropy for key generation");
dmsg (D_SHOW_KEY_SOURCE, "Cipher source entropy: %s", format_hex (key->cipher, cipher_len, 0, &gc));
@@ -870,7 +871,7 @@ test_crypto (const struct crypto_options *co, struct frame* frame)
ASSERT (buf_init (&src, 0));
ASSERT (i <= src.capacity);
src.len = i;
- ASSERT (RAND_pseudo_bytes (BPTR (&src), BLEN (&src)));
+ ASSERT (rand_bytes (BPTR (&src), BLEN (&src)));
/* copy source to input buf */
buf = work;
@@ -1671,7 +1672,7 @@ prng_init (const char *md_name, const int nonce_secret_len_parm)
nonce_data = (uint8_t*) malloc (size);
check_malloc_return (nonce_data);
#if 1 /* Must be 1 for real usage */
- if (!RAND_bytes (nonce_data, size))
+ if (!rand_bytes (nonce_data, size))
msg (M_FATAL, "ERROR: Random number generator cannot obtain entropy for PRNG");
#else
/* Only for testing -- will cause a predictable PRNG sequence */
@@ -1716,7 +1717,7 @@ prng_bytes (uint8_t *output, int len)
}
}
else
- RAND_bytes (output, len);
+ rand_bytes (output, len);
}
/* an analogue to the random() function, but use prng_bytes */