some minor changes to performance testing code
This commit is contained in:
parent
cdcf3abb34
commit
85b05e7b86
4
cast5.c
4
cast5.c
|
@ -102,7 +102,9 @@ void cast5_init(cast5_ctx_t* s, uint8_t* key, uint8_t keylength){
|
||||||
s->shortkey = (keylength<=80);
|
s->shortkey = (keylength<=80);
|
||||||
/* littel endian only! */
|
/* littel endian only! */
|
||||||
memset(&(x[0]), 0 ,16); /* set x to zero */
|
memset(&(x[0]), 0 ,16); /* set x to zero */
|
||||||
memcpy(&(x[0]), key, keylength/8);
|
if(keylength > 128)
|
||||||
|
keylength=128;
|
||||||
|
memcpy(&(x[0]), key, (keylength+7)/8);
|
||||||
|
|
||||||
|
|
||||||
/* todo: merge a and b and compress the whole stuff */
|
/* todo: merge a and b and compress the whole stuff */
|
||||||
|
|
|
@ -176,21 +176,25 @@ void test_performance_cast5(void){
|
||||||
cast5_init(&ctx, key, 128);
|
cast5_init(&ctx, key, 128);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
|
uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
|
||||||
startTimer(1);
|
startTimer(1);
|
||||||
cast5_enc(&ctx, data);
|
cast5_enc(&ctx, data);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tencrypt time: "));
|
uart_putstr_P(PSTR("\r\n\tencrypt time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
|
||||||
startTimer(1);
|
startTimer(1);
|
||||||
cast5_dec(&ctx, data);
|
cast5_dec(&ctx, data);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
|
uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
uart_putstr_P(PSTR("\r\n"));
|
uart_putstr_P(PSTR("\r\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,9 @@
|
||||||
#include "present.h"
|
#include "present.h"
|
||||||
#include "nessie_bc_test.h"
|
#include "nessie_bc_test.h"
|
||||||
#include "cli.h"
|
#include "cli.h"
|
||||||
|
#include "performance_test.h"
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
@ -74,6 +76,49 @@ void testrun_self_present(void){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void testrun_performance_present(void){
|
||||||
|
uint16_t i,c;
|
||||||
|
uint64_t t;
|
||||||
|
char str[16];
|
||||||
|
uint8_t key[10], data[8];
|
||||||
|
present_ctx_t ctx;
|
||||||
|
|
||||||
|
calibrateTimer();
|
||||||
|
getOverhead(&c, &i);
|
||||||
|
uart_putstr_P(PSTR("\r\n\r\n=== benchmark ==="));
|
||||||
|
utoa(c, str, 10);
|
||||||
|
uart_putstr_P(PSTR("\r\n\tconst overhead: "));
|
||||||
|
uart_putstr(str);
|
||||||
|
utoa(i, str, 10);
|
||||||
|
uart_putstr_P(PSTR("\r\n\tinterrupt overhead: "));
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
memset(key, 0, 10);
|
||||||
|
memset(data, 0, 8);
|
||||||
|
|
||||||
|
startTimer(1);
|
||||||
|
present_init(key, 80, &ctx);
|
||||||
|
t = stopTimer();
|
||||||
|
uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
|
||||||
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
startTimer(1);
|
||||||
|
present_enc(data, &ctx);
|
||||||
|
t = stopTimer();
|
||||||
|
uart_putstr_P(PSTR("\r\n\tencrypt time: "));
|
||||||
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
startTimer(1);
|
||||||
|
present_dec(data, &ctx);
|
||||||
|
t = stopTimer();
|
||||||
|
uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
|
||||||
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
uart_putstr_P(PSTR("\r\n"));
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* main *
|
* main *
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -89,8 +134,8 @@ int main (void){
|
||||||
uart_putstr(cipher_name);
|
uart_putstr(cipher_name);
|
||||||
uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
|
uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
|
||||||
|
|
||||||
PGM_P u = PSTR("nessie\0test\0");
|
PGM_P u = PSTR("nessie\0test\0performance\0");
|
||||||
void_fpt v[] = {testrun_nessie_present, testrun_self_present};
|
void_fpt v[] = {testrun_nessie_present, testrun_self_present, testrun_performance_present};
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
|
if (!getnextwordn(str,20)){DEBUG_S("DBG: W1\r\n"); goto error;}
|
||||||
|
|
|
@ -48,7 +48,7 @@ void testrun_nessie_serpent(void){
|
||||||
void testrun_performance_serpent(void){
|
void testrun_performance_serpent(void){
|
||||||
uint16_t i,c;
|
uint16_t i,c;
|
||||||
uint64_t t;
|
uint64_t t;
|
||||||
char str[6];
|
char str[16];
|
||||||
uint8_t key[32], data[16];
|
uint8_t key[32], data[16];
|
||||||
serpent_ctx_t ctx;
|
serpent_ctx_t ctx;
|
||||||
|
|
||||||
|
@ -69,21 +69,25 @@ void testrun_performance_serpent(void){
|
||||||
serpent_genctx(key, 0, &ctx);
|
serpent_genctx(key, 0, &ctx);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
|
uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
|
||||||
startTimer(1);
|
startTimer(1);
|
||||||
serpent_enc(data, &ctx);
|
serpent_enc(data, &ctx);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tencrypt time: "));
|
uart_putstr_P(PSTR("\r\n\tencrypt time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
|
|
||||||
startTimer(1);
|
startTimer(1);
|
||||||
serpent_dec(data, &ctx);
|
serpent_dec(data, &ctx);
|
||||||
t = stopTimer();
|
t = stopTimer();
|
||||||
uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
|
uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
|
||||||
uart_hexdump(&t, 8);
|
ultoa((unsigned long)t, str, 10);
|
||||||
|
uart_putstr(str);
|
||||||
|
|
||||||
uart_putstr_P(PSTR("\r\n"));
|
uart_putstr_P(PSTR("\r\n"));
|
||||||
}
|
}
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
|
|
|
@ -7,7 +7,8 @@ BLOCK_CIPHERS += $(ALGO_NAME)
|
||||||
|
|
||||||
$(ALGO_NAME)_OBJ := present.o
|
$(ALGO_NAME)_OBJ := present.o
|
||||||
$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o serial-tools.o \
|
$(ALGO_NAME)_TEST_BIN := main-present-test.o debug.o uart.o serial-tools.o \
|
||||||
present.o nessie_bc_test.o nessie_common.o cli.o
|
present.o nessie_bc_test.o nessie_common.o cli.o \
|
||||||
|
performance_test.o
|
||||||
$(ALGO_NAME)_NESSIE_TEST := "nessie"
|
$(ALGO_NAME)_NESSIE_TEST := "nessie"
|
||||||
$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
|
$(ALGO_NAME)_PEROFRMANCE_TEST := "performance"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue