avr-crypto-lib/test_src/main-cast6-test.c

130 lines
3.3 KiB
C
Raw Normal View History

2009-04-03 22:58:48 +00:00
/*
* rc6 test-suit
*
*/
#include "config.h"
2009-11-05 05:33:56 +00:00
2009-07-29 09:49:57 +00:00
#include "uart_i.h"
2009-04-03 22:58:48 +00:00
#include "debug.h"
#include "cast6.h"
#include "cli.h"
#include "performance_test.h"
#include "bcal-performance.h"
2011-01-03 19:52:10 +00:00
#include "bcal-nessie.h"
#include "bcal_cast6.h"
2009-04-03 22:58:48 +00:00
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <avr/pgmspace.h>
char* algo_name = "CAST-256";
2012-03-14 16:38:51 +00:00
const bcdesc_t* const algolist[] PROGMEM = {
(bcdesc_t*)&cast6_desc,
NULL
};
2009-04-03 22:58:48 +00:00
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
void testrun_nessie_cast6(void){
2011-01-03 19:52:10 +00:00
bcal_nessie_multiple(algolist);
2009-04-03 22:58:48 +00:00
}
void testrun_rfc_cast6(void){
cli_putstr_P(PSTR("\r\n testvalues from rfc-2612\r\n"));
uint8_t key[32], data[16];
cast6_ctx_t ctx;
memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
"\x0a\xf7\x56\x47\xf2\x9f\x61\x5d"), 16);
memset(data, 0, 16);
cli_putstr_P(PSTR("\r\n key: "));
cli_hexdump(key, 16);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cast6_init(key, 128, &ctx);
cast6_enc(data, &ctx);
cli_putstr_P(PSTR("\r\n CT: "));
cli_hexdump(data, 16);
cast6_dec(data, &ctx);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cli_putstr_P(PSTR("\r\n\r\n"));
memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
"\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
"\xba\xc7\x7a\x77\x17\x94\x28\x63"), 24);
cli_putstr_P(PSTR("\r\n key: "));
cli_hexdump(key, 24);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cast6_init(key, 192, &ctx);
cast6_enc(data, &ctx);
cli_putstr_P(PSTR("\r\n CT: "));
cli_hexdump(data, 16);
cast6_dec(data, &ctx);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cli_putstr_P(PSTR("\r\n\r\n"));
memcpy_P(key, PSTR("\x23\x42\xbb\x9e\xfa\x38\x54\x2c"
"\xbe\xd0\xac\x83\x94\x0a\xc2\x98"
"\x8d\x7c\x47\xce\x26\x49\x08\x46"
"\x1c\xc1\xb5\x13\x7a\xe6\xb6\x04"), 32);
cli_putstr_P(PSTR("\r\n key: "));
cli_hexdump(key, 32);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cast6_init(key, 256, &ctx);
cast6_enc(data, &ctx);
cli_putstr_P(PSTR("\r\n CT: "));
cli_hexdump(data, 16);
cast6_dec(data, &ctx);
cli_putstr_P(PSTR("\r\n PT: "));
cli_hexdump(data, 16);
cli_putstr_P(PSTR("\r\n\r\n"));
}
void testrun_performance_cast6(void){
bcal_performance_multiple(algolist);
2009-04-03 22:58:48 +00:00
}
2009-04-03 22:58:48 +00:00
/*****************************************************************************
* main *
*****************************************************************************/
const char nessie_str[] PROGMEM = "nessie";
const char test_str[] PROGMEM = "test";
const char performance_str[] PROGMEM = "performance";
const char echo_str[] PROGMEM = "echo";
2012-03-14 16:38:51 +00:00
const cmdlist_entry_t cmdlist[] PROGMEM = {
2009-04-03 22:58:48 +00:00
{ nessie_str, NULL, testrun_nessie_cast6 },
{ test_str, NULL, testrun_rfc_cast6},
{ performance_str, NULL, testrun_performance_cast6},
{ echo_str, (void*)1, (void_fpt)echo_ctrl},
{ NULL, NULL, NULL}
};
int main (void){
DEBUG_INIT();
2009-07-29 09:49:57 +00:00
cli_rx = (cli_rx_fpt)uart0_getc;
cli_tx = (cli_tx_fpt)uart0_putc;
2009-04-03 22:58:48 +00:00
for(;;){
cli_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
cli_putstr(algo_name);
cli_putstr_P(PSTR(")\r\nloaded and running\r\n"));
cmd_interface(cmdlist);
}
}