]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-arcfour-test.c
74e76e158844e656b1635ca1b2f0d0cb9af8804a
[avr-crypto-lib.git] / main-arcfour-test.c
1 /*
2  * arcfour (RC4 compatible) 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 "arcfour.h"
12 #include "nessie_stream_test.h"
13
14 #include <stdint.h>
15 #include <string.h>
16
17 char* cipher_name = "Arcfour";
18
19 /*****************************************************************************
20  *  additional validation-functions                                                                                      *
21  *****************************************************************************/
22 void arcfour_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
23         arcfour_init(ctx, key, (keysize+7)/8);
24 }
25
26
27
28 void testrun_nessie_arcfour(void){
29         nessie_stream_ctx.outsize_b = 8; /* actually unused */
30         nessie_stream_ctx.keysize_b = 128; /* this is theone we have refrence vectors for */
31         nessie_stream_ctx.ivsize_b = (uint16_t)-1;
32         nessie_stream_ctx.name = cipher_name;
33         nessie_stream_ctx.ctx_size_B = sizeof(arcfour_ctx_t);
34         nessie_stream_ctx.cipher_genctx = (nessie_stream_genctx_fpt)arcfour_genctx_dummy;
35         nessie_stream_ctx.cipher_enc = (nessie_stream_genenc_fpt)arcfour_gen;
36         
37         nessie_stream_run();    
38 }
39
40
41
42 /*****************************************************************************
43  *  main                                                                                                                                         *
44  *****************************************************************************/
45
46 int main (void){
47         char  str[20];
48         DEBUG_INIT();
49         uart_putstr("\r\n");
50
51         uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
52         uart_putstr(cipher_name);
53         uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
54
55 restart:
56         while(1){ 
57                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
58                 if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
59                         testrun_nessie_arcfour();
60                 goto restart;           
61                 continue;
62         error:
63                 uart_putstr("ERROR\r\n");
64         }
65         
66         
67 }
68