summaryrefslogtreecommitdiff
path: root/src/common/crypto.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-05 15:05:17 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-10 10:40:30 -0500
commit85c7d7659ea1b9c99c13596e943260ad2e396483 (patch)
tree5a3700122078de625883b9b2a34f6696533724ae /src/common/crypto.c
parent6b9298ef72997c1cd0ed2e9c47abeb6c06f64f9f (diff)
downloadtor-85c7d7659ea1b9c99c13596e943260ad2e396483.tar.gz
tor-85c7d7659ea1b9c99c13596e943260ad2e396483.zip
Add macros to construct openssl version numbers
It's a pain to convert 0x0090813f to and from 0.9.8s-release on the fly, so these macros should help.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r--src/common/crypto.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c
index d1d823da7e..aa8ceed938 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -60,7 +60,7 @@
#include "container.h"
#include "compat.h"
-#if OPENSSL_VERSION_NUMBER < 0x00907000l
+#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(0,9,7)
#error "We require OpenSSL >= 0.9.7"
#endif
@@ -72,7 +72,7 @@
/** Longest recognized */
#define MAX_DNS_LABEL_SIZE 63
-#if OPENSSL_VERSION_NUMBER < 0x00908000l
+#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(0,9,8)
/** @{ */
/** On OpenSSL versions before 0.9.8, there is no working SHA256
* implementation, so we use Tom St Denis's nice speedy one, slightly adapted
@@ -452,7 +452,7 @@ crypto_pk_generate_key_with_bits(crypto_pk_env_t *env, int bits)
if (env->key)
RSA_free(env->key);
-#if OPENSSL_VERSION_NUMBER < 0x00908000l
+#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(0,9,8)
/* In OpenSSL 0.9.7, RSA_generate_key is all we have. */
env->key = RSA_generate_key(bits, 65537, NULL, NULL);
#else
@@ -1723,7 +1723,7 @@ crypto_hmac_sha256(char *hmac_out,
const char *key, size_t key_len,
const char *msg, size_t msg_len)
{
-#if (OPENSSL_VERSION_NUMBER >= 0x00908000l)
+#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(0,9,8)
/* If we've got OpenSSL >=0.9.8 we can use its hmac implementation. */
tor_assert(key_len < INT_MAX);
tor_assert(msg_len < INT_MAX);
@@ -2363,9 +2363,8 @@ crypto_dh_free(crypto_dh_env_t *dh)
/** True iff we should use OpenSSL's RAND_poll function to add entropy to its
* pool.
*
- * Use RAND_poll if OpenSSL is 0.9.6 release or later. (The "f" means
- *"release".) */
-#define HAVE_RAND_POLL (OPENSSL_VERSION_NUMBER >= 0x0090600fl)
+ * Use RAND_poll if OpenSSL is 0.9.6 release or later. */
+#define HAVE_RAND_POLL (OPENSSL_VERSION_NUMBER >= OPENSSL_V_NOPATCH(0,9,6))
/** True iff it's safe to use RAND_poll after setup.
*
@@ -2374,9 +2373,9 @@ crypto_dh_free(crypto_dh_env_t *dh)
* that fd without checking whether it fit in the fd_set. Thus, if the
* system has not just been started up, it is unsafe to call */
#define RAND_POLL_IS_SAFE \
- ((OPENSSL_VERSION_NUMBER >= 0x009070afl && \
- OPENSSL_VERSION_NUMBER <= 0x00907fffl) || \
- (OPENSSL_VERSION_NUMBER >= 0x0090803fl))
+ ((OPENSSL_VERSION_NUMBER >= OPENSSL_V(0,9,7,'j') && \
+ OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(0,9,8)) || \
+ OPENSSL_VERSION_NUMBER >= OPENSSL_V(0,9,8,'c'))
/** Set the seed of the weak RNG to a random value. */
static void