From: bg Date: Sat, 6 Mar 2010 22:46:52 +0000 (+0000) Subject: debugging stuff removed from bigint X-Git-Url: https://git.cryptolib.org/?a=commitdiff_plain;h=96e930bbd293d62d8a9d2b011eb958aee6840c42;p=avr-crypto-lib.git debugging stuff removed from bigint --- diff --git a/bigint/bigint.c b/bigint/bigint.c index 7dd841b..f57d285 100644 --- a/bigint/bigint.c +++ b/bigint/bigint.c @@ -29,9 +29,6 @@ #include "bigint.h" #include -#include "bigint_io.h" -#include "cli.h" - #ifndef MAX #define MAX(a,b) (((a)>(b))?(a):(b)) #endif @@ -559,7 +556,6 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){ int16_t t; if(a->length_B < b->length_B+byteshift){ - cli_putstr_P(PSTR("\r\nERROR: bigint_sub_u_bitscale result negative")); bigint_set_zero(a); return; } @@ -579,7 +575,6 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){ } while(borrow){ if(i+1 > a->length_B){ - cli_putstr_P(PSTR("\r\nERROR: bigint_sub_u_bitscale result negative (2) shift=")); cli_hexdump_rev(&bitscale, 2); bigint_set_zero(a); return; @@ -597,13 +592,6 @@ void bigint_sub_u_bitscale(bigint_t* a, const bigint_t* b, uint16_t bitscale){ void bigint_reduce(bigint_t* a, const bigint_t* r){ uint8_t rfbs = GET_FBS(r); -/* - cli_putstr_P(PSTR("\r\nreduce ")); - bigint_print_hex(a); - cli_putstr_P(PSTR(" % ")); - bigint_print_hex(r); - cli_putstr_P(PSTR("\r\n")); -*/ if(r->length_B==0){ return; @@ -643,11 +631,9 @@ void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, con i=exp->length_B-1; if(exp->wordv[i]!=1){ for(j=1<<(GET_FBS(exp)-1); j>0; j>>=1){ - // cli_putc('Q'); bigint_square(&tmp2, &tmp); bigint_reduce(&tmp2, r); if(exp->wordv[i]&j){ - // cli_putc('M'); bigint_mul_u(&tmp, &tmp2, &x); bigint_reduce(&tmp, r); }else{ @@ -657,11 +643,9 @@ void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, con } for(--i; i>=0; --i){ for(j=0x80; j>0; j>>=1){ -// cli_putc('q'); bigint_square(&tmp2, &tmp); bigint_reduce(&tmp2, r); if(exp->wordv[i]&j){ -// cli_putc('m'); bigint_mul_u(&tmp, &tmp2, &x); bigint_reduce(&tmp, r); }else{ @@ -669,10 +653,9 @@ void bigint_expmod_u(bigint_t* dest, const bigint_t* a, const bigint_t* exp, con } } } -// cli_putstr_P(PSTR("\r\n")); bigint_copy(dest, &tmp); } -#define DEBUG 0 + /******************************************************************************/ /* gcd <-- gcd(x,y) a*x+b*y=gcd */ void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, const bigint_t* y){ @@ -704,31 +687,13 @@ void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, c for(i=0; (x_.wordv[0]&(1<=v ...")); - cli_putstr_P(PSTR("\r\nDBG: (30) a = ")); - bigint_print_hex(&a_); - cli_putstr_P(PSTR("\r\nDBG: (30) b = ")); - bigint_print_hex(&b_); - cli_putstr_P(PSTR("\r\nDBG: (30) c = ")); - bigint_print_hex(&c_); - cli_putstr_P(PSTR("\r\nDBG: (30) d = ")); - bigint_print_hex(&d_); -#endif if(bigint_cmp_u(&u, &v)>=0){ bigint_sub_u(&u, &u, &v); bigint_sub_s(&a_, &a_, &c_); @@ -811,26 +741,6 @@ void bigint_gcdext(bigint_t* gcd, bigint_t* a, bigint_t* b, const bigint_t* x, c bigint_sub_s(&c_, &c_, &a_); bigint_sub_s(&d_, &d_, &b_); } -#if DEBUG - if(GET_SIGN(&u)){ - cli_putstr_P(PSTR("\r\nDBG: u negative! u = ")); - bigint_print_hex(&u); - } - if(GET_SIGN(&v)){ - cli_putstr_P(PSTR("\r\nDBG: v negative! v = ")); - bigint_print_hex(&v); - } -#endif -/* - cli_putstr_P(PSTR("\r\nDBG: (2) a = ")); - bigint_print_hex(&a_); - cli_putstr_P(PSTR("\r\nDBG: (2) b = ")); - bigint_print_hex(&b_); - cli_putstr_P(PSTR("\r\nDBG: (2) c = ")); - bigint_print_hex(&c_); - cli_putstr_P(PSTR("\r\nDBG: (2) d = ")); - bigint_print_hex(&d_); -*/ }while(u.length_B); if(gcd){ bigint_mul_s(gcd, &v, &g);