1 #include "testutils.h"
2
3 void
test_main(void)4 test_main (void)
5 {
6 unsigned i;
7
8 for (i = 0; ecc_curves[i]; i++)
9 {
10 const struct ecc_curve *ecc = ecc_curves[i];
11 mp_limb_t *g = xalloc_limbs (ecc_size_j (ecc));
12 mp_limb_t *p = xalloc_limbs (ecc_size_j (ecc));
13 mp_limb_t *scratch = xalloc_limbs (ECC_DUP_EH_ITCH(ecc->p.size));;
14
15 if (ecc->p.bit_size == 255)
16 {
17 mp_limb_t *z = xalloc_limbs (ecc_size_j (ecc));
18 /* Zero point has x = 0, y = 1, z = 1 */
19 mpn_zero (z, 3*ecc->p.size);
20 z[ecc->p.size] = z[2*ecc->p.size] = 1;
21
22 ecc_a_to_j (ecc, g, ecc->g);
23
24 ecc_dup_eh (ecc, p, z, scratch);
25 test_ecc_mul_h (i, 0, p);
26
27 ecc_dup_eh (ecc, p, g, scratch);
28 test_ecc_mul_h (i, 2, p);
29
30 ecc_dup_eh (ecc, p, p, scratch);
31 test_ecc_mul_h (i, 4, p);
32 free (z);
33 }
34 else
35 {
36 ecc_a_to_j (ecc, g, ecc->g);
37
38 ecc_dup_jj (ecc, p, g, scratch);
39 test_ecc_mul_h (i, 2, p);
40
41 ecc_dup_jj (ecc, p, p, scratch);
42 test_ecc_mul_h (i, 4, p);
43 }
44 free (p);
45 free (g);
46 free (scratch);
47 }
48 }
49