mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-07-07 22:10:42 +00:00
Style and language fixes
Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
parent
2a48b53ee7
commit
a6033e92af
|
@ -1,2 +1,2 @@
|
||||||
Features
|
Features
|
||||||
* Added support for AES-ECB to the PSA Crypto cipher API.
|
* Add support for ECB to the PSA cipher API.
|
||||||
|
|
|
@ -86,7 +86,7 @@ static inline psa_algorithm_t mbedtls_psa_translate_cipher_mode(
|
||||||
switch( mode )
|
switch( mode )
|
||||||
{
|
{
|
||||||
case MBEDTLS_MODE_ECB:
|
case MBEDTLS_MODE_ECB:
|
||||||
return ( PSA_ALG_ECB_NO_PADDING );
|
return( PSA_ALG_ECB_NO_PADDING );
|
||||||
case MBEDTLS_MODE_GCM:
|
case MBEDTLS_MODE_GCM:
|
||||||
return( PSA_ALG_AEAD_WITH_TAG_LENGTH( PSA_ALG_GCM, taglen ) );
|
return( PSA_ALG_AEAD_WITH_TAG_LENGTH( PSA_ALG_GCM, taglen ) );
|
||||||
case MBEDTLS_MODE_CCM:
|
case MBEDTLS_MODE_CCM:
|
||||||
|
|
|
@ -981,11 +981,22 @@
|
||||||
#define PSA_ALG_XTS ((psa_algorithm_t)0x044000ff)
|
#define PSA_ALG_XTS ((psa_algorithm_t)0x044000ff)
|
||||||
|
|
||||||
/** The Electronic Code Book (ECB) mode of a block cipher, with no padding.
|
/** The Electronic Code Book (ECB) mode of a block cipher, with no padding.
|
||||||
|
*
|
||||||
|
* \warning ECB mode does not protect the confidentiality of the encrypted data
|
||||||
|
* except in extremely narrow circumstances. It is recommended that applications
|
||||||
|
* only use ECB if they need to construct an operating mode that the
|
||||||
|
* implementation does not provide. Implementations are encouraged to provide
|
||||||
|
* the modes that applications need in preference to supporting direct access
|
||||||
|
* to ECB.
|
||||||
*
|
*
|
||||||
* The underlying block cipher is determined by the key type.
|
* The underlying block cipher is determined by the key type.
|
||||||
*
|
*
|
||||||
* This symmetric cipher mode can only be used with messages whose lengths
|
* This symmetric cipher mode can only be used with messages whose lengths are a
|
||||||
* are whole number of blocks for the chosen block cipher.
|
* multiple of the block size of the chosen block cipher.
|
||||||
|
*
|
||||||
|
* ECB mode does not accept an initialization vector (IV). When using a
|
||||||
|
* multi-part cipher operation with this algorithm, psa_cipher_generate_iv()
|
||||||
|
* and psa_cipher_set_iv() must not be called.
|
||||||
*/
|
*/
|
||||||
#define PSA_ALG_ECB_NO_PADDING ((psa_algorithm_t)0x04404400)
|
#define PSA_ALG_ECB_NO_PADDING ((psa_algorithm_t)0x04404400)
|
||||||
|
|
||||||
|
|
|
@ -3749,9 +3749,12 @@ static psa_status_t psa_cipher_init( psa_cipher_operation_t *operation,
|
||||||
operation->alg = alg;
|
operation->alg = alg;
|
||||||
operation->key_set = 0;
|
operation->key_set = 0;
|
||||||
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 {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
operation->iv_required = 1;
|
operation->iv_required = 1;
|
||||||
}
|
}
|
||||||
operation->iv_size = 0;
|
operation->iv_size = 0;
|
||||||
|
@ -3844,7 +3847,8 @@ static psa_status_t psa_cipher_setup( psa_cipher_operation_t *operation,
|
||||||
operation->key_set = 1;
|
operation->key_set = 1;
|
||||||
operation->block_size = ( PSA_ALG_IS_STREAM_CIPHER( alg ) ? 1 :
|
operation->block_size = ( PSA_ALG_IS_STREAM_CIPHER( alg ) ? 1 :
|
||||||
PSA_BLOCK_CIPHER_BLOCK_SIZE( slot->attr.type ) );
|
PSA_BLOCK_CIPHER_BLOCK_SIZE( slot->attr.type ) );
|
||||||
if( alg & PSA_ALG_CIPHER_FROM_BLOCK_FLAG && alg != PSA_ALG_ECB_NO_PADDING )
|
if( ( alg & PSA_ALG_CIPHER_FROM_BLOCK_FLAG ) != 0 &&
|
||||||
|
alg != PSA_ALG_ECB_NO_PADDING )
|
||||||
{
|
{
|
||||||
operation->iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( slot->attr.type );
|
operation->iv_size = PSA_BLOCK_CIPHER_BLOCK_SIZE( slot->attr.type );
|
||||||
}
|
}
|
||||||
|
@ -4002,7 +4006,8 @@ psa_status_t psa_cipher_finish( psa_cipher_operation_t *operation,
|
||||||
{
|
{
|
||||||
if( operation->alg == PSA_ALG_ECB_NO_PADDING ||
|
if( operation->alg == PSA_ALG_ECB_NO_PADDING ||
|
||||||
( operation->alg == PSA_ALG_CBC_NO_PADDING &&
|
( operation->alg == PSA_ALG_CBC_NO_PADDING &&
|
||||||
operation->ctx.cipher.operation == MBEDTLS_ENCRYPT ) ) {
|
operation->ctx.cipher.operation == MBEDTLS_ENCRYPT ) )
|
||||||
|
{
|
||||||
status = PSA_ERROR_INVALID_ARGUMENT;
|
status = PSA_ERROR_INVALID_ARGUMENT;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue