]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-arcfour-test.c
arcfour got its own testsuit now + some modifications of the build process
[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_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.name = cipher_name;
32         nessie_stream_ctx.ctx_size_B = sizeof(arcfour_ctx_t);
33         nessie_stream_ctx.cipher_genctx = arcfour_genctx_dummy;
34         nessie_stream_ctx.cipher_enc = arcfour_gen;
35         
36         nessie_stream_run();    
37 }
38
39
40
41 /*****************************************************************************
42  *  main                                                                                                                                         *
43  *****************************************************************************/
44
45 int main (void){
46         char  str[20];
47         DEBUG_INIT();
48         uart_putstr("\r\n");
49
50         uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
51         uart_putstr(cipher_name);
52         uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
53
54 restart:
55         while(1){ 
56                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
57                 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
58                         testrun_arcfour();
59                 goto restart;           
60                 continue;
61         error:
62                 uart_putstr("ERROR\r\n");
63         }
64         
65         
66 }
67