X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=test_src%2Fmain-aes-test.c;h=6b20c582d244263fe3dab918d51cd1858b298fce;hp=88f87d5b266544e165143b8f734d046b72b8473e;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=7b5401ab9ce23a5da1de8b6c7de3a1aa20ac4cf8 diff --git a/test_src/main-aes-test.c b/test_src/main-aes-test.c index 88f87d5..6b20c58 100644 --- a/test_src/main-aes-test.c +++ b/test_src/main-aes-test.c @@ -1,7 +1,7 @@ /* main-aes-test.c */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,40 +20,29 @@ * AES test-suit * */ +#include "main-test-common.h" +#include "aes.h" -#include "config.h" - -#include "uart_i.h" -#include "debug.h" - -#include "aes/aes.h" - -#include "nessie_bc_test.h" -#include "cli.h" #include "performance_test.h" #include "dump.h" -#include "bcal/bcal_aes128.h" -#include "bcal/bcal_aes192.h" -#include "bcal/bcal_aes256.h" -#include "bcal/bcal-cbc.h" -#include "bcal/bcal-cfb_byte.h" -#include "bcal/bcal-cfb_bit.h" -#include "bcal/bcal-ofb.h" -#include "bcal/bcal-ctr.h" -#include "bcal/bcal-cmac.h" -#include "bcal/bcal-eax.h" +#include "bcal_aes128.h" +#include "bcal_aes192.h" +#include "bcal_aes256.h" +#include "bcal-cbc.h" +#include "bcal-cfb_byte.h" +#include "bcal-cfb_bit.h" +#include "bcal-ofb.h" +#include "bcal-ctr.h" +#include "bcal-cmac.h" +#include "bcal-eax.h" #include "cmacvs.h" -#include "bcal/bcal-performance.h" - -#include -#include -#include -#include +#include "bcal-performance.h" +#include "bcal-nessie.h" -char* algo_name = "AES"; +const char *algo_name = "AES"; -const bcdesc_t* algolist[] PROGMEM = { +const bcdesc_t *const const algolist[] PROGMEM = { (bcdesc_t*)&aes128_desc, (bcdesc_t*)&aes192_desc, (bcdesc_t*)&aes256_desc, @@ -65,26 +54,7 @@ const bcdesc_t* algolist[] PROGMEM = { *****************************************************************************/ void testrun_nessie_aes(void){ - nessie_bc_ctx.blocksize_B = 16; - nessie_bc_ctx.keysize_b = 128; - nessie_bc_ctx.name = algo_name; - nessie_bc_ctx.ctx_size_B = sizeof(aes128_ctx_t); - nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)aes128_enc; - nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)aes128_dec; - nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)aes_init; - nessie_bc_run(); - - nessie_bc_ctx.keysize_b = 192; - nessie_bc_ctx.ctx_size_B = sizeof(aes192_ctx_t); - nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)aes192_enc; - nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)aes192_dec; - nessie_bc_run(); - - nessie_bc_ctx.keysize_b = 256; - nessie_bc_ctx.ctx_size_B = sizeof(aes256_ctx_t); - nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)aes256_enc; - nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)aes256_dec; - nessie_bc_run(); + bcal_nessie_multiple(algolist); } void testrun_test_aes(void){ @@ -196,23 +166,23 @@ void testrun_testkey_aes(void){ testrun_testkey_aes256(); } -uint8_t modes_key[] PROGMEM = { +const uint8_t modes_key[] PROGMEM = { 0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6, 0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c, 0x1f, 0x35, 0x2c, 0x07, 0x3b, 0x61, 0x08, 0xd7, 0x2d, 0x98, 0x10, 0xa3, 0x09, 0x14, 0xdf, 0xf4 }; -uint8_t modes_iv[] PROGMEM = { +const uint8_t modes_iv[] PROGMEM = { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }; -uint8_t modes_ctriv[] PROGMEM = { +const uint8_t modes_ctriv[] PROGMEM = { 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }; -uint8_t modes_plain[] PROGMEM = { +const uint8_t modes_plain[] PROGMEM = { 0x6b, 0xc1, 0xbe, 0xe2, 0x2e, 0x40, 0x9f, 0x96, 0xe9, 0x3d, 0x7e, 0x11, 0x73, 0x93, 0x17, 0x2a, /* --- */ @@ -529,7 +499,7 @@ void testrun_aes192_cmac0(void){ bcal_cmac_free(&ctx); } -uint8_t eax_msg[] PROGMEM = { +const uint8_t eax_msg[] PROGMEM = { 0xF7, 0xFB, 0x1A, 0x47, 0xCB, 0x49, 0x33, 0x48, 0x1C, 0x9E, 0x39, 0xB1, @@ -541,9 +511,9 @@ uint8_t eax_msg[] PROGMEM = { 0xCA, 0x40, 0xD7, 0x44, 0x6E, 0x54, 0x5F, 0xFA, 0xED, 0x3B, 0xD1, 0x2A, 0x74, 0x0A, 0x65, 0x9F, 0xFB, 0xBB, 0x3C, 0xEA, 0xB7 }; -uint8_t eax_msg_len[] PROGMEM = {0, 2, 5, 5, 6, 12, 17, 18, 18, 21}; +const uint8_t eax_msg_len[] PROGMEM = {0, 2, 5, 5, 6, 12, 17, 18, 18, 21}; -uint8_t eax_key[] PROGMEM = { +const uint8_t eax_key[] PROGMEM = { 0x23, 0x39, 0x52, 0xDE, 0xE4, 0xD5, 0xED, 0x5F, 0x9B, 0x9C, 0x6D, 0x6F, 0xF8, 0x0F, 0xF4, 0x78, 0x91, 0x94, 0x5D, 0x3F, 0x4D, 0xCB, 0xEE, 0x0B, 0xF4, 0x5E, 0xF5, 0x22, 0x55, 0xF0, 0x95, 0xA4, 0x01, 0xF7, 0x4A, 0xD6, 0x40, 0x77, 0xF2, 0xE7, 0x04, 0xC0, 0xF6, 0x0A, 0xDA, 0x3D, 0xD5, 0x23, @@ -556,7 +526,7 @@ uint8_t eax_key[] PROGMEM = { 0x83, 0x95, 0xFC, 0xF1, 0xE9, 0x5B, 0xEB, 0xD6, 0x97, 0xBD, 0x01, 0x0B, 0xC7, 0x66, 0xAA, 0xC3 }; -uint8_t eax_nonce[] PROGMEM = { +const uint8_t eax_nonce[] PROGMEM = { 0x62, 0xEC, 0x67, 0xF9, 0xC3, 0xA4, 0xA4, 0x07, 0xFC, 0xB2, 0xA8, 0xC4, 0x90, 0x31, 0xA8, 0xB3, 0xBE, 0xCA, 0xF0, 0x43, 0xB0, 0xA2, 0x3D, 0x84, 0x31, 0x94, 0xBA, 0x97, 0x2C, 0x66, 0xDE, 0xBD, 0x70, 0xC3, 0xDB, 0x4F, 0x0D, 0x26, 0x36, 0x84, 0x00, 0xA1, 0x0E, 0xD0, 0x5D, 0x2B, 0xFF, 0x5E, @@ -569,7 +539,7 @@ uint8_t eax_nonce[] PROGMEM = { 0x22, 0xE7, 0xAD, 0xD9, 0x3C, 0xFC, 0x63, 0x93, 0xC5, 0x7E, 0xC0, 0xB3, 0xC1, 0x7D, 0x6B, 0x44 }; -uint8_t eax_header[] PROGMEM = { +const uint8_t eax_header[] PROGMEM = { 0x6B, 0xFB, 0x91, 0x4F, 0xD0, 0x7E, 0xAE, 0x6B, 0xFA, 0x3B, 0xFD, 0x48, 0x06, 0xEB, 0x53, 0xFA, 0x23, 0x4A, 0x34, 0x63, 0xC1, 0x26, 0x4A, 0xC6, @@ -582,7 +552,7 @@ uint8_t eax_header[] PROGMEM = { 0x12, 0x67, 0x35, 0xFC, 0xC3, 0x20, 0xD2, 0x5A }; -uint8_t eax_cipher[] PROGMEM = { +const uint8_t eax_cipher[] PROGMEM = { 0xE0, 0x37, 0x83, 0x0E, 0x83, 0x89, 0xF2, 0x7B, 0x02, 0x5A, 0x2D, 0x65, 0x27, 0xE7, 0x9D, 0x01, 0x19, 0xDD, 0x5C, 0x4C, 0x93, 0x31, 0x04, 0x9D, 0x0B, 0xDA, 0xB0, 0x27, 0x74, 0x08, 0xF6, 0x79, 0x67, 0xE5, 0xD8, 0x51, 0xD5, 0xBA, 0xE0, 0x3A, 0x59, 0xF2, 0x38, 0xA2, 0x3E, 0x39, 0x19, 0x9D, 0xC9, 0x26, 0x66, 0x26, 0xC4, 0x0F, 0x80, @@ -699,7 +669,7 @@ const char performance_str[] PROGMEM = "performance"; const char dump_str[] PROGMEM = "dump"; const char echo_str[] PROGMEM = "echo"; -cmdlist_entry_t cmdlist[] PROGMEM = { +const const cmdlist_entry_t cmdlist[] PROGMEM = { { nessie_str, NULL, testrun_nessie_aes }, { test_str, NULL, testrun_test_aes }, { testkey_str, NULL, testrun_testkey_aes }, @@ -722,19 +692,16 @@ cmdlist_entry_t cmdlist[] PROGMEM = { { NULL, NULL, NULL } }; +int main(void) { + main_setup(); -int main (void){ - DEBUG_INIT(); - - cli_rx = (cli_rx_fpt)uart0_getc; - cli_tx = (cli_tx_fpt)uart0_putc; cmacvs_algolist=(bcdesc_t**)algolist; cmacvs_algo=(bcdesc_t*)&aes128_desc; + for(;;){ - cli_putstr_P(PSTR("\r\n\r\nCrypto-VS (")); - cli_putstr(algo_name); - cli_putstr_P(PSTR(")\r\nloaded and running\r\n")); + welcome_msg(algo_name); cmd_interface(cmdlist); - } + } + }