diff options
author | Kevin Butler <haqkrs@gmail.com> | 2013-09-01 17:38:01 +0100 |
---|---|---|
committer | Kevin Butler <haqkrs@gmail.com> | 2013-09-01 17:38:01 +0100 |
commit | 6e17fa6d7ba57b990dd929e07969d35dc82fc46b (patch) | |
tree | cb6d7b7e79941df0dec6b7379821c6e8f2cbebe8 /src/common/crypto.c | |
parent | 00bcc25d05dc0273323a2cae20c6aa62afd4b50a (diff) | |
download | tor-6e17fa6d7ba57b990dd929e07969d35dc82fc46b.tar.gz tor-6e17fa6d7ba57b990dd929e07969d35dc82fc46b.zip |
Added --library-versions flag to print the compile time and runtime versions of libevent, openssl and zlib. Partially implements #6384.
Diffstat (limited to 'src/common/crypto.c')
-rw-r--r-- | src/common/crypto.c | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/common/crypto.c b/src/common/crypto.c index 6f1a0bca57..5be3327b81 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -195,6 +195,24 @@ try_load_engine(const char *path, const char *engine) } #endif +static char * +parse_openssl_version_str(const char *raw_version) +{ + const char *end_of_version = NULL; + /* The output should be something like "OpenSSL 1.0.0b 10 May 2012. Let's + trim that down. */ + if (!strcmpstart(raw_version, "OpenSSL ")) { + raw_version += strlen("OpenSSL "); + end_of_version = strchr(raw_version, ' '); + } + + if (end_of_version) + return tor_strndup(raw_version, + end_of_version-raw_version); + else + return tor_strdup(raw_version); +} + static char *crypto_openssl_version_str = NULL; /* Return a human-readable version of the run-time openssl version number. */ const char * @@ -202,23 +220,20 @@ crypto_openssl_get_version_str(void) { if (crypto_openssl_version_str == NULL) { const char *raw_version = SSLeay_version(SSLEAY_VERSION); - const char *end_of_version = NULL; - /* The output should be something like "OpenSSL 1.0.0b 10 May 2012. Let's - trim that down. */ - if (!strcmpstart(raw_version, "OpenSSL ")) { - raw_version += strlen("OpenSSL "); - end_of_version = strchr(raw_version, ' '); - } - - if (end_of_version) - crypto_openssl_version_str = tor_strndup(raw_version, - end_of_version-raw_version); - else - crypto_openssl_version_str = tor_strdup(raw_version); + crypto_openssl_version_str = parse_openssl_version_str(raw_version); } return crypto_openssl_version_str; } +/* Return a human-readable version of the compile-time openssl version +* number. */ +const char * +crypto_openssl_get_header_version_str(void) +{ + //return OPENSSL_VERSION_TEXT; + return parse_openssl_version_str(OPENSSL_VERSION_TEXT); +} + /** Initialize the crypto library. Return 0 on success, -1 on failure. */ int |