/* div */ static int divide(void *a, void *b, void *c, void *d) { LTC_ARGCHK(a != NULL); LTC_ARGCHK(b != NULL); mpa_div(c, d, (const mpanum) a, (const mpanum) b, external_mem_pool); return CRYPT_OK; }
/*------------------------------------------------------------ * * mpa_mul_mod * */ void mpa_mul_mod(mpanum dest, const mpanum op1, const mpanum op2, const mpanum n, mpa_scratch_mem pool) { mpanum tmp_dest; mpa_alloc_static_temp_var(&tmp_dest, pool); mpa_mul(tmp_dest, op1, op2, pool); mpa_div(NULL, dest, tmp_dest, n, pool); mpa_free_static_temp_var(&tmp_dest, pool); }
/* * TEE_BigIntDiv */ void TEE_BigIntDiv(TEE_BigInt *dest_q, TEE_BigInt *dest_r, const TEE_BigInt *op1, const TEE_BigInt *op2) { mpanum mpa_dest_q = (mpa_num_base *)dest_q; mpanum mpa_dest_r = (mpa_num_base *)dest_r; mpanum mpa_op1 = (mpa_num_base *)op1; mpanum mpa_op2 = (mpa_num_base *)op2; if (TEE_BigIntCmpS32(op2, 0) == 0) TEE_BigInt_Panic("Divisor is zero"); mpa_div(mpa_dest_q, mpa_dest_r, mpa_op1, mpa_op2, mempool); }
/*------------------------------------------------------------ * * mpa_mod * */ void mpa_mod(mpanum dest, const mpanum op, const mpanum n, mpa_scratch_mem pool) { mpa_div(NULL, dest, op, n, pool); }