summaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/asm/x86_64-gcc.c3
-rw-r--r--crypto/bn/bn.h35
-rw-r--r--crypto/bn/bn_add.c6
-rw-r--r--crypto/bn/bn_asm.c10
-rw-r--r--crypto/bn/bn_div.c13
-rw-r--r--crypto/bn/bn_exp.c13
-rw-r--r--crypto/bn/bn_lcl.h31
-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
15 files changed, 77 insertions, 99 deletions
diff --git a/crypto/bn/asm/x86_64-gcc.c b/crypto/bn/asm/x86_64-gcc.c
index 9381ccf42a..f13f52dd85 100644
--- a/crypto/bn/asm/x86_64-gcc.c
+++ b/crypto/bn/asm/x86_64-gcc.c
@@ -1,7 +1,6 @@
#ifdef __SUNPRO_C
# include "../bn_asm.c" /* kind of dirty hack for Sun Studio */
#else
-#include <stddef.h>
/*
* x86_64 BIGNUM accelerator version 0.1, December 2002.
*
@@ -176,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, size_t n)
+BN_ULONG bn_add_words (BN_ULONG *rp, BN_ULONG *ap, BN_ULONG *bp,int 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 971e55053b..e484b7fc11 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. */
- size_t top; /* Index of last used d +1. */
+ int top; /* Index of last used d +1. */
/* The next are internal book keeping for bn_expand. */
- size_t dmax; /* Size of the d array. */
+ int 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, size_t bits, int top,int bottom);
-int BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top,int bottom);
+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_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, size_t len, BIGNUM *ret);
+BIGNUM *BN_bin2bn(const unsigned char *s,int len,BIGNUM *ret);
int BN_bn2bin(const BIGNUM *a, unsigned char *to);
-BIGNUM *BN_mpi2bn(const unsigned char *s, size_t len, BIGNUM *ret);
+BIGNUM *BN_mpi2bn(const unsigned char *s,int 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,8 +466,6 @@ 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);
@@ -502,7 +500,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, size_t len, BN_CTX *ctx);
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int 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);
@@ -666,9 +664,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, size_t words);
+BIGNUM *bn_expand2(BIGNUM *a, int words);
#ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *a, size_t words); /* unused */
+BIGNUM *bn_dup_expand(const BIGNUM *a, int words); /* unused */
#endif
/* Bignum consistency macros
@@ -764,15 +762,12 @@ 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, 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_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_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,
- size_t num);
-BN_ULONG bn_sub_words(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp,
- size_t num);
+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);
/* Primes from RFC 2409 */
BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
@@ -786,7 +781,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, size_t bits, int top, int bottom);
+int BN_bntest_rand(BIGNUM *rnd, int 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 fa27ff77b7..9405163706 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)
{
- size_t max,min,dif;
+ int 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)
{
- size_t max,min,dif;
+ int 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)
{
- size_t max;
+ int max;
int add=0,neg=0;
const BIGNUM *tmp;
diff --git a/crypto/bn/bn_asm.c b/crypto/bn/bn_asm.c
index 85b203d25d..dd00277e54 100644
--- a/crypto/bn/bn_asm.c
+++ b/crypto/bn/bn_asm.c
@@ -143,7 +143,7 @@ void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, size_t n)
#else /* !(defined(BN_LLONG) || defined(BN_UMULT_HIGH)) */
-BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num, BN_ULONG w)
+BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, int num, BN_ULONG w)
{
BN_ULONG c=0;
BN_ULONG bl,bh;
@@ -172,7 +172,7 @@ BN_ULONG bn_mul_add_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num, BN_ULONG
return(c);
}
-BN_ULONG bn_mul_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, int num, BN_ULONG w)
{
BN_ULONG carry=0;
BN_ULONG bl,bh;
@@ -201,7 +201,7 @@ BN_ULONG bn_mul_words(BN_ULONG *rp, const BN_ULONG *ap, size_t num, BN_ULONG w)
return(carry);
}
-void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, size_t n)
+void bn_sqr_words(BN_ULONG *r, const BN_ULONG *a, int n)
{
assert(n >= 0);
if (n <= 0) return;
@@ -338,7 +338,7 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, size_t
return((BN_ULONG)ll);
}
#else /* !BN_LLONG */
-BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, size_t n)
+BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
{
BN_ULONG c,l,t;
@@ -390,7 +390,7 @@ BN_ULONG bn_add_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, size_t
}
#endif /* !BN_LLONG */
-BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, size_t n)
+BN_ULONG bn_sub_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b, int n)
{
BN_ULONG t1,t2;
int c=0;
diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c
index 68ff960aef..6db472f8c3 100644
--- a/crypto/bn/bn_div.c
+++ b/crypto/bn/bn_div.c
@@ -181,12 +181,11 @@ 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;
- size_t loop;
+ int norm_shift,i,loop;
BIGNUM *tmp,wnum,*snum,*sdiv,*res;
BN_ULONG *resp,*wnump;
BN_ULONG d0,d1;
- size_t num_n,div_n;
+ int 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
@@ -266,7 +265,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)
{
@@ -430,7 +429,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;
- size_t num_n,div_n;
+ int num_n,div_n;
bn_check_top(dv);
bn_check_top(rm);
@@ -499,12 +498,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+1U)) goto err;
+ if (!bn_wexpand(res,(loop+1))) goto err;
res->top=loop-1;
resp= &(res->d[loop-1]);
/* space for temp */
- if (!bn_wexpand(tmp,div_n+1U)) goto err;
+ if (!bn_wexpand(tmp,(div_n+1))) 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 ac590e0f9d..70a33f0d93 100644
--- a/crypto/bn/bn_exp.c
+++ b/crypto/bn/bn_exp.c
@@ -521,8 +521,7 @@ 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, size_t top,
- unsigned char *buf, int idx, int width)
+static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
{
size_t i, j;
@@ -542,9 +541,7 @@ static int MOD_EXP_CTIME_COPY_TO_PREBUF(BIGNUM *b, size_t top,
return 1;
}
-static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, size_t top,
- unsigned char *buf, int idx,
- int width)
+static int MOD_EXP_CTIME_COPY_FROM_PREBUF(BIGNUM *b, int top, unsigned char *buf, int idx, int width)
{
size_t i, j;
@@ -575,14 +572,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;
- size_t top;
+ int top;
BIGNUM *r;
const BIGNUM *aa;
BN_MONT_CTX *mont=NULL;
int numPowers;
unsigned char *powerbufFree=NULL;
- size_t powerbufLen = 0;
+ int powerbufLen = 0;
unsigned char *powerbuf=NULL;
BIGNUM *computeTemp=NULL, *am=NULL;
@@ -628,7 +625,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=OPENSSL_malloc(powerbufLen+MOD_EXP_CTIME_MIN_CACHE_LINE_WIDTH)) == NULL)
+ if ((powerbufFree=(unsigned char*)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 05e8874a5a..8e5e98e3f2 100644
--- a/crypto/bn/bn_lcl.h
+++ b/crypto/bn/bn_lcl.h
@@ -113,7 +113,6 @@
#define HEADER_BN_LCL_H
#include <openssl/bn.h>
-#include <unistd.h>
#ifdef __cplusplus
extern "C" {
@@ -469,23 +468,21 @@ 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, 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);
+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);
BN_ULONG bn_add_part_words(BN_ULONG *r, const BN_ULONG *a, const BN_ULONG *b,
- size_t cl, ssize_t dl);
-BN_ULONG bn_sub_part_words(BN_ULONG *r,
- const BN_ULONG *a, const BN_ULONG *b,
- size_t cl, ssize_t 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);
+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);
#ifdef __cplusplus
}
diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c
index f22d358ce5..0c6e7e5964 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, size_t words)
+static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
{
BN_ULONG *A,*a = NULL;
const BN_ULONG *B;
@@ -391,7 +391,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, size_t words)
*/
#ifndef OPENSSL_NO_DEPRECATED
-BIGNUM *bn_dup_expand(const BIGNUM *b, size_t words)
+BIGNUM *bn_dup_expand(const BIGNUM *b, int words)
{
BIGNUM *r = NULL;
@@ -442,7 +442,7 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, size_t 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, size_t words)
+BIGNUM *bn_expand2(BIGNUM *b, int 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, size_t len, BIGNUM *ret)
+BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
{
unsigned int i,m;
unsigned int n;
@@ -614,7 +614,7 @@ BIGNUM *BN_bin2bn(const unsigned char *s, size_t len, BIGNUM *ret)
}
i=((n-1)/BN_BYTES)+1;
m=((n-1)%(BN_BYTES));
- if (bn_wexpand(ret, i) == NULL)
+ if (bn_wexpand(ret, (int)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)
{
- size_t i,j,k;
+ int i,j,k;
if (n < 0)
return 0;
diff --git a/crypto/bn/bn_mpi.c b/crypto/bn/bn_mpi.c
index da2d2c479e..a054d21aed 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, size_t n, BIGNUM *a)
+BIGNUM *BN_mpi2bn(const unsigned char *d, int n, BIGNUM *a)
{
long len;
int neg=0;
diff --git a/crypto/bn/bn_mul.c b/crypto/bn/bn_mul.c
index 6938c88cb2..b848c8cc60 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,
- size_t cl, ssize_t dl)
+ const BN_ULONG *a, const BN_ULONG *b,
+ int cl, int dl)
{
BN_ULONG c, t;
@@ -126,7 +126,7 @@ BN_ULONG bn_sub_part_words(BN_ULONG *r,
}
else
{
- ssize_t save_dl = dl;
+ int 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,
- size_t cl, ssize_t dl)
+ const BN_ULONG *a, const BN_ULONG *b,
+ int cl, int dl)
{
BN_ULONG c, l, t;
@@ -222,7 +222,7 @@ BN_ULONG bn_add_part_words(BN_ULONG *r,
if (dl < 0)
{
- ssize_t save_dl = dl;
+ int 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, size_t n2,
- int dna, int dnb, BN_ULONG *t)
+void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int 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, size_t n2,
* r[32] holds (b[1]*b[1])
*/
- c1=bn_add_words(t,r,&(r[n2]),n2);
+ c1=(int)(bn_add_words(t,r,&(r[n2]),n2));
if (neg) /* if t[32] is negative */
{
- c1-=bn_sub_words(&(t[n2]),t,&(t[n2]),n2);
+ c1-=(int)(bn_sub_words(&(t[n2]),t,&(t[n2]),n2));
}
else
{
/* Might have a carry */
- c1+=bn_add_words(&(t[n2]),&(t[n2]),t,n2);
+ c1+=(int)(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, size_t n2,
* r[32] holds (b[1]*b[1])
* c1 holds the carry bits
*/
- c1+=bn_add_words(&(r[n]),&(r[n]),&(t[n2]),n2);
+ c1+=(int)(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 4d07a0d94e..ea991c95b1 100644
--- a/crypto/bn/bn_nist.c
+++ b/crypto/bn/bn_nist.c
@@ -415,8 +415,7 @@ 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 *,
- size_t);
+typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *,const BN_ULONG *,const BN_ULONG *,int);
#define nist_set_224(to, from, a1, a2, a3, a4, a5, a6, a7) \
{ \
@@ -430,7 +429,7 @@ typedef BN_ULONG (*bn_addsub_f)(BN_ULONG *, const BN_ULONG *, const BN_ULONG *,
}
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 521e8a3831..bebb466d08 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=OPENSSL_malloc(a->top*BN_BYTES*2+2);
+ buf=(char *)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=OPENSSL_malloc(num+3);
+ buf=(char *)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 a58a77988c..b376c28ff3 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, size_t bits, int top, int bottom)
+int BN_rand(BIGNUM *rnd, int bits, int top, int bottom)
{
return bnrand(0, rnd, bits, top, bottom);
}
-int BN_pseudo_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
+int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom)
{
return bnrand(1, rnd, bits, top, bottom);
}
#if 1
-int BN_bntest_rand(BIGNUM *rnd, size_t bits, int top, int bottom)
+int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom)
{
return bnrand(2, rnd, bits, top, bottom);
}
@@ -229,8 +229,7 @@ int BN_bntest_rand(BIGNUM *rnd, size_t 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 *, size_t, int, int)
- = pseudo ? BN_pseudo_rand : BN_rand;
+ int (*bn_rand)(BIGNUM *, int, 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 20ee319fe5..2e8efb8dae 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, size_t len, BN_CTX *ctx)
+int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx)
{
int ret= -1;
BIGNUM *t;
diff --git a/crypto/bn/bn_word.c b/crypto/bn/bn_word.c
index d83032c66c..ee7b87c45c 100644
--- a/crypto/bn/bn_word.c
+++ b/crypto/bn/bn_word.c
@@ -168,13 +168,6 @@ 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;