]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-skipjack-test.c
+RC5 +size-statistics tool +small modification to nessie_bc_test (optional free(...
[avr-crypto-lib.git] / main-skipjack-test.c
1 /*
2  * skipjack test-suit
3  * 
4 */
5
6 #include "config.h"
7 #include "serial-tools.h"
8 #include "uart.h"
9 #include "debug.h"
10
11 #include "skipjack.h"
12
13 #include <stdint.h>
14 #include <string.h>
15
16
17 /*****************************************************************************
18  *  additional validation-functions                                                                                      *
19  *****************************************************************************/
20
21 /*****************************************************************************
22  *  self tests                                                                                                                           *
23  *****************************************************************************/
24
25 void testencrypt(uint8_t* block, uint8_t* key){
26         uart_putstr("\r\n==testy-encrypt==\r\n key: ");
27         uart_hexdump(key,10);
28         uart_putstr("\r\n plain: ");
29         uart_hexdump(block,8);
30         skipjack_enc(block,key);
31         uart_putstr("\r\n crypt: ");
32         uart_hexdump(block,8);
33 }
34
35 void testdecrypt(uint8_t* block, uint8_t* key){
36         uart_putstr("\r\n==testy-decrypt==\r\n key: ");
37         uart_hexdump(key,10);
38         uart_putstr("\r\n crypt: ");
39         uart_hexdump(block,8);
40         skipjack_dec(block,key);
41         uart_putstr("\r\n plain: ");
42         uart_hexdump(block,8);
43 }
44
45 void testrun_skipjack(void){
46         uint8_t key[]={ 0x00, 0x99, 0x88, 0x77, 0x66,
47                                         0x55, 0x44, 0x33, 0x22, 0x11};
48         uint8_t data[]={ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa};
49         testencrypt(data,key);
50         testdecrypt(data,key);  
51 }
52
53
54
55 /*****************************************************************************
56  *  main                                                                                                                                         *
57  *****************************************************************************/
58
59 int main (void){
60         char str[20];
61
62         DEBUG_INIT();
63         uart_putstr("\r\n");
64
65         uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
66
67 restart:
68         while(1){ 
69                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
70                 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
71                         testrun_skipjack();
72                 goto restart;           
73                 continue;
74         error:
75                 uart_putstr("ERROR\r\n");
76         }
77         
78         
79 }
80