diff --git a/bcal/keysize_descriptor.c b/bcal/keysize_descriptor.c
new file mode 100644
index 0000000..579ef56
--- /dev/null
+++ b/bcal/keysize_descriptor.c
@@ -0,0 +1,161 @@
+/* keysize_descriptor.c */
+/*
+ This file is part of the ARM-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 .
+*/
+/**
+ * \file keysize_descriptor.c
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-01-07
+ * \license GPLv3 or later
+ */
+
+#include
+#include
+#include "keysize_descriptor.h"
+
+uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize){
+ uint8_t type;
+ type = *((uint8_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 1;
+ if(type==KS_TYPE_TERMINATOR)
+ return 0;
+ if(type==KS_TYPE_LIST){
+ uint8_t items;
+ uint16_t item;
+ items = *((uint8_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 1;
+ while(items--){
+ item = *((uint16_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 2;
+ if(item==keysize)
+ return 1;
+ }
+ ks_desc = (uint8_t*)ks_desc - 2;
+ }
+ if(type==KS_TYPE_RANGE){
+ uint16_t max, min;
+ min = *((uint16_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 2;
+ max = *((uint16_t*)ks_desc);
+ if(min<=keysize && keysize<=max)
+ return 1;
+ }
+ if(type==KS_TYPE_ARG_RANGE){
+ uint16_t max, min, dist, offset;
+ min = *((uint16_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 2;
+ max = *((uint16_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 2;
+ dist = *((uint16_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 2;
+ offset = *((uint16_t*)ks_desc);
+ if(min<=keysize && keysize<=max && (keysize%dist==offset))
+ return 1;
+ }
+ if(type>KS_TYPE_ARG_RANGE){
+ /* bad error, you may insert a big warning message here */
+ return 0;
+ }
+ return is_valid_keysize_P((uint8_t*)ks_desc+1, keysize); /* search the next record */
+}
+
+uint16_t get_keysize(const void* ks_desc){
+ uint8_t type;
+ uint16_t keysize;
+ type = *((uint8_t*)ks_desc);
+ if(type==KS_TYPE_LIST){
+ ks_desc = (uint8_t*)ks_desc + 1;
+ }
+ ks_desc = (uint8_t*)ks_desc + 1;
+ keysize = *((uint8_t*)ks_desc);
+ return keysize;
+}
+
+uint16_t get_keysizes(const void* ks_desc, uint16_t** list){
+ uint8_t type;
+ uint16_t items;
+ uint8_t i;
+ type = *((uint8_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 1;
+ if(type==KS_TYPE_LIST){
+ items = *((uint8_t*)ks_desc);
+ ks_desc = (uint8_t*)ks_desc + 1;
+ if(!*list){
+ *list = malloc(items*2);
+ if(!*list){
+ return 0;
+ }
+ }
+ for(i=0; i.
+*/
+/**
+ * \file keysize_descriptor.h
+ * \author Daniel Otte
+ * \email daniel.otte@rub.de
+ * \date 2009-01-07
+ * \license GPLv3 or later
+ */
+
+#ifndef KEYSIZE_DESCRIPTOR_H_
+#define KEYSIZE_DESCRIPTOR_H_
+
+#include
+
+#define KS_TYPE_TERMINATOR 0x00
+#define KS_TYPE_LIST 0x01
+#define KS_TYPE_RANGE 0x02
+#define KS_TYPE_ARG_RANGE 0x03
+
+#define KS_INT(a) ((a)&0xFF), ((a)>>8)
+
+typedef struct{ /* keysize is valid if listed in items */
+ uint8_t n_items; /* number of items (value 0 is reserved) */
+ uint16_t items[]; /* list of valid lengths */
+}keysize_desc_list_t;
+
+typedef struct{ /* keysize is valid if min<=keysize<=max */
+ uint16_t min;
+ uint16_t max;
+}keysize_desc_range_t;
+
+typedef struct{ /* keysize is valid if min<=keysize<=max and if keysize mod distance == offset */
+ uint16_t min;
+ uint16_t max;
+ uint16_t distance;
+ uint16_t offset;
+}keysize_desc_arg_range_t;
+
+uint8_t is_valid_keysize_P(const void* ks_desc, uint16_t keysize);
+uint16_t get_keysize(const void* ks_desc);
+uint16_t get_keysizes(const void* ks_desc, uint16_t** list);
+
+
+#endif /* KEYSIZE_DESCRIPTOR_H_ */
diff --git a/host/shavs_test2.rb b/host/shavs_test2.rb
index fadbcb5..36c3e8c 100644
--- a/host/shavs_test2.rb
+++ b/host/shavs_test2.rb
@@ -24,7 +24,7 @@ require 'rubygems'
require 'serialport'
require 'getopt/std'
-$buffer_size = 0
+$buffer_size = 0 # set automatically in init_system
$conffile_check = Hash.new
$conffile_check.default = 0
@@ -137,19 +137,19 @@ end
=end
def send_md(md_string)
# puts 'DBG: send_md; md_string.length = '+md_string.length.to_s+'; buffer_size = '+$buffer_size.to_s
- bs = $buffer_size*2
+ bs = $buffer_size
$sp.print("Msg = ")
for i in 0..((md_string.length-1)/bs)
# puts 'DBG bulk send'
- if(md_string.length-i*bs also read config from
+# -i skip until test nr.
+# -j start with testfile
+# -h ???
+# -d enable debug mode
+# -c ???
+# -a ???
opts = Getopt::Std.getopts("s:f:i:j:hdca")
@@ -299,7 +311,7 @@ algo_tasks.each do |algoa|
puts("\n[errors: "+ nerrors.to_s() +"]")
logfile.puts("[error] "+nerrors.to_s+" "+conf[algo]["file_#{i}"]+ " ("+Time.now.to_s()+")")
end
- i += 1
+ i = i+1
end
logfile.close()
end
diff --git a/test_src/shavs.c b/test_src/shavs.c
index 8ef9619..41a1551 100644
--- a/test_src/shavs.c
+++ b/test_src/shavs.c
@@ -110,6 +110,7 @@ typedef struct {
static shavs_ctx_t shavs_ctx;
+static
uint8_t buffer_add(char c){
uint8_t v,t;
if(shavs_ctx.buffer_idx==shavs_ctx.buffersize_B){
@@ -368,11 +369,11 @@ void shavs_test2(void){ /* Monte Carlo tests for SHA-1 & SHA-2 */
return;
}
}
- if((c=cli_getc_cecho())!='e' && c!='e'){
+ if((c=cli_getc_cecho())!='e' && c!='E'){
cli_putstr("\r\nERROR: wrong input (2)!\r\n");
return;
}
- if((c=cli_getc_cecho())!='e' && c!='e'){
+ if((c=cli_getc_cecho())!='e' && c!='E'){
cli_putstr("\r\nERROR: wrong input (3)!\r\n");
return;
}
@@ -453,11 +454,11 @@ void shavs_test3(void){ /* Monte Carlo tests for SHA-3 */
return;
}
}
- if((c=cli_getc_cecho())!='e' && c!='e'){
+ if((c=cli_getc_cecho())!='e' && c!='E'){
cli_putstr("\r\nERROR: wrong input (2)!\r\n");
return;
}
- if((c=cli_getc_cecho())!='e' && c!='e'){
+ if((c=cli_getc_cecho())!='e' && c!='E'){
cli_putstr("\r\nERROR: wrong input (3)!\r\n");
return;
}