3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2006-2010 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 "uart_lowlevel.h"
40 #include "nessie_bc_test.h"
41 #include "performance_test.h"
42 #include "bcal-performance.h"
43 #include "bcal_seed.h"
46 char* algo_name = "Seed";
48 void uart0_putc(char byte){
49 uart_putc(UART_0, byte);
52 char uart0_getc(void){
53 return uart_getc(UART_0);
56 const bcdesc_t* algolist[] = {
57 (bcdesc_t*)&seed_desc,
60 /*****************************************************************************
61 * additional validation-functions *
62 *****************************************************************************/
63 void seed_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
67 void testrun_nessie_seed(void){
68 nessie_bc_ctx.blocksize_B = 16;
69 nessie_bc_ctx.keysize_b = 128;
70 nessie_bc_ctx.name = algo_name;
71 nessie_bc_ctx.ctx_size_B = sizeof(seed_ctx_t);
72 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)seed_enc;
73 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)seed_dec;
74 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)seed_genctx_dummy;
81 void testrun_performance_seed(void){
82 bcal_performance_multiple(algolist);
85 /*****************************************************************************
87 *****************************************************************************/
89 void testencrypt(uint8_t* block, uint8_t* key){
91 cli_putstr("\r\n==testy-encrypt==\r\n key: ");
94 cli_putstr("\r\n plain: ");
95 cli_hexdump(block,16);
96 seed_enc(block, &ctx);
97 cli_putstr("\r\n crypt: ");
98 cli_hexdump(block,16);
101 void testdecrypt(uint8_t* block, uint8_t* key){
103 cli_putstr("\r\n==testy-decrypt==\r\n key: ");
105 seed_init(key, &ctx);
106 cli_putstr("\r\n crypt: ");
107 cli_hexdump(block,16);
108 seed_dec(block, &ctx);
109 cli_putstr("\r\n plain: ");
110 cli_hexdump(block,16);
113 void testrun_seed(void){
115 { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
117 { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
118 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
119 { 0x47, 0x06, 0x48, 0x08, 0x51, 0xE6, 0x1B, 0xE8,
120 0x5D, 0x74, 0xBF, 0xB3, 0xFD, 0x95, 0x61, 0x85 },
121 { 0x28, 0xDB, 0xC3, 0xBC, 0x49, 0xFF, 0xD8, 0x7D,
122 0xCF, 0xA5, 0x09, 0xB1, 0x1D, 0x42, 0x2B, 0xE7,}
124 uint8_t datas[4][16]=
125 { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
126 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f },
127 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
128 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
129 { 0x83, 0xA2, 0xF8, 0xA2, 0x88, 0x64, 0x1F, 0xB9,
130 0xA4, 0xE9, 0xA5, 0xCC, 0x2F, 0x13, 0x1C, 0x7D },
131 { 0xB4, 0x1E, 0x6B, 0xE2, 0xEB, 0xA8, 0x4A, 0x14,
132 0x8E, 0x2E, 0xED, 0x84, 0x59, 0x3C, 0x5E, 0xC7 }
136 testencrypt(datas[i],keys[i]);
137 testdecrypt(datas[i],keys[i]);
143 /*****************************************************************************
145 *****************************************************************************/
147 const char nessie_str[] = "nessie";
148 const char test_str[] = "test";
149 const char performance_str[] = "performance";
150 const char echo_str[] = "echo";
152 cmdlist_entry_t cmdlist[] = {
153 { nessie_str, NULL, testrun_nessie_seed},
154 { test_str, NULL, testrun_seed},
155 { performance_str, NULL, testrun_performance_seed},
156 { echo_str, (void*)1, (void_fpt)echo_ctrl},
161 sysclk_set_freq(SYS_FREQ);
162 sysclk_mosc_verify_enable();
163 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
164 gptm_set_timer_32periodic(TIMER0);
170 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
171 cli_putstr(algo_name);
173 cli_putstr(__DATE__);
175 cli_putstr(__TIME__);
176 cli_putstr(")\r\nloaded and running\r\n");
177 cmd_interface(cmdlist);