# Check for zlib availability
libz_dep = dependency('zlib', fallback : ['zlib', 'zlib_dep'])
-# Check for OpenSSL availability
-openssl_dep = dependency('openssl', version: '>=1.1.0',
- required: get_option('openssl'),
- fallback : ['openssl', 'openssl_dep'])
-conf.set('CONFIG_OPENSSL', openssl_dep.found(), description: 'Is OpenSSL available?')
-
# Set the nvme-cli version
conf.set('NVME_VERSION', '"' + meson.project_version() + '"')
executable(
'nvme',
sources,
- dependencies: [ libnvme_dep, libuuid_dep, json_c_dep, libz_dep, openssl_dep,
+ dependencies: [ libnvme_dep, libuuid_dep, json_c_dep, libz_dep,
libhugetlbfs_dep ],
include_directories: incdir,
install: true,
option('htmldir', type : 'string', value : '', description : 'directory for HTML documentation')
option('docs', type : 'combo', choices : ['false', 'html', 'man', 'all'], description : 'install documentation')
-option('openssl', type : 'feature', value: 'auto', description : 'OpenSSL support')
#include <hugetlbfs.h>
#endif
-#ifdef CONFIG_OPENSSL
-#include <openssl/engine.h>
-#include <openssl/evp.h>
-#include <openssl/hmac.h>
-#endif
-
#include <linux/fs.h>
#include <sys/mman.h>
return 0;
}
+
static int gen_dhchap_key(int argc, char **argv, struct command *command, struct plugin *plugin)
{
const char *desc = "Generate a DH-HMAC-CHAP host key usable "\
"(0 = none, 1 = SHA-256, 2 = SHA-384, 3 = SHA-512).";
const char *nqn = "Host NQN to use for key transformation.";
- char *raw_secret;
+ unsigned char *raw_secret;
unsigned char key[68];
char encoded_key[128];
unsigned long crc = crc32(0L, NULL, 0);
int err = 0;
-#ifdef CONFIG_OPENSSL
- const EVP_MD *md = NULL;
- const char *hostnqn;
-#else
- const char *md = NULL;
-#endif
+
struct config {
char *secret;
unsigned int key_len;
return -EINVAL;
}
if (cfg.hmac > 0) {
-#ifdef CONFIG_OPENSSL
- if (!cfg.nqn) {
- hostnqn = nvmf_hostnqn_from_file();
- if (!hostnqn) {
- fprintf(stderr, "Could not read host NQN\n");
- return -ENOENT;
- }
- } else {
- hostnqn = cfg.nqn;
- }
switch (cfg.hmac) {
case 1:
- md = EVP_sha256();
if (!cfg.key_len)
cfg.key_len = 32;
else if (cfg.key_len != 32) {
}
break;
case 2:
- md = EVP_sha384();
if (!cfg.key_len)
cfg.key_len = 48;
else if (cfg.key_len != 48) {
}
break;
case 3:
- md = EVP_sha512();
if (!cfg.key_len)
cfg.key_len = 64;
else if (cfg.key_len != 64) {
default:
break;
}
-#else
- fprintf(stderr, "HMAC transformation not supported; "\
- "recompile with OpenSSL support.\n");
- return -EINVAL;
-#endif
} else if (!cfg.key_len)
cfg.key_len = 32;
}
}
- if (md) {
-#ifdef CONFIG_OPENSSL
- HMAC_CTX *hmac_ctx = HMAC_CTX_new();
- const char hmac_seed[] = "NVMe-over-Fabrics";
- unsigned int key_len;
-
- ENGINE_load_builtin_engines();
- ENGINE_register_all_complete();
-
- HMAC_Init_ex(hmac_ctx, raw_secret, cfg.key_len,md, NULL);
- HMAC_Update(hmac_ctx, (unsigned char *)hostnqn,
- strlen(hostnqn));
- HMAC_Update(hmac_ctx, (unsigned char *)hmac_seed,
- strlen(hmac_seed));
- HMAC_Final(hmac_ctx, key, &key_len);
- HMAC_CTX_free(hmac_ctx);
-#endif
- } else {
- memcpy(key, raw_secret, cfg.key_len);
+ if (!cfg.nqn) {
+ cfg.nqn = nvmf_hostnqn_from_file();
+ if (!cfg.nqn) {
+ fprintf(stderr, "Could not read host NQN\n");
+ return -ENOENT;
+ }
}
+ if (nvme_gen_dhchap_key(cfg.nqn, cfg.hmac, cfg.key_len,
+ raw_secret, key) < 0)
+ return -errno;
+
crc = crc32(crc, key, cfg.key_len);
key[cfg.key_len++] = crc & 0xff;
key[cfg.key_len++] = (crc >> 8) & 0xff;
+++ /dev/null
-[wrap-file]
-directory = openssl-1.1.1l
-source_url = https://www.openssl.org/source/openssl-1.1.1l.tar.gz
-source_filename = openssl-1.1.1l.tar.gz
-source_hash = 0b7a3e5e59c34827fe0c3a74b7ec8baef302b98fa80088d7f9153aa16fa76bd1
-patch_filename = openssl_1.1.1l-2_patch.zip
-patch_url = https://wrapdb.mesonbuild.com/v2/openssl_1.1.1l-2/get_patch
-patch_hash = 852521fb016fa2deee8ebf9ffeeee0292c6de86a03c775cf72ac04e86f9f177e
-
-[provide]
-libcrypto = libcrypto_dep
-libssl = libssl_dep
-openssl = openssl_dep
-