Remove useless parameter from function

This commit is contained in:
Manuel Pégourié-Gonnard 2018-05-22 13:18:01 +02:00
parent 89924ddc7e
commit 08c337d058
3 changed files with 14 additions and 20 deletions

View file

@ -124,24 +124,21 @@ int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
* \brief This function performs an ARIA single-block encryption or * \brief This function performs an ARIA single-block encryption or
* decryption operation. * decryption operation.
* *
* It performs the operation defined in the \p mode parameter * It performs encryption or decryption (depending on whether
* (encrypt or decrypt), on the input data buffer defined in * the key was set for encryption on decryption) on the input
* the \p input parameter. * data buffer defined in the \p input parameter.
* *
* mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or * mbedtls_aria_init(), and either mbedtls_aria_setkey_enc() or
* mbedtls_aria_setkey_dec() must be called before the first * mbedtls_aria_setkey_dec() must be called before the first
* call to this API with the same context. * call to this API with the same context.
* *
* \param ctx The ARIA context to use for encryption or decryption. * \param ctx The ARIA context to use for encryption or decryption.
* \param mode The ARIA operation: #MBEDTLS_ARIA_ENCRYPT or
* #MBEDTLS_ARIA_DECRYPT.
* \param input The 16-Byte buffer holding the input data. * \param input The 16-Byte buffer holding the input data.
* \param output The 16-Byte buffer holding the output data. * \param output The 16-Byte buffer holding the output data.
* \return \c 0 on success. * \return \c 0 on success.
*/ */
int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
int mode,
const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ); unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] );

View file

