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