1 /* main-skipjack-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 "nessie_bc_test.h"
28 #include "performance_test.h"
29 #include "bcal-performance.h"
30 #include "bcal-nessie.h"
31 #include "bcal_skipjack.h"
33 char *algo_name = "Skipjack";
35 const bcdesc_t *const algolist[] PROGMEM = {
36 (bcdesc_t*)&skipjack_desc,
39 /*****************************************************************************
40 * additional validation-functions *
41 *****************************************************************************/
42 void skipjack_genctx_dummy(uint8_t *key, uint16_t keysize, void *ctx){
46 void testrun_nessie_skipjack(void){
47 bcal_nessie_multiple(algolist);
51 void testrun_performance_skipjack(void){
52 bcal_performance_multiple(algolist);
55 int test_enc(const void *buffer, void *key){
58 memcpy(data, buffer, 8);
59 skipjack_enc(data, key);
60 cli_putstr_P(PSTR(" key = "));
62 cli_putstr_P(PSTR(" plaintext = "));
63 cli_hexdump(buffer, 8);
64 cli_putstr_P(PSTR(" ciphertext = "));
66 skipjack_dec(data, key);
67 r = memcmp(data, buffer, 8);
68 cli_putstr_P(PSTR(" decrypt: "));
70 cli_putstr_P(PSTR("fail"));
72 cli_putstr_P(PSTR("ok"));
77 void testrun_nist_vectors(void){
82 cli_putstr_P(PSTR("\r\n\r\n=== NIST vectors run 1 ==="));
86 data[i>>3] |= 0x80 >> (i & 7);
87 cli_putstr_P(PSTR("\r\n round: 0x"));
92 cli_putstr_P(PSTR("\r\n\r\n=== NIST vectors run 2 ==="));
96 key[i>>3] |= 0x80 >> (i & 7);
97 cli_putstr_P(PSTR("\r\n round: 0x"));
103 /*****************************************************************************
105 *****************************************************************************/
107 void testencrypt(uint8_t *block, uint8_t *key){
108 cli_putstr("\r\n==testy-encrypt==\r\n key: ");
110 cli_putstr("\r\n plain: ");
111 cli_hexdump(block,8);
112 skipjack_enc(block,key);
113 cli_putstr("\r\n crypt: ");
114 cli_hexdump(block,8);
117 void testdecrypt(uint8_t *block, uint8_t *key){
118 cli_putstr("\r\n==testy-decrypt==\r\n key: ");
120 cli_putstr("\r\n crypt: ");
121 cli_hexdump(block,8);
122 skipjack_dec(block,key);
123 cli_putstr("\r\n plain: ");
124 cli_hexdump(block,8);
127 void testrun_skipjack(void){
129 { 0x00, 0x99, 0x88, 0x77, 0x66,
130 0x55, 0x44, 0x33, 0x22, 0x11 },
131 { 0x11, 0x22, 0x33, 0x44, 0x55,
132 0x66, 0x77, 0x88, 0x99, 0x00 }
136 { 0x33, 0x22, 0x11, 0x00,
137 0xdd, 0xcc, 0xbb, 0xaa },
138 { 0xaa, 0xbb, 0xcc, 0xdd,
139 0x00, 0x11, 0x22, 0x33 }
141 testencrypt(data[0],key[0]);
142 testdecrypt(data[0],key[0]);
143 testencrypt(data[1],key[1]);
144 testdecrypt(data[1],key[1]);
149 /*****************************************************************************
151 *****************************************************************************/
153 const char nessie_str[] PROGMEM = "nessie";
154 const char test_str[] PROGMEM = "test";
155 const char nist_str[] PROGMEM = "nist";
156 const char performance_str[] PROGMEM = "performance";
157 const char echo_str[] PROGMEM = "echo";
159 const cmdlist_entry_t cmdlist[] PROGMEM = {
160 { nessie_str, NULL, testrun_nessie_skipjack},
161 { test_str, NULL, testrun_skipjack},
162 { nist_str, NULL, testrun_nist_vectors},
163 { performance_str, NULL, testrun_performance_skipjack},
164 { echo_str, (void*)1, (void_fpt)echo_ctrl},
172 welcome_msg(algo_name);
173 cmd_interface(cmdlist);