int BN_rshift1(BIGNUM *r, const BIGNUM *a)
	{
	BN_ULONG *ap,*rp,t,c;
	int i;

	bn_check_top(r);
	bn_check_top(a);

	if (BN_is_zero(a))
		{
		BN_zero(r);
		return(1);
		}
	if (a != r)
		{
		if (bn_wexpand(r,a->top) == NULL) return(0);
		r->top=a->top;
		r->neg=a->neg;
		}
	ap=a->d;
	rp=r->d;
	c=0;
	for (i=a->top-1; i>=0; i--)
		{
		t=ap[i];
		rp[i]=((t>>1)&BN_MASK2)|c;
		c=(t&1)?BN_TBIT:0;
		}
	bn_correct_top(r);
	bn_check_top(r);
	return(1);
	}