fixing style, typos and uart

This commit is contained in:
bg nerilex 2015-02-02 22:20:18 +01:00
parent 6c688ee8a1
commit eb0cafe05a
7 changed files with 35 additions and 17 deletions

View 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 {

View 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>

View 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

View File

@ -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){

View 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) */

View 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

View 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