diff options
author | Ulf Möller <ulf@openssl.org> | 1999-04-19 21:31:43 +0000 |
---|---|---|
committer | Ulf Möller <ulf@openssl.org> | 1999-04-19 21:31:43 +0000 |
commit | 6b691a5c85ddc4e407e32781841fee5c029506cd (patch) | |
tree | 436f1127406e1cacfe83dfcbfff824d89c47d834 /crypto/bn | |
parent | 3edd7ed15de229230f74c79c3d71e7c9c674cf4f (diff) | |
download | openssl-6b691a5c85ddc4e407e32781841fee5c029506cd.tar.gz |
Change functions to ANSI C.
Diffstat (limited to 'crypto/bn')
33 files changed, 203 insertions, 588 deletions
diff --git a/crypto/bn/bn_add.c b/crypto/bn/bn_add.c index caea96f3b5..cd7d48d71e 100644 --- a/crypto/bn/bn_add.c +++ b/crypto/bn/bn_add.c @@ -61,10 +61,7 @@ #include "bn_lcl.h" /* r can == a or b */ -int BN_add(r, a, b) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; +int BN_add(BIGNUM *r, BIGNUM *a, BIGNUM *b) { BIGNUM *tmp; @@ -107,10 +104,7 @@ BIGNUM *b; } /* unsigned add of b to a, r must be large enough */ -int BN_uadd(r,a,b) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; +int BN_uadd(BIGNUM *r, BIGNUM *a, BIGNUM *b) { register int i; int max,min; @@ -170,10 +164,7 @@ BIGNUM *b; } /* unsigned subtraction of b from a, a must be larger than b. */ -int BN_usub(r, a, b) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; +int BN_usub(BIGNUM *r, BIGNUM *a, BIGNUM *b) { int max,min; register BN_ULONG t1,t2,*ap,*bp,*rp; @@ -264,10 +255,7 @@ BIGNUM *b; return(1); } -int BN_sub(r, a, b) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; +int BN_sub(BIGNUM *r, BIGNUM *a, BIGNUM *b) { int max; int add=0,neg=0; diff --git a/crypto/bn/bn_asm.c b/crypto/bn/bn_asm.c index cdf20efa4f..05ede3b250 100644 --- a/crypto/bn/bn_asm.c +++ b/crypto/bn/bn_asm.c @@ -62,10 +62,7 @@ #ifdef BN_LLONG -BN_ULONG bn_mul_add_words(rp,ap,num,w) -BN_ULONG *rp,*ap; -int num; -BN_ULONG w; +BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c1=0; @@ -89,10 +86,7 @@ BN_ULONG w; return(c1); } -BN_ULONG bn_mul_words(rp,ap,num,w) -BN_ULONG *rp,*ap; -int num; -BN_ULONG w; +BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c1=0; @@ -115,9 +109,7 @@ BN_ULONG w; return(c1); } -void bn_sqr_words(r,a,n) -BN_ULONG *r,*a; -int n; +void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) { bn_check_num(n); if (n <= 0) return; @@ -148,10 +140,7 @@ int n; #else -BN_ULONG bn_mul_add_words(rp,ap,num,w) -BN_ULONG *rp,*ap; -int num; -BN_ULONG w; +BN_ULONG bn_mul_add_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG c=0; BN_ULONG bl,bh; @@ -178,10 +167,7 @@ BN_ULONG w; return(c); } -BN_ULONG bn_mul_words(rp,ap,num,w) -BN_ULONG *rp,*ap; -int num; -BN_ULONG w; +BN_ULONG bn_mul_words(BN_ULONG *rp, BN_ULONG *ap, int num, BN_ULONG w) { BN_ULONG carry=0; BN_ULONG bl,bh; @@ -208,9 +194,7 @@ BN_ULONG w; return(carry); } -void bn_sqr_words(r,a,n) -BN_ULONG *r,*a; -int n; +void bn_sqr_words(BN_ULONG *r, BN_ULONG *a, int n) { bn_check_num(n); if (n <= 0) return; @@ -237,8 +221,7 @@ int n; #if defined(BN_LLONG) && defined(BN_DIV2W) -BN_ULONG bn_div_words(h,l,d) -BN_ULONG h,l,d; +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { return((BN_ULONG)(((((BN_ULLONG)h)<<BN_BITS2)|l)/(BN_ULLONG)d)); } @@ -247,8 +230,7 @@ BN_ULONG h,l,d; /* Divide h-l by d and return the result. */ /* I need to test this some more :-( */ -BN_ULONG bn_div_words(h,l,d) -BN_ULONG h,l,d; +BN_ULONG bn_div_words(BN_ULONG h, BN_ULONG l, BN_ULONG d) { BN_ULONG dh,dl,q,ret=0,th,tl,t; int i,count=2; @@ -318,9 +300,7 @@ BN_ULONG h,l,d; #endif #ifdef BN_LLONG -BN_ULONG bn_add_words(r,a,b,n) -BN_ULONG *r,*a,*b; -int n; +BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { BN_ULLONG ll=0; @@ -356,9 +336,7 @@ int n; return((BN_ULONG)ll); } #else -BN_ULONG bn_add_words(r,a,b,n) -BN_ULONG *r,*a,*b; -int n; +BN_ULONG bn_add_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { BN_ULONG c,l,t; @@ -408,9 +386,7 @@ int n; } #endif -BN_ULONG bn_sub_words(r,a,b,n) -BN_ULONG *r,*a,*b; -int n; +BN_ULONG bn_sub_words(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { BN_ULONG t1,t2; int c=0; @@ -510,8 +486,7 @@ int n; mul_add_c2((a)[i],(a)[j],c0,c1,c2) #endif -void bn_mul_comba8(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { #ifdef BN_LLONG BN_ULLONG t; @@ -620,8 +595,7 @@ BN_ULONG *r,*a,*b; r[15]=c1; } -void bn_mul_comba4(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { #ifdef BN_LLONG BN_ULLONG t; @@ -666,8 +640,7 @@ BN_ULONG *r,*a,*b; r[7]=c2; } -void bn_sqr_comba8(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a) { #ifdef BN_LLONG BN_ULLONG t,tt; @@ -748,8 +721,7 @@ BN_ULONG *r,*a; r[15]=c1; } -void bn_sqr_comba4(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a) { #ifdef BN_LLONG BN_ULLONG t,tt; @@ -791,23 +763,20 @@ BN_ULONG *r,*a; /* hmm... is it faster just to do a multiply? */ #undef bn_sqr_comba4 -void bn_sqr_comba4(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba4(BN_ULONG *r, BN_ULONG *a) { BN_ULONG t[8]; bn_sqr_normal(r,a,4,t); } #undef bn_sqr_comba8 -void bn_sqr_comba8(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba8(BN_ULONG *r, BN_ULONG *a) { BN_ULONG t[16]; bn_sqr_normal(r,a,8,t); } -void bn_mul_comba4(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba4(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { r[4]=bn_mul_words( &(r[0]),a,4,b[0]); r[5]=bn_mul_add_words(&(r[1]),a,4,b[1]); @@ -815,8 +784,7 @@ BN_ULONG *r,*a,*b; r[7]=bn_mul_add_words(&(r[3]),a,4,b[3]); } -void bn_mul_comba8(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba8(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { r[ 8]=bn_mul_words( &(r[0]),a,8,b[0]); r[ 9]=bn_mul_add_words(&(r[1]),a,8,b[1]); diff --git a/crypto/bn/bn_blind.c b/crypto/bn/bn_blind.c index e9b39430e1..1b1bb06046 100644 --- a/crypto/bn/bn_blind.c +++ b/crypto/bn/bn_blind.c @@ -60,10 +60,7 @@ #include "cryptlib.h" #include "bn_lcl.h" -BN_BLINDING *BN_BLINDING_new(A,Ai,mod) -BIGNUM *A; -BIGNUM *Ai; -BIGNUM *mod; +BN_BLINDING *BN_BLINDING_new(BIGNUM *A, BIGNUM *Ai, BIGNUM *mod) { BN_BLINDING *ret=NULL; @@ -87,8 +84,7 @@ err: return(NULL); } -void BN_BLINDING_free(r) -BN_BLINDING *r; +void BN_BLINDING_free(BN_BLINDING *r) { if(r == NULL) return; @@ -98,9 +94,7 @@ BN_BLINDING *r; Free(r); } -int BN_BLINDING_update(b,ctx) -BN_BLINDING *b; -BN_CTX *ctx; +int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx) { int ret=0; @@ -118,10 +112,7 @@ err: return(ret); } -int BN_BLINDING_convert(n,b,ctx) -BIGNUM *n; -BN_BLINDING *b; -BN_CTX *ctx; +int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { bn_check_top(n); @@ -133,10 +124,7 @@ BN_CTX *ctx; return(BN_mod_mul(n,n,b->A,b->mod,ctx)); } -int BN_BLINDING_invert(n,b,ctx) -BIGNUM *n; -BN_BLINDING *b; -BN_CTX *ctx; +int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx) { int ret; diff --git a/crypto/bn/bn_comba.c b/crypto/bn/bn_comba.c index 30357cf5fb..7ad09b4a6d 100644 --- a/crypto/bn/bn_comba.c +++ b/crypto/bn/bn_comba.c @@ -70,8 +70,7 @@ void bn_mul_comba44(BN_ULONG *r,BN_ULONG *a,BN_ULONG *b); void bn_sqr_comba88(BN_ULONG *r,BN_ULONG *a); void bn_sqr_comba44(BN_ULONG *r,BN_ULONG *a); -void bn_mul_comba88(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba88(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { #ifdef BN_LLONG BN_ULLONG t; @@ -180,8 +179,7 @@ BN_ULONG *r,*a,*b; r[15]=c1; } -void bn_mul_comba44(r,a,b) -BN_ULONG *r,*a,*b; +void bn_mul_comba44(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b) { #ifdef BN_LLONG BN_ULLONG t; @@ -226,8 +224,7 @@ BN_ULONG *r,*a,*b; r[7]=c2; } -void bn_sqr_comba88(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba88(BN_ULONG *r, BN_ULONG *a) { #ifdef BN_LLONG BN_ULLONG t,tt; @@ -308,8 +305,7 @@ BN_ULONG *r,*a; r[15]=c1; } -void bn_sqr_comba44(r,a) -BN_ULONG *r,*a; +void bn_sqr_comba44(BN_ULONG *r, BN_ULONG *a) { #ifdef BN_LLONG BN_ULLONG t,tt; diff --git a/crypto/bn/bn_div.c b/crypto/bn/bn_div.c index c7bc04d0b4..bffa9f3e61 100644 --- a/crypto/bn/bn_div.c +++ b/crypto/bn/bn_div.c @@ -62,12 +62,7 @@ /* The old slow way */ #if 0 -int BN_div(dv, rem, m, d,ctx) -BIGNUM *dv; -BIGNUM *rem; -BIGNUM *m; -BIGNUM *d; -BN_CTX *ctx; +int BN_div(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx) { int i,nm,nd; BIGNUM *D; @@ -122,12 +117,8 @@ BN_CTX *ctx; #else -int BN_div(dv, rm, num, divisor,ctx) -BIGNUM *dv; -BIGNUM *rm; -BIGNUM *num; -BIGNUM *divisor; -BN_CTX *ctx; +int BN_div(BIGNUM *dv, BIGNUM *rm, BIGNUM *num, BIGNUM *divisor, + BN_CTX *ctx) { int norm_shift,i,j,loop; BIGNUM *tmp,wnum,*snum,*sdiv,*res; @@ -292,11 +283,7 @@ err: #endif /* rem != m */ -int BN_mod(rem, m, d,ctx) -BIGNUM *rem; -BIGNUM *m; -BIGNUM *d; -BN_CTX *ctx; +int BN_mod(BIGNUM *rem, BIGNUM *m, BIGNUM *d, BN_CTX *ctx) { #if 0 /* The old slow way */ int i,nm,nd; diff --git a/crypto/bn/bn_err.c b/crypto/bn/bn_err.c index 626502a0e3..2041b018ea 100644 --- a/crypto/bn/bn_err.c +++ b/crypto/bn/bn_err.c @@ -98,7 +98,7 @@ static ERR_STRING_DATA BN_str_reasons[]= #endif -void ERR_load_BN_strings() +void ERR_load_BN_strings(void) { static int init=1; diff --git a/crypto/bn/bn_exp.c b/crypto/bn/bn_exp.c index cc4528247e..9833037384 100644 --- a/crypto/bn/bn_exp.c +++ b/crypto/bn/bn_exp.c @@ -63,12 +63,7 @@ #define TABLE_SIZE 16 /* slow but works */ -int BN_mod_mul(ret, a, b, m, ctx) -BIGNUM *ret; -BIGNUM *a; -BIGNUM *b; -BIGNUM *m; -BN_CTX *ctx; +int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, BIGNUM *m, BN_CTX *ctx) { BIGNUM *t; int r=0; @@ -91,9 +86,7 @@ err: #if 0 /* this one works - simple but works */ -int BN_mod_exp(r,a,p,m,ctx) -BIGNUM *r,*a,*p,*m; -BN_CTX *ctx; +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx) { int i,bits,ret=0; BIGNUM *v,*tmp; @@ -127,9 +120,7 @@ err: #endif /* this one works - simple but works */ -int BN_exp(r,a,p,ctx) -BIGNUM *r,*a,*p; -BN_CTX *ctx; +int BN_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BN_CTX *ctx) { int i,bits,ret=0,tos; BIGNUM *v,*rr; @@ -163,12 +154,7 @@ err: return(ret); } -int BN_mod_exp(r,a,p,m,ctx) -BIGNUM *r; -BIGNUM *a; -BIGNUM *p; -BIGNUM *m; -BN_CTX *ctx; +int BN_mod_exp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx) { int ret; @@ -197,12 +183,7 @@ BN_CTX *ctx; } /* #ifdef RECP_MUL_MOD */ -int BN_mod_exp_recp(r,a,p,m,ctx) -BIGNUM *r; -BIGNUM *a; -BIGNUM *p; -BIGNUM *m; -BN_CTX *ctx; +int BN_mod_exp_recp(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx) { int i,j,bits,ret=0,wstart,wend,window,wvalue; int start=1,ts=0; @@ -315,13 +296,8 @@ err: /* #endif */ /* #ifdef MONT_MUL_MOD */ -int BN_mod_exp_mont(rr,a,p,m,ctx,in_mont) -BIGNUM *rr; -BIGNUM *a; -BIGNUM *p; -BIGNUM *m; -BN_CTX *ctx; -BN_MONT_CTX *in_mont; +int BN_mod_exp_mont(BIGNUM *rr, BIGNUM *a, BIGNUM *p, BIGNUM *m, BN_CTX *ctx, + BN_MONT_CTX *in_mont) { int i,j,bits,ret=0,wstart,wend,window,wvalue; int start=1,ts=0; @@ -461,12 +437,8 @@ err: /* #endif */ /* The old fallback, simple version :-) */ -int BN_mod_exp_simple(r,a,p,m,ctx) -BIGNUM *r; -BIGNUM *a; -BIGNUM *p; -BIGNUM *m; -BN_CTX *ctx; +int BN_mod_exp_simple(BIGNUM *r, BIGNUM *a, BIGNUM *p, BIGNUM *m, + BN_CTX *ctx) { int i,j,bits,ret=0,wstart,wend,window,wvalue,ts=0; int start=1; diff --git a/crypto/bn/bn_exp2.c b/crypto/bn/bn_exp2.c index eface739b3..1132d53365 100644 --- a/crypto/bn/bn_exp2.c +++ b/crypto/bn/bn_exp2.c @@ -15,15 +15,8 @@ #define EXP2_TABLE_BITS 2 /* 1 2 3 4 5 */ #define EXP2_TABLE_SIZE 4 /* 2 4 8 16 32 */ -int BN_mod_exp2_mont(rr,a1,p1,a2,p2,m,ctx,in_mont) -BIGNUM *rr; -BIGNUM *a1; -BIGNUM *p1; -BIGNUM *a2; -BIGNUM *p2; -BIGNUM *m; -BN_CTX *ctx; -BN_MONT_CTX *in_mont; +int BN_mod_exp2_mont(BIGNUM *rr, BIGNUM *a1, BIGNUM *p1, BIGNUM *a2, + BIGNUM *p2, BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *in_mont) { int i,j,k,bits,bits1,bits2,ret=0,wstart,wend,window,xvalue,yvalue; int start=1,ts=0,x,y; diff --git a/crypto/bn/bn_gcd.c b/crypto/bn/bn_gcd.c index c80cecdc8d..833d2a8e40 100644 --- a/crypto/bn/bn_gcd.c +++ b/crypto/bn/bn_gcd.c @@ -66,9 +66,7 @@ static BIGNUM *euclid(BIGNUM *a, BIGNUM *b); static BIGNUM *euclid(); #endif -int BN_gcd(r,in_a,in_b,ctx) -BIGNUM *r,*in_a,*in_b; -BN_CTX *ctx; +int BN_gcd(BIGNUM *r, BIGNUM *in_a, BIGNUM *in_b, BN_CTX *ctx) { BIGNUM *a,*b,*t; int ret=0; @@ -92,8 +90,7 @@ err: return(ret); } -static BIGNUM *euclid(a,b) -BIGNUM *a,*b; +static BIGNUM *euclid(BIGNUM *a, BIGNUM *b) { BIGNUM *t; int shifts=0; @@ -148,11 +145,7 @@ err: } /* solves ax == 1 (mod n) */ -BIGNUM *BN_mod_inverse(in, a, n, ctx) -BIGNUM *in; -BIGNUM *a; -BIGNUM *n; -BN_CTX *ctx; +BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, BIGNUM *n, BN_CTX *ctx) { BIGNUM *A,*B,*X,*Y,*M,*D,*R; BIGNUM *T,*ret=NULL; diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index ed5a76d027..00693bc5c3 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -80,8 +80,7 @@ int bn_limit_num_high=8; /* (1<<bn_limit_bits_high) */ int bn_limit_bits_mont=0; int bn_limit_num_mont=8; /* (1<<bn_limit_bits_mont) */ -void BN_set_params(mult,high,low,mont) -int mult,high,low,mont; +void BN_set_params(int mult, int high, int low, int mont) { if (mult >= 0) { @@ -113,8 +112,7 @@ int mult,high,low,mont; } } -int BN_get_params(which) -int which; +int BN_get_params(int which) { if (which == 0) return(bn_limit_bits); else if (which == 1) return(bn_limit_bits_high); @@ -123,7 +121,7 @@ int which; else return(0); } -BIGNUM *BN_value_one() +BIGNUM *BN_value_one(void) { static BN_ULONG data_one=1L; static BIGNUM const_one={&data_one,1,1,0}; @@ -131,7 +129,7 @@ BIGNUM *BN_value_one() return(&const_one); } -char *BN_options() +char *BN_options(void) { static int init=0; static char data[16]; @@ -150,8 +148,7 @@ char *BN_options() return(data); } -int BN_num_bits_word(l) -BN_ULONG l; +int BN_num_bits_word(BN_ULONG l) { static char bits[256]={ 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4, @@ -238,8 +235,7 @@ BN_ULONG l; } } -int BN_num_bits(a) -BIGNUM *a; +int BN_num_bits(BIGNUM *a) { BN_ULONG l; int i; @@ -259,8 +255,7 @@ BIGNUM *a; return(i+BN_num_bits_word(l)); } -void BN_clear_free(a) -BIGNUM *a; +void BN_clear_free(BIGNUM *a) { int i; @@ -277,8 +272,7 @@ BIGNUM *a; Free(a); } -void BN_free(a) -BIGNUM *a; +void BN_free(BIGNUM *a) { if (a == NULL) return; if ((a->d != NULL) && !(BN_get_flags(a,BN_FLG_STATIC_DATA))) @@ -288,13 +282,12 @@ BIGNUM *a; Free(a); } -void BN_init(a) -BIGNUM *a; +void BN_init(BIGNUM *a) { memset(a,0,sizeof(BIGNUM)); } -BIGNUM *BN_new() +BIGNUM *BN_new(void) { BIGNUM *ret; @@ -312,7 +305,7 @@ BIGNUM *BN_new() } -BN_CTX *BN_CTX_new() +BN_CTX *BN_CTX_new(void) { BN_CTX *ret; @@ -328,16 +321,14 @@ BN_CTX *BN_CTX_new() return(ret); } -void BN_CTX_init(ctx) -BN_CTX *ctx; +void BN_CTX_init(BN_CTX *ctx) { memset(ctx,0,sizeof(BN_CTX)); ctx->tos=0; ctx->flags=0; } -void BN_CTX_free(c) -BN_CTX *c; +void BN_CTX_free(BN_CTX *c) { int i; @@ -350,9 +341,7 @@ BN_CTX *c; Free(c); } -BIGNUM *bn_expand2(b, words) -BIGNUM *b; -int words; +BIGNUM *bn_expand2(BIGNUM *b, int words) { BN_ULONG *A,*B,*a; int i,j; @@ -451,8 +440,7 @@ memset(A,0x5c,sizeof(BN_ULONG)*(words+1)); return(b); } -BIGNUM *BN_dup(a) -BIGNUM *a; +BIGNUM *BN_dup(BIGNUM *a) { BIGNUM *r; @@ -463,9 +451,7 @@ BIGNUM *a; return((BIGNUM *)BN_copy(r,a)); } -BIGNUM *BN_copy(a, b) -BIGNUM *a; -BIGNUM *b; +BIGNUM *BN_copy(BIGNUM *a, BIGNUM *b) { int i; BN_ULONG *A,*B; @@ -532,8 +518,7 @@ BIGNUM *b; return(a); } -void BN_clear(a) -BIGNUM *a; +void BN_clear(BIGNUM *a) { if (a->d != NULL) memset(a->d,0,a->max*sizeof(a->d[0])); @@ -541,8 +526,7 @@ BIGNUM *a; a->neg=0; } -BN_ULONG BN_get_word(a) -BIGNUM *a; +BN_ULONG BN_get_word(BIGNUM *a) { int i,n; BN_ULONG ret=0; @@ -561,9 +545,7 @@ BIGNUM *a; return(ret); } -int BN_set_word(a,w) -BIGNUM *a; -BN_ULONG w; +int BN_set_word(BIGNUM *a, BN_ULONG w) { int i,n; if (bn_expand(a,sizeof(BN_ULONG)*8) == NULL) return(0); @@ -589,10 +571,7 @@ BN_ULONG w; } /* ignore negative */ -BIGNUM *BN_bin2bn(s, len, ret) -unsigned char *s; -int len; -BIGNUM *ret; +BIGNUM *BN_bin2bn(unsigned char *s, int len, BIGNUM *ret) { unsigned int i,m; unsigned int n; @@ -629,9 +608,7 @@ BIGNUM *ret; } /* ignore negative */ -int BN_bn2bin(a, to) -BIGNUM *a; -unsigned char *to; +int BN_bn2bin(BIGNUM *a, unsigned char *to) { int n,i; BN_ULONG l; @@ -645,9 +622,7 @@ unsigned char *to; return(n); } -int BN_ucmp(a, b) -BIGNUM *a; -BIGNUM *b; +int BN_ucmp(BIGNUM *a, BIGNUM *b) { int i; BN_ULONG t1,t2,*ap,*bp; @@ -669,9 +644,7 @@ BIGNUM *b; return(0); } -int BN_cmp(a, b) -BIGNUM *a; -BIGNUM *b; +int BN_cmp(BIGNUM *a, BIGNUM *b) { int i; int gt,lt; @@ -712,9 +685,7 @@ BIGNUM *b; return(0); } -int BN_set_bit(a, n) -BIGNUM *a; -int n; +int BN_set_bit(BIGNUM *a, int n) { int i,j,k; @@ -732,9 +703,7 @@ int n; return(1); } -int BN_clear_bit(a, n) -BIGNUM *a; -int n; +int BN_clear_bit(BIGNUM *a, int n) { int i,j; @@ -747,9 +716,7 @@ int n; return(1); } -int BN_is_bit_set(a, n) -BIGNUM *a; -int n; +int BN_is_bit_set(BIGNUM *a, int n) { int i,j; @@ -760,9 +727,7 @@ int n; return((a->d[i]&(((BN_ULONG)1)<<j))?1:0); } -int BN_mask_bits(a,n) -BIGNUM *a; -int n; +int BN_mask_bits(BIGNUM *a, int n) { int b,w; @@ -780,9 +745,7 @@ int n; return(1); } -int bn_cmp_words(a,b,n) -BN_ULONG *a,*b; -int n; +int bn_cmp_words(BN_ULONG *a, BN_ULONG *b, int n) { int i; BN_ULONG aa,bb; diff --git a/crypto/bn/bn_m.c b/crypto/bn/bn_m.c index 5166daaeec..555514074c 100644 --- a/crypto/bn/bn_m.c +++ b/crypto/bn/bn_m.c @@ -70,8 +70,7 @@ typedef struct bn_pool_st STACK *sk; } BN_POOL; -BIGNUM *BN_POOL_push(bp) -BN_POOL *bp; +BIGNUM *BN_POOL_push(BN_POOL *bp) { BIGNUM *ret; @@ -90,15 +89,12 @@ BN_POOL *bp; return(ret); } -void BN_POOL_pop(bp,num) -BN_POOL *bp; -int num; +void BN_POOL_pop(BN_POOL *bp, int num) { bp->used-=num; } -int BN_m(r,a,b) -BIGNUM *r,*a,*b; +int BN_m(BIGNUM *r, BIGNUM *a, BIGNUM *b) { static BN_POOL bp; static init=1; @@ -114,9 +110,7 @@ BIGNUM *r,*a,*b; } /* r must be different to a and b */ -int BN_mm(m, A, B, bp) -BIGNUM *m,*A,*B; -BN_POOL *bp; +int BN_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BN_POOL *bp) { int i,num; int an,bn; diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 4ed433e05c..5bdac17e6c 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -68,10 +68,8 @@ #define MONT_WORD -int BN_mod_mul_montgomery(r,a,b,mont,ctx) -BIGNUM *r,*a,*b; -BN_MONT_CTX *mont; -BN_CTX *ctx; +int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont, + BN_CTX *ctx) { BIGNUM *tmp,*tmp2; @@ -107,11 +105,8 @@ err: return(0); } -int BN_from_montgomery(ret,a,mont,ctx) -BIGNUM *ret; -BIGNUM *a; -BN_MONT_CTX *mont; -BN_CTX *ctx; +int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont, + BN_CTX *ctx) { #ifdef BN_RECURSION_MONT if (mont->use_word) @@ -269,7 +264,7 @@ printf("number BN_from_montgomery\n"); #endif } -BN_MONT_CTX *BN_MONT_CTX_new() +BN_MONT_CTX *BN_MONT_CTX_new(void) { BN_MONT_CTX *ret; @@ -281,8 +276,7 @@ BN_MONT_CTX *BN_MONT_CTX_new() return(ret); } -void BN_MONT_CTX_init(ctx) -BN_MONT_CTX *ctx; +void BN_MONT_CTX_init(BN_MONT_CTX *ctx) { ctx->use_word=0; ctx->ri=0; @@ -292,8 +286,7 @@ BN_MONT_CTX *ctx; ctx->flags=0; } -void BN_MONT_CTX_free(mont) -BN_MONT_CTX *mont; +void BN_MONT_CTX_free(BN_MONT_CTX *mont) { if(mont == NULL) return; @@ -305,10 +298,7 @@ BN_MONT_CTX *mont; Free(mont); } -int BN_MONT_CTX_set(mont,mod,ctx) -BN_MONT_CTX *mont; -BIGNUM *mod; -BN_CTX *ctx; +int BN_MONT_CTX_set(BN_MONT_CTX *mont, BIGNUM *mod, BN_CTX *ctx) { BIGNUM Ri,*R; @@ -402,8 +392,7 @@ err: return(0); } -BN_MONT_CTX *BN_MONT_CTX_copy(to, from) -BN_MONT_CTX *to, *from; +BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from) { if (to == from) return(to); diff --git a/crypto/bn/bn_mpi.c b/crypto/bn/bn_mpi.c index 84b0317081..5d786d7b15 100644 --- a/crypto/bn/bn_mpi.c +++ b/crypto/bn/bn_mpi.c @@ -60,9 +60,7 @@ #include "cryptlib.h" #include "bn_lcl.h" -int BN_bn2mpi(a,d) -BIGNUM *a; -unsigned char *d; +int BN_bn2mpi(BIGNUM *a, unsigned char *d) { int bits; int num=0; @@ -90,10 +88,7 @@ unsigned char *d; return(num+4+ext); } -BIGNUM *BN_mpi2bn(d,n,a) -unsigned char *d; -int n; -BIGNUM *a; +BIGNUM *BN_mpi2bn(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 0af6e96d7a..4b19c9f043 100644 --- a/crypto/bn/bn_mul.c +++ b/crypto/bn/bn_mul.c @@ -71,10 +71,8 @@ * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ -void bn_mul_recursive(r,a,b,n2,t) -BN_ULONG *r,*a,*b; -int n2; -BN_ULONG *t; +void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, + BN_ULONG *t) { int n=n2/2,c1,c2; unsigned int neg,zero; @@ -217,10 +215,8 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2); /* n+tn is the word length * t needs to be n*4 is size, as does r */ -void bn_mul_part_recursive(r,a,b,tn,n,t) -BN_ULONG *r,*a,*b; -int tn,n; -BN_ULONG *t; +void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn, + int n, BN_ULONG *t) { int i,j,n2=n*2; unsigned int c1; @@ -344,10 +340,8 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); /* a and b must be the same size, which is n2. * r needs to be n2 words and t needs to be n2*2 */ -void bn_mul_low_recursive(r,a,b,n2,t) -BN_ULONG *r,*a,*b; -int n2; -BN_ULONG *t; +void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, + BN_ULONG *t) { int n=n2/2; @@ -377,10 +371,8 @@ printf(" bn_mul_low_recursive %d * %d\n",n2,n2); * l is the low words of the output. * t needs to be n2*3 */ -void bn_mul_high(r,a,b,l,n2,t) -BN_ULONG *r,*a,*b,*l; -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) { int i,n; int c1,c2; @@ -565,9 +557,7 @@ printf(" bn_mul_high %d * %d\n",n2,n2); } #endif -int BN_mul(r,a,b,ctx) -BIGNUM *r,*a,*b; -BN_CTX *ctx; +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { int top,al,bl; BIGNUM *rr; @@ -706,11 +696,7 @@ end: return(1); } -void bn_mul_normal(r,a,na,b,nb) -BN_ULONG *r,*a; -int na; -BN_ULONG *b; -int nb; +void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) { BN_ULONG *rr; @@ -746,9 +732,7 @@ printf(" bn_mul_normal %d * %d\n",na,nb); } } -void bn_mul_low_normal(r,a,b,n) -BN_ULONG *r,*a,*b; -int n; +void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { #ifdef BN_COUNT printf(" bn_mul_low_normal %d * %d\n",n,n); diff --git a/crypto/bn/bn_opts.c b/crypto/bn/bn_opts.c index 86a03e2423..2d04184c88 100644 --- a/crypto/bn/bn_opts.c +++ b/crypto/bn/bn_opts.c @@ -102,9 +102,7 @@ void do_it(int sec, PARMS *p); #define P_MULH 5 #define P_MRED 6 -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { PARMS p; BN_MONT_CTX *mont; @@ -203,9 +201,7 @@ char **argv; do_it(num,&p); } -void do_it(num,p) -int num; -PARMS *p; +void do_it(int num, PARMS *p) { char *start,*end; int i,j,number; @@ -240,9 +236,7 @@ PARMS *p; } } -int time_it(sec,p) -int sec; -PARMS *p; +int time_it(int sec, PARMS *p) { char *start,*end; int i,j; @@ -279,9 +273,7 @@ PARMS *p; return(i); } -void do_mul_exp(num,p) -int num; -PARMS *p; +void do_mul_exp(int num, PARMS *p) { int i; @@ -290,9 +282,7 @@ PARMS *p; p->ctx,p->mont); } -void do_mul(num,p) -int num; -PARMS *p; +void do_mul(int num, PARMS *p) { int i; @@ -300,9 +290,7 @@ PARMS *p; BN_mul(&(p->r),&(p->a),&(p->b),p->ctx); } -void do_sqr(num,p) -int num; -PARMS *p; +void do_sqr(int num, PARMS *p) { int i; @@ -310,9 +298,7 @@ PARMS *p; BN_sqr(&(p->r),&(p->a),p->ctx); } -void do_mul_low(num,p) -int num; -PARMS *p; +void do_mul_low(int num, PARMS *p) { int i; @@ -320,9 +306,7 @@ PARMS *p; BN_mul_low(&(p->r),&(p->a),&(p->b),p->w,p->ctx); } -void do_mul_high(num,p) -int num; -PARMS *p; +void do_mul_high(int num, PARMS *p) { int i; @@ -330,9 +314,7 @@ PARMS *p; BN_mul_low(&(p->r),&(p->a),&(p->b),&(p->low),p->w,p->ctx); } -void do_from_montgomery(num,p) -int num; -PARMS *p; +void do_from_montgomery(int num, PARMS *p) { int i; diff --git a/crypto/bn/bn_prime.c b/crypto/bn/bn_prime.c index f915b6b46d..bd9900db4d 100644 --- a/crypto/bn/bn_prime.c +++ b/crypto/bn/bn_prime.c @@ -83,14 +83,8 @@ static int probable_prime_dh(); static int probable_prime_dh_strong(); #endif -BIGNUM *BN_generate_prime(ret,bits,strong,add,rem,callback,cb_arg) -BIGNUM *ret; -int bits; -int strong; -BIGNUM *add; -BIGNUM *rem; -void (*callback)(P_I_I_P); -char *cb_arg; +BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int strong, BIGNUM *add, + BIGNUM *rem, void (*callback)(P_I_I_P), char *cb_arg) { BIGNUM *rnd=NULL; BIGNUM t; @@ -165,12 +159,8 @@ err: return(ret); } -int BN_is_prime(a,checks,callback,ctx_passed,cb_arg) -BIGNUM *a; -int checks; -void (*callback)(P_I_I_P); -BN_CTX *ctx_passed; -char *cb_arg; +int BN_is_prime(BIGNUM *a, int checks, void (*callback)(P_I_I_P), + BN_CTX *ctx_passed, char *cb_arg) { int i,j,c2=0,ret= -1; BIGNUM *check; @@ -218,11 +208,8 @@ err: #define RECP_MUL_MOD -static int witness(a,n,ctx,ctx2,mont) -BIGNUM *a; -BIGNUM *n; -BN_CTX *ctx,*ctx2; -BN_MONT_CTX *mont; +static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx, BN_CTX *ctx2, + BN_MONT_CTX *mont) { int k,i,ret= -1,good; BIGNUM *d,*dd,*tmp,*d1,*d2,*n1; @@ -285,9 +272,7 @@ err: return(ret); } -static int probable_prime(rnd, bits) -BIGNUM *rnd; -int bits; +static int probable_prime(BIGNUM *rnd, int bits) { int i; MS_STATIC BN_ULONG mods[NUMPRIMES]; @@ -318,12 +303,8 @@ again: return(1); } -static int probable_prime_dh(rnd, bits, add, rem,ctx) -BIGNUM *rnd; -int bits; -BIGNUM *add; -BIGNUM *rem; -BN_CTX *ctx; +static int probable_prime_dh(BIGNUM *rnd, int bits, BIGNUM *add, BIGNUM *rem, + BN_CTX *ctx) { int i,ret=0; BIGNUM *t1; @@ -358,12 +339,8 @@ err: return(ret); } -static int probable_prime_dh_strong(p, bits, padd, rem,ctx) -BIGNUM *p; -int bits; -BIGNUM *padd; -BIGNUM *rem; -BN_CTX *ctx; +static int probable_prime_dh_strong(BIGNUM *p, int bits, BIGNUM *padd, + BIGNUM *rem, BN_CTX *ctx) { int i,ret=0; BIGNUM *t1,*qadd=NULL,*q=NULL; @@ -412,10 +389,7 @@ err: } #if 0 -static int witness(a, n,ctx) -BIGNUM *a; -BIGNUM *n; -BN_CTX *ctx; +static int witness(BIGNUM *a, BIGNUM *n, BN_CTX *ctx) { int k,i,nb,ret= -1; BIGNUM *d,*dd,*tmp; diff --git a/crypto/bn/bn_print.c b/crypto/bn/bn_print.c index c473d6f941..9383ab2ae5 100644 --- a/crypto/bn/bn_print.c +++ b/crypto/bn/bn_print.c @@ -65,8 +65,7 @@ const static char *Hex="0123456789ABCDEF"; /* Must 'Free' the returned data */ -char *BN_bn2hex(a) -BIGNUM *a; +char *BN_bn2hex(BIGNUM *a) { int i,j,v,z=0; char *buf; @@ -101,8 +100,7 @@ err: } /* Must 'Free' the returned data */ -char *BN_bn2dec(a) -BIGNUM *a; +char *BN_bn2dec(BIGNUM *a) { int i=0,num; char *buf=NULL; @@ -156,9 +154,7 @@ err: return(buf); } -int BN_hex2bn(bn,a) -BIGNUM **bn; -char *a; +int BN_hex2bn(BIGNUM **bn, char *a) { BIGNUM *ret=NULL; BN_ULONG l=0; @@ -224,9 +220,7 @@ err: return(0); } -int BN_dec2bn(bn,a) -BIGNUM **bn; -char *a; +int BN_dec2bn(BIGNUM **bn, char *a) { BIGNUM *ret=NULL; BN_ULONG l=0; @@ -286,9 +280,7 @@ err: #ifndef NO_BIO #ifndef NO_FP_API -int BN_print_fp(fp, a) -FILE *fp; -BIGNUM *a; +int BN_print_fp(FILE *fp, BIGNUM *a) { BIO *b; int ret; @@ -302,9 +294,7 @@ BIGNUM *a; } #endif -int BN_print(bp, a) -BIO *bp; -BIGNUM *a; +int BN_print(BIO *bp, BIGNUM *a) { int i,j,v,z=0; int ret=0; diff --git a/crypto/bn/bn_rand.c b/crypto/bn/bn_rand.c index 7b21821fe6..7d6f635b70 100644 --- a/crypto/bn/bn_rand.c +++ b/crypto/bn/bn_rand.c @@ -62,11 +62,7 @@ #include "bn_lcl.h" #include "rand.h" -int BN_rand(rnd, bits, top, bottom) -BIGNUM *rnd; -int bits; -int top; -int bottom; +int BN_rand(BIGNUM *rnd, int bits, int top, int bottom) { unsigned char *buf=NULL; int ret=0,bit,bytes,mask; diff --git a/crypto/bn/bn_recp.c b/crypto/bn/bn_recp.c index 3ace566b55..85b4ac8148 100644 --- a/crypto/bn/bn_recp.c +++ b/crypto/bn/bn_recp.c @@ -60,8 +60,7 @@ #include "cryptlib.h" #include "bn_lcl.h" -void BN_RECP_CTX_init(recp) -BN_RECP_CTX *recp; +void BN_RECP_CTX_init(BN_RECP_CTX *recp) { BN_init(&(recp->N)); BN_init(&(recp->Nr)); @@ -69,7 +68,7 @@ BN_RECP_CTX *recp; recp->flags=0; } -BN_RECP_CTX *BN_RECP_CTX_new() +BN_RECP_CTX *BN_RECP_CTX_new(void) { BN_RECP_CTX *ret; @@ -81,8 +80,7 @@ BN_RECP_CTX *BN_RECP_CTX_new() return(ret); } -void BN_RECP_CTX_free(recp) -BN_RECP_CTX *recp; +void BN_RECP_CTX_free(BN_RECP_CTX *recp) { if(recp == NULL) return; @@ -93,10 +91,7 @@ BN_RECP_CTX *recp; Free(recp); } -int BN_RECP_CTX_set(recp,d,ctx) -BN_RECP_CTX *recp; -BIGNUM *d; -BN_CTX *ctx; +int BN_RECP_CTX_set(BN_RECP_CTX *recp, BIGNUM *d, BN_CTX *ctx) { BN_copy(&(recp->N),d); BN_zero(&(recp->Nr)); @@ -105,12 +100,8 @@ BN_CTX *ctx; return(1); } -int BN_mod_mul_reciprocal(r, x, y, recp, ctx) -BIGNUM *r; -BIGNUM *x; -BIGNUM *y; -BN_RECP_CTX *recp; -BN_CTX *ctx; +int BN_mod_mul_reciprocal(BIGNUM *r, BIGNUM *x, BIGNUM *y, BN_RECP_CTX *recp, + BN_CTX *ctx) { int ret=0; BIGNUM *a; @@ -133,12 +124,8 @@ err: return(ret); } -int BN_div_recp(dv,rem,m,recp,ctx) -BIGNUM *dv; -BIGNUM *rem; -BIGNUM *m; -BN_RECP_CTX *recp; -BN_CTX *ctx; +int BN_div_recp(BIGNUM *dv, BIGNUM *rem, BIGNUM *m, BN_RECP_CTX *recp, + BN_CTX *ctx) { int i,j,tos,ret=0,ex; BIGNUM *a,*b,*d,*r; @@ -221,11 +208,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(r,m,len,ctx) -BIGNUM *r; -BIGNUM *m; -int len; -BN_CTX *ctx; +int BN_reciprocal(BIGNUM *r, BIGNUM *m, int len, BN_CTX *ctx) { int ret= -1; BIGNUM t; diff --git a/crypto/bn/bn_shift.c b/crypto/bn/bn_shift.c index 944bf1794b..6dbe77b50f 100644 --- a/crypto/bn/bn_shift.c +++ b/crypto/bn/bn_shift.c @@ -60,9 +60,7 @@ #include "cryptlib.h" #include "bn_lcl.h" -int BN_lshift1(r, a) -BIGNUM *r; -BIGNUM *a; +int BN_lshift1(BIGNUM *r, BIGNUM *a) { register BN_ULONG *ap,*rp,t,c; int i; @@ -94,9 +92,7 @@ BIGNUM *a; return(1); } -int BN_rshift1(r, a) -BIGNUM *r; -BIGNUM *a; +int BN_rshift1(BIGNUM *r, BIGNUM *a) { BN_ULONG *ap,*rp,t,c; int i; @@ -125,10 +121,7 @@ BIGNUM *a; return(1); } -int BN_lshift(r, a, n) -BIGNUM *r; -BIGNUM *a; -int n; +int BN_lshift(BIGNUM *r, BIGNUM *a, int n) { int i,nw,lb,rb; BN_ULONG *t,*f; @@ -160,10 +153,7 @@ int n; return(1); } -int BN_rshift(r, a, n) -BIGNUM *r; -BIGNUM *a; -int n; +int BN_rshift(BIGNUM *r, BIGNUM *a, int n) { int i,j,nw,lb,rb; BN_ULONG *t,*f; diff --git a/crypto/bn/bn_sqr.c b/crypto/bn/bn_sqr.c index bcd9c3b6af..12cce4d7ce 100644 --- a/crypto/bn/bn_sqr.c +++ b/crypto/bn/bn_sqr.c @@ -62,10 +62,7 @@ /* r must not be a */ /* I've just gone over this and it is now %20 faster on x86 - eay - 27 Jun 96 */ -int BN_sqr(r, a, ctx) -BIGNUM *r; -BIGNUM *a; -BN_CTX *ctx; +int BN_sqr(BIGNUM *r, BIGNUM *a, BN_CTX *ctx) { int max,al; BIGNUM *tmp,*rr; @@ -146,11 +143,7 @@ printf("BN_sqr %d * %d\n",a->top,a->top); } /* tmp must have 2*n words */ -void bn_sqr_normal(r, a, n, tmp) -BN_ULONG *r; -BN_ULONG *a; -int n; -BN_ULONG *tmp; +void bn_sqr_normal(BN_ULONG *r, BN_ULONG *a, int n, BN_ULONG *tmp) { int i,j,max; BN_ULONG *ap,*rp; @@ -197,10 +190,7 @@ BN_ULONG *tmp; * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ -void bn_sqr_recursive(r,a,n2,t) -BN_ULONG *r,*a; -int n2; -BN_ULONG *t; +void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t) { int n=n2/2; int zero,c1; diff --git a/crypto/bn/bn_word.c b/crypto/bn/bn_word.c index 9c168e4f48..c0cfbc6797 100644 --- a/crypto/bn/bn_word.c +++ b/crypto/bn/bn_word.c @@ -60,9 +60,7 @@ #include "cryptlib.h" #include "bn_lcl.h" -BN_ULONG BN_mod_word(a, w) -BIGNUM *a; -BN_ULONG w; +BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w) { #ifndef BN_LLONG BN_ULONG ret=0; @@ -85,9 +83,7 @@ BN_ULONG w; return((BN_ULONG)ret); } -BN_ULONG BN_div_word(a, w) -BIGNUM *a; -BN_ULONG w; +BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w) { BN_ULONG ret; int i; @@ -109,9 +105,7 @@ BN_ULONG w; return(ret); } -int BN_add_word(a, w) -BIGNUM *a; -BN_ULONG w; +int BN_add_word(BIGNUM *a, BN_ULONG w) { BN_ULONG l; int i; @@ -142,9 +136,7 @@ BN_ULONG w; return(1); } -int BN_sub_word(a, w) -BIGNUM *a; -BN_ULONG w; +int BN_sub_word(BIGNUM *a, BN_ULONG w) { int i; @@ -183,9 +175,7 @@ BN_ULONG w; return(1); } -int BN_mul_word(a,w) -BIGNUM *a; -BN_ULONG w; +int BN_mul_word(BIGNUM *a, BN_ULONG w) { BN_ULONG ll; diff --git a/crypto/bn/bnspeed.c b/crypto/bn/bnspeed.c index 777212c1ba..af4ebe7986 100644 --- a/crypto/bn/bnspeed.c +++ b/crypto/bn/bnspeed.c @@ -133,8 +133,7 @@ static double Time_F(); #define START 0 #define STOP 1 -static double Time_F(s) -int s; +static double Time_F(int s) { double ret; #ifdef TIMES @@ -176,9 +175,7 @@ static int sizes[NUM_SIZES]={128,256,512,1024,2048}; void do_mul(BIGNUM *r,BIGNUM *a,BIGNUM *b,BN_CTX *ctx); -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { BN_CTX *ctx; BIGNUM a,b,c; @@ -191,11 +188,7 @@ char **argv; do_mul(&a,&b,&c,ctx); } -void do_mul(r,a,b,ctx) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; -BN_CTX *ctx; +void do_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { int i,j,k; double tm; diff --git a/crypto/bn/bntest.c b/crypto/bn/bntest.c index e84cf250b2..ab93138de8 100644 --- a/crypto/bn/bntest.c +++ b/crypto/bn/bntest.c @@ -112,9 +112,7 @@ static int results=0; #include "bss_file.c" #endif -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out; @@ -229,8 +227,7 @@ err: return(1); } -int test_add(bp) -BIO *bp; +int test_add(BIO *bp) { BIGNUM a,b,c; int i; @@ -269,8 +266,7 @@ BIO *bp; return(1); } -int test_sub(bp) -BIO *bp; +int test_sub(BIO *bp) { BIGNUM a,b,c; int i; @@ -309,9 +305,7 @@ BIO *bp; return(1); } -int test_div(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_div(BIO *bp, BN_CTX *ctx) { BIGNUM a,b,c,d; int i; @@ -362,9 +356,7 @@ BN_CTX *ctx; return(1); } -int test_div_recp(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_div_recp(BIO *bp, BN_CTX *ctx) { BIGNUM a,b,c,d; BN_RECP_CTX recp; @@ -419,8 +411,7 @@ BN_CTX *ctx; return(1); } -int test_mul(bp) -BIO *bp; +int test_mul(BIO *bp) { BIGNUM a,b,c; int i; @@ -464,9 +455,7 @@ BIO *bp; return(1); } -int test_sqr(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_sqr(BIO *bp, BN_CTX *ctx) { BIGNUM a,c; int i; @@ -501,9 +490,7 @@ BN_CTX *ctx; return(1); } -int test_mont(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_mont(BIO *bp, BN_CTX *ctx) { BIGNUM a,b,c,A,B; BIGNUM n; @@ -563,9 +550,7 @@ BN_num_bits(mont->N)); return(1); } -int test_mod(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_mod(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c; int i; @@ -604,9 +589,7 @@ BN_CTX *ctx; return(1); } -int test_mod_mul(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_mod_mul(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c,*d,*e; int i; @@ -660,9 +643,7 @@ BN_CTX *ctx; return(1); } -int test_mod_exp(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_mod_exp(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*c,*d,*e; int i; @@ -705,9 +686,7 @@ BN_CTX *ctx; return(1); } -int test_exp(bp,ctx) -BIO *bp; -BN_CTX *ctx; +int test_exp(BIO *bp, BN_CTX *ctx) { BIGNUM *a,*b,*d,*e; int i; @@ -745,8 +724,7 @@ BN_CTX *ctx; return(1); } -int test_lshift(bp) -BIO *bp; +int test_lshift(BIO *bp) { BIGNUM *a,*b,*c; int i; @@ -781,8 +759,7 @@ BIO *bp; return(1); } -int test_lshift1(bp) -BIO *bp; +int test_lshift1(BIO *bp) { BIGNUM *a,*b; int i; @@ -813,8 +790,7 @@ BIO *bp; return(1); } -int test_rshift(bp) -BIO *bp; +int test_rshift(BIO *bp) { BIGNUM *a,*b,*c; int i; @@ -849,8 +825,7 @@ BIO *bp; return(1); } -int test_rshift1(bp) -BIO *bp; +int test_rshift1(BIO *bp) { BIGNUM *a,*b; int i; @@ -881,7 +856,7 @@ BIO *bp; return(1); } -int rand_neg() +int rand_neg(void) { static unsigned int neg=0; static int sign[8]={0,0,0,1,1,0,1,1}; diff --git a/crypto/bn/expspeed.c b/crypto/bn/expspeed.c index fe00373246..7b7652d022 100644 --- a/crypto/bn/expspeed.c +++ b/crypto/bn/expspeed.c @@ -133,8 +133,7 @@ static double Time_F(); #define START 0 #define STOP 1 -static double Time_F(s) -int s; +static double Time_F(int s) { double ret; #ifdef TIMES @@ -177,9 +176,7 @@ static int mul_c[NUM_SIZES]={8*8*8*8*8,8*8*8*8,8*8*8,8*8,8,1}; void do_mul_exp(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *c,BN_CTX *ctx); -int main(argc,argv) -int argc; -char **argv; +int main(int argc, char **argv) { BN_CTX *ctx; BIGNUM *a,*b,*c,*r; @@ -193,12 +190,7 @@ char **argv; do_mul_exp(r,a,b,c,ctx); } -void do_mul_exp(r,a,b,c,ctx) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; -BIGNUM *c; -BN_CTX *ctx; +void do_mul_exp(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *c, BN_CTX *ctx) { int i,k; double tm; diff --git a/crypto/bn/exptest.c b/crypto/bn/exptest.c index 1ec61c2c87..4816344f56 100644 --- a/crypto/bn/exptest.c +++ b/crypto/bn/exptest.c @@ -69,9 +69,7 @@ #define NUM_BITS (BN_BITS*2) -int main(argc,argv) -int argc; -char *argv[]; +int main(int argc, char *argv[]) { BN_CTX *ctx; BIO *out=NULL; diff --git a/crypto/bn/old/b_sqr.c b/crypto/bn/old/b_sqr.c index e1a61b8471..715cb1c8ab 100644 --- a/crypto/bn/old/b_sqr.c +++ b/crypto/bn/old/b_sqr.c @@ -64,10 +64,7 @@ static int bn_mm(BIGNUM *m,BIGNUM *A,BIGNUM *B, BIGNUM *sk,BN_CTX *ctx); /* r must be different to a and b */ /* int BN_mmul(r, a, b) */ -int BN_mul(r, a, b) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; +int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b) { BN_ULONG *ap,*bp,*rp; BIGNUM *sk; @@ -132,10 +129,7 @@ printf("BN_mul(%d,%d)\n",a->top,b->top); #define blbh (sk[1]) /* r must be different to a and b */ -int bn_mm(m, A, B, sk,ctx) -BIGNUM *m,*A,*B; -BIGNUM *sk; -BN_CTX *ctx; +int bn_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk, BN_CTX *ctx) { int n,num,sqr=0; int an,bn; diff --git a/crypto/bn/old/bn_high.c b/crypto/bn/old/bn_high.c index 90268fb31a..763bcb605b 100644 --- a/crypto/bn/old/bn_high.c +++ b/crypto/bn/old/bn_high.c @@ -15,9 +15,7 @@ int BN_mul_high(BIGNUM *r,BIGNUM *a,BIGNUM *b,BIGNUM *low, int words); #undef t1 #undef t2 -int BN_mul_high(r,a,b,low,words) -BIGNUM *r,*a,*b,*low; -int words; +int BN_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words) { int w2,borrow=0,full=0; BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1; diff --git a/crypto/bn/old/bn_ka.c b/crypto/bn/old/bn_ka.c index b49a52aa73..378c94dc5a 100644 --- a/crypto/bn/old/bn_ka.c +++ b/crypto/bn/old/bn_ka.c @@ -13,10 +13,8 @@ * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ -void bn_mul_recursive(r,a,b,n2,t) -BN_ULONG *r,*a,*b; -int n2; -BN_ULONG *t; +void bn_mul_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, + BN_ULONG *t) { int n=n2/2; int neg,zero,c1,c2; @@ -145,10 +143,8 @@ printf(" bn_mul_recursive %d * %d\n",n2,n2); /* n+tn is the word length * t needs to be n*4 is size, as does r */ -void bn_mul_part_recursive(r,a,b,tn,n,t) -BN_ULONG *r,*a,*b; -int tn,n; -BN_ULONG *t; +void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int tn, + int n, BN_ULONG *t) { int n2=n*2,i,j; int c1; @@ -265,10 +261,7 @@ printf(" bn_mul_part_recursive %d * %d\n",tn+n,tn+n); * a[0]*b[0]+a[1]*b[1]+(a[0]-a[1])*(b[1]-b[0]) * a[1]*b[1] */ -void bn_sqr_recursive(r,a,n2,t) -BN_ULONG *r,*a; -int n2; -BN_ULONG *t; +void bn_sqr_recursive(BN_ULONG *r, BN_ULONG *a, int n2, BN_ULONG *t) { int n=n2/2; int zero,c1; @@ -367,10 +360,8 @@ printf(" bn_sqr_recursive %d * %d\n",n2,n2); /* a and b must be the same size, which is n2. * r needs to be n2 words and t needs to be n2*2 */ -void bn_mul_low_recursive(r,a,b,n2,t) -BN_ULONG *r,*a,*b; -int n2; -BN_ULONG *t; +void bn_mul_low_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n2, + BN_ULONG *t) { int n=n2/2; @@ -400,10 +391,8 @@ printf(" bn_mul_low_recursive %d * %d\n",n2,n2); * l is the low words of the output. * t needs to be n2*3 */ -void bn_mul_high(r,a,b,l,n2,t) -BN_ULONG *r,*a,*b,*l; -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) { int j,i,n,c1,c2; int neg,oneg,zero; diff --git a/crypto/bn/old/bn_low.c b/crypto/bn/old/bn_low.c index 217c8c2f96..cbc406751c 100644 --- a/crypto/bn/old/bn_low.c +++ b/crypto/bn/old/bn_low.c @@ -65,11 +65,7 @@ static int bn_mm_low(BIGNUM *m,BIGNUM *A,BIGNUM *B, int num, int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b,int words); /* r must be different to a and b */ -int BN_mul_low(r, a, b, num) -BIGNUM *r; -BIGNUM *a; -BIGNUM *b; -int num; +int BN_mul_low(BIGNUM *r, BIGNUM *a, BIGNUM *b, int num) { BN_ULONG *ap,*bp,*rp; BIGNUM *sk; @@ -142,11 +138,8 @@ printf("BN_mul_low(%d,%d,%d)\n",a->top,b->top,num); #define t2 (sk[1]) /* r must be different to a and b */ -int bn_mm_low(m, A, B, num, sk,ctx) -BIGNUM *m,*A,*B; -int num; -BIGNUM *sk; -BN_CTX *ctx; +int bn_mm_low(BIGNUM *m, BIGNUM *A, BIGNUM *B, int num, BIGNUM *sk, + BN_CTX *ctx) { int n; /* ,sqr=0; */ int an,bn; diff --git a/crypto/bn/old/bn_m.c b/crypto/bn/old/bn_m.c index 1cf51e8e2a..522beb02bc 100644 --- a/crypto/bn/old/bn_m.c +++ b/crypto/bn/old/bn_m.c @@ -63,8 +63,7 @@ #define limit_bits 5 /* 2^5, or 32 words */ #define limit_num (1<<limit_bits) -int BN_m(r,a,b) -BIGNUM *r,*a,*b; +int BN_m(BIGNUM *r, BIGNUM *a, BIGNUM *b) { BIGNUM *sk; int i,n; @@ -82,9 +81,7 @@ BIGNUM *r,*a,*b; #define blbh (sk[1]) /* r must be different to a and b */ -int BN_mm(m, A, B, sk) -BIGNUM *m,*A,*B; -BIGNUM *sk; +int BN_mm(BIGNUM *m, BIGNUM *A, BIGNUM *B, BIGNUM *sk) { int i,num,anum,bnum; int an,bn; diff --git a/crypto/bn/old/bn_wmul.c b/crypto/bn/old/bn_wmul.c index e3ce107921..a467b2f17a 100644 --- a/crypto/bn/old/bn_wmul.c +++ b/crypto/bn/old/bn_wmul.c @@ -5,9 +5,7 @@ int bn_mull(BIGNUM *r,BIGNUM *a,BIGNUM *b, BN_CTX *ctx); -int bn_mull(r,a,b,ctx) -BIGNUM *r,*a,*b; -BN_CTX *ctx; +int bn_mull(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx) { int top,i,j,k,al,bl; BIGNUM *t; @@ -114,11 +112,7 @@ end: } #endif -void bn_mul_normal(r,a,na,b,nb) -BN_ULONG *r,*a; -int na; -BN_ULONG *b; -int nb; +void bn_mul_normal(BN_ULONG *r, BN_ULONG *a, int na, BN_ULONG *b, int nb) { BN_ULONG *rr; @@ -155,9 +149,7 @@ printf(" bn_mul_normal %d * %d\n",na,nb); } #if 1 -void bn_mul_low_normal(r,a,b,n) -BN_ULONG *r,*a,*b; -int n; +void bn_mul_low_normal(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n) { #ifdef BN_COUNT printf(" bn_mul_low_normal %d * %d\n",n,n); diff --git a/crypto/bn/test.c b/crypto/bn/test.c index 46fdc9c27e..a048b9f878 100644 --- a/crypto/bn/test.c +++ b/crypto/bn/test.c @@ -50,9 +50,7 @@ main() } #if 0 -int bn_mul_high(r,a,b,low,words) -BIGNUM *r,*a,*b,*low; -int words; +int bn_mul_high(BIGNUM *r, BIGNUM *a, BIGNUM *b, BIGNUM *low, int words) { int i; BIGNUM t1,t2,t3,h,ah,al,bh,bl,m,s0,s1; @@ -151,10 +149,8 @@ t3.max=t3.top; BN_free(&m); BN_free(&h); } -int BN_mod_mul_montgomery(r,a,b,mont,ctx) -BIGNUM *r,*a,*b; -BN_MONT_CTX *mont; -BN_CTX *ctx; +int BN_mod_mul_montgomery(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_MONT_CTX *mont, + BN_CTX *ctx) { BIGNUM *tmp; @@ -176,11 +172,7 @@ err: return(0); } -int BN_from_montgomery(r,a,mont,ctx) -BIGNUM *r; -BIGNUM *a; -BN_MONT_CTX *mont; -BN_CTX *ctx; +int BN_from_montgomery(BIGNUM *r, BIGNUM *a, BN_MONT_CTX *mont, BN_CTX *ctx) { BIGNUM z1; BIGNUM *t1,*t2; @@ -217,10 +209,7 @@ err: return(0); } -int BN_MONT_CTX_set(mont,mod,ctx) -BN_MONT_CTX *mont; -BIGNUM *mod; -BN_CTX *ctx; +int BN_MONT_CTX_set(BN_MONT_CTX *mont, BIGNUM *mod, BN_CTX *ctx) { BIGNUM *Ri=NULL,*R=NULL; |