]> git.cryptolib.org Git - arm-crypto-lib.git/commitdiff
update to stream-cipher mkfiles
authorbg <daniel.otte@rub.de>
Sun, 23 Oct 2011 13:49:06 +0000 (15:49 +0200)
committerbg <daniel.otte@rub.de>
Sun, 23 Oct 2011 13:49:06 +0000 (15:49 +0200)
17 files changed:
arm-makefile.inc_arm7tdmi [new file with mode: 0644]
hfal/hfal-hmac.c
mkfiles/arcfour_c.mk
mkfiles/grain.mk
mkfiles/mickey128.mk
mkfiles/prf_tls12.mk
mkfiles/rabbit_c.mk
mkfiles/rabbit_estream_c.mk
mkfiles/salsa20_c.mk
mkfiles/trivium.mk
mkfiles/zzz_lib.mk
prf_tls12/prf_tls12.h
sha2/sha2_small_common.c
test_src/main-bigint-test.c
test_src/main-groestl-test.c
test_src/main-rc6-test.c
test_src/main-skein-test.c

diff --git a/arm-makefile.inc_arm7tdmi b/arm-makefile.inc_arm7tdmi
new file mode 100644 (file)
index 0000000..e648810
--- /dev/null
@@ -0,0 +1,69 @@
+TOOLCHAIN      = arm-none-eabi-#
+MCU_TARGET     = arm7tdmi 
+MCU_OPTS       = -marm
+OPTIMIZE       = -O0 -fomit-frame-pointer  
+DEBUG          = -gdwarf-2
+WARNING        = -pedantic -Wall -Wstrict-prototypes -Werror
+DEFS           = -D$(call uc, $(subst -,_,$(MCU_TARGET)))
+FLASHCMD       = $(OPENOCD) -f openocd.cfg \
+                    -c "init" \
+                    -c "halt" \
+                    -c "flash write_image erase $(1) 0 bin" \
+                    -c "reset run" \
+                    -c "shutdown"
+DEP_DIR        = deps/#
+TEST_DIR       = test/#
+BIN_DIR        = bin/#
+TESTSRC_DIR    = test_src/#
+ERASECMD       =
+TESTPORT       = /dev/ttyUSB1
+TESTPORTBAUDR  = 115200
+TESTLOG_DIR    = testlog/#
+TESTPREFIX     = nessie-#
+SPEEDTOOL      = host/get_performance.rb
+SPEEDLOG_DIR   = speed_log/#
+SPEEDPREFIX    =
+SPEEDCMD       = performance
+SIZE_DIR       = size_log/#
+LIST_DIR       = listings/#
+STAT_DIR       = stats/#
+AUTOASM_DIR    = autoasm/#
+LIB_DIR        = lib/#
+LIB_NAME       = libcrypto.a
+AUTOASM_OPT    = -S
+CSTD           = gnu99
+LIBS           = c gcc
+
+COMMON_FLAGS   = -ffunction-sections -fdata-sections          \
+                 $(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) \
+                 -mcpu=$(MCU_TARGET) $(MCU_OPTS) $(DEFS) -MMD
+
+override CFLAGS_A      = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) 
+override CFLAGS        = $(COMMON_FLAGS) \
+                      -MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@))
+                      
+override LDFLAGS       = -g -T lm3s9b90.ld -Wl,--gc-sections    \
+                         -Wl,--entry=reset_isr  \
+                         -Wl,-Map,# no space at the end
+                          
+override ASFLAGS          =  -mcpu=$(MCU_TARGET) 
+
+SIZESTAT_FILE = sizestats.txt
+
+CC                 = $(TOOLCHAIN)gcc
+OBJCOPY         = $(TOOLCHAIN)objcopy
+OBJDUMP         = $(TOOLCHAIN)objdump
+SIZE            = $(TOOLCHAIN)size
+OPENOCD         = openocd
+READELF         = readelf
+AR              = $(TOOLCHAIN)ar
+CHMOD           = chmod
+CHOWN           = chown
+CHGRP           = chgrp
+RM              = rm
+RUBY            = ruby
+GET_TEST        = host/get_test.rb
+MAKE            = make
+MAKE2GRAPH      = ~/bin/make2graph.rb
+TWOPI           = twopi
index 6f5fbf9bc7c32ae546b9f4fce960ffca70a2d43e..f27105592998d7b24d3933b26b7334538c9842aa 100644 (file)
@@ -78,6 +78,7 @@ uint8_t hfal_hmac_ctxcopy(hfhmacgen_ctx_t* dest, hfhmacgen_ctx_t* src){
        memcpy(dest->ctx, src->ctx, dest->desc->ctxsize_B);
        dest->finctx = malloc(dest->desc->ctxsize_B);
        if(dest->finctx == NULL){
+               free(dest->ctx);
                return 1;
        }
        memcpy(dest->finctx, src->finctx, dest->desc->ctxsize_B);
index fccca0789bb39b159e2cc897216c753767f1ce9f..ff85f98de8cbb5a25380651f4640e82ba6ec4823 100644 (file)
@@ -5,7 +5,7 @@ ALGO_NAME := ARCFOUR_C
 STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := arcfour/
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_OBJ      := arcfour.o
 $(ALGO_NAME)_TESTBIN := main-arcfour-test.o scal_arcfour.o $(CLI_STD) $(SCAL_STD)
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
index f513e4eaefed4f31738682793d83864c5c1aaca4..5e013e69f6ee8e4f5d3ad84b51eec71a6db26f3c 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := grain/
 $(ALGO_NAME)_OBJ      := grain.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-grain-test.o $(CLI_STD) $(SCAL_STD) scal_grain.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index fc0b1f45606f7f189f97d99ad4582ded4f131a98..87bc476821e14e190557918ebb0d6b2c92cb3ae4 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := mickey128/
 $(ALGO_NAME)_OBJ      := mickey128.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-mickey128-test.o $(CLI_STD) $(SCAL_STD) scal_mickey128.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index d80c61e7591d878e92f544b4e76f2564c7f0767d..f52b65170effa5181fc5f3c622d0b1e63d3ec7ec 100644 (file)
@@ -5,10 +5,10 @@ ALGO_NAME := PRF_TLS12
 AUX += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := prf_tls12/
-$(ALGO_NAME)_INCDIR   := hmac/ sha512/ sha256/ hfal/
+$(ALGO_NAME)_INCDIR   := hmac/ sha2/ hfal/
 $(ALGO_NAME)_OBJ      := prf_tls12.o
-$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) hfal_sha512.o hfal_sha256.o $(HFAL_STD) \
-                        sha256.o sha512.o hfal-hmac.o
+$(ALGO_NAME)_TESTBIN := main-prf_tls12-test.o $(CLI_STD) $(HFAL_STD) sha224.o sha256.o sha384.o sha512.o \
+                        sha2_small_common.o sha2_large_common.o hfal_sha224.o hfal_sha256.o hfal_sha384.o hfal_sha512.o hfal-hmac.o
                         
 $(ALGO_NAME)_PERFORMANCE_TEST := performance
 
