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 {
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;
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){
#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) */
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