fixing style, typos and uart
authorbg <bg@nerilex.org>
Mon, 2 Feb 2015 21:20:18 +0000 (22:20 +0100)
committerbg <bg@nerilex.org>
Mon, 2 Feb 2015 21:20:18 +0000 (22:20 +0100)
bcal/bcal-basic.c
bcal/bcal-performance.c
hfal/hfal-performance.c
keysize_descriptor.c
keysize_descriptor.h
mkfiles/001_cli_std.mk
mkfiles/norx_c.mk

index 52734de..78a490d 100644 (file)
@@ -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 {
index 3cd9df4..086e597 100644 (file)
@@ -32,7 +32,7 @@
 #include "performance_test.h"
 #include "stack_measuring.h"
 #include "cli.h"
-#include "uart_i.h"
+#include "uart.h"
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
index cb78115..d3cd008 100644 (file)
@@ -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
index 253100f..a97ad16 100644 (file)
 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){
index af5e383..4ea70e9 100644 (file)
@@ -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) */
index 01f0102..eccb02a 100644 (file)
@@ -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
index 75591d8..3dd57ca 100644 (file)
@@ -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