]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-cast6-test.c
fixing some decryption bugs in GCM128
[avr-crypto-lib.git] / test_src / main-cast6-test.c
1 /*
2  * rc6 test-suit
3  * 
4 */
5
6 #include "main-test-common.h"
7
8 #include "cast6.h"
9 #include "performance_test.h"
10 #include "bcal-performance.h"
11 #include "bcal-nessie.h"
12 #include "bcal_cast6.h"
13
14 char *algo_name = "CAST-256";
15
16 const bcdesc_t *const algolist[] PROGMEM = {
17         (bcdesc_t*)&cast6_desc,
18         NULL
19 };
20
21 /*****************************************************************************
22  *  additional validation-functions                                                                                      *
23  *****************************************************************************/
24
25
26 void testrun_nessie_cast6(void){
27         bcal_nessie_multiple(algolist);
28 }
29
30 void testrun_rfc_cast6(void){
31         cli_putstr_P(PSTR("\r\n testvalues from rfc-2612\r\n"));
32         uint8_t key[32], data[16];
33         cast6_ctx_t ctx;
34         memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
35                            "\x0a\xf7\x56\x47\xf2\x9f\x61\x5d"), 16);
36         memset(data, 0, 16);
37         
38         cli_putstr_P(PSTR("\r\n key: "));
39         cli_hexdump(key, 16);
40         cli_putstr_P(PSTR("\r\n PT:  "));
41         cli_hexdump(data, 16);
42         cast6_init(key, 128, &ctx);
43         cast6_enc(data, &ctx);
44         cli_putstr_P(PSTR("\r\n CT:  "));
45         cli_hexdump(data, 16);
46         cast6_dec(data, &ctx);
47         cli_putstr_P(PSTR("\r\n PT:  "));
48         cli_hexdump(data, 16);
49         
50         cli_putstr_P(PSTR("\r\n\r\n"));
51
52         memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
53                            "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
54                                        "\xba\xc7\x7a\x77\x17\x94\x28\x63"), 24);
55         
56         cli_putstr_P(PSTR("\r\n key: "));
57         cli_hexdump(key, 24);
58         cli_putstr_P(PSTR("\r\n PT:  "));
59         cli_hexdump(data, 16);
60         cast6_init(key, 192, &ctx);
61         cast6_enc(data, &ctx);
62         cli_putstr_P(PSTR("\r\n CT:  "));
63         cli_hexdump(data, 16);
64         cast6_dec(data, &ctx);
65         cli_putstr_P(PSTR("\r\n PT:  "));
66         cli_hexdump(data, 16);
67         
68         cli_putstr_P(PSTR("\r\n\r\n"));
69         
70         memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
71                            "\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
72                                        "\x8d\x7c\x47\xce\x26\x49\x08\x46"
73                                        "\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04"), 32);
74         cli_putstr_P(PSTR("\r\n key: "));
75         cli_hexdump(key, 32);
76         cli_putstr_P(PSTR("\r\n PT:  "));
77         cli_hexdump(data, 16);
78         cast6_init(key, 256, &ctx);
79         cast6_enc(data, &ctx);
80         cli_putstr_P(PSTR("\r\n CT:  "));
81         cli_hexdump(data, 16);
82         cast6_dec(data, &ctx);
83         cli_putstr_P(PSTR("\r\n PT:  "));
84         cli_hexdump(data, 16);
85         
86         cli_putstr_P(PSTR("\r\n\r\n"));
87 }
88
89 void testrun_performance_cast6(void){
90         bcal_performance_multiple(algolist);
91 }
92
93 /*****************************************************************************
94  *  main                                                                                                                                         *
95  *****************************************************************************/
96
97 const char nessie_str[]      PROGMEM = "nessie";
98 const char test_str[]        PROGMEM = "test";
99 const char performance_str[] PROGMEM = "performance";
100 const char echo_str[]        PROGMEM = "echo";
101
102 const cmdlist_entry_t cmdlist[] PROGMEM = {
103         { nessie_str,      NULL, testrun_nessie_cast6 },
104         { test_str,        NULL, testrun_rfc_cast6},
105         { performance_str, NULL, testrun_performance_cast6},
106         { echo_str,    (void*)1, (void_fpt)echo_ctrl},
107         { NULL,            NULL, NULL}
108 };
109
110 int main (void){
111     main_setup();
112
113     for(;;){
114         welcome_msg(algo_name);
115         cmd_interface(cmdlist);
116         }
117 }