Ejemplo n.º 1
0
/*
 * TEE_BigIntInvMod
 */
void TEE_BigIntInvMod(TEE_BigInt *dest, const TEE_BigInt *op,
		      const TEE_BigInt *n)
{
	mpanum mpa_dest = (mpa_num_base *)dest;
	mpanum mpa_op = (mpa_num_base *)op;
	mpanum mpa_n = (mpa_num_base *)n;

	if (TEE_BigIntCmpS32(n, 2) < 0 || TEE_BigIntCmpS32(op, 0) == 0)
		TEE_BigInt_Panic("too small modulus or trying to invert zero");

	mpa_inv_mod(mpa_dest, mpa_op, mpa_n, mempool);
}
Ejemplo n.º 2
0
/* invmod */
static int invmod(void *a, void *b, void *c)
{
	LTC_ARGCHK(a != NULL);
	LTC_ARGCHK(b != NULL);
	LTC_ARGCHK(c != NULL);
	LTC_ARGCHK(b != c);
	mod(a, b, c);
	if (mpa_inv_mod((mpanum) c, (const mpanum) c, (const mpanum) b, external_mem_pool) != 0) {
		return CRYPT_ERROR;
	}

	return CRYPT_OK;
}