fixing some bugs of performance measurment
This commit is contained in:
parent
4787ed5e98
commit
b022a029de
30
Makefile
30
Makefile
|
@ -149,6 +149,36 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
|
|||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
define Speed_Template
|
||||
$(1)_SPEED: $(1)_FLASH
|
||||
@$(RUBY) $(SPEEDTOOL) -c $(SPEEDCMD) -t $(SPEEDLOG_DIR) -a $(call lc, $(1))
|
||||
endef
|
||||
|
||||
$(foreach algo, $(ALGORITHMS), $(eval $(call Speed_Template, \
|
||||
$(algo), $(algo) \
|
||||
)))
|
||||
|
||||
.PHONY: hash_speed
|
||||
hash_speed: $(foreach algo, $(HASHES), $(algo)_SPEED)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
define Size_Template
|
||||
$(1)_SIZE: $(2)
|
||||
@echo "[size] $(1)"
|
||||
$(SIZE) $(2) > $(strip $(SIZE_DIR))$(strip $(call lc, $(1))).size
|
||||
endef
|
||||
|
||||
$(foreach algo, $(ALGORITHMS), $(eval $(call Size_Template, \
|
||||
$(strip $(algo)), $($(algo)_BINOBJ) \
|
||||
)))
|
||||
|
||||
.PHONY: hash_size
|
||||
hash_size: $(foreach algo, $(HASHES), $(algo)_SIZE)
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
.PHONY: tests
|
||||
tests: $(foreach a, $(ALGORITHMS), $(a)_TEST_BIN)
|
||||
|
||||
|
|
|
@ -14,13 +14,16 @@ TESTSRC_DIR = test_src/
|
|||
ERASECMD =
|
||||
TESTPORT = /dev/ttyUSB1
|
||||
TESTPORTBAUDR = 38400
|
||||
TESTLOG_DIR = testlog/
|
||||
TESTLOG_DIR = testlog/#
|
||||
TESTPREFIX = nessie-
|
||||
SPEEDTOOL = host/get_performance.rb
|
||||
SPEEDLOG_DIR = speed_log/
|
||||
SPEEDPREFIX =
|
||||
LIST_DIR = listings/
|
||||
STAT_DIR = stats/
|
||||
AUTOASM_DIR = autoasm/
|
||||
SPEEDCMD = performance
|
||||
SIZE_DIR = size_log/#
|
||||
LIST_DIR = listings/#
|
||||
STAT_DIR = stats/#
|
||||
AUTOASM_DIR = autoasm/#
|
||||
AUTOASM_OPT = -S
|
||||
CC = avr-gcc
|
||||
CSTD = c99
|
||||
|
@ -39,7 +42,6 @@ SIZE = avr-size
|
|||
READELF = readelf
|
||||
RUBY = ruby
|
||||
GET_TEST = host/get_test.rb
|
||||
GET_PERFORMANCE = host/get_performance.rb
|
||||
MAKE = make
|
||||
MAKE2GRAPH = ~/bin/make2graph.rb
|
||||
TWOPI = twopi
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
|
||||
static
|
||||
void printvalue(unsigned int v){
|
||||
void printvalue(unsigned long v){
|
||||
char str[20];
|
||||
int i;
|
||||
ultoa(v, str, 10);
|
||||
|
@ -53,6 +53,7 @@ void hfal_performance(const hfdesc_t* hd){
|
|||
uint8_t data[(hf.blocksize_b+7)/8];
|
||||
uint8_t digest[(hf.hashsize_b+7)/8];
|
||||
uint64_t t;
|
||||
uint8_t i;
|
||||
|
||||
if(hf.type!=HFDESC_TYPE_HASHFUNCTION)
|
||||
return;
|
||||
|
@ -71,35 +72,51 @@ void hfal_performance(const hfdesc_t* hd){
|
|||
cli_putstr_P(PSTR("\r\n blocksize (bits): "));
|
||||
printvalue(hf.blocksize_b);
|
||||
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.init(&ctx);
|
||||
STOP_TIMER;
|
||||
t = stopTimer();
|
||||
t=0;
|
||||
for(i=0; i<32; ++i){
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.init(&ctx);
|
||||
STOP_TIMER;
|
||||
t += stopTimer();
|
||||
}
|
||||
t>>=5;
|
||||
cli_putstr_P(PSTR("\r\n init (cycles): "));
|
||||
printvalue(t);
|
||||
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.nextBlock(&ctx, data);
|
||||
STOP_TIMER;
|
||||
t = stopTimer();
|
||||
t=0;
|
||||
for(i=0; i<32; ++i){
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.nextBlock(&ctx, data);
|
||||
STOP_TIMER;
|
||||
t += stopTimer();
|
||||
}
|
||||
t>>=5;
|
||||
cli_putstr_P(PSTR("\r\n nextBlock (cycles): "));
|
||||
printvalue(t);
|
||||
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.lastBlock(&ctx, data, 0);
|
||||
STOP_TIMER;
|
||||
t = stopTimer();
|
||||
t=0;
|
||||
for(i=0; i<32; ++i){
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.lastBlock(&ctx, data, 0);
|
||||
STOP_TIMER;
|
||||
t += stopTimer();
|
||||
}
|
||||
t>>=5;
|
||||
cli_putstr_P(PSTR("\r\n lastBlock (cycles): "));
|
||||
printvalue(t);
|
||||
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.ctx2hash(digest, &ctx);
|
||||
STOP_TIMER;
|
||||
t = stopTimer();
|
||||
t=0;
|
||||
for(i=0; i<32; ++i){
|
||||
startTimer(0);
|
||||
START_TIMER;
|
||||
hf.ctx2hash(digest, &ctx);
|
||||
STOP_TIMER;
|
||||
t += stopTimer();
|
||||
}
|
||||
t>>=5;
|
||||
cli_putstr_P(PSTR("\r\n ctx2hash (cycles): "));
|
||||
printvalue(t);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,126 @@
|
|||
#!/usr/bin/ruby
|
||||
# performnce to wiki
|
||||
|
||||
=begin
|
||||
This file is part of the AVR-Crypto-Lib.
|
||||
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
=end
|
||||
|
||||
=begin
|
||||
=== Twister-256 performance ===
|
||||
type: hash
|
||||
hashsize (bits): 256
|
||||
ctxsize (bytes): 80
|
||||
blocksize (bits): 512
|
||||
init (cycles): 425
|
||||
nextBlock (cycles): 36535
|
||||
lastBlock (cycles): 8071
|
||||
ctx2hash (cycles): 19431
|
||||
|
||||
text data bss dec hex filename
|
||||
6801 32 0 6833 1ab1 bin/bmw_c/bmw_small.o
|
||||
=end
|
||||
|
||||
def get_size_string(fsize)
|
||||
str = ''
|
||||
sum = 0
|
||||
lb = fsize.readline()
|
||||
loop do
|
||||
return sum.to_s() + str if fsize.eof()
|
||||
lb = fsize.readline()
|
||||
m = lb.match(/[\s]*([\w]*)[\s]*([\w]*)[\s]*([\w]*)[\s]*([\w]*)[\s]*([\w]*)[\s]*([\w_\/-]*)/)
|
||||
name = m[6].match(/\/([^\/]*)$/)[1]
|
||||
str += "<br> \n" + name+': '+m[4]
|
||||
sum += m[4].to_i
|
||||
end
|
||||
end
|
||||
|
||||
def process_hashfunction(fin, name, fsize)
|
||||
lb = fin.readline()
|
||||
m = lb.match(/hashsize \(bits\):[\s]*([\d]*)/)
|
||||
if(!m)
|
||||
printf("unexpected string %s\n", lb)
|
||||
end
|
||||
hashsize = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/ctxsize \(bytes\):[\s]*([\d]*)/)
|
||||
ctxsize = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/blocksize \(bits\):[\s]*([\d]*)/)
|
||||
blocksize = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/init \(cycles\):[\s]*([\d]*)/)
|
||||
inittime = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/nextBlock \(cycles\):[\s]*([\d]*)/)
|
||||
nextblocktime = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/lastBlock \(cycles\):[\s]*([\d]*)/)
|
||||
lastblocktime = m[1].to_i()
|
||||
lb = fin.readline()
|
||||
m = lb.match(/ctx2hash \(cycles\):[\s]*([\d]*)/)
|
||||
convtime = m[1].to_i()
|
||||
size = get_size_string(fsize)
|
||||
printf("| %20s || %3s || %3s \n| %s \n| %4d || || %4d || %4d ||" +
|
||||
" %6d || %6d || %7.2f || %6d || || || \n|-\n" ,
|
||||
name, $lang, $lang, size, ctxsize, hashsize, blocksize,
|
||||
inittime, nextblocktime, nextblocktime.to_f/(blocksize/8),
|
||||
lastblocktime+convtime)
|
||||
end
|
||||
|
||||
|
||||
$handlers = Hash.new
|
||||
$handlers.default = 0
|
||||
$handlers["hashfunction"] = 1 #process_hashfunction
|
||||
|
||||
def process_file(fname)
|
||||
fin = File.open(fname, "r")
|
||||
$lang = "asm"
|
||||
$lang = "C" if fname.match(/_c.txt$/)
|
||||
algo = fname.match(/.([^.]*).txt$/)[1]
|
||||
size_filename = 'size_log/'+algo+'.size'
|
||||
fsize = File.open(size_filename, "r")
|
||||
begin
|
||||
begin
|
||||
if fin.eof()
|
||||
return
|
||||
end
|
||||
lb = fin.readline()
|
||||
end while !m=lb.match(/=== (.*) performance ===/)
|
||||
name = m[1];
|
||||
lb = fin.readline()
|
||||
m = lb.match(/type:[\s]*([\w]*)/)
|
||||
type = m[1]
|
||||
if $handlers[type] != 0
|
||||
# handlers[type](fin, name)
|
||||
process_hashfunction(fin, name, fsize)
|
||||
else
|
||||
printf("ERROR: unsupported type: %s !\n", type)
|
||||
end
|
||||
end while(true)
|
||||
fin.close()
|
||||
end
|
||||
|
||||
for i in (0..ARGV.size-1)
|
||||
process_file(ARGV[i])
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
#!/usr/bin/ruby
|
||||
# performnce to wiki
|
||||
|
||||
=begin
|
||||
This file is part of the AVR-Crypto-Lib.
|
||||
Copyright (C) 2009 Daniel Otte (daniel.otte@rub.de)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
=end
|
||||
|
||||
=begin
|
||||
| Blake-28 || C || C
|
||||
| 10916<br>
|
||||
blake_small: 3494<br>
|
||||
blake_large: 7142<br>
|
||||
blake_common: 256<br>
|
||||
memxor: 24
|
||||
| 53 || || 224 || 512 || 386 || 71362 || 1115.03 || 71893 || || ||
|
||||
|-
|
||||
|
||||
=end
|
||||
|
||||
|
||||
def fix_file(fin, fout)
|
||||
loop do
|
||||
return if fin.eof()
|
||||
comp = Array.new
|
||||
i = 0
|
||||
lb1 = fin.readline()
|
||||
lb2 = fin.readline()
|
||||
begin
|
||||
comp[i] = fin.readline()
|
||||
i += 1
|
||||
end until comp[i-1].match(/^\|/)
|
||||
sum = 0
|
||||
(i-1).times{ |j| sum += comp[j].match(/[^:]*:[\s]*([\d]*)/)[1].to_i}
|
||||
fout.puts(lb1)
|
||||
fout.printf("| %d <br>\n", sum)
|
||||
comp.each{ |s| fout.puts(s)}
|
||||
begin
|
||||
lb1 = fin.readline()
|
||||
fout.puts(lb1)
|
||||
end until lb1.match(/^\|\-/)
|
||||
end
|
||||
end
|
||||
|
||||
################################################################################
|
||||
# MAIN #
|
||||
################################################################################
|
||||
|
||||
fin = STDIN
|
||||
fout = STDOUT
|
||||
|
||||
|
||||
fin = File.open(ARGV[0], "r") if ARGV.size > 0
|
||||
fout = File.open(ARGV[1], "w") if ARGV.size > 1
|
||||
|
||||
fix_file(fin, fout)
|
||||
|
||||
fin.close if ARGV.size > 0
|
||||
fout.close if ARGV.size > 1
|
||||
|
|
@ -18,10 +18,54 @@
|
|||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
=end
|
||||
|
||||
$debug = false
|
||||
require 'rubygems'
|
||||
require 'serialport'
|
||||
require 'getopt/std'
|
||||
$conffile_check = Hash.new
|
||||
$conffile_check.default = 0
|
||||
|
||||
################################################################################
|
||||
# readconfigfile #
|
||||
################################################################################
|
||||
|
||||
def readconfigfile(fname, conf)
|
||||
return conf if $conffile_check[fname]==1
|
||||
$conffile_check[fname]=1
|
||||
section = "default"
|
||||
if not File.exists?(fname)
|
||||
return conf
|
||||
end
|
||||
file = File.open(fname, "r")
|
||||
until file.eof
|
||||
line = file.gets()
|
||||
next if /[\s]*#/.match(line)
|
||||
if m=/\[[\s]*([^\s]*)[\s]*\]/.match(line)
|
||||
section=m[1]
|
||||
conf[m[1]] = Hash.new
|
||||
next
|
||||
end
|
||||
next if not /=/.match(line)
|
||||
m=/[\s]*([^\s]*)[\s]*=[\s]*([^\s]*)/.match(line)
|
||||
if m[1]=="include"
|
||||
Dir.glob(m[2]){ |fn| conf = readconfigfile(fn, conf) }
|
||||
else
|
||||
conf[section][m[1]] = m[2]
|
||||
end
|
||||
end
|
||||
file.close()
|
||||
return conf
|
||||
end
|
||||
|
||||
################################################################################
|
||||
# read_line #
|
||||
################################################################################
|
||||
|
||||
def read_line(error_msg=true)
|
||||
s = $sp.gets()
|
||||
i=$extended_wait
|
||||
begin
|
||||
s = $sp.gets()
|
||||
end until s or i==0
|
||||
if s==nil
|
||||
puts("ERROR: read timeout!\n") if error_msg
|
||||
return nil
|
||||
|
@ -29,6 +73,10 @@ def read_line(error_msg=true)
|
|||
s.gsub(/\006/, '');
|
||||
end
|
||||
|
||||
################################################################################
|
||||
# readPerformanceVector #
|
||||
################################################################################
|
||||
|
||||
def readPerformanceVector(param)
|
||||
lb=""
|
||||
buffer=""
|
||||
|
@ -55,22 +103,58 @@ def readPerformanceVector(param)
|
|||
end while true
|
||||
end
|
||||
|
||||
################################################################################
|
||||
# MAIN #
|
||||
################################################################################
|
||||
|
||||
if ARGV.size < 5
|
||||
|
||||
opts = Getopt::Std.getopts("f:c:t:a:d")
|
||||
|
||||
conf = Hash.new
|
||||
conf = readconfigfile("/etc/testport.conf", conf)
|
||||
conf = readconfigfile("~/.testport.conf", conf)
|
||||
conf = readconfigfile("testport.conf", conf)
|
||||
conf = readconfigfile(opts["f"], conf) if opts["f"]
|
||||
|
||||
#puts conf.inspect
|
||||
|
||||
puts("serial port interface version: " + SerialPort::VERSION);
|
||||
$linewidth = 64
|
||||
params = { "baud" => conf["PORT"]["baud"].to_i,
|
||||
"data_bits" => conf["PORT"]["databits"].to_i,
|
||||
"stop_bits" => conf["PORT"]["stopbits"].to_i,
|
||||
"parity" => SerialPort::NONE }
|
||||
params["paraty"] = SerialPort::ODD if conf["PORT"]["paraty"].downcase == "odd"
|
||||
params["paraty"] = SerialPort::EVEN if conf["PORT"]["paraty"].downcase == "even"
|
||||
params["paraty"] = SerialPort::MARK if conf["PORT"]["paraty"].downcase == "mark"
|
||||
params["paraty"] = SerialPort::SPACE if conf["PORT"]["paraty"].downcase == "space"
|
||||
|
||||
puts("\nPort: "+conf["PORT"]["port"]+"@" +
|
||||
params["baud"].to_s +
|
||||
" " +
|
||||
params["data_bits"].to_s +
|
||||
conf["PORT"]["paraty"][0,1].upcase +
|
||||
params["stop_bits"].to_s +
|
||||
"\n")
|
||||
|
||||
$sp = SerialPort.new(conf["PORT"]["port"], params)
|
||||
|
||||
$sp.read_timeout=1000; # 5 minutes
|
||||
$sp.flow_control = SerialPort::SOFT
|
||||
=begin
|
||||
if ARGV.size < 1
|
||||
STDERR.print <<EOF
|
||||
Usage: ruby #{$0} port bps nbits stopb command [target_dir] [additional specifier]
|
||||
Usage: ruby #{$0} -c command [-t target_dir] [-a additional specifier]
|
||||
EOF
|
||||
exit(1)
|
||||
end
|
||||
=end
|
||||
|
||||
command=ARGV[4]+"\r";
|
||||
$dir=(ARGV.size>=6)?ARGV[5]:"";
|
||||
param=(ARGV.size>=7)?ARGV[6]:"";
|
||||
command=opts['c']+"\r";
|
||||
$dir=(opts['t'])?opts['t']:"";
|
||||
param=(opts['a'])?opts['a']:"";
|
||||
|
||||
puts("\nPort: "+ARGV[0]+ "@"+ARGV[1]+" "+ARGV[2]+"N"+ARGV[3]+"\n");
|
||||
$linewidth = 16
|
||||
$sp = SerialPort.new(ARGV[0], ARGV[1].to_i, ARGV[2].to_i, ARGV[3].to_i, SerialPort::NONE);
|
||||
$sp.read_timeout=1000; # 1 secound
|
||||
$extended_wait=100;
|
||||
$sp.write(command);
|
||||
|
||||
|
|
8
main.dox
8
main.dox
|
@ -50,6 +50,13 @@
|
|||
- MD5 (md5.h)
|
||||
- SHA-1 (sha1.h)
|
||||
- SHA-256 (sha256.h)
|
||||
- Blake
|
||||
- Blue Midnight Wish
|
||||
- Grøstl
|
||||
- Keccak
|
||||
- Shabal
|
||||
- Skein
|
||||
- Twister
|
||||
|
||||
\subsection MACs Message-Authentification-Codes (MACs)
|
||||
Message-Authentification-Codes work like hash function but take an additional
|
||||
|
@ -59,6 +66,7 @@
|
|||
Implemented MAC functions:
|
||||
- HMAC-SHA-1 (hmac-sha1.h)
|
||||
- HMAC-SHA-256 (hmac-sha256.h)
|
||||
|
||||
|
||||
\subsection PRNGs Pseudo-Random-Number-Generators (PRNGs)
|
||||
PRNGs produce pseudo random output determinated by the input. They aim to
|
||||
|
|
|
@ -67,8 +67,7 @@ void startTimer(uint8_t granularity){
|
|||
TCNT1 = 0;
|
||||
ovfcounter = 0;
|
||||
TCCR1A = 0x00;
|
||||
TIMSK &= 0xC3;
|
||||
TIMSK |= _BV(TOIE1); /* enable TOIE1 */
|
||||
TIMSK = _BV(TOIE1); /* enable TOIE1 */
|
||||
TCCR1B = granularity & 0x7; /* start timer */
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,8 @@
|
|||
#include <avr/interrupt.h>
|
||||
|
||||
|
||||
#define START_TIMER TCCR1B=1
|
||||
#define STOP_TIMER TCCR1B=0
|
||||
#define START_TIMER TCCR1B=1
|
||||
#define STOP_TIMER TCCR1B=0
|
||||
|
||||
void calibrateTimer(void);
|
||||
void startTimer(uint8_t granularity);
|
||||
|
|
Loading…
Reference in New Issue