]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-serpent-test.c
hmac-sha256 bugfix + hmac-sha256 test suit
[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_nessie_serpent(void){
27         nessie_bc_ctx.blocksize_B =  16;
28         nessie_bc_ctx.keysize_b   = 128;
29         nessie_bc_ctx.name        = cipher_name;
30         nessie_bc_ctx.ctx_size_B  = sizeof(serpent_ctx_t);
31         nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)serpent_enc;
32         nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)serpent_dec;
33         nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)serpent_genctx_dummy;
34         
35         nessie_bc_run();
36         
37         nessie_bc_ctx.keysize_b   = 192;
38         nessie_bc_run();
39         
40         nessie_bc_ctx.keysize_b   = 256;
41         nessie_bc_run();
42 }
43
44
45
46 /*****************************************************************************
47  *  main                                                                                                                                         *
48  *****************************************************************************/
49
50 int main (void){
51         char  str[20];
52         DEBUG_INIT();
53         uart_putstr("\r\n");
54
55         uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
56         uart_putstr(cipher_name);
57         uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
58
59 restart:
60         while(1){ 
61                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
62                 if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
63                         testrun_nessie_serpent();
64                 goto restart;           
65                 continue;
66         error:
67                 uart_putstr("ERROR\r\n");
68         }
69         
70 }
71