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
24 #include "main-test-common.h"
27 #include "omac_noekeon.h"
29 #include "nessie_mac_test.h"
30 #include "performance_test.h"
32 char *algo_name = "OMAC-Noekeon";
34 /*****************************************************************************
35 * additional validation-functions *
36 *****************************************************************************/
38 void test_mac(void *key, void *data, uint16_t datalength_b){
40 cli_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
41 cli_hexdump(((uint8_t*)&datalength_b)+1, 1);
42 cli_hexdump(((uint8_t*)&datalength_b)+0, 1);
43 cli_putstr_P(PSTR("\r\n msg: "));
44 cli_hexdump(data, (datalength_b+7)/8);
45 cli_putstr_P(PSTR("\r\n key: "));
47 omac_noekeon(mac, data, datalength_b, key, (uint8_t)-1);
48 cli_putstr_P(PSTR("\r\n mac: "));
53 void testrun_test_omac_noekeon(void){
54 uint8_t key[16], data[64];
56 memset(key, 0xAA, 16);
57 memset(data, 0x00, 64);
59 test_mac(key, data, i);
63 /******************************************************************************/
67 void omac_noekeon_next_dummy(void *ctx, const void *buffer){
68 omac_noekeon_next(buffer, stat_key, ctx);
71 void omac_noekeon_init_dummy(void *ctx, const void *key, uint16_t keysize_b){
72 omac_noekeon_init(ctx);
73 memcpy(stat_key, key, 16);
76 void omac_noekeon_last_dummy(void *ctx, const void *buffer, uint16_t size_b){
78 omac_noekeon_next(buffer, stat_key, ctx);
80 buffer = (uint8_t*)buffer +16;
82 omac_noekeon_last(buffer, size_b, stat_key, ctx);
85 void omac_noekeon_conv_dummy(void *buffer, void *ctx){
86 memcpy(buffer, ctx, 16);
89 void testrun_nessie_omac_noekeon(void){
90 nessie_mac_ctx.macsize_b = 128;
91 nessie_mac_ctx.keysize_b = 128;
92 nessie_mac_ctx.blocksize_B = 16;
93 nessie_mac_ctx.ctx_size_B = sizeof(omac_noekeon_ctx_t);
94 nessie_mac_ctx.name = algo_name;
95 nessie_mac_ctx.mac_init = omac_noekeon_init_dummy;
96 nessie_mac_ctx.mac_next = omac_noekeon_next_dummy;
97 nessie_mac_ctx.mac_last = omac_noekeon_last_dummy;
98 nessie_mac_ctx.mac_conv = omac_noekeon_conv_dummy;
103 /******************************************************************************/
105 void testrun_performance_omac_noekeon(void){
108 uint8_t data[16], key[16];
109 omac_noekeon_ctx_t ctx;
118 omac_noekeon_init(&ctx);
120 cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
121 ultoa((unsigned long)t, str, 10);
126 omac_noekeon_next(data, key, &ctx);
128 cli_putstr_P(PSTR("\r\n\tone-block time: "));
129 ultoa((unsigned long)t, str, 10);
134 omac_noekeon_last(data, 128, key, &ctx);
136 cli_putstr_P(PSTR("\r\n\tlast block time: "));
137 ultoa((unsigned long)t, str, 10);
140 cli_putstr_P(PSTR("\r\n"));
143 /*****************************************************************************
145 *****************************************************************************/
147 const char nessie_str[] PROGMEM = "nessie";
148 const char test_str[] PROGMEM = "test";
149 const char performance_str[] PROGMEM = "performance";
150 const char echo_str[] PROGMEM = "echo";
152 const cmdlist_entry_t cmdlist[] PROGMEM = {
153 { nessie_str, NULL, testrun_nessie_omac_noekeon },
154 { test_str, NULL, testrun_test_omac_noekeon},
155 { performance_str, NULL, testrun_performance_omac_noekeon},
156 { echo_str, (void*)1, (void_fpt)echo_ctrl},
164 welcome_msg(algo_name);
165 cmd_interface(cmdlist);