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"
35 /*****************************************************************************
36 * additional validation-functions *
37 *****************************************************************************/
39 /*****************************************************************************
41 *****************************************************************************/
43 void sha1_ctx_dump(sha1_ctx_t *s){
45 uart_putstr("\r\n==== sha1_ctx_dump ====");
47 uart_putstr("\r\na["); uart_hexdump(&i, 1); uart_putstr("]: ");
48 uart_hexdump(&(s->h[i]), 4);
50 uart_putstr("\r\nlength"); uart_hexdump(&i, 8);
53 void testrun_sha1(void){
55 sha1(&hash,"abc",3*8);
56 uart_putstr("\r\nsha1(\"abc\") = \r\n\t");
57 uart_hexdump(hash,SHA1_HASH_BITS/8);
59 sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
60 uart_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
61 uart_hexdump(hash,SHA1_HASH_BITS/8);
63 uart_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
65 uint8_t block[SHA1_BLOCK_BITS/8];
68 memset(block,'a',SHA1_BLOCK_BITS/8);
70 for(i=0;i<15625; ++i){ /* (1000000/(SHA1_BLOCK_BITS/8)) */
71 sha1_nextBlock(&s, block);
73 sha1_lastBlock(&s,block,0);
74 sha1_ctx2hash(&hash, &s);
76 uart_hexdump(hash,SHA1_HASH_BITS/8);
84 /*****************************************************************************
86 *****************************************************************************/
94 uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n");
98 if (!getnextwordn(str,20)) {DEBUG_S("DBG: W1\r\n"); goto error;}
99 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
104 uart_putstr("ERROR\r\n");