summaryrefslogtreecommitdiff
path: root/crypto/bn/bn_recp.c
diff options
context:
space:
mode:
authorBodo Möller <bodo@openssl.org>2000-11-26 16:42:38 +0000
committerBodo Möller <bodo@openssl.org>2000-11-26 16:42:38 +0000
commit78a0c1f18d5a1f0e51b7467ef7b153b8c29fbb03 (patch)
tree631b1606ee2f90a5fcaf2f141461113d30c7f5a8 /crypto/bn/bn_recp.c
parent6cc5e19d4710d7d3355bf6fa05c3d7269e48428f (diff)
downloadopenssl-new-78a0c1f18d5a1f0e51b7467ef7b153b8c29fbb03.tar.gz
modular arithmetics
"make update"
Diffstat (limited to 'crypto/bn/bn_recp.c')
-rw-r--r--crypto/bn/bn_recp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index a175e1c5f2..0700a0f063 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -167,7 +167,8 @@ int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
if (i != recp->shift)
recp->shift=BN_reciprocal(&(recp->Nr),&(recp->N),
- i,ctx);
+ i,ctx); /* BN_reciprocal returns i, or -1 for an error */
+ if (recp->shift == -1) goto err;
if (!BN_rshift(a,m,j)) goto err;
if (!BN_mul(b,a,&(recp->Nr),ctx)) goto err;
@@ -203,6 +204,7 @@ err:
* We actually calculate with an extra word of precision, so
* we can do faster division if the remainder is not required.
*/
+/* r := 2^len / m */
int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
{
int ret= -1;