mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-07-30 16:26:33 +08:00
Merge f5e1cb21c8d7ba9c0a2c0450afac524bab9e819c into f4a1aceb8ca7198b11447d6e1885ce70feb2dcc6
This commit is contained in:
commit
5f67f7cbc4
2
ChangeLog.d/iar-4.1.0.txt
Normal file
2
ChangeLog.d/iar-4.1.0.txt
Normal file
@ -0,0 +1,2 @@
|
||||
Bugfix
|
||||
* Fix some IAR warnings. Fixes #10648.
|
||||
@ -38,7 +38,14 @@
|
||||
|
||||
#include "mbedtls/platform.h"
|
||||
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/* Suppress a very overeager warning from IAR: it dislikes a forward goto
|
||||
* that bypasses the initialization of a variable, even if that variable
|
||||
* is not used after the jump. (This is perfectly valid C; it would only
|
||||
* be invalid C if jumping into a block from outside that block.)
|
||||
*/
|
||||
#pragma diag_suppress=Pe546 // transfer of control bypasses initialization
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Conditionally select an MPI sign in constant time.
|
||||
|
||||
@ -20,6 +20,15 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/* Suppress a very overeager warning from IAR: it dislikes a forward goto
|
||||
* that bypasses the initialization of a variable, even if that variable
|
||||
* is not used after the jump. (This is perfectly valid C; it would only
|
||||
* be invalid C if jumping into a block from outside that block.)
|
||||
*/
|
||||
#pragma diag_suppress=Pe546 // transfer of control bypasses initialization
|
||||
#endif
|
||||
|
||||
/* mbedtls_cipher_values_from_psa() below only checks if the proper build symbols
|
||||
* are enabled, but it does not provide any compatibility check between them
|
||||
* (i.e. if the specified key works with the specified algorithm). This helper
|
||||
|
||||
@ -10204,7 +10204,7 @@ int mbedtls_ssl_export_keying_material(mbedtls_ssl_context *ssl,
|
||||
|
||||
int ciphersuite_id = mbedtls_ssl_get_ciphersuite_id_from_ssl(ssl);
|
||||
const mbedtls_ssl_ciphersuite_t *ciphersuite = mbedtls_ssl_ciphersuite_from_id(ciphersuite_id);
|
||||
const mbedtls_md_type_t hash_alg = ciphersuite->mac;
|
||||
const mbedtls_md_type_t hash_alg = (mbedtls_md_type_t) ciphersuite->mac;
|
||||
|
||||
switch (mbedtls_ssl_get_version_number(ssl)) {
|
||||
#if defined(MBEDTLS_SSL_PROTO_TLS1_2)
|
||||
|
||||
@ -11,6 +11,15 @@
|
||||
#include <test/ssl_helpers.h>
|
||||
#include "mbedtls/psa_util.h"
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/* Suppress a very overeager warning from IAR: it dislikes a forward goto
|
||||
* that bypasses the initialization of a variable, even if that variable
|
||||
* is not used after the jump. (This is perfectly valid C; it would only
|
||||
* be invalid C if jumping into a block from outside that block.)
|
||||
*/
|
||||
#pragma diag_suppress=Pe546 // transfer of control bypasses initialization
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS_C)
|
||||
int mbedtls_test_random(void *p_rng, unsigned char *output, size_t output_len)
|
||||
{
|
||||
@ -1285,12 +1294,15 @@ static void mbedtls_test_ssl_cipher_info_from_type(mbedtls_cipher_type_t cipher_
|
||||
|
||||
int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
mbedtls_ssl_transform *t_out,
|
||||
int cipher_type, int hash_id,
|
||||
int cipher_type_arg, int md_type_arg,
|
||||
int etm, int tag_mode,
|
||||
mbedtls_ssl_protocol_version tls_version,
|
||||
size_t cid0_len,
|
||||
size_t cid1_len)
|
||||
{
|
||||
mbedtls_md_type_t md_type = (mbedtls_md_type_t) md_type_arg;
|
||||
mbedtls_cipher_type_t cipher_type = (mbedtls_cipher_type_t) cipher_type_arg;
|
||||
|
||||
mbedtls_cipher_mode_t cipher_mode = MBEDTLS_MODE_NONE;
|
||||
size_t key_bits = 0;
|
||||
int ret = 0;
|
||||
@ -1321,7 +1333,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
#endif /* MBEDTLS_SSL_DTLS_CONNECTION_ID */
|
||||
|
||||
maclen = 0;
|
||||
mbedtls_test_ssl_cipher_info_from_type((mbedtls_cipher_type_t) cipher_type,
|
||||
mbedtls_test_ssl_cipher_info_from_type(cipher_type,
|
||||
&cipher_mode, &key_bits, &ivlen);
|
||||
|
||||
/* Pick keys */
|
||||
@ -1336,7 +1348,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
/* Pick cipher */
|
||||
cipher_info = mbedtls_cipher_info_from_type((mbedtls_cipher_type_t) cipher_type);
|
||||
cipher_info = mbedtls_cipher_info_from_type(cipher_type);
|
||||
CHK(cipher_info != NULL);
|
||||
CHK(mbedtls_cipher_info_get_iv_size(cipher_info) <= 16);
|
||||
CHK(mbedtls_cipher_info_get_key_bitlen(cipher_info) % 8 == 0);
|
||||
@ -1383,10 +1395,10 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
if (cipher_mode == MBEDTLS_MODE_CBC ||
|
||||
cipher_mode == MBEDTLS_MODE_STREAM) {
|
||||
#if !defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
mbedtls_md_info_t const *md_info = mbedtls_md_info_from_type((mbedtls_md_type_t) hash_id);
|
||||
mbedtls_md_info_t const *md_info = mbedtls_md_info_from_type(md_type);
|
||||
CHK(md_info != NULL);
|
||||
#endif
|
||||
maclen = mbedtls_md_get_size_from_type((mbedtls_md_type_t) hash_id);
|
||||
maclen = mbedtls_md_get_size_from_type(md_type);
|
||||
CHK(maclen != 0);
|
||||
/* Pick hash keys */
|
||||
CHK((md0 = mbedtls_calloc(1, maclen)) != NULL);
|
||||
@ -1395,7 +1407,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
memset(md1, 0x6, maclen);
|
||||
|
||||
#if defined(MBEDTLS_USE_PSA_CRYPTO)
|
||||
alg = mbedtls_md_psa_alg_from_type(hash_id);
|
||||
alg = mbedtls_md_psa_alg_from_type(md_type);
|
||||
|
||||
CHK(alg != 0);
|
||||
|
||||
@ -1452,7 +1464,7 @@ int mbedtls_test_ssl_build_transforms(mbedtls_ssl_transform *t_in,
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
((void) hash_id);
|
||||
(void) md_type;
|
||||
#endif /* MBEDTLS_SSL_SOME_SUITES_USE_MAC */
|
||||
|
||||
|
||||
|
||||
@ -39,7 +39,7 @@ static int verify_int(char *str, intmax_t *p_value)
|
||||
/* Limit the range to long: for large integers, the test framework will
|
||||
* use expressions anyway. */
|
||||
long value = strtol(str, &end, 0);
|
||||
if (errno == EINVAL || *end != '\0') {
|
||||
if (*end != '\0' || end == str) {
|
||||
mbedtls_fprintf(stderr,
|
||||
"Expected integer for parameter and got: %s\n", str);
|
||||
return KEY_VALUE_MAPPING_NOT_FOUND;
|
||||
|
||||
@ -34,6 +34,12 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/* With IAR, enable support for ::FILE functions in stdio.h.
|
||||
*/
|
||||
#define _DLIB_FILE_DESCRIPTOR 1
|
||||
#endif
|
||||
|
||||
#include "mbedtls/build_info.h"
|
||||
|
||||
/* Test code may use deprecated identifiers only if the preprocessor symbol
|
||||
@ -57,6 +63,24 @@ __MBEDTLS_TEST_TEMPLATE__TEST_COMMON_HELPERS
|
||||
/* Test Suite Code */
|
||||
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
/* Suppress a very overeager warning from IAR: it dislikes a forward goto
|
||||
* that bypasses the initialization of a variable, even if that variable
|
||||
* is not used after the jump. (This is perfectly valid C; it would only
|
||||
* be invalid C if jumping into a block from outside that block.)
|
||||
*/
|
||||
#pragma diag_suppress=Pe546 // transfer of control bypasses initialization
|
||||
|
||||
/* Temporarily suppress a perfectly reasonable warning from IAR that
|
||||
* comes up very often in our unit tests: silent conversion of int to
|
||||
* an enum type.
|
||||
*
|
||||
* Remove this when https://github.com/Mbed-TLS/TF-PSA-Crypto/issues/707
|
||||
* is fixed.
|
||||
*/
|
||||
#pragma diag_suppress=Pe188 // enumerated type mixed with another type
|
||||
#endif
|
||||
|
||||
#define TEST_SUITE_ACTIVE
|
||||
|
||||
__MBEDTLS_TEST_TEMPLATE__FUNCTIONS_CODE
|
||||
@ -221,7 +245,6 @@ static int check_test(size_t func_idx)
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
__MBEDTLS_TEST_TEMPLATE__PLATFORM_CODE
|
||||
|
||||
#line __MBEDTLS_TEST_TEMPLATE__LINE_NO "suites/main_test.function"
|
||||
|
||||
@ -158,12 +158,6 @@ void mbedtls_byteswap(char *input_str, int size, char *expected_str)
|
||||
/* BEGIN_CASE */
|
||||
void get_byte()
|
||||
{
|
||||
uint8_t data[16];
|
||||
|
||||
for (size_t i = 0; i < sizeof(data); i++) {
|
||||
data[i] = (uint8_t) i;
|
||||
}
|
||||
|
||||
uint64_t u64 = 0x0706050403020100;
|
||||
for (size_t b = 0; b < 8; b++) {
|
||||
uint8_t expected = b;
|
||||
|
||||
@ -580,7 +580,7 @@ void ecdh_context_grp(int id)
|
||||
mbedtls_ecdh_init(&srv);
|
||||
TEST_ASSERT(mbedtls_ecdh_setup(&srv, id) == 0);
|
||||
|
||||
/* Test the retrieved group id matches/*/
|
||||
/* Test the retrieved group id matches */
|
||||
TEST_ASSERT((int) mbedtls_ecdh_get_grp_id(&srv) == id);
|
||||
|
||||
exit:
|
||||
|
||||
@ -6,10 +6,14 @@
|
||||
#include "mbedtls/x509_crl.h"
|
||||
#include "x509_internal.h"
|
||||
#include "mbedtls/oid.h"
|
||||
#include "sys/types.h"
|
||||
#include "sys/stat.h"
|
||||
#include "mbedtls/rsa.h"
|
||||
#include "mbedtls/error.h"
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
#include "sys/types.h"
|
||||
#include "sys/stat.h"
|
||||
#endif
|
||||
|
||||
/* END_HEADER */
|
||||
|
||||
/* BEGIN_DEPENDENCIES
|
||||
|
||||
@ -836,8 +836,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 1) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -942,8 +942,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 1) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1010,8 +1010,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 2) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
|
||||
break;
|
||||
@ -1077,8 +1077,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 3) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1137,8 +1137,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 3) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1177,8 +1177,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
|
||||
/* Error didn't trigger, make test fail */
|
||||
if (inject_error == 4) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -252,8 +252,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND1_SERVER_KEY_SHARE_PART1) &&
|
||||
(err_stage <= ERR_INJECT_ROUND1_SERVER_ZK_PROOF_PART2)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -346,8 +346,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND1_SERVER_KEY_SHARE_PART1) &&
|
||||
(err_stage <= ERR_INJECT_ROUND1_SERVER_ZK_PROOF_PART2)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,8 +379,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND1_CLIENT_KEY_SHARE_PART1) &&
|
||||
(err_stage <= ERR_INJECT_ROUND1_CLIENT_ZK_PROOF_PART2)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
|
||||
break;
|
||||
@ -435,8 +435,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND2_SERVER_KEY_SHARE) &&
|
||||
(err_stage <= ERR_INJECT_ROUND2_SERVER_ZK_PROOF)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -499,8 +499,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND2_SERVER_KEY_SHARE) &&
|
||||
(err_stage <= ERR_INJECT_ROUND2_SERVER_ZK_PROOF)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,8 +526,8 @@ static void ecjpake_do_round(psa_algorithm_t alg, unsigned int primitive,
|
||||
/* Error didn't trigger, make test fail */
|
||||
if ((err_stage >= ERR_INJECT_ROUND2_CLIENT_KEY_SHARE) &&
|
||||
(err_stage <= ERR_INJECT_ROUND2_CLIENT_ZK_PROOF)) {
|
||||
TEST_ASSERT(
|
||||
!"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
TEST_FAIL(
|
||||
"One of the last psa_pake_input() calls should have returned the expected error.");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@ -1190,7 +1190,7 @@ void mbedtls_rsa_validate_params(char *input_N,
|
||||
have_D ? &D : NULL,
|
||||
have_E ? &E : NULL,
|
||||
prng ? mbedtls_test_rnd_std_rand : NULL,
|
||||
prng ? NULL : NULL) == result);
|
||||
NULL) == result);
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free(&N);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user