HASHES :=
MACS :=
PRNGS :=
+ENCODINGS :=
# we use the gnu make standard library
include gmsl
include avr-makefile.inc
include mkfiles/*.mk
-ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS)
+ALGORITHMS = $(BLOCK_CIPHERS) $(STREAM_CIPHERS) $(HASHES) $(PRNGS) $(MACS) $(ENCODINGS)
ALGORITHMS_OBJ = $(patsubst %,%_OBJ, $(ALGORITHMS))
ALGORITHMS_TEST_BIN = $(patsubst %,%_TEST_BIN, $(ALGORITHMS))
@echo " $(MACS)"
@echo " PRNG functions:"
@echo " $(PRNGS)"
+ @echo " encodings:"
+ @echo " $(ENCODINGS)"
# @echo " ALGORITHMS_TEST_BIN:"
# @echo " $(ALGORITHMS_TEST_BIN)"
# @echo " ALGORITHMS_TEST_TARGET_ELF:"
$(HASHES_OBJ): $(patsubst %,%_OBJ, $(HASHES))
$(PRNGS_OBJ): $(patsubst %,%_OBJ, $(PRNGS))
$(MACS_OBJ): $(patsubst %,%_OBJ, $(MACS))
+$(ENCODINGS_OBJ): $(patsubst %,%_OBJ, $(ENCODINGS))
#-------------------------------------------------------------------------------
.PHONY: prngs
prngs: $(patsubst %, %_OBJ, $(PRNGS))
+.PHONY: encodings
+encodings: $(patsubst %, %_OBJ, $(ENCODINGS))
+
tests: $(ALGORITHMS_TEST_BIN) \
$(ALGORITHMS_TEST_TARGET_ELF) \
$(ALGORITHMS_TEST_TARGET_HEX)
#include <string.h>
#include "config.h"
#include "sha1.h"
+#include "hmac-sha1.h"
#define IPAD 0x36
#define OPAD 0x5C
-typedef sha1_ctx_t hmac_sha1_ctx_t;
#ifndef HMAC_SHORTONLY
sha1_init(s);
sha1_nextBlock(s, buffer);
#if defined SECURE_WIPE_BUFFER
- memset(buffer, 0, SHA256_BLOCK_BITS/8);
+ memset(buffer, 0, SHA1_BLOCK_BYTES);
#endif
}
memcpy(s, &a, sizeof(sha1_ctx_t));
#if defined SECURE_WIPE_BUFFER
memset(buffer, 0, SHA1_BLOCK_BYTES);
- memset(a.h, 0, 20);
+ memset(&a, 0, sizeof(sha1_ctx_t));
#endif
}
* keylength in bits!
* message length in bits!
*/
-void hmac_sha1(void* dest, void* key, uint16_t keylength_b, void* msg, uint64_t msglength_b){ /* a one-shot*/
+void hmac_sha1(void* dest, void* key, uint16_t keylength_b, void* msg, uint32_t msglength_b){ /* a one-shot*/
sha1_ctx_t s;
uint8_t i;
uint8_t buffer[SHA1_BLOCK_BYTES];
-/* hmac-sha256.h */
+/* hmac-sha1.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
#include "sha1.h"
#define HMACSHA1_BITS SHA1_HASH_BITS
-#define HMACSHA1_BYTES ((HMAC_BITS+7)/8)
+#define HMACSHA1_BYTES ((HMACSHA1_BITS+7)/8)
typedef sha1_ctx_t hmac_sha1_ctx_t;
void hmac_sha1_init(hmac_sha1_ctx_t *s, void* key, uint16_t keylength_b);
void hmac_sha1_final(hmac_sha1_ctx_t *s, void* key, uint16_t keylength_b);
-void hmac_sha1(void* dest, void* key, uint16_t keylength_b, void* msg, uint64_t msglength_b);
+void hmac_sha1(void* dest, void* key, uint16_t keylength_b, void* msg, uint32_t msglength_b);
#endif /*HMACSHA1_H_*/
require 'serialport'
-def read_line
+def read_line(error_msg=true)
s = $sp.gets()
if s==nil
- puts "ERROR: read timeout!\n";
+ puts("ERROR: read timeout!\n") if error_msg
return nil
end
s.gsub(/\006/, '');
set=0;
vector=0;
begin
- lb = read_line()
+ lb = read_line(false)
if (m=/unknown command/.match(lb) || m=/[Ee][Rr]{2}[Oo][Rr]/.match(lb))
puts("ERROR: "+lb);
exit(2);
return nil if file.eof
l = file.gets().strip()
if not /[^=]+=[^=]+/.match(l)
- value += l if /[0-9A-Fa-f]{5}/.match(l)
+ value += l if /^[0-9A-Fa-f]{5}/.match(l)
end
end until /[^=]+=[^=]+/.match(l)
$last_assign[i] = l
return nil if file.eof
l = file.gets().strip()
if not /[^=]+=[^=]+/.match(l)
- value += l if /[0-9A-Fa-f]{5}/.match(l)
+ value += l if /^[0-9A-Fa-f]{5}/.match(l)
end
end until /[^=]+=[^=]+/.match(l)
$last_assign[i] = l
$quiet=true
end
else
- f1 = ARGV[1]
- f2 = ARGV[2]
+ f1 = ARGV[0]
+ f2 = ARGV[1]
end
puts("compare("+f1+", "+f2+")")
# Makefile for HMAC-SHA256
ALGO_NAME := HMAC-SHA1
-# comment out the following line for removement of HMAC-SHA256 from the build process
+# comment out the following line for removement of HMAC-SHA1 from the build process
MACS += $(ALGO_NAME)
$(ALGO_NAME)_OBJ := hmac-sha1.o sha1-asm.o
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
0xe0, 0x37, 0x07, 0x34 };
aes128_ctx_t ctx;
aes128_init(key, &ctx);
- uart_putstr_P(PSTR("\r\n\r\n cipher test (FIPS 197):\r\n key: "));
- uart_hexdump(key, 16);
- uart_putstr_P(PSTR("\r\n plaintext: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n\r\n cipher test (FIPS 197):\r\n key: "));
+ cli_hexdump(key, 16);
+ cli_putstr_P(PSTR("\r\n plaintext: "));
+ cli_hexdump(data, 16);
aes128_enc(data, &ctx);
- uart_putstr_P(PSTR("\r\n ciphertext: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n ciphertext: "));
+ cli_hexdump(data, 16);
aes128_dec(data, &ctx);
- uart_putstr_P(PSTR("\r\n plaintext: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n plaintext: "));
+ cli_hexdump(data, 16);
}
aes128_ctx_t ctx;
uint8_t i;
aes128_init(key, &ctx);
- uart_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
- uart_hexdump(key, 16);
+ cli_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
+ cli_hexdump(key, 16);
for(i=0; i<11; ++i){
- uart_putstr_P(PSTR("\r\n index: "));
- uart_putc('0'+i/10);
- uart_putc('0'+i%10);
- uart_putstr_P(PSTR(" roundkey "));
- uart_hexdump(ctx.key[i].ks, 16);
+ cli_putstr_P(PSTR("\r\n index: "));
+ cli_putc('0'+i/10);
+ cli_putc('0'+i%10);
+ cli_putstr_P(PSTR(" roundkey "));
+ cli_hexdump(ctx.key[i].ks, 16);
}
}
uint8_t i;
memset(&ctx, 0, sizeof(aes192_ctx_t));
aes192_init(key, &ctx);
- uart_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
- uart_hexdump(key, 24);
+ cli_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
+ cli_hexdump(key, 24);
for(i=0; i<13; ++i){
- uart_putstr_P(PSTR("\r\n index: "));
- uart_putc('0'+i/10);
- uart_putc('0'+i%10);
- uart_putstr_P(PSTR(" roundkey "));
- uart_hexdump(ctx.key[i].ks, 16);
+ cli_putstr_P(PSTR("\r\n index: "));
+ cli_putc('0'+i/10);
+ cli_putc('0'+i%10);
+ cli_putstr_P(PSTR(" roundkey "));
+ cli_hexdump(ctx.key[i].ks, 16);
}
}
uint8_t i;
memset(&ctx, 0, sizeof(aes256_ctx_t));
aes256_init(key, &ctx);
- uart_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
- uart_hexdump(key, 32);
+ cli_putstr_P(PSTR("\r\n\r\n keyschedule test (FIPS 197):\r\n key: "));
+ cli_hexdump(key, 32);
for(i=0; i<15; ++i){
- uart_putstr_P(PSTR("\r\n index: "));
- uart_putc('0'+i/10);
- uart_putc('0'+i%10);
- uart_putstr_P(PSTR(" roundkey "));
- uart_hexdump(ctx.key[i].ks, 16);
+ cli_putstr_P(PSTR("\r\n index: "));
+ cli_putc('0'+i/10);
+ cli_putc('0'+i%10);
+ cli_putstr_P(PSTR(" roundkey "));
+ cli_hexdump(ctx.key[i].ks, 16);
}
}
startTimer(1);
aes128_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes128_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes128_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
startTimer(1);
aes192_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes192_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes192_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
startTimer(1);
aes256_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes256_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
aes256_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
void testrun_performance_aes(void){
- uart_putstr_P(PSTR("\r\n -=AES Performance Test=-\r\n"));
- uart_putstr_P(PSTR("\r\n AES-128\r\n"));
+ cli_putstr_P(PSTR("\r\n -=AES Performance Test=-\r\n"));
+ cli_putstr_P(PSTR("\r\n AES-128\r\n"));
testrun_performance_aes128();
- uart_putstr_P(PSTR("\r\n AES-192\r\n"));
+ cli_putstr_P(PSTR("\r\n AES-192\r\n"));
testrun_performance_aes192();
- uart_putstr_P(PSTR("\r\n AES-256\r\n"));
+ cli_putstr_P(PSTR("\r\n AES-256\r\n"));
testrun_performance_aes256();
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
arcfour_init(key, 16, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
arcfour_gen(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
camellia128_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
camellia128_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
camellia128_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
camellia128_ctx_t ctx;
camellia128_init(key, &ctx);
- uart_putstr_P(PSTR("\r\n key: "));
- uart_hexdump(data, 16);
- uart_putstr_P(PSTR("\r\n plaintext: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n key: "));
+ cli_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n plaintext: "));
+ cli_hexdump(data, 16);
camellia128_enc(data, &ctx);
- uart_putstr_P(PSTR("\r\n ciphertext: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n ciphertext: "));
+ cli_hexdump(data, 16);
camellia128_dec(data, &ctx);
- uart_putstr_P(PSTR("\r\n decrypted: "));
- uart_hexdump(data, 16);
+ cli_putstr_P(PSTR("\r\n decrypted: "));
+ cli_hexdump(data, 16);
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
void cast5_ctx_dump(cast5_ctx_t *s){
uint8_t i;
- uart_putstr("\r\n==== cast5_ctx_dump ====\r\n shortkey: ");
- uart_putstr(s->shortkey?"yes":"no");
+ cli_putstr("\r\n==== cast5_ctx_dump ====\r\n shortkey: ");
+ cli_putstr(s->shortkey?"yes":"no");
for(i=0;i<16;++i){
uint8_t r;
- uart_putstr("\r\n Km"); uart_hexdump(&i, 1); uart_putc(':');
- uart_hexdump(&(s->mask[i]), 4);
- uart_putstr("\r\n Kr"); uart_hexdump(&i, 1); uart_putc(':');
+ cli_putstr("\r\n Km"); cli_hexdump(&i, 1); cli_putc(':');
+ cli_hexdump(&(s->mask[i]), 4);
+ cli_putstr("\r\n Kr"); cli_hexdump(&i, 1); cli_putc(':');
r = (s->rotl[i/2]);
if (i&0x01) r >>= 4;
r &= 0xf;
r += (s->roth[i>>3]&(1<<(i&0x7)))?0x10:0x00;
- uart_hexdump(&r, 1);
+ cli_hexdump(&r, 1);
}
}
void test_encrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
cast5_ctx_t s;
if (print){
- uart_putstr("\r\nCAST5:\r\n key:\t");
- uart_hexdump(key, keylength/8);
- uart_putstr("\r\n plaintext:\t");
- uart_hexdump(block, 8);
+ cli_putstr("\r\nCAST5:\r\n key:\t");
+ cli_hexdump(key, keylength/8);
+ cli_putstr("\r\n plaintext:\t");
+ cli_hexdump(block, 8);
}
cast5_init(key, keylength, &s);
cast5_enc(block, &s);
if (print){
- uart_putstr("\r\n ciphertext:\t");
- uart_hexdump(block, 8);
+ cli_putstr("\r\n ciphertext:\t");
+ cli_hexdump(block, 8);
}
}
void test_decrypt(uint8_t *block, uint8_t *key, uint8_t keylength, bool print){
cast5_ctx_t s;
if (print){
- uart_putstr("\r\nCAST5:\r\n key:\t");
- uart_hexdump(key, keylength/8);
- uart_putstr("\r\n ciphertext:\t");
- uart_hexdump(block, 8);
+ cli_putstr("\r\nCAST5:\r\n key:\t");
+ cli_hexdump(key, keylength/8);
+ cli_putstr("\r\n ciphertext:\t");
+ cli_hexdump(block, 8);
}
cast5_init(key, keylength, &s);
cast5_dec(block, &s);
if (print){
- uart_putstr("\r\n plaintext:\t");
- uart_hexdump(block, 8);
+ cli_putstr("\r\n plaintext:\t");
+ cli_hexdump(block, 8);
}
}
test_decrypt(block, key, 40, true);
/**** long test *****/
- uart_putstr("\r\nmaintance-test");
+ cli_putstr("\r\nmaintance-test");
uint8_t a[16]= {0x01, 0x23, 0x45, 0x67, 0x12,
0x34, 0x56, 0x78, 0x23, 0x45,
0x67, 0x89, 0x34, 0x56, 0x78,
test_encrypt(&(b[0]), &(a[0]), 128, false);
test_encrypt(&(b[8]), &(a[0]), 128, false);
if ((i&0x000000ff) == 0){
- uart_putstr("\r\n");
- uart_hexdump(&i, 4);
+
+ cli_hexdump(&i, 4);
}
}
- uart_putstr("\r\na = "); uart_hexdump(a, 16);
- uart_putstr("\r\nb = "); uart_hexdump(b, 16);
+ cli_putstr("\r\na = "); cli_hexdump(a, 16);
+ cli_putstr("\r\nb = "); cli_hexdump(b, 16);
}
startTimer(1);
cast5_init(key, 128, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
cast5_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
cast5_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
des_enc(data, data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
des_dec(data, data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr(str);
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
uint32_t i=0;
while(!uart_getc_nb(&c)){
entropium_getRandomBlock(data);
- uart_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR("\r\n "));
ultoa(i, str, 10);
for(c=strlen(str); c<11; ++c){
- uart_putc(' ');
+ cli_putc(' ');
}
- uart_putstr(str);
+ cli_putstr(str);
++i;
- uart_putstr_P(PSTR(" : "));
- uart_hexdump(data, 32);
+ cli_putstr_P(PSTR(" : "));
+ cli_hexdump(data, 32);
}
- uart_putstr_P(PSTR("\r\n\r\n"));
+ cli_putstr_P(PSTR("\r\n\r\n"));
}
startTimer(1);
entropium_addEntropy(128, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tadd entropy time: "));
+ cli_putstr_P(PSTR("\r\n\tadd entropy time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
entropium_getRandomBlock(data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tget random time: "));
+ cli_putstr_P(PSTR("\r\n\tget random time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
cli_rx = uart_getc;
cli_tx = uart_putc;
+
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
/* 1 */
memset(key, 0, 10);
memset(iv, 0, 8);
- uart_putstr_P(PSTR("\r\n=== std test ==="));
- uart_putstr_P(PSTR("\r\n key: "));
- uart_hexdump(key, 10);
- uart_putstr_P(PSTR("\r\n iv: "));
- uart_hexdump(key, 8);
+ cli_putstr_P(PSTR("\r\n=== std test ==="));
+ cli_putstr_P(PSTR("\r\n key: "));
+ cli_hexdump(key, 10);
+ cli_putstr_P(PSTR("\r\n iv: "));
+ cli_hexdump(key, 8);
grain_init(key, iv, &ctx);
for(i=0; i<10; ++i){
out[i] = grain_getbyte_dummy(&ctx);
}
- uart_putstr_P(PSTR("\r\n out: "));
- uart_hexdump(out, 10);
+ cli_putstr_P(PSTR("\r\n out: "));
+ cli_hexdump(out, 10);
/* 2 */
for(i=0; i<8; ++i){
for(i=0; i<8; ++i){
iv[i] = i*0x22+1;
}
- uart_putstr_P(PSTR("\r\n\r\n key: "));
- uart_hexdump(key, 10);
- uart_putstr_P(PSTR("\r\n iv: "));
- uart_hexdump(key, 8);
+ cli_putstr_P(PSTR("\r\n\r\n key: "));
+ cli_hexdump(key, 10);
+ cli_putstr_P(PSTR("\r\n iv: "));
+ cli_hexdump(key, 8);
grain_init(key, iv, &ctx);
for(i=0; i<10; ++i){
out[i] = grain_getbyte_dummy(&ctx);
}
- uart_putstr_P(PSTR("\r\n out: "));
- uart_hexdump(out, 10);
+ cli_putstr_P(PSTR("\r\n out: "));
+ cli_hexdump(out, 10);
- uart_putstr_P(PSTR("\r\n\r\n"));
+ cli_putstr_P(PSTR("\r\n\r\n"));
}
void testrun_performance_grain(void){
startTimer(1);
grain_init(key, iv, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
grain_enc(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
uint16_t i;
- uart_putstr("\r\n=== MD5 test suit ===");
+ cli_putstr("\r\n=== MD5 test suit ===");
for(i=0; i<7; ++i){
cli_putstr("\r\n MD5 (\"");
cli_putstr(testv[i]);
startTimer(1);
md5_init(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
md5_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
md5_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
- * serpent test-suit
+ * noekeon test-suit
*
*/
void testrun_stdtest_rundirect(void* data, void* key){
- uart_putstr_P(PSTR("\r\n "));
- uart_putstr_P(PSTR("k = "));
- uart_hexdump(key,16);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR("k = "));
+ cli_hexdump(key,16);
- uart_putstr_P(PSTR("\r\n "));
- uart_putstr_P(PSTR("a = "));
- uart_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR("a = "));
+ cli_hexdump(data,16);
noekeon_enc(data, key);
- uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
- uart_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
+ cli_hexdump(data,16);
noekeon_dec(data, key);
- uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
- uart_hexdump(data,16);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
+ cli_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\n"));
}
void testrun_stdtest_runindirect(void* data, void* key){
noekeon_ctx_t ctx;
- uart_putstr_P(PSTR("\r\n "));
- uart_putstr_P(PSTR("k = "));
- uart_hexdump(key,16);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR("k = "));
+ cli_hexdump(key,16);
- uart_putstr_P(PSTR("\r\n "));
- uart_putstr_P(PSTR("a = "));
- uart_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\n "));
+ cli_putstr_P(PSTR("a = "));
+ cli_hexdump(data,16);
noekeon_init(key, &ctx);
noekeon_enc(data, &ctx);
- uart_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
- uart_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\nafter NESSIEencrypt, b = "));
+ cli_hexdump(data,16);
noekeon_dec(data, &ctx);
- uart_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
- uart_hexdump(data,16);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\nafter NESSIEdecrypt, a?= "));
+ cli_hexdump(data,16);
+ cli_putstr_P(PSTR("\r\n"));
}
void testrun_stdtest_noekeon(void){
uint8_t key3[16];
noekeon_ctx_t ctx;
- uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
+ cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Indirect-Key Mode:\r\n"));
memset(key, 0, 16);
memset(data, 0, 16);
noekeon_enc(data, &ctx);
testrun_stdtest_runindirect(data, key3);
- uart_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
+ cli_putstr_P(PSTR("\r\nTest vectors for block cipher Noekeon in Direct-Key Mode:\r\n"));
memset(key, 0, 16);
memset(data, 0, 16);
startTimer(1);
noekeon_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
noekeon_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
noekeon_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
void test_mac(void* key, void* data, uint16_t datalength_b){
uint8_t mac[16];
- uart_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
- uart_hexdump(((uint8_t*)&datalength_b)+1, 1);
- uart_hexdump(((uint8_t*)&datalength_b)+0, 1);
- uart_putstr_P(PSTR("\r\n msg: "));
- uart_hexdump(data, (datalength_b+7)/8);
- uart_putstr_P(PSTR("\r\n key: "));
- uart_hexdump(key, 16);
+ cli_putstr_P(PSTR("\r\n-----------\r\n msg length (bit): 0x"));
+ cli_hexdump(((uint8_t*)&datalength_b)+1, 1);
+ cli_hexdump(((uint8_t*)&datalength_b)+0, 1);
+ cli_putstr_P(PSTR("\r\n msg: "));
+ cli_hexdump(data, (datalength_b+7)/8);
+ cli_putstr_P(PSTR("\r\n key: "));
+ cli_hexdump(key, 16);
omac_noekeon(mac, data, datalength_b, key, (uint8_t)-1);
- uart_putstr_P(PSTR("\r\n mac: "));
- uart_hexdump(mac, 16);
+ cli_putstr_P(PSTR("\r\n mac: "));
+ cli_hexdump(mac, 16);
}
startTimer(1);
omac_noekeon_init(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
omac_noekeon_next(data, key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
omac_noekeon_last(data, 128, key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
void testrun_selfenc(uint8_t* key, uint8_t* buffer){
present_ctx_t ctx;
- uart_putstr_P(PSTR("\r\nkey : "));
- uart_hexdump(key, 10);
- uart_putstr_P(PSTR("\r\nplain : "));
- uart_hexdump(buffer, 8);
+ cli_putstr_P(PSTR("\r\nkey : "));
+ cli_hexdump(key, 10);
+ cli_putstr_P(PSTR("\r\nplain : "));
+ cli_hexdump(buffer, 8);
present_init(key, 80, &ctx);
present_enc(buffer, &ctx);
- uart_putstr_P(PSTR("\r\ncipher: "));
- uart_hexdump(buffer, 8);
+ cli_putstr_P(PSTR("\r\ncipher: "));
+ cli_hexdump(buffer, 8);
present_dec(buffer, &ctx);
- uart_putstr_P(PSTR("\r\nplain : "));
- uart_hexdump(buffer, 8);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\nplain : "));
+ cli_hexdump(buffer, 8);
+ cli_putstr_P(PSTR("\r\n"));
}
void testrun_self_present(void){
uint8_t buffer[8], key[10];
- uart_putstr_P(PSTR("\r\n\r\n=== Testvectors from the paper ===\r\n"));
+ cli_putstr_P(PSTR("\r\n\r\n=== Testvectors from the paper ===\r\n"));
memset(buffer, 0, 8);
memset(key, 0, 10);
t = stopTimer();
print_time_P(PSTR("\tdecrypt time: "), t);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
rc5_init(key, 128, RC5_ROUNDS, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc5_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc5_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc5_free(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tfree time: "));
+ cli_putstr_P(PSTR("\r\n\tfree time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr(str);
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
rc6_init(key, 128, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc6_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc6_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
rc6_free(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tfree time: "));
+ cli_putstr_P(PSTR("\r\n\tfree time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr(str);
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
seed_init(key, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
seed_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
seed_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
void testencrypt(uint8_t* block, uint8_t* key){
seed_ctx_t ctx;
- uart_putstr("\r\n==testy-encrypt==\r\n key: ");
- uart_hexdump(key,16);
+ cli_putstr("\r\n==testy-encrypt==\r\n key: ");
+ cli_hexdump(key,16);
seed_init(key, &ctx);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,16);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,16);
seed_enc(block, &ctx);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,16);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,16);
}
void testdecrypt(uint8_t* block, uint8_t* key){
seed_ctx_t ctx;
- uart_putstr("\r\n==testy-decrypt==\r\n key: ");
- uart_hexdump(key,16);
+ cli_putstr("\r\n==testy-decrypt==\r\n key: ");
+ cli_hexdump(key,16);
seed_init(key, &ctx);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,16);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,16);
seed_dec(block, &ctx);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,16);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,16);
}
void testrun_seed(void){
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
memset(key, 0, 16);
serpent_init(key, 128, &ctx);
for(i=0; i<33; ++i){
- uart_putstr_P(PSTR("\r\n subkekey "));
- uart_hexdump(&i, 1);
- uart_putstr_P(PSTR(" : "));
- uart_hexdump(ctx.k[i], 16);
+ cli_putstr_P(PSTR("\r\n subkekey "));
+ cli_hexdump(&i, 1);
+ cli_putstr_P(PSTR(" : "));
+ cli_hexdump(ctx.k[i], 16);
}
}
startTimer(1);
serpent_init(key, 0, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
serpent_enc(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
serpent_dec(data, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
void sha1_ctx_dump(sha1_ctx_t *s){
uint8_t i;
- uart_putstr("\r\n==== sha1_ctx_dump ====");
+ cli_putstr("\r\n==== sha1_ctx_dump ====");
for(i=0;i<5;++i){
- uart_putstr("\r\na["); uart_hexdump(&i, 1); uart_putstr("]: ");
- uart_hexdump(&(s->h[i]), 4);
+ cli_putstr("\r\na["); cli_hexdump(&i, 1); cli_putstr("]: ");
+ cli_hexdump(&(s->h[i]), 4);
}
- uart_putstr("\r\nlength"); uart_hexdump(&i, 8);
+ cli_putstr("\r\nlength"); cli_hexdump(&i, 8);
}
void testrun_sha1(void){
sha1_hash_t hash;
sha1(&hash,"abc",3*8);
- uart_putstr("\r\nsha1(\"abc\") = \r\n\t");
- uart_hexdump(hash,SHA1_HASH_BITS/8);
+ cli_putstr("\r\nsha1(\"abc\") = \r\n\t");
+ cli_hexdump(hash,SHA1_HASH_BITS/8);
sha1(&hash,"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",448);
- uart_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
- uart_hexdump(hash,SHA1_HASH_BITS/8);
+ cli_putstr("\r\nsha1(\"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq\") = \r\n\t");
+ cli_hexdump(hash,SHA1_HASH_BITS/8);
- uart_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
+ cli_putstr("\r\nsha1(1,000,000 * 'a') = \r\n\t");
{
uint8_t block[SHA1_BLOCK_BITS/8];
uint16_t i;
sha1_lastBlock(&s,block,0);
sha1_ctx2hash(&hash, &s);
}
- uart_hexdump(hash,SHA1_HASH_BITS/8);
+ cli_hexdump(hash,SHA1_HASH_BITS/8);
- uart_putstr("\r\nx");
+ cli_putstr("\r\nx");
}
sha1_ctx_t ctx;
sha1_hash_t hash;
sha1(&hash,"",0);
- uart_putstr("\r\nsha1(NULL) = \r\n\t");
- uart_hexdump(hash,SHA1_HASH_BYTES);
+ cli_putstr("\r\nsha1(NULL) = \r\n\t");
+ cli_hexdump(hash,SHA1_HASH_BYTES);
memset(hash, 0, SHA1_HASH_BYTES);
sha1_init(&ctx);
sha1_lastBlock(&ctx, "", 0);
sha1_ctx2hash(&hash, &ctx);
- uart_putstr("\r\nsha1(NULL) = \r\n\t");
- uart_hexdump(hash,SHA1_HASH_BYTES);
+ cli_putstr("\r\nsha1(NULL) = \r\n\t");
+ cli_hexdump(hash,SHA1_HASH_BYTES);
}
startTimer(1);
sha1_init(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
sha1_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
sha1_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&sha1_desc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
sha256_init(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
sha256_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
sha256_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
shavs_algolist=(hfdesc_t**)algolist;
shavs_algo=(hfdesc_t*)&sha256_desc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
shabea256(data, key, 256, 1, 16);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
shabea256(data, key, 256, 0, 16);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
*****************************************************************************/
void testencrypt(uint8_t* block, uint8_t* key){
- uart_putstr("\r\n==testy-encrypt==\r\n key: ");
- uart_hexdump(key,16);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,32);
+ cli_putstr("\r\n==testy-encrypt==\r\n key: ");
+ cli_hexdump(key,16);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,32);
shabea256(block,key,128,1,16);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,32);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,32);
}
void testdecrypt(uint8_t* block, uint8_t* key){
- uart_putstr("\r\n==testy-decrypt==\r\n key: ");
- uart_hexdump(key,16);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,32);
+ cli_putstr("\r\n==testy-decrypt==\r\n key: ");
+ cli_hexdump(key,16);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,32);
shabea256(block,key,128,0,16);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,32);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,32);
}
void testrun_shabea(void){
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
t = stopTimer();
print_time_P(PSTR("\tencrypt time: "), t);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
t = stopTimer();
print_time_P(PSTR("\tencrypt time: "), t);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
skipjack_enc(data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
skipjack_dec(data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
*****************************************************************************/
void testencrypt(uint8_t* block, uint8_t* key){
- uart_putstr("\r\n==testy-encrypt==\r\n key: ");
- uart_hexdump(key,10);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,8);
+ cli_putstr("\r\n==testy-encrypt==\r\n key: ");
+ cli_hexdump(key,10);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,8);
skipjack_enc(block,key);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,8);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,8);
}
void testdecrypt(uint8_t* block, uint8_t* key){
- uart_putstr("\r\n==testy-decrypt==\r\n key: ");
- uart_hexdump(key,10);
- uart_putstr("\r\n crypt: ");
- uart_hexdump(block,8);
+ cli_putstr("\r\n==testy-decrypt==\r\n key: ");
+ cli_hexdump(key,10);
+ cli_putstr("\r\n crypt: ");
+ cli_hexdump(block,8);
skipjack_dec(block,key);
- uart_putstr("\r\n plain: ");
- uart_hexdump(block,8);
+ cli_putstr("\r\n plain: ");
+ cli_hexdump(block,8);
}
void testrun_skipjack(void){
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
tdes_enc(data, data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
tdes_dec(data, data, key);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tdecrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tdecrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr(str);
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
* main *
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
startTimer(1);
trivium_init(key, 80, iv, 80, &ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
trivium_enc(&ctx);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tencrypt time: "));
+ cli_putstr_P(PSTR("\r\n\tencrypt time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
uint32_t i;
- uart_putstr_P(PSTR("\r\n=== TWISTER-224 test suit (MD5 test values) ==="));
+ cli_putstr_P(PSTR("\r\n=== TWISTER-224 test suit (MD5 test values) ==="));
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-224 (\""));
- uart_putstr(testv[i]);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-224 (\""));
+ cli_putstr(testv[i]);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister224(&hash, testv[i], strlen(testv[i])*8);
- uart_hexdump(hash, 224/8);
+ cli_hexdump(hash, 224/8);
}
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-224 test suit (short test values) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-224 test suit (short test values) ==="));
uint8_t stestv[]= {0x00, 0x00, 0xC0, 0xC0, 0x80, 0x48, 0x50};
uint8_t stestl[]= { 0, 1, 2, 3, 4, 5, 6};
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-224 (\""));
- uart_hexdump(&(stestv[i]), 1);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-224 (\""));
+ cli_hexdump(&(stestv[i]), 1);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister224(&hash, &(stestv[i]), stestl[i]);
- uart_hexdump(hash, 224/8);
+ cli_hexdump(hash, 224/8);
}
#ifdef TWISTER_LONGTEST
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-224 test suit (long test) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-224 test suit (long test) ==="));
char* ltest= "abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno";
twister224_ctx_t ctx;
twister224_init(&ctx);
- uart_putstr_P(PSTR("\r\n TWISTER-224 ( 16777216 x \""));
- uart_putstr(ltest);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-224 ( 16777216 x \""));
+ cli_putstr(ltest);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
for(i=0; i<16777216; ++i){
twister224_nextBlock(&ctx, ltest);
}
twister224_ctx2hash(hash, &ctx);
- uart_hexdump(hash, 224/8);
+ cli_hexdump(hash, 224/8);
#endif
}
startTimer(1);
twister_small_init(&ctx, 224);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
i=3000;
while(i--)
startTimer(1);
twister_small_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
i=3000;
while(i--)
startTimer(1);
twister_small_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
i=3000;
while(i--)
startTimer(1);
twister_small_ctx2hash(data, &ctx, 224);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx2hash time: "));
+ cli_putstr_P(PSTR("\r\n\tctx2hash time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
i=3000;
while(i--)
_delay_ms(1);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
*****************************************************************************/
void print_hash(void* hash){
- uart_hexdump(hash, 256/8);
+ cli_hexdump(hash, 256/8);
}
void testrun_twister256(void){
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
uint32_t i;
- uart_putstr_P(PSTR("\r\n=== TWISTER-256 test suit (MD5 test values) ==="));
+ cli_putstr_P(PSTR("\r\n=== TWISTER-256 test suit (MD5 test values) ==="));
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-256 (\""));
- uart_putstr(testv[i]);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-256 (\""));
+ cli_putstr(testv[i]);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister256(&hash, testv[i], strlen(testv[i])*8);
print_hash(hash);
}
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (short test values) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (short test values) ==="));
uint8_t stestv[]= {0x00, 0x00, 0xC0, 0xC0, 0x80, 0x48, 0x50};
uint8_t stestl[]= { 0, 1, 2, 3, 4, 5, 6};
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-256 (\""));
- uart_hexdump(&(stestv[i]), 1);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-256 (\""));
+ cli_hexdump(&(stestv[i]), 1);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister256(&hash, &(stestv[i]), stestl[i]);
print_hash(hash);
}
#ifdef TWISTER_LONGTEST
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (long test) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-256 test suit (long test) ==="));
char* ltest= "abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno";
twister256_ctx_t ctx;
twister256_init(&ctx);
- uart_putstr_P(PSTR("\r\n TWISTER-256 ( 16777216 x \""));
- uart_putstr(ltest);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-256 ( 16777216 x \""));
+ cli_putstr(ltest);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
for(i=0; i<16777216; ++i){
twister224_nextBlock(&ctx, ltest);
}
startTimer(1);
twister_small_init(&ctx, 256);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_small_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_small_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_small_ctx2hash(data, &ctx, 256);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx2hash time: "));
+ cli_putstr_P(PSTR("\r\n\tctx2hash time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
******************************************************************************/
void print_hash(void* hash){
- uart_hexdump(hash, 256/8);
- uart_putstr_P(PSTR("\r\n\t"));
- uart_hexdump((uint8_t*)hash+256/8, 128/8);
+ cli_hexdump(hash, 256/8);
+ cli_putstr_P(PSTR("\r\n\t"));
+ cli_hexdump((uint8_t*)hash+256/8, 128/8);
}
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
uint32_t i;
- uart_putstr_P(PSTR("\r\n=== TWISTER-384 test suit (MD5 test values) ==="));
+ cli_putstr_P(PSTR("\r\n=== TWISTER-384 test suit (MD5 test values) ==="));
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-384 (\""));
- uart_putstr(testv[i]);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-384 (\""));
+ cli_putstr(testv[i]);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister384(&hash, testv[i], strlen(testv[i])*8);
print_hash(hash);
// return;
}
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-384 test suit (short test values) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-384 test suit (short test values) ==="));
uint8_t stestv[]= {0x00, 0x00, 0xC0, 0xC0, 0x80, 0x48, 0x50};
uint8_t stestl[]= { 0, 1, 2, 3, 4, 5, 6};
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-384 (\""));
- uart_hexdump(&(stestv[i]), 1);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-384 (\""));
+ cli_hexdump(&(stestv[i]), 1);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister384(hash, &(stestv[i]), stestl[i]);
print_hash(hash);
}
#ifdef TWISTER_LONGTEST
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-384 test suit (long test) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-384 test suit (long test) ==="));
char* ltest= "abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno";
twister384_ctx_t ctx;
twister384_init(&ctx);
- uart_putstr_P(PSTR("\r\n TWISTER-384 ( 16777216 x \""));
- uart_putstr(ltest);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-384 ( 16777216 x \""));
+ cli_putstr(ltest);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
for(i=0; i<16777216; ++i){
twister384_nextBlock(&ctx, ltest);
}
startTimer(1);
twister_big_init(&ctx, 384);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_ctx2hash(data, &ctx, 384);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx2hash time: "));
+ cli_putstr_P(PSTR("\r\n\tctx2hash time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
******************************************************************************/
void print_hash(void* hash){
- uart_hexdump(hash, 256/8);
- uart_putstr_P(PSTR("\r\n\t"));
- uart_hexdump((uint8_t*)hash+256/8, 256/8);
+ cli_hexdump(hash, 256/8);
+ cli_putstr_P(PSTR("\r\n\t"));
+ cli_hexdump((uint8_t*)hash+256/8, 256/8);
}
"12345678901234567890123456789012345678901234567890123456789012345678901234567890"};
uint32_t i;
- uart_putstr_P(PSTR("\r\n=== TWISTER-512 test suit (MD5 test values) ==="));
+ cli_putstr_P(PSTR("\r\n=== TWISTER-512 test suit (MD5 test values) ==="));
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-512 (\""));
- uart_putstr(testv[i]);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-512 (\""));
+ cli_putstr(testv[i]);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister512(&hash, testv[i], strlen(testv[i])*8);
print_hash(hash);
// return;
}
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-512 test suit (short test values) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-512 test suit (short test values) ==="));
uint8_t stestv[]= {0x00, 0x00, 0xC0, 0xC0, 0x80, 0x48, 0x50};
uint8_t stestl[]= { 0, 1, 2, 3, 4, 5, 6};
for(i=0; i<7; ++i){
- uart_putstr_P(PSTR("\r\n TWISTER-512 (\""));
- uart_hexdump(&(stestv[i]), 1);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-512 (\""));
+ cli_hexdump(&(stestv[i]), 1);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
twister512(hash, &(stestv[i]), stestl[i]);
print_hash(hash);
}
#ifdef TWISTER_LONGTEST
- uart_putstr_P(PSTR("\r\n\r\n=== TWISTER-512 test suit (long test) ==="));
+ cli_putstr_P(PSTR("\r\n\r\n=== TWISTER-512 test suit (long test) ==="));
char* ltest= "abcdefghbcdefghicdefghijdefghijk"
"efghijklfghijklmghijklmnhijklmno";
twister512_ctx_t ctx;
twister512_init(&ctx);
- uart_putstr_P(PSTR("\r\n TWISTER-512 ( 16777216 x \""));
- uart_putstr(ltest);
- uart_putstr_P(PSTR("\") = \r\n\t"));
+ cli_putstr_P(PSTR("\r\n TWISTER-512 ( 16777216 x \""));
+ cli_putstr(ltest);
+ cli_putstr_P(PSTR("\") = \r\n\t"));
for(i=0; i<16777216; ++i){
twister512_nextBlock(&ctx, ltest);
}
startTimer(1);
twister_big_init(&ctx, 512);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx-gen time: "));
+ cli_putstr_P(PSTR("\r\n\tctx-gen time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_nextBlock(&ctx, data);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tone-block time: "));
+ cli_putstr_P(PSTR("\r\n\tone-block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_lastBlock(&ctx, data, 0);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tlast block time: "));
+ cli_putstr_P(PSTR("\r\n\tlast block time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
startTimer(1);
twister_big_ctx2hash(data, &ctx, 512);
t = stopTimer();
- uart_putstr_P(PSTR("\r\n\tctx2hash time: "));
+ cli_putstr_P(PSTR("\r\n\tctx2hash time: "));
ultoa((unsigned long)t, str, 10);
- uart_putstr(str);
+ cli_putstr(str);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
t = stopTimer();
print_time_P(PSTR("\tdecrypt time: "), t);
- uart_putstr_P(PSTR("\r\n"));
+ cli_putstr_P(PSTR("\r\n"));
}
/*****************************************************************************
int main (void){
DEBUG_INIT();
- uart_putstr("\r\n");
+
cli_rx = uart_getc;
cli_tx = uart_putc;
for(;;){
- uart_putstr_P(PSTR("\r\n\r\nCrypto-VS ("));
- uart_putstr(algo_name);
- uart_putstr_P(PSTR(")\r\nloaded and running\r\n"));
+ 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);
}
}
* */
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
#include "nessie_mac_test.h"
#include "nessie_common.h"
#include "uart.h"
}
static
-void tv4_mac(uint8_t* key){
+void tv4_mac(void){
uint8_t ctx[nessie_mac_ctx.ctx_size_B];
uint8_t mac[MACSIZE_B];
- uint8_t block[256/8];
- uint16_t n=256;
+ uint8_t block[MACSIZE_B];
+ uint8_t core_key[] = {
+ 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
+ 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
+ 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF
+ };
+ uint8_t key[KEYSIZE_B];
+ uint16_t n=MACSIZE_B*8;
uint32_t i;
+ char str[6];
NESSIE_PUTSTR_P(PSTR("\r\n message="));
- NESSIE_PUTSTR(PSTR("256 zero bits"));
- memset(block, 0, 256/8);
-
- nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);;
+ utoa(MACSIZE_B*8, str, 10);
+ NESSIE_PUTSTR(str);
+ NESSIE_PUTSTR_P(PSTR(" zero bits"));
+ memset(block, 0, MACSIZE_B);
+ for(i=0; i<KEYSIZE_B; ++i)
+ key[i] = core_key[i%(3*8)];
+ nessie_print_item("key", key, KEYSIZE_B);
+ nessie_mac_ctx.mac_init(key, nessie_mac_ctx.keysize_b, ctx);
while(n>nessie_mac_ctx.blocksize_B*8){
nessie_mac_ctx.mac_next(block, ctx);
n -= nessie_mac_ctx.blocksize_B*8;
nessie_print_setheader(set);
/* we use the same key as above */
nessie_print_set_vector(set, 0);
- tv4_mac(key);
+ tv4_mac();
/* test set 5 */
+ set=5;
+ nessie_print_setheader(set);
for(i=0; i<nessie_mac_ctx.keysize_b; ++i){
nessie_print_set_vector(set, i);
memset(key, 0, KEYSIZE_B);
#ifdef UART_XON_XOFF
+#define XON 0x11
+#define XOFF 0x13
+
#ifdef UART_INTERRUPT
void uart_insertc(char c);
#else
Test vectors -- set 4\r
=====================\r
\r
-Iterated message digest computation (100000 times): Set 4, vector# 0:\r
+Iterated message digest computation (100000 times):
+Set 4, vector# 0:\r
message=160 zero bits\r
key=00112233445566778899AABBCCDDEEFF\r
0123456789ABCDEF0011223344556677\r
Test vectors -- set 4\r
=====================\r
\r
-Iterated message digest computation (100000 times): Set 4, vector# 0:\r
+Iterated message digest computation (100000 times):
+Set 4, vector# 0:\r
message=256 zero bits\r
key=00112233445566778899AABBCCDDEEFF\r
0123456789ABCDEF0011223344556677\r