Skip to content

Commit e9dae79

Browse files
committed
build: drop support for openssl 1
The OpenSSL 1.1 branch has reached End Of Live in September 2023. It's time to rip out the support in upstream for this version of OpenSSL. That means TLS and authentication for the fabrics commands won't be supported anymore. The rest will continue to work. Signed-off-by: Daniel Wagner <wagi@kernel.org>
1 parent 2e28bfe commit e9dae79

File tree

2 files changed

+13
-171
lines changed

2 files changed

+13
-171
lines changed

meson.build

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -79,36 +79,23 @@ if get_option('openssl').disabled()
7979
openssl_dep = dependency('', required: false)
8080
else
8181
openssl_dep = dependency('openssl',
82-
version: '>=1.1.0',
82+
version: '>=3.0.0',
8383
required: get_option('openssl'),
8484
fallback : ['openssl', 'libssl_dep'])
85-
86-
if openssl_dep.found()
87-
if openssl_dep.version().version_compare('<2.0.0')
88-
api_version = 1
89-
endif
90-
91-
if openssl_dep.version().version_compare('>=3.0.0')
92-
api_version = 3
93-
endif
94-
95-
# Test for LibreSSL v3.x with incomplete OpenSSL v3 APIs
96-
if openssl_dep.type_name() != 'internal'
97-
is_libressl = cc.has_header_symbol('openssl/opensslv.h',
98-
'LIBRESSL_VERSION_NUMBER',
99-
dependencies: openssl_dep)
100-
has_header = cc.has_header('openssl/core_names.h',
101-
dependencies: openssl_dep)
102-
if is_libressl and not has_header
103-
api_version = 1
104-
endif
85+
endif
86+
if openssl_dep.found()
87+
# Test for LibreSSL v3.x with incomplete OpenSSL v3 APIs
88+
if openssl_dep.type_name() != 'internal'
89+
is_libressl = cc.has_header_symbol('openssl/opensslv.h',
90+
'LIBRESSL_VERSION_NUMBER',
91+
dependencies: openssl_dep)
92+
has_header = cc.has_header('openssl/core_names.h',
93+
dependencies: openssl_dep)
94+
if is_libressl and not has_header
95+
openssl_dep = dependency('', required: false)
10596
endif
106-
107-
conf.set('CONFIG_OPENSSL_@0@'.format(api_version), true,
108-
description: 'OpenSSL/LibreSSL API version @0@'.format(api_version))
10997
endif
11098
endif
111-
11299
conf.set('CONFIG_OPENSSL', openssl_dep.found(),
113100
description: 'Is OpenSSL/LibreSSL available?')
114101

src/nvme/linux.c

Lines changed: 1 addition & 146 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,9 @@
2121
#include <openssl/evp.h>
2222
#include <openssl/hmac.h>
2323
#include <openssl/kdf.h>
24-
25-
#ifdef CONFIG_OPENSSL_3
2624
#include <openssl/core_names.h>
2725
#include <openssl/params.h>
2826
#endif
29-
#endif
3027

