1 /* main-skipjack-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"
30 #include "nessie_bc_test.h"
32 #include "performance_test.h"
39 char* cipher_name = "Skipjack";
41 /*****************************************************************************
42 * additional validation-functions *
43 *****************************************************************************/
44 void skipjack_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
48 void testrun_nessie_skipjack(void){
49 nessie_bc_ctx.blocksize_B = 8;
50 nessie_bc_ctx.keysize_b = 80;
51 nessie_bc_ctx.name = cipher_name;
52 nessie_bc_ctx.ctx_size_B = 10;
53 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)skipjack_enc;
54 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)skipjack_dec;
55 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)skipjack_genctx_dummy;
61 void testrun_performance_skipjack(void){
65 uint8_t key[10], data[8];
69 uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
71 uart_putstr_P(PSTR("\r\n\tconst overhead: "));
74 uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
81 skipjack_enc(data, key);
83 uart_putstr_P(PSTR("\r\n\tencrypt time: "));
84 ultoa((unsigned long)t, str, 10);
89 skipjack_dec(data, key);
91 uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
92 ultoa((unsigned long)t, str, 10);
95 uart_putstr_P(PSTR("\r\n"));
98 /*****************************************************************************
100 *****************************************************************************/
102 void testencrypt(uint8_t* block, uint8_t* key){
103 uart_putstr("\r\n==testy-encrypt==\r\n key: ");
104 uart_hexdump(key,10);
105 uart_putstr("\r\n plain: ");
106 uart_hexdump(block,8);
107 skipjack_enc(block,key);
108 uart_putstr("\r\n crypt: ");
109 uart_hexdump(block,8);
112 void testdecrypt(uint8_t* block, uint8_t* key){
113 uart_putstr("\r\n==testy-decrypt==\r\n key: ");
114 uart_hexdump(key,10);
115 uart_putstr("\r\n crypt: ");
116 uart_hexdump(block,8);
117 skipjack_dec(block,key);
118 uart_putstr("\r\n plain: ");
119 uart_hexdump(block,8);
122 void testrun_skipjack(void){
123 uint8_t key[]={ 0x00, 0x99, 0x88, 0x77, 0x66,
124 0x55, 0x44, 0x33, 0x22, 0x11};
125 uint8_t data[]={ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa};
126 testencrypt(data,key);
127 testdecrypt(data,key);
132 /*****************************************************************************
134 *****************************************************************************/
142 uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
144 PGM_P u = PSTR("nessie\0test\0performance\0");
145 void_fpt v[] = {testrun_nessie_skipjack, testrun_skipjack, testrun_performance_skipjack};
148 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
149 if(execcommand_d0_P(str, u, v)<0){
150 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
154 uart_putstr("ERROR\r\n");