summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSlávek Banko <[email protected]>2017-01-17 19:58:20 +0100
committerSlávek Banko <[email protected]>2017-01-17 19:58:32 +0100
commit097987a3c73cfcd21f026e48b1204e1a89797c8b (patch)
tree6f0ffc139b6c4cc3366ea68affc29f2ff4114c55 /src
parentdac47be70aaaac6ba2794a504d1a6ee22bc04d70 (diff)
downloadtork-097987a3c73cfcd21f026e48b1204e1a89797c8b.tar.gz
tork-097987a3c73cfcd21f026e48b1204e1a89797c8b.zip
Added support for OpenSSL 1.1
Signed-off-by: Slávek Banko <[email protected]> (cherry picked from commit 19f9a09ee257137e62517378c50b205c2bfe3036)
Diffstat (limited to 'src')
-rw-r--r--src/crypto.cpp36
1 files changed, 28 insertions, 8 deletions
diff --git a/src/crypto.cpp b/src/crypto.cpp
index 9adfbac..3fb4696 100644
--- a/src/crypto.cpp
+++ b/src/crypto.cpp
@@ -327,7 +327,7 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
// gnutls_datum_t data_in;
base64_decodestate state;
#else
- EVP_ENCODE_CTX ctx;
+ EVP_ENCODE_CTX *ctx;
int len;
#endif
int ret;
@@ -355,10 +355,20 @@ base64_decode(char *dest, size_t destlen, const char *src, size_t srclen)
ret = base64_decode_block(src, srclen, dest, &state);
return ret;
#else
- EVP_DecodeInit(&ctx);
- EVP_DecodeUpdate(&ctx, (unsigned char*)dest, &len,
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ ctx = (EVP_ENCODE_CTX*)OPENSSL_malloc( sizeof(EVP_ENCODE_CTX) );
+#else
+ ctx = EVP_ENCODE_CTX_new();
+#endif
+ EVP_DecodeInit(ctx);
+ EVP_DecodeUpdate(ctx, (unsigned char*)dest, &len,
(unsigned char*)src, srclen);
- EVP_DecodeFinal(&ctx, (unsigned char*)dest, &ret);
+ EVP_DecodeFinal(ctx, (unsigned char*)dest, &ret);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ OPENSSL_free(ctx);
+#else
+ EVP_ENCODE_CTX_free(ctx);
+#endif
ret += len;
return ret;
#endif
@@ -382,7 +392,7 @@ base64_encode(char *dest, size_t destlen, const char *src, size_t srclen)
// gnutls_datum_t data_in;
base64_encodestate state;
#else
- EVP_ENCODE_CTX ctx;
+ EVP_ENCODE_CTX *ctx;
int len;
#endif
int ret;
@@ -411,10 +421,20 @@ base64_encode(char *dest, size_t destlen, const char *src, size_t srclen)
return ret;
#else
- EVP_EncodeInit(&ctx);
- EVP_EncodeUpdate(&ctx, (unsigned char*)dest, &len,
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ ctx = (EVP_ENCODE_CTX*)OPENSSL_malloc( sizeof(EVP_ENCODE_CTX) );
+#else
+ ctx = EVP_ENCODE_CTX_new();
+#endif
+ EVP_EncodeInit(ctx);
+ EVP_EncodeUpdate(ctx, (unsigned char*)dest, &len,
(unsigned char*)src, srclen);
- EVP_EncodeFinal(&ctx, (unsigned char*)(dest+len), &ret);
+ EVP_EncodeFinal(ctx, (unsigned char*)(dest+len), &ret);
+#if OPENSSL_VERSION_NUMBER < 0x10100000L
+ OPENSSL_free(ctx);
+#else
+ EVP_ENCODE_CTX_free(ctx);
+#endif
ret += len;
return ret;
#endif