]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-skipjack-test.c
insereated GPLv3 stub
[avr-crypto-lib.git] / main-skipjack-test.c
1 /* main-skipjack-test.c */
2 /*
3     This file is part of the Crypto-avr-lib/microcrypt-lib.
4     Copyright (C) 2008  Daniel Otte (daniel.otte@rub.de)
5
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.
10
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.
15
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/>.
18 */
19 /*
20  * skipjack test-suit
21  * 
22 */
23
24 #include "config.h"
25 #include "serial-tools.h"
26 #include "uart.h"
27 #include "debug.h"
28
29 #include "skipjack.h"
30
31 #include <stdint.h>
32 #include <string.h>
33
34
35 /*****************************************************************************
36  *  additional validation-functions                                                                                      *
37  *****************************************************************************/
38
39 /*****************************************************************************
40  *  self tests                                                                                                                           *
41  *****************************************************************************/
42
43 void testencrypt(uint8_t* block, uint8_t* key){
44         uart_putstr("\r\n==testy-encrypt==\r\n key: ");
45         uart_hexdump(key,10);
46         uart_putstr("\r\n plain: ");
47         uart_hexdump(block,8);
48         skipjack_enc(block,key);
49         uart_putstr("\r\n crypt: ");
50         uart_hexdump(block,8);
51 }
52
53 void testdecrypt(uint8_t* block, uint8_t* key){
54         uart_putstr("\r\n==testy-decrypt==\r\n key: ");
55         uart_hexdump(key,10);
56         uart_putstr("\r\n crypt: ");
57         uart_hexdump(block,8);
58         skipjack_dec(block,key);
59         uart_putstr("\r\n plain: ");
60         uart_hexdump(block,8);
61 }
62
63 void testrun_skipjack(void){
64         uint8_t key[]={ 0x00, 0x99, 0x88, 0x77, 0x66,
65                                         0x55, 0x44, 0x33, 0x22, 0x11};
66         uint8_t data[]={ 0x33, 0x22, 0x11, 0x00, 0xdd, 0xcc, 0xbb, 0xaa};
67         testencrypt(data,key);
68         testdecrypt(data,key);  
69 }
70
71
72
73 /*****************************************************************************
74  *  main                                                                                                                                         *
75  *****************************************************************************/
76
77 int main (void){
78         char str[20];
79
80         DEBUG_INIT();
81         uart_putstr("\r\n");
82
83         uart_putstr("\r\n\r\nCrypto-VS (skipjack)\r\nloaded and running\r\n");
84
85 restart:
86         while(1){ 
87                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
88                 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
89                         testrun_skipjack();
90                 goto restart;           
91                 continue;
92         error:
93                 uart_putstr("ERROR\r\n");
94         }
95         
96         
97 }
98