Skip to content

Commit a99f26f

Browse files
author
ericeberry
authored
Issue 28: Fix integration issue with OpenSSL 1.1.1l (#37)
1 parent f483b26 commit a99f26f

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ set_target_properties(sec_api PROPERTIES
106106
VERSION 2.3.2.26
107107
)
108108

109+
target_compile_options(sec_api PRIVATE -Wno-deprecated-declarations)
110+
109111
target_link_libraries(sec_api
110112
PRIVATE
111113
${SACLIENT_LIBRARY}
@@ -148,6 +150,8 @@ target_include_directories(sec_api_2_adapter_test
148150
test/openssl/headers
149151
)
150152

153+
target_compile_options(sec_api_2_adapter_test PRIVATE -Wno-deprecated-declarations)
154+
151155
target_link_libraries(sec_api_2_adapter_test
152156
PRIVATE
153157
sec_api

src/sec_adapter_engine.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <pthread.h>
2222

2323
#define SECAPI_ENGINE_ID "securityapi"
24+
#define OPENSSL_ENGINE_ID "openssl"
2425

2526
static SEC_BOOL g_sec_openssl_inited = SEC_FALSE;
2627

@@ -276,6 +277,7 @@ void Sec_InitOpenSSL() {
276277
ENGINE_set_default(engine, ENGINE_METHOD_ALL);
277278
ENGINE_free(engine);
278279
}
280+
279281
ENGINE_load_securityapi();
280282

281283
if (atexit(Sec_ShutdownOpenSSL) != 0) {
@@ -297,9 +299,8 @@ void Sec_PrintOpenSSLVersion() {
297299
RSA* SecKey_ToEngineRSA(Sec_KeyHandle* keyHandle) {
298300
Sec_RSARawPublicKey pubKey;
299301
RSA* rsa = NULL;
300-
ENGINE* engine = NULL;
301302

302-
engine = ENGINE_by_id(SECAPI_ENGINE_ID);
303+
ENGINE* engine = ENGINE_by_id(SECAPI_ENGINE_ID);
303304
if (engine == NULL) {
304305
SEC_LOG_ERROR("ENGINE_by_id failed");
305306
return NULL;
@@ -334,9 +335,8 @@ RSA* SecKey_ToEngineRSA(Sec_KeyHandle* keyHandle) {
334335
RSA* SecKey_ToEngineRSAWithCert(Sec_KeyHandle* keyHandle, Sec_CertificateHandle* certificateHandle) {
335336
Sec_RSARawPublicKey pubKey;
336337
RSA* rsa = NULL;
337-
ENGINE* engine = NULL;
338338

339-
engine = ENGINE_by_id(SECAPI_ENGINE_ID);
339+
ENGINE* engine = ENGINE_by_id(SECAPI_ENGINE_ID);
340340
if (engine == NULL) {
341341
SEC_LOG_ERROR("ENGINE_by_id failed");
342342
return NULL;

test/main/cpp/exchange.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,12 @@ static Sec_Result hkdf(SEC_BYTE* key, SEC_SIZE key_len, SEC_BYTE* out, const SEC
393393
return SEC_RESULT_FAILURE;
394394
}
395395

396+
#if OPENSSL_VERSION_NUMBER >= 0x30000000
397+
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, reinterpret_cast<const unsigned char*>(use_salt ? "salt" : nullptr),
398+
use_salt ? 4 : 0) <= 0) {
399+
#else
396400
if (EVP_PKEY_CTX_set1_hkdf_salt(pctx, use_salt ? "salt" : nullptr, use_salt ? 4 : 0) <= 0) {
401+
#endif
397402
EVP_PKEY_CTX_free(pctx);
398403
return SEC_RESULT_FAILURE;
399404
}
@@ -403,7 +408,11 @@ static Sec_Result hkdf(SEC_BYTE* key, SEC_SIZE key_len, SEC_BYTE* out, const SEC
403408
return SEC_RESULT_FAILURE;
404409
}
405410

411+
#if OPENSSL_VERSION_NUMBER >= 0x30000000
412+
if (EVP_PKEY_CTX_add1_hkdf_info(pctx, reinterpret_cast<const unsigned char*>("label"), 5) <= 0) {
413+
#else
406414
if (EVP_PKEY_CTX_add1_hkdf_info(pctx, "label", 5) <= 0) {
415+
#endif
407416
EVP_PKEY_CTX_free(pctx);
408417
return SEC_RESULT_FAILURE;
409418
}

0 commit comments

Comments
 (0)