Latest update. (3.0.0-dev)
This commit is contained in:
+37
-13
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the OpenSSL license (the "License"). You may not use
|
||||
* Licensed under the Apache License 2.0 (the "License"). You may not use
|
||||
* this file except in compliance with the License. You can obtain a copy
|
||||
* in the file LICENSE in the source distribution or at
|
||||
* https://www.openssl.org/source/license.html
|
||||
@@ -4028,20 +4028,25 @@ static int test_serverinfo(int tst)
|
||||
* no test vectors so all we do is test that both sides of the communication
|
||||
* produce the same results for different protocol versions.
|
||||
*/
|
||||
#define SMALL_LABEL_LEN 10
|
||||
#define LONG_LABEL_LEN 249
|
||||
static int test_export_key_mat(int tst)
|
||||
{
|
||||
int testresult = 0;
|
||||
SSL_CTX *cctx = NULL, *sctx = NULL, *sctx2 = NULL;
|
||||
SSL *clientssl = NULL, *serverssl = NULL;
|
||||
const char label[] = "test label";
|
||||
const char label[LONG_LABEL_LEN + 1] = "test label";
|
||||
const unsigned char context[] = "context";
|
||||
const unsigned char *emptycontext = NULL;
|
||||
unsigned char ckeymat1[80], ckeymat2[80], ckeymat3[80];
|
||||
unsigned char skeymat1[80], skeymat2[80], skeymat3[80];
|
||||
size_t labellen;
|
||||
const int protocols[] = {
|
||||
TLS1_VERSION,
|
||||
TLS1_1_VERSION,
|
||||
TLS1_2_VERSION,
|
||||
TLS1_3_VERSION,
|
||||
TLS1_3_VERSION,
|
||||
TLS1_3_VERSION
|
||||
};
|
||||
|
||||
@@ -4058,7 +4063,7 @@ static int test_export_key_mat(int tst)
|
||||
return 1;
|
||||
#endif
|
||||
#ifdef OPENSSL_NO_TLS1_3
|
||||
if (tst == 3)
|
||||
if (tst >= 3)
|
||||
return 1;
|
||||
#endif
|
||||
if (!TEST_true(create_ssl_ctx_pair(TLS_server_method(), TLS_client_method(),
|
||||
@@ -4076,33 +4081,52 @@ static int test_export_key_mat(int tst)
|
||||
SSL_ERROR_NONE)))
|
||||
goto end;
|
||||
|
||||
if (tst == 5) {
|
||||
/*
|
||||
* TLSv1.3 imposes a maximum label len of 249 bytes. Check we fail if we
|
||||
* go over that.
|
||||
*/
|
||||
if (!TEST_int_le(SSL_export_keying_material(clientssl, ckeymat1,
|
||||
sizeof(ckeymat1), label,
|
||||
LONG_LABEL_LEN + 1, context,
|
||||
sizeof(context) - 1, 1), 0))
|
||||
goto end;
|
||||
|
||||
testresult = 1;
|
||||
goto end;
|
||||
} else if (tst == 4) {
|
||||
labellen = LONG_LABEL_LEN;
|
||||
} else {
|
||||
labellen = SMALL_LABEL_LEN;
|
||||
}
|
||||
|
||||
if (!TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat1,
|
||||
sizeof(ckeymat1), label,
|
||||
sizeof(label) - 1, context,
|
||||
labellen, context,
|
||||
sizeof(context) - 1, 1), 1)
|
||||
|| !TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat2,
|
||||
sizeof(ckeymat2), label,
|
||||
sizeof(label) - 1,
|
||||
labellen,
|
||||
emptycontext,
|
||||
0, 1), 1)
|
||||
|| !TEST_int_eq(SSL_export_keying_material(clientssl, ckeymat3,
|
||||
sizeof(ckeymat3), label,
|
||||
sizeof(label) - 1,
|
||||
labellen,
|
||||
NULL, 0, 0), 1)
|
||||
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat1,
|
||||
sizeof(skeymat1), label,
|
||||
sizeof(label) - 1,
|
||||
labellen,
|
||||
context,
|
||||
sizeof(context) -1, 1),
|
||||
1)
|
||||
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat2,
|
||||
sizeof(skeymat2), label,
|
||||
sizeof(label) - 1,
|
||||
labellen,
|
||||
emptycontext,
|
||||
0, 1), 1)
|
||||
|| !TEST_int_eq(SSL_export_keying_material(serverssl, skeymat3,
|
||||
sizeof(skeymat3), label,
|
||||
sizeof(label) - 1,
|
||||
labellen,
|
||||
NULL, 0, 0), 1)
|
||||
/*
|
||||
* Check that both sides created the same key material with the
|
||||
@@ -4131,10 +4155,10 @@ static int test_export_key_mat(int tst)
|
||||
* Check that an empty context and no context produce different results in
|
||||
* protocols less than TLSv1.3. In TLSv1.3 they should be the same.
|
||||
*/
|
||||
if ((tst != 3 && !TEST_mem_ne(ckeymat2, sizeof(ckeymat2), ckeymat3,
|
||||
if ((tst < 3 && !TEST_mem_ne(ckeymat2, sizeof(ckeymat2), ckeymat3,
|
||||
sizeof(ckeymat3)))
|
||||
|| (tst ==3 && !TEST_mem_eq(ckeymat2, sizeof(ckeymat2), ckeymat3,
|
||||
sizeof(ckeymat3))))
|
||||
|| (tst >= 3 && !TEST_mem_eq(ckeymat2, sizeof(ckeymat2), ckeymat3,
|
||||
sizeof(ckeymat3))))
|
||||
goto end;
|
||||
|
||||
testresult = 1;
|
||||
@@ -5909,7 +5933,7 @@ int setup_tests(void)
|
||||
ADD_ALL_TESTS(test_custom_exts, 3);
|
||||
#endif
|
||||
ADD_ALL_TESTS(test_serverinfo, 8);
|
||||
ADD_ALL_TESTS(test_export_key_mat, 4);
|
||||
ADD_ALL_TESTS(test_export_key_mat, 6);
|
||||
#ifndef OPENSSL_NO_TLS1_3
|
||||
ADD_ALL_TESTS(test_export_key_mat_early, 3);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user