Change functions to ANSI C.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user