mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 08:14:27 +01:00
Restructured cipher_set_padding_mode() to use switch statement
This commit is contained in:
parent
ebdc413f44
commit
1a45d91cf2
@ -417,8 +417,10 @@ int cipher_setkey( cipher_context_t *ctx, const unsigned char *key, int key_leng
|
||||
* \param ctx generic cipher context
|
||||
* \param mode padding mode
|
||||
*
|
||||
* \returns 0 on success, POLARSSL_ERR_CIPHER_BAD_INPUT_DATA
|
||||
* if parameters verification fails.
|
||||
* \returns 0 on success, POLARSSL_ERR_CIPHER_FEATURE_UNAVAILABLE
|
||||
* if selected padding mode is not supported, or
|
||||
* POLARSSL_ERR_CIPHER_BAD_INPUT_DATA if the cipher mode
|
||||
* does not support padding.
|
||||
*/
|
||||
int cipher_set_padding_mode( cipher_context_t *ctx, cipher_padding_t mode );
|
||||
|
||||
|
@ -747,42 +747,38 @@ int cipher_set_padding_mode( cipher_context_t *ctx, cipher_padding_t mode )
|
||||
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
if( POLARSSL_PADDING_PKCS7 == mode )
|
||||
switch( mode )
|
||||
{
|
||||
case POLARSSL_PADDING_PKCS7:
|
||||
ctx->add_padding = add_pkcs_padding;
|
||||
ctx->get_padding = get_pkcs_padding;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
if( POLARSSL_PADDING_ONE_AND_ZEROS == mode )
|
||||
{
|
||||
case POLARSSL_PADDING_ONE_AND_ZEROS:
|
||||
ctx->add_padding = add_one_and_zeros_padding;
|
||||
ctx->get_padding = get_one_and_zeros_padding;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
if( POLARSSL_PADDING_ZEROS_AND_LEN == mode )
|
||||
{
|
||||
case POLARSSL_PADDING_ZEROS_AND_LEN:
|
||||
ctx->add_padding = add_zeros_and_len_padding;
|
||||
ctx->get_padding = get_zeros_and_len_padding;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
if( POLARSSL_PADDING_ZEROS == mode )
|
||||
{
|
||||
case POLARSSL_PADDING_ZEROS:
|
||||
ctx->add_padding = add_zeros_padding;
|
||||
ctx->get_padding = get_zeros_padding;
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
if( POLARSSL_PADDING_NONE == mode )
|
||||
{
|
||||
case POLARSSL_PADDING_NONE:
|
||||
ctx->add_padding = NULL;
|
||||
ctx->get_padding = get_no_padding;
|
||||
return 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
|
||||
}
|
||||
|
||||
return POLARSSL_ERR_CIPHER_BAD_INPUT_DATA;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(POLARSSL_SELF_TEST)
|
||||
|
Loading…
Reference in New Issue
Block a user