summaryrefslogtreecommitdiff
path: root/beecrypt/mp.c
diff options
context:
space:
mode:
authorjbj <devnull@localhost>2003-05-04 16:00:18 +0000
committerjbj <devnull@localhost>2003-05-04 16:00:18 +0000
commitf54e177d8a8ee61d2d07cbc36e20c33c630f5ccb (patch)
tree7858dd7ca63cc06a9f66b6026f3d889a897b1be5 /beecrypt/mp.c
parent6d64db3442af92c18847d75b473141fbd28a72b0 (diff)
downloadlibrpm-tizen-f54e177d8a8ee61d2d07cbc36e20c33c630f5ccb.tar.gz
librpm-tizen-f54e177d8a8ee61d2d07cbc36e20c33c630f5ccb.tar.bz2
librpm-tizen-f54e177d8a8ee61d2d07cbc36e20c33c630f5ccb.zip
Merge latest beecrypt-3.0.0 bits.
Spliddles. CVS patchset: 6809 CVS date: 2003/05/04 16:00:18
Diffstat (limited to 'beecrypt/mp.c')
-rw-r--r--beecrypt/mp.c168
1 files changed, 87 insertions, 81 deletions
diff --git a/beecrypt/mp.c b/beecrypt/mp.c
index f78118c20..944944b0e 100644
--- a/beecrypt/mp.c
+++ b/beecrypt/mp.c
@@ -30,7 +30,7 @@
#include "debug.h"
#ifndef ASM_MPZERO
-void mpzero(register size_t size, register mpw* data)
+void mpzero(size_t size, mpw* data)
{
while (size--)
*(data++) = 0;
@@ -38,7 +38,7 @@ void mpzero(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPFILL
-void mpfill(register size_t size, register mpw* data, register mpw fill)
+void mpfill(size_t size, mpw* data, mpw fill)
{
while (size--)
*(data++) = fill;
@@ -46,21 +46,21 @@ void mpfill(register size_t size, register mpw* data, register mpw fill)
#endif
#ifndef ASM_MPODD
-int mpodd(register size_t size, register const mpw* data)
+int mpodd(size_t size, const mpw* data)
{
return (int)(data[size-1] & 0x1);
}
#endif
#ifndef ASM_MPEVEN
-int mpeven(register size_t size, register const mpw* data)
+int mpeven(size_t size, const mpw* data)
{
return !(int)(data[size-1] & 0x1);
}
#endif
#ifndef ASM_MPZ
-int mpz(register size_t size, register const mpw* data)
+int mpz(size_t size, const mpw* data)
{
while (size--)
if (*(data++))
@@ -70,7 +70,7 @@ int mpz(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPNZ
-int mpnz(register size_t size, register const mpw* data)
+int mpnz(size_t size, const mpw* data)
{
while (size--)
if (*(data++))
@@ -80,7 +80,7 @@ int mpnz(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPEQ
-int mpeq(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mpeq(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -97,7 +97,7 @@ int mpeq(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPEQX
-int mpeqx(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpeqx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -115,7 +115,7 @@ int mpeqx(register size_t xsize, register const mpw* xdata, register size_t ysiz
#endif
#ifndef ASM_MPNE
-int mpne(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mpne(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -132,7 +132,7 @@ int mpne(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPNEX
-int mpnex(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpnex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -150,7 +150,7 @@ int mpnex(register size_t xsize, register const mpw* xdata, register size_t ysiz
#endif
#ifndef ASM_MPGT
-int mpgt(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mpgt(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -165,7 +165,7 @@ int mpgt(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPGTX
-int mpgtx(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpgtx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -183,7 +183,7 @@ int mpgtx(register size_t xsize, register const mpw* xdata, register size_t ysiz
#endif
#ifndef ASM_MPLT
-int mplt(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mplt(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -198,7 +198,7 @@ int mplt(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPLTX
-int mpltx(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpltx(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -216,7 +216,7 @@ int mpltx(register size_t xsize, register const mpw* xdata, register size_t ysiz
#endif
#ifndef ASM_MPGE
-int mpge(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mpge(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -231,7 +231,7 @@ int mpge(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPGEX
-int mpgex(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpgex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -249,7 +249,7 @@ int mpgex(register size_t xsize, register const mpw* xdata, register size_t ysiz
#endif
#ifndef ASM_MPLE
-int mple(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mple(size_t size, const mpw* xdata, const mpw* ydata)
{
while (size--)
{
@@ -264,7 +264,7 @@ int mple(register size_t size, register const mpw* xdata, register const mpw* yd
#endif
#ifndef ASM_MPLEX
-int mplex(register size_t xsize, register const mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mplex(size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -283,7 +283,7 @@ int mplex(register size_t xsize, register const mpw* xdata, register size_t ysiz
#ifndef ASM_MPISONE
-int mpisone(register size_t size, register const mpw* data)
+int mpisone(size_t size, const mpw* data)
{
data += size;
if (*(--data) == 1)
@@ -298,7 +298,7 @@ int mpisone(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPISTWO
-int mpistwo(register size_t size, register const mpw* data)
+int mpistwo(size_t size, const mpw* data)
{
data += size;
if (*(--data) == 2)
@@ -313,7 +313,7 @@ int mpistwo(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPEQMONE
-int mpeqmone(register size_t size, register const mpw* xdata, register const mpw* ydata)
+int mpeqmone(size_t size, const mpw* xdata, const mpw* ydata)
{
xdata += size;
ydata += size;
@@ -330,7 +330,7 @@ int mpeqmone(register size_t size, register const mpw* xdata, register const mpw
#endif
#ifndef ASM_MPLEONE
-int mpleone(register size_t size, register const mpw* data)
+int mpleone(size_t size, const mpw* data)
{
data += size;
if (*(--data) > 1)
@@ -346,49 +346,49 @@ int mpleone(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPMSBSET
-int mpmsbset(/*@unused@*/ register size_t size, register const mpw* data)
+int mpmsbset(/*@unused@*/ size_t size, const mpw* data)
{
return (int)((*data) >> (MP_WBITS-1));
}
#endif
#ifndef ASM_MPLSBSET
-int mplsbset(register size_t size, register const mpw* data)
+int mplsbset(size_t size, const mpw* data)
{
return (int)(data[size-1] & 0x1);
}
#endif
#ifndef ASM_MPSETMSB
-void mpsetmsb(/*@unused@*/ register size_t size, register mpw* data)
+void mpsetmsb(/*@unused@*/ size_t size, mpw* data)
{
*data |= MP_MSBMASK;
}
#endif
#ifndef ASM_MPSETLSB
-void mpsetlsb(register size_t size, register mpw* data)
+void mpsetlsb(size_t size, mpw* data)
{
data[size-1] |= MP_LSBMASK;
}
#endif
#ifndef ASM_MPCLRMSB
-void mpclrmsb(/*@unused@*/ register size_t size, register mpw* data)
+void mpclrmsb(/*@unused@*/ size_t size, mpw* data)
{
*data &= ~ MP_MSBMASK;
}
#endif
#ifndef ASM_MPCLRLSB
-void mpclrlsb(register size_t size, register mpw* data)
+void mpclrlsb(size_t size, mpw* data)
{
data[size-1] &= ~ MP_LSBMASK;
}
#endif
#ifndef ASM_MPAND
-void mpand(register size_t size, register mpw* xdata, register const mpw* ydata)
+void mpand(size_t size, mpw* xdata, const mpw* ydata)
{
while (size--)
xdata[size] &= ydata[size];
@@ -396,7 +396,7 @@ void mpand(register size_t size, register mpw* xdata, register const mpw* ydata)
#endif
#ifndef ASM_MPXOR
-void mpxor(register size_t size, register mpw* xdata, register const mpw* ydata)
+void mpxor(size_t size, mpw* xdata, const mpw* ydata)
{
while (size--)
xdata[size] ^= ydata[size];
@@ -404,7 +404,7 @@ void mpxor(register size_t size, register mpw* xdata, register const mpw* ydata)
#endif
#ifndef ASM_MPOR
-void mpor(register size_t size, register mpw* xdata, register const mpw* ydata)
+void mpor(size_t size, mpw* xdata, const mpw* ydata)
{
while (size--)
xdata[size] |= ydata[size];
@@ -412,7 +412,7 @@ void mpor(register size_t size, register mpw* xdata, register const mpw* ydata)
#endif
#ifndef ASM_MPNOT
-void mpnot(register size_t size, register mpw* data)
+void mpnot(size_t size, mpw* data)
{
while (size--)
data[size] = ~data[size];
@@ -420,16 +420,16 @@ void mpnot(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPSETW
-void mpsetw(register size_t xsize, register mpw* xdata, register mpw y)
+void mpsetw(size_t size, mpw* xdata, mpw y)
{
- while (--xsize)
+ while (--size)
*(xdata++) = 0;
*(xdata++) = y;
}
#endif
#ifndef ASM_MPSETX
-void mpsetx(register size_t xsize, register mpw* xdata, register size_t ysize, register const mpw* ydata)
+void mpsetx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
{
while (xsize > ysize)
{
@@ -447,7 +447,7 @@ void mpsetx(register size_t xsize, register mpw* xdata, register size_t ysize, r
#endif
#ifndef ASM_MPADDW
-int mpaddw(register size_t size, register mpw* xdata, register mpw y)
+int mpaddw(size_t size, mpw* xdata, mpw y)
{
register mpw load, temp;
register int carry = 0;
@@ -471,7 +471,7 @@ int mpaddw(register size_t size, register mpw* xdata, register mpw y)
#endif
#ifndef ASM_MPADD
-int mpadd(register size_t size, register mpw* xdata, register const mpw* ydata)
+int mpadd(size_t size, mpw* xdata, const mpw* ydata)
{
register mpw load, temp;
register int carry = 0;
@@ -492,7 +492,7 @@ int mpadd(register size_t size, register mpw* xdata, register const mpw* ydata)
#endif
#ifndef ASM_MPADDX
-int mpaddx(register size_t xsize, register mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpaddx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -510,7 +510,7 @@ int mpaddx(register size_t xsize, register mpw* xdata, register size_t ysize, re
#endif
#ifndef ASM_MPSUBW
-int mpsubw(register size_t size, register mpw* xdata, register mpw y)
+int mpsubw(size_t size, mpw* xdata, mpw y)
{
register mpw load, temp;
register int carry = 0;
@@ -534,7 +534,7 @@ int mpsubw(register size_t size, register mpw* xdata, register mpw y)
#endif
#ifndef ASM_MPSUB
-int mpsub(register size_t size, register mpw* xdata, register const mpw* ydata)
+int mpsub(size_t size, mpw* xdata, const mpw* ydata)
{
register mpw load, temp;
register int carry = 0;
@@ -555,7 +555,7 @@ int mpsub(register size_t size, register mpw* xdata, register const mpw* ydata)
#endif
#ifndef ASM_MPSUBX
-int mpsubx(register size_t xsize, register mpw* xdata, register size_t ysize, register const mpw* ydata)
+int mpsubx(size_t xsize, mpw* xdata, size_t ysize, const mpw* ydata)
{
if (xsize > ysize)
{
@@ -573,7 +573,7 @@ int mpsubx(register size_t xsize, register mpw* xdata, register size_t ysize, re
#endif
#ifndef ASM_MPNEG
-void mpneg(register size_t size, register mpw* data)
+void mpneg(size_t size, mpw* data)
{
mpnot(size, data);
(void) mpaddw(size, data, 1);
@@ -581,7 +581,7 @@ void mpneg(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPSETMUL
-mpw mpsetmul(register size_t size, register mpw* result, register const mpw* data, register mpw y)
+mpw mpsetmul(size_t size, mpw* result, const mpw* data, mpw y)
{
#if HAVE_MPDW
register mpdw temp;
@@ -637,7 +637,7 @@ mpw mpsetmul(register size_t size, register mpw* result, register const mpw* dat
#endif
#ifndef ASM_MPADDMUL
-mpw mpaddmul(register size_t size, register mpw* result, register const mpw* data, register mpw y)
+mpw mpaddmul(size_t size, mpw* result, const mpw* data, mpw y)
{
#if HAVE_MPDW
register mpdw temp;
@@ -739,7 +739,7 @@ void mpmul(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw*
#endif
#ifndef ASM_MPADDSQRTRC
-mpw mpaddsqrtrc(register size_t size, register mpw* result, register const mpw* data)
+mpw mpaddsqrtrc(size_t size, mpw* result, const mpw* data)
{
#if HAVE_MPDW
register mpdw temp;
@@ -802,7 +802,7 @@ mpw mpaddsqrtrc(register size_t size, register mpw* result, register const mpw*
#endif
#ifndef ASM_MPSQR
-void mpsqr(register mpw* result, register size_t size, register const mpw* data)
+void mpsqr(mpw* result, size_t size, const mpw* data)
{
register mpw rc;
register size_t n = size-1;
@@ -830,7 +830,7 @@ void mpsqr(register mpw* result, register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPSIZE
-size_t mpsize(register size_t size, register const mpw* data)
+size_t mpsize(size_t size, const mpw* data)
{
while (size)
{
@@ -844,14 +844,14 @@ size_t mpsize(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPBITS
-size_t mpbits(register size_t size, register const mpw* data)
+size_t mpbits(size_t size, const mpw* data)
{
return MP_WORDS_TO_BITS(size) - mpmszcnt(size, data);
}
#endif
#ifndef ASM_MPNORM
-size_t mpnorm(register size_t size, register mpw* data)
+size_t mpnorm(size_t size, mpw* data)
{
register size_t shift = mpmszcnt(size, data);
mplshift(size, data, shift);
@@ -860,7 +860,7 @@ size_t mpnorm(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPDIVTWO
-void mpdivtwo(register size_t size, register mpw* data)
+void mpdivtwo(size_t size, mpw* data)
{
register mpw temp, carry = 0;
@@ -874,7 +874,7 @@ void mpdivtwo(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPSDIVTWO
-void mpsdivtwo(register size_t size, register mpw* data)
+void mpsdivtwo(size_t size, mpw* data)
{
int carry = mpmsbset(size, data);
mpdivtwo(size, data);
@@ -884,7 +884,7 @@ void mpsdivtwo(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPMULTWO
-int mpmultwo(register size_t size, register mpw* data)
+int mpmultwo(size_t size, mpw* data)
{
register mpw temp, carry = 0;
@@ -900,7 +900,7 @@ int mpmultwo(register size_t size, register mpw* data)
#endif
#ifndef ASM_MPMSZCNT
-size_t mpmszcnt(register size_t size, register const mpw* data)
+size_t mpmszcnt(size_t size, const mpw* data)
{
register size_t zbits = 0;
register size_t i = 0;
@@ -925,7 +925,7 @@ size_t mpmszcnt(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPBITCNT
-size_t mpbitcnt(register size_t size, register const mpw* data)
+size_t mpbitcnt(size_t size, const mpw* data)
{
register mpw xmask = (mpw)((*data & MP_MSBMASK) ? -1 : 0);
register size_t nbits = MP_WBITS * size;
@@ -947,7 +947,7 @@ size_t mpbitcnt(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPLSZCNT
-size_t mplszcnt(register size_t size, register const mpw* data)
+size_t mplszcnt(size_t size, const mpw* data)
{
register size_t zbits = 0;
@@ -971,7 +971,7 @@ size_t mplszcnt(register size_t size, register const mpw* data)
#endif
#ifndef ASM_MPLSHIFT
-void mplshift(register size_t size, register mpw* data, size_t count)
+void mplshift(size_t size, mpw* data, size_t count)
{
register size_t words = MP_BITS_TO_WORDS(count);
@@ -1005,7 +1005,7 @@ void mplshift(register size_t size, register mpw* data, size_t count)
#endif
#ifndef ASM_MPRSHIFT
-void mprshift(register size_t size, register mpw* data, size_t count)
+void mprshift(size_t size, mpw* data, size_t count)
{
register size_t words = MP_BITS_TO_WORDS(count);
@@ -1040,7 +1040,7 @@ void mprshift(register size_t size, register mpw* data, size_t count)
#ifndef ASM_MPRSHIFTLSZ
/* x must be != 0 */
-size_t mprshiftlsz(register size_t size, register mpw* data)
+size_t mprshiftlsz(size_t size, mpw* data)
{
register mpw* slide = data+size-1;
register size_t zwords = 0; /* counter for 'all zero bit' words */
@@ -1255,7 +1255,7 @@ void mpnmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw
#endif
#ifndef ASM_MPNDIVMOD
-void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, register mpw* workspace)
+void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const mpw* ydata, mpw* workspace)
{
/* result must be xsize+1 in length */
/* workspace must be ysize+1 in length */
@@ -1289,61 +1289,67 @@ void mpndivmod(mpw* result, size_t xsize, const mpw* xdata, size_t ysize, const
}
#endif
-#ifndef ASM_MPPRINT
-void mpprint(register FILE * fp, register size_t size, register const mpw* data)
+void mpprint(size_t size, const mpw* data)
+{
+ mpfprint(stdout, size, data);
+}
+
+void mpprintln(size_t size, const mpw* data)
+{
+ mpfprintln(stdout, size, data);
+}
+
+void mpfprint(FILE * f, size_t size, const mpw* data)
{
if (data == NULL)
return;
- if (fp == NULL)
- fp = stderr;
+ if (f == NULL)
+ f = stderr;
while (size--)
{
#if (MP_WBITS == 32)
- fprintf(fp, "%08x", (unsigned) *(data++));
+ fprintf(f, "%08x", (unsigned) *(data++));
#elif (MP_WBITS == 64)
# if WIN32
- fprintf(fp, "%016I64x", *(data++));
+ fprintf(f, "%016I64x", *(data++));
# elif SIZEOF_UNSIGNED_LONG == 8
- fprintf(fp, "%016lx", *(data++));
+ fprintf(f, "%016lx", *(data++));
# else
- fprintf(fp, "%016llx", *(data++));
+ fprintf(f, "%016llx", *(data++));
# endif
#else
# error
#endif
}
- fprintf(fp, "\n");
- (void) fflush(fp);
+ fprintf(f, "\n");
+ (void) fflush(f);
}
-#endif
-#ifndef ASM_MPPRINTLN
-void mpprintln(register FILE * fp, register size_t size, register const mpw* data)
+void mpfprintln(FILE * f, size_t size, const mpw* data)
{
if (data == NULL)
return;
- if (fp == NULL)
- fp = stderr;
+ if (f == NULL)
+ f = stderr;
while (size--)
{
#if (MP_WBITS == 32)
- fprintf(fp, "%08x", (unsigned) *(data++));
+ fprintf(f, "%08x", (unsigned) *(data++));
#elif (MP_WBITS == 64)
# if WIN32
- fprintf(fp, "%016I64x", *(data++));
+ fprintf(f, "%016I64x", *(data++));
# elif SIZEOF_UNSIGNED_LONG == 8
- fprintf(fp, "%016lx", *(data++));
+ fprintf(f, "%016lx", *(data++));
# else
- fprintf(fp, "%016llx", *(data++));
+ fprintf(f, "%016llx", *(data++));
# endif
#else
# error
#endif
}
- fprintf(fp, "\n");
- (void) fflush(fp);
+ fprintf(f, "\n");
+ (void) fflush(f);
}
-#endif
int i2osp(byte *osdata, size_t ossize, const mpw* idata, size_t isize)
{