X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=test_src%2Fmain-sha256-test.c;h=44ea153473b4ee59feddddadf4ed585c3a3ebd3c;hp=61ee2313e6666d048c0c4564fbca0e3eb56340c2;hb=4b5da1dc27a791b5c448274a3db09cd035b33493;hpb=52ec168ece9d61bd9cb652235dfe8faee6232a11 diff --git a/test_src/main-sha256-test.c b/test_src/main-sha256-test.c index 61ee231..44ea153 100644 --- a/test_src/main-sha256-test.c +++ b/test_src/main-sha256-test.c @@ -1,7 +1,7 @@ /* main-sha256-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 @@ -18,13 +18,11 @@ */ /* * SHA-256 test-suit - * + * */ -#include "config.h" -#include "serial-tools.h" -#include "uart_i.h" -#include "debug.h" + +#include "main-test-common.h" #include "sha256.h" #include "nessie_hash_test.h" @@ -32,17 +30,14 @@ #include "hfal-performance.h" #include "hfal-nessie.h" -#include -#include -#include -#include "cli.h" #include "shavs.h" #include "hfal_sha256.h" + #include "dump.h" -char* algo_name = "SHA-256"; +char *algo_name = "SHA-256"; -const hfdesc_t* algolist[] PROGMEM = { +const hfdesc_t *const algolist[] PROGMEM = { (hfdesc_t*)&sha256_desc, NULL }; @@ -59,42 +54,109 @@ void testrun_performance_sha256(void){ hfal_performance_multiple(algolist); } +void test_monte(void){ + uint8_t data1[] = { + 0xF4, 0x1E, 0xCE, 0x26, 0x13, 0xE4, 0x57, 0x39, + 0x15, 0x69, 0x6B, 0x5A, 0xDC, 0xD5, 0x1C, 0xA3, + 0x28, 0xBE, 0x3B, 0xF5, 0x66, 0xA9, 0xCA, 0x99, + 0xC9, 0xCE, 0xB0, 0x27, 0x9C, 0x1C, 0xB0, 0xA7, + 0xF4, 0x1E, 0xCE, 0x26, 0x13, 0xE4, 0x57, 0x39, + 0x15, 0x69, 0x6B, 0x5A, 0xDC, 0xD5, 0x1C, 0xA3, + 0x28, 0xBE, 0x3B, 0xF5, 0x66, 0xA9, 0xCA, 0x99, + 0xC9, 0xCE, 0xB0, 0x27, 0x9C, 0x1C, 0xB0, 0xA7, + 0xF4, 0x1E, 0xCE, 0x26, 0x13, 0xE4, 0x57, 0x39, + 0x15, 0x69, 0x6B, 0x5A, 0xDC, 0xD5, 0x1C, 0xA3, + 0x28, 0xBE, 0x3B, 0xF5, 0x66, 0xA9, 0xCA, 0x99, + 0xC9, 0xCE, 0xB0, 0x27, 0x9C, 0x1C, 0xB0, 0xA7 }; + + uint8_t data2[] = { + 0xF4, 0x1E, 0xCE, 0x26, 0x13, 0xE4, 0x57, 0x39, + 0x15, 0x69, 0x6B, 0x5A, 0xDC, 0xD5, 0x1C, 0xA3, + 0x28, 0xBE, 0x3B, 0xF5, 0x66, 0xA9, 0xCA, 0x99, + 0xC9, 0xCE, 0xB0, 0x27, 0x9C, 0x1C, 0xB0, 0xA7, + 0xF4, 0x1E, 0xCE, 0x26, 0x13, 0xE4, 0x57, 0x39, + 0x15, 0x69, 0x6B, 0x5A, 0xDC, 0xD5, 0x1C, 0xA3, + 0x28, 0xBE, 0x3B, 0xF5, 0x66, 0xA9, 0xCA, 0x99, + 0xC9, 0xCE, 0xB0, 0x27, 0x9C, 0x1C, 0xB0, 0xA7, + 0xFD, 0xDF, 0x1B, 0x37, 0xDD, 0x34, 0xB3, 0xB2, + 0x01, 0xD4, 0x3C, 0x57, 0xBC, 0xDE, 0x11, 0x58, + 0x38, 0xF0, 0xDF, 0x70, 0x1D, 0xA9, 0x3C, 0x3B, + 0xF2, 0xC9, 0xC8, 0x68, 0x96, 0xE7, 0xE6, 0xC7 }; + uint8_t hash[SHA256_HASH_BYTES]; + sha256((sha256_hash_t*)hash, data1, 3*32*8); + cli_putstr_P(PSTR("\r\n hash(data1) = ")); + cli_hexdump(hash, 32); + sha256((sha256_hash_t*)hash, data2, 3*32*8); + cli_putstr_P(PSTR("\r\n hash(data2) = ")); + cli_hexdump(hash, 32); +} + +void test_monte2(void){ + uint8_t data[] = { + 0x6c, 0xd4, 0xc0, 0xc5, 0xcb, 0x2c, 0xa2, 0xa0, + 0xf1, 0xd1, 0xae, 0xce, 0xba, 0xc0, 0x3b, 0x52, + 0xe6, 0x4e, 0xa0, 0x3d, 0x1a, 0x16, 0x54, 0x37, + 0x29, 0x36, 0x54, 0x5b, 0x92, 0xbb, 0xc5, 0x48, + 0x4a, 0x59, 0xdb, 0x74, 0xbb, 0x60, 0xf9, 0xc4, + 0x0c, 0xeb, 0x1a, 0x5a, 0xa3, 0x5a, 0x6f, 0xaf, + 0xe8, 0x03, 0x49, 0xe1, 0x4c, 0x25, 0x3a, 0x4e, + 0x8b, 0x1d, 0x77, 0x61, 0x2d, 0xdd, 0x81, 0xac, + 0xe9, 0x26, 0xae, 0x8b, 0x0a, 0xf6, 0xe5, 0x31, + 0x76, 0xdb, 0xff, 0xcc, 0x2a, 0x6b, 0x88, 0xc6, + 0xbd, 0x76, 0x5f, 0x93, 0x9d, 0x3d, 0x17, 0x8a, + 0x9b, 0xde, 0x9e, 0xf3, 0xaa, 0x13, 0x1c, 0x61, + 0xe3, 0x1c, 0x1e, 0x42, 0xcd, 0xfa, 0xf4, 0xb4, + 0xdc, 0xde, 0x57, 0x9a, 0x37, 0xe1, 0x50, 0xef, + 0xbe, 0xf5, 0x55, 0x5b, 0x4c, 0x1c, 0xb4, 0x04, + 0x39, 0xd8, 0x35, 0xa7, 0x24, 0xe2, 0xfa, 0xe7 }; + + uint8_t hash[SHA256_HASH_BYTES]; + sha256((sha256_hash_t*)hash, data, 1024); + cli_putstr_P(PSTR("\r\n hash(data) = ")); + cli_hexdump(hash, 32); +} + /***************************************************************************** * main * *****************************************************************************/ const char nessie_str[] PROGMEM = "nessie"; const char test_str[] PROGMEM = "test"; +const char monte_str[] PROGMEM = "monte"; +const char monte2_str[] PROGMEM = "monte2"; const char performance_str[] PROGMEM = "performance"; const char echo_str[] PROGMEM = "echo"; const char shavs_list_str[] PROGMEM = "shavs_list"; const char shavs_set_str[] PROGMEM = "shavs_set"; const char shavs_test1_str[] PROGMEM = "shavs_test1"; +const char shavs_test2_str[] PROGMEM = "shavs_test2"; +const char shavs_test3_str[] PROGMEM = "shavs_test3"; const char dump_str[] PROGMEM = "dump"; -cmdlist_entry_t cmdlist[] PROGMEM = { - { nessie_str, NULL, testrun_nessie_sha256}, - { test_str, NULL, testrun_nessie_sha256}, - { performance_str, NULL, testrun_performance_sha256}, - { echo_str, (void*)1, (void_fpt)echo_ctrl}, - { shavs_list_str, NULL, shavs_listalgos}, - { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo}, - { shavs_test1_str, NULL, shavs_test1}, - { dump_str, (void*)1, (void_fpt)dump}, - { NULL, NULL, NULL} +const cmdlist_entry_t cmdlist[] PROGMEM = { + { nessie_str, NULL, testrun_nessie_sha256 }, + { test_str, NULL, testrun_nessie_sha256 }, + { monte_str, NULL, test_monte }, + { monte2_str, NULL, test_monte2 }, + { performance_str, NULL, testrun_performance_sha256 }, + { echo_str, (void*)1, (void_fpt)echo_ctrl }, + { shavs_list_str, NULL, shavs_listalgos }, + { shavs_set_str, (void*)1, (void_fpt)shavs_setalgo }, + { shavs_test1_str, NULL, shavs_test1 }, + { shavs_test2_str, NULL, shavs_test2 }, + { shavs_test3_str, NULL, shavs_test3 }, + { dump_str, (void*)1, (void_fpt)dump }, + { NULL, NULL, NULL } }; int main (void){ - DEBUG_INIT(); - - cli_rx = (cli_rx_fpt)uart0_getc; - cli_tx = (cli_tx_fpt)uart0_putc; - shavs_algolist=(hfdesc_t**)algolist; + main_setup(); + + shavs_algolist=(hfdesc_t**)algolist; shavs_algo=(hfdesc_t*)&sha256_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")); - cmd_interface(cmdlist); + welcome_msg(algo_name); + cmd_interface(cmdlist); } }