mirror of
https://gitlab.com/cryptsetup/cryptsetup.git
synced 2025-12-16 05:10:03 +01:00
Fix OpenSSL 1.1.0 compatibility
If backward-compatible API is not defined (-DOPENSSL_API_COMPAT=0x10100000L) deprecated symbols cannot be used. Also see https://bugs.gentoo.org/show_bug.cgi?id=604698 Thanks eroen for reporting this.
This commit is contained in:
@@ -49,31 +49,20 @@ struct crypt_hmac {
|
|||||||
int hash_len;
|
int hash_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
int crypt_backend_init(struct crypt_device *ctx)
|
|
||||||
{
|
|
||||||
if (crypto_backend_initialised)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
OpenSSL_add_all_algorithms();
|
|
||||||
|
|
||||||
crypto_backend_initialised = 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t crypt_backend_flags(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *crypt_backend_version(void)
|
|
||||||
{
|
|
||||||
return SSLeay_version(SSLEAY_VERSION);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Compatible wrappers for OpenSSL < 1.1.0
|
* Compatible wrappers for OpenSSL < 1.1.0
|
||||||
*/
|
*/
|
||||||
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
|
||||||
|
static void openssl_backend_init(void)
|
||||||
|
{
|
||||||
|
OpenSSL_add_all_algorithms();
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *openssl_backend_version(void)
|
||||||
|
{
|
||||||
|
return SSLeay_version(SSLEAY_VERSION);
|
||||||
|
}
|
||||||
|
|
||||||
static EVP_MD_CTX *EVP_MD_CTX_new(void)
|
static EVP_MD_CTX *EVP_MD_CTX_new(void)
|
||||||
{
|
{
|
||||||
EVP_MD_CTX *md = malloc(sizeof(*md));
|
EVP_MD_CTX *md = malloc(sizeof(*md));
|
||||||
@@ -105,8 +94,38 @@ static void HMAC_CTX_free(HMAC_CTX *md)
|
|||||||
HMAC_CTX_cleanup(md);
|
HMAC_CTX_cleanup(md);
|
||||||
free(md);
|
free(md);
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
static void openssl_backend_init(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char *openssl_backend_version(void)
|
||||||
|
{
|
||||||
|
return OpenSSL_version(OPENSSL_VERSION);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int crypt_backend_init(struct crypt_device *ctx)
|
||||||
|
{
|
||||||
|
if (crypto_backend_initialised)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
openssl_backend_init();
|
||||||
|
|
||||||
|
crypto_backend_initialised = 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t crypt_backend_flags(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *crypt_backend_version(void)
|
||||||
|
{
|
||||||
|
return openssl_backend_version();
|
||||||
|
}
|
||||||
|
|
||||||
/* HASH */
|
/* HASH */
|
||||||
int crypt_hash_size(const char *name)
|
int crypt_hash_size(const char *name)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user