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/>.
24 #include "main-test-common.h"
27 #include "scal_trivium.h"
28 #include "scal-basic.h"
29 #include "scal-nessie.h"
30 #include "performance_test.h"
32 char* algo_name = "Trivium";
34 /*****************************************************************************
35 * additional validation-functions *
36 *****************************************************************************/
38 void testrun_nessie_trivium(void){
39 scal_nessie_run(&trivium_desc);
42 void testrun_trivium(void){
50 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
51 scal_cipher_gen_fillblock(buffer, 64, &ctx);
52 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
54 cli_putstr_P(PSTR("\r\n IV = "));
56 cli_putstr_P(PSTR("\r\n Cipher = "));
57 cli_hexdump_block(buffer, 64, 4, 16);
58 scal_cipher_free(&ctx);
60 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
61 scal_cipher_gen_fillblock(buffer, 64, &ctx);
62 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
64 cli_putstr_P(PSTR("\r\n IV = "));
66 cli_putstr_P(PSTR("\r\n Cipher = "));
67 cli_hexdump_block(buffer, 64, 4, 16);
68 scal_cipher_free(&ctx);
70 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
71 scal_cipher_gen_fillblock(buffer, 64, &ctx);
72 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
74 cli_putstr_P(PSTR("\r\n IV = "));
76 cli_putstr_P(PSTR("\r\n Cipher = "));
77 cli_hexdump_block(buffer, 64, 4, 16);
78 scal_cipher_free(&ctx);
80 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
81 scal_cipher_gen_fillblock(buffer, 64, &ctx);
82 cli_putstr_P(PSTR("\r\nTest:\r\n Key = "));
84 cli_putstr_P(PSTR("\r\n IV = "));
86 cli_putstr_P(PSTR("\r\n Cipher = "));
87 cli_hexdump_block(buffer, 64, 4, 16);
88 scal_cipher_free(&ctx);
91 void testrun_performance_trivium(void){
94 uint8_t key[10], iv[10];
104 trivium_init(key, 80, iv, 80, &ctx);
106 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
107 ultoa((unsigned long)t, str, 10);
113 cli_putstr_P(PSTR("\r\n\tencrypt time: "));
114 ultoa((unsigned long)t, str, 10);
117 cli_putstr_P(PSTR("\r\n"));
120 /*****************************************************************************
122 *****************************************************************************/
124 const char nessie_str[] PROGMEM = "nessie";
125 const char test_str[] PROGMEM = "test";
126 const char performance_str[] PROGMEM = "performance";
127 const char echo_str[] PROGMEM = "echo";
129 const cmdlist_entry_t cmdlist[] PROGMEM = {
130 { nessie_str, NULL, testrun_nessie_trivium},
131 { test_str, NULL, testrun_trivium},
132 { performance_str, NULL, testrun_performance_trivium},
133 { echo_str, (void*)1, (void_fpt)echo_ctrl},
141 welcome_msg(algo_name);
142 cmd_interface(cmdlist);