diff --git a/library/camellia.c b/library/camellia.c index 5dd6c5615..6e781c72b 100644 --- a/library/camellia.c +++ b/library/camellia.c @@ -526,7 +526,6 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, const unsigned char *input, unsigned char *output ) { - int i; unsigned char temp[16]; if( mode != MBEDTLS_CAMELLIA_ENCRYPT && mode != MBEDTLS_CAMELLIA_DECRYPT ) return MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA; @@ -541,8 +540,7 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, memcpy( temp, input, 16 ); mbedtls_camellia_crypt_ecb( ctx, mode, input, output ); - for( i = 0; i < 16; i++ ) - output[i] = (unsigned char)( output[i] ^ iv[i] ); + mbedtls_xor( output, output, iv, 16 ); memcpy( iv, temp, 16 ); @@ -555,8 +553,7 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx, { while( length > 0 ) { - for( i = 0; i < 16; i++ ) - output[i] = (unsigned char)( input[i] ^ iv[i] ); + mbedtls_xor( output, input, iv, 16 ); mbedtls_camellia_crypt_ecb( ctx, mode, output, output ); memcpy( iv, output, 16 );