mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-03-24 22:15:07 +00:00
Adapt new test gcm_bad_parameters() to on target testing changes
This commit is contained in:
parent
f0e42fbd1f
commit
317efe85e1
|
@ -9,41 +9,23 @@
|
||||||
|
|
||||||
/* BEGIN_CASE */
|
/* BEGIN_CASE */
|
||||||
void gcm_bad_parameters( int cipher_id, int direction,
|
void gcm_bad_parameters( int cipher_id, int direction,
|
||||||
char *hex_key_string, char *hex_src_string,
|
HexParam_t *key_str, HexParam_t *src_str,
|
||||||
char *hex_iv_string, char *hex_add_string,
|
HexParam_t *iv_str, HexParam_t *add_str,
|
||||||
int tag_len_bits, int gcm_result )
|
int tag_len_bits, int gcm_result )
|
||||||
{
|
{
|
||||||
unsigned char key_str[128];
|
|
||||||
unsigned char src_str[128];
|
|
||||||
unsigned char dst_str[257];
|
|
||||||
unsigned char iv_str[128];
|
|
||||||
unsigned char add_str[128];
|
|
||||||
unsigned char tag_str[128];
|
|
||||||
unsigned char output[128];
|
unsigned char output[128];
|
||||||
unsigned char tag_output[16];
|
unsigned char tag_output[16];
|
||||||
mbedtls_gcm_context ctx;
|
mbedtls_gcm_context ctx;
|
||||||
unsigned int key_len;
|
size_t tag_len = tag_len_bits / 8;
|
||||||
size_t pt_len, iv_len, add_len, tag_len = tag_len_bits / 8;
|
|
||||||
|
|
||||||
mbedtls_gcm_init( &ctx );
|
mbedtls_gcm_init( &ctx );
|
||||||
|
|
||||||
memset( key_str, 0x00, sizeof( key_str ) );
|
|
||||||
memset( src_str, 0x00, sizeof( src_str ) );
|
|
||||||
memset( dst_str, 0x00, sizeof( dst_str ) );
|
|
||||||
memset( iv_str, 0x00, sizeof( iv_str ) );
|
|
||||||
memset( add_str, 0x00, sizeof( add_str ) );
|
|
||||||
memset( tag_str, 0x00, sizeof( tag_str ) );
|
|
||||||
memset( output, 0x00, sizeof( output ) );
|
memset( output, 0x00, sizeof( output ) );
|
||||||
memset( tag_output, 0x00, sizeof( tag_output ) );
|
memset( tag_output, 0x00, sizeof( tag_output ) );
|
||||||
|
|
||||||
key_len = unhexify( key_str, hex_key_string );
|
TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str->x, key_str->len * 8 ) == 0 );
|
||||||
pt_len = unhexify( src_str, hex_src_string );
|
TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, src_str->len, iv_str->x, iv_str->len,
|
||||||
iv_len = unhexify( iv_str, hex_iv_string );
|
add_str->x, add_str->len, src_str->x, output, tag_len, tag_output ) == gcm_result );
|
||||||
add_len = unhexify( add_str, hex_add_string );
|
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_gcm_setkey( &ctx, cipher_id, key_str, key_len * 8 ) == 0 );
|
|
||||||
TEST_ASSERT( mbedtls_gcm_crypt_and_tag( &ctx, direction, pt_len, iv_str, iv_len,
|
|
||||||
add_str, add_len, src_str, output, tag_len, tag_output ) == gcm_result );
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_gcm_free( &ctx );
|
mbedtls_gcm_free( &ctx );
|
||||||
|
|
Loading…
Reference in a new issue