| 623 | */ |
| 624 | |
| 625 | static void ec_double(txMachine *the, txECPoint *r, txECPoint *a, txECParam *ec, pool_t *pool) |
| 626 | { |
| 627 | txBigInt *XX, *YY, *YYYY, *ZZ, *S, *M, *T, *Y3, *Z3; |
| 628 | txBigInt *t1, *t2; |
| 629 | txBigInt *m = ec->m; |
| 630 | |
| 631 | if (fxBigInt_iszero(a->z)) { |
| 632 | fxBigInt_copy(r->z, a->z); |
| 633 | return; |
| 634 | } |
| 635 | |
| 636 | t1 = pool_get(the, m->size, pool); |
| 637 | t2 = pool_get(the, m->size, pool); |
| 638 | XX = pool_get(the, m->size, pool); |
| 639 | YY = pool_get(the, m->size, pool); |
| 640 | YYYY = pool_get(the, m->size, pool); |
| 641 | ZZ = pool_get(the, m->size, pool); |
| 642 | S = pool_get(the, m->size, pool); |
| 643 | M = pool_get(the, m->size, pool); |
| 644 | T = pool_get(the, m->size, pool); |
| 645 | Y3 = pool_get(the, m->size, pool); |
| 646 | Z3 = pool_get(the, m->size, pool); |
| 647 | |
| 648 | XX = fxBigInt_mont_square(the, XX, a->x, m, ec->u, pool); |
| 649 | YY = fxBigInt_mont_square(the, YY, a->y, m, ec->u, pool); |
| 650 | YYYY = fxBigInt_mont_square(the, YYYY, YY, m, ec->u, pool); |
| 651 | ZZ = fxBigInt_mont_square(the, ZZ, a->z, m, ec->u, pool); |
| 652 | t1 = fxBigInt_mod_add(the, t1, a->x, YY, m, pool); |
| 653 | t1 = fxBigInt_mont_square(the, t1, t1, m, ec->u, pool); |
| 654 | t1 = fxBigInt_mod_sub(the, t1, t1, XX, m, pool); |
| 655 | t1 = fxBigInt_mod_sub(the, t1, t1, YYYY, m, pool); |
| 656 | S = fxBigInt_mod_dbl(the, S, t1, 1, m, pool); |
| 657 | t1 = fxBigInt_mod_dbl(the, t1, XX, 1, m, pool); |
| 658 | t1 = fxBigInt_mod_add(the, t1, t1, XX, m, pool); |
| 659 | t2 = fxBigInt_mont_square(the, t2, ZZ, m, ec->u, pool); |
| 660 | t2 = fxBigInt_mont_mul(the, t2, t2, ec->a, m, ec->u, pool); |
| 661 | M = fxBigInt_mod_add(the, M, t1, t2, m, pool); |
| 662 | t1 = fxBigInt_mont_square(the, t1, M, m, ec->u, pool); |
| 663 | t2 = fxBigInt_mod_dbl(the, t2, S, 1, m, pool); |
| 664 | T = fxBigInt_mod_sub(the, T, t1, t2, m, pool); |
| 665 | t1 = fxBigInt_mod_sub(the, t1, S, T, m, pool); |
| 666 | t1 = fxBigInt_mont_mul(the, t1, t1, M, m, ec->u, pool); |
| 667 | t2 = fxBigInt_mod_dbl(the, t2, YYYY, 3, m, pool); |
| 668 | Y3 = fxBigInt_mod_sub(the, Y3, t1, t2, m, pool); |
| 669 | t1 = fxBigInt_mod_add(the, t1, a->y, a->z, m, pool); |
| 670 | t1 = fxBigInt_mont_square(the, t1, t1, m, ec->u, pool); |
| 671 | t1 = fxBigInt_mod_sub(the, t1, t1, YY, m, pool); |
| 672 | Z3 = fxBigInt_mod_sub(the, Z3, t1, ZZ, m, pool); |
| 673 | |
| 674 | fxBigInt_copy(r->z, Z3); |
| 675 | fxBigInt_copy(r->y, Y3); |
| 676 | fxBigInt_copy(r->x, T); |
| 677 | |
| 678 | pool_put(Z3, m->size); |
| 679 | pool_put(Y3, m->size); |
| 680 | pool_put(T, m->size); |
| 681 | pool_put(M, m->size); |
| 682 | pool_put(S, m->size); |
no test coverage detected