index bc19ac17cc06e7898a5f6ccaac8590b98160da10..149a6ab04475d09c4ee2f9048f2973a17ec01299 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := rabbit/
 $(ALGO_NAME)_OBJ      := rabbit_c.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 9277f67181b7007affb1dfc1d4ab18f0487142bd..51bc9c8dc99b6b54e41a4b44f43c991da04932c8 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := rabbit/
 $(ALGO_NAME)_OBJ      := rabbit_c.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-rabbit-test.o $(CLI_STD) $(SCAL_STD) scal_rabbit.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 79169db32fd60941bb8be933005607c0a767e4ed..96a76bb15095fce6e5c4cc050b2ecfc026af0a6d 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := salsa20/
 $(ALGO_NAME)_OBJ      := salsa20.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-salsa20-test.o $(CLI_STD) $(SCAL_STD) scal_salsa20.o
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 52c531700cd8b1fd500cb2ffe5da1e7deb4666cd..64e3c7e8da81c7b07519d3a394c2748bf3fac45f 100644 (file)
@@ -6,7 +6,7 @@ STREAM_CIPHERS += $(ALGO_NAME)
 
 $(ALGO_NAME)_DIR      := trivium/
 $(ALGO_NAME)_OBJ      := trivium.o
-$(ALGO_NAME)_INCDIR   := memxor/ scal/
+$(ALGO_NAME)_INCDIR   := memxor/ bcal/ scal/
 $(ALGO_NAME)_TESTBIN := main-trivium-test.o $(CLI_STD) $(SCAL_STD) scal_trivium.o 
 $(ALGO_NAME)_NESSIE_TEST      := "nessie"
 $(ALGO_NAME)_PERFORMANCE_TEST := "performance"
