]> git.cryptolib.org Git - avr-crypto-lib.git/blob - main-xtea-test.c
+RC5 +size-statistics tool +small modification to nessie_bc_test (optional free(...
[avr-crypto-lib.git] / main-xtea-test.c
1 /*
2  * XTEA 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 "xtea.h"
12 #include "nessie_bc_test.h"
13
14 #include <stdint.h>
15 #include <string.h>
16
17 char* cipher_name = "XTEA";
18
19 void xtea_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
20         memcpy(ctx, key, (keysize+7)/8);
21 }
22
23 void xtea_enc_dummy(uint8_t* buffer, void* ctx){
24         xtea_enc((uint32_t*)buffer, (uint32_t*)buffer, ctx);
25 }
26
27 void xtea_dec_dummy(uint8_t* buffer, void* ctx){
28         xtea_dec((uint32_t*)buffer, (uint32_t*)buffer, ctx);
29 }
30
31 void testrun_nessie_xtea(void){
32         nessie_bc_ctx.blocksize_B =   8;
33         nessie_bc_ctx.keysize_b   = 128;
34         nessie_bc_ctx.name        = cipher_name;
35         nessie_bc_ctx.ctx_size_B  = 128/8;
36         nessie_bc_ctx.cipher_enc  = (nessie_bc_enc_fpt)xtea_enc_dummy;
37         nessie_bc_ctx.cipher_dec  = (nessie_bc_dec_fpt)xtea_dec_dummy;
38         nessie_bc_ctx.cipher_genctx  = (nessie_bc_gen_fpt)xtea_genctx_dummy;
39         
40         nessie_bc_run();        
41 }
42
43
44
45 /*****************************************************************************
46  *  main                                                                                                                                         *
47  *****************************************************************************/
48
49 int main (void){
50         char  str[20];
51         DEBUG_INIT();
52         uart_putstr("\r\n");
53
54         uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
55         uart_putstr(cipher_name);
56         uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
57
58 restart:
59         while(1){ 
60                 if (!getnextwordn(str,20))  {DEBUG_S("DBG: W1\r\n"); goto error;}
61                 if (strcmp(str, "nessie")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
62                         testrun_nessie_xtea();
63                 goto restart;           
64                 continue;
65         error:
66                 uart_putstr("ERROR\r\n");
67         }       
68 }