|
9 | 9 | #include <stdlib.h> |
10 | 10 | #include <errno.h> |
11 | 11 |
|
| 12 | +#ifdef CONFIG_OPENSSL |
| 13 | +#include <openssl/opensslv.h> |
| 14 | +#endif |
| 15 | + |
12 | 16 | #include <ccan/array_size/array_size.h> |
13 | 17 |
|
14 | 18 | #include <libnvme.h> |
@@ -99,6 +103,54 @@ static struct test_data_identity test_data_identity[] = { |
99 | 103 | "NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys QhW2+Rp6RzHlNtCslyRxMnwJ11tKKhz8JCAQpQ+XUD8f9td1VeH5h53yz2wKJG1a" }, |
100 | 104 | }; |
101 | 105 |
|
| 106 | +/* |
| 107 | + * Older OpenSSL versions have a bug where |
| 108 | + * EVP_PKEY_CTX_add1_hkdf_info() will always overwrite |
| 109 | + * existing 'info' string. So add the resulting 'compat' |
| 110 | + * identity hash vector here to make the tests succeed. |
| 111 | + */ |
| 112 | +#if (OPENSSL_VERSION_MINOR == 0 && OPENSSL_VERSION_PATCH < 14) |
| 113 | +#define OPENSSL_HKDF_INFO_BUG |
| 114 | +#elif (OPENSSL_VERSION_MINOR == 1 && OPENSSL_VERSION_PATCH < 4) |
| 115 | +#define OPENSSL_HKDF_INFO_BUG |
| 116 | +#elif (OPENSSL_VERSION_MINOR == 2 && OPENSSL_VERSION_PATCH < 2) |
| 117 | +#define OPENSSL_HKDF_INFO_BUG |
| 118 | +#elif (OPENSSL_VERSION_MINOR == 3 && OPENSSL_VERSION_PATCH < 2) |
| 119 | +#define OPENSSL_HKDF_INFO_BUG |
| 120 | +#elif (OPENSSL_VERSION_MINOR == 5 && OPENSSL_VERSION_PATCH < 2) |
| 121 | +#define OPENSSL_HKDF_INFO_BUG |
| 122 | +#endif |
| 123 | + |
| 124 | +#ifdef OPENSSL_HKDF_INFO_BUG |
| 125 | +static struct test_data_identity test_data_identity_compat[] = { |
| 126 | + { { 0x55, 0x12, 0xDB, 0xB6, |
| 127 | + 0x73, 0x7D, 0x01, 0x06, |
| 128 | + 0xF6, 0x59, 0x75, 0xB7, |
| 129 | + 0x73, 0xDF, 0xB0, 0x11, |
| 130 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 131 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 132 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 133 | + 0x0B, 0x5D, 0x5B, 0x03}, |
| 134 | + 32, 1, NVME_HMAC_ALG_SHA2_256, |
| 135 | + "nqn.psk-test-host", "nqn.psk-test-subsys", |
| 136 | + "NVMe1R01 nqn.psk-test-host nqn.psk-test-subsys mJUDthe4jhFVFSnaBaydV/EHJK6OvIuw8xap5IkTnG0=" }, |
| 137 | + { { 0x55, 0x12, 0xDB, 0xB6, |
| 138 | + 0x73, 0x7D, 0x01, 0x06, |
| 139 | + 0xF6, 0x59, 0x75, 0xB7, |
| 140 | + 0x73, 0xDF, 0xB0, 0x11, |
| 141 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 142 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 143 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 144 | + 0x0B, 0x5D, 0x5B, 0x03, |
| 145 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 146 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 147 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 148 | + 0x0B, 0x5D, 0x5B, 0x03}, |
| 149 | + 48, 1, NVME_HMAC_ALG_SHA2_384, |
| 150 | + "nqn.psk-test-host", "nqn.psk-test-subsys", |
| 151 | + "NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys J6B5sIVRCNLtZutDfmNnfPeqOFbnewwc8KEkhcOcO0dAWfdJYe/DrMyIC7znu00M" }, |
| 152 | +}; |
| 153 | +#else |
102 | 154 | static struct test_data_identity test_data_identity_compat[] = { |
103 | 155 | { { 0x55, 0x12, 0xDB, 0xB6, |
104 | 156 | 0x73, 0x7D, 0x01, 0x06, |
@@ -127,6 +179,7 @@ static struct test_data_identity test_data_identity_compat[] = { |
127 | 179 | "nqn.psk-test-host", "nqn.psk-test-subsys", |
128 | 180 | "NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys RsKmYJ3nAn1ApjjMloJFbAkLPivONDAX/xW327YBUsn2eGShXSjCZvBaOxscLqmz" }, |
129 | 181 | }; |
| 182 | +#endif |
130 | 183 |
|
131 | 184 | static void check_str(const char *exp, const char *res) |
132 | 185 | { |
|
0 commit comments