diff --git a/demos/tv_gen.c b/demos/tv_gen.c index ab4df0f6..c39983bf 100644 --- a/demos/tv_gen.c +++ b/demos/tv_gen.c @@ -726,7 +726,7 @@ void ecc_gen(void) { FILE *out; unsigned char str[512]; - void *k, *order, *modulus; + void *k, *order, *modulus, *a; ecc_point *G, *R; int x; @@ -734,9 +734,9 @@ void ecc_gen(void) fprintf(out, "ecc vectors. These are for kG for k=1,3,9,27,...,3**n until k > order of the curve outputs are triplets\n\n"); G = ltc_ecc_new_point(); R = ltc_ecc_new_point(); - mp_init(&k); - mp_init(&order); - mp_init(&modulus); + if (mp_init_multi(&k, &order, &modulus, &a, NULL) != CRYPT_OK) { + return; + } for (x = 0; ltc_ecc_sets[x].size != 0; x++) { fprintf(out, "ECC-%d\n", ltc_ecc_sets[x].size*8); @@ -744,12 +744,13 @@ void ecc_gen(void) mp_read_radix(order, (char *)ltc_ecc_sets[x].order, 16); mp_read_radix(modulus, (char *)ltc_ecc_sets[x].prime, 16); + mp_read_radix(a, (char *)ltc_ecc_sets[x].A, 16); mp_read_radix(G->x, (char *)ltc_ecc_sets[x].Gx, 16); mp_read_radix(G->y, (char *)ltc_ecc_sets[x].Gy, 16); mp_set(G->z, 1); while (mp_cmp(k, order) == LTC_MP_LT) { - ltc_mp.ecc_ptmul(k, G, R, modulus, 1); + ltc_mp.ecc_ptmul(k, G, R, modulus, a, 1); mp_tohex(k, (char*)str); fprintf(out, "%s, ", (char*)str); mp_tohex(R->x, (char*)str); fprintf(out, "%s, ", (char*)str); mp_tohex(R->y, (char*)str); fprintf(out, "%s\n", (char*)str); diff --git a/testprof/ecc_test.c b/testprof/ecc_test.c index d623af3b..c4f6878b 100644 --- a/testprof/ecc_test.c +++ b/testprof/ecc_test.c @@ -32,12 +32,12 @@ static int sizes[] = { #ifdef LTC_ECC_SHAMIR int ecc_test_shamir(void) { - void *modulus, *mp, *kA, *kB, *rA, *rB; + void *modulus, *mp, *kA, *kB, *rA, *rB, *a; ecc_point *G, *A, *B, *C1, *C2; int x, y, z; unsigned char buf[ECC_BUF_SIZE]; - DO(mp_init_multi(&kA, &kB, &rA, &rB, &modulus, NULL)); + DO(mp_init_multi(&kA, &kB, &rA, &rB, &modulus, &a, NULL)); LTC_ARGCHK((G = ltc_ecc_new_point()) != NULL); LTC_ARGCHK((A = ltc_ecc_new_point()) != NULL); LTC_ARGCHK((B = ltc_ecc_new_point()) != NULL); @@ -56,6 +56,7 @@ int ecc_test_shamir(void) DO(mp_read_radix(G->y, ltc_ecc_sets[z].Gy, 16)); DO(mp_set(G->z, 1)); DO(mp_read_radix(modulus, ltc_ecc_sets[z].prime, 16)); + DO(mp_read_radix(a, ltc_ecc_sets[z].A, 16)); DO(mp_montgomery_setup(modulus, &mp)); /* do 100 random tests */ @@ -67,10 +68,10 @@ int ecc_test_shamir(void) DO(mp_read_unsigned_bin(rB, buf, sizes[x])); /* compute rA * G = A */ - DO(ltc_mp.ecc_ptmul(rA, G, A, modulus, 1)); + DO(ltc_mp.ecc_ptmul(rA, G, A, modulus, a, 1)); /* compute rB * G = B */ - DO(ltc_mp.ecc_ptmul(rB, G, B, modulus, 1)); + DO(ltc_mp.ecc_ptmul(rB, G, B, modulus, a, 1)); /* pick a random kA, kB */ LTC_ARGCHK(yarrow_read(buf, sizes[x], &yarrow_prng) == sizes[x]); @@ -79,13 +80,13 @@ int ecc_test_shamir(void) DO(mp_read_unsigned_bin(kB, buf, sizes[x])); /* now, compute kA*A + kB*B = C1 using the older method */ - DO(ltc_mp.ecc_ptmul(kA, A, C1, modulus, 0)); - DO(ltc_mp.ecc_ptmul(kB, B, C2, modulus, 0)); - DO(ltc_mp.ecc_ptadd(C1, C2, C1, modulus, mp)); + DO(ltc_mp.ecc_ptmul(kA, A, C1, modulus, a, 0)); + DO(ltc_mp.ecc_ptmul(kB, B, C2, modulus, a, 0)); + DO(ltc_mp.ecc_ptadd(C1, C2, C1, modulus, a, mp)); DO(ltc_mp.ecc_map(C1, modulus, mp)); /* now compute using mul2add */ - DO(ltc_mp.ecc_mul2add(A, kA, B, kB, C2, modulus)); + DO(ltc_mp.ecc_mul2add(A, kA, B, kB, C2, modulus, a)); /* is they the sames? */ if ((mp_cmp(C1->x, C2->x) != LTC_MP_EQ) || (mp_cmp(C1->y, C2->y) != LTC_MP_EQ) || (mp_cmp(C1->z, C2->z) != LTC_MP_EQ)) {