Skip to content

Commit 3aab043

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 3aab043

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

test/psk.c

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

12+
#ifdef CONFIG_OPENSSL
13+
#include <openssl/opensslv.h>
14+
#endif
15+
1216
#include <ccan/array_size/array_size.h>
1317

1418
#include <libnvme.h>
@@ -99,6 +103,45 @@ static struct test_data_identity test_data_identity[] = {
99103
"NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys QhW2+Rp6RzHlNtCslyRxMnwJ11tKKhz8JCAQpQ+XUD8f9td1VeH5h53yz2wKJG1a" },
100104
};
101105

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
102145
static struct test_data_identity test_data_identity_compat[] = {
103146
{ { 0x55, 0x12, 0xDB, 0xB6,
104147
0x73, 0x7D, 0x01, 0x06,
@@ -127,6 +170,7 @@ static struct test_data_identity test_data_identity_compat[] = {
127170
"nqn.psk-test-host", "nqn.psk-test-subsys",
128171
"NVMe1R02 nqn.psk-test-host nqn.psk-test-subsys RsKmYJ3nAn1ApjjMloJFbAkLPivONDAX/xW327YBUsn2eGShXSjCZvBaOxscLqmz" },
129172
};
173+
#endif
130174

131175
static void check_str(const char *exp, const char *res)
132176
{

0 commit comments

Comments
 (0)