|
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,45 @@ 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 | + || (OPENSSL_VERSION_MINOR == 1 && OPENSSL_VERSION_PATCH < 4) \ |
| 114 | + || (OPENSSL_VERSION_MINOR == 2 && OPENSSL_VERSION_PATCH < 2) \ |
| 115 | + || (OPENSSL_VERSION_MINOR == 3 && OPENSSL_VERSION_PATCH < 2)) |
| 116 | +static struct test_data_identity test_data_identity_compat[] = { |
| 117 | + { { 0x55, 0x12, 0xDB, 0xB6, |
| 118 | + 0x73, 0x7D, 0x01, 0x06, |
| 119 | + 0xF6, 0x59, 0x75, 0xB7, |
| 120 | + 0x73, 0xDF, 0xB0, 0x11, |
| 121 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 122 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 123 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 124 | + 0x0B, 0x5D, 0x5B, 0x03}, |
| 125 | + 32, 1, NVME_HMAC_ALG_SHA2_256, |
| 126 | + "nqn.psk-test-host", "nqn.psk-test-subsys", |
| 127 | + "NVMe1R01 nqn.psk-test-host nqn.psk-test-subsys mJUDthe4jhFVFSnaBaydV/EHJK6OvIuw8xap5IkTnG0=" }, |
| 128 | + { { 0x55, 0x12, 0xDB, 0xB6, |
| 129 | + 0x73, 0x7D, 0x01, 0x06, |
| 130 | + 0xF6, 0x59, 0x75, 0xB7, |
| 131 | + 0x73, 0xDF, 0xB0, 0x11, |
| 132 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 133 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 134 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 135 | + 0x0B, 0x5D, 0x5B, 0x03, |
| 136 | + 0xFF, 0xC3, 0x44, 0xBC, |
| 137 | + 0xF4, 0x42, 0xE2, 0xDD, |
| 138 | + 0x6D, 0x8B, 0xC4, 0x87, |
| 139 | + 0x0B, 0x5D, 0x5B, 0x03}, |
| 140 | + 48, 1, NVME_HMAC_ALG_SHA2_384, |
| 141 | + "nqn.psk-test-host", "nqn.psk-test-subsys", |
| 142 | + "NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys J6B5sIVRCNLtZutDfmNnfPeqOFbnewwc8KEkhcOcO0dAWfdJYe/DrMyIC7znu00M" }, |
| 143 | +}; |
| 144 | +#else |
102 | 145 | static struct test_data_identity test_data_identity_compat[] = { |
103 | 146 | { { 0x55, 0x12, 0xDB, 0xB6, |
104 | 147 | 0x73, 0x7D, 0x01, 0x06, |
@@ -127,6 +170,7 @@ static struct test_data_identity test_data_identity_compat[] = { |
127 | 170 | "nqn.psk-test-host", "nqn.psk-test-subsys", |
128 | 171 | "NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys RsKmYJ3nAn1ApjjMloJFbAkLPivONDAX/xW327YBUsn2eGShXSjCZvBaOxscLqmz" }, |
129 | 172 | }; |
| 173 | +#endif |
130 | 174 |
|
131 | 175 | static void check_str(const char *exp, const char *res) |
132 | 176 | { |
|
0 commit comments