mirror of
https://git.suyu.dev/suyu/mbedtls.git
synced 2026-01-07 23:18:59 +01:00
aes: xts: Rename iv to data_unit
XTS doesn't have an IV, it has a "Data Unit". Rename iv for parity with the XTS standard.
This commit is contained in:
parent
d82cd860b2
commit
cd9fc5e541
3 changed files with 14 additions and 13 deletions
|
|
@ -152,12 +152,12 @@ exit:
|
|||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
|
||||
void aes_encrypt_xts( char *hex_key_string, char *hex_iv_string,
|
||||
void aes_encrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
int data_unit_len, int xts_result )
|
||||
{
|
||||
unsigned char key_str[100] = { 0, };
|
||||
unsigned char iv_str[100] = { 0, };
|
||||
unsigned char data_unit_str[100] = { 0, };
|
||||
unsigned char src_str[100] = { 0, };
|
||||
unsigned char dst_str[100] = { 0, };
|
||||
unsigned char output[100] = { 0, };
|
||||
|
|
@ -167,13 +167,13 @@ void aes_encrypt_xts( char *hex_key_string, char *hex_iv_string,
|
|||
mbedtls_aes_xts_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
unhexify( data_unit_str, hex_data_unit_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
TEST_ASSERT( data_len == data_unit_len / 8 );
|
||||
|
||||
mbedtls_aes_xts_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, data_len, iv_str, src_str, output ) == xts_result );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_ENCRYPT, data_len, data_unit_str, src_str, output ) == xts_result );
|
||||
if( xts_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
|
|
@ -187,12 +187,12 @@ exit:
|
|||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CIPHER_MODE_XTS */
|
||||
void aes_decrypt_xts( char *hex_key_string, char *hex_iv_string,
|
||||
void aes_decrypt_xts( char *hex_key_string, char *hex_data_unit_string,
|
||||
char *hex_src_string, char *hex_dst_string,
|
||||
int data_unit_len, int xts_result )
|
||||
{
|
||||
unsigned char key_str[100] = { 0, };
|
||||
unsigned char iv_str[100] = { 0, };
|
||||
unsigned char data_unit_str[100] = { 0, };
|
||||
unsigned char src_str[100] = { 0, };
|
||||
unsigned char dst_str[100] = { 0, };
|
||||
unsigned char output[100] = { 0, };
|
||||
|
|
@ -202,13 +202,13 @@ void aes_decrypt_xts( char *hex_key_string, char *hex_iv_string,
|
|||
mbedtls_aes_xts_init( &ctx );
|
||||
|
||||
key_len = unhexify( key_str, hex_key_string );
|
||||
unhexify( iv_str, hex_iv_string );
|
||||
unhexify( data_unit_str, hex_data_unit_string );
|
||||
data_len = unhexify( src_str, hex_src_string );
|
||||
TEST_ASSERT( data_len == data_unit_len / 8 );
|
||||
|
||||
mbedtls_aes_xts_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, data_len, iv_str, src_str, output ) == xts_result );
|
||||
TEST_ASSERT( mbedtls_aes_crypt_xts( &ctx, MBEDTLS_AES_DECRYPT, data_len, data_unit_str, src_str, output ) == xts_result );
|
||||
if( xts_result == 0 )
|
||||
{
|
||||
hexify( dst_str, output, data_len );
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue