Skip to content

Commit d3b4dd5

Browse files
committed
test/psk: add compat vector for OpenSSL < 3.2
Older OpenSSL versions have a bug where EVP_PKEY_CTX_add1_hkdf_info() will always overwrite the existing 'info' value, and thus calculate a different identity hash. This issue has been uncovered by the PSK testcases, and has always been present. We have fixed this with eff0ffe ("linux: fix HKDF TLS key derivation back to OpenSSL 3.0.8"), but the PSK testcases will still fail. So add the resulting hash values for the 'compat' test, and select the correct test vector based on the OpenSSL version. Signed-off-by: Hannes Reinecke <[email protected]>
1 parent 0bf294e commit d3b4dd5

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

test/psk.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <stdlib.h>
1010
#include <errno.h>
1111

12+
#include <openssl/opensslv.h>
13+
1214
#include <ccan/array_size/array_size.h>
1315

1416
#include <libnvme.h>
@@ -99,6 +101,45 @@ static struct test_data_identity test_data_identity[] = {
99101
"NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys QhW2+Rp6RzHlNtCslyRxMnwJ11tKKhz8JCAQpQ+XUD8f9td1VeH5h53yz2wKJG1a" },
100102
};
101103

104+
/*
105+
* Older OpenSSL versions have a bug where
106+
* EVP_PKEY_CTX_add1_hkdf_info() will always overwrite
107+
* existing 'info' string. So add the resulting 'compat'
108+
* identity hash vector here to make the tests succeed.
109+
*/
110+
#if ((OPENSSL_VERSION_MINOR == 0 && OPENSSL_VERSION_PATCH < 14) \
111+
|| (OPENSSL_VERSION_MINOR == 1 && OPENSSL_VERSION_PATCH < 4) \
112+
|| (OPENSSL_VERSION_MINOR == 2 && OPENSSL_VERSION_PATCH < 2) \
113+
|| (OPENSSL_VERSION_MINOR == 3 && OPENSSL_VERSION_PATCH < 2))
114+
static struct test_data_identity test_data_identity_compat[] = {
115+
{ { 0x55, 0x12, 0xDB, 0xB6,
116+
0x73, 0x7D, 0x01, 0x06,
117+
0xF6, 0x59, 0x75, 0xB7,
118+
0x73, 0xDF, 0xB0, 0x11,
119+
0xFF, 0xC3, 0x44, 0xBC,
120+
0xF4, 0x42, 0xE2, 0xDD,
121+
0x6D, 0x8B, 0xC4, 0x87,
122+
0x0B, 0x5D, 0x5B, 0x03},
123+
32, 1, NVME_HMAC_ALG_SHA2_256,
124+
"nqn.psk-test-host", "nqn.psk-test-subsys",
125+
"NVMe1R01 nqn.psk-test-host nqn.psk-test-subsys mJUDthe4jhFVFSnaBaydV/EHJK6OvIuw8xap5IkTnG0=" },
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+
0xFF, 0xC3, 0x44, 0xBC,
135+
0xF4, 0x42, 0xE2, 0xDD,
136+
0x6D, 0x8B, 0xC4, 0x87,
137+
0x0B, 0x5D, 0x5B, 0x03},
138+
48, 1, NVME_HMAC_ALG_SHA2_384,
139+
"nqn.psk-test-host", "nqn.psk-test-subsys",
140+
"NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys J6B5sIVRCNLtZutDfmNnfPeqOFbnewwc8KEkhcOcO0dAWfdJYe/DrMyIC7znu00M" },
141+
};
142+
#else
102143
static struct test_data_identity test_data_identity_compat[] = {
103144
{ { 0x55, 0x12, 0xDB, 0xB6,
104145
0x73, 0x7D, 0x01, 0x06,
@@ -127,6 +168,7 @@ static struct test_data_identity test_data_identity_compat[] = {
127168
"nqn.psk-test-host", "nqn.psk-test-subsys",
128169
"NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys RsKmYJ3nAn1ApjjMloJFbAkLPivONDAX/xW327YBUsn2eGShXSjCZvBaOxscLqmz" },
129170
};
171+
#endif
130172

131173
static void check_str(const char *exp, const char *res)
132174
{

0 commit comments

Comments
 (0)