Fix RC4 multipart PSA

RC4 doesn't take an IV.

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
This commit is contained in:
Gilles Peskine 2022-04-20 17:00:22 +02:00
parent c768600de7
commit 4a83c1047f
3 changed files with 11 additions and 0 deletions

3
ChangeLog.d/psa-rc4.txt Normal file
View File

@ -0,0 +1,3 @@
Bugfix
* Fix PSA cipher multipart operations using RC4. Previously, an IV was
required but discarded. Now, an IV is rejected, as it should be.

View File

@ -3359,6 +3359,8 @@ static psa_status_t psa_cipher_setup( psa_cipher_operation_t *operation,
operation->iv_set = 0; operation->iv_set = 0;
if( alg == PSA_ALG_ECB_NO_PADDING ) if( alg == PSA_ALG_ECB_NO_PADDING )
operation->iv_required = 0; operation->iv_required = 0;
else if( slot->attr.type == PSA_KEY_TYPE_ARC4 )
operation->iv_required = 0;
else else
operation->iv_required = 1; operation->iv_required = 1;
operation->default_iv_length = PSA_CIPHER_IV_LENGTH( slot->attr.type, alg ); operation->default_iv_length = PSA_CIPHER_IV_LENGTH( slot->attr.type, alg );

View File

@ -11,21 +11,27 @@ hash_fail:PSA_ALG_ECDSA_ANY:PSA_ERROR_INVALID_ARGUMENT
# The RC4 construction allows any whole number of bytes from 1 to 256 bytes # The RC4 construction allows any whole number of bytes from 1 to 256 bytes
# (8 to 2048 bits). # (8 to 2048 bits).
PSA cipher STREAM_CIPHER: 8-bit ARC4 never supported PSA cipher STREAM_CIPHER: 8-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"41":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"41":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
PSA cipher STREAM_CIPHER: 40-bit ARC4 never supported PSA cipher STREAM_CIPHER: 40-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"4152433420":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"4152433420":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
PSA cipher STREAM_CIPHER: 120-bit ARC4 never supported PSA cipher STREAM_CIPHER: 120-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b65":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b65":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
PSA cipher STREAM_CIPHER: 136-bit ARC4 never supported PSA cipher STREAM_CIPHER: 136-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
PSA cipher STREAM_CIPHER: 256-bit ARC4 never supported PSA cipher STREAM_CIPHER: 256-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941524334206b657941524334206b6579":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941524334206b657941524334206b6579":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
PSA cipher STREAM_CIPHER: 2048-bit ARC4 never supported PSA cipher STREAM_CIPHER: 2048-bit ARC4 never supported
depends_on:PSA_WANT_KEY_TYPE_ARC4
cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b6579":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED cipher_fail:PSA_KEY_TYPE_ARC4:"41524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b657941524334206b6579":PSA_ALG_STREAM_CIPHER:PSA_ERROR_NOT_SUPPORTED
# Redundant, to help debugging the test code # Redundant, to help debugging the test code