mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-09-23 18:47:23 +00:00
Reject overlong PSA ChaChaPoly lengths
Signed-off-by: Ben Taylor <[email protected]>
This commit is contained in:
@@ -5357,7 +5357,13 @@ psa_status_t psa_aead_set_lengths(psa_aead_operation_t *operation,
|
||||
#endif /* PSA_WANT_ALG_CCM */
|
||||
#if defined(PSA_WANT_ALG_CHACHA20_POLY1305)
|
||||
case PSA_ALG_CHACHA20_POLY1305:
|
||||
/* No length restrictions for ChaChaPoly. */
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
if (plaintext_length > (size_t) UINT32_MAX *
|
||||
64U) {
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
goto exit;
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
#endif /* PSA_WANT_ALG_CHACHA20_POLY1305 */
|
||||
default:
|
||||
|
||||
@@ -6367,7 +6367,8 @@ void aead_multipart_state_test(int key_type_arg, data_t *key_data,
|
||||
#if SIZE_MAX > UINT32_MAX
|
||||
PSA_ASSERT(psa_aead_encrypt_setup(&operation, key, alg));
|
||||
|
||||
if (operation.alg == PSA_ALG_GCM) {
|
||||
if (operation.alg == PSA_ALG_GCM ||
|
||||
operation.alg == PSA_ALG_CHACHA20_POLY1305) {
|
||||
TEST_EQUAL(psa_aead_set_lengths(&operation, additional_data->len,
|
||||
SIZE_MAX),
|
||||
PSA_ERROR_INVALID_ARGUMENT);
|
||||
@@ -6388,7 +6389,8 @@ void aead_multipart_state_test(int key_type_arg, data_t *key_data,
|
||||
|
||||
PSA_ASSERT(psa_aead_set_nonce(&operation, nonce->x, nonce->len));
|
||||
|
||||
if (operation.alg == PSA_ALG_GCM) {
|
||||
if (operation.alg == PSA_ALG_GCM ||
|
||||
operation.alg == PSA_ALG_CHACHA20_POLY1305) {
|
||||
TEST_EQUAL(psa_aead_set_lengths(&operation, additional_data->len,
|
||||
SIZE_MAX),
|
||||
PSA_ERROR_INVALID_ARGUMENT);
|
||||
|
||||
Reference in New Issue
Block a user