Fix IAR pointless integer comparison
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
7e9af05409
commit
02a53d7bef
3 changed files with 10 additions and 0 deletions
|
@ -514,9 +514,11 @@ int mbedtls_pk_verify_ext(mbedtls_pk_type_t type, const void *options,
|
|||
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
|
||||
const mbedtls_pk_rsassa_pss_options *pss_opts;
|
||||
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
if (md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (options == NULL) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
|
|
|
@ -262,9 +262,11 @@ static int rsa_verify_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg,
|
|||
mbedtls_rsa_context *rsa = (mbedtls_rsa_context *) pk->pk_ctx;
|
||||
size_t rsa_len = mbedtls_rsa_get_len(rsa);
|
||||
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
if (md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (sig_len < rsa_len) {
|
||||
return MBEDTLS_ERR_RSA_VERIFY_FAILED;
|
||||
|
@ -382,9 +384,11 @@ static int rsa_sign_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg,
|
|||
{
|
||||
mbedtls_rsa_context *rsa = (mbedtls_rsa_context *) pk->pk_ctx;
|
||||
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
if (md_alg == MBEDTLS_MD_NONE && UINT_MAX < hash_len) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
*sig_len = mbedtls_rsa_get_len(rsa);
|
||||
if (sig_size < *sig_len) {
|
||||
|
@ -1565,9 +1569,11 @@ static int rsa_alt_sign_wrap(mbedtls_pk_context *pk, mbedtls_md_type_t md_alg,
|
|||
{
|
||||
mbedtls_rsa_alt_context *rsa_alt = pk->pk_ctx;
|
||||
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
if (UINT_MAX < hash_len) {
|
||||
return MBEDTLS_ERR_PK_BAD_INPUT_DATA;
|
||||
}
|
||||
#endif
|
||||
|
||||
*sig_len = rsa_alt->key_len_func(rsa_alt->key);
|
||||
if (*sig_len > MBEDTLS_PK_SIGNATURE_MAX_SIZE) {
|
||||
|
|
|
@ -328,9 +328,11 @@ static psa_status_t psa_rsa_decode_md_type(psa_algorithm_t alg,
|
|||
/* The Mbed TLS RSA module uses an unsigned int for hash length
|
||||
* parameters. Validate that it fits so that we don't risk an
|
||||
* overflow later. */
|
||||
#if SIZE_MAX > UINT_MAX
|
||||
if (hash_length > UINT_MAX) {
|
||||
return PSA_ERROR_INVALID_ARGUMENT;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* For signatures using a hash, the hash length must be correct. */
|
||||
if (alg != PSA_ALG_RSA_PKCS1V15_SIGN_RAW) {
|
||||
|
|
Loading…
Reference in a new issue