mirror of
https://github.com/espressif/mbedtls.git
synced 2025-06-24 17:20:21 +08:00
Simplify unnecessarily complex error code handling
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
fd96579ecd
commit
ee5464fab9
@ -915,7 +915,7 @@ static int get_one_and_zeros_padding(unsigned char *input, size_t input_len,
|
|||||||
in_padding = mbedtls_ct_bool_and(in_padding, mbedtls_ct_bool_not(is_nonzero));
|
in_padding = mbedtls_ct_bool_and(in_padding, mbedtls_ct_bool_not(is_nonzero));
|
||||||
}
|
}
|
||||||
|
|
||||||
return -((int) mbedtls_ct_uint_if_else_0(bad, -MBEDTLS_ERR_CIPHER_INVALID_PADDING));
|
return (int) mbedtls_ct_uint_if_else_0(bad, MBEDTLS_ERR_CIPHER_INVALID_PADDING);
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */
|
#endif /* MBEDTLS_CIPHER_PADDING_ONE_AND_ZEROS */
|
||||||
|
|
||||||
@ -962,7 +962,7 @@ static int get_zeros_and_len_padding(unsigned char *input, size_t input_len,
|
|||||||
bad = mbedtls_ct_bool_or(bad, nonzero_pad_byte);
|
bad = mbedtls_ct_bool_or(bad, nonzero_pad_byte);
|
||||||
}
|
}
|
||||||
|
|
||||||
return -((int) mbedtls_ct_uint_if_else_0(bad, -MBEDTLS_ERR_CIPHER_INVALID_PADDING));
|
return (int) mbedtls_ct_uint_if_else_0(bad, MBEDTLS_ERR_CIPHER_INVALID_PADDING);
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */
|
#endif /* MBEDTLS_CIPHER_PADDING_ZEROS_AND_LEN */
|
||||||
|
|
||||||
|
@ -421,8 +421,8 @@ int mbedtls_nist_kw_unwrap(mbedtls_nist_kw_context *ctx,
|
|||||||
* larger than 8, because of the type wrap around.
|
* larger than 8, because of the type wrap around.
|
||||||
*/
|
*/
|
||||||
padlen = in_len - KW_SEMIBLOCK_LENGTH - Plen;
|
padlen = in_len - KW_SEMIBLOCK_LENGTH - Plen;
|
||||||
ret = -((int) mbedtls_ct_uint_if(mbedtls_ct_uint_gt(padlen, 7),
|
ret = (int) mbedtls_ct_uint_if(mbedtls_ct_uint_gt(padlen, 7),
|
||||||
-MBEDTLS_ERR_CIPHER_AUTH_FAILED, -ret));
|
MBEDTLS_ERR_CIPHER_AUTH_FAILED, ret);
|
||||||
padlen &= 7;
|
padlen &= 7;
|
||||||
|
|
||||||
/* Check padding in "constant-time" */
|
/* Check padding in "constant-time" */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user