From 5df160f116fbe49eff5c938cf184f84bf4cc3952 Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Mon, 11 Dec 2023 15:40:19 +0100 Subject: [PATCH] test_export_key_mat(): Long context support works with new fips provider only Reviewed-by: Shane Lontis Reviewed-by: Hugo Landau (Merged from https://github.com/openssl/openssl/pull/23007) --- test/sslapitest.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/test/sslapitest.c b/test/sslapitest.c index efea1a6495..e2c4563fd3 100644 --- a/test/sslapitest.c +++ b/test/sslapitest.c @@ -6335,6 +6335,7 @@ static int test_export_key_mat(int tst) const unsigned char context[] = "context"; const unsigned char *emptycontext = NULL; unsigned char longcontext[1280]; + int test_longcontext = fips_provider_version_ge(libctx, 3, 3, 0); unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80], ckeymat4[80]; unsigned char skeymat1[80], skeymat2[80], skeymat3[80], skeymat4[80]; size_t labellen; @@ -6429,12 +6430,14 @@ static int test_export_key_mat(int tst) sizeof(ckeymat3), label, labellen, NULL, 0, 0), 1) - || !TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat4, - sizeof(ckeymat4), label, - labellen, - longcontext, - sizeof(longcontext), 1), - 1) + || (test_longcontext + && !TEST_int_eq(SSL_export_keying_material(clientssl, + ckeymat4, + sizeof(ckeymat4), label, + labellen, + longcontext, + sizeof(longcontext), 1), + 1)) || !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat1, sizeof(skeymat1), label, labellen, @@ -6450,12 +6453,13 @@ static int test_export_key_mat(int tst) sizeof(skeymat3), label, labellen, NULL, 0, 0), 1) - || !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat4, - sizeof(skeymat4), label, - labellen, - longcontext, - sizeof(longcontext), 1), - 1) + || (test_longcontext + && !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat4, + sizeof(skeymat4), label, + labellen, + longcontext, + sizeof(longcontext), 1), + 1)) /* * Check that both sides created the same key material with the * same context. @@ -6478,8 +6482,9 @@ static int test_export_key_mat(int tst) * Check that both sides created the same key material with a * long context. */ - || !TEST_mem_eq(ckeymat4, sizeof(ckeymat4), skeymat4, - sizeof(skeymat4)) + || (test_longcontext + && !TEST_mem_eq(ckeymat4, sizeof(ckeymat4), skeymat4, + sizeof(skeymat4))) /* Different contexts should produce different results */ || !TEST_mem_ne(ckeymat1, sizeof(ckeymat1), ckeymat2, sizeof(ckeymat2)))