mirror of
https://github.com/Mbed-TLS/mbedtls-framework.git
synced 2026-10-17 06:07:23 +00:00
Merge remote-tracking branch 'mbedtls/development' into tls13-cli-max-early-data-size
This commit is contained in:
@@ -40,5 +40,7 @@
|
|||||||
//#define MBEDTLS_MD_C
|
//#define MBEDTLS_MD_C
|
||||||
//#define MBEDTLS_PEM_PARSE_C
|
//#define MBEDTLS_PEM_PARSE_C
|
||||||
//#define MBEDTLS_BASE64_C
|
//#define MBEDTLS_BASE64_C
|
||||||
|
//#define MBEDTLS_THREADING_C
|
||||||
|
//#define MBEDTLS_THREADING_PTHREAD
|
||||||
|
|
||||||
#endif /* MBEDTLS_CONFIG_H */
|
#endif /* MBEDTLS_CONFIG_H */
|
||||||
|
|||||||
@@ -196,6 +196,13 @@ typedef struct mbedtls_test_ssl_endpoint {
|
|||||||
|
|
||||||
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
|
#endif /* MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Random number generator aimed for TLS unitary tests. Its main purpose is to
|
||||||
|
* simplify the set-up of a random number generator for TLS
|
||||||
|
* unitary tests: no need to set up a good entropy source for example.
|
||||||
|
*/
|
||||||
|
int mbedtls_test_random(void *p_rng, unsigned char *output, size_t output_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This function can be passed to mbedtls to receive output logs from it. In
|
* This function can be passed to mbedtls to receive output logs from it. In
|
||||||
* this case, it will count the instances of a mbedtls_test_ssl_log_pattern
|
* this case, it will count the instances of a mbedtls_test_ssl_log_pattern
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ psa_status_t sign_hash(
|
|||||||
size_t signature_size,
|
size_t signature_size,
|
||||||
size_t *signature_length)
|
size_t *signature_length)
|
||||||
{
|
{
|
||||||
if (attributes->core.type == PSA_KEY_TYPE_RSA_KEY_PAIR) {
|
if (attributes->type == PSA_KEY_TYPE_RSA_KEY_PAIR) {
|
||||||
if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) ||
|
if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) ||
|
||||||
PSA_ALG_IS_RSA_PSS(alg)) {
|
PSA_ALG_IS_RSA_PSS(alg)) {
|
||||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||||
@@ -71,7 +71,7 @@ psa_status_t sign_hash(
|
|||||||
} else {
|
} else {
|
||||||
return PSA_ERROR_INVALID_ARGUMENT;
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
} else if (PSA_KEY_TYPE_IS_ECC(attributes->core.type)) {
|
} else if (PSA_KEY_TYPE_IS_ECC(attributes->type)) {
|
||||||
if (PSA_ALG_IS_ECDSA(alg)) {
|
if (PSA_ALG_IS_ECDSA(alg)) {
|
||||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||||
(defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
(defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||||
@@ -116,7 +116,7 @@ psa_status_t verify_hash(
|
|||||||
const uint8_t *signature,
|
const uint8_t *signature,
|
||||||
size_t signature_length)
|
size_t signature_length)
|
||||||
{
|
{
|
||||||
if (PSA_KEY_TYPE_IS_RSA(attributes->core.type)) {
|
if (PSA_KEY_TYPE_IS_RSA(attributes->type)) {
|
||||||
if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) ||
|
if (PSA_ALG_IS_RSA_PKCS1V15_SIGN(alg) ||
|
||||||
PSA_ALG_IS_RSA_PSS(alg)) {
|
PSA_ALG_IS_RSA_PSS(alg)) {
|
||||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||||
@@ -138,7 +138,7 @@ psa_status_t verify_hash(
|
|||||||
} else {
|
} else {
|
||||||
return PSA_ERROR_INVALID_ARGUMENT;
|
return PSA_ERROR_INVALID_ARGUMENT;
|
||||||
}
|
}
|
||||||
} else if (PSA_KEY_TYPE_IS_ECC(attributes->core.type)) {
|
} else if (PSA_KEY_TYPE_IS_ECC(attributes->type)) {
|
||||||
if (PSA_ALG_IS_ECDSA(alg)) {
|
if (PSA_ALG_IS_ECDSA(alg)) {
|
||||||
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
#if defined(MBEDTLS_TEST_LIBTESTDRIVER1) && \
|
||||||
(defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
(defined(LIBTESTDRIVER1_MBEDTLS_PSA_BUILTIN_ALG_ECDSA) || \
|
||||||
|
|||||||
@@ -12,9 +12,7 @@
|
|||||||
#include "mbedtls/psa_util.h"
|
#include "mbedtls/psa_util.h"
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_TLS_C)
|
#if defined(MBEDTLS_SSL_TLS_C)
|
||||||
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
|
int mbedtls_test_random(void *p_rng, unsigned char *output, size_t output_len)
|
||||||
static int rng_seed = 0xBEEF;
|
|
||||||
static int rng_get(void *p_rng, unsigned char *output, size_t output_len)
|
|
||||||
{
|
{
|
||||||
(void) p_rng;
|
(void) p_rng;
|
||||||
for (size_t i = 0; i < output_len; i++) {
|
for (size_t i = 0; i < output_len; i++) {
|
||||||
@@ -23,7 +21,6 @@ static int rng_get(void *p_rng, unsigned char *output, size_t output_len)
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
void mbedtls_test_ssl_log_analyzer(void *ctx, int level,
|
void mbedtls_test_ssl_log_analyzer(void *ctx, int level,
|
||||||
const char *file, int line,
|
const char *file, int line,
|
||||||
@@ -46,6 +43,8 @@ void mbedtls_test_init_handshake_options(
|
|||||||
mbedtls_test_handshake_test_options *opts)
|
mbedtls_test_handshake_test_options *opts)
|
||||||
{
|
{
|
||||||
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
|
#if defined(MBEDTLS_SSL_HANDSHAKE_WITH_CERT_ENABLED)
|
||||||
|
static int rng_seed = 0xBEEF;
|
||||||
|
|
||||||
srand(rng_seed);
|
srand(rng_seed);
|
||||||
rng_seed += 0xD0;
|
rng_seed += 0xD0;
|
||||||
#endif
|
#endif
|
||||||
@@ -686,9 +685,20 @@ int mbedtls_test_ssl_endpoint_certificate_init(mbedtls_test_ssl_endpoint *ep,
|
|||||||
|
|
||||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||||
if (opaque_alg != 0) {
|
if (opaque_alg != 0) {
|
||||||
TEST_EQUAL(mbedtls_pk_wrap_as_opaque(cert->pkey, &key_slot,
|
psa_key_attributes_t key_attr = PSA_KEY_ATTRIBUTES_INIT;
|
||||||
opaque_alg, opaque_usage,
|
/* Use a fake key usage to get a successful initial guess for the PSA attributes. */
|
||||||
opaque_alg2), 0);
|
TEST_EQUAL(mbedtls_pk_get_psa_attributes(cert->pkey, PSA_KEY_USAGE_SIGN_HASH,
|
||||||
|
&key_attr), 0);
|
||||||
|
/* Then manually usage, alg and alg2 as requested by the test. */
|
||||||
|
psa_set_key_usage_flags(&key_attr, opaque_usage);
|
||||||
|
psa_set_key_algorithm(&key_attr, opaque_alg);
|
||||||
|
if (opaque_alg2 != PSA_ALG_NONE) {
|
||||||
|
psa_set_key_enrollment_algorithm(&key_attr, opaque_alg2);
|
||||||
|
}
|
||||||
|
TEST_EQUAL(mbedtls_pk_import_into_psa(cert->pkey, &key_attr, &key_slot), 0);
|
||||||
|
mbedtls_pk_free(cert->pkey);
|
||||||
|
mbedtls_pk_init(cert->pkey);
|
||||||
|
TEST_EQUAL(mbedtls_pk_setup_opaque(cert->pkey, key_slot), 0);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
(void) opaque_alg;
|
(void) opaque_alg;
|
||||||
@@ -745,7 +755,7 @@ int mbedtls_test_ssl_endpoint_init(
|
|||||||
|
|
||||||
mbedtls_ssl_init(&(ep->ssl));
|
mbedtls_ssl_init(&(ep->ssl));
|
||||||
mbedtls_ssl_config_init(&(ep->conf));
|
mbedtls_ssl_config_init(&(ep->conf));
|
||||||
mbedtls_ssl_conf_rng(&(ep->conf), rng_get, NULL);
|
mbedtls_ssl_conf_rng(&(ep->conf), mbedtls_test_random, NULL);
|
||||||
|
|
||||||
TEST_ASSERT(mbedtls_ssl_conf_get_user_data_p(&ep->conf) == NULL);
|
TEST_ASSERT(mbedtls_ssl_conf_get_user_data_p(&ep->conf) == NULL);
|
||||||
TEST_EQUAL(mbedtls_ssl_conf_get_user_data_n(&ep->conf), 0);
|
TEST_EQUAL(mbedtls_ssl_conf_get_user_data_n(&ep->conf), 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user