]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-serpent-test.c
make process changed and modularised
[avr-crypto-lib.git] / main-serpent-test.c
1 /*
2  * serpent 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 "serpent.h"
12 #include "nessie_bc_test.h"
13
14 #include <stdint.h>
15 #include <string.h>
16
17 char* cipher_name = "Serpent";
18
19 /*****************************************************************************
20  *  additional validation-functions                                                                                      *
21  *****************************************************************************/
22 void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
23         serpent_genctx(key, keysize&0xff, ctx);
24 }
25
26 void testrun_serpent(void){
27         nessie_ctx.blocksize_B =  16;
28         nessie_ctx.keysize     = 128;
29         nessie_ctx.name        = cipher_name;
30         nessie_ctx.ctx_size_B  = sizeof(serpent_ctx_t);
31         nessie_ctx.cipher_enc  = (nessie_enc_fpt)serpent_enc;
32         nessie_ctx.cipher_dec  = (nessie_dec_fpt)serpent_dec;
33         nessie_ctx.cipher_genctx  = (nessie_gen_fpt)serpent_genctx_dummy;
34         
35         nessie_run();
36         
37         nessie_ctx.keysize     = 192;
38         nessie_run();
39         
40         nessie_ctx.keysize     = 256;
41         nessie_run();
42         
43 }
44
45
46
47 /*****************************************************************************
48  *  main                                                                                                                                         *
49  *****************************************************************************/
50
51 int main (void){
52         char  str[20];
53         DEBUG_INIT();
54         uart_putstr("\r\n");
55
56         uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
57         uart_putstr(cipher_name);
58         uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
59
60 restart:
61         while(1){ 
62                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
63                 if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
64                         testrun_serpent();
65                 goto restart;           
66                 continue;
67         error:
68                 uart_putstr("ERROR\r\n");
69         }
70         
71         
72 }
73