]> git.cryptolib.org Git - avr-crypto-lib.git/blob - test_src/main-bmw-test.c
fixing E-Mail-Address & Copyright
[avr-crypto-lib.git] / test_src / main-bmw-test.c
1 /* main-bmw-test.c */
2 /*
3     This file is part of the AVR-Crypto-Lib.
4     Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org)
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  * BlueMidnightWish test-suit
21  *
22 */
23
24 #include "main-test-common.h"
25
26 #include "bmw_small.h"
27 #include "bmw_large.h"
28 #include "hfal_bmw_small.h"
29 #include "hfal_bmw_large.h"
30
31 #include "shavs.h"
32 #include "nessie_hash_test.h"
33 #include "hfal-nessie.h"
34 #include "hfal-performance.h"
35 #include "hfal-test.h"
36 #include "performance_test.h"
37
38 char *algo_name = "BlueMidnightWish";
39
40
41 const hfdesc_t *const algolist[] PROGMEM = {
42         (hfdesc_t*)&bmw224_desc,
43         (hfdesc_t*)&bmw256_desc,
44         (hfdesc_t*)&bmw384_desc,
45         (hfdesc_t*)&bmw512_desc,
46         NULL
47 };
48
49 /*****************************************************************************
50  *  additional validation-functions                                                                                      *
51  *****************************************************************************/
52
53 void performance_bmw(void){
54         hfal_performance_multiple(algolist);
55 }
56
57 void testrun_nessie_bmw(void){
58         hfal_nessie_multiple(algolist);
59 }
60
61 void bmw224_test(void *msg, uint32_t length_b){
62         hfal_test(&bmw224_desc, msg, length_b);
63 }
64
65 void bmw256_test(void *msg, uint32_t length_b){
66         hfal_test(&bmw256_desc, msg, length_b);
67 }
68 void bmw384_test(void *msg, uint32_t length_b){
69         hfal_test(&bmw384_desc, msg, length_b);
70 }
71
72 void bmw512_test(void *msg, uint32_t length_b){
73         hfal_test(&bmw512_desc, msg, length_b);
74 }
75
76 void test506(void){
77         /* Testvector of length = 506 from short KAT */
78         uint8_t v[] = {
79                 0xB9, 0xE3, 0xE2, 0x75, 0x5E, 0xD1, 0x21, 0x53,
80                 0x81, 0xB2, 0x45, 0x57, 0xEE, 0x14, 0xF8, 0xCD,
81                 0x26, 0x87, 0xA0, 0x71, 0xAE, 0xB3, 0xC7, 0x4F,
82                 0x42, 0x1C, 0xFE, 0xA3, 0xCF, 0xF8, 0xA6, 0xEA,
83                 0x0D, 0x4B, 0xDA, 0x2A, 0xD4, 0xBD, 0x82, 0x43,
84                 0xCB, 0xA7, 0x2B, 0x48, 0x1C, 0xBD, 0x52, 0x6E,
85                 0x1E, 0xFA, 0x1D, 0x9F, 0xD4, 0x32, 0xB9, 0x87,
86                 0xE8, 0x12, 0x65, 0x82, 0x44, 0x29, 0xBA, 0xC0 };
87         bmw512_test(v, 506);
88 }
89
90 void test507(void){
91         /* Testvector of length = 506 from short KAT */
92         uint8_t v[] = {
93                 0xE8, 0x33, 0x25, 0x35, 0xE9, 0xA2, 0x05, 0x24,
94                 0x67, 0xA1, 0x02, 0x05, 0xC8, 0x70, 0x00, 0xBF,
95                 0xC6, 0xA6, 0x8D, 0x73, 0x96, 0x2E, 0x69, 0xE4,
96                 0xE5, 0x6F, 0x10, 0xBC, 0x79, 0xC6, 0x33, 0xC5,
97                 0x2F, 0x4D, 0x00, 0x74, 0xD6, 0x07, 0x75, 0x95,
98                 0xB6, 0x60, 0x07, 0x2E, 0x10, 0x74, 0x0D, 0xFA,
99                 0x66, 0xBC, 0x13, 0x20, 0x46, 0x9A, 0x31, 0x96,
100                 0xE0, 0x21, 0xE1, 0x32, 0x7C, 0xC0, 0x3A, 0xE0 };
101         bmw512_test(v, 507);
102 }
103
104 void testrun_stdtest_bmw(void){
105         char *msg0 = "abc";
106         char *msg1 = "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq";
107         bmw224_test(msg0, strlen(msg0)*8);
108         bmw224_test(msg1, strlen(msg1)*8);
109         bmw256_test(msg0, strlen(msg0)*8);
110         bmw256_test(msg1, strlen(msg1)*8);
111         bmw384_test(msg0, strlen(msg0)*8);
112         bmw384_test(msg1, strlen(msg1)*8);
113         bmw512_test(msg0, strlen(msg0)*8);
114         bmw512_test(msg1, strlen(msg1)*8);
115 }
116
117 void bmw256_short_test(void *msg, uint32_t length_b){
118         bmw256_test("abc", 3*8);
119 }
120
121
122 void testshort(void){
123         char *msg0 = "abc";
124         bmw224_test(msg0, strlen(msg0)*8);
125 }
126
127 void testlshort(void){
128         char *msg0 = "abc";
129         bmw384_test(msg0, strlen(msg0)*8);
130 }
131
132 /*****************************************************************************
133  *  main                                                                                                                                         *
134  *****************************************************************************/
135
136 const char nessie_str[]      PROGMEM = "nessie";
137 const char test_str[]        PROGMEM = "test";
138 const char test224_str[]     PROGMEM = "test224";
139 const char test256_str[]     PROGMEM = "test256";
140 const char test384_str[]     PROGMEM = "test384";
141 const char test512_str[]     PROGMEM = "test512";
142 const char test506_str[]     PROGMEM = "506";
143 const char test507_str[]     PROGMEM = "507";
144 const char testshort_str[]   PROGMEM = "short";
145 const char testlshort_str[]  PROGMEM = "lshort";
146 const char performance_str[] PROGMEM = "performance";
147 const char echo_str[]        PROGMEM = "echo";
148 const char shavs_list_str[]  PROGMEM = "shavs_list";
149 const char shavs_set_str[]   PROGMEM = "shavs_set";
150 const char shavs_test1_str[] PROGMEM = "shavs_test1";
151 const char shavs_test3_str[] PROGMEM = "shavs_test3";
152
153 const cmdlist_entry_t cmdlist[] PROGMEM = {
154         { nessie_str,                  NULL, testrun_nessie_bmw            },
155         { test_str,                    NULL, testrun_stdtest_bmw           },
156         { testshort_str,               NULL, testshort                     },
157         { testlshort_str,              NULL, testlshort                    },
158         { test506_str,                 NULL, test506                       },
159         { test507_str,                 NULL, test507                       },
160         { performance_str,             NULL, performance_bmw               },
161         { shavs_list_str,              NULL, shavs_listalgos               },
162         { shavs_set_str,           (void*)1, (void_fpt)shavs_setalgo       },
163         { shavs_test1_str,             NULL, shavs_test1                   },
164         { shavs_test3_str,             NULL, shavs_test3                   },
165         { echo_str,                (void*)1, (void_fpt)echo_ctrl           },
166         { NULL,                        NULL, NULL                          }
167 };
168
169 int main (void){
170     main_setup();
171
172     shavs_algolist=(hfdesc_t**)algolist;
173         shavs_algo=(hfdesc_t*)&bmw256_desc;
174         for(;;){
175             welcome_msg(algo_name);
176                 cmd_interface(cmdlist);
177         }
178 }