MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / fxBigInt_mod_exp_LR

Function fxBigInt_mod_exp_LR

modules/crypt/arith/xsBigIntEx.c:369–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

367}
368
369txBigInt *fxBigInt_mod_exp_LR(txMachine *the, txBigInt *r, txBigInt *b, txBigInt *e, txBigInt *m)
370{
371 int i;
372 txBigInt *t, *t2 = NULL;
373 pool_t pool;
374
375 pool_init(&pool);
376 if (r == NULL)
377 r = fxBigInt_alloc(the, m->size);
378 t = pool_get(the, m->size, &pool);
379 t = mod_exp_init(the, t, m);
380 if (fxBigInt_ucomp(b, m) > 0) {
381 t2 = pool_get(the, m->size, &pool);
382 b = fxBigInt_mod(the, t2, b, m);
383 }
384 for (i = fxBigInt_bitsize(e); --i >= 0;) {
385 fxBigInt_mod_square(the, t, t, m, &pool);
386 if (fxBigInt_isset(e, i))
387 fxBigInt_mod_mul(the, t, t, b, m,&pool);
388 }
389 fxBigInt_copy(r, t);
390 pool_dispose(the, &pool);
391 return r;
392}
393
394/*
395 * Montgomery method

Callers 1

xs_mod2_expFunction · 0.85

Calls 12

pool_initFunction · 0.85
fxBigInt_allocFunction · 0.85
pool_getFunction · 0.85
mod_exp_initFunction · 0.85
fxBigInt_ucompFunction · 0.85
fxBigInt_modFunction · 0.85
fxBigInt_bitsizeFunction · 0.85
fxBigInt_mod_squareFunction · 0.85
fxBigInt_issetFunction · 0.85
fxBigInt_mod_mulFunction · 0.85
fxBigInt_copyFunction · 0.85
pool_disposeFunction · 0.85

Tested by

no test coverage detected