]> git.cryptolib.org Git - arm-crypto-lib.git/blob - test_src/main-rc6-test.c
bigint looks good but needs more testing
[arm-crypto-lib.git] / test_src / main-rc6-test.c
1 /* main-rc6-test.c */
2 /*
3     This file is part of the ARM-Crypto-Lib.
4     Copyright (C) 2006-2010  Daniel Otte (daniel.otte@rub.de)
5
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.
10
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.
15
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/>.
18 */
19 /*
20  * rc6 test-suit
21  * 
22 */
23
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <string.h>
27 #include "config.h"
28 #include "cli.h"
29 #include "dump.h"
30 #include "uart_lowlevel.h"
31 #include "sysclock.h"
32 #include "hw_gptm.h"
33
34 #include "rc6.h"
35 #include "nessie_bc_test.h"
36 #include "performance_test.h"
37 #include "bcal-performance.h"
38 #include "bcal_rc6.h"
39
40 #include <stdint.h>
41 #include <string.h>
42 #include <stdlib.h>
43
44 #define RC6_ROUNDS 20
45 char* algo_name = "RC6-32/20/16";
46
47 void uart0_putc(char byte){
48         uart_putc(UART_0, byte);
49 }
50
51 char uart0_getc(void){
52         return uart_getc(UART_0);
53 }
54
55 const bcdesc_t* algolist[] = {
56         (bcdesc_t*)&rc6_desc,
57         NULL
58 };
59 /*****************************************************************************
60  *  additional validation-functions                                                                                      *
61  *****************************************************************************/
62
63 void testrun_nessie_rc6(void){
64         nessie_bc_init();
65         nessie_bc_ctx.blocksize_B =  16;
66         nessie_bc_ctx.keysize_b   = 128;
67         nessie_bc_ctx.name        = algo_name;
68         nessie_bc_ctx.ctx_size_B  = sizeof(rc6_ctx_t);
69         nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)rc6_enc;
70         nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)rc6_dec;
71         nessie_bc_ctx.cipher_free = (nessie_bc_free_fpt)rc6_free;
72         nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)rc6_init;
73         
74         nessie_bc_run();
75         
76         nessie_bc_ctx.keysize_b   = 192;
77         nessie_bc_run();
78         
79         nessie_bc_ctx.keysize_b   = 256;
80         nessie_bc_run();
81         
82 }
83
84
85 void testrun_performance_rc6(void){
86         bcal_performance_multiple(algolist);
87 }
88 /*****************************************************************************
89  *  main                                                                                                                                         *
90  *****************************************************************************/
91
92 const char nessie_str[]      = "nessie";
93 const char test_str[]        = "test";
94 const char performance_str[] = "performance";
95 const char echo_str[]        = "echo";
96
97 const cmdlist_entry_t cmdlist[] = {
98         { nessie_str,      NULL, testrun_nessie_rc6},
99         { test_str,        NULL, testrun_nessie_rc6},
100         { performance_str, NULL, testrun_performance_rc6},
101         { echo_str,    (void*)1, (void_fpt)echo_ctrl},
102         { NULL,            NULL, NULL}
103 };
104
105 int main (void){
106         sysclk_set_freq(SYS_FREQ);
107         sysclk_mosc_verify_enable();
108         uart_init_flow(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE, UART_FLOWCTRL_SOFT);
109         gptm_set_timer_32periodic(TIMER0);
110         
111         cli_rx = (cli_rx_fpt)uart0_getc;
112         cli_tx = (cli_tx_fpt)uart0_putc;                
113         for(;;){
114                 cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
115                 cli_putstr(algo_name);
116                 cli_putstr("; ");
117                 cli_putstr(__DATE__);
118                 cli_putc(' ');
119                 cli_putstr(__TIME__);
120                 cli_putstr(")\r\nloaded and running\r\n");
121         cmd_interface(cmdlist);
122     }
123 }