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"
38 char* algo_name = "OMAC-Noekeon";
40 /*****************************************************************************
41 * additional validation-functions *
42 *****************************************************************************/
44 void test_mac(void* key, void* data, uint16_t datalength_b){
46 uart_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
47 uart_hexdump(((uint8_t*)&datalength_b)+1, 1);
48 uart_hexdump(((uint8_t*)&datalength_b)+0, 1);
49 uart_putstr_P(PSTR("\r\n msg: "));
50 uart_hexdump(data, (datalength_b+7)/8);
51 uart_putstr_P(PSTR("\r\n key: "));
52 uart_hexdump(key, 16);
53 omac_noekeon(mac, data, datalength_b, key, (uint8_t)-1);
54 uart_putstr_P(PSTR("\r\n mac: "));
55 uart_hexdump(mac, 16);
59 void testrun_test_noekeonomac(void){
60 uint8_t key[16], data[64];
62 memset(key, 0xAA, 16);
63 memset(data, 0x00, 64);
65 test_mac(key, data, i);
69 /******************************************************************************/
73 void noekeonomac_next_dummy(void* buffer, void* ctx){
74 omac_noekeon_next(buffer, stat_key, ctx);
77 void noekeonomac_init_dummy(void* key, uint16_t keysize_b, void* ctx){
78 omac_noekeon_init(ctx);
79 memcpy(stat_key, key, 16);
82 void noekeonomac_last_dummy(void* buffer, uint16_t size_b, void* key, uint16_t keysize_b, void* ctx){
84 omac_noekeon_next(buffer, key, ctx);
86 buffer = (uint8_t*)buffer +16;
88 omac_noekeon_last(buffer, size_b, key, ctx);
91 void noekeonomac_conv_dummy(void* buffer, void* ctx){
92 memcpy(buffer, ctx, 16);
95 void testrun_nessie_noekeonomac(void){
96 nessie_mac_ctx.macsize_b = 128;
97 nessie_mac_ctx.keysize_b = 128;
98 nessie_mac_ctx.blocksize_B = 16;
99 nessie_mac_ctx.ctx_size_B = sizeof(noekeon_omac_ctx_t);
100 nessie_mac_ctx.name = algo_name;
101 nessie_mac_ctx.mac_init = noekeonomac_init_dummy;
102 nessie_mac_ctx.mac_next = noekeonomac_next_dummy;
103 nessie_mac_ctx.mac_last = noekeonomac_last_dummy;
104 nessie_mac_ctx.mac_conv = noekeonomac_conv_dummy;
112 /*****************************************************************************
114 *****************************************************************************/
121 uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
122 uart_putstr(algo_name);
123 uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
125 PGM_P u = PSTR("nessie\0test\0");
126 void_fpt v[] = {testrun_nessie_noekeonomac, testrun_test_noekeonomac};
129 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
130 if(execcommand_d0_P(str, u, v)<0){
131 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
135 uart_putstr("ERROR\r\n");