mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-02-01 23:54:01 +00:00
Use mbedtls_xor in Camellia
Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
parent
7bb6b84b29
commit
d23399eb69
@ -526,7 +526,6 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
|
|||||||
const unsigned char *input,
|
const unsigned char *input,
|
||||||
unsigned char *output )
|
unsigned char *output )
|
||||||
{
|
{
|
||||||
int i;
|
|
||||||
unsigned char temp[16];
|
unsigned char temp[16];
|
||||||
if( mode != MBEDTLS_CAMELLIA_ENCRYPT && mode != MBEDTLS_CAMELLIA_DECRYPT )
|
if( mode != MBEDTLS_CAMELLIA_ENCRYPT && mode != MBEDTLS_CAMELLIA_DECRYPT )
|
||||||
return MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_CAMELLIA_BAD_INPUT_DATA;
|
||||||
@ -541,8 +540,7 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
|
|||||||
memcpy( temp, input, 16 );
|
memcpy( temp, input, 16 );
|
||||||
mbedtls_camellia_crypt_ecb( ctx, mode, input, output );
|
mbedtls_camellia_crypt_ecb( ctx, mode, input, output );
|
||||||
|
|
||||||
for( i = 0; i < 16; i++ )
|
mbedtls_xor( output, output, iv, 16 );
|
||||||
output[i] = (unsigned char)( output[i] ^ iv[i] );
|
|
||||||
|
|
||||||
memcpy( iv, temp, 16 );
|
memcpy( iv, temp, 16 );
|
||||||
|
|
||||||
@ -555,8 +553,7 @@ int mbedtls_camellia_crypt_cbc( mbedtls_camellia_context *ctx,
|
|||||||
{
|
{
|
||||||
while( length > 0 )
|
while( length > 0 )
|
||||||
{
|
{
|
||||||
for( i = 0; i < 16; i++ )
|
mbedtls_xor( output, input, iv, 16 );
|
||||||
output[i] = (unsigned char)( input[i] ^ iv[i] );
|
|
||||||
|
|
||||||
mbedtls_camellia_crypt_ecb( ctx, mode, output, output );
|
mbedtls_camellia_crypt_ecb( ctx, mode, output, output );
|
||||||
memcpy( iv, output, 16 );
|
memcpy( iv, output, 16 );
|
||||||
|
Loading…
x
Reference in New Issue
Block a user