| 460 | } |
| 461 | |
| 462 | static txBigInt *mont_mul(txMachine *the, txBigInt *r, txBigInt *a, txBigInt *b, txBigInt *m, txU4 u, pool_t *pool) |
| 463 | { |
| 464 | int i, n, sz; |
| 465 | txBigInt *t1, *t2, *t3; |
| 466 | |
| 467 | sz = MAX(b->size + 1, m->size + 1) + 1; |
| 468 | t1 = pool_get(the, sz, pool); |
| 469 | t2 = pool_get(the, sz, pool); |
| 470 | t3 = pool_get(the, sz + 1, pool); |
| 471 | t3->size = 1; |
| 472 | t3->data[0] = 0; |
| 473 | for (i = 0, n = m->size; i < n; i++) { |
| 474 | txU4 s = i < a->size ? a->data[i] : 0; |
| 475 | txU4 u1 = (t3->data[0] + s * b->data[0]) * u; |
| 476 | fxBigInt_umul1(the, t1, b, s); |
| 477 | fxBigInt_umul1(the, t2, m, u1); |
| 478 | fxBigInt_uadd(the, t1, t1, t2); |
| 479 | fxBigInt_uadd(the, t3, t3, t1); |
| 480 | fxBigInt_ulsr1(the, t3, t3, mxBigIntWordSize); |
| 481 | } |
| 482 | if (fxBigInt_ucomp(t3, m) >= 0) |
| 483 | fxBigInt_sub(the, t3, t3, m); |
| 484 | fxBigInt_copy(r, t3); |
| 485 | pool_put(t3, sz + 1); |
| 486 | pool_put(t2, sz); |
| 487 | pool_put(t1, sz); |
| 488 | return r; |
| 489 | } |
| 490 | |
| 491 | static txBigInt *mont_square(txMachine *the, txBigInt *r, txBigInt *a, txBigInt *m, txU4 u, pool_t *pool) |
| 492 | { |
no test coverage detected