1 /* main-trivium-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
31 #include "scal_trivium.h"
32 #include "scal-basic.h"
33 #include "scal-nessie.h"
34 #include "performance_test.h"
40 char* algo_name = "Trivium";
42 /*****************************************************************************
43 * additional validation-functions *
44 *****************************************************************************/
46 void testrun_nessie_trivium(void){
47 scal_nessie_run(&trivium_desc);
50 void testrun_trivium(void){
58 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
59 scal_cipher_gen_fillblock(buffer, 64, &ctx);
60 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
62 cli_putstr_P(PSTR("\r\n IV = "));
64 cli_putstr_P(PSTR("\r\n Cipher = "));
65 cli_hexdump_block(buffer, 64, 4, 16);
66 scal_cipher_free(&ctx);
68 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
69 scal_cipher_gen_fillblock(buffer, 64, &ctx);
70 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
72 cli_putstr_P(PSTR("\r\n IV = "));
74 cli_putstr_P(PSTR("\r\n Cipher = "));
75 cli_hexdump_block(buffer, 64, 4, 16);
76 scal_cipher_free(&ctx);
78 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
79 scal_cipher_gen_fillblock(buffer, 64, &ctx);
80 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
82 cli_putstr_P(PSTR("\r\n IV = "));
84 cli_putstr_P(PSTR("\r\n Cipher = "));
85 cli_hexdump_block(buffer, 64, 4, 16);
86 scal_cipher_free(&ctx);
88 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
89 scal_cipher_gen_fillblock(buffer, 64, &ctx);
90 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
92 cli_putstr_P(PSTR("\r\n IV = "));
94 cli_putstr_P(PSTR("\r\n Cipher = "));
95 cli_hexdump_block(buffer, 64, 4, 16);
96 scal_cipher_free(&ctx);
99 void testrun_performance_trivium(void){
102 uint8_t key[10], iv[10];
112 trivium_init(key, 80, iv, 80, &ctx);
114 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
115 ultoa((unsigned long)t, str, 10);
121 cli_putstr_P(PSTR("\r\n\tencrypt time: "));
122 ultoa((unsigned long)t, str, 10);
125 cli_putstr_P(PSTR("\r\n"));
128 /*****************************************************************************
130 *****************************************************************************/
132 const char nessie_str[] PROGMEM = "nessie";
133 const char test_str[] PROGMEM = "test";
134 const char performance_str[] PROGMEM = "performance";
135 const char echo_str[] PROGMEM = "echo";
137 const cmdlist_entry_t cmdlist[] PROGMEM = {
138 { nessie_str, NULL, testrun_nessie_trivium},
139 { test_str, NULL, testrun_trivium},
140 { performance_str, NULL, testrun_performance_trivium},
141 { echo_str, (void*)1, (void_fpt)echo_ctrl},
148 cli_rx = (cli_rx_fpt)uart0_getc;
149 cli_tx = (cli_tx_fpt)uart0_putc;
151 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
152 cli_putstr(algo_name);
153 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
154 cmd_interface(cmdlist);