7 #include "serial-tools.h"
12 #include "mickey128.h"
13 #include "nessie_stream_test.h"
18 char* algo_name = "Mickey128";
20 /*****************************************************************************
21 * additional validation-functions *
22 *****************************************************************************/
23 void mickey128_genctx_dummy(uint8_t* key, uint16_t keysize_b, void* ctx){
24 mickey128_init(key, keysize_b, NULL, 0, ctx);
27 void testrun_nessie_mickey128(void){
28 nessie_stream_ctx.outsize_b = 8; /* actually unused */
29 nessie_stream_ctx.keysize_b = 128; /* this is the one we have refrence vectors for */
30 nessie_stream_ctx.ivsize_b = 0;
31 nessie_stream_ctx.name = algo_name;
32 nessie_stream_ctx.ctx_size_B = sizeof(mickey128_ctx_t);
33 nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)mickey128_genctx_dummy;
34 nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)mickey128_getbyte;
39 void testrun_ref_mickey128(void){
41 { 0x12, 0x34, 0x56, 0x78,
42 0x9a, 0xbc, 0xde, 0xf0,
43 0x01, 0x23, 0x45, 0x67,
44 0x89, 0xab, 0xcd, 0xef},
45 { 0xf1, 0x1a, 0x56, 0x27,
46 0xce, 0x43, 0xb6, 0x1f,
47 0x89, 0x12, 0x29, 0x94,
48 0x86, 0x09, 0x44, 0x86},
49 { 0x3b, 0x80, 0xfc, 0x8c,
50 0x47, 0x5f, 0xc2, 0x70,
51 0xfa, 0x26, 0xb4, 0x70,
52 0x64, 0xb3, 0x2d, 0x33},
53 { 0x82, 0xac, 0xb3, 0x8c,
54 0x5d, 0x7a, 0x3c, 0x78,
55 0xd9, 0x8f, 0x15, 0x3c,
56 0xa3, 0xf9, 0xde, 0x7c} };
57 uint8_t iv_1[] = {0x21, 0x43, 0x65, 0x87};
58 uint8_t iv_2[] = {0x9c, 0x53, 0x2f, 0x8a,
59 0xc3, 0xea, 0x4b, 0x2e,
60 0xa0, 0xf5, 0x96, 0x40,
61 0x30, 0x83, 0x77, 0xcc};
65 cli_putstr_P(PSTR("\r\n-=Reference test=-\r\n"));
67 cli_putstr_P(PSTR("Test 1:\r\n key: "));
68 cli_hexdump(key[0], 16);
69 cli_putstr_P(PSTR("\r\n iv: "));
71 mickey128_init(&(key[0][0]), 128, iv_1, 4*8, &ctx);
73 data[i] = mickey128_getbyte(&ctx);
75 cli_putstr_P(PSTR("\r\n stream: "));
76 cli_hexdump(data, 16);
78 cli_putstr_P(PSTR("\r\n\r\nTest 2:\r\n key: "));
79 cli_hexdump(key[1], 16);
80 cli_putstr_P(PSTR("\r\n iv: "));
81 cli_hexdump(iv_2, 16);
82 mickey128_init(key[1], 128, iv_2, 16*8, &ctx);
84 data[i] = mickey128_getbyte(&ctx);
86 cli_putstr_P(PSTR("\r\n stream: "));
87 cli_hexdump(data, 16);
89 cli_putstr_P(PSTR("\r\n\r\nTest 3:\r\n key: "));
90 cli_hexdump(key[2], 16);
91 cli_putstr_P(PSTR("\r\n iv: "));
92 mickey128_init(key[2], 128, NULL, 0, &ctx);
94 data[i] = mickey128_getbyte(&ctx);
96 cli_putstr_P(PSTR("\r\n stream: "));
97 cli_hexdump(data, 16);
99 cli_putstr_P(PSTR("\r\n\r\nIteration test:\r\n key: "));
100 cli_hexdump(key[3], 16);
101 mickey128_init(key[3], 128, NULL, 0, &ctx);
103 for(j=0; j<1000; ++j){
105 key[0][i] = mickey128_getbyte(&ctx);
107 iv_1[i] = mickey128_getbyte(&ctx);
108 mickey128_init(key[0], 128, iv_1, 32, &ctx);
111 data[i] = mickey128_getbyte(&ctx);
113 cli_putstr_P(PSTR("\r\n stream: "));
114 cli_hexdump(data, 16);
115 cli_putstr_P(PSTR("\r\n"));
121 /*****************************************************************************
123 *****************************************************************************/
125 const char nessie_str[] PROGMEM = "nessie";
126 const char test_str[] PROGMEM = "test";
127 const char performance_str[] PROGMEM = "performance";
128 const char echo_str[] PROGMEM = "echo";
130 cmdlist_entry_t cmdlist[] PROGMEM = {
131 { nessie_str, NULL, testrun_nessie_mickey128},
132 { test_str, NULL, testrun_ref_mickey128},
133 { echo_str, (void*)1, (void_fpt)echo_ctrl},
143 cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
144 cli_putstr(algo_name);
145 cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
146 cmd_interface(cmdlist);