mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 03:25:38 +01:00
- Added additional cases for MPI, MDx
- Added test case set for Camellia, DES and 3-DES
This commit is contained in:
parent
f3eedce885
commit
e896feafbe
@ -19,3 +19,5 @@ add_test_suite(mdx)
|
||||
add_test_suite(shax)
|
||||
add_test_suite(hmac_shax)
|
||||
add_test_suite(aes)
|
||||
add_test_suite(camellia)
|
||||
add_test_suite(des)
|
||||
|
1
tests/data_files/mpi_10
Normal file
1
tests/data_files/mpi_10
Normal file
@ -0,0 +1 @@
|
||||
643808006803554439230129854961492699151386107534013432918073439524138264842370630061369715394739134090922937332590384720397133335969549256322620979036686633213903952966175107096769180017646161851573147596390153
|
164
tests/suites/test_suite_camellia.data
Normal file
164
tests/suites/test_suite_camellia.data
Normal file
@ -0,0 +1,164 @@
|
||||
Camellia-128-ECB Encrypt RFC3713 #1
|
||||
camellia_encrypt_ecb:"0123456789abcdeffedcba9876543210":"0123456789abcdeffedcba9876543210":"67673138549669730857065648eabe43"
|
||||
|
||||
Camellia-192-ECB Encrypt RFC3713 #1
|
||||
camellia_encrypt_ecb:"0123456789abcdeffedcba98765432100011223344556677":"0123456789abcdeffedcba9876543210":"b4993401b3e996f84ee5cee7d79b09b9"
|
||||
|
||||
Camellia-256-ECB Encrypt RFC3713 #1
|
||||
camellia_encrypt_ecb:"0123456789abcdeffedcba987654321000112233445566778899aabbccddeeff":"0123456789abcdeffedcba9876543210":"9acc237dff16d76c20ef7c919e3a7509"
|
||||
|
||||
Camellia-128-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"000102030405060708090A0B0C0D0E0F":"00112233445566778899AABBCCDDEEFF":"77CF412067AF8270613529149919546F"
|
||||
|
||||
Camellia-192-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"000102030405060708090A0B0C0D0E0F1011121314151617":"00112233445566778899AABBCCDDEEFF":"B22F3C36B72D31329EEE8ADDC2906C68"
|
||||
|
||||
Camellia-256-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"000102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F":"00112233445566778899AABBCCDDEEFF":"2EDF1F3418D53B88841FC8985FB1ECF2"
|
||||
|
||||
Camellia-128-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"2B7E151628AED2A6ABF7158809CF4F3C":"6BC1BEE22E409F96E93D7E117393172A":"432FC5DCD628115B7C388D770B270C96"
|
||||
|
||||
Camellia-128-ECB Encrypt Perl EVP #2
|
||||
camellia_encrypt_ecb:"2B7E151628AED2A6ABF7158809CF4F3C":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"0BE1F14023782A22E8384C5ABB7FAB2B"
|
||||
|
||||
Camellia-128-ECB Encrypt Perl EVP #3
|
||||
camellia_encrypt_ecb:"2B7E151628AED2A6ABF7158809CF4F3C":"30C81C46A35CE411E5FBC1191A0A52EF":"A0A1ABCD1893AB6FE0FE5B65DF5F8636"
|
||||
|
||||
Camellia-128-ECB Encrypt Perl EVP #4
|
||||
camellia_encrypt_ecb:"2B7E151628AED2A6ABF7158809CF4F3C":"F69F2445DF4F9B17AD2B417BE66C3710":"E61925E0D5DFAA9BB29F815B3076E51A"
|
||||
|
||||
Camellia-192-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"6BC1BEE22E409F96E93D7E117393172A":"CCCC6C4E138B45848514D48D0D3439D3"
|
||||
|
||||
Camellia-192-ECB Encrypt Perl EVP #2
|
||||
camellia_encrypt_ecb:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"5713C62C14B2EC0F8393B6AFD6F5785A"
|
||||
|
||||
Camellia-192-ECB Encrypt Perl EVP #3
|
||||
camellia_encrypt_ecb:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"30C81C46A35CE411E5FBC1191A0A52EF":"B40ED2B60EB54D09D030CF511FEEF366"
|
||||
|
||||
Camellia-192-ECB Encrypt Perl EVP #4
|
||||
camellia_encrypt_ecb:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"F69F2445DF4F9B17AD2B417BE66C3710":"909DBD95799096748CB27357E73E1D26"
|
||||
|
||||
Camellia-256-ECB Encrypt Perl EVP #1
|
||||
camellia_encrypt_ecb:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"6BC1BEE22E409F96E93D7E117393172A":"BEFD219B112FA00098919CD101C9CCFA"
|
||||
|
||||
Camellia-256-ECB Encrypt Perl EVP #2
|
||||
camellia_encrypt_ecb:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"C91D3A8F1AEA08A9386CF4B66C0169EA"
|
||||
|
||||
Camellia-256-ECB Encrypt Perl EVP #3
|
||||
camellia_encrypt_ecb:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"30C81C46A35CE411E5FBC1191A0A52EF":"A623D711DC5F25A51BB8A80D56397D28"
|
||||
|
||||
Camellia-256-ECB Encrypt Perl EVP #4
|
||||
camellia_encrypt_ecb:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"F69F2445DF4F9B17AD2B417BE66C3710":"7960109FB6DC42947FCFE59EA3C5EB6B"
|
||||
|
||||
Camellia-128-CBC Encrypt Perl EVP #1
|
||||
camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"1607CF494B36BBF00DAEB0B503C831AB"
|
||||
|
||||
Camellia-128-CBC Encrypt Perl EVP #2
|
||||
camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"1607CF494B36BBF00DAEB0B503C831AB":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"A2F2CF671629EF7840C5A5DFB5074887"
|
||||
|
||||
Camellia-128-CBC Encrypt Perl EVP #3
|
||||
camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"A2F2CF671629EF7840C5A5DFB5074887":"30C81C46A35CE411E5FBC1191A0A52EF":"0F06165008CF8B8B5A63586362543E54"
|
||||
|
||||
Camellia-128-CBC Encrypt Perl EVP #4
|
||||
camellia_encrypt_cbc:"2B7E151628AED2A6ABF7158809CF4F3C":"36A84CDAFD5F9A85ADA0F0A993D6D577":"F69F2445DF4F9B17AD2B417BE66C3710":"74C64268CDB8B8FAF5B34E8AF3732980"
|
||||
|
||||
Camellia-192-CBC Encrypt Perl EVP #1
|
||||
camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"2A4830AB5AC4A1A2405955FD2195CF93"
|
||||
|
||||
Camellia-192-CBC Encrypt Perl EVP #2
|
||||
camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"2A4830AB5AC4A1A2405955FD2195CF93":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"5D5A869BD14CE54264F892A6DD2EC3D5"
|
||||
|
||||
Camellia-192-CBC Encrypt Perl EVP #3
|
||||
camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"5D5A869BD14CE54264F892A6DD2EC3D5":"30C81C46A35CE411E5FBC1191A0A52EF":"37D359C3349836D884E310ADDF68C449"
|
||||
|
||||
Camellia-192-CBC Encrypt Perl EVP #4
|
||||
camellia_encrypt_cbc:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"37D359C3349836D884E310ADDF68C449":"F69F2445DF4F9B17AD2B417BE66C3710":"01FAAA930B4AB9916E9668E1428C6B08"
|
||||
|
||||
Camellia-256-CBC Encrypt Perl EVP #1
|
||||
camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"E6CFA35FC02B134A4D2C0B6737AC3EDA"
|
||||
|
||||
Camellia-256-CBC Encrypt Perl EVP #2
|
||||
camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E6CFA35FC02B134A4D2C0B6737AC3EDA":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"36CBEB73BD504B4070B1B7DE2B21EB50"
|
||||
|
||||
Camellia-256-CBC Encrypt Perl EVP #3
|
||||
camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"36CBEB73BD504B4070B1B7DE2B21EB50":"30C81C46A35CE411E5FBC1191A0A52EF":"E31A6055297D96CA3330CDF1B1860A83"
|
||||
|
||||
Camellia-256-CBC Encrypt Perl EVP #4
|
||||
camellia_encrypt_cbc:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"E31A6055297D96CA3330CDF1B1860A83":"F69F2445DF4F9B17AD2B417BE66C3710":"5D563F6D1CCCF236051C0C5C1C58F28F"
|
||||
|
||||
Camellia-128-CFB128 Encrypt Perl EVP #1
|
||||
camellia_encrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"14F7646187817EB586599146B82BD719"
|
||||
|
||||
Camellia-128-CFB128 Encrypt Perl EVP #2
|
||||
camellia_encrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"14F7646187817EB586599146B82BD719":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"A53D28BB82DF741103EA4F921A44880B"
|
||||
|
||||
Camellia-128-CFB128 Encrypt Perl EVP #3
|
||||
camellia_encrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"A53D28BB82DF741103EA4F921A44880B":"30C81C46A35CE411E5FBC1191A0A52EF":"9C2157A664626D1DEF9EA420FDE69B96"
|
||||
|
||||
Camellia-128-CFB128 Encrypt Perl EVP #4
|
||||
camellia_encrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"9C2157A664626D1DEF9EA420FDE69B96":"F69F2445DF4F9B17AD2B417BE66C3710":"742A25F0542340C7BAEF24CA8482BB09"
|
||||
|
||||
Camellia-128-CFB128 Decrypt Perl EVP #1
|
||||
camellia_decrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"14F7646187817EB586599146B82BD719"
|
||||
|
||||
Camellia-128-CFB128 Decrypt Perl EVP #2
|
||||
camellia_decrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"14F7646187817EB586599146B82BD719":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"A53D28BB82DF741103EA4F921A44880B"
|
||||
|
||||
Camellia-128-CFB128 Decrypt Perl EVP #3
|
||||
camellia_decrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"A53D28BB82DF741103EA4F921A44880B":"30C81C46A35CE411E5FBC1191A0A52EF":"9C2157A664626D1DEF9EA420FDE69B96"
|
||||
|
||||
Camellia-128-CFB128 Decrypt Perl EVP #4
|
||||
camellia_decrypt_cfb128:"2B7E151628AED2A6ABF7158809CF4F3C":"9C2157A664626D1DEF9EA420FDE69B96":"F69F2445DF4F9B17AD2B417BE66C3710":"742A25F0542340C7BAEF24CA8482BB09"
|
||||
|
||||
Camellia-192-CFB128 Encrypt Perl EVP #1
|
||||
camellia_encrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"C832BB9780677DAA82D9B6860DCD565E"
|
||||
|
||||
Camellia-192-CFB128 Encrypt Perl EVP #2
|
||||
camellia_encrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"C832BB9780677DAA82D9B6860DCD565E":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"86F8491627906D780C7A6D46EA331F98"
|
||||
|
||||
Camellia-192-CFB128 Encrypt Perl EVP #3
|
||||
camellia_encrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"86F8491627906D780C7A6D46EA331F98":"30C81C46A35CE411E5FBC1191A0A52EF":"69511CCE594CF710CB98BB63D7221F01"
|
||||
|
||||
Camellia-192-CFB128 Encrypt Perl EVP #4
|
||||
camellia_encrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"69511CCE594CF710CB98BB63D7221F01":"F69F2445DF4F9B17AD2B417BE66C3710":"D5B5378A3ABED55803F25565D8907B84"
|
||||
|
||||
Camellia-192-CFB128 Decrypt Perl EVP #1
|
||||
camellia_decrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"C832BB9780677DAA82D9B6860DCD565E"
|
||||
|
||||
Camellia-192-CFB128 Decrypt Perl EVP #2
|
||||
camellia_decrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"C832BB9780677DAA82D9B6860DCD565E":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"86F8491627906D780C7A6D46EA331F98"
|
||||
|
||||
Camellia-192-CFB128 Decrypt Perl EVP #3
|
||||
camellia_decrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"86F8491627906D780C7A6D46EA331F98":"30C81C46A35CE411E5FBC1191A0A52EF":"69511CCE594CF710CB98BB63D7221F01"
|
||||
|
||||
Camellia-192-CFB128 Decrypt Perl EVP #4
|
||||
camellia_decrypt_cfb128:"8E73B0F7DA0E6452C810F32B809079E562F8EAD2522C6B7B":"69511CCE594CF710CB98BB63D7221F01":"F69F2445DF4F9B17AD2B417BE66C3710":"D5B5378A3ABED55803F25565D8907B84"
|
||||
|
||||
Camellia-256-CFB128 Encrypt Perl EVP #1
|
||||
camellia_encrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"CF6107BB0CEA7D7FB1BD31F5E7B06C93"
|
||||
|
||||
Camellia-256-CFB128 Encrypt Perl EVP #2
|
||||
camellia_encrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"CF6107BB0CEA7D7FB1BD31F5E7B06C93":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"89BEDB4CCDD864EA11BA4CBE849B5E2B"
|
||||
|
||||
Camellia-256-CFB128 Encrypt Perl EVP #3
|
||||
camellia_encrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"89BEDB4CCDD864EA11BA4CBE849B5E2B":"30C81C46A35CE411E5FBC1191A0A52EF":"555FC3F34BDD2D54C62D9E3BF338C1C4"
|
||||
|
||||
Camellia-256-CFB128 Encrypt Perl EVP #4
|
||||
camellia_encrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"555FC3F34BDD2D54C62D9E3BF338C1C4":"F69F2445DF4F9B17AD2B417BE66C3710":"5953ADCE14DB8C7F39F1BD39F359BFFA"
|
||||
|
||||
Camellia-256-CFB128 Decrypt Perl EVP #1
|
||||
camellia_decrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"000102030405060708090A0B0C0D0E0F":"6BC1BEE22E409F96E93D7E117393172A":"CF6107BB0CEA7D7FB1BD31F5E7B06C93"
|
||||
|
||||
Camellia-256-CFB128 Decrypt Perl EVP #2
|
||||
camellia_decrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"CF6107BB0CEA7D7FB1BD31F5E7B06C93":"AE2D8A571E03AC9C9EB76FAC45AF8E51":"89BEDB4CCDD864EA11BA4CBE849B5E2B"
|
||||
|
||||
Camellia-256-CFB128 Decrypt Perl EVP #3
|
||||
camellia_decrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"89BEDB4CCDD864EA11BA4CBE849B5E2B":"30C81C46A35CE411E5FBC1191A0A52EF":"555FC3F34BDD2D54C62D9E3BF338C1C4"
|
||||
|
||||
Camellia-256-CFB128 Decrypt Perl EVP #4
|
||||
camellia_decrypt_cfb128:"603DEB1015CA71BE2B73AEF0857D77811F352C073B6108D72D9810A30914DFF4":"555FC3F34BDD2D54C62D9E3BF338C1C4":"F69F2445DF4F9B17AD2B417BE66C3710":"5953ADCE14DB8C7F39F1BD39F359BFFA"
|
||||
|
||||
Camellia Selftest
|
||||
camellia_selftest:
|
174
tests/suites/test_suite_camellia.function
Normal file
174
tests/suites/test_suite_camellia.function
Normal file
@ -0,0 +1,174 @@
|
||||
BEGIN_HEADER
|
||||
#include <polarssl/camellia.h>
|
||||
END_HEADER
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_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];
|
||||
camellia_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_ecb( &ctx, CAMELLIA_ENCRYPT, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_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];
|
||||
camellia_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_ecb( &ctx, CAMELLIA_DECRYPT, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
camellia_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_cbc( &ctx, CAMELLIA_ENCRYPT, 16, iv_str, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
camellia_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_dec( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_cbc( &ctx, CAMELLIA_DECRYPT, 16, iv_str, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_encrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
camellia_context ctx;
|
||||
int iv_offset = 0;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_cfb128( &ctx, CAMELLIA_ENCRYPT, 16, &iv_offset, iv_str, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_decrypt_cfb128:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
camellia_context ctx;
|
||||
int iv_offset = 0;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
unhexify( src_str, {hex_src_string} );
|
||||
|
||||
camellia_setkey_enc( &ctx, key_str, key_len * 8 );
|
||||
camellia_crypt_cfb128( &ctx, CAMELLIA_DECRYPT, 16, &iv_offset, iv_str, src_str, output );
|
||||
hexify( dst_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
camellia_selftest:
|
||||
{
|
||||
TEST_ASSERT( camellia_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
230
tests/suites/test_suite_des.data
Normal file
230
tests/suites/test_suite_des.data
Normal file
@ -0,0 +1,230 @@
|
||||
DES Encrypt OpenSSL Test Vector #1
|
||||
des_encrypt_ecb:"0000000000000000":"0000000000000000":"8CA64DE9C1B123A7"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #2
|
||||
des_encrypt_ecb:"FFFFFFFFFFFFFFFF":"FFFFFFFFFFFFFFFF":"7359B2163E4EDC58"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #3
|
||||
des_encrypt_ecb:"3000000000000000":"1000000000000001":"958E6E627A05557B"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #4
|
||||
des_encrypt_ecb:"1111111111111111":"1111111111111111":"F40379AB9E0EC533"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #5
|
||||
des_encrypt_ecb:"0123456789ABCDEF":"1111111111111111":"17668DFC7292532D"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #6
|
||||
des_encrypt_ecb:"1111111111111111":"0123456789ABCDEF":"8A5AE1F81AB8F2DD"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #7
|
||||
des_encrypt_ecb:"0000000000000000":"0000000000000000":"8CA64DE9C1B123A7"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #8
|
||||
des_encrypt_ecb:"FEDCBA9876543210":"0123456789ABCDEF":"ED39D950FA74BCC4"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #9
|
||||
des_encrypt_ecb:"7CA110454A1A6E57":"01A1D6D039776742":"690F5B0D9A26939B"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #10
|
||||
des_encrypt_ecb:"0131D9619DC1376E":"5CD54CA83DEF57DA":"7A389D10354BD271"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #11
|
||||
des_encrypt_ecb:"07A1133E4A0B2686":"0248D43806F67172":"868EBB51CAB4599A"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #12
|
||||
des_encrypt_ecb:"3849674C2602319E":"51454B582DDF440A":"7178876E01F19B2A"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #13
|
||||
des_encrypt_ecb:"04B915BA43FEB5B6":"42FD443059577FA2":"AF37FB421F8C4095"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #14
|
||||
des_encrypt_ecb:"0113B970FD34F2CE":"059B5E0851CF143A":"86A560F10EC6D85B"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #15
|
||||
des_encrypt_ecb:"0170F175468FB5E6":"0756D8E0774761D2":"0CD3DA020021DC09"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #16
|
||||
des_encrypt_ecb:"43297FAD38E373FE":"762514B829BF486A":"EA676B2CB7DB2B7A"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #17
|
||||
des_encrypt_ecb:"07A7137045DA2A16":"3BDD119049372802":"DFD64A815CAF1A0F"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #18
|
||||
des_encrypt_ecb:"04689104C2FD3B2F":"26955F6835AF609A":"5C513C9C4886C088"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #19
|
||||
des_encrypt_ecb:"37D06BB516CB7546":"164D5E404F275232":"0A2AEEAE3FF4AB77"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #20
|
||||
des_encrypt_ecb:"1F08260D1AC2465E":"6B056E18759F5CCA":"EF1BF03E5DFA575A"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #21
|
||||
des_encrypt_ecb:"584023641ABA6176":"004BD6EF09176062":"88BF0DB6D70DEE56"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #22
|
||||
des_encrypt_ecb:"025816164629B007":"480D39006EE762F2":"A1F9915541020B56"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #23
|
||||
des_encrypt_ecb:"49793EBC79B3258F":"437540C8698F3CFA":"6FBF1CAFCFFD0556"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #24
|
||||
des_encrypt_ecb:"4FB05E1515AB73A7":"072D43A077075292":"2F22E49BAB7CA1AC"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #25
|
||||
des_encrypt_ecb:"49E95D6D4CA229BF":"02FE55778117F12A":"5A6B612CC26CCE4A"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #26
|
||||
des_encrypt_ecb:"018310DC409B26D6":"1D9D5C5018F728C2":"5F4C038ED12B2E41"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #27
|
||||
des_encrypt_ecb:"1C587F1C13924FEF":"305532286D6F295A":"63FAC0D034D9F793"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #28
|
||||
des_encrypt_ecb:"0101010101010101":"0123456789ABCDEF":"617B3A0CE8F07100"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #29
|
||||
des_encrypt_ecb:"1F1F1F1F0E0E0E0E":"0123456789ABCDEF":"DB958605F8C8C606"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #30
|
||||
des_encrypt_ecb:"E0FEE0FEF1FEF1FE":"0123456789ABCDEF":"EDBFD1C66C29CCC7"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #31
|
||||
des_encrypt_ecb:"0000000000000000":"FFFFFFFFFFFFFFFF":"355550B2150E2451"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #32
|
||||
des_encrypt_ecb:"FFFFFFFFFFFFFFFF":"0000000000000000":"CAAAAF4DEAF1DBAE"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #33
|
||||
des_encrypt_ecb:"0123456789ABCDEF":"0000000000000000":"D5D44FF720683D0D"
|
||||
|
||||
DES Encrypt OpenSSL Test Vector #34
|
||||
des_encrypt_ecb:"FEDCBA9876543210":"FFFFFFFFFFFFFFFF":"2A2BB008DF97C2F2"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #1
|
||||
des_decrypt_ecb:"0000000000000000":"8CA64DE9C1B123A7":"0000000000000000"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #2
|
||||
des_decrypt_ecb:"FFFFFFFFFFFFFFFF":"7359B2163E4EDC58":"FFFFFFFFFFFFFFFF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #3
|
||||
des_decrypt_ecb:"3000000000000000":"958E6E627A05557B":"1000000000000001"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #4
|
||||
des_decrypt_ecb:"1111111111111111":"F40379AB9E0EC533":"1111111111111111"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #5
|
||||
des_decrypt_ecb:"0123456789ABCDEF":"17668DFC7292532D":"1111111111111111"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #6
|
||||
des_decrypt_ecb:"1111111111111111":"8A5AE1F81AB8F2DD":"0123456789ABCDEF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #7
|
||||
des_decrypt_ecb:"0000000000000000":"8CA64DE9C1B123A7":"0000000000000000"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #8
|
||||
des_decrypt_ecb:"FEDCBA9876543210":"ED39D950FA74BCC4":"0123456789ABCDEF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #9
|
||||
des_decrypt_ecb:"7CA110454A1A6E57":"690F5B0D9A26939B":"01A1D6D039776742"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #10
|
||||
des_decrypt_ecb:"0131D9619DC1376E":"7A389D10354BD271":"5CD54CA83DEF57DA"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #11
|
||||
des_decrypt_ecb:"07A1133E4A0B2686":"868EBB51CAB4599A":"0248D43806F67172"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #12
|
||||
des_decrypt_ecb:"3849674C2602319E":"7178876E01F19B2A":"51454B582DDF440A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #13
|
||||
des_decrypt_ecb:"04B915BA43FEB5B6":"AF37FB421F8C4095":"42FD443059577FA2"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #14
|
||||
des_decrypt_ecb:"0113B970FD34F2CE":"86A560F10EC6D85B":"059B5E0851CF143A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #15
|
||||
des_decrypt_ecb:"0170F175468FB5E6":"0CD3DA020021DC09":"0756D8E0774761D2"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #16
|
||||
des_decrypt_ecb:"43297FAD38E373FE":"EA676B2CB7DB2B7A":"762514B829BF486A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #17
|
||||
des_decrypt_ecb:"07A7137045DA2A16":"DFD64A815CAF1A0F":"3BDD119049372802"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #18
|
||||
des_decrypt_ecb:"04689104C2FD3B2F":"5C513C9C4886C088":"26955F6835AF609A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #19
|
||||
des_decrypt_ecb:"37D06BB516CB7546":"0A2AEEAE3FF4AB77":"164D5E404F275232"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #20
|
||||
des_decrypt_ecb:"1F08260D1AC2465E":"EF1BF03E5DFA575A":"6B056E18759F5CCA"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #21
|
||||
des_decrypt_ecb:"584023641ABA6176":"88BF0DB6D70DEE56":"004BD6EF09176062"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #22
|
||||
des_decrypt_ecb:"025816164629B007":"A1F9915541020B56":"480D39006EE762F2"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #23
|
||||
des_decrypt_ecb:"49793EBC79B3258F":"6FBF1CAFCFFD0556":"437540C8698F3CFA"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #24
|
||||
des_decrypt_ecb:"4FB05E1515AB73A7":"2F22E49BAB7CA1AC":"072D43A077075292"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #25
|
||||
des_decrypt_ecb:"49E95D6D4CA229BF":"5A6B612CC26CCE4A":"02FE55778117F12A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #26
|
||||
des_decrypt_ecb:"018310DC409B26D6":"5F4C038ED12B2E41":"1D9D5C5018F728C2"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #27
|
||||
des_decrypt_ecb:"1C587F1C13924FEF":"63FAC0D034D9F793":"305532286D6F295A"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #28
|
||||
des_decrypt_ecb:"0101010101010101":"617B3A0CE8F07100":"0123456789ABCDEF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #29
|
||||
des_decrypt_ecb:"1F1F1F1F0E0E0E0E":"DB958605F8C8C606":"0123456789ABCDEF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #30
|
||||
des_decrypt_ecb:"E0FEE0FEF1FEF1FE":"EDBFD1C66C29CCC7":"0123456789ABCDEF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #31
|
||||
des_decrypt_ecb:"0000000000000000":"355550B2150E2451":"FFFFFFFFFFFFFFFF"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #32
|
||||
des_decrypt_ecb:"FFFFFFFFFFFFFFFF":"CAAAAF4DEAF1DBAE":"0000000000000000"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #33
|
||||
des_decrypt_ecb:"0123456789ABCDEF":"D5D44FF720683D0D":"0000000000000000"
|
||||
|
||||
DES Decrypt OpenSSL Test Vector #34
|
||||
des_decrypt_ecb:"FEDCBA9876543210":"2A2BB008DF97C2F2":"FFFFFFFFFFFFFFFF"
|
||||
|
||||
DES-CBC Encrypt OpenSSL Test Vector #1
|
||||
des_encrypt_cbc:"0123456789abcdef":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68"
|
||||
|
||||
DES-CBC Decrypt OpenSSL Test Vector #1
|
||||
des_decrypt_cbc:"0123456789abcdef":"fedcba9876543210":"ccd173ffab2039f4acd8aefddfd8a1eb468e91157888ba68":"37363534333231204E6F77206973207468652074696D6520"
|
||||
|
||||
3DES-ECB 2Key Encrypt OpenSSL Test Vector #1
|
||||
des3_encrypt_ecb:2:"0000000000000000FFFFFFFFFFFFFFFF":"0000000000000000":"9295B59BB384736E"
|
||||
|
||||
3DES-ECB 2Key Encrypt OpenSSL Test Vector #2
|
||||
des3_encrypt_ecb:2:"FFFFFFFFFFFFFFFF3000000000000000":"FFFFFFFFFFFFFFFF":"199E9D6DF39AA816"
|
||||
|
||||
3DES-ECB 2Key Decrypt OpenSSL Test Vector #1
|
||||
des3_decrypt_ecb:2:"0000000000000000FFFFFFFFFFFFFFFF":"9295B59BB384736E":"0000000000000000"
|
||||
|
||||
3DES-ECB 2Key Decrypt OpenSSL Test Vector #2
|
||||
des3_decrypt_ecb:2:"FFFFFFFFFFFFFFFF3000000000000000":"199E9D6DF39AA816":"FFFFFFFFFFFFFFFF"
|
||||
|
||||
3DES-CBC 3Key Encrypt OpenSSL Test Vector #1
|
||||
des3_encrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"37363534333231204E6F77206973207468652074696D6520":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4"
|
||||
|
||||
3DES-CBC 3Key Decrypt OpenSSL Test Vector #1
|
||||
des3_decrypt_cbc:3:"0123456789abcdeff1e0d3c2b5a49786fedcba9876543210":"fedcba9876543210":"3FE301C962AC01D02213763C1CBD4CDC799657C064ECF5D4":"37363534333231204E6F77206973207468652074696D6520"
|
||||
|
||||
DES Selftest
|
||||
des_selftest:
|
246
tests/suites/test_suite_des.function
Normal file
246
tests/suites/test_suite_des.function
Normal file
@ -0,0 +1,246 @@
|
||||
BEGIN_HEADER
|
||||
#include <polarssl/des.h>
|
||||
END_HEADER
|
||||
|
||||
BEGIN_CASE
|
||||
des_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];
|
||||
des_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} );
|
||||
|
||||
des_setkey_enc( &ctx, key_str );
|
||||
des_crypt_ecb( &ctx, src_str, output );
|
||||
hexify( dst_str, output, 8 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des_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];
|
||||
des_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} );
|
||||
|
||||
des_setkey_dec( &ctx, key_str );
|
||||
des_crypt_ecb( &ctx, src_str, output );
|
||||
hexify( dst_str, output, 8 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des_encrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
des_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
des_setkey_enc( &ctx, key_str );
|
||||
des_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output );
|
||||
hexify( dst_str, output, src_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des_decrypt_cbc:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
des_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
des_setkey_dec( &ctx, key_str );
|
||||
des_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output );
|
||||
hexify( dst_str, output, src_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des3_encrypt_ecb:key_count: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];
|
||||
des3_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} );
|
||||
|
||||
if( {key_count} == 2 )
|
||||
des3_set2key_enc( &ctx, key_str );
|
||||
else if( {key_count} == 3 )
|
||||
des3_set3key_enc( &ctx, key_str );
|
||||
else
|
||||
TEST_ASSERT( 0 );
|
||||
|
||||
des3_crypt_ecb( &ctx, src_str, output );
|
||||
hexify( dst_str, output, 8 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des3_decrypt_ecb:key_count: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];
|
||||
des3_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} );
|
||||
|
||||
if( {key_count} == 2 )
|
||||
des3_set2key_dec( &ctx, key_str );
|
||||
else if( {key_count} == 3 )
|
||||
des3_set3key_dec( &ctx, key_str );
|
||||
else
|
||||
TEST_ASSERT( 0 );
|
||||
|
||||
des3_crypt_ecb( &ctx, src_str, output );
|
||||
hexify( dst_str, output, 8 );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des3_encrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
des3_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
if( {key_count} == 2 )
|
||||
des3_set2key_enc( &ctx, key_str );
|
||||
else if( {key_count} == 3 )
|
||||
des3_set3key_enc( &ctx, key_str );
|
||||
else
|
||||
TEST_ASSERT( 0 );
|
||||
|
||||
des3_crypt_cbc( &ctx, DES_ENCRYPT, src_len, iv_str, src_str, output );
|
||||
hexify( dst_str, output, src_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des3_decrypt_cbc:key_count:hex_key_string:hex_iv_string:hex_src_string:hex_dst_string
|
||||
{
|
||||
unsigned char key_str[100];
|
||||
unsigned char iv_str[100];
|
||||
unsigned char src_str[100];
|
||||
unsigned char dst_str[100];
|
||||
unsigned char output[100];
|
||||
des3_context ctx;
|
||||
|
||||
memset(key_str, 0x00, 100);
|
||||
memset(iv_str, 0x00, 100);
|
||||
memset(src_str, 0x00, 100);
|
||||
memset(dst_str, 0x00, 100);
|
||||
memset(output, 0x00, 100);
|
||||
|
||||
unhexify( key_str, {hex_key_string} );
|
||||
unhexify( iv_str, {hex_iv_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
if( {key_count} == 2 )
|
||||
des3_set2key_dec( &ctx, key_str );
|
||||
else if( {key_count} == 3 )
|
||||
des3_set3key_dec( &ctx, key_str );
|
||||
else
|
||||
TEST_ASSERT( 0 );
|
||||
|
||||
des3_crypt_cbc( &ctx, DES_DECRYPT, src_len, iv_str, src_str, output );
|
||||
hexify( dst_str, output, src_len );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) dst_str, {hex_dst_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
des_selftest:
|
||||
{
|
||||
TEST_ASSERT( des_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
@ -60,3 +60,87 @@ md5_text:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789":"d174a
|
||||
|
||||
md5 Test vector RFC1321 #7
|
||||
md5_text:"12345678901234567890123456789012345678901234567890123456789012345678901234567890":"57edf4a22be3c955ac49da2e2107b67a"
|
||||
|
||||
HMAC-MD2 Hash File OpenSSL test #1
|
||||
md2_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"d5732582f494f5ddf35efd166c85af9c"
|
||||
|
||||
HMAC-MD2 Hash File OpenSSL test #2
|
||||
md2_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"54ab68503f7d1b5c7741340dff2722a9"
|
||||
|
||||
HMAC-MD4 Hash File OpenSSL test #1
|
||||
md4_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"eabd0fbefb82fb0063a25a6d7b8bdc0f"
|
||||
|
||||
HMAC-MD4 Hash File OpenSSL test #2
|
||||
md4_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"cec3c5e421a7b783aa89cacf78daf6dc"
|
||||
|
||||
HMAC-MD5 Hash File OpenSSL test #1
|
||||
md5_hmac:16:"61616161616161616161616161616161":"b91ce5ac77d33c234e61002ed6":"42552882f00bd4633ea81135a184b284"
|
||||
|
||||
HMAC-MD5 Hash File OpenSSL test #2
|
||||
md5_hmac:16:"61616161616161616161616161616161":"270fcf11f27c27448457d7049a7edb084a3e554e0b2acf5806982213f0ad516402e4c869c4ff2171e18e3489baa3125d2c3056ebb616296f9b6aa97ef68eeabcdc0b6dde47775004096a241efcf0a90d19b34e898cc7340cdc940f8bdd46e23e352f34bca131d4d67a7c2ddb8d0d68b67f06152a128168e1c341c37e0a66c5018999b7059bcc300beed2c19dd1152d2fe062853293b8f3c8b5":"a16a842891786d01fe50ba7731db7464"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #1
|
||||
md5_hmac:16:"0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b":"4869205468657265":"9294727a3638bb1c13f48ef8158bfc9d"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #2
|
||||
md5_hmac:16:"4a656665":"7768617420646f2079612077616e7420666f72206e6f7468696e673f":"750c783e6ab0b503eaa86e310a5db738"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #3
|
||||
md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd":"56be34521d144c88dbb8c733f0e8b3f6"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #4
|
||||
md5_hmac:16:"0102030405060708090a0b0c0d0e0f10111213141516171819":"cdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcdcd":"697eaf0aca3a3aea3a75164746ffaa79"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #5
|
||||
md5_hmac:12:"0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c":"546573742057697468205472756e636174696f6e":"56461ef2342edc00f9bab995"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #6
|
||||
md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b6579202d2048617368204b6579204669727374":"6b1ab7fe4bd7bf8f0b62e6ce61b9d0cd"
|
||||
|
||||
HMAC-MD5 Test Vector RFC2202 #7
|
||||
md5_hmac:16:"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa":"54657374205573696e67204c6172676572205468616e20426c6f636b2d53697a65204b657920616e64204c6172676572205468616e204f6e6520426c6f636b2d53697a652044617461":"6f630fad67cda0ee1fb1f562db3aa53e"
|
||||
|
||||
MD2 Hash file #1
|
||||
md2_file:"data_files/hash_file_1":"b593c098712d2e21628c8986695451a8"
|
||||
|
||||
MD2 Hash file #2
|
||||
md2_file:"data_files/hash_file_2":"3c027b7409909a4c4b26bbab69ad9f4f"
|
||||
|
||||
MD2 Hash file #3
|
||||
md2_file:"data_files/hash_file_3":"6bb43eb285e81f414083a94cdbe2989d"
|
||||
|
||||
MD2 Hash file #4
|
||||
md2_file:"data_files/hash_file_4":"8350e5a3e24c153df2275c9f80692773"
|
||||
|
||||
MD4 Hash file #1
|
||||
md4_file:"data_files/hash_file_1":"8d19772c176bd27153b9486715e2c0b9"
|
||||
|
||||
MD4 Hash file #2
|
||||
md4_file:"data_files/hash_file_2":"f2ac53b8542882a5a0007c6f84b4d9fd"
|
||||
|
||||
MD4 Hash file #3
|
||||
md4_file:"data_files/hash_file_3":"195c15158e2d07881d9a654095ce4a42"
|
||||
|
||||
MD4 Hash file #4
|
||||
md4_file:"data_files/hash_file_4":"31d6cfe0d16ae931b73c59d7e0c089c0"
|
||||
|
||||
MD5 Hash file #1
|
||||
md5_file:"data_files/hash_file_1":"52bcdc983c9ed64fc148a759b3c7a415"
|
||||
|
||||
MD5 Hash file #2
|
||||
md5_file:"data_files/hash_file_2":"d17d466f15891df10542207ae78277f0"
|
||||
|
||||
MD5 Hash file #3
|
||||
md5_file:"data_files/hash_file_3":"d945bcc6200ea95d061a2a818167d920"
|
||||
|
||||
MD5 Hash file #4
|
||||
md5_file:"data_files/hash_file_4":"d41d8cd98f00b204e9800998ecf8427e"
|
||||
|
||||
MD2 Selftest
|
||||
md2_selftest:
|
||||
|
||||
MD4 Selftest
|
||||
md4_selftest:
|
||||
|
||||
MD5 Selftest
|
||||
md5_selftest:
|
||||
|
@ -63,3 +63,141 @@ md5_text:text_src_string:hex_hash_string
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md2_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char key_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(key_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
md2_hmac( key_str, key_len, src_str, src_len, output );
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md4_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char key_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(key_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
md4_hmac( key_str, key_len, src_str, src_len, output );
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md5_hmac:trunc_size:hex_key_string:hex_src_string:hex_hash_string
|
||||
{
|
||||
unsigned char src_str[10000];
|
||||
unsigned char key_str[10000];
|
||||
unsigned char hash_str[10000];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(src_str, 0x00, 10000);
|
||||
memset(key_str, 0x00, 10000);
|
||||
memset(hash_str, 0x00, 10000);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
int key_len = unhexify( key_str, {hex_key_string} );
|
||||
int src_len = unhexify( src_str, {hex_src_string} );
|
||||
|
||||
md5_hmac( key_str, key_len, src_str, src_len, output );
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strncmp( (char *) hash_str, {hex_hash_string}, {trunc_size} * 2 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md2_file:filename:hex_hash_string
|
||||
{
|
||||
unsigned char hash_str[65];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(hash_str, 0x00, 65);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
md2_file( {filename}, output);
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md4_file:filename:hex_hash_string
|
||||
{
|
||||
unsigned char hash_str[65];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(hash_str, 0x00, 65);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
md4_file( {filename}, output);
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md5_file:filename:hex_hash_string
|
||||
{
|
||||
unsigned char hash_str[65];
|
||||
unsigned char output[33];
|
||||
|
||||
memset(hash_str, 0x00, 65);
|
||||
memset(output, 0x00, 33);
|
||||
|
||||
md5_file( {filename}, output);
|
||||
hexify( hash_str, output, 16 );
|
||||
|
||||
TEST_ASSERT( strcmp( (char *) hash_str, {hex_hash_string} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md2_selftest:
|
||||
{
|
||||
TEST_ASSERT( md2_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md4_selftest:
|
||||
{
|
||||
TEST_ASSERT( md4_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
md5_selftest:
|
||||
{
|
||||
TEST_ASSERT( md5_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
@ -16,6 +16,54 @@ mpi_read_write_string:16:"-20":10:"-32"
|
||||
Base test mpi_read_write_string #3 (Negative decimal)
|
||||
mpi_read_write_string:16:"-23":16:"-23"
|
||||
|
||||
Test mpi_read_write_string #1
|
||||
mpi_read_write_string:10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924":16:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424"
|
||||
|
||||
Base test mpi_read_binary #1
|
||||
mpi_read_binary:"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424":10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924"
|
||||
|
||||
Base test mpi_write_binary #1
|
||||
mpi_write_binary:10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924":"0941379d00fed1491fe15df284dfde4a142f68aa8d412023195cee66883e6290ffe703f4ea5963bf212713cee46b107c09182b5edcd955adac418bf4918e2889af48e1099d513830cec85c26ac1e158b52620e33ba8692f893efbb2f958b4424"
|
||||
|
||||
Base test mpi_read_file #1
|
||||
mpi_read_file:10:"data_files/mpi_10":"01f55332c3a48b910f9942f6c914e58bef37a47ee45cb164a5b6b8d1006bf59a059c21449939ebebfdf517d2e1dbac88010d7b1f141e997bd6801ddaec9d05910f4f2de2b2c4d714e2c14a72fc7f17aa428d59c531627f09"
|
||||
|
||||
Base test mpi_write_file #1
|
||||
mpi_write_file:10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924":16:"data_files/mpi_write"
|
||||
|
||||
Base test mpi_lsb #1
|
||||
mpi_lsb:10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924":2
|
||||
|
||||
Base test mpi_lsb #2
|
||||
mpi_lsb:10:"24":3
|
||||
|
||||
Base test mpi_lsb #3
|
||||
mpi_lsb:16:"24":2
|
||||
|
||||
Base test mpi_lsb #4
|
||||
mpi_lsb:16:"2000":13
|
||||
|
||||
Base test mpi_msb #1
|
||||
mpi_msb:10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924":764
|
||||
|
||||
Base test mpi_msb #2
|
||||
mpi_msb:10:"24":5
|
||||
|
||||
Base test mpi_msb #3
|
||||
mpi_msb:10:"1":1
|
||||
|
||||
Base test mpi_msb #4
|
||||
mpi_msb:10:"15":4
|
||||
|
||||
Base test mpi_msb #5
|
||||
mpi_msb:10:"16":5
|
||||
|
||||
Base test mpi_msb #6
|
||||
mpi_msb:10:"10":4
|
||||
|
||||
Base test mpi_msb #7
|
||||
mpi_msb:10:"0":0
|
||||
|
||||
Base test mpi_cmp_int #1
|
||||
mpi_cmp_int:693:693:0
|
||||
|
||||
@ -82,6 +130,9 @@ mpi_cmp_abs:10:"-2":10:"1":1
|
||||
Base test mpi_copy #1
|
||||
mpi_copy:0:1500
|
||||
|
||||
Base test mpi_copy_self #1
|
||||
mpi_copy_self:14
|
||||
|
||||
Base test mpi_swap #1
|
||||
mpi_swap:0:1500
|
||||
|
||||
@ -339,3 +390,6 @@ mpi_is_prime:10:"827131507221654563937832686696200995595835694437983658840870036
|
||||
|
||||
Test mpi_is_prime #2
|
||||
mpi_is_prime:10:"827131507221654563937832686696200995595835694437983658840870036586124168186967796809117749047430768825822857042432722828096779098498192459819306321073968735177531164565305635281198148032612029767584644305912001":POLARSSL_ERR_MPI_NOT_ACCEPTABLE
|
||||
|
||||
MPI Selftest
|
||||
mpi_selftest:
|
||||
|
@ -22,7 +22,115 @@ mpi_read_write_string:radix_X:input_X:radix_A:input_A
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
|
||||
TEST_ASSERT( mpi_write_string( &X, {radix_A}, str, &len ) == 0 );
|
||||
TEST_ASSERT( strcmp( str, {input_A} ) == 0 );
|
||||
TEST_ASSERT( strcasecmp( str, {input_A} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_read_binary:input_X:radix_A:input_A
|
||||
{
|
||||
mpi X;
|
||||
unsigned char str[1000];
|
||||
unsigned char buf[1000];
|
||||
int len = 1000;
|
||||
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
int input_len = unhexify( buf, {input_X} );
|
||||
|
||||
TEST_ASSERT( mpi_read_binary( &X, buf, input_len ) == 0 );
|
||||
TEST_ASSERT( mpi_write_string( &X, {radix_A}, (char *) str, &len ) == 0 );
|
||||
TEST_ASSERT( strcmp( (char *) str, {input_A} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_write_binary:radix_X:input_X:input_A
|
||||
{
|
||||
mpi X;
|
||||
unsigned char str[1000];
|
||||
unsigned char buf[1000];
|
||||
|
||||
memset( buf, 0x00, 1000 );
|
||||
memset( str, 0x00, 1000 );
|
||||
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
|
||||
|
||||
int buflen = mpi_size( &X );
|
||||
TEST_ASSERT( mpi_write_binary( &X, buf, buflen ) == 0 );
|
||||
|
||||
hexify( str, buf, buflen );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) str, {input_A} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_read_file:radix_X:input_file:input_A
|
||||
{
|
||||
mpi X;
|
||||
unsigned char str[1000];
|
||||
unsigned char buf[1000];
|
||||
|
||||
memset( buf, 0x00, 1000 );
|
||||
memset( str, 0x00, 1000 );
|
||||
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
FILE *file = fopen( {input_file}, "r" );
|
||||
TEST_ASSERT( mpi_read_file( &X, {radix_X}, file ) == 0 );
|
||||
fclose(file);
|
||||
|
||||
int buflen = mpi_size( &X );
|
||||
TEST_ASSERT( mpi_write_binary( &X, buf, buflen ) == 0 );
|
||||
|
||||
hexify( str, buf, buflen );
|
||||
|
||||
TEST_ASSERT( strcasecmp( (char *) str, {input_A} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_write_file:radix_X:input_X:output_radix:output_file
|
||||
{
|
||||
mpi X, Y;
|
||||
mpi_init( &X, &Y, NULL );
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
|
||||
|
||||
FILE *file_out = fopen( {output_file}, "w" );
|
||||
TEST_ASSERT( mpi_write_file( NULL, &X, {output_radix}, file_out ) == 0 );
|
||||
fclose(file_out);
|
||||
|
||||
FILE *file_in = fopen( {output_file}, "r" );
|
||||
TEST_ASSERT( mpi_read_file( &Y, {output_radix}, file_in ) == 0 );
|
||||
fclose(file_in);
|
||||
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &Y ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_lsb:radix_X:input_X:nr_bits
|
||||
{
|
||||
mpi X;
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
|
||||
TEST_ASSERT( mpi_lsb( &X ) == {nr_bits} );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_msb:radix_X:input_X:nr_bits
|
||||
{
|
||||
mpi X;
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, {radix_X}, {input_X} ) == 0 );
|
||||
TEST_ASSERT( mpi_msb( &X ) == {nr_bits} );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
@ -92,6 +200,18 @@ mpi_copy:input_X:input_A
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_copy_self:input_X
|
||||
{
|
||||
mpi X;
|
||||
mpi_init(&X, NULL);
|
||||
|
||||
TEST_ASSERT( mpi_lset( &X, {input_X} ) == 0 );
|
||||
TEST_ASSERT( mpi_copy( &X, &X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_int( &X, {input_X} ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_swap:input_X:input_Y
|
||||
{
|
||||
@ -382,6 +502,12 @@ mpi_shift_r:radix_X:input_X:shift_X:radix_A:input_A
|
||||
}
|
||||
END_CASE
|
||||
|
||||
BEGIN_CASE
|
||||
mpi_selftest:
|
||||
{
|
||||
TEST_ASSERT( mpi_self_test( 0 ) == 0 );
|
||||
}
|
||||
END_CASE
|
||||
/* Helper Code
|
||||
char str[1000];
|
||||
int len = 1000;
|
||||
|
Loading…
Reference in New Issue
Block a user