1 /* main-omac-noekeon-test.c */
3 This file is part of the Crypto-avr-lib/microcrypt-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 *****************************************************************************/
160 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
161 uart_putstr(algo_name);
162 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
164 PGM_P u = PSTR("nessie\0test\0performance\0");
165 void_fpt v[] = {testrun_nessie_omac_noekeon,
166 testrun_test_omac_noekeon,
167 testrun_performance_omac_noekeon};
170 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
171 if(execcommand_d0_P(str, u, v)<0){
172 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
176 uart_putstr("ERROR\r\n");