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/>.
25 #include "serial-tools.h"
30 #include "nessie_hash_test.h"
36 char* algo_name = "MD5";
38 /*****************************************************************************
39 * additional validation-functions *
40 *****************************************************************************/
41 void md5_next_dummy(void* buffer, void* ctx){
42 md5_nextBlock(ctx, buffer);
45 void md5_last_dummy(void* buffer, uint16_t size_b, void* ctx){
46 md5_lastBlock(ctx, buffer, size_b);
49 void md5_ctx2hash_dummy(void* buffer, void* ctx){
50 memcpy(buffer, ctx, 16);
54 void testrun_nessie_md5(void){
55 nessie_hash_ctx.hashsize_b = 128;
56 nessie_hash_ctx.blocksize_B = 512/8;
57 nessie_hash_ctx.ctx_size_B = sizeof(md5_ctx_t);
58 nessie_hash_ctx.name = algo_name;
59 nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)md5_init;
60 nessie_hash_ctx.hash_next = (nessie_hash_next_fpt)md5_next_dummy;
61 nessie_hash_ctx.hash_last = (nessie_hash_last_fpt)md5_last_dummy;
62 nessie_hash_ctx.hash_conv = (nessie_hash_conv_fpt)md5_ctx2hash_dummy;
67 /*****************************************************************************
69 *****************************************************************************/
73 * MD5 ("") = d41d8cd98f00b204e9800998ecf8427e
74 * MD5 ("a") = 0cc175b9c0f1b6a831c399e269772661
75 * MD5 ("abc") = 900150983cd24fb0d6963f7d28e17f72
76 * MD5 ("message digest") = f96b697d7cb7938d525a2f31aaf161d0
77 * MD5 ("abcdefghijklmnopqrstuvwxyz") = c3fcd3d76192e4007dfb496cca67e13b
78 * MD5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") =
79 * d174ab98d277d9f5a5611c2c9f419d9f
80 * MD5 ("123456789012345678901234567890123456789012345678901234567890123456
81 * 78901234567890") = 57edf4a22be3c955ac49da2e2107b67a
84 void testrun_md5(void){
86 char* testv[]={"", "a", "abc", "message digest", "abcdefghijklmnopqrstuvwxyz",
87 "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
88 "12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
91 uart_putstr("\r\n=== MD5 test suit ===");
93 uart_putstr("\r\n MD5 (\"");
94 uart_putstr(testv[i]);
95 uart_putstr("\") = \r\n");
97 md5_lastBlock(&s, testv[i], strlen(testv[i])*8);
98 uart_hexdump(&s.a[0], 16);
104 /*****************************************************************************
106 *****************************************************************************/
115 uart_putstr("\r\n\r\nCrypto-VS (MD5)\r\nloaded and running\r\n");
116 PGM_P u = PSTR("nessie\0test\0");
117 void_fpt v[] = {testrun_nessie_md5, testrun_md5};
120 if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
121 if(execcommand_d0_P(str, u, v)<0){
122 uart_putstr_P(PSTR("\r\nunknown command\r\n"));
126 uart_putstr("ERROR\r\n");