index 856a378dcbe2a504a0cda1340b431e4e2558545d..0fce0ebdaaac0f22d7a184d2179e2cd6a16e2fef 100644 (file)
@@ -4,7 +4,7 @@ LIB_ALGOS:= \
     BASE64 \
     BIGINT_C \
     BLAKE_C \
-    BMW \
+    BMW_C \
     CAST5 \
     CAST6 \
     CSCIPHER_SMALL_C \
@@ -20,6 +20,7 @@ LIB_ALGOS:= \
     MICKEY128 \
     NOEKEON_C \
     PRESENT \
+    PRF_TLS12 \
     RABBIT_C \
     RC5 \
     RC6 \
@@ -27,7 +28,7 @@ LIB_ALGOS:= \
     SEED_C \
     SERPENT_BITSLICE \
     SHA1_C \
-    SHA256_C \
+    SHA2_C \
     SHABAL_C \
     SKEIN_C \
     TDES \
@@ -35,4 +36,9 @@ LIB_ALGOS:= \
     XTEA_C \
     HFAL_HMAC \
     BCAL_BASIC \
-    SCAL_BASIC 
+    SCAL_BASIC \
+    HFAL_ALGOS \
+    BCAL_ALGOS \
+    SCAL_ALGOS
+
+
index dbd6938b3251c1b0d761f2c6fddc737ecc7a82b8..e312f7e1b68f93594b143546aa8b6284bb862c72 100644 (file)
@@ -21,9 +21,9 @@
 #define PRF_TLS12_H_
 
 #include <stdint.h>
