bn_check_top(r);
int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)	{	BIGNUM *b, *c, *u, *v, *tmp;	int ret = 0;	BN_CTX_start(ctx);		b = BN_CTX_get(ctx);	c = BN_CTX_get(ctx);	u = BN_CTX_get(ctx);	v = BN_CTX_get(ctx);	if (v == NULL) goto err;	if (!BN_one(b)) goto err;	if (!BN_zero(c)) goto err;	if (!BN_GF2m_mod(u, a, p)) goto err;	if (!BN_copy(v, p)) goto err;	u->neg = 0; /* Need to set u->neg = 0 because BN_is_one(u) checks	             * the neg flag of the bignum.	             */	if (BN_is_zero(u)) goto err;	while (1)		{		while (!BN_is_odd(u))			{			if (!BN_rshift1(u, u)) goto err;			if (BN_is_odd(b))				{				if (!BN_GF2m_add(b, b, p)) goto err;				}			if (!BN_rshift1(b, b)) goto err;			}		if (BN_is_one(u)) break;		if (BN_num_bits(u) < BN_num_bits(v))			{			tmp = u; u = v; v = tmp;			tmp = b; b = c; c = tmp;			}				if (!BN_GF2m_add(u, u, v)) goto err;		if (!BN_GF2m_add(b, b, c)) goto err;		}	if (!BN_copy(r, b)) goto err;	ret = 1;  err:  	BN_CTX_end(ctx);	return ret;	}