- BIGNUM *t1,*t2;
-
- t1=&(ctx->bn[ctx->tos]);
- t2=&(ctx->bn[ctx->tos+1]);
- ctx->tos+=2;
-
- if (!BN_copy(t1,a)) goto err;
- BN_mask_bits(t1,mont->ri);
-
- if (!BN_mul(t2,t1,&mont->Ni,ctx)) goto err;
- BN_mask_bits(t2,mont->ri);
-
- if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
- if (!BN_add(t2,a,t1)) goto err;
- BN_rshift(ret,t2,mont->ri);
-
- if (BN_ucmp(ret,&mont->N) >= 0)
- BN_usub(ret,ret,&mont->N);
- ctx->tos-=2;
- retn=1;