added arcfour/rc4

This commit is contained in:
bg 2011-07-19 18:20:06 +02:00
parent 85aee632b0
commit 498cf95d73
26 changed files with 15848 additions and 147 deletions

View File

@ -146,6 +146,10 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
#-------------------------------------------------------------------------------
%.bin: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -O binary $< $@
%.hex: %.elf
@echo "[objcopy]: $@"
@$(OBJCOPY) -j .text -j .data -O ihex $< $@
@ -155,12 +159,12 @@ $(foreach algo, $(ALGORITHMS), $(eval $(call TestBin_TEMPLATE, \
define Flash_Template
$(1)_FLASH: $(2)
@echo "[flash]: $(2)"
@$(FLASHCMD)$(call first,$(2))
@$(call FLASHCMD, $(call first,$(2)))
endef
$(foreach algo, $(ALGORITHMS), $(eval $(call Flash_Template, \
$(algo), \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.elf \
$(BIN_DIR)$(call lc, $(algo))/$(TEST_DIR)main-$(call lc, $(algo))-test.bin \
)))
#-------------------------------------------------------------------------------

70
arcfour/arcfour.c Normal file
View File

@ -0,0 +1,70 @@
/* arcfour.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: arcfour.c
* Author: Daniel Otte
* email: daniel.otte@rub.de
* Date: 2006-06-07
* License: GPLv3 or later
* Description: Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
*
*/
#include <stdint.h>
#include "arcfour.h"
/*
* length is length of key in bits!
*/
void arcfour_init(const void *key, uint16_t length_b, arcfour_ctx_t *ctx){
uint8_t t;
uint8_t x=0,y=0;
length_b /= 8;
const uint8_t *kptr, *limit;
limit = (uint8_t*)key + length_b;
kptr = key;
do{
ctx->s[x]=x;
}while(++x);
do{
y += ctx->s[x] + *kptr++;
if(kptr==limit){
kptr=key;
}
/* ctx->s[y] <--> ctx->s[x] */
t = ctx->s[y];
ctx->s[y] = ctx->s[x];
ctx->s[x] = t;
}while(++x);
ctx->i = ctx->j = 0;
}
uint8_t arcfour_gen(arcfour_ctx_t *ctx){
uint8_t t;
ctx->i++;
ctx->j += ctx->s[ctx->i];
/* ctx->s[i] <--> ctx->s[j] */
t = ctx->s[ctx->j];
ctx->s[ctx->j] = ctx->s[ctx->i];
ctx->s[ctx->i] = t;
return ctx->s[(ctx->s[ctx->j] + ctx->s[ctx->i]) & 0xff];
}

91
arcfour/arcfour.h Normal file
View File

@ -0,0 +1,91 @@
/* arcfour.h */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* File: arcfour.h
* Author: Daniel Otte
* Date: 2006-06-07
* License: GPLv3+
* Description: Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
*/
/**
* \file arcfour.h
* \author Daniel Otte
* \date 2006-06-07
* \license GPLv3+
* \brief Implementation of the ARCFOUR (RC4 compatible) stream cipher algorithm.
*
* This header file defines the interface of the ARCFOUR cipher implementation.
*
* This implementation aims to be compatible with the ARCFOUR description
* available at
* http://www.mozilla.org/projects/security/pki/nss/draft-kaukonen-cipher-arcfour-03.txt
*/
#ifndef ARCFOUR_H_
#define ARCFOUR_H_
#include <stdint.h>
/** \typedef arcfour_ctx_t
* \brief type for arcfour context
*
* A variable of this type may contain a complete ARCFOUR context.
* The context is used to store the state of the cipher and gets
* created by the arcfour_init(arcfour_ctx_t *c, uint8_t *key, uint8_t length_B)
* function. The context is of the fixed size of 258 bytes
*/
/** \struct arcfour_ctx_st
* \brief base for ::arcfour_ctx_t
*
* The struct holds the two indices and the S-Box
*/
typedef struct arcfour_ctx_st {
uint8_t i,j;
uint8_t s[256];
} arcfour_ctx_t;
/** \fn void arcfour_init(const void *key, uint8_t length_B, arcfour_ctx_t *ctx)
* \brief setup a context with a key
*
* This function sets up a ::arcfour_ctx_t context using
* the supplied key of the given length.
* \param ctx pointer to the context
* \param key pointer to the key
* \param length_b length of the key in bits
*/
void arcfour_init(const void *key, uint16_t length_b, arcfour_ctx_t *ctx);
/** \fn uint8_t arcfour_gen(arcfour_ctx_t *ctx)
* \brief generates a byte of keystream
*
* This function generates the next byte of keystream
* from the supplied ::arcfour_ctx_t context which is updated accordingly
*
* \param ctx pointer to the context
* \return byte of keystream
*/
uint8_t arcfour_gen(arcfour_ctx_t *ctx);
#endif

View File

@ -4,7 +4,12 @@ OPTIMIZE = -O0
DEBUG = -gdwarf-2
WARNING = -pedantic -Wall -Wstrict-prototypes -Werror
DEFS = -D$(call uc, $(subst -,_,$(MCU_TARGET)))
FLASHCMD = $(TOOLCHAIN)gdb -x gdb-flash #
FLASHCMD = $(OPENOCD) -f openocd.cfg \
-c "init" \
-c "halt" \
-c "flash write_image erase $(1) 0 bin" \
-c "reset run" \
-c "shutdown"
DEP_DIR = deps/
TEST_DIR = test/
BIN_DIR = bin/
@ -30,23 +35,24 @@ override CFLAGS_A = -fomit-frame-pointer \
-mthumb -ffunction-sections -fdata-sections -MMD \
-MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $(1))) \
$(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) \
-mcpu=$(MCU_TARGET) -Wa,-mthumb $(DEFS)
-mcpu=$(MCU_TARGET) $(DEFS)
override CFLAGS = -fomit-frame-pointer \
-mthumb -ffunction-sections -fdata-sections -MMD \
-MF$(DEP_DIR)$(patsubst %.o,%.d,$(notdir $@)) \
$(DEBUG) $(WARNING) -std=$(CSTD) $(OPTIMIZE) \
-mcpu=$(MCU_TARGET) -Wa,-mthumb $(DEFS)
-mcpu=$(MCU_TARGET) $(DEFS)
override LDFLAGS = -g -T lm3s9b90.ld -Wl,--gc-sections \
-Wl,--entry=reset_isr -lc -lgcc \
-Wl,--entry=reset_isr -lc -lgcc \
-Wl,-Map,# no space at the end
override ASFLAGS = -mthumb -mcpu=$(MCU_TARGET) -Wa,--g -Wa,-mthumb
override ASFLAGS = -mcpu=$(MCU_TARGET)
SIZESTAT_FILE = sizestats.txt
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
OPENOCD = openocd
READELF = readelf
RUBY = ruby
GET_TEST = host/get_test.rb

13
mkfiles/arcfour_c.mk Normal file
View File

@ -0,0 +1,13 @@
# Makefile for ARCFOUR (RC4 compatible)
ALGO_NAME := ARCFOUR_C
# comment out the following line for removement of ARCFOUR from the build process
STREAM_CIPHERS += $(ALGO_NAME)
$(ALGO_NAME)_DIR := arcfour/
$(ALGO_NAME)_INCDIR := memxor/ scal/
$(ALGO_NAME)_OBJ := arcfour.o
$(ALGO_NAME)_TEST_BIN := main-arcfour-test.o scal_arcfour.o $(CLI_STD) $(SCAL_STD)
$(ALGO_NAME)_NESSIE_TEST := "nessie"
$(ALGO_NAME)_PERFORMANCE_TEST := "performance"

View File

@ -1,7 +1,7 @@
source [find /usr/share/openocd/scripts/interface/luminary-icdi.cfg]
source [find /usr/share/openocd/scripts/target/lm3s9b9x.cfg]
# GDB can also flash my flash!
gdb_memory_map enable
gdb_flash_program enable
jtag_khz 5500
#gdb_memory_map enable
#gdb_flash_program enable
#jtag_khz 5500
#source [find /usr/share/openocd/scripts/target/lm3s9b9x.cfg]

164
scal/scal-basic.c Normal file
View File

@ -0,0 +1,164 @@
/* scal-basic.c */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "streamcipher_descriptor.h"
#include "keysize_descriptor.h"
#include "scal-basic.h"
uint8_t scal_cipher_init(const scdesc_t* cipher_descriptor,
const void* key, uint16_t keysize_b,
const void* iv, uint16_t ivsize_b, scgen_ctx_t* ctx){
ctx->buffer = NULL;
ctx->ctx = NULL;
if(!is_valid_keysize_P(cipher_descriptor->valid_keysize_desc, keysize_b)){
return 1;
}
if(!is_valid_keysize_P(cipher_descriptor->valid_ivsize_desc, ivsize_b)){
return 2;
}
uint8_t flags;
sc_init_fpt init_fpt;
flags = cipher_descriptor->flags;
ctx->desc_ptr = cipher_descriptor;
ctx->keysize = keysize_b;
ctx->ivsize = ivsize_b;
ctx->ctx = malloc(cipher_descriptor->ctxsize_B);
if(ctx->ctx==NULL){
return 3;
}
init_fpt = (cipher_descriptor->init);
switch(flags&SC_INIT_TYPE){
case SC_INIT_TYPE_1:
init_fpt.init1(key, ctx->ctx);
break;
case SC_INIT_TYPE_2:
init_fpt.init2(key, iv, ctx->ctx);
break;
case SC_INIT_TYPE_3:
init_fpt.init3(key, keysize_b, ctx->ctx);
break;
case SC_INIT_TYPE_4:
init_fpt.init4(key, keysize_b, iv, ctx->ctx);
break;
case SC_INIT_TYPE_5:
init_fpt.init5(key, keysize_b, iv, ivsize_b, ctx->ctx);
break;
default:
return 4;
}
uint16_t blocksize_b;
blocksize_b = cipher_descriptor->gensize_b;
if(blocksize_b>8){
ctx->buffer=malloc((blocksize_b+7)/8);
if(ctx->buffer==NULL){
return 5;
}
ctx->index=0;
}
return 0;
}
void scal_cipher_free(scgen_ctx_t* ctx){
if(ctx->buffer){
free(ctx->buffer);
}
if(ctx->ctx){
free(ctx->ctx);
}
}
uint8_t scal_cipher_gen_byte(scgen_ctx_t* ctx){
uint8_t flags;
uint16_t blocksize_b;
void_fpt gen_fpt;
flags = ctx->desc_ptr->flags;
blocksize_b = ctx->desc_ptr->gensize_b;
gen_fpt = (void_fpt)(ctx->desc_ptr->gen.genvoid);
if(blocksize_b==8){
if((flags&SC_GEN_TYPE)==SC_GEN_TYPE_1){
return ((sc_gen1_fpt)gen_fpt)(ctx->ctx);
}else{
uint8_t r;
((sc_gen2_fpt)gen_fpt)(&r, ctx->ctx);
return r;
}
}
if(blocksize_b<8){
uint8_t r=0;
uint8_t fill=0;
do{
r |= ((((sc_gen1_fpt)gen_fpt)(ctx->ctx))&(0xff<<(8-blocksize_b)))>>fill;
fill += blocksize_b;
}while(fill<8);
return r;
}else{
uint8_t r;
if(ctx->index==0){
((sc_gen2_fpt)gen_fpt)(ctx->buffer, ctx->ctx);
ctx->index = blocksize_b;
}
r=ctx->buffer[(blocksize_b-ctx->index)/8];
ctx->index -= 8;
return r;
}
}
void scal_cipher_gen_block(void* block, scgen_ctx_t* ctx){
uint8_t flags;
/* uint16_t blocksize_b; */
sc_gen_fpt gen_fpt;
flags = ctx->desc_ptr->flags;
/* blocksize_b = ctx->desc_ptr->gensize_b; */
gen_fpt = ctx->desc_ptr->gen;
if((flags&SC_GEN_TYPE)==SC_GEN_TYPE_1){
*((uint8_t*)block) = gen_fpt.gen1(ctx->ctx);
}else{
gen_fpt.gen2(block, ctx->ctx);
}
}
void scal_cipher_gen_fillblock(void* block, uint16_t blocksize_B, scgen_ctx_t* ctx){
while(blocksize_B){
*((uint8_t*)block) = scal_cipher_gen_byte(ctx);
block = (uint8_t*)block + 1;
blocksize_B -= 1;
}
}
uint16_t scal_cipher_getBlocksize_b(const scdesc_t* desc){
uint16_t blocksize_b;
blocksize_b = desc->gensize_b;
return blocksize_b;
}
void* scal_cipher_getKeysizeDesc(const scdesc_t* desc){
return (void*)(desc->valid_keysize_desc);
}
void* scal_cipher_getIVsizeDesc(const scdesc_t* desc){
return (void*)(desc->valid_ivsize_desc);
}

40
scal/scal-basic.h Normal file
View File

@ -0,0 +1,40 @@
/* scal-basic.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCAL_BASIC_H_
#define SCAL_BASIC_H_
#include <stdlib.h>
#include <stdint.h>
#include "streamcipher_descriptor.h"
#include "keysize_descriptor.h"
uint8_t scal_cipher_init(const scdesc_t* cipher_descriptor,
const void* key, uint16_t keysize_b,
const void* iv, uint16_t ivsize_b, scgen_ctx_t* ctx);
void scal_cipher_free(scgen_ctx_t* ctx);
uint8_t scal_cipher_gen_byte(scgen_ctx_t* ctx);
void scal_cipher_gen_block(void* block, scgen_ctx_t* ctx);
void scal_cipher_gen_fillblock(void* block, uint16_t blocksize_B, scgen_ctx_t* ctx);
uint16_t scal_cipher_getBlocksize_b(const scdesc_t* desc);
void* scal_cipher_getKeysizeDesc(const scdesc_t* desc);
void* scal_cipher_getIVsizeDesc(const scdesc_t* desc);
#endif /* SCAL_BASIC_H_ */

279
scal/scal-nessie.c Normal file
View File

@ -0,0 +1,279 @@
/* scal-nessie.c */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2006-2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include "streamcipher_descriptor.h"
#include "scal-basic.h"
#include "nessie_common.h"
#include "memxor.h"
static
uint8_t estream_flag = 0;
void scal_nessie_set_estream(uint8_t v){
estream_flag = v?1:0;
}
uint8_t scal_nessie_get_estream(void){
return estream_flag?1:0;
}
static const uint8_t normal_hooks[] = {
0, 192/64, 256/64, 448/64
};
static const uint16_t long_hooks[] = {
0, 65472/64, 65536/64, 131008/64
};
static const char stream0_n[] = "stream[0..63]";
static const char stream1_n[] = "stream[192..255]";
static const char stream2_n[] = "stream[256..319]";
static const char stream3_n[] = "stream[448..511]";
static const char streamX_n_estream[] = "xor-digest";
static const char streamX_n_nessie[] = "stream[0..511]xored";
static const char* stream_n_str[] = {
stream0_n,
stream1_n,
stream2_n,
stream3_n,
streamX_n_nessie
};
static const char stream1_l[] = "stream[65472..65535]";
static const char stream2_l[] = "stream[65536..65599]";
static const char stream3_l[] = "stream[131008..131071]";
static const char streamX_l_estream[] = "xor-digest";
static const char streamX_l_nessie[] = "stream[0..131071]xored";
static const char* stream_l_str[] = {
stream0_n,
stream1_l,
stream2_l,
stream3_l,
streamX_l_nessie
};
static const uint8_t list_of_keys[][20] = {
{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
{ 0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0xfe, 0xdc,
0xba, 0x98, 0x76, 0x54, 0x32, 0x10, 0x00, 0x00, 0x00, 0x00 },
{ 0x67, 0x45, 0x23, 0x01, 0xef, 0xcd, 0xab, 0x89, 0x98, 0xba,
0xdc, 0xfe, 0x10, 0x32, 0x54, 0x76, 0xc3, 0xd2, 0xe1, 0xf0 }
};
static const uint8_t list_of_ivs[][4] = {
{ 0x00, 0x00, 0x00, 0x00 },
{ 0x01, 0x01, 0x01, 0x01 },
{ 0x01, 0x35, 0x77, 0xaf }
};
static
void normal_block(scgen_ctx_t *ctx){
uint8_t xor_block[64];
uint8_t block[64];
const uint8_t* hook_ptr = normal_hooks;
const char* *hook_str_ptr = stream_n_str;
uint8_t i;
memset(xor_block, 0, 64);
for(i=0; i<=448/64; ++i){
scal_cipher_gen_fillblock(block, 64, ctx);
memxor(xor_block, block, 64);
if(i==*hook_ptr){
++hook_ptr;
nessie_print_item(*(hook_str_ptr++), block, 64);
}
}
nessie_print_item(*(hook_str_ptr), xor_block, 64);
}
static
void long_block(scgen_ctx_t *ctx){
uint8_t xor_block[64];
uint8_t block[64];
const uint16_t* hook_ptr = long_hooks;
const char* *hook_str_ptr = stream_l_str;
uint16_t i;
memset(xor_block, 0, 64);
for(i=0; i<=131008/64; ++i){
scal_cipher_gen_fillblock(block, 64, ctx);
memxor(xor_block, block, 64);
if(i==*hook_ptr){
++hook_ptr;
nessie_print_item(*(hook_str_ptr++), block, 64);
}
if(i%64==0){
NESSIE_SEND_ALIVE;
}
}
nessie_print_item(*(hook_str_ptr), xor_block, 64);
}
void scal_nessie_stream_run(const scdesc_t *desc, uint16_t keysize_b, uint16_t ivsize_b){
uint8_t key[(keysize_b+7)/8];
uint8_t iv[(ivsize_b+7)/8];
uint16_t v;
scgen_ctx_t ctx;
nessie_print_header(desc->name, keysize_b, 0, 0, 0, ivsize_b?ivsize_b:((uint16_t)-1));
if(estream_flag){
stream_n_str[4] = streamX_n_estream;
stream_l_str[4] = streamX_l_estream;
}else{
stream_n_str[4] = streamX_n_nessie;
stream_l_str[4] = streamX_l_nessie;
}
memset(iv, 0, (ivsize_b+7)/8);
memset(key, 0, (keysize_b+7)/8);
/*** Test SET 1 ***/
nessie_print_setheader(1);
for(v=0;v<keysize_b; v+=estream_flag?9:1){
nessie_print_set_vector(1,v);
key[v/8] |= 0x80>>(v&7);
nessie_print_item("key", key, (keysize_b+7)/8);
if(ivsize_b){
nessie_print_item("IV", iv, (ivsize_b+7)/8);
}
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
normal_block(&ctx);
key[v/8] = 0;
scal_cipher_free(&ctx);
}
/*** Test SET 2 ***/
nessie_print_setheader(2);
for(v=0;v<256; v+=estream_flag?9:1){
nessie_print_set_vector(2,v);
memset(key, v&0xff, (keysize_b+7)/8);
nessie_print_item("key", key, (keysize_b+7)/8);
if(ivsize_b){
nessie_print_item("IV", iv, (ivsize_b+7)/8);
}
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
normal_block(&ctx);
scal_cipher_free(&ctx);
}
/*** Test SET 3 ***/
nessie_print_setheader(3);
for(v=0;v<256; v+=estream_flag?9:1){
uint8_t i;
nessie_print_set_vector(3,v);
for(i=0; i<((keysize_b+7)/8); ++i){
key[i]=(i+v)&0xff;
}
nessie_print_item("key", key, (keysize_b+7)/8);
if(ivsize_b){
nessie_print_item("IV", iv, (ivsize_b+7)/8);
}
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
normal_block(&ctx);
scal_cipher_free(&ctx);
}
/*** Test SET 4 ***/
nessie_print_setheader(4);
for(v=0;v<4; ++v){
uint8_t i;
nessie_print_set_vector(4,v);
for(i=0; i<((keysize_b+7)/8); ++i){
key[i]=(i*0x53+v*5)&0xff;
}
nessie_print_item("key", key, (keysize_b+7)/8);
if(ivsize_b){
nessie_print_item("IV", iv, (ivsize_b+7)/8);
}
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
long_block(&ctx);
scal_cipher_free(&ctx);
}
if(ivsize_b==0){ /* exit if there is no IV */
nessie_print_footer();
return;
}
/*** Test SET 5 ***/
nessie_print_setheader(5);
memset(key, 0, (keysize_b+7)/8);
for(v=0;v<ivsize_b; v+=estream_flag?9:1){
nessie_print_set_vector(5,v);
iv[v/8] |= 0x80>>(v&7);
nessie_print_item("key", key, (keysize_b+7)/8);
nessie_print_item("IV", iv, (ivsize_b+7)/8);
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
normal_block(&ctx);
scal_cipher_free(&ctx);
iv[v/8] = 0;
}
/*** Test SET 6 ***/
nessie_print_setheader(6);
for(v=0;v<4; ++v){
uint8_t i;
nessie_print_set_vector(6,v);
for(i=0; i<((keysize_b+7)/8); ++i){
key[i]=(i*0x53+v*5)&0xff;
}
for(i=0; i<((ivsize_b+7)/8); ++i){
iv[i]=(i*0x67+v*9+13)&0xff;
}
nessie_print_item("key", key, (keysize_b+7)/8);
nessie_print_item("IV", iv, (ivsize_b+7)/8);
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
long_block(&ctx);
scal_cipher_free(&ctx);
}
/*** Test SET 7 ***/
if(!estream_flag){
nessie_print_setheader(7);
uint8_t u;
for(v=0;v<3; ++v){
for(u=0; u<3; ++u){
uint8_t i;
nessie_print_set_vector(7,v*3+u);
for(i=0; i<((keysize_b+7)/8); ++i){
key[i]=list_of_keys[v][i%20];
}
for(i=0; i<((ivsize_b+7)/8); ++i){
key[i]=*((uint8_t*)list_of_keys+4*u+(i%4));
}
}
nessie_print_item("key", key, (keysize_b+7)/8);
nessie_print_item("IV", iv, (ivsize_b+7)/8);
scal_cipher_init(desc, key, keysize_b, iv, ivsize_b, &ctx);
long_block(&ctx);
scal_cipher_free(&ctx);
}
}
nessie_print_footer();
}
void scal_nessie_run(const scdesc_t* desc){
uint16_t keysizes_count, ivsizes_count,i,j;
uint16_t *keysizes=NULL, *ivsizes=NULL;
keysizes_count = get_keysizes(desc->valid_keysize_desc, &keysizes);
ivsizes_count = get_keysizes(desc->valid_ivsize_desc, &ivsizes);
for(i=0; i<keysizes_count; ++i){
for(j=0; j<ivsizes_count; ++j){
scal_nessie_stream_run(desc, keysizes[i], ivsizes[j]);
}
}
}

32
scal/scal-nessie.h Normal file
View File

@ -0,0 +1,32 @@
/* scal-nessie.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCALNESSIE_H_
#define SCALNESSIE_H_
#include <stdint.h>
#include <streamcipher_descriptor.h>
void scal_nessie_set_estream(uint8_t v);
uint8_t scal_nessie_get_estream(void);
void scal_nessie_stream_run(const scdesc_t *desc, uint16_t keysize_b, uint16_t ivsize_b);
void scal_nessie_run(const scdesc_t* desc);
#endif /* SCALNESSIE_H_ */

56
scal/scal_arcfour.c Normal file
View File

@ -0,0 +1,56 @@
/* scal_arcfour.c */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <stdint.h>
#include "streamcipher_descriptor.h"
#include "keysize_descriptor.h"
#include "arcfour.h"
const char arcfour_str[] = "ARCFOUR";
const uint8_t arcfour_keysize_desc[] = {
KS_TYPE_LIST, 3, KS_INT(128), KS_INT(192), KS_INT(256),
KS_TYPE_ARG_RANGE, KS_INT(8), KS_INT(2040), KS_INT(8), KS_INT(0),
KS_TYPE_TERMINATOR };
const uint8_t arcfour_ivsize_desc[] = {
KS_TYPE_LIST, 1, KS_INT(0),
KS_TYPE_TERMINATOR };
const scdesc_t arcfour_desc = {
SCDESC_TYPE_STREAMCIPHER, /* abstraction layer type designator */
SC_INIT_TYPE_3|SC_GEN_TYPE_1, /* flags*/
arcfour_str, /* name string pointer */
sizeof(arcfour_ctx_t), /* size of context */
8, /* blocksize */
{(void_fpt)arcfour_init}, /* init function pointer */
{(void_fpt)arcfour_gen}, /* key stream generator function pointer */
{(void_fpt)NULL}, /* key stream generator for random access function pointer */
(sc_free_fpt)NULL, /* free function pointer */
arcfour_keysize_desc, /* key size descriptor pointer */
arcfour_ivsize_desc /* iv size descriptor pointer */
};

27
scal/scal_arcfour.h Normal file
View File

@ -0,0 +1,27 @@
/* scal_arcfour.h */
/*
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2011 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SCAL_ARCFOUR_H_
#define SCAL_ARCFOUR_H_
#include "streamcipher_descriptor.h"
extern const scdesc_t arcfour_desc;
#endif /* SCAL_ARCFOUR_H_ */

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,7 @@
/* cli.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -81,7 +81,7 @@ uint16_t cli_getc_cecho(void){
}
/**
* \brief outputs a zero-terminated string from ram to the console
* \brief ouputs a zero-terminated string from ram to the console
*/
void cli_putstr(const char* s){
if(!cli_tx)
@ -90,12 +90,13 @@ void cli_putstr(const char* s){
cli_tx(*s++);
}
/**
* \brief reads a line or max n characters from the console
* Writes characters from the console into the supplied buffer until a '\r'
* character is received or until n character a read (whatever happens first).
* Writes characters from the console into the supplyed buffer until a '\r'
* character is recieved or until n character a read (whatever happens first).
* The string will always be terminated by a '\0' character, so the buffer
* should have at least a size of n+1.
* should have at least a size of n+1.
*/
uint8_t cli_getsn(char* s, uint32_t n){
char c;
@ -108,22 +109,6 @@ uint8_t cli_getsn(char* s, uint32_t n){
return (c=='\r')?0:1;
}
/**
* \brief reads a line or max n characters from the console and echos the characters back
* Writes characters from the console into the supplied buffer until a '\r'
* character is received or until n character a read (whatever happens first).
* The string will always be terminated by a '\0' character, so the buffer
* should have at least a size of n+1.
*/
uint8_t cli_getsn_cecho(char* s, uint32_t n){
uint8_t echo_backup,r ;
echo_backup = cli_echo;
cli_echo = 1;
r = cli_getsn(s, n);
cli_echo = echo_backup;
return r;
}
void cli_hexdump_byte(uint8_t byte){
cli_tx(hexdigit_tab[byte>>4]);
cli_tx(hexdigit_tab[byte & 0xf]);
@ -257,7 +242,10 @@ typedef void(*str_fpt)(char*);
static
int8_t search_and_call(char* cmd, uint32_t maxcmdlength, const cmdlist_entry_t* cmdlist){
const cmdlist_entry_t* cmdlist_orig = cmdlist;
const cmdlist_entry_t* cmdlist_orig=cmdlist;
if(!cmdlist){
return 3;
}
if(*cmd=='\0' || *cmd=='#')
return 1;
if(!strcmp(cmd, "exit"))
@ -271,15 +259,13 @@ int8_t search_and_call(char* cmd, uint32_t maxcmdlength, const cmdlist_entry_t*
memcpy(fw, cmd, fwlength);
fw[fwlength] = '\0';
cmdlist_entry_t item;
do{
memcpy(&item, cmdlist, sizeof(cmdlist_entry_t));
cmdlist += 1;
}while(item.cmd_name!=NULL && strcmp(fw, item.cmd_name));
if(item.cmd_name==NULL){
while(cmdlist->cmd_name && strcmp(fw, cmdlist->cmd_name)){
++cmdlist;
}
if(!cmdlist->cmd_name){
cli_auto_help(maxcmdlength, cmdlist_orig);
} else {
if(item.cmd_function==NULL)
return 2;
memcpy(&item, cmdlist, sizeof(cmdlist_entry_t));
switch((uint32_t)item.cmd_param_str){
case 0:
item.cmd_function();
@ -300,13 +286,13 @@ int8_t search_and_call(char* cmd, uint32_t maxcmdlength, const cmdlist_entry_t*
return 1;
}
static const
static
uint16_t max_cmd_length(const cmdlist_entry_t* cmdlist){
uint16_t t,ret=0;
const char* str;
for(;;){
str = cmdlist->cmd_name;
cmdlist += 1;
++cmdlist;
if(str==NULL){
return ret;
}
@ -331,7 +317,7 @@ uint8_t cli_completion(char* buffer, uint16_t maxcmdlength, const cmdlist_entry_
itemstr = cmdlist->cmd_name;
if(itemstr==NULL)
break;
cmdlist += 1;
++cmdlist;
if(!strncmp(buffer, itemstr, i)){
if(!ref[0]){
strcpy(ref, itemstr);

View File

@ -1,6 +1,6 @@
/* cli.h */
/*
This file is part of the ARM-Crypto-Lib.
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
@ -42,10 +42,10 @@ typedef struct {
#define CLI_OPTION_MANP 0x02
typedef struct {
const char* cmd_name; /* string containing the function name */
const char* cmd_param_str; /* param descriptor string */
const char* cmd_name; /* string containing the function name */
const char* cmd_param_str; /* param descriptor string */
void_fpt cmd_function; /* function pointer */
cmdoption_t* options;
const cmdoption_t* options;
} cmdlist_entry_t;
extern cli_rx_fpt cli_rx;
@ -56,14 +56,12 @@ extern uint8_t cli_echo;
void cli_putc(char c);
uint16_t cli_getc(void);
uint16_t cli_getc_cecho(void);
uint8_t cli_getsn_cecho(char* s, uint32_t n);
uint8_t cli_getsn(char* s, uint32_t n);
void cli_putstr(const char* s);
void cli_hexdump(const void* data, uint32_t length);
void cli_hexdump_rev(const void* data, uint32_t length);
void cli_hexdump2(const void* data, uint32_t length);
void cli_hexdump_block(const void* data, uint32_t length, uint8_t indent, uint8_t width);
void cli_hexdump_byte(uint8_t byte);
void echo_ctrl(char* s);
int8_t cmd_interface(const cmdlist_entry_t* cmd_desc);

View File

@ -158,7 +158,7 @@ int32_t getValue(char* key){
if(*str2=='='){
do{
str2++;
}while(*str2 && !isdigit(*str2));
}while(*str2 && !isdigit((uint8_t)(*str2)));
val=(uint32_t)strtoul(str2, NULL, 10);
return val;
}
@ -322,7 +322,7 @@ void cmacvs_test1(void){ /* Gen tests */
cli_putstr("\r\n");
#endif
while((c=cli_getc_cecho())!='M' && c!='m'){
if(!isspace(c)){
if(!isspace((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (1) [0x");
cli_hexdump(&c, 1);
cli_putstr("]!\r\n");
@ -341,7 +341,7 @@ void cmacvs_test1(void){ /* Gen tests */
return;
}
while((c=cli_getc_cecho())!='='){
if(!isspace(c)){
if(!isspace((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (4)!\r\n");
bcal_cmac_free(&(cmacvs_ctx.ctx));
return;
@ -487,7 +487,7 @@ void cmacvs_test2(void){ /* Ver tests */
cli_putstr("\r\n");
#endif
while((c=cli_getc_cecho())!='M' && c!='m'){
if(!isspace(c)){
if(!isspace((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (1) [0x");
cli_hexdump(&c, 1);
cli_putstr("]!\r\n");
@ -506,7 +506,7 @@ void cmacvs_test2(void){ /* Ver tests */
return;
}
while((c=cli_getc_cecho())!='='){
if(!isspace(c)){
if(!isspace((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (4)!\r\n");
bcal_cmac_free(&(cmacvs_ctx.ctx));
return;

View File

@ -0,0 +1,125 @@
/* main-arcfour-test.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* arcfour (RC4 compatible) test-suit
*
*/
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "config.h"
#include "cli.h"
#include "dump.h"
#include "uart_lowlevel.h"
#include "sysclock.h"
#include "hw_gptm.h"
#include "arcfour.h"
#include "scal_arcfour.h"
#include "scal-nessie.h"
#include "nessie_stream_test.h"
#include "performance_test.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
const char* algo_name = "Arcfour";
void uart0_putc(char byte){
uart_putc(UART_0, byte);
}
char uart0_getc(void){
return uart_getc(UART_0);
}
/*****************************************************************************
* additional validation-functions *
*****************************************************************************/
void testrun_nessie_arcfour(void){
scal_nessie_run(&arcfour_desc);
}
void testrun_performance_arcfour(void){
uint64_t t;
char str[16];
uint8_t key[16];
arcfour_ctx_t ctx;
calibrateTimer();
print_overhead();
memset(key, 0, 16);
startTimer(1);
arcfour_init(key, 16, &ctx);
t = stopTimer();
cli_putstr("\r\n\tctx-gen time: ");
ultoa((unsigned long)t, str, 10);
cli_putstr(str);
startTimer(1);
arcfour_gen(&ctx);
t = stopTimer();
cli_putstr("\r\n\tencrypt time: ");
ultoa((unsigned long)t, str, 10);
cli_putstr(str);
cli_putstr("\r\n");
}
/*****************************************************************************
* main *
*****************************************************************************/
const cmdlist_entry_t cmdlist[] = {
{ "nessie", NULL, testrun_nessie_arcfour },
{ "test", NULL, testrun_nessie_arcfour},
{ "performance", NULL, testrun_performance_arcfour},
{ "echo", (void*)1, (void_fpt)echo_ctrl},
{ NULL, NULL, NULL}
};
int main (void){
sysclk_set_freq(SYS_FREQ);
sysclk_mosc_verify_enable();
uart_init(UART_0, 115200, 8, UART_PARATY_NONE, UART_STOPBITS_ONE);
gptm_set_timer_32periodic(TIMER0);
cli_rx = uart0_getc;
cli_tx = uart0_putc;
for(;;){
cli_putstr("\r\n\r\nARM-Crypto-Lib VS (");
cli_putstr(algo_name);
cli_putstr("; ");
cli_putstr(__DATE__);
cli_putc(' ');
cli_putstr(__TIME__);
cli_putstr(")\r\nloaded and running\r\n");
cmd_interface(cmdlist);
}
}

View File

@ -167,8 +167,7 @@ void nessie_print_header(const char* name,
if(ivsize_b){
if(ivsize_b==(uint16_t)-1){
cli_putstr("\r\nNo initial value (IV) mode");
}
{
}else{
cli_putstr("\r\nIV size: ");
ustoa(ivsize_b, str, 10);
cli_putstr(str);

View File

@ -157,7 +157,7 @@ int32_t getLength(void){
if(*len2=='='){
do{
len2++;
}while(*len2 && !isdigit(*len2));
}while(*len2 && !isdigit((uint8_t)*len2));
len=(uint32_t)strtoul(len2, NULL, 10);
return len;
}
@ -229,7 +229,7 @@ void shavs_test1(void){ /* KAT tests */
cli_putstr("\r\n");
#endif
while((c=cli_getc_cecho())!='M' && c!='m'){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (1) [0x");
cli_hexdump(&c, 1);
cli_putstr("]!\r\n");
@ -248,7 +248,7 @@ void shavs_test1(void){ /* KAT tests */
return;
}
while((c=cli_getc_cecho())!='='){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (4)!\r\n");
hfal_hash_free(&(shavs_ctx.ctx));
return;
@ -336,7 +336,7 @@ void shavs_test2(void){ /* Monte Carlo tests for SHA-1 & SHA-2 */
uint8_t m[ml*4+8];
for(;;){
while((c=cli_getc_cecho())!='S' && c!='s'){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (1) [0x");
cli_hexdump(&c, 1);
cli_putstr("]!\r\n");
@ -356,7 +356,7 @@ void shavs_test2(void){ /* Monte Carlo tests for SHA-1 & SHA-2 */
return;
}
while((c=cli_getc_cecho())!='='){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (5)!\r\n");
return;
}
@ -421,7 +421,7 @@ void shavs_test3(void){ /* Monte Carlo tests for SHA-3 */
uint8_t m[ml+128];
for(;;){
while((c=cli_getc_cecho())!='S' && c!='s'){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (1) [0x");
cli_hexdump(&c, 1);
cli_putstr("]!\r\n");
@ -441,7 +441,7 @@ void shavs_test3(void){ /* Monte Carlo tests for SHA-3 */
return;
}
while((c=cli_getc_cecho())!='='){
if(!isblank(c)){
if(!isblank((uint8_t)c)){
cli_putstr("\r\nERROR: wrong input (5)!\r\n");
return;
}

View File

@ -1,7 +1,7 @@
/* string_extras.c */
/*
This file is part of the ARM-Crypto-Lib.
Copyright (C) 2006-2010 Daniel Otte (daniel.otte@rub.de)
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@ -28,7 +28,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>
#include "cli.h"
uint32_t stridentcnt(const char* a, const char* b){
uint16_t i=0;
@ -43,8 +44,13 @@ uint32_t stridentcnt(const char* a, const char* b){
uint16_t firstword_length(const char* s){
uint16_t ret=0;
while(isgraph((uint8_t)(*s++)))
if(!s){
return 0;
}
int c;
while(c=*s++, isgraph(c)){
ret++;
}
return ret;
}
@ -77,85 +83,65 @@ void str_reverse(char* buffer){
--j;
}
}
char* ultoa (unsigned long value, char* buffer, uint8_t radix ){
if((radix>36) || (radix<2) || (buffer==NULL)){
char* ultoa(unsigned long a, char* buffer, uint8_t radix){
if(radix<2 || radix>36){
return NULL;
}
unsigned length=(unsigned)-1;
uint8_t x;
char c;
do{
x = value%radix;
value /= radix;
if(x<10){
c = x+ '0';
}else{
c = x+ 'a';
}
buffer[++length] = c;
}while(value);
buffer[length+1]='\0';
unsigned idx=0;
while(idx+1<length){
c = buffer[idx];
buffer[idx++] = buffer[length];
buffer[length--] = c;
char* ptr=buffer;
div_t result;
if(a==0){
ptr[0] = '0';
ptr[1] = '\0';
return buffer;
}
while(a){
result = div(a, radix);
*ptr = result.rem;
if(result.rem<10){
*ptr += '0';
}else{
*ptr += 'a'-10;
}
++ptr;
a = result.quot;
}
*ptr = '\0';
str_reverse(buffer);
return buffer;
}
char* ulltoa(unsigned long long value, char* buffer, uint8_t radix){
if((radix>36) || (radix<2) || (buffer==NULL)){
char* ulltoa(unsigned long long a, char* buffer, uint8_t radix){
if(radix<2 || radix>36){
return NULL;
}
unsigned length=(unsigned)-1;
uint8_t x;
char c;
do{
x = value%radix;
value /= radix;
if(x<10){
c = x+ '0';
}else{
c = x+ 'a';
}
buffer[++length] = c;
}while(value);
buffer[length+1]='\0';
unsigned idx=0;
while(idx+1<length){
c = buffer[idx];
buffer[idx++] = buffer[length];
buffer[length--] = c;
char* ptr=buffer;
uint8_t rem;
unsigned long long quot;
if(a==0){
ptr[0] = '0';
ptr[1] = '\0';
return buffer;
}
while(a){
rem = a % radix;
quot = a / radix;
if(rem<10){
rem += '0';
}else{
rem += 'a'-10;
}
*ptr++ =rem;
a = quot;
}
*ptr = '\0';
str_reverse(buffer);
return buffer;
}
char* ustoa(unsigned short value, char* buffer, uint8_t radix){
if((radix>36) || (radix<2) || (buffer==NULL)){
return NULL;
}
unsigned length=(unsigned)-1;
uint8_t x;
char c;
do{
x = value%radix;
value /= radix;
if(x<10){
c = x+ '0';
}else{
c = x+ 'a';
}
buffer[++length] = c;
}while(value);
buffer[length+1]='\0';
unsigned idx=0;
while(idx+1<length){
c = buffer[idx];
buffer[idx++] = buffer[length];
buffer[length--] = c;
}
return buffer;
char* ustoa(unsigned short a, char* buffer, uint8_t radix){
return ultoa((unsigned long)a, buffer, radix);
}
/*
void strlwr(char* s){

View File

@ -1,6 +1,6 @@
/* string-extras.h */
/*
This file is part of the ARM-Crypto-Lib.
This file is part of the AVR-Crypto-Lib.
Copyright (C) 2008 Daniel Otte (daniel.otte@rub.de)
This program is free software: you can redistribute it and/or modify
@ -58,8 +58,6 @@ char* strstrip(char* str);
void str_reverse(char* buffer);
char* ultoa(unsigned long a, char* buffer, uint8_t radix);
char* ulltoa(unsigned long long a, char* buffer, uint8_t radix);
char* ustoa(unsigned short a, char* buffer, uint8_t radix);
// void strlwr(char* s);

Binary file not shown.

View File

@ -212,7 +212,7 @@ uint8_t uart_init(uint8_t uartno, uint32_t baudrate, uint8_t databits, uint8_t p
}
/* uart interrupt enable */
HW_REG(uart_base[uartno]+UARTIM_OFFSET) |= _BV(UART_TXIM) | _BV(UART_RXIM);
HW_REG(ISR_ENABLE_VECTOR+uart_isr_vector[uartno]/32) |=
HW_REG(ISR_ENABLE_VECTOR+4*(uart_isr_vector[uartno]/32)) |=
_BV(uart_isr_vector[uartno]%32);
HW_REG(uart_base[uartno]+UARTCTL_OFFSET) |= _BV(UART_EOT);
@ -266,12 +266,3 @@ uint32_t uart_dataavail(uint8_t uartno){
}
return(HW_REG(uart_base[uartno]+UARTFR_OFFSET)&_BV(UART_RXFE))?0:1;
}
void uart_flush(uint8_t uartno){
if(uartno>UART_MAX){
return;
}
while(uart_tx_buffer[uartno].fillcount>0){
;
}
}

File diff suppressed because it is too large Load Diff