3128
#ifdef CONFIG_KEYUTILS
3229
#include <keyutils.h>
@@ -812,149 +809,7 @@ static int derive_tls_key(int version, unsigned char cipher,
812809

813810
return key_len;
814811
}
815-
#endif /* CONFIG_OPENSSL */
816-
817-
#ifdef CONFIG_OPENSSL_1
818-
static DEFINE_CLEANUP_FUNC(cleanup_hmac_ctx, HMAC_CTX *, HMAC_CTX_free)
819-
#define _cleanup_hmac_ctx_ __cleanup__(cleanup_hmac_ctx)
820-
821-
int nvme_gen_dhchap_key(char *hostnqn, enum nvme_hmac_alg hmac,
822-
unsigned int key_len, unsigned char *secret,
823-
unsigned char *key)
824-
{
825-
const char hmac_seed[] = "NVMe-over-Fabrics";
826-
_cleanup_hmac_ctx_ HMAC_CTX *hmac_ctx = NULL;
827-
const EVP_MD *md;
828-
829-
hmac_ctx = HMAC_CTX_new();
830-
if (!hmac_ctx) {
831-
errno = ENOMEM;
832-
return -1;
833-
}
834-
835-
switch (hmac) {
836-
case NVME_HMAC_ALG_NONE:
837-
memcpy(key, secret, key_len);
838-
return 0;
839-
case NVME_HMAC_ALG_SHA2_256:
840-
md = EVP_sha256();
841-
break;
842-
case NVME_HMAC_ALG_SHA2_384:
843-
md = EVP_sha384();
844-
break;
845-
case NVME_HMAC_ALG_SHA2_512:
846-
md = EVP_sha512();
847-
break;
848-
default:
849-
errno = EINVAL;
850-
return -1;
851-
}
852-
853-
if (!md) {
854-
errno = EINVAL;
855-
return -1;
856-
}
857-
858-
if (!HMAC_Init_ex(hmac_ctx, secret, key_len, md, NULL)) {
859-
errno = ENOMEM;
860-
return -1;
861-
}
862-
863-
if (!HMAC_Update(hmac_ctx, (unsigned char *)hostnqn,
864-
strlen(hostnqn))) {
865-
errno = ENOKEY;
866-
return -1;
867-
}
868-
869-
if (!HMAC_Update(hmac_ctx, (unsigned char *)hmac_seed,
870-
strlen(hmac_seed))) {
871-
errno = ENOKEY;
872-
return -1;
873-
}
874-
875-
if (!HMAC_Final(hmac_ctx, key, &key_len)) {
876-
errno = ENOKEY;
877-
return -1;
878-
}
879-
880-
return 0;
881-
}
882-
883-
static int derive_psk_digest(const char *hostnqn, const char *subsysnqn,
884-
int version, int cipher,
885-
unsigned char *retained, size_t key_len,
886-
char *digest, size_t digest_len)
887-
{
888-
static const char hmac_seed[] = "NVMe-over-Fabrics";
889-
_cleanup_hmac_ctx_ HMAC_CTX *hmac_ctx = NULL;
890-
_cleanup_free_ unsigned char *psk_ctx = NULL;
891-
const EVP_MD *md;
892-
size_t hmac_len;
893-
size_t len;
894-
895-
hmac_ctx = HMAC_CTX_new();
896-
if (!hmac_ctx) {
897-
errno = ENOMEM;
898-
return -1;
899-
}
900-
md = select_hmac(cipher, &hmac_len);
901-
if (!md || !hmac_len) {
902-
errno = EINVAL;
903-
return -1;
904-
}
905-
906-
psk_ctx = malloc(key_len);
907-
if (!psk_ctx) {
908-
errno = ENOMEM;
909-
return -1;
910-
}
911-
if (!HMAC_Init_ex(hmac_ctx, retained, key_len, md, NULL)) {
912-
errno = ENOMEM;
913-
return -1;
914-
}
915-
if (!HMAC_Update(hmac_ctx, (unsigned char *)hostnqn,
916-
strlen(hostnqn))) {
917-
errno = ENOKEY;
918-
return -1;
919-
}
920-
if (!HMAC_Update(hmac_ctx, (unsigned char *)" ", 1)) {
921-
errno = ENOKEY;
922-
return -1;
923-
}
924-
if (!HMAC_Update(hmac_ctx, (unsigned char *)subsysnqn,
925-
strlen(subsysnqn))) {
926-
errno = ENOKEY;
927-
return -1;
928-
}
929-
if (!HMAC_Update(hmac_ctx, (unsigned char *)" ", 1)) {
930-
errno = ENOKEY;
931-
return -1;
932-
}
933-
if (!HMAC_Update(hmac_ctx, (unsigned char *)hmac_seed,
934-
strlen(hmac_seed))) {
935-
errno = ENOKEY;
936-
return -1;
937-
}
938-
if (!HMAC_Final(hmac_ctx, psk_ctx, (unsigned int *)&key_len)) {
939-
errno = ENOKEY;
940-
return -1;
941-
}
942-
if (key_len * 2 > digest_len) {
943-
errno = EINVAL;
944-
return -1;
945-
}
946-
memset(digest, 0, digest_len);
947-
len = base64_encode(psk_ctx, key_len, digest);
948-
if (len < 0) {
949-
errno = ENOKEY;
950-
return len;
951-
}
952-
return strlen(digest);
953-
}
954-
955-
#endif /* !CONFIG_OPENSSL_1 */
956812

957-
#ifdef CONFIG_OPENSSL_3
958813
static DEFINE_CLEANUP_FUNC(
959814
cleanup_ossl_lib_ctx, OSSL_LIB_CTX *, OSSL_LIB_CTX_free)
960815
#define _cleanup_ossl_lib_ctx_ __cleanup__(cleanup_ossl_lib_ctx)
@@ -1148,7 +1003,7 @@ static int derive_psk_digest(const char *hostnqn, const char *subsysnqn,
11481003
}
11491004
return strlen(digest);
11501005
}
1151-
#endif /* !CONFIG_OPENSSL_3 */
1006+
#endif /* !CONFIG_OPENSSL */
11521007

11531008
static int gen_tls_identity(const char *hostnqn, const char *subsysnqn,
11541009
int version, int cipher, char *digest,

0 commit comments

Comments
 (0)