@ -536,7 +536,6 @@ int mbedtls_aria_setkey_dec( mbedtls_aria_context *ctx,
* Encrypt a block * Encrypt a block
*/ */
int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx, int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
int mode,
const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE], const unsigned char input[MBEDTLS_ARIA_BLOCKSIZE],
unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] ) unsigned char output[MBEDTLS_ARIA_BLOCKSIZE] )
{ {
@ -544,8 +543,6 @@ int mbedtls_aria_crypt_ecb( mbedtls_aria_context *ctx,
uint32_t a, b, c, d; uint32_t a, b, c, d;
( (void) mode );
GET_UINT32_LE( a, input, 0 ); GET_UINT32_LE( a, input, 0 );
GET_UINT32_LE( b, input, 4 ); GET_UINT32_LE( b, input, 4 );
GET_UINT32_LE( c, input, 8 ); GET_UINT32_LE( c, input, 8 );
@ -626,7 +623,7 @@ int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
while( length > 0 ) while( length > 0 )
{ {
memcpy( temp, input, MBEDTLS_ARIA_BLOCKSIZE ); memcpy( temp, input, MBEDTLS_ARIA_BLOCKSIZE );
mbedtls_aria_crypt_ecb( ctx, mode, input, output ); mbedtls_aria_crypt_ecb( ctx, input, output );
for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ ) for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ )
output[i] = (unsigned char)( output[i] ^ iv[i] ); output[i] = (unsigned char)( output[i] ^ iv[i] );
@ -645,7 +642,7 @@ int mbedtls_aria_crypt_cbc( mbedtls_aria_context *ctx,
for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ ) for( i = 0; i < MBEDTLS_ARIA_BLOCKSIZE; i++ )
output[i] = (unsigned char)( input[i] ^ iv[i] ); output[i] = (unsigned char)( input[i] ^ iv[i] );
mbedtls_aria_crypt_ecb( ctx, mode, output, output ); mbedtls_aria_crypt_ecb( ctx, output, output );
memcpy( iv, output, MBEDTLS_ARIA_BLOCKSIZE ); memcpy( iv, output, MBEDTLS_ARIA_BLOCKSIZE );
input += MBEDTLS_ARIA_BLOCKSIZE; input += MBEDTLS_ARIA_BLOCKSIZE;
@ -678,7 +675,7 @@ int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
while( length-- ) while( length-- )
{ {
if( n == 0 ) if( n == 0 )
mbedtls_aria_crypt_ecb( ctx, MBEDTLS_ARIA_ENCRYPT, iv, iv ); mbedtls_aria_crypt_ecb( ctx, iv, iv );
c = *input++; c = *input++;
*output++ = (unsigned char)( c ^ iv[n] ); *output++ = (unsigned char)( c ^ iv[n] );
@ -692,7 +689,7 @@ int mbedtls_aria_crypt_cfb128( mbedtls_aria_context *ctx,
while( length-- ) while( length-- )
{ {
if( n == 0 ) if( n == 0 )
mbedtls_aria_crypt_ecb( ctx, MBEDTLS_ARIA_ENCRYPT, iv, iv ); mbedtls_aria_crypt_ecb( ctx, iv, iv );
iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ ); iv[n] = *output++ = (unsigned char)( iv[n] ^ *input++ );
@ -724,7 +721,7 @@ int mbedtls_aria_crypt_ctr( mbedtls_aria_context *ctx,
while( length-- ) while( length-- )
{ {
if( n == 0 ) { if( n == 0 ) {
mbedtls_aria_crypt_ecb( ctx, MBEDTLS_ARIA_ENCRYPT, nonce_counter, mbedtls_aria_crypt_ecb( ctx, nonce_counter,
stream_block ); stream_block );
for( i = MBEDTLS_ARIA_BLOCKSIZE; i > 0; i-- ) for( i = MBEDTLS_ARIA_BLOCKSIZE; i > 0; i-- )
@ -916,8 +913,7 @@ int mbedtls_aria_self_test( int verbose )
if( verbose ) if( verbose )
printf( " ARIA-ECB-%d (enc): ", 128 + 64 * i ); printf( " ARIA-ECB-%d (enc): ", 128 + 64 * i );
mbedtls_aria_setkey_enc( &ctx, aria_test1_ecb_key, 128 + 64 * i ); mbedtls_aria_setkey_enc( &ctx, aria_test1_ecb_key, 128 + 64 * i );
mbedtls_aria_crypt_ecb( &ctx, MBEDTLS_ARIA_ENCRYPT, mbedtls_aria_crypt_ecb( &ctx, aria_test1_ecb_pt, blk );
aria_test1_ecb_pt, blk );
if( memcmp( blk, aria_test1_ecb_ct[i], MBEDTLS_ARIA_BLOCKSIZE ) != 0 ) if( memcmp( blk, aria_test1_ecb_ct[i], MBEDTLS_ARIA_BLOCKSIZE ) != 0 )
ARIA_SELF_TEST_IF_FAIL; ARIA_SELF_TEST_IF_FAIL;
@ -925,8 +921,7 @@ int mbedtls_aria_self_test( int verbose )
if( verbose ) if( verbose )
printf( " ARIA-ECB-%d (dec): ", 128 + 64 * i ); printf( " ARIA-ECB-%d (dec): ", 128 + 64 * i );
mbedtls_aria_setkey_dec( &ctx, aria_test1_ecb_key, 128 + 64 * i ); mbedtls_aria_setkey_dec( &ctx, aria_test1_ecb_key, 128 + 64 * i );
mbedtls_aria_crypt_ecb( &ctx, MBEDTLS_ARIA_DECRYPT, mbedtls_aria_crypt_ecb( &ctx, aria_test1_ecb_ct[i], blk );
aria_test1_ecb_ct[i], blk );
if( memcmp( blk, aria_test1_ecb_pt, MBEDTLS_ARIA_BLOCKSIZE ) != 0 ) if( memcmp( blk, aria_test1_ecb_pt, MBEDTLS_ARIA_BLOCKSIZE ) != 0 )
ARIA_SELF_TEST_IF_FAIL; ARIA_SELF_TEST_IF_FAIL;
} }

View file

@ -831,7 +831,8 @@ static const mbedtls_cipher_info_t camellia_256_ccm_info = {
static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation, static int aria_crypt_ecb_wrap( void *ctx, mbedtls_operation_t operation,
const unsigned char *input, unsigned char *output ) const unsigned char *input, unsigned char *output )
{ {
return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, operation, input, (void) operation;
return mbedtls_aria_crypt_ecb( (mbedtls_aria_context *) ctx, input,
output ); output );
} }
@ -840,7 +841,8 @@ static int aria_crypt_cbc_wrap( void *ctx, mbedtls_operation_t operation,
size_t length, unsigned char *iv, size_t length, unsigned char *iv,
const unsigned char *input, unsigned char *output ) const unsigned char *input, unsigned char *output )
{ {
return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, operation, length, iv, (void) operation;
return mbedtls_aria_crypt_cbc( (mbedtls_aria_context *) ctx, length, iv,
input, output ); input, output );
} }
#endif /* MBEDTLS_CIPHER_MODE_CBC */ #endif /* MBEDTLS_CIPHER_MODE_CBC */