From 6825182b8137c036afcdc0e48397c0ea5ffc2404 Mon Sep 17 00:00:00 2001 From: Adriaan de Jong Date: Wed, 22 Jun 2011 17:16:03 +0200 Subject: Refactored to rand_bytes for OpenSSL-independency Signed-off-by: Adriaan de Jong Acked-by: David Sommerseth Signed-off-by: David Sommerseth --- crypto.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crypto.c') 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. + * Copyright (C) 2010 Fox Crypto B.V. * * 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 */ -- cgit