X-Git-Url: https://git.cryptolib.org/?a=blobdiff_plain;f=ecdsa%2Fecdsa_sign.c;h=217da031ce27dcdc7ea465a585fb3bf2e695ae9d;hb=d9352fc79fbdee0cf3288809b104ea196ea85693;hp=7b3671ea76ffc1ba5ce3ac983865672277dda8a7;hpb=55113fbb49edbc607a5ea5657be14e35296102c4;p=avr-crypto-lib.git diff --git a/ecdsa/ecdsa_sign.c b/ecdsa/ecdsa_sign.c index 7b3671e..217da03 100644 --- a/ecdsa/ecdsa_sign.c +++ b/ecdsa/ecdsa_sign.c @@ -1,7 +1,7 @@ /* ecdsa.c */ /* This file is part of the AVR-Crypto-Lib. - Copyright (C) 2006-2012 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 @@ -76,35 +76,14 @@ uint8_t ecdsa_sign_bigint(ecdsa_signature_t *s, const bigint_t *m, return 2; } ecc_chudnovsky_to_affine_point(&q.affine, &q.chudnovsky, ctx->curve); - bigint_inverse(&s->s, k, ctx->curve->p); - - printf_P(PSTR("x: ")); - bigint_print_hex(&q.affine.x); - putchar('\n'); + bigint_inverse(&s->s, k, ctx->curve->n); bigint_mul_u(&t, &q.affine.x, ctx->priv); - ctx->curve->reduce_p(&t); - - printf_P(PSTR("msg: ")); - bigint_print_hex(m); - putchar('\n'); - printf_P(PSTR("k: ")); - bigint_print_hex(k); - putchar('\n'); - printf_P(PSTR("k-inv: ")); - bigint_print_hex(&s->s); - putchar('\n'); - printf_P(PSTR("t (1): ")); - bigint_print_hex(&t); - putchar('\n'); - + bigint_reduce(&t, ctx->curve->n); bigint_add_u(&t, &t, m); - ctx->curve->reduce_p(&t); - printf_P(PSTR("t (2): ")); - bigint_print_hex(&t); - putchar('\n'); + bigint_reduce(&t, ctx->curve->n); bigint_mul_u(&t, &t, &s->s); - ctx->curve->reduce_p(&t); + bigint_reduce(&t, ctx->curve->n); if(t.length_W == 0){ printf_P(PSTR("DBG: XXX <%S %s %d>\n"), PSTR(__FILE__), __func__, __LINE__); return 2;