]> git.cryptolib.org Git - avr-crypto-lib.git/commitdiff
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 52734deec94a19ae3107264a4214cbde94760307..78a490d1467a9b0232f258ad85db75fed1676839 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) {
     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;
             return 2;
+        }
         memcpy(ctx->ctx, key, (keysize_b + 7) / 8);
         return 0;
     }
         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;
         return 3;
+    }
     if ((flags & BC_INIT_TYPE) == BC_INIT_TYPE_1) {
         init_fpt.init1((void*) key, (ctx->ctx));
     } else {
     if ((flags & BC_INIT_TYPE) == BC_INIT_TYPE_1) {
         init_fpt.init1((void*) key, (ctx->ctx));
     } else {
index 3cd9df41717b6dc050b1ceb124b7f2d13c83d558..086e597195060a17976e84f2301f8c3d9a659c65 100644 (file)
@@ -32,7 +32,7 @@
 #include "performance_test.h"
 #include "stack_measuring.h"
 #include "cli.h"
 #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>
 #include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
index cb781157501ac79bdfd512044ea7226fc4deb6af..d3cd0081eb61785121f510c4aa83fc95d09b1b3c 100644 (file)
@@ -34,7 +34,7 @@
 #include "hashfunction_descriptor.h"
 #include "stack_measuring.h"
 #include "performance_test.h"
 #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
 
 #define PATTERN_A 0xAA
 #define PATTERN_B 0x55
index 253100ff63f4e82b35e749d99ddc383f12271ed5..a97ad1628ff8afc5546366fbf07a6bf787335aec 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++);
 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;
                return 0;
-       if(type==KS_TYPE_LIST){
+       }
+       if (type == KS_TYPE_LIST) {
                uint8_t items;
                uint16_t item;
                items = pgm_read_byte(ks_desc++);
                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;
                        item = pgm_read_word(ks_desc);
                        ks_desc = (uint8_t*)ks_desc + 2;
-                       if(item==keysize)
+                       if (item == keysize) {
                                return 1;
                                return 1;
+                       }
                }
                ks_desc = (uint8_t*)ks_desc - 2;
        }
                }
                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);
                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;
                        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;
                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);
                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;
                        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;
        }
                /* 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){
 }
 
 uint16_t get_keysize(PGM_VOID_P ks_desc){
index af5e38395ad72a7c3042c4d954309a48c942ff53..4ea70e973e5542507fe7c369d0da8d1ed20928c7 100644 (file)
@@ -35,7 +35,7 @@
 #define KS_TYPE_RANGE      0x02
 #define KS_TYPE_ARG_RANGE  0x03
 
 #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) */
 
 typedef struct{ /* keysize is valid if listed in items */
        uint8_t  n_items;  /* number of items (value 0 is reserved) */
index 01f01022846af74d83aaf8eb14213058bc0561d0..eccb02a450779f4108b634edf1a7156c74ef6e34 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 \
 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
 
            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
 #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 75591d810aa1d6231db242f2852d4b907681a549..3dd57cafe505378d9d80b147579ca1da30e2be6c 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
 ALGO_NAME := NORX_C
 
 # comment out the following line for removement of noekeon from the build process