1 /* main-trivium-test.c */
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 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/>.
20 #include "main-test-common.h"
23 #include "scal_trivium.h"
24 #include "scal-basic.h"
25 #include "scal-nessie.h"
26 #include "performance_test.h"
28 char* algo_name = "Trivium";
30 /*****************************************************************************
31 * additional validation-functions *
32 *****************************************************************************/
34 void testrun_nessie_trivium(void){
35 scal_nessie_set_estream(1);
36 scal_nessie_run(&trivium_desc);
39 void testrun_trivium(void){
47 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
48 scal_cipher_gen_fillblock(buffer, 64, &ctx);
49 cli_putstr("\r\nTest:\r\n Key = ");
51 cli_putstr("\r\n IV = ");
53 cli_putstr("\r\n Cipher = ");
54 cli_hexdump_block(buffer, 64, 4, 16);
55 scal_cipher_free(&ctx);
57 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
58 scal_cipher_gen_fillblock(buffer, 64, &ctx);
59 cli_putstr("\r\nTest:\r\n Key = ");
61 cli_putstr("\r\n IV = ");
63 cli_putstr("\r\n Cipher = ");
64 cli_hexdump_block(buffer, 64, 4, 16);
65 scal_cipher_free(&ctx);
67 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
68 scal_cipher_gen_fillblock(buffer, 64, &ctx);
69 cli_putstr("\r\nTest:\r\n Key = ");
71 cli_putstr("\r\n IV = ");
73 cli_putstr("\r\n Cipher = ");
74 cli_hexdump_block(buffer, 64, 4, 16);
75 scal_cipher_free(&ctx);
77 scal_cipher_init(&trivium_desc, key, 80, iv, 32, &ctx);
78 scal_cipher_gen_fillblock(buffer, 64, &ctx);
79 cli_putstr("\r\nTest:\r\n Key = ");
81 cli_putstr("\r\n IV = ");
83 cli_putstr("\r\n Cipher = ");
84 cli_hexdump_block(buffer, 64, 4, 16);
85 scal_cipher_free(&ctx);
88 void testrun_performance_trivium(void){
91 uint8_t key[10], iv[10];
101 trivium_init(key, 80, iv, 80, &ctx);
103 cli_putstr("\r\n\tctx-gen time: ");
104 ultoa((unsigned long)t, str, 10);
110 cli_putstr("\r\n\tencrypt time: ");
111 ultoa((unsigned long)t, str, 10);
117 /*****************************************************************************
119 *****************************************************************************/
121 const char nessie_str[] = "nessie";
122 const char test_str[] = "test";
123 const char performance_str[] = "performance";
124 const char echo_str[] = "echo";
126 cmdlist_entry_t cmdlist[] = {
127 { nessie_str, NULL, testrun_nessie_trivium},
128 { test_str, NULL, testrun_trivium},
129 { performance_str, NULL, testrun_performance_trivium},
130 { echo_str, (void*)1, (void_fpt)echo_ctrl},
138 welcome_msg(algo_name);
139 cmd_interface(cmdlist);