blake64_test("", 8);
}
-void performance_blake(void){
- uint64_t t;
- char str[16];
- uint8_t data[64];
- uint8_t hash[512/8];
- blake_small_ctx_t ctx;
- blake_large_ctx_t ctx2;
-
- calibrateTimer();
- print_overhead();
-
- memset(data, 0, 64);
-
-
- startTimer(1);
- blake28_init(&ctx);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx-gen time (224): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake32_init(&ctx);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx-gen time (256): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake48_init(&ctx2);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx-gen time (384): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake64_init(&ctx2);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx-gen time (512): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake_small_nextBlock(&ctx, data);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tone-block (small) time: "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake_large_nextBlock(&ctx2, data);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tone-block (large) time: "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake_small_lastBlock(&ctx, data, 0);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tlast block (small) time: "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake_large_lastBlock(&ctx2, data, 0);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tlast block (large) time: "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake28_ctx2hash(hash, &ctx);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx2hash time (224): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake32_ctx2hash(hash, &ctx);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx2hash time (256): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake48_ctx2hash(hash, &ctx2);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx2hash time (384): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- startTimer(1);
- blake64_ctx2hash(hash, &ctx2);
- t = stopTimer();
- cli_putstr_P(PSTR("\r\n\tctx2hash time (512): "));
- ultoa((unsigned long)t, str, 10);
- cli_putstr(str);
-
- cli_putstr_P(PSTR("\r\n"));
-
-}
-void autoperformance_blake(void){
+void performance_blake(void){
hfal_performance_multiple(algolist);
}
const char testshort_str[] PROGMEM = "short";
const char testlshort_str[] PROGMEM = "lshort";
const char performance_str[] PROGMEM = "performance";
-const char aperformance_str[] PROGMEM = "autoperformance";
const char echo_str[] PROGMEM = "echo";
const char shavs_list_str[] PROGMEM = "shavs_list";
const char shavs_set_str[] PROGMEM = "shavs_set";
{ testshort_str, NULL, testshort},
{ testlshort_str, NULL, testlshort},
{ performance_str, NULL, performance_blake},
- { aperformance_str, NULL, autoperformance_blake},
{ shavs_list_str, NULL, shavs_listalgos},
{ shavs_set_str, (void*)1, (void_fpt)shavs_setalgo},
{ shavs_test1_str, NULL, shavs_test1},
--- /dev/null
+/* main-twister-test.c */
+/*
+ This file is part of the AVR-Crypto-Lib.
+ Copyright (C) 2008, 2009 Daniel Otte (daniel.otte@rub.de)
+
+ 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
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+/*
+ * twister test suit
+ *
+*/
+
+#include "config.h"
+#include "serial-tools.h"
+#include "uart.h"
+#include "debug.h"
+
+#include "twister-small.h"
+#include "nessie_hash_test.h"
+#include "performance_test.h"
+#include "hfal_twister224.h"
+#include "hfal_twister256.h"
+#include "hfal_twister384.h"
+#include "hfal_twister512.h"
+#include "hfal-nessie.h"
+#include "hfal-performance.h"
+#include "hfal-test.h"
+#include "shavs.h"
+
+
+#include <stdint.h>
+#include <string.h>
+#include <stdlib.h>
+#include "cli.h"
+
+char* algo_name = "TWISTER";
+
+const hfdesc_t* algolist[] PROGMEM = {
+ (hfdesc_t*)&twister224_desc,
+ (hfdesc_t*)&twister256_desc,
+ (hfdesc_t*)&twister384_desc,
+ (hfdesc_t*)&twister512_desc,
+ NULL
+};
+
+/*****************************************************************************
+ * additional validation-functions *
+ *****************************************************************************/
+
+void testrun_nessie_twister(void){
+ hfal_nessie_multiple(algolist);
+}
+
+/*****************************************************************************
+ * selftests
+ *
+ *****************************************************************************/
+
+void test_twister224( void* msg, uint32_t length_b){
+ hfal_test(&twister224_desc, msg, length_b);
+}
+
+void test_twister256( void* msg, uint32_t length_b){
+ hfal_test(&twister256_desc, msg, length_b);
+}
+
+void test_twister384( void* msg, uint32_t length_b){
+ hfal_test(&twister384_desc, msg, length_b);
+}
+
+void test_twister512( void* msg, uint32_t length_b){
+ hfal_test(&twister512_desc, msg, length_b);
+}
+
+void testrun_twister(void){
+ const hfdesc_t* desc[4] = { &twister224_desc, &twister256_desc,
+ &twister384_desc, &twister512_desc };
+ uint8_t i,j;
+ char* testv[]={
+ "",
+ "a",
+ "abc",
+ "message digest",
+ "abcdefghijklmnopqrstuvwxyz",
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
+ "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
+ uint8_t stestv[]= {0x00, 0x00, 0xC0, 0xC0, 0x80, 0x48, 0x50};
+ uint8_t stestl[]= { 0, 1, 2, 3, 4, 5, 6};
+
+ for(i=0; i<4; ++i){
+ for(j=0; j<7; ++j){
+ hfal_test(desc[i], testv[j], strlen(testv[j])*8);
+ }
+ hfal_test(desc[i], stestv, 7*8);
+ hfal_test(desc[i], stestl, 7*8);
+
+ }
+}
+
+
+void testrun_performance_twister(void){
+ hfal_performance_multiple(algolist);
+}
+
+
+/*****************************************************************************
+ * main *
+ *****************************************************************************/
+
+const char nessie_str[] PROGMEM = "nessie";
+const char test_str[] PROGMEM = "test";
+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";
+
+cmdlist_entry_t cmdlist[] PROGMEM = {
+ { nessie_str, NULL, testrun_nessie_twister},
+ { test_str, NULL, testrun_twister},
+ { performance_str, NULL, testrun_performance_twister},
+ { 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},
+ { NULL, NULL, NULL}
+};
+
+int main (void){
+ DEBUG_INIT();
+
+ cli_rx = uart_getc;
+ cli_tx = uart_putc;
+ shavs_algolist=(hfdesc_t**)algolist;
+ shavs_algo=(hfdesc_t*)&twister256_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);
+ }
+}