mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-25 03:15:28 +00:00
Merge pull request #5194 from bensze01/invalid_nonce_error_2.x
Backport 2.x: PSA: Indicate in the error returned when we know that an AEAD nonce length is invalid, not just unsupported
This commit is contained in:
commit
1d7f7a7c6e
3
ChangeLog.d/chacha20-poly1305-invalid-nonce.txt
Normal file
3
ChangeLog.d/chacha20-poly1305-invalid-nonce.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Changes
|
||||
* Indicate in the error returned if the nonce length used with
|
||||
ChaCha20-Poly1305 is invalid, and not just unsupported.
|
|
@ -224,7 +224,16 @@ psa_status_t mbedtls_psa_aead_encrypt(
|
|||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
|
||||
if( operation.core_alg == PSA_ALG_CHACHA20_POLY1305 )
|
||||
{
|
||||
if( nonce_length != 12 || operation.tag_length != 16 )
|
||||
if( nonce_length != 12 )
|
||||
{
|
||||
if( nonce_length == 8 )
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
else
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( operation.tag_length != 16 )
|
||||
{
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
goto exit;
|
||||
|
@ -331,7 +340,16 @@ psa_status_t mbedtls_psa_aead_decrypt(
|
|||
#if defined(MBEDTLS_PSA_BUILTIN_ALG_CHACHA20_POLY1305)
|
||||
if( operation.core_alg == PSA_ALG_CHACHA20_POLY1305 )
|
||||
{
|
||||
if( nonce_length != 12 || operation.tag_length != 16 )
|
||||
if( nonce_length != 12 )
|
||||
{
|
||||
if( nonce_length == 8 )
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
else
|
||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if( operation.tag_length != 16 )
|
||||
{
|
||||
status = PSA_ERROR_NOT_SUPPORTED;
|
||||
goto exit;
|
||||
|
|
|
@ -2413,11 +2413,11 @@ aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495
|
|||
|
||||
PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=11, too short)
|
||||
depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20
|
||||
aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243444546":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED
|
||||
aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"0700000040414243444546":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA AEAD decrypt: ChaCha20-Poly1305 (nonce=13, too long)
|
||||
depends_on:PSA_WANT_ALG_CHACHA20_POLY1305:PSA_WANT_KEY_TYPE_CHACHA20
|
||||
aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"07000000404142434445464700":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_NOT_SUPPORTED
|
||||
aead_decrypt:PSA_KEY_TYPE_CHACHA20:"808182838485868788898a8b8c8d8e8f909192939495969798999a9b9c9d9e9f":PSA_ALG_CHACHA20_POLY1305:"07000000404142434445464700":"":"a0784d7a4716f3feb4f64e7f4b39bf04":"":PSA_ERROR_INVALID_ARGUMENT
|
||||
|
||||
PSA AEAD encrypt/decrypt: invalid algorithm (CTR)
|
||||
depends_on:MBEDTLS_AES_C:MBEDTLS_GCM_C
|
||||
|
|
Loading…
Reference in a new issue