summaryrefslogtreecommitdiff
path: root/crypto/bn/bn_recp.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2000-11-06 21:15:54 +0000
committerRichard Levitte <levitte@openssl.org>2000-11-06 21:15:54 +0000
commit020fc820dc90dbbcf0d7e3f3345af9e44cf905a7 (patch)
tree43557879bf9ba3fd467211edf75155c45a51fd6f /crypto/bn/bn_recp.c
parentbc8a9f1f0fa10e75a8a3610d870c37d742cb0eb7 (diff)
downloadopenssl-new-020fc820dc90dbbcf0d7e3f3345af9e44cf905a7.tar.gz
Constify the BIGNUM routines a bit more. The only trouble were the
two functions that did expansion on in parameters (BN_mul() and BN_sqr()). The problem was solved by making bn_dup_expand() which is a mix of bn_expand2() and BN_dup().
Diffstat (limited to 'crypto/bn/bn_recp.c')
-rw-r--r--crypto/bn/bn_recp.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index d019941d6b..a175e1c5f2 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -100,11 +100,12 @@ int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx)
return(1);
}
-int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
- BN_CTX *ctx)
+int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y,
+ BN_RECP_CTX *recp, BN_CTX *ctx)
{
int ret=0;
BIGNUM *a;
+ const BIGNUM *ca;
BN_CTX_start(ctx);
if ((a = BN_CTX_get(ctx)) == NULL) goto err;
@@ -114,19 +115,20 @@ int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp,
{ if (!BN_sqr(a,x,ctx)) goto err; }
else
{ if (!BN_mul(a,x,y,ctx)) goto err; }
+ ca = a;
}
else
- a=x; /* Just do the mod */
+ ca=x; /* Just do the mod */
- BN_div_recp(NULL,r,a,recp,ctx);
+ BN_div_recp(NULL,r,ca,recp,ctx);
ret=1;
err:
BN_CTX_end(ctx);
return(ret);
}
-int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp,
- BN_CTX *ctx)
+int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
+ BN_RECP_CTX *recp, BN_CTX *ctx)
{
int i,j,ret=0;
BIGNUM *a,*b,*d,*r;
@@ -201,7 +203,7 @@ err:
* We actually calculate with an extra word of precision, so
* we can do faster division if the remainder is not required.
*/
-int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx)
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
{
int ret= -1;
BIGNUM t;