1 /* main-serpent-test.c */
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/>.
29 #include "uart_lowlevel.h"
35 #include "nessie_bc_test.h"
36 #include "performance_test.h"
37 #include "bcal-performance.h"
38 #include "bcal_serpent.h"
40 char* algo_name = "Serpent";
42 void uart0_putc(char byte){
43 uart_putc(UART_0, byte);
46 char uart0_getc(void){
47 return uart_getc(UART_0);
50 const bcdesc_t* algolist[] = {
51 (bcdesc_t*)&serpent_desc,
55 /*****************************************************************************
56 * additional validation-functions *
57 *****************************************************************************/
59 void testrun_nessie_serpent(void){
60 nessie_bc_ctx.blocksize_B = 16;
61 nessie_bc_ctx.keysize_b = 128;
62 nessie_bc_ctx.name = algo_name;
63 nessie_bc_ctx.ctx_size_B = sizeof(serpent_ctx_t);
64 nessie_bc_ctx.cipher_enc = (nessie_bc_enc_fpt)serpent_enc;
65 nessie_bc_ctx.cipher_dec = (nessie_bc_dec_fpt)serpent_dec;
66 nessie_bc_ctx.cipher_genctx = (nessie_bc_gen_fpt)serpent_init;
70 nessie_bc_ctx.keysize_b = 192;
73 nessie_bc_ctx.keysize_b = 256;
77 void testrun_test_serpent(void){
82 serpent_init(key, 128, &ctx);
84 cli_putstr("\r\n subkekey ");
87 cli_hexdump(ctx.k[i], 16);
91 void testrun_serpent256(void){
98 cli_putstr("\r\n== small test Serpent-256 ==");
99 cli_putstr("\r\n key = ");
100 cli_hexdump(key, 32);
101 cli_putstr("\r\n plain = ");
102 cli_hexdump(data, 16);
103 serpent_init(key, 256, &ctx);
104 serpent_enc(data, &ctx);
105 cli_putstr("\r\n cipher = ");
106 cli_hexdump(data, 16);
109 void testrun_performance_serpent(void){
110 bcal_performance_multiple(algolist);
112 /*****************************************************************************
114 *****************************************************************************/
116 const char nessie_str[] = "nessie";
117 const char test_str[] = "test";
118 const char test256_str[] = "test256";
119 const char performance_str[] = "performance";
120 const char echo_str[] = "echo";
122 const cmdlist_entry_t cmdlist[] = {
123 { nessie_str, NULL, testrun_nessie_serpent},
124 { test_str, NULL, testrun_test_serpent},
125 { test256_str, NULL, testrun_serpent256},
126 { performance_str, NULL, testrun_performance_serpent},
127 { echo_str, (void*)1, (void_fpt)echo_ctrl},
132 sysclk_set_freq(SYS_FREQ);
133 sysclk_mosc_verify_enable();
134 uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
135 gptm_set_timer_32periodic(TIMER0);
141 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
142 cli_putstr(algo_name);
144 cli_putstr(__DATE__);
146 cli_putstr(__TIME__);
147 cli_putstr(")\r\nloaded and running\r\n");
148 cmd_interface(cmdlist);