summaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
authorBen Laurie <ben@openssl.org>2008-11-01 14:37:00 +0000
committerBen Laurie <ben@openssl.org>2008-11-01 14:37:00 +0000
commit4d6e1e4f29de455b5e644ea9cae5d5f5a2dbef33 (patch)
tree9b43a103ede688bfb7b006837387dacb02ec3dc5 /crypto/bn
parent122396f2dbeda0f25e9af1bb069a324ec793da57 (diff)
size_tification.
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/asm/x86_64-gcc.c2
-rw-r--r--crypto/bn/bn.h35
-rw-r--r--crypto/bn/bn_add.c6
-rw-r--r--crypto/bn/bn_div.c13
-rw-r--r--crypto/bn/bn_exp.c13
-rw-r--r--crypto/bn/bn_lcl.h28
-rw-r--r--crypto/bn/bn_lib.c12
-rw-r--r--crypto/bn/bn_mpi.c2
-rw-r--r--crypto/bn/bn_mul.c24
-rw-r--r--crypto/bn/bn_nist.c5
-rw-r--r--crypto/bn/bn_print.c4
-rw-r--r--crypto/bn/bn_rand.c9
-rw-r--r--crypto/bn/bn_recp.c2
-rw-r--r--crypto/bn/bn_word.c7
14 files changed, 91 insertions, 71 deletions
diff --git a/crypto/bn/asm/x86_64-gcc.c b/crypto/bn/asm/x86_64-gcc.c
index f13f52dd85..1509864574 100644
--- a/crypto/bn/asm/x86_64-gcc.c
+++ b/crypto/bn/asm/x86_64-gcc.c
@@ -175,7 +175,7 @@ BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d)
return ret;
}
-BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int n)
+BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp, size_t n)
{ BN_ULONG ret=0,i=0;
if (n <= 0) return 0;
diff --git a/crypto/bn/bn.h b/crypto/bn/bn.h
index 2333682a17..3a8d694bb6 100644
--- a/crypto/bn/bn.h
+++ b/crypto/bn/bn.h
@@ -300,9 +300,9 @@ typedef struct bn_gencb_st BN_GENCB;
struct bignum_st
{
BN_ULONG *d; /* Pointer to an array of 'BN_BITS2' bit chunks. */
- int top; /* Index of last used d +1. */
+ size_t top; /* Index of last used d +1. */
/* The next are internal book keeping for bn_expand. */
- int dmax; /* Size of the d array. */
+ size_t dmax; /* Size of the d array. */
int neg; /* one if the number is negative */
int flags;
};
@@ -414,8 +414,8 @@ void BN_CTX_free(BN_CTX *c);
void BN_CTX_start(BN_CTX *ctx);
BIGNUM *BN_CTX_get(BN_CTX *ctx);
void BN_CTX_end(BN_CTX *ctx);
-int BN_rand(BIGNUM *rnd, int bits, int top,int bottom);
-int BN_pseudo_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_rand(BIGNUM *rnd, size_t bits, int top,int bottom);
+int BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top,int bottom);
int BN_rand_range(BIGNUM *rnd, const BIGNUM *range);
int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range);
int BN_num_bits(const BIGNUM *a);
@@ -425,9 +425,9 @@ void BN_init(BIGNUM *);
void BN_clear_free(BIGNUM *a);
BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b);
void BN_swap(BIGNUM *a, BIGNUM *b);
-BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
+BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret);
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
-BIGNUM *BN_mpi2bn(const unsigned char *s,int len,BIGNUM *ret);
+BIGNUM *BN_mpi2bn(const unsigned char *s, size_t len, BIGNUM *ret);
int BN_bn2mpi(const BIGNUM *a, unsigned char *to);
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b);
@@ -466,6 +466,8 @@ BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w);
BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w);
int BN_mul_word(BIGNUM *a, BN_ULONG w);
int BN_add_word(BIGNUM *a, BN_ULONG w);
+/* Note that this will give an error if w is negative */
+int BN_add_signed_word(BIGNUM *a, BN_LONG w);
int BN_sub_word(BIGNUM *a, BN_ULONG w);
int BN_set_word(BIGNUM *a, BN_ULONG w);
BN_ULONG BN_get_word(const BIGNUM *a);
@@ -500,7 +502,7 @@ int BN_print(BIO *fp, const BIGNUM *a);
#else
int BN_print(void *fp, const BIGNUM *a);
#endif
-int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx);
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, size_t len, BN_CTX *ctx);
int BN_rshift(BIGNUM *r, const BIGNUM *a, int n);
int BN_rshift1(BIGNUM *r, const BIGNUM *a);
void BN_clear(BIGNUM *a);
@@ -664,9 +666,9 @@ const BIGNUM *BN_get0_nist_prime_521(void);
#define bn_expand(a,bits) ((((((bits+BN_BITS2-1))/BN_BITS2)) <= (a)->dmax)?\
(a):bn_expand2((a),(bits+BN_BITS2-1)/BN_BITS2))
#define bn_wexpand(a,words) (((words) <= (a)->dmax)?(a):bn_expand2((a),(words)))
-BIGNUM *bn_expand2(BIGNUM *a, int words);
+BIGNUM *bn_expand2(BIGNUM *a, size_t words);
#ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
+BIGNUM *bn_dup_expand(const BIGNUM *a, size_t words); /* unused */
#endif
/* Bignum consistency macros
@@ -762,12 +764,15 @@ int RAND_pseudo_bytes(unsigned char *buf,int num);
bn_pollute(a); \
}
-BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
-BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w);
-void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, int num);
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num,
+ BN_ULONG w);
+BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num, BN_ULONG w);
+void bn_sqr_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num);
BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d);
-BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
-BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,int num);
+BN_ULONG bn_add_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ size_t num);
+BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ size_t num);
/* Primes from RFC 2409 */
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
@@ -781,7 +786,7 @@ BIGNUM *get_rfc3526_prime_4096(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_6144(BIGNUM *bn);
BIGNUM *get_rfc3526_prime_8192(BIGNUM *bn);
-int BN_bntest_rand(BIGNUM *rnd, int bits, int top,int bottom);
+int BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom);
/* BEGIN ERROR CODES */
/* The following lines are auto generated by the script mkerr.pl. Any changes
diff --git a/crypto/bn/bn_add.c b/crypto/bn/bn_add.c
index 9405163706..fa27ff77b7 100644
--- a/crypto/bn/bn_add.c
+++ b/crypto/bn/bn_add.c
@@ -104,7 +104,7 @@ int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
/* unsigned add of b to a */
int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
- int max,min,dif;
+ size_t max,min,dif;
BN_ULONG *ap,*bp,*rp,carry,t1,t2;
const BIGNUM *tmp;
@@ -165,7 +165,7 @@ int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
/* unsigned subtraction of b from a, a must be larger than b. */
int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
- int max,min,dif;
+ size_t max,min,dif;
register BN_ULONG t1,t2,*ap,*bp,*rp;
int i,carry;
#if defined(IRIX_CC_BUG) && !defined(LINT)
@@ -262,7 +262,7 @@ int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b)
{
- int max;
+ size_t max;
int add=0,neg=0;
const BIGNUM *tmp;
diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c
index 6db472f8c3..68ff960aef 100644
--- a/crypto/bn/bn_div.c
+++ b/crypto/bn/bn_div.c
@@ -181,11 +181,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
BN_CTX *ctx)
{
- int norm_shift,i,loop;
+ int norm_shift,i;
+ size_t loop;
BIGNUM *tmp,wnum,*snum,*sdiv,*res;
BN_ULONG *resp,*wnump;
BN_ULONG d0,d1;
- int num_n,div_n;
+ size_t num_n,div_n;
/* Invalid zero-padding would have particularly bad consequences
* in the case of 'num', so don't just rely on bn_check_top() for this one
@@ -265,7 +266,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
resp= &(res->d[loop-1]);
/* space for temp */
- if (!bn_wexpand(tmp,(div_n+1))) goto err;
+ if (!bn_wexpand(tmp, div_n+1)) goto err;
if (BN_ucmp(&wnum,sdiv) >= 0)
{
@@ -429,7 +430,7 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
BIGNUM *tmp,wnum,*snum,*sdiv,*res;
BN_ULONG *resp,*wnump;
BN_ULONG d0,d1;
- int num_n,div_n;
+ size_t num_n,div_n;
bn_check_top(dv);
bn_check_top(rm);
@@ -498,12 +499,12 @@ static int BN_div_no_branch(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num,
/* Setup to 'res' */
res->neg= (num->neg^divisor->neg);
- if (!bn_wexpand(res,(loop+1))) goto err;
+ if (!bn_wexpand(res,loop+1U)) goto err;
res->top=loop-1;
resp= &(res->d[loop-1]);
/* space for temp */
- if (!bn_wexpand(tmp,(div_n+1))) goto err;
+ if (!bn_wexpand(tmp,div_n+1U)) goto err;
/* if res->top == 0 then clear the neg value otherwise decrease
* the resp pointer */
diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c
index 70a33f0d93..ac590e0f9d 100644
--- a/crypto/bn/bn_exp.c
+++ b/crypto/bn/bn_exp.c
@@ -521,7 +521,8 @@ err:
* as cache lines are concerned. The following functions are used to transfer a BIGNUM
* from/to that table. */
-static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
+static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, size_t top,
+ unsigned char *buf, int idx, int width)
{
size_t i, j;
@@ -541,7 +542,9 @@ static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf,
return 1;
}
-static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
+static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, size_t top,
+ unsigned char *buf, int idx,
+ int width)
{
size_t i, j;
@@ -572,14 +575,14 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont)
{
int i,bits,ret=0,idx,window,wvalue;
- int top;
+ size_t top;
BIGNUM *r;
const BIGNUM *aa;
BN_MONT_CTX *mont=NULL;
int numPowers;
unsigned char *powerbufFree=NULL;
- int powerbufLen = 0;
+ size_t powerbufLen = 0;
unsigned char *powerbuf=NULL;
BIGNUM *computeTemp=NULL, *am=NULL;
@@ -625,7 +628,7 @@ int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p,
*/
numPowers = 1 << window;
powerbufLen = sizeof(m->d[0])*top*numPowers;
- if ((powerbufFree=(unsigned char*)OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
+ if ((powerbufFree=OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
goto err;
powerbuf = MOD_EXP_CTIME_ALIGN(powerbufFree);
diff --git a/crypto/bn/bn_lcl.h b/crypto/bn/bn_lcl.h
index 8e5e98e3f2..857616d53b 100644
--- a/crypto/bn/bn_lcl.h
+++ b/crypto/bn/bn_lcl.h
@@ -113,6 +113,7 @@
#define HEADER_BN_LCL_H
#include <openssl/bn.h>
+#include <unistd.h>
#ifdef __cplusplus
extern "C" {
@@ -468,21 +469,22 @@ void bn_sqr_comba4(BN_ULONG *r,const BN_ULONG *a);
int bn_cmp_words(const BN_ULONG *a,const BN_ULONG *b,int n);
int bn_cmp_part_words(const BN_ULONG *a, const BN_ULONG *b,
int cl, int dl);
-void bn_mul_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
- int dna,int dnb,BN_ULONG *t);
-void bn_mul_part_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,
- int n,int tna,int tnb,BN_ULONG *t);
-void bn_sqr_recursive(BN_ULONG *r,const BN_ULONG *a, int n2, BN_ULONG *t);
-void bn_mul_low_normal(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b, int n);
-void bn_mul_low_recursive(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,int n2,
- BN_ULONG *t);
-void bn_mul_high(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b,BN_ULONG *l,int n2,
- BN_ULONG *t);
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
+ int dna, int dnb, BN_ULONG *t);
+void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b,
+ int n, int tna, int tnb, BN_ULONG *t);
+void bn_sqr_recursive(BN_ULONG *r, const BN_ULONG *a, int n2, BN_ULONG *t);
+void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n);
+void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
+ BN_ULONG *t);
+void bn_mul_high(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, BN_ULONG *l, int n2,
+ BN_ULONG *t);
BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
- int cl, int dl);
+ size_t cl, ssize_t dl);
BN_ULONG bn_sub_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
- int cl, int dl);
-int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np,const BN_ULONG *n0, int num);
+ int cl, int dl);
+int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
+ const BN_ULONG *np,const BN_ULONG *n0, int num);
#ifdef __cplusplus
}
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index 0c6e7e5964..f22d358ce5 100644
--- a/crypto/bn/bn_lib.c
+++ b/crypto/bn/bn_lib.c
@@ -315,7 +315,7 @@ BIGNUM *BN_new(void)
/* This is used both by bn_expand2() and bn_dup_expand() */
/* The caller MUST check that words > b->dmax before calling this */
-static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
+static BN_ULONG *bn_expand_internal(const BIGNUM *b, size_t words)
{
BN_ULONG *A,*a = NULL;
const BN_ULONG *B;
@@ -391,7 +391,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
*/
#ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
+BIGNUM *bn_dup_expand(const BIGNUM *b, size_t words)
{
BIGNUM *r = NULL;
@@ -442,7 +442,7 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
* It is mostly used by the various BIGNUM routines. If there is an error,
* NULL is returned. If not, 'b' is returned. */
-BIGNUM *bn_expand2(BIGNUM *b, int words)
+BIGNUM *bn_expand2(BIGNUM *b, size_t words)
{
bn_check_top(b);
@@ -594,7 +594,7 @@ int BN_set_word(BIGNUM *a, BN_ULONG w)
return(1);
}
-BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
+BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret)
{
unsigned int i,m;
unsigned int n;
@@ -614,7 +614,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
}
i=((n-1)/BN_BYTES)+1;
m=((n-1)%(BN_BYTES));
- if (bn_wexpand(ret, (int)i) == NULL)
+ if (bn_wexpand(ret, i) == NULL)
{
if (bn) BN_free(bn);
return NULL;
@@ -718,7 +718,7 @@ int BN_cmp(const BIGNUM *a, const BIGNUM *b)
int BN_set_bit(BIGNUM *a, int n)
{
- int i,j,k;
+ size_t i,j,k;
if (n < 0)
return 0;
diff --git a/crypto/bn/bn_mpi.c b/crypto/bn/bn_mpi.c
index a054d21aed..da2d2c479e 100644
--- a/crypto/bn/bn_mpi.c
+++ b/crypto/bn/bn_mpi.c
@@ -88,7 +88,7 @@ int BN_bn2mpi(const BIGNUM *a, unsigned char *d)
return(num+4+ext);
}
-BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
+BIGNUM *BN_mpi2bn(const unsigned char *d, size_t n, BIGNUM *a)
{
long len;
int neg=0;
diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c
index b848c8cc60..6938c88cb2 100644
--- a/crypto/bn/bn_mul.c
+++ b/crypto/bn/bn_mul.c
@@ -78,8 +78,8 @@
assembler counterparts for the systems that use assembler files. */
BN_ULONG bn_sub_part_words(BN_ULONG *r,
- const BN_ULONG *a, const BN_ULONG *b,
- int cl, int dl)
+ const BN_ULONG *a, const BN_ULONG *b,
+ size_t cl, ssize_t dl)
{
BN_ULONG c, t;
@@ -126,7 +126,7 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
}
else
{
- int save_dl = dl;
+ ssize_t save_dl = dl;
#ifdef BN_COUNT
fprintf(stderr, " bn_sub_part_words %d + %d (dl > 0, c = %d)\n", cl, dl, c);
#endif
@@ -205,8 +205,8 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
#endif
BN_ULONG bn_add_part_words(BN_ULONG *r,
- const BN_ULONG *a, const BN_ULONG *b,
- int cl, int dl)
+ const BN_ULONG *a, const BN_ULONG *b,
+ size_t cl, ssize_t dl)
{
BN_ULONG c, l, t;
@@ -222,7 +222,7 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
if (dl < 0)
{
- int save_dl = dl;
+ ssize_t save_dl = dl;
#ifdef BN_COUNT
fprintf(stderr, " bn_add_part_words %d + %d (dl < 0, c = %d)\n", cl, dl, c);
#endif
@@ -390,8 +390,8 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
* a[1]*b[1]
*/
/* dnX may not be positive, but n2/2+dnX has to be */
-void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
- int dna, int dnb, BN_ULONG *t)
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, size_t n2,
+ int dna, int dnb, BN_ULONG *t)
{
int n=n2/2,c1,c2;
int tna=n+dna, tnb=n+dnb;
@@ -505,16 +505,16 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
* r[32] holds (b[1]*b[1])
*/
- c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
+ c1=bn_add_words(t,r,&(r[n2]),n2);
if (neg) /* if t[32] is negative */
{
- c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
+ c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
}
else
{
/* Might have a carry */
- c1+=(int)(bn_add_words(&(t[n2]),&(t[n2]),t,n2));
+ c1+=bn_add_words(&(t[n2]),&(t[n2]),t,n2);
}
/* t[32] holds (a[0]-a[1])*(b[1]-b[0])+(a[0]*b[0])+(a[1]*b[1])
@@ -522,7 +522,7 @@ void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2,
* r[32] holds (b[1]*b[1])
* c1 holds the carry bits
*/
- c1+=(int)(bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2));
+ c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
if (c1)
{
p= &(r[n+n2]);
diff --git a/crypto/bn/bn_nist.c b/crypto/bn/bn_nist.c
index ea991c95b1..4d07a0d94e 100644
--- a/crypto/bn/bn_nist.c
+++ b/crypto/bn/bn_nist.c
@@ -415,7 +415,8 @@ int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
return 1;
}
-typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int);
+typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *, const BN_ULONG *, const BN_ULONG *,
+ size_t);
#define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \
{ \
@@ -429,7 +430,7 @@ typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int
}
int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *field,
- BN_CTX *ctx)
+ BN_CTX *ctx)
{
int top = a->top, i;
int carry;
diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c
index bebb466d08..521e8a3831 100644
--- a/crypto/bn/bn_print.c
+++ b/crypto/bn/bn_print.c
@@ -71,7 +71,7 @@ char *BN_bn2hex(const BIGNUM *a)
char *buf;
char *p;
- buf=(char *)OPENSSL_malloc(a->top*BN_BYTES*2+2);
+ buf=OPENSSL_malloc(a->top*BN_BYTES*2+2);
if (buf == NULL)
{
BNerr(BN_F_BN_BN2HEX,ERR_R_MALLOC_FAILURE);
@@ -116,7 +116,7 @@ char *BN_bn2dec(const BIGNUM *a)
i=BN_num_bits(a)*3;
num=(i/10+i/1000+1)+1;
bn_data=(BN_ULONG *)OPENSSL_malloc((num/BN_DEC_NUM+1)*sizeof(BN_ULONG));
- buf=(char *)OPENSSL_malloc(num+3);
+ buf=OPENSSL_malloc(num+3);
if ((buf == NULL) || (bn_data == NULL))
{
BNerr(BN_F_BN_BN2DEC,ERR_R_MALLOC_FAILURE);
diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c
index b376c28ff3..a58a77988c 100644
--- a/crypto/bn/bn_rand.c
+++ b/crypto/bn/bn_rand.c
@@ -208,18 +208,18 @@ err:
return(ret);
}
-int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int BN_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
{
return bnrand(0, rnd, bits, top, bottom);
}
-int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
{
return bnrand(1, rnd, bits, top, bottom);
}
#if 1
-int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
+int BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
{
return bnrand(2, rnd, bits, top, bottom);
}
@@ -229,7 +229,8 @@ int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
/* random number r: 0 <= r < range */
static int bn_rand_range(int pseudo, BIGNUM *r, const BIGNUM *range)
{
- int (*bn_rand)(BIGNUM *, int, int, int) = pseudo ? BN_pseudo_rand : BN_rand;
+ int (*bn_rand)(BIGNUM *, size_t, int, int)
+ = pseudo ? BN_pseudo_rand : BN_rand;
int n;
int count = 100;
diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c
index 2e8efb8dae..20ee319fe5 100644
--- a/crypto/bn/bn_recp.c
+++ b/crypto/bn/bn_recp.c
@@ -214,7 +214,7 @@ err:
* 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 BN_reciprocal(BIGNUM *r, const BIGNUM *m, size_t len, BN_CTX *ctx)
{
int ret= -1;
BIGNUM *t;
diff --git a/crypto/bn/bn_word.c b/crypto/bn/bn_word.c
index ee7b87c45c..d83032c66c 100644
--- a/crypto/bn/bn_word.c
+++ b/crypto/bn/bn_word.c
@@ -168,6 +168,13 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
return(1);
}
+int BN_add_signed_word(BIGNUM *a, BN_LONG w)
+ {
+ if(w < 0)
+ return 0;
+ return BN_add_word(a, (BN_ULONG)w);
+ }
+
int BN_sub_word(BIGNUM *a, BN_ULONG w)
{
int i;