/* 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
return 2;
}
ecc_chudnovsky_to_affine_point(&q.affine, &q.chudnovsky, ctx->curve);
- bigint_inverse(&s->s, k, ctx->curve->p);
+ 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;
((uint8_t*)m_int.wordv)[idx++] = ((uint8_t*)hash)[--hash_len_B];
}
}
+ bigint_adjust(&m_int);
do{
if(rand_in == NULL){
size_t i;