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){
64 uint8_t key[10], data[8];
73 skipjack_enc(data, key);
75 uart_putstr_P(PSTR("\r\n\tencrypt time: "));
76 ultoa((unsigned long)t, str, 10);
81 skipjack_dec(data, key);
83 uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
84 ultoa((unsigned long)t, str, 10);
87 uart_putstr_P(PSTR("\r\n"));
90 /*****************************************************************************
92 *****************************************************************************/
94 void testencrypt(uint8_t* block, uint8_t* key){
95 uart_putstr("\r\n==testy-encrypt==\r\n key: ");
97 uart_putstr("\r\n plain: ");
98 uart_hexdump(block,8);
99 skipjack_enc(block,key);
100 uart_putstr("\r\n crypt: ");
101 uart_hexdump(block,8);
104 void testdecrypt(uint8_t* block, uint8_t* key){
105 uart_putstr("\r\n==testy-decrypt==\r\n key: ");
106 uart_hexdump(key,10);
107 uart_putstr("\r\n crypt: ");
108 uart_hexdump(block,8);
109 skipjack_dec(block,key);
110 uart_putstr("\r\n plain: ");
111 uart_hexdump(block,8);
114 void testrun_skipjack(void){
116 { 0x00, 0x99, 0x88, 0x77, 0x66,
117 0x55, 0x44, 0x33, 0x22, 0x11 },
118 { 0x11, 0x22, 0x33, 0x44, 0x55,
119 0x66, 0x77, 0x88, 0x99, 0x00 }
123 { 0x33, 0x22, 0x11, 0x00,
124 0xdd, 0xcc, 0xbb, 0xaa },
125 { 0xaa, 0xbb, 0xcc, 0xdd,
126 0x00, 0x11, 0x22, 0x33 }
128 testencrypt(data[0],key[0]);
129 testdecrypt(data[0],key[0]);
130 testencrypt(data[1],key[1]);
131 testdecrypt(data[1],key[1]);
136 /*****************************************************************************
138 *****************************************************************************/
146 uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
148 PGM_P u = PSTR("nessie\0test\0performance\0");
149 void_fpt v[] = {testrun_nessie_skipjack, testrun_skipjack, testrun_performance_skipjack};
152 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
153 if(execcommand_d0_P(str, u, v)<0){
154 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
158 uart_putstr("ERROR\r\n");