-#include <crypto/hashfunction_descriptor.h>
-#include <crypto/hfal-basic.h>
-#include <crypto/hfal-hmac.h>
+#include "hashfunction_descriptor.h"
+#include "hfal-basic.h"
+#include "hfal-hmac.h"
 
 typedef struct{
        hfhmacgen_ctx_t mainctx;
index 7dad795f492fb44bc981cfa5593688c406ef76a6..d650b287f26ee45f20f95737dd691d7a72038c8d 100644 (file)
@@ -51,9 +51,9 @@ uint32_t change_endian32(uint32_t x){
 #define CH(x,y,z)  (((x)&(y)) ^ ((~(x))&(z)))
 #define MAJ(x,y,z) (((x)&(y)) ^ ((x)&(z)) ^ ((y)&(z)))
 
-#define SIGMA0(x) (rotr32((x),2) ^ rotr32((x),13) ^ rotl32((x),10))
-#define SIGMA1(x) (rotr32((x),6) ^ rotr32((x),11) ^ rotl32((x),7))
-#define SIGMA_a(x) (rotr32((x),7)  ^ rotl32((x),14) ^ ((x)>>3))
+#define SIGMA_0(x) (rotr32((x), 2) ^ rotr32((x),13) ^ rotl32((x),10))
+#define SIGMA_1(x) (rotr32((x), 6) ^ rotr32((x),11) ^ rotl32((x),7))
+#define SIGMA_a(x) (rotr32((x), 7) ^ rotl32((x),14) ^ ((x)>>3))
 #define SIGMA_b(x) (rotl32((x),15) ^ rotl32((x),13) ^ ((x)>>10))
 
 const
@@ -74,7 +74,7 @@ uint32_t k[]={
  * block must be, 512, Bit = 64, Byte, long !!!
  */
 void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* block){
-       uint32_t w[16], wx;     /* this is 256, byte, large, */
+       uint32_t w[16], wx;
        uint8_t  i;
        uint32_t a[8],t1,t2;
 
@@ -103,8 +103,8 @@ void sha2_small_common_nextBlock (sha2_small_common_ctx_t *state, const void* bl
                        memmove(&(w[0]), &(w[1]), 15*4);
                        w[15] = wx;
                }
-               t1 = a[7] + SIGMA1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx;
-               t2 = SIGMA0(a[0]) + MAJ(a[0],a[1],a[2]);
+               t1 = a[7] + SIGMA_1(a[4]) + CH(a[4],a[5],a[6]) + k[i] + wx;
+               t2 = SIGMA_0(a[0]) + MAJ(a[0],a[1],a[2]);
                memmove(&(a[1]), &(a[0]), 7*4);         /* a[7]=a[6]; a[6]=a[5]; a[5]=a[4]; a[4]=a[3]; a[3]=a[2]; a[2]=a[1]; a[1]=a[0]; */
                a[4] += t1;
                a[0] = t1 + t2;
index 4f4dfdc169b7b76494f4f064ba37d1f0c53338bd..ad14ab4841436386fccd638ba0508ce5a65e13f2 100644 (file)
  * bigint test-suit
  * 
 */
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
 
 #include "noekeon.h"
 #include "noekeon_prng.h"
 
 char* algo_name = "BigInt";
 
-void uart0_putc(char byte){
-       uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
-       return uart_getc(UART_0);
-}
-
 /*****************************************************************************
  *  additional validation-functions                                                                                     *
  *****************************************************************************/
@@ -122,7 +106,7 @@ void test_add_scale_bigint(void){
                cli_putstr("\r\nenter scale:");
                {
                        char str[8];
-                       cli_getsn_cecho(str, 7);
+                       cli_getsn(str, 7);
                        scale = atoi(str);
                }
        /*
@@ -538,22 +522,9 @@ const cmdlist_entry_t cmdlist[] = {
 };
 
 int main (void){
-       sysclk_set_freq(SYS_FREQ);
-       sysclk_mosc_verify_enable();
-       uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
-       gptm_set_timer_32periodic(TIMER0);
-
-       cli_rx = uart0_getc;
-       cli_tx = uart0_putc;
-       
+       main_setup();
        for(;;){
-               cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
-               cli_putstr(algo_name);
-               cli_putstr("; ");
-               cli_putstr(__DATE__);
-               cli_putc(' ');
-               cli_putstr(__TIME__);
-               cli_putstr(")\r\nloaded and running\r\n");
+               welcome_msg(algo_name);
                cmd_interface(cmdlist);
        }
 }
index 3ed24091d53470794ba2e36462787195a788028d..5720b5274025df3011d2ef5dffc5fb9e52f3d31e 100644 (file)
@@ -69,19 +69,19 @@ const hfdesc_t* algolist[] = {
 void testrun_nessie_groestl(void){
        hfal_nessie_multiple(algolist);
 }
-void groestl224_test(void* msg, uint32_t length_b){
+void groestl224_test(const void* msg, uint32_t length_b){
        hfal_test(&groestl224_desc, msg, length_b);
 }
 
-void groestl256_test(void* msg, uint32_t length_b){
+void groestl256_test(const void* msg, uint32_t length_b){
        hfal_test(&groestl256_desc, msg, length_b);
 }
 
-void groestl384_test(void* msg, uint32_t length_b){
+void groestl384_test(const void* msg, uint32_t length_b){
        hfal_test(&groestl384_desc, msg, length_b);
 }
 
-void groestl512_test(void* msg, uint32_t length_b){
+void groestl512_test(const void* msg, uint32_t length_b){
        hfal_test(&groestl512_desc, msg, length_b);
 }
 
index 07b677cdc60004176bcebe08af4ff9ed41251dfd..95ae76dd30e471799d0c0467ae19d0a64049dd3f 100644 (file)
  * 
 */
 
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
 
 #include "rc6.h"
 #include "nessie_bc_test.h"
 #include "bcal-performance.h"
 #include "bcal_rc6.h"
 
-#include <stdint.h>
-#include <string.h>
-#include <stdlib.h>
-
 #define RC6_ROUNDS 20
 char* algo_name = "RC6-32/20/16";
 
-void uart0_putc(char byte){
-       uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
-       return uart_getc(UART_0);
-}
-
 const bcdesc_t* algolist[] = {
        (bcdesc_t*)&rc6_desc,
        NULL
@@ -103,21 +83,10 @@ const cmdlist_entry_t cmdlist[] = {
 };
 
 int main (void){
-       sysclk_set_freq(SYS_FREQ);
-       sysclk_mosc_verify_enable();
-       uart_init_flow(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE, UART_FLOWCTRL_SOFT);
-       gptm_set_timer_32periodic(TIMER0);
+       main_setup();
        
-       cli_rx = (cli_rx_fpt)uart0_getc;
-       cli_tx = (cli_tx_fpt)uart0_putc;                
        for(;;){
-               cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
-               cli_putstr(algo_name);
-               cli_putstr("; ");
-               cli_putstr(__DATE__);
-               cli_putc(' ');
-               cli_putstr(__TIME__);
-               cli_putstr(")\r\nloaded and running\r\n");
-       cmd_interface(cmdlist);
+               welcome_msg(algo_name);
+               cmd_interface(cmdlist);
     }
 }
index b52fd43df6d7e11b4d424634b40ef1a362af48c0..4b9fdff5a190ba24471def87c3e1220b21dd68a5 100644 (file)
  *
 */
 
-#include <stdint.h>
-#include <stdlib.h>
-#include <string.h>
-#include "config.h"
-#include "cli.h"
-#include "dump.h"
-#include "uart_lowlevel.h"
-#include "sysclock.h"
-#include "hw_gptm.h"
+#include "main-test-common.h"
 
 #include "shavs.h"
 #include "nessie_hash_test.h"
 #include "performance_test.h"
+#include "hfal-basic.h"
 #include "hfal-nessie.h"
 #include "hfal-performance.h"
 #include "hfal-test.h"
 #include "hfal_skein512.h"
 #include "hfal_skein1024.h"
 
-
-void uart0_putc(char byte){
-       uart_putc(UART_0, byte);
-}
-
-char uart0_getc(void){
-       return uart_getc(UART_0);
-}
-
 const char* algo_name = "Skein";
 
 const hfdesc_t* algolist[] = {
@@ -284,26 +268,13 @@ cmdlist_entry_t cmdlist[]  = {
 };
 
 int main(void) {
-       sysclk_set_freq(SYS_FREQ);
-       sysclk_mosc_verify_enable();
-    uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
-    gptm_set_timer_32periodic(TIMER0);
-
-       cli_rx = uart0_getc;
-    cli_tx = uart0_putc;
-
+       main_setup();
        shavs_algolist=(hfdesc_t**)algolist;
        shavs_algo=(hfdesc_t*)&skein256_256_desc;
 
        for(;;){
-               cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
-               cli_putstr(algo_name);
-               cli_putstr("; ");
-               cli_putstr(__DATE__);
-               cli_putc(' ');
-               cli_putstr(__TIME__);
-               cli_putstr(")\r\nloaded and running\r\n");
-       cmd_interface(cmdlist);
+               welcome_msg(algo_name);
+               cmd_interface(cmdlist);
     }
 
 }