Added LibreSSL detection

Signed-off-by: Matías Fonzo <selk@dragora.org>
pull/4/head
Matías Fonzo 5 years ago
parent 07369b58fe
commit 9cd1493c36
No known key found for this signature in database
GPG Key ID: 3AAF1CEC203A99D5

@ -57,7 +57,7 @@ static bool lib_generateKeyIV(const EVP_CIPHER *_type, const TQByteArray &data,
TQByteArray k, i;
unsigned char *kp = 0;
unsigned char *ip = 0;
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
EVP_CIPHER type = *_type;
EVP_CIPHER *loctype = &type;
if(keysize != -1)
@ -75,7 +75,7 @@ static bool lib_generateKeyIV(const EVP_CIPHER *_type, const TQByteArray &data,
ip = (unsigned char *)i.data();
}
int res = EVP_BytesToKey(loctype, EVP_sha1(), (unsigned char *)salt.data(), (unsigned char *)data.data(), data.size(), 1, kp, ip);
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
EVP_CIPHER_meth_free(loctype);
#endif
if (!res)
@ -187,7 +187,7 @@ public:
virtual ~EVPCipherContext()
{
if(type) {
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
EVP_CIPHER_CTX_cleanup(c);
OPENSSL_free(c);
#else
@ -234,7 +234,7 @@ public:
pad = _pad;
type = getType(mode);
r.resize(0);
#if OPENSSL_VERSION_NUMBER < 0x10100000L
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
c = (EVP_CIPHER_CTX*)OPENSSL_malloc(sizeof(EVP_CIPHER_CTX));
EVP_CIPHER_CTX_init(c);
#else
@ -283,11 +283,11 @@ public:
TQByteArray result(EVP_CIPHER_block_size(type));
int olen;
if(dir == TQCA::Encrypt) {
if(!EVP_EncryptFinal(c, (unsigned char *)result.data(), &olen))
if(!EVP_EncryptFinal_ex(c, (unsigned char *)result.data(), &olen))
return false;
}
else {
if(!EVP_DecryptFinal(c, (unsigned char *)result.data(), &olen))
if(!EVP_DecryptFinal_ex(c, (unsigned char *)result.data(), &olen))
return false;
}
result.resize(olen);

Loading…
Cancel
Save