avr-crypto-lib/main-serpent-test.c

74 lines
1.6 KiB
C
Raw Normal View History

2008-04-02 13:35:03 +00:00
/*
* serpent test-suit
*
*/
#include "config.h"
#include "serial-tools.h"
#include "uart.h"
#include "debug.h"
#include "serpent.h"
2008-04-03 01:02:01 +00:00
#include "nessie_bc_test.h"
2008-04-02 13:35:03 +00:00
#include <stdint.h>
#include <string.h>
2008-04-03 01:02:01 +00:00
char* cipher_name = "Serpent";
2008-04-02 13:35:03 +00:00
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
2008-04-03 01:02:01 +00:00
void serpent_genctx_dummy(uint8_t* key, uint16_t keysize, void* ctx){
serpent_genctx(key, keysize&0xff, ctx);
2008-04-02 13:35:03 +00:00
}
void testrun_serpent(void){
2008-04-03 01:02:01 +00:00
nessie_ctx.blocksize_B = 16;
nessie_ctx.keysize = 128;
nessie_ctx.name = cipher_name;
nessie_ctx.ctx_size_B = sizeof(serpent_ctx_t);
2008-04-05 17:57:46 +00:00
nessie_ctx.cipher_enc = (nessie_enc_fpt)serpent_enc;
nessie_ctx.cipher_dec = (nessie_dec_fpt)serpent_dec;
nessie_ctx.cipher_genctx = (nessie_gen_fpt)serpent_genctx_dummy;
2008-04-03 01:02:01 +00:00
nessie_run();
nessie_ctx.keysize = 192;
nessie_run();
nessie_ctx.keysize = 256;
nessie_run();
2008-04-02 13:35:03 +00:00
}
/*****************************************************************************
* main *
*****************************************************************************/
int main (void){
2008-04-03 01:02:01 +00:00
char str[20];
2008-04-02 13:35:03 +00:00
DEBUG_INIT();
uart_putstr("\r\n");
2008-04-03 01:02:01 +00:00
uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
uart_putstr(cipher_name);
uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
2008-04-02 13:35:03 +00:00
restart:
while(1){
if (!getnextwordn(str,20)) {DEBUG_S("DBG: W1\r\n"); goto error;}
if (strcmp(str, "test")) {DEBUG_S("DBG: 1b\r\n"); goto error;}
testrun_serpent();
goto restart;
continue;
error:
uart_putstr("ERROR\r\n");
}
}