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/>.
20 * \file main-seed-test.c
22 * \email daniel.otte@rub.de
24 * \brief test suit for SEED
35 #include "nessie_bc_test.h"
37 #include "performance_test.h"
38 #include "bcal-performance.h"
39 #include "bcal_seed.h"
45 char* algo_name = "Seed";
47 const bcdesc_t* algolist[] PROGMEM = {
48 (bcdesc_t*)&seed_desc,
51 /*****************************************************************************
52 * additional validation-functions *
53 *****************************************************************************/
54 void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
58 void testrun_nessie_seed(void){
59 nessie_bc_ctx.blocksize_B = 16;
60 nessie_bc_ctx.keysize_b = 128;
61 nessie_bc_ctx.name = algo_name;
62 nessie_bc_ctx.ctx_size_B = sizeof(seed_ctx_t);
63 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)seed_enc;
64 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)seed_dec;
65 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)seed_genctx_dummy;
72 void testrun_performance_seed(void){
73 bcal_performance_multiple(algolist);
76 /*****************************************************************************
78 *****************************************************************************/
80 void testencrypt(uint8_t* block, uint8_t* key){
82 cli_putstr("\r\n==testy-encrypt==\r\n key: ");
85 cli_putstr("\r\n plain: ");
86 cli_hexdump(block,16);
87 seed_enc(block, &ctx);
88 cli_putstr("\r\n crypt: ");
89 cli_hexdump(block,16);
92 void testdecrypt(uint8_t* block, uint8_t* key){
94 cli_putstr("\r\n==testy-decrypt==\r\n key: ");
97 cli_putstr("\r\n crypt: ");
98 cli_hexdump(block,16);
99 seed_dec(block, &ctx);
100 cli_putstr("\r\n plain: ");
101 cli_hexdump(block,16);
104 void testrun_seed(void){
106 { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
107 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
108 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
109 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
110 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
111 0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
112 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
113 0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
115 uint8_t datas[4][16]=
116 { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
117 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
118 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
119 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
120 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9,
121 0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
122 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14,
123 0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
127 testencrypt(datas[i],keys[i]);
128 testdecrypt(datas[i],keys[i]);
134 /*****************************************************************************
136 *****************************************************************************/
138 const char nessie_str[] PROGMEM = "nessie";
139 const char test_str[] PROGMEM = "test";
140 const char performance_str[] PROGMEM = "performance";
141 const char echo_str[] PROGMEM = "echo";
143 cmdlist_entry_t cmdlist[] PROGMEM = {
144 { nessie_str, NULL, testrun_nessie_seed},
145 { test_str, NULL, testrun_seed},
146 { performance_str, NULL, testrun_performance_seed},
147 { echo_str, (void*)1, (void_fpt)echo_ctrl},
154 cli_rx = (cli_rx_fpt)uart0_getc;
155 cli_tx = (cli_tx_fpt)uart0_putc;
157 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
158 cli_putstr(algo_name);
159 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
160 cmd_interface(cmdlist);