mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #9189 from misch7/fix-v3.6-issues-9186-and-9188
Fix build of v3.6 (issues #9186 and #9188)
This commit is contained in:
@ -244,14 +244,14 @@ component_build_no_ssl_srv () {
|
||||
msg "build: full config except SSL server, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_SSL_SRV_C
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -Wmissing-prototypes'
|
||||
}
|
||||
|
||||
component_build_no_ssl_cli () {
|
||||
msg "build: full config except SSL client, make, gcc" # ~ 30s
|
||||
scripts/config.py full
|
||||
scripts/config.py unset MBEDTLS_SSL_CLI_C
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1'
|
||||
make CC=gcc CFLAGS='-Werror -Wall -Wextra -O1 -Wmissing-prototypes'
|
||||
}
|
||||
|
||||
component_test_no_max_fragment_length () {
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
#include <mbedtls/asn1.h>
|
||||
|
||||
#include <test/asn1_helpers.h>
|
||||
|
||||
int mbedtls_test_asn1_skip_integer(unsigned char **p, const unsigned char *end,
|
||||
size_t min_bits, size_t max_bits,
|
||||
int must_be_odd)
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include <test/helpers.h>
|
||||
|
||||
#if defined(MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS)
|
||||
|
||||
#include <psa/crypto.h>
|
||||
#include <psa/crypto_extra.h>
|
||||
|
||||
@ -76,3 +78,5 @@ psa_status_t mbedtls_psa_platform_get_builtin_key(
|
||||
|
||||
return PSA_ERROR_DOES_NOT_EXIST;
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_PSA_CRYPTO_BUILTIN_KEYS */
|
||||
|
@ -4,7 +4,8 @@
|
||||
* Copyright The Mbed TLS Contributors
|
||||
* SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
|
||||
*/
|
||||
#include "test/memory.h"
|
||||
#include <test/memory.h>
|
||||
#include <test/psa_memory_poisoning_wrappers.h>
|
||||
|
||||
#include "psa_crypto_invasive.h"
|
||||
|
||||
|
@ -950,10 +950,10 @@ int mbedtls_test_move_handshake_to_state(mbedtls_ssl_context *ssl,
|
||||
/*
|
||||
* Write application data. Increase write counter if necessary.
|
||||
*/
|
||||
int mbedtls_ssl_write_fragment(mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf, int buf_len,
|
||||
int *written,
|
||||
const int expected_fragments)
|
||||
static int mbedtls_ssl_write_fragment(mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf, int buf_len,
|
||||
int *written,
|
||||
const int expected_fragments)
|
||||
{
|
||||
int ret;
|
||||
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is
|
||||
@ -997,10 +997,10 @@ exit:
|
||||
* Read application data and increase read counter and fragments counter
|
||||
* if necessary.
|
||||
*/
|
||||
int mbedtls_ssl_read_fragment(mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf, int buf_len,
|
||||
int *read, int *fragments,
|
||||
const int expected_fragments)
|
||||
static int mbedtls_ssl_read_fragment(mbedtls_ssl_context *ssl,
|
||||
unsigned char *buf, int buf_len,
|
||||
int *read, int *fragments,
|
||||
const int expected_fragments)
|
||||
{
|
||||
int ret;
|
||||
/* Verify that calling mbedtls_ssl_write with a NULL buffer and zero length is
|
||||
|
@ -9,7 +9,7 @@ struct buffer_data {
|
||||
char *ptr;
|
||||
};
|
||||
|
||||
void string_debug(void *data, int level, const char *file, int line, const char *str)
|
||||
static void string_debug(void *data, int level, const char *file, int line, const char *str)
|
||||
{
|
||||
struct buffer_data *buffer = (struct buffer_data *) data;
|
||||
char *p = buffer->ptr;
|
||||
|
@ -17,7 +17,7 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
/* BEGIN_SUITE_HELPERS */
|
||||
int pkcs7_parse_buffer(unsigned char *pkcs7_buf, int buflen)
|
||||
static int pkcs7_parse_buffer(unsigned char *pkcs7_buf, int buflen)
|
||||
{
|
||||
int res;
|
||||
mbedtls_pkcs7 pkcs7;
|
||||
|
@ -1623,11 +1623,11 @@ void ssl_tls13_derive_secret(int hash_alg,
|
||||
|
||||
unsigned char const *lbl = NULL;
|
||||
size_t lbl_len;
|
||||
#define MBEDTLS_SSL_TLS1_3_LABEL(name, string) \
|
||||
if (label_idx == (int) tls13_label_ ## name) \
|
||||
#define MBEDTLS_SSL_TLS1_3_LABEL(name, string) \
|
||||
if (label_idx == (int) tls13_label_ ## name) \
|
||||
{ \
|
||||
lbl = mbedtls_ssl_tls13_labels.name; \
|
||||
lbl_len = sizeof(mbedtls_ssl_tls13_labels.name); \
|
||||
lbl_len = sizeof(mbedtls_ssl_tls13_labels.name); \
|
||||
}
|
||||
MBEDTLS_SSL_TLS1_3_LABEL_LIST
|
||||
#undef MBEDTLS_SSL_TLS1_3_LABEL
|
||||
@ -1667,7 +1667,7 @@ void ssl_tls13_derive_early_secrets(int hash_alg,
|
||||
/* Double-check that we've passed sane parameters. */
|
||||
psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
|
||||
size_t const hash_len = PSA_HASH_LENGTH(alg);
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
secret->len == hash_len &&
|
||||
transcript->len == hash_len &&
|
||||
traffic_expected->len == hash_len &&
|
||||
@ -1701,7 +1701,7 @@ void ssl_tls13_derive_handshake_secrets(int hash_alg,
|
||||
/* Double-check that we've passed sane parameters. */
|
||||
psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
|
||||
size_t const hash_len = PSA_HASH_LENGTH(alg);
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
secret->len == hash_len &&
|
||||
transcript->len == hash_len &&
|
||||
client_expected->len == hash_len &&
|
||||
@ -1736,7 +1736,7 @@ void ssl_tls13_derive_application_secrets(int hash_alg,
|
||||
/* Double-check that we've passed sane parameters. */
|
||||
psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
|
||||
size_t const hash_len = PSA_HASH_LENGTH(alg);
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
secret->len == hash_len &&
|
||||
transcript->len == hash_len &&
|
||||
client_expected->len == hash_len &&
|
||||
@ -1772,7 +1772,7 @@ void ssl_tls13_derive_resumption_secrets(int hash_alg,
|
||||
/* Double-check that we've passed sane parameters. */
|
||||
psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
|
||||
size_t const hash_len = PSA_HASH_LENGTH(alg);
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
secret->len == hash_len &&
|
||||
transcript->len == hash_len &&
|
||||
resumption_expected->len == hash_len);
|
||||
@ -1803,7 +1803,7 @@ void ssl_tls13_create_psk_binder(int hash_alg,
|
||||
/* Double-check that we've passed sane parameters. */
|
||||
psa_algorithm_t alg = (psa_algorithm_t) hash_alg;
|
||||
size_t const hash_len = PSA_HASH_LENGTH(alg);
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
TEST_ASSERT(PSA_ALG_IS_HASH(alg) &&
|
||||
transcript->len == hash_len &&
|
||||
binder_expected->len == hash_len);
|
||||
|
||||
|
@ -60,7 +60,10 @@ const mbedtls_x509_crt_profile profile_sha512 =
|
||||
1024,
|
||||
};
|
||||
|
||||
int verify_none(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
static int verify_none(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
{
|
||||
((void) data);
|
||||
((void) crt);
|
||||
@ -70,7 +73,7 @@ int verify_none(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32
|
||||
return 0;
|
||||
}
|
||||
|
||||
int verify_all(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
static int verify_all(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
{
|
||||
((void) data);
|
||||
((void) crt);
|
||||
@ -80,8 +83,10 @@ int verify_all(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||
int ca_callback_fail(void *data, mbedtls_x509_crt const *child, mbedtls_x509_crt **candidates)
|
||||
#if defined(MBEDTLS_X509_CRL_PARSE_C) && \
|
||||
defined(MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK)
|
||||
static int ca_callback_fail(void *data, mbedtls_x509_crt const *child,
|
||||
mbedtls_x509_crt **candidates)
|
||||
{
|
||||
((void) data);
|
||||
((void) child);
|
||||
@ -89,9 +94,9 @@ int ca_callback_fail(void *data, mbedtls_x509_crt const *child, mbedtls_x509_crt
|
||||
|
||||
return -1;
|
||||
}
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
int ca_callback(void *data, mbedtls_x509_crt const *child,
|
||||
mbedtls_x509_crt **candidates)
|
||||
|
||||
static int ca_callback(void *data, mbedtls_x509_crt const *child,
|
||||
mbedtls_x509_crt **candidates)
|
||||
{
|
||||
int ret = 0;
|
||||
mbedtls_x509_crt *ca = (mbedtls_x509_crt *) data;
|
||||
@ -138,10 +143,9 @@ exit:
|
||||
*candidates = first;
|
||||
return ret;
|
||||
}
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
#endif /* MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
|
||||
#endif /* MBEDTLS_X509_CRL_PARSE_C && MBEDTLS_X509_TRUSTED_CERTIFICATE_CALLBACK */
|
||||
|
||||
int verify_fatal(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
static int verify_fatal(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
{
|
||||
int *levels = (int *) data;
|
||||
|
||||
@ -158,7 +162,7 @@ int verify_fatal(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint3
|
||||
}
|
||||
|
||||
/* strsep() not available on Windows */
|
||||
char *mystrsep(char **stringp, const char *delim)
|
||||
static char *mystrsep(char **stringp, const char *delim)
|
||||
{
|
||||
const char *p;
|
||||
char *ret = *stringp;
|
||||
@ -186,19 +190,18 @@ done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#if defined(MBEDTLS_X509_CRT_PARSE_C)
|
||||
typedef struct {
|
||||
char buf[512];
|
||||
char *p;
|
||||
} verify_print_context;
|
||||
|
||||
void verify_print_init(verify_print_context *ctx)
|
||||
static void verify_print_init(verify_print_context *ctx)
|
||||
{
|
||||
memset(ctx, 0, sizeof(verify_print_context));
|
||||
ctx->p = ctx->buf;
|
||||
}
|
||||
|
||||
int verify_print(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
static int verify_print(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint32_t *flags)
|
||||
{
|
||||
int ret;
|
||||
verify_print_context *ctx = (verify_print_context *) data;
|
||||
@ -226,8 +229,8 @@ int verify_print(void *data, mbedtls_x509_crt *crt, int certificate_depth, uint3
|
||||
return 0;
|
||||
}
|
||||
|
||||
int verify_parse_san(mbedtls_x509_subject_alternative_name *san,
|
||||
char **buf, size_t *size)
|
||||
static int verify_parse_san(mbedtls_x509_subject_alternative_name *san,
|
||||
char **buf, size_t *size)
|
||||
{
|
||||
int ret;
|
||||
size_t i;
|
||||
@ -316,9 +319,10 @@ int verify_parse_san(mbedtls_x509_subject_alternative_name *san,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
|
||||
int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf const *oid,
|
||||
int critical, const unsigned char *cp, const unsigned char *end)
|
||||
static int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf const *oid,
|
||||
int critical, const unsigned char *cp, const unsigned char *end)
|
||||
{
|
||||
(void) crt;
|
||||
(void) critical;
|
||||
@ -416,9 +420,14 @@ int parse_crt_ext_cb(void *p_ctx, mbedtls_x509_crt const *crt, mbedtls_x509_buf
|
||||
}
|
||||
#endif /* MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C)
|
||||
int parse_csr_ext_accept_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid,
|
||||
int critical, const unsigned char *cp, const unsigned char *end)
|
||||
#if defined(MBEDTLS_X509_CSR_PARSE_C) && \
|
||||
!defined(MBEDTLS_X509_REMOVE_INFO)
|
||||
static int parse_csr_ext_accept_cb(void *p_ctx,
|
||||
mbedtls_x509_csr const *csr,
|
||||
mbedtls_x509_buf const *oid,
|
||||
int critical,
|
||||
const unsigned char *cp,
|
||||
const unsigned char *end)
|
||||
{
|
||||
(void) p_ctx;
|
||||
(void) csr;
|
||||
@ -430,8 +439,12 @@ int parse_csr_ext_accept_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x5
|
||||
return 0;
|
||||
}
|
||||
|
||||
int parse_csr_ext_reject_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x509_buf const *oid,
|
||||
int critical, const unsigned char *cp, const unsigned char *end)
|
||||
static int parse_csr_ext_reject_cb(void *p_ctx,
|
||||
mbedtls_x509_csr const *csr,
|
||||
mbedtls_x509_buf const *oid,
|
||||
int critical,
|
||||
const unsigned char *cp,
|
||||
const unsigned char *end)
|
||||
{
|
||||
(void) p_ctx;
|
||||
(void) csr;
|
||||
@ -443,7 +456,7 @@ int parse_csr_ext_reject_cb(void *p_ctx, mbedtls_x509_csr const *csr, mbedtls_x5
|
||||
return MBEDTLS_ERROR_ADD(MBEDTLS_ERR_X509_INVALID_EXTENSIONS,
|
||||
MBEDTLS_ERR_ASN1_UNEXPECTED_TAG);
|
||||
}
|
||||
#endif /* MBEDTLS_X509_CSR_PARSE_C */
|
||||
#endif /* MBEDTLS_X509_CSR_PARSE_C && !MBEDTLS_X509_REMOVE_INFO */
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_X509_CRT_PARSE_C */
|
||||
|
@ -10,27 +10,31 @@
|
||||
#include "mbedtls/pk.h"
|
||||
#include "mbedtls/psa_util.h"
|
||||
|
||||
#if defined(MBEDTLS_RSA_C)
|
||||
int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen,
|
||||
const unsigned char *input, unsigned char *output,
|
||||
size_t output_max_len)
|
||||
#if defined(MBEDTLS_PEM_WRITE_C) && \
|
||||
defined(MBEDTLS_X509_CRT_WRITE_C) && \
|
||||
defined(MBEDTLS_X509_CRT_PARSE_C) && \
|
||||
defined(MBEDTLS_MD_CAN_SHA1) && \
|
||||
defined(MBEDTLS_RSA_C) && defined(MBEDTLS_PK_RSA_ALT_SUPPORT)
|
||||
static int mbedtls_rsa_decrypt_func(void *ctx, size_t *olen,
|
||||
const unsigned char *input, unsigned char *output,
|
||||
size_t output_max_len)
|
||||
{
|
||||
return mbedtls_rsa_pkcs1_decrypt((mbedtls_rsa_context *) ctx, NULL, NULL,
|
||||
olen, input, output, output_max_len);
|
||||
}
|
||||
int mbedtls_rsa_sign_func(void *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
|
||||
mbedtls_md_type_t md_alg, unsigned int hashlen,
|
||||
const unsigned char *hash, unsigned char *sig)
|
||||
static int mbedtls_rsa_sign_func(void *ctx,
|
||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
|
||||
mbedtls_md_type_t md_alg, unsigned int hashlen,
|
||||
const unsigned char *hash, unsigned char *sig)
|
||||
{
|
||||
return mbedtls_rsa_pkcs1_sign((mbedtls_rsa_context *) ctx, f_rng, p_rng,
|
||||
md_alg, hashlen, hash, sig);
|
||||
}
|
||||
size_t mbedtls_rsa_key_len_func(void *ctx)
|
||||
static size_t mbedtls_rsa_key_len_func(void *ctx)
|
||||
{
|
||||
return ((const mbedtls_rsa_context *) ctx)->len;
|
||||
}
|
||||
#endif /* MBEDTLS_RSA_C */
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO) && \
|
||||
defined(MBEDTLS_PEM_WRITE_C) && defined(MBEDTLS_X509_CSR_WRITE_C)
|
||||
|
Reference in New Issue
Block a user