1 /* main-omac-noekeon-test.c */
3 This file is part of the AVR-Crypto-Lib.
4 Copyright (C) 2008 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/>.
20 * OMAC-Noekeon test-suit
25 #include "serial-tools.h"
30 #include "omac_noekeon.h"
33 #include "nessie_mac_test.h"
34 #include "performance_test.h"
40 char* algo_name = "OMAC-Noekeon";
42 /*****************************************************************************
43 * additional validation-functions *
44 *****************************************************************************/
46 void test_mac(void* key, void* data, uint16_t datalength_b){
48 uart_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
49 uart_hexdump(((uint8_t*)&datalength_b)+1, 1);
50 uart_hexdump(((uint8_t*)&datalength_b)+0, 1);
51 uart_putstr_P(PSTR("\r\n msg: "));
52 uart_hexdump(data, (datalength_b+7)/8);
53 uart_putstr_P(PSTR("\r\n key: "));
54 uart_hexdump(key, 16);
55 omac_noekeon(mac, data, datalength_b, key, (uint8_t)-1);
56 uart_putstr_P(PSTR("\r\n mac: "));
57 uart_hexdump(mac, 16);
61 void testrun_test_omac_noekeon(void){
62 uint8_t key[16], data[64];
64 memset(key, 0xAA, 16);
65 memset(data, 0x00, 64);
67 test_mac(key, data, i);
71 /******************************************************************************/
75 void omac_noekeon_next_dummy(void* buffer, void* ctx){
76 omac_noekeon_next(buffer, stat_key, ctx);
79 void omac_noekeon_init_dummy(void* key, uint16_t keysize_b, void* ctx){
80 omac_noekeon_init(ctx);
81 memcpy(stat_key, key, 16);
84 void omac_noekeon_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
86 omac_noekeon_next(buffer, key, ctx);
88 buffer = (uint8_t*)buffer +16;
90 omac_noekeon_last(buffer, size_b, key, ctx);
93 void omac_noekeon_conv_dummy(void* buffer, void* ctx){
94 memcpy(buffer, ctx, 16);
97 void testrun_nessie_omac_noekeon(void){
98 nessie_mac_ctx.macsize_b = 128;
99 nessie_mac_ctx.keysize_b = 128;
100 nessie_mac_ctx.blocksize_B = 16;
101 nessie_mac_ctx.ctx_size_B = sizeof(omac_noekeon_ctx_t);
102 nessie_mac_ctx.name = algo_name;
103 nessie_mac_ctx.mac_init = omac_noekeon_init_dummy;
104 nessie_mac_ctx.mac_next = omac_noekeon_next_dummy;
105 nessie_mac_ctx.mac_last = omac_noekeon_last_dummy;
106 nessie_mac_ctx.mac_conv = omac_noekeon_conv_dummy;
111 /******************************************************************************/
113 void testrun_performance_omac_noekeon(void){
116 uint8_t data[16], key[16];
117 omac_noekeon_ctx_t ctx;
126 omac_noekeon_init(&ctx);
128 uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
129 ultoa((unsigned long)t, str, 10);
134 omac_noekeon_next(data, key, &ctx);
136 uart_putstr_P(PSTR("\r\n\tone-block time: "));
137 ultoa((unsigned long)t, str, 10);
142 omac_noekeon_last(data, 128, key, &ctx);
144 uart_putstr_P(PSTR("\r\n\tlast block time: "));
145 ultoa((unsigned long)t, str, 10);
148 uart_putstr_P(PSTR("\r\n"));
151 /*****************************************************************************
153 *****************************************************************************/
155 const char nessie_str[] PROGMEM = "nessie";
156 const char test_str[] PROGMEM = "test";
157 const char performance_str[] PROGMEM = "performance";
158 const char echo_str[] PROGMEM = "echo";
160 cmdlist_entry_t cmdlist[] PROGMEM = {
161 { nessie_str, NULL, testrun_nessie_omac_noekeon },
162 { test_str, NULL, testrun_test_omac_noekeon},
163 { performance_str, NULL, testrun_performance_omac_noekeon},
164 { echo_str, (void*)1, (void_fpt)echo_ctrl},
174 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
175 uart_putstr(algo_name);
176 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
177 cmd_interface(cmdlist);