aboutsummaryrefslogtreecommitdiff
path: root/src/common/crypto.h
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.h
parent6b9298ef72997c1cd0ed2e9c47abeb6c06f64f9f (diff)
downloadtor-85c7d7659ea1b9c99c13596e943260ad2e396483.tar
tor-85c7d7659ea1b9c99c13596e943260ad2e396483.tar.gz
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.h')
-rw-r--r--src/common/crypto.h32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/common/crypto.h b/src/common/crypto.h
index 771c49c2d..478365444 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -16,6 +16,38 @@
#include <stdio.h>
#include "torint.h"
+/*
+ Macro to create an arbitrary OpenSSL version number as used by
+ OPENSSL_VERSION_NUMBER or SSLeay(), since the actual numbers are a bit hard
+ to read.
+
+ Don't use this directly, instead use one of the other OPENSSL_V macros
+ below.
+
+ The format is: 4 bits major, 8 bits minor, 8 bits fix, 8 bits patch, 4 bit
+ status.
+ */
+#define OPENSSL_VER(a,b,c,d,e) \
+ (((a)<<28) | \
+ ((b)<<20) | \
+ ((c)<<12) | \
+ ((d)<< 4) | \
+ (e))
+/** An openssl release number. For example, OPENSSL_V(0,9,8,'j') is the
+ * version for the released version of 0.9.8j */
+#define OPENSSL_V(a,b,c,d) \
+ OPENSSL_VER((a),(b),(c),(d)-'a'+1,0xf)
+/** An openssl release number for the first release in the series. For
+ * example, OPENSSL_V_NOPATCH(1,0,0) is the first released version of OpenSSL
+ * 1.0.0. */
+#define OPENSSL_V_NOPATCH(a,b,c) \
+ OPENSSL_VER((a),(b),(c),0,0xf)
+/** The first version that would occur for any alpha or beta in an openssl
+ * series. For example, OPENSSL_V_SERIES(0,9,8) is greater than any released
+ * 0.9.7, and less than any released 0.9.8. */
+#define OPENSSL_V_SERIES(a,b,c) \
+ OPENSSL_VER((a),(b),(c),0,0)
+
/** Length of the output of our message digest. */
#define DIGEST_LEN 20
/** Length of the output of our second (improved) message digests. (For now