X-Git-Url: https://git.cryptolib.org/?p=avr-crypto-lib.git;a=blobdiff_plain;f=rsa%2Frsa_basic.c;h=0b6fef624237e0393e568f4d0bf0982b982de2dd;hp=3d6581fe5fcf13ea1fd0f56f492239bfa9849758;hb=e9e07569721b9e005d6b602e26a03e930e796577;hpb=3a9f9d918fb95474996af535c225a7e187d88372 diff --git a/rsa/rsa_basic.c b/rsa/rsa_basic.c index 3d6581f..0b6fef6 100644 --- a/rsa/rsa_basic.c +++ b/rsa/rsa_basic.c @@ -1,7 +1,7 @@ /* rsa_basic.c */ /* This file is part of the ARM-Crypto-Lib. - Copyright (C) 2006-2011 Daniel Otte (daniel.otte@rub.de) + Copyright (C) 2006-2015 Daniel Otte (bg@nerilex.org) 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,6 +28,7 @@ #if DEBUG #include "cli.h" +#include #endif void rsa_enc(bigint_t *data, const rsa_publickey_t *key){ @@ -101,7 +102,7 @@ uint8_t rsa_dec_crt_mono(bigint_t *data, const rsa_privatekey_t *key){ while(BIGINT_NEG_MASK & m1.info){ #if DEBUG cli_putstr_P(PSTR("\r\nDBG: adding ")); - bigint_print_hex(key->components[0]); + bigint_print_hex(&key->components[0]); cli_putstr_P(PSTR("\r\nDBG: to ")); bigint_print_hex(&m1); #endif @@ -188,13 +189,12 @@ void rsa_os2ip(bigint_t *dest, const void *data, uint32_t length_B){ uint8_t off; off = (sizeof(bigint_word_t) - length_B % sizeof(bigint_word_t)) % sizeof(bigint_word_t); #if DEBUG - cli_putstr_P(PSTR("\r\nDBG: off = 0x")); - cli_hexdump_byte(off); + printf("\r\nDBG: off = 0x%02x", off); #endif - if(!data){ - if(off){ + if (!data) { + if (off) { dest->wordv = realloc(dest->wordv, length_B + sizeof(bigint_word_t) - off); - memmove((uint8_t*)dest->wordv+off, dest->wordv, length_B); + memmove((uint8_t*)dest->wordv + off, dest->wordv, length_B); memset(dest->wordv, 0, off); } }else{ @@ -205,8 +205,7 @@ void rsa_os2ip(bigint_t *dest, const void *data, uint32_t length_B){ } dest->length_W = (length_B + off) / sizeof(bigint_word_t); #if DEBUG - cli_putstr_P(PSTR("\r\nDBG: dest->length_W = 0x")); - cli_hexdump_rev(&(dest->length_W), 2); + printf("\r\nDBG: dest->length_W = %u", dest->length_W); #endif #endif dest->info = 0;