- Added test suite for XTEA

This commit is contained in:
Paul Bakker 2009-07-08 06:43:10 +00:00
parent 42a29bf7bf
commit f725a88e54
3 changed files with 99 additions and 0 deletions

View File

@ -22,3 +22,4 @@ add_test_suite(aes)
add_test_suite(camellia)
add_test_suite(des)
add_test_suite(rsa)
add_test_suite(xtea)

View File

@ -0,0 +1,38 @@
XTEA Encrypt_ecb #1
xtea_encrypt_ecb:"000102030405060708090a0b0c0d0e0f":"4142434445464748":"497df3d072612cb5"
XTEA Encrypt_ecb #2
xtea_encrypt_ecb:"000102030405060708090a0b0c0d0e0f":"4141414141414141":"e78f2d13744341d8"
XTEA Encrypt_ecb #3
xtea_encrypt_ecb:"000102030405060708090a0b0c0d0e0f":"5a5b6e278948d77f":"4141414141414141"
XTEA Encrypt_ecb #4
xtea_encrypt_ecb:"00000000000000000000000000000000":"4142434445464748":"a0390589f8b8efa5"
XTEA Encrypt_ecb #5
xtea_encrypt_ecb:"00000000000000000000000000000000":"4141414141414141":"ed23375a821a8c2d"
XTEA Encrypt_ecb #6
xtea_encrypt_ecb:"00000000000000000000000000000000":"70e1225d6e4e7655":"4141414141414141"
XTEA Decrypt_ecb #1
xtea_decrypt_ecb:"000102030405060708090a0b0c0d0e0f":"497df3d072612cb5":"4142434445464748"
XTEA Decrypt_ecb #2
xtea_decrypt_ecb:"000102030405060708090a0b0c0d0e0f":"e78f2d13744341d8":"4141414141414141"
XTEA Decrypt_ecb #3
xtea_decrypt_ecb:"000102030405060708090a0b0c0d0e0f":"4141414141414141":"5a5b6e278948d77f"
XTEA Decrypt_ecb #4
xtea_decrypt_ecb:"00000000000000000000000000000000":"a0390589f8b8efa5":"4142434445464748"
XTEA Decrypt_ecb #5
xtea_decrypt_ecb:"00000000000000000000000000000000":"ed23375a821a8c2d":"4141414141414141"
XTEA Decrypt_ecb #6
xtea_decrypt_ecb:"00000000000000000000000000000000":"4141414141414141":"70e1225d6e4e7655"
XTEA Selftest
xtea_selftest:

View File

@ -0,0 +1,60 @@
BEGIN_HEADER
#include <polarssl/xtea.h>
END_HEADER
BEGIN_CASE
xtea_encrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
{
unsigned char key_str[100];
unsigned char src_str[100];
unsigned char dst_str[100];
unsigned char output[100];
xtea_context ctx;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
xtea_setup( &ctx, key_str );
xtea_crypt_ecb( &ctx, XTEA_ENCRYPT, src_str, output );
hexify( dst_str, output, 8 );
TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
}
END_CASE
BEGIN_CASE
xtea_decrypt_ecb:hex_key_string:hex_src_string:hex_dst_string
{
unsigned char key_str[100];
unsigned char src_str[100];
unsigned char dst_str[100];
unsigned char output[100];
xtea_context ctx;
memset(key_str, 0x00, 100);
memset(src_str, 0x00, 100);
memset(dst_str, 0x00, 100);
memset(output, 0x00, 100);
unhexify( key_str, {hex_key_string} );
unhexify( src_str, {hex_src_string} );
xtea_setup( &ctx, key_str );
xtea_crypt_ecb( &ctx, XTEA_DECRYPT, src_str, output );
hexify( dst_str, output, 8 );
TEST_ASSERT( strcmp( (char *) dst_str, {hex_dst_string} ) == 0 );
}
END_CASE
BEGIN_CASE
xtea_selftest:
{
TEST_ASSERT( xtea_self_test( 0 ) == 0 );
}
END_CASE