1 /* main-khazad-test.c */
3 This file is part of the ARM-Crypto-Lib.
4 Copyright (C) 2011 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/>.
29 #include "uart_lowlevel.h"
34 #include "performance_test.h"
35 #include "bcal-performance.h"
36 #include "bcal-nessie.h"
37 #include "bcal_khazad.h"
39 char* algo_name = "Khazad";
41 void uart0_putc(char byte){
42 uart_putc(UART_0, byte);
45 char uart0_getc(void){
46 return uart_getc(UART_0);
49 const bcdesc_t* algolist[] = {
50 (bcdesc_t*)&khazad_desc,
54 /*****************************************************************************
55 * additional validation-functions *
56 *****************************************************************************/
58 void testrun_nessie_khazad(void){
59 bcal_nessie(&khazad_desc);
62 void testrun_performance_khazad(void){
63 bcal_performance_multiple(algolist);
66 void test_khazad(void){
74 cli_putstr("\r\nkey: ");
76 khazad_init(key, &ctx);
77 cli_putstr("\r\nround keys:");
78 cli_hexdump_block(&ctx, 8*8, 4, 8);
79 cli_putstr("\r\nplain: ");
81 khazad_enc(data, &ctx);
82 cli_putstr("\r\nencrypt:");
84 khazad_dec(data, &ctx);
85 cli_putstr("\r\ndecrypt:");
91 cli_putstr("\r\nKhazad Sbox:\r\n\t");
103 /*****************************************************************************
105 *****************************************************************************/
107 const char nessie_str[] = "nessie";
108 const char test_str[] = "test";
109 const char test_sbox_str[] = "test_sbox";
110 const char performance_str[] = "performance";
111 const char echo_str[] = "echo";
113 cmdlist_entry_t cmdlist[] = {
114 { nessie_str, NULL, testrun_nessie_khazad},
115 { test_str, NULL, test_khazad},
116 { test_sbox_str, NULL, test_sbox},
117 { performance_str, NULL, testrun_performance_khazad},
118 { echo_str, (void*)1, (void_fpt)echo_ctrl},
123 sysclk_set_freq(SYS_FREQ);
124 sysclk_mosc_verify_enable();
125 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
126 gptm_set_timer_32periodic(TIMER0);
132 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
133 cli_putstr(algo_name);
135 cli_putstr(__DATE__);
137 cli_putstr(__TIME__);
138 cli_putstr(")\r\nloaded and running\r\n");
139 cmd_interface(cmdlist);