7 #include "serial-tools.h"
17 /*****************************************************************************
18 * additional validation-functions *
19 *****************************************************************************/
21 /*****************************************************************************
23 *****************************************************************************/
25 void sha1_ctx_dump(sha1_ctx_t *s){
27 uart_putstr("\r\n==== sha1_ctx_dump ====");
29 uart_putstr("\r\na["); uart_hexdump(&i, 1); uart_putstr("]: ");
30 uart_hexdump(&(s->h[i]), 4);
32 uart_putstr("\r\nlength"); uart_hexdump(&i, 8);
35 void testrun_sha1(void){
37 sha1(&hash,"abc",3*8);
38 uart_putstr("\r\nsha1(\"abc\") = \r\n\t");
39 uart_hexdump(hash,SHA1_HASH_BITS/8);
41 sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
42 uart_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
43 uart_hexdump(hash,SHA1_HASH_BITS/8);
45 uart_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
47 uint8_t block[SHA1_BLOCK_BITS/8];
50 memset(block,'a',SHA1_BLOCK_BITS/8);
52 for(i=0;i<15625; ++i){ /* (1000000/(SHA1_BLOCK_BITS/8)) */
53 sha1_nextBlock(&s, block);
55 sha1_lastBlock(&s,block,0);
56 sha1_ctx2hash(&hash, &s);
58 uart_hexdump(hash,SHA1_HASH_BITS/8);
66 /*****************************************************************************
68 *****************************************************************************/
76 uart_putstr("\r\n\r\nCrypto-VS (SHA-1)\r\nloaded and running\r\n");
80 if (!getnextwordn(str,20)) {DEBUG_S("DBG: W1\r\n"); goto error;}
81 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
86 uart_putstr("ERROR\r\n");