return;
nessie_hash_ctx.hashsize_b = hd->hashsize_b;
- nessie_hash_ctx.name = (char*)(hd->name); /* needs a nicer fix */
+ nessie_hash_ctx.name = hd->name;
nessie_hash_ctx.blocksize_B = hd->blocksize_b/8;
nessie_hash_ctx.ctx_size_B = hd->ctxsize_B;
nessie_hash_ctx.hash_init = (nessie_hash_init_fpt)(hd->init);
char c;
if(n==0)
return 2;
- while((c=cli_getc_cecho())!='\0' && c!='\r' && n--){
+ while((c=cli_getc_cecho())!='\0' && c!='\r' && n){
+ --n;
*s++=c;
}
*s='\0';
int main(void) {
main_setup();
+ shavs_algolist=(hfdesc_t**)algolist;
+ shavs_algo=(hfdesc_t*)&sha512_desc;
+
for(;;){
welcome_msg(algo_name);
cmd_interface(cmdlist);
#include "cli.h"
#include "string-extras.h"
+
#ifdef NESSIE_ALIVE
void nessie_send_alive(void){
cli_putc(NESSIE_ALIVE_CHAR);
uint16_t i;
cli_putstr("\r\n\r\n"
"********************************************************************************\r\n"
- "* ARM-Crypto-Lib - crypto primitives for ARM microcontrolles by Daniel Otte *\r\n"
+ "* ARM-Crypto-Lib - crypto primitives for ARM microcontrollers by Daniel Otte *\r\n"
"********************************************************************************\r\n"
"\r\n");
+
cli_putstr("Primitive Name: ");
cli_putstr(name);
cli_putstr("\r\n");
for(i=0; i<16+strlen(name); ++i){
cli_putc('=');
}
- char str[6]; /* must catch numbers up to 65535 + terminatin \0 */
+ char str[6]; /* must catch numbers up to 65535 + terminating \0 */
if(keysize_b){
cli_putstr("\r\nKey size: ");
ustoa(keysize_b, str, 10);
cli_putstr(str);
cli_putstr(" bits");
}
+
if(macsize_b){
cli_putstr("\r\nMac size: ");
ustoa(macsize_b, str, 10);
uint16_t hashsize_b;
uint16_t blocksize_B;
uint16_t ctx_size_B;
- char* name;
+ const char* name;
nessie_hash_init_fpt hash_init;
nessie_hash_next_fpt hash_next;
nessie_hash_last_fpt hash_last;
#define DEBUG 0
#if DEBUG
+#include "uart_lowlevel.h"
//# include "config.h"
//# include <util/delay.h>
#endif
return 0;
}
+static
+uint32_t my_strtoul(const char* str){
+ uint32_t r=0;
+ while(*str && (*str<'0' || *str>'9')){
+ str++;
+ }
+ if(!*str){
+ return 0;
+ }
+ while(*str && (*str>='0' && *str<='9')){
+ r *= 10;
+ r += *str-'0';
+ str++;
+ }
+ return r;
+}
+
int32_t getLength(void){
uint32_t len=0;
- char lenstr[21];
+ char lenstr[25];
char* len2;
for(;;){
memset(lenstr, 0, 21);
do{
len2++;
}while(*len2 && !isdigit((uint8_t)*len2));
- len=(uint32_t)strtoul(len2, NULL, 10);
+ len = my_strtoul(len2);
+ //len=(uint32_t)strtoul(len2, NULL, 10);
return len;
}
} else {
shavs_ctx.blocks = 0;
memset(buffer, 0, shavs_ctx.buffersize_B);
length = getLength();
- if(length<0){
+ if((int32_t)length<0){
+#if DEBUG
+ cli_putstr("\r\n(x) Len == ");
+ cli_hexdump_rev(&length, 4);
+ uart_flush(0);
+#endif
return;
}
#if DEBUG
cli_putstr("\r\nLen == ");
cli_hexdump_rev(&length, 4);
+ uart_flush(0);
#endif
if(length==0){
expect_input=2;
return buffer;
}
while(a){
+ /* toolchain bug??
result = div(a, radix);
+ */
+ result.quot = a/radix;
+ result.rem = a%radix;
*ptr = result.rem;
if(result.rem<10){
*ptr += '0';
if(uartno>UART_MAX){
return;
}
+ while(circularbytebuffer_cnt(&(uart_tx_buffer[uartno])))
+ ;
while((HW_REG(uart_base[uartno]+UARTCTL_OFFSET)&_BV(UART_EOT)) == 0)
;
}