From eb0cafe05ab4cdf60878dbd81e4ff3712d5150f2 Mon Sep 17 00:00:00 2001 From: bg Date: Mon, 2 Feb 2015 22:20:18 +0100 Subject: [PATCH] fixing style, typos and uart --- bcal/bcal-basic.c | 6 ++++-- bcal/bcal-performance.c | 2 +- hfal/hfal-performance.c | 2 +- keysize_descriptor.c | 24 ++++++++++++++---------- keysize_descriptor.h | 2 +- mkfiles/001_cli_std.mk | 14 +++++++++++++- mkfiles/norx_c.mk | 2 +- 7 files changed, 35 insertions(+), 17 deletions(-) diff --git a/bcal/bcal-basic.c b/bcal/bcal-basic.c index 52734de..78a490d 100644 --- a/bcal/bcal-basic.c +++ b/bcal/bcal-basic.c @@ -39,13 +39,15 @@ uint8_t bcal_cipher_init(const bcdesc_t *cipher_descriptor, init_fpt.initvoid = (void_fpt) (pgm_read_word(&(cipher_descriptor->init.initvoid))); if (init_fpt.initvoid == NULL) { - if (!(ctx->ctx = malloc((keysize_b + 7) / 8))) + if (!(ctx->ctx = malloc((keysize_b + 7) / 8))) { return 2; + } memcpy(ctx->ctx, key, (keysize_b + 7) / 8); return 0; } - if (!(ctx->ctx = malloc(pgm_read_word(&(cipher_descriptor->ctxsize_B))))) + if (!(ctx->ctx = malloc(pgm_read_word(&(cipher_descriptor->ctxsize_B))))) { return 3; + } if ((flags & BC_INIT_TYPE) == BC_INIT_TYPE_1) { init_fpt.init1((void*) key, (ctx->ctx)); } else { diff --git a/bcal/bcal-performance.c b/bcal/bcal-performance.c index 3cd9df4..086e597 100644 --- a/bcal/bcal-performance.c +++ b/bcal/bcal-performance.c @@ -32,7 +32,7 @@ #include "performance_test.h" #include "stack_measuring.h" #include "cli.h" -#include "uart_i.h" +#include "uart.h" #include #include #include diff --git a/hfal/hfal-performance.c b/hfal/hfal-performance.c index cb78115..d3cd008 100644 --- a/hfal/hfal-performance.c +++ b/hfal/hfal-performance.c @@ -34,7 +34,7 @@ #include "hashfunction_descriptor.h" #include "stack_measuring.h" #include "performance_test.h" -#include "uart_i.h" +#include "uart.h" #define PATTERN_A 0xAA #define PATTERN_B 0x55 diff --git a/keysize_descriptor.c b/keysize_descriptor.c index 253100f..a97ad16 100644 --- a/keysize_descriptor.c +++ b/keysize_descriptor.c @@ -32,29 +32,32 @@ uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize){ uint8_t type; type = pgm_read_byte(ks_desc++); - if(type==KS_TYPE_TERMINATOR) + if (type == KS_TYPE_TERMINATOR) { return 0; - if(type==KS_TYPE_LIST){ + } + if (type == KS_TYPE_LIST) { uint8_t items; uint16_t item; items = pgm_read_byte(ks_desc++); - while(items--){ + while (items--) { item = pgm_read_word(ks_desc); ks_desc = (uint8_t*)ks_desc + 2; - if(item==keysize) + if (item == keysize) { return 1; + } } ks_desc = (uint8_t*)ks_desc - 2; } - if(type==KS_TYPE_RANGE){ + if (type == KS_TYPE_RANGE) { uint16_t max, min; min = pgm_read_word(ks_desc); ks_desc = (uint8_t*)ks_desc + 2; max = pgm_read_word(ks_desc); - if(min<=keysize && keysize<=max) + if (min <= keysize && keysize <= max) { return 1; + } } - if(type==KS_TYPE_ARG_RANGE){ + if (type == KS_TYPE_ARG_RANGE) { uint16_t max, min, dist, offset; min = pgm_read_word(ks_desc); ks_desc = (uint8_t*)ks_desc + 2; @@ -63,14 +66,15 @@ uint8_t is_valid_keysize_P(PGM_VOID_P ks_desc, uint16_t keysize){ dist = pgm_read_word(ks_desc); ks_desc = (uint8_t*)ks_desc + 2; offset = pgm_read_word(ks_desc); - if(min<=keysize && keysize<=max && (keysize%dist==offset)) + if (min <= keysize && keysize <= max && (keysize % dist == offset)) { return 1; + } } - if(type>KS_TYPE_ARG_RANGE){ + 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 */ + return is_valid_keysize_P((uint8_t*)ks_desc + 1, keysize); /* search the next record */ } uint16_t get_keysize(PGM_VOID_P ks_desc){ diff --git a/keysize_descriptor.h b/keysize_descriptor.h index af5e383..4ea70e9 100644 --- a/keysize_descriptor.h +++ b/keysize_descriptor.h @@ -35,7 +35,7 @@ #define KS_TYPE_RANGE 0x02 #define KS_TYPE_ARG_RANGE 0x03 -#define KS_INT(a) ((a)&0xFF), ((a)>>8) +#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) */ diff --git a/mkfiles/001_cli_std.mk b/mkfiles/001_cli_std.mk index 01f0102..eccb02a 100644 --- a/mkfiles/001_cli_std.mk +++ b/mkfiles/001_cli_std.mk @@ -1,7 +1,19 @@ CLI_STD = cli-stub.o cli-basics.o cli-core.o cli-hexdump.o debug.o hexdigit_tab.o \ - dbz_strings.o string-extras-asm.o uart_i-asm.o circularbytebuffer-asm.o \ + dbz_strings.o string-extras-asm.o $(UART_OBJ) \ main-test-common.o +UART_I_OBJ = uart_i-asm.o circularbytebuffer-asm.o +UART_NI_OBJ = uart_ni-asm.o + +ifeq ($(UART),NI) +UART_OBJ = $(UART_NI_OBJ) +DEFS += -DUART_NI=1 +else +UART_OBJ = $(UART_I_OBJ) +DEFS += -DUART_NI=0 +endif + + #CLI_STD = cli.o debug.o hexdigit_tab.o \ # dbz_strings.o string-extras-asm.o uart_i-asm.o circularbytebuffer-asm.o \ # main-test-common.o diff --git a/mkfiles/norx_c.mk b/mkfiles/norx_c.mk index 75591d8..3dd57ca 100644 --- a/mkfiles/norx_c.mk +++ b/mkfiles/norx_c.mk @@ -1,4 +1,4 @@ -# Makefile for noekeon +# Makefile for norx ALGO_NAME := NORX_C # comment out the following line for removement of noekeon from the build process -- 2.39.5