/*
 * TEE_BigIntInitFMMContext
 */
void TEE_BigIntInitFMMContext(TEE_BigIntFMMContext *context,
			      uint32_t len, const TEE_BigInt *modulus)
{
	mpa_fmm_context mpa_context = (mpa_fmm_context_base *)context;
	mpanum mpa_modulus = (mpa_num_base *)modulus;

	mpa_init_static_fmm_context(mpa_context, (uint32_t)len);
	mpa_compute_fmm_context(mpa_modulus, mpa_context->r_ptr,
				mpa_context->r2_ptr, &mpa_context->n_inv,
				mempool);
}
示例#2
0
/* setup */
static int montgomery_setup(void *a, void **b)
{
	LTC_ARGCHK(a != NULL);
	LTC_ARGCHK(b != NULL);
	mpa_word_t len = mpa_fmm_context_size_in_U32(count_bits(a));
	*b = malloc(len * sizeof(mpa_word_t));
	if (*b == NULL) {
		return CRYPT_MEM;
	}
	mpa_fmm_context_base * b_tmp = (mpa_fmm_context_base *) *b;
	mpa_init_static_fmm_context(b_tmp, len);
	mpa_compute_fmm_context((const mpanum) a, b_tmp->r_ptr, b_tmp->r2_ptr, &(b_tmp->n_inv), external_mem_pool);
	return CRYPT_OK;
}