1 /* main-trivium-test.c */
3 This file is part of the Crypto-avr-lib/microcrypt-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/>.
25 #include "serial-tools.h"
31 #include "nessie_stream_test.h"
32 #include "performance_test.h"
38 char* cipher_name = "Trivium";
40 /*****************************************************************************
41 * additional validation-functions *
42 *****************************************************************************/
43 void trivium_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
45 trivium_init(key, 80, &iv, 32, ctx);
48 uint8_t trivium_getbyte_dummy(trivium_ctx_t* ctx){
52 ret |= trivium_enc(ctx);
57 void testrun_nessie_trivium(void){
58 nessie_stream_ctx.outsize_b = 8; /* actually unused */
59 nessie_stream_ctx.keysize_b = 80; /* this is the one we have refrence vectors for */
60 nessie_stream_ctx.ivsize_b = 32;
61 nessie_stream_ctx.name = cipher_name;
62 nessie_stream_ctx.ctx_size_B = sizeof(trivium_ctx_t);
63 nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)trivium_genctx_dummy;
64 nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)trivium_getbyte_dummy;
69 void testrun_performance_trivium(void){
73 uint8_t key[10], iv[10];
78 uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
80 uart_putstr_P(PSTR("\r\n\tconst overhead: "));
83 uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
90 trivium_init(key, 80, iv, 80, &ctx);
92 uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
93 ultoa((unsigned long)t, str, 10);
99 uart_putstr_P(PSTR("\r\n\tencrypt time: "));
100 ultoa((unsigned long)t, str, 10);
103 uart_putstr_P(PSTR("\r\n"));
106 /*****************************************************************************
108 *****************************************************************************/
115 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
116 uart_putstr(cipher_name);
117 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
119 PGM_P u = PSTR("nessie\0test\0performance\0");
120 void_fpt v[] = {testrun_nessie_trivium, testrun_nessie_trivium, testrun_performance_trivium};
123 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
124 if(execcommand_d0_P(str, u, v)<0){
125 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
129 uart_putstr("ERROR\r\n");