addressed concern

This commit is contained in:
Sebastian Klemke 2022-12-24 16:56:46 +01:00
parent f5c9b44f6e
commit 6c17fcfeb7
1 changed files with 14 additions and 42 deletions

View File

@ -35,16 +35,8 @@ static void (*dlsym_EVP_CIPHER_CTX_init)(EVP_CIPHER_CTX *);
#endif
static int (*dlsym_EVP_CIPHER_CTX_set_padding)(EVP_CIPHER_CTX *, int);
static int (*dlsym_EVP_CIPHER_CTX_test_flags)(const EVP_CIPHER_CTX *, int);
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static int (*dlsym_EVP_CIPHER_CTX_get_block_size)(const EVP_CIPHER_CTX *);
#else
static int (*dlsym_EVP_CIPHER_CTX_block_size)(const EVP_CIPHER_CTX *);
#endif
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static int (*dlsym_EVP_CIPHER_CTX_is_encrypting)(const EVP_CIPHER_CTX *);
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
static int (*dlsym_EVP_CIPHER_CTX_encrypting)(const EVP_CIPHER_CTX *);
#endif
static int (*dlsym_EVP_CipherInit_ex)(EVP_CIPHER_CTX *, const EVP_CIPHER *, \
@ -71,16 +63,8 @@ typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_cleanup)(EVP_CIPHER_CTX *);
typedef void (__cdecl *__dlsym_EVP_CIPHER_CTX_init)(EVP_CIPHER_CTX *);
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_set_padding)(EVP_CIPHER_CTX *, int);
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_test_flags)(const EVP_CIPHER_CTX *, int);
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_get_block_size)(const EVP_CIPHER_CTX *);
#else
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_block_size)(const EVP_CIPHER_CTX *);
#endif
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_is_encrypting)(const EVP_CIPHER_CTX *);
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
typedef int (__cdecl *__dlsym_EVP_CIPHER_CTX_encrypting)(const EVP_CIPHER_CTX *);
#endif
typedef int (__cdecl *__dlsym_EVP_CipherInit_ex)(EVP_CIPHER_CTX *, \
@ -98,14 +82,8 @@ static __dlsym_EVP_CIPHER_CTX_cleanup dlsym_EVP_CIPHER_CTX_cleanup;
static __dlsym_EVP_CIPHER_CTX_init dlsym_EVP_CIPHER_CTX_init;
static __dlsym_EVP_CIPHER_CTX_set_padding dlsym_EVP_CIPHER_CTX_set_padding;
static __dlsym_EVP_CIPHER_CTX_test_flags dlsym_EVP_CIPHER_CTX_test_flags;
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static __dlsym_EVP_CIPHER_CTX_get_block_size dlsym_EVP_CIPHER_CTX_get_block_size;
#else
static __dlsym_EVP_CIPHER_CTX_block_size dlsym_EVP_CIPHER_CTX_block_size;
#endif
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
static __dlsym_EVP_CIPHER_CTX_is_encrypting dlsym_EVP_CIPHER_CTX_is_encrypting;
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
#if OPENSSL_VERSION_NUMBER >= 0x10100000L
static __dlsym_EVP_CIPHER_CTX_encrypting dlsym_EVP_CIPHER_CTX_encrypting;
#endif
static __dlsym_EVP_CipherInit_ex dlsym_EVP_CipherInit_ex;
@ -191,15 +169,17 @@ JNIEXPORT void JNICALL Java_org_apache_hadoop_crypto_OpensslCipher_initIDs
"EVP_CIPHER_CTX_set_padding");
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_test_flags, env, openssl, \
"EVP_CIPHER_CTX_test_flags");
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_get_block_size, env, openssl, \
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_block_size, env, openssl, \
"EVP_CIPHER_CTX_get_block_size");
#else
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_block_size, env, openssl, \
"EVP_CIPHER_CTX_block_size");
#endif
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_is_encrypting, env, openssl, \
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_encrypting, env, openssl, \
"EVP_CIPHER_CTX_is_encrypting");
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
LOAD_DYNAMIC_SYMBOL(dlsym_EVP_CIPHER_CTX_encrypting, env, openssl, \
@ -237,18 +217,20 @@ JNIEXPORT void JNICALL Java_org_apache_hadoop_crypto_OpensslCipher_initIDs
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_test_flags, \
dlsym_EVP_CIPHER_CTX_test_flags, env, \
openssl, "EVP_CIPHER_CTX_test_flags");
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_get_block_size, \
dlsym_EVP_CIPHER_CTX_get_block_size, env, \
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_block_size, \
dlsym_EVP_CIPHER_CTX_block_size, env, \
openssl, "EVP_CIPHER_CTX_get_block_size");
#else
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_block_size, \
dlsym_EVP_CIPHER_CTX_block_size, env, \
openssl, "EVP_CIPHER_CTX_block_size");
#endif
// name changed in OpenSSL 3 ABI - see History section in EVP_EncryptInit(3)
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_is_encrypting, \
dlsym_EVP_CIPHER_CTX_is_encrypting, env, \
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_encrypting, \
dlsym_EVP_CIPHER_CTX_encrypting, env, \
openssl, "EVP_CIPHER_CTX_is_encrypting");
#elif OPENSSL_VERSION_NUMBER >= 0x10100000L
LOAD_DYNAMIC_SYMBOL(__dlsym_EVP_CIPHER_CTX_encrypting, \
@ -445,17 +427,11 @@ static int check_update_max_output_len(EVP_CIPHER_CTX *context, int input_len,
}
return 0;
} else {
#if OPENSSL_VERSION_NUMBER < 0x30000000L
int b = dlsym_EVP_CIPHER_CTX_block_size(context);
#else
int b = dlsym_EVP_CIPHER_CTX_get_block_size(context);
#endif
#if OPENSSL_VERSION_NUMBER < 0x10100000L
if (context->encrypt) {
#elif OPENSSL_VERSION_NUMBER < 0x30000000L
if (dlsym_EVP_CIPHER_CTX_encrypting(context)) {
#else
if (dlsym_EVP_CIPHER_CTX_is_encrypting(context)) {
if (dlsym_EVP_CIPHER_CTX_encrypting(context)) {
#endif
if (max_output_len >= input_len + b - 1) {
return 1;
@ -510,11 +486,7 @@ static int check_doFinal_max_output_len(EVP_CIPHER_CTX *context,
if ( dlsym_EVP_CIPHER_CTX_test_flags(context, EVP_CIPH_NO_PADDING) ) {
return 1;
} else {
#if OPENSSL_VERSION_NUMBER < 0x30000000L
int b = dlsym_EVP_CIPHER_CTX_block_size(context);
#else
int b = dlsym_EVP_CIPHER_CTX_get_block_size(context);
#endif
if (max_output_len >= b) {
return 1;
}