Added support for OpenSSL 1.1

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
pull/2/head
Slávek Banko 8 years ago
parent 435ea0b78d
commit 19f9a09ee2

@ -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

Loading…
Cancel
Save