mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-17 15:44:34 +02:00
* mpicoder.c, mpi-inline.h, mpi-inv.c, mpiutil.c, mpih-div.c,
mpi-internal.h, mpi-scan.c: Edit all preprocessor instructions to remove whitespace before the '#'. This is not required by C89, but there are some compilers out there that don't like it.
This commit is contained in:
parent
88b7e52b42
commit
628e98785a
@ -1,3 +1,10 @@
|
|||||||
|
2003-05-21 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* mpicoder.c, mpi-inline.h, mpi-inv.c, mpiutil.c, mpih-div.c,
|
||||||
|
mpi-internal.h, mpi-scan.c: Edit all preprocessor instructions to
|
||||||
|
remove whitespace before the '#'. This is not required by C89,
|
||||||
|
but there are some compilers out there that don't like it.
|
||||||
|
|
||||||
2003-04-23 David Shaw <dshaw@jabberwocky.com>
|
2003-04-23 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* config.links: Put back proper copyright line.
|
* config.links: Put back proper copyright line.
|
||||||
@ -397,7 +404,6 @@ Mon Feb 16 13:00:27 1998 Werner Koch (wk@isil.d.shuttle.de)
|
|||||||
* config.links : Add detection of m68k cpus
|
* config.links : Add detection of m68k cpus
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Copyright 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
Copyright 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||||
|
|
||||||
This file is free software; as a special exception the author gives
|
This file is free software; as a special exception the author gives
|
||||||
@ -407,5 +413,3 @@ Mon Feb 16 13:00:27 1998 Werner Koch (wk@isil.d.shuttle.de)
|
|||||||
This file is distributed in the hope that it will be useful, but
|
This file is distributed in the hope that it will be useful, but
|
||||||
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#define G10_MPI_INLINE_H
|
#define G10_MPI_INLINE_H
|
||||||
|
|
||||||
#ifndef G10_MPI_INLINE_DECL
|
#ifndef G10_MPI_INLINE_DECL
|
||||||
#define G10_MPI_INLINE_DECL extern __inline__
|
#define G10_MPI_INLINE_DECL extern __inline__
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
G10_MPI_INLINE_DECL mpi_limb_t
|
G10_MPI_INLINE_DECL mpi_limb_t
|
||||||
@ -124,5 +124,4 @@ mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size,
|
|||||||
return cy;
|
return cy;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /*G10_MPI_INLINE_H*/
|
#endif /*G10_MPI_INLINE_H*/
|
||||||
|
@ -39,13 +39,13 @@
|
|||||||
* checking a 768 and a 1024 bit ElGamal signature.
|
* checking a 768 and a 1024 bit ElGamal signature.
|
||||||
* (wk 22.12.97) */
|
* (wk 22.12.97) */
|
||||||
#ifndef KARATSUBA_THRESHOLD
|
#ifndef KARATSUBA_THRESHOLD
|
||||||
#define KARATSUBA_THRESHOLD 16
|
#define KARATSUBA_THRESHOLD 16
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
|
/* The code can't handle KARATSUBA_THRESHOLD smaller than 2. */
|
||||||
#if KARATSUBA_THRESHOLD < 2
|
#if KARATSUBA_THRESHOLD < 2
|
||||||
#undef KARATSUBA_THRESHOLD
|
#undef KARATSUBA_THRESHOLD
|
||||||
#define KARATSUBA_THRESHOLD 2
|
#define KARATSUBA_THRESHOLD 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@ -151,8 +151,8 @@ typedef int mpi_size_t; /* (must be a signed type) */
|
|||||||
|
|
||||||
/*-- mpiutil.c --*/
|
/*-- mpiutil.c --*/
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
#define mpi_alloc_limb_space(n,f) mpi_debug_alloc_limb_space((n),(f), M_DBGINFO( __LINE__ ) )
|
#define mpi_alloc_limb_space(n,f) mpi_debug_alloc_limb_space((n),(f), M_DBGINFO( __LINE__ ) )
|
||||||
#define mpi_free_limb_space(n) mpi_debug_free_limb_space((n), M_DBGINFO( __LINE__ ) )
|
#define mpi_free_limb_space(n) mpi_debug_free_limb_space((n), M_DBGINFO( __LINE__ ) )
|
||||||
mpi_ptr_t mpi_debug_alloc_limb_space( unsigned nlimbs, int sec, const char *info );
|
mpi_ptr_t mpi_debug_alloc_limb_space( unsigned nlimbs, int sec, const char *info );
|
||||||
void mpi_debug_free_limb_space( mpi_ptr_t a, const char *info );
|
void mpi_debug_free_limb_space( mpi_ptr_t a, const char *info );
|
||||||
#else
|
#else
|
||||||
@ -253,7 +253,7 @@ mpi_limb_t mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#include "mpi-inline.h"
|
#include "mpi-inline.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /*G10_MPI_INTERNAL_H*/
|
#endif /*G10_MPI_INTERNAL_H*/
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
void
|
void
|
||||||
mpi_invm( MPI x, MPI a, MPI n )
|
mpi_invm( MPI x, MPI a, MPI n )
|
||||||
{
|
{
|
||||||
#if 0
|
#if 0
|
||||||
MPI u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
|
MPI u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3;
|
||||||
MPI ta, tb, tc;
|
MPI ta, tb, tc;
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ mpi_invm( MPI x, MPI a, MPI n )
|
|||||||
mpi_free(t3);
|
mpi_free(t3);
|
||||||
mpi_free(u);
|
mpi_free(u);
|
||||||
mpi_free(v);
|
mpi_free(v);
|
||||||
#elif 0
|
#elif 0
|
||||||
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
|
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
|
||||||
* modified according to Michael Penk's solution for Exercice 35 */
|
* modified according to Michael Penk's solution for Exercice 35 */
|
||||||
|
|
||||||
@ -157,7 +157,7 @@ mpi_invm( MPI x, MPI a, MPI n )
|
|||||||
mpi_free(t1);
|
mpi_free(t1);
|
||||||
mpi_free(t2);
|
mpi_free(t2);
|
||||||
mpi_free(t3);
|
mpi_free(t3);
|
||||||
#else
|
#else
|
||||||
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
|
/* Extended Euclid's algorithm (See TAOPC Vol II, 4.5.2, Alg X)
|
||||||
* modified according to Michael Penk's solution for Exercice 35
|
* modified according to Michael Penk's solution for Exercice 35
|
||||||
* with further enhancement */
|
* with further enhancement */
|
||||||
@ -263,8 +263,5 @@ mpi_invm( MPI x, MPI a, MPI n )
|
|||||||
|
|
||||||
mpi_free(u);
|
mpi_free(u);
|
||||||
mpi_free(v);
|
mpi_free(v);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
|
|||||||
limb = ap[i];
|
limb = ap[i];
|
||||||
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
|
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
|
||||||
if( n == idx ) {
|
if( n == idx ) {
|
||||||
#if BYTES_PER_MPI_LIMB == 4
|
#if BYTES_PER_MPI_LIMB == 4
|
||||||
if( j == 0 )
|
if( j == 0 )
|
||||||
limb = (limb & 0xffffff00) | c;
|
limb = (limb & 0xffffff00) | c;
|
||||||
else if( j == 1 )
|
else if( j == 1 )
|
||||||
@ -76,7 +76,7 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
|
|||||||
limb = (limb & 0xff00ffff) | (c<<16);
|
limb = (limb & 0xff00ffff) | (c<<16);
|
||||||
else
|
else
|
||||||
limb = (limb & 0x00ffffff) | (c<<24);
|
limb = (limb & 0x00ffffff) | (c<<24);
|
||||||
#elif BYTES_PER_MPI_LIMB == 8
|
#elif BYTES_PER_MPI_LIMB == 8
|
||||||
if( j == 0 )
|
if( j == 0 )
|
||||||
limb = (limb & 0xffffffffffffff00) | c;
|
limb = (limb & 0xffffffffffffff00) | c;
|
||||||
else if( j == 1 )
|
else if( j == 1 )
|
||||||
@ -93,9 +93,9 @@ mpi_putbyte( MPI a, unsigned idx, int xc )
|
|||||||
limb = (limb & 0xff00ffffffffffff) | (c<<48);
|
limb = (limb & 0xff00ffffffffffff) | (c<<48);
|
||||||
else
|
else
|
||||||
limb = (limb & 0x00ffffffffffffff) | (c<<56);
|
limb = (limb & 0x00ffffffffffffff) | (c<<56);
|
||||||
#else
|
#else
|
||||||
#error please enhance this function, its ugly - i know.
|
#error please enhance this function, its ugly - i know.
|
||||||
#endif
|
#endif
|
||||||
if( a->nlimbs <= i )
|
if( a->nlimbs <= i )
|
||||||
a->nlimbs = i+1;
|
a->nlimbs = i+1;
|
||||||
ap[i] = limb;
|
ap[i] = limb;
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include "util.h"
|
#include "util.h"
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
#undef mpi_read
|
#undef mpi_read
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_EXTERN_MPI_BITS 16384
|
#define MAX_EXTERN_MPI_BITS 16384
|
||||||
@ -92,13 +92,13 @@ mpi_read(IOBUF inp, unsigned *ret_nread, int secure)
|
|||||||
|
|
||||||
nbytes = (nbits+7) / 8;
|
nbytes = (nbits+7) / 8;
|
||||||
nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
|
nlimbs = (nbytes+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB;
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
val = secure? mpi_debug_alloc_secure( nlimbs, info )
|
val = secure? mpi_debug_alloc_secure( nlimbs, info )
|
||||||
: mpi_debug_alloc( nlimbs, info );
|
: mpi_debug_alloc( nlimbs, info );
|
||||||
#else
|
#else
|
||||||
val = secure? mpi_alloc_secure( nlimbs )
|
val = secure? mpi_alloc_secure( nlimbs )
|
||||||
: mpi_alloc( nlimbs );
|
: mpi_alloc( nlimbs );
|
||||||
#endif
|
#endif
|
||||||
i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
|
i = BYTES_PER_MPI_LIMB - nbytes % BYTES_PER_MPI_LIMB;
|
||||||
i %= BYTES_PER_MPI_LIMB;
|
i %= BYTES_PER_MPI_LIMB;
|
||||||
val->nbits = nbits;
|
val->nbits = nbits;
|
||||||
@ -314,7 +314,7 @@ mpi_get_keyid( MPI a, u32 *keyid )
|
|||||||
}
|
}
|
||||||
return a->nlimbs? (u32)(a->d[0] & 0xffffffff) : 0;
|
return a->nlimbs? (u32)(a->d[0] & 0xffffffff) : 0;
|
||||||
#else
|
#else
|
||||||
#error Make this function work with other LIMB sizes
|
#error Make this function work with other LIMB sizes
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -402,12 +402,12 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
|
|||||||
a->sign = sign;
|
a->sign = sign;
|
||||||
|
|
||||||
for(i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) {
|
for(i=0, p = buffer+nbytes-1; p >= buffer+BYTES_PER_MPI_LIMB; ) {
|
||||||
#if BYTES_PER_MPI_LIMB == 4
|
#if BYTES_PER_MPI_LIMB == 4
|
||||||
alimb = (mpi_limb_t)*p-- ;
|
alimb = (mpi_limb_t)*p-- ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 8 ;
|
alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 16 ;
|
alimb |= (mpi_limb_t)*p-- << 16 ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 24 ;
|
alimb |= (mpi_limb_t)*p-- << 24 ;
|
||||||
#elif BYTES_PER_MPI_LIMB == 8
|
#elif BYTES_PER_MPI_LIMB == 8
|
||||||
alimb = (mpi_limb_t)*p-- ;
|
alimb = (mpi_limb_t)*p-- ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 8 ;
|
alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 16 ;
|
alimb |= (mpi_limb_t)*p-- << 16 ;
|
||||||
@ -416,18 +416,18 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
|
|||||||
alimb |= (mpi_limb_t)*p-- << 40 ;
|
alimb |= (mpi_limb_t)*p-- << 40 ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 48 ;
|
alimb |= (mpi_limb_t)*p-- << 48 ;
|
||||||
alimb |= (mpi_limb_t)*p-- << 56 ;
|
alimb |= (mpi_limb_t)*p-- << 56 ;
|
||||||
#else
|
#else
|
||||||
#error please implement for this limb size.
|
#error please implement for this limb size.
|
||||||
#endif
|
#endif
|
||||||
a->d[i++] = alimb;
|
a->d[i++] = alimb;
|
||||||
}
|
}
|
||||||
if( p >= buffer ) {
|
if( p >= buffer ) {
|
||||||
#if BYTES_PER_MPI_LIMB == 4
|
#if BYTES_PER_MPI_LIMB == 4
|
||||||
alimb = *p-- ;
|
alimb = *p-- ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 24 ;
|
||||||
#elif BYTES_PER_MPI_LIMB == 8
|
#elif BYTES_PER_MPI_LIMB == 8
|
||||||
alimb = (mpi_limb_t)*p-- ;
|
alimb = (mpi_limb_t)*p-- ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 8 ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 16 ;
|
||||||
@ -436,12 +436,11 @@ mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign )
|
|||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 40 ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 48 ;
|
||||||
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ;
|
if( p >= buffer ) alimb |= (mpi_limb_t)*p-- << 56 ;
|
||||||
#else
|
#else
|
||||||
#error please implement for this limb size.
|
#error please implement for this limb size.
|
||||||
#endif
|
#endif
|
||||||
a->d[i++] = alimb;
|
a->d[i++] = alimb;
|
||||||
}
|
}
|
||||||
a->nlimbs = i;
|
a->nlimbs = i;
|
||||||
assert( i == nlimbs );
|
assert( i == nlimbs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,10 +34,10 @@
|
|||||||
#include "longlong.h"
|
#include "longlong.h"
|
||||||
|
|
||||||
#ifndef UMUL_TIME
|
#ifndef UMUL_TIME
|
||||||
#define UMUL_TIME 1
|
#define UMUL_TIME 1
|
||||||
#endif
|
#endif
|
||||||
#ifndef UDIV_TIME
|
#ifndef UDIV_TIME
|
||||||
#define UDIV_TIME UMUL_TIME
|
#define UDIV_TIME UMUL_TIME
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* FIXME: We should be using invert_limb (or invert_normalized_limb)
|
/* FIXME: We should be using invert_limb (or invert_normalized_limb)
|
||||||
@ -533,5 +533,3 @@ mpihelp_divmod_1( mpi_ptr_t quot_ptr,
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,9 +31,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
#undef mpi_alloc
|
#undef mpi_alloc
|
||||||
#undef mpi_alloc_secure
|
#undef mpi_alloc_secure
|
||||||
#undef mpi_free
|
#undef mpi_free
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -54,13 +54,13 @@ mpi_alloc( unsigned nlimbs )
|
|||||||
|
|
||||||
if( DBG_MEMORY )
|
if( DBG_MEMORY )
|
||||||
log_debug("mpi_alloc(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
|
log_debug("mpi_alloc(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
a = m_debug_alloc( sizeof *a, info );
|
a = m_debug_alloc( sizeof *a, info );
|
||||||
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 0, info ) : NULL;
|
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 0, info ) : NULL;
|
||||||
#else
|
#else
|
||||||
a = m_alloc( sizeof *a );
|
a = m_alloc( sizeof *a );
|
||||||
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
|
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL;
|
||||||
#endif
|
#endif
|
||||||
a->alloced = nlimbs;
|
a->alloced = nlimbs;
|
||||||
a->nlimbs = 0;
|
a->nlimbs = 0;
|
||||||
a->sign = 0;
|
a->sign = 0;
|
||||||
@ -87,13 +87,13 @@ mpi_alloc_secure( unsigned nlimbs )
|
|||||||
|
|
||||||
if( DBG_MEMORY )
|
if( DBG_MEMORY )
|
||||||
log_debug("mpi_alloc_secure(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
|
log_debug("mpi_alloc_secure(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
a = m_debug_alloc( sizeof *a, info );
|
a = m_debug_alloc( sizeof *a, info );
|
||||||
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 1, info ) : NULL;
|
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 1, info ) : NULL;
|
||||||
#else
|
#else
|
||||||
a = m_alloc( sizeof *a );
|
a = m_alloc( sizeof *a );
|
||||||
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL;
|
a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL;
|
||||||
#endif
|
#endif
|
||||||
a->alloced = nlimbs;
|
a->alloced = nlimbs;
|
||||||
a->flags = 1;
|
a->flags = 1;
|
||||||
a->nlimbs = 0;
|
a->nlimbs = 0;
|
||||||
@ -121,7 +121,7 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure )
|
|||||||
|
|
||||||
if( DBG_MEMORY )
|
if( DBG_MEMORY )
|
||||||
log_debug("mpi_alloc_limb_space(%u)\n", (unsigned)len*8 );
|
log_debug("mpi_alloc_limb_space(%u)\n", (unsigned)len*8 );
|
||||||
#if 0
|
#if 0
|
||||||
if( !secure ) {
|
if( !secure ) {
|
||||||
if( nlimbs == 5 && unused_limbs_5 ) { /* DSA 160 bits */
|
if( nlimbs == 5 && unused_limbs_5 ) { /* DSA 160 bits */
|
||||||
p = unused_limbs_5;
|
p = unused_limbs_5;
|
||||||
@ -139,13 +139,13 @@ mpi_alloc_limb_space( unsigned nlimbs, int secure )
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
p = secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info );
|
p = secure? m_debug_alloc_secure(len, info):m_debug_alloc( len, info );
|
||||||
#else
|
#else
|
||||||
p = secure? m_alloc_secure( len ):m_alloc( len );
|
p = secure? m_alloc_secure( len ):m_alloc( len );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ mpi_free_limb_space( mpi_ptr_t a )
|
|||||||
if( DBG_MEMORY )
|
if( DBG_MEMORY )
|
||||||
log_debug("mpi_free_limb_space of size %lu\n", (ulong)m_size(a)*8 );
|
log_debug("mpi_free_limb_space of size %lu\n", (ulong)m_size(a)*8 );
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if( !m_is_secure(a) ) {
|
if( !m_is_secure(a) ) {
|
||||||
size_t nlimbs = m_size(a) / 4 ;
|
size_t nlimbs = m_size(a) / 4 ;
|
||||||
void *p = a;
|
void *p = a;
|
||||||
@ -183,8 +183,7 @@ mpi_free_limb_space( mpi_ptr_t a )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
m_free(a);
|
m_free(a);
|
||||||
}
|
}
|
||||||
@ -218,17 +217,17 @@ mpi_resize( MPI a, unsigned nlimbs )
|
|||||||
* and rely on a mpi_is_secure function, which would be
|
* and rely on a mpi_is_secure function, which would be
|
||||||
* a wrapper around m_is_secure
|
* a wrapper around m_is_secure
|
||||||
*/
|
*/
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
if( a->d )
|
if( a->d )
|
||||||
a->d = m_debug_realloc(a->d, nlimbs * sizeof(mpi_limb_t), info );
|
a->d = m_debug_realloc(a->d, nlimbs * sizeof(mpi_limb_t), info );
|
||||||
else
|
else
|
||||||
a->d = m_debug_alloc_clear( nlimbs * sizeof(mpi_limb_t), info );
|
a->d = m_debug_alloc_clear( nlimbs * sizeof(mpi_limb_t), info );
|
||||||
#else
|
#else
|
||||||
if( a->d )
|
if( a->d )
|
||||||
a->d = m_realloc(a->d, nlimbs * sizeof(mpi_limb_t) );
|
a->d = m_realloc(a->d, nlimbs * sizeof(mpi_limb_t) );
|
||||||
else
|
else
|
||||||
a->d = m_alloc_clear( nlimbs * sizeof(mpi_limb_t) );
|
a->d = m_alloc_clear( nlimbs * sizeof(mpi_limb_t) );
|
||||||
#endif
|
#endif
|
||||||
a->alloced = nlimbs;
|
a->alloced = nlimbs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,11 +254,11 @@ mpi_free( MPI a )
|
|||||||
if( a->flags & 4 )
|
if( a->flags & 4 )
|
||||||
m_free( a->d );
|
m_free( a->d );
|
||||||
else {
|
else {
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
mpi_debug_free_limb_space(a->d, info);
|
mpi_debug_free_limb_space(a->d, info);
|
||||||
#else
|
#else
|
||||||
mpi_free_limb_space(a->d);
|
mpi_free_limb_space(a->d);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if( a->flags & ~7 )
|
if( a->flags & ~7 )
|
||||||
log_bug("invalid flag value in mpi\n");
|
log_bug("invalid flag value in mpi\n");
|
||||||
@ -280,18 +279,18 @@ mpi_set_secure( MPI a )
|
|||||||
assert(!ap);
|
assert(!ap);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
bp = mpi_debug_alloc_limb_space( a->nlimbs, 1, "set_secure" );
|
bp = mpi_debug_alloc_limb_space( a->nlimbs, 1, "set_secure" );
|
||||||
#else
|
#else
|
||||||
bp = mpi_alloc_limb_space( a->nlimbs, 1 );
|
bp = mpi_alloc_limb_space( a->nlimbs, 1 );
|
||||||
#endif
|
#endif
|
||||||
MPN_COPY( bp, ap, a->nlimbs );
|
MPN_COPY( bp, ap, a->nlimbs );
|
||||||
a->d = bp;
|
a->d = bp;
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
mpi_debug_free_limb_space(ap, "set_secure");
|
mpi_debug_free_limb_space(ap, "set_secure");
|
||||||
#else
|
#else
|
||||||
mpi_free_limb_space(ap);
|
mpi_free_limb_space(ap);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -299,21 +298,21 @@ MPI
|
|||||||
mpi_set_opaque( MPI a, void *p, int len )
|
mpi_set_opaque( MPI a, void *p, int len )
|
||||||
{
|
{
|
||||||
if( !a ) {
|
if( !a ) {
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
a = mpi_debug_alloc(0,"alloc_opaque");
|
a = mpi_debug_alloc(0,"alloc_opaque");
|
||||||
#else
|
#else
|
||||||
a = mpi_alloc(0);
|
a = mpi_alloc(0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if( a->flags & 4 )
|
if( a->flags & 4 )
|
||||||
m_free( a->d );
|
m_free( a->d );
|
||||||
else {
|
else {
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
mpi_debug_free_limb_space(a->d, "alloc_opaque");
|
mpi_debug_free_limb_space(a->d, "alloc_opaque");
|
||||||
#else
|
#else
|
||||||
mpi_free_limb_space(a->d);
|
mpi_free_limb_space(a->d);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
a->d = p;
|
a->d = p;
|
||||||
@ -357,13 +356,13 @@ mpi_copy( MPI a )
|
|||||||
b = mpi_set_opaque( NULL, p, a->nbits );
|
b = mpi_set_opaque( NULL, p, a->nbits );
|
||||||
}
|
}
|
||||||
else if( a ) {
|
else if( a ) {
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
|
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
|
||||||
: mpi_debug_alloc( a->nlimbs, info );
|
: mpi_debug_alloc( a->nlimbs, info );
|
||||||
#else
|
#else
|
||||||
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
|
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
|
||||||
: mpi_alloc( a->nlimbs );
|
: mpi_alloc( a->nlimbs );
|
||||||
#endif
|
#endif
|
||||||
b->nlimbs = a->nlimbs;
|
b->nlimbs = a->nlimbs;
|
||||||
b->sign = a->sign;
|
b->sign = a->sign;
|
||||||
b->flags = a->flags;
|
b->flags = a->flags;
|
||||||
@ -398,13 +397,13 @@ mpi_alloc_like( MPI a )
|
|||||||
b = mpi_set_opaque( NULL, p, a->nbits );
|
b = mpi_set_opaque( NULL, p, a->nbits );
|
||||||
}
|
}
|
||||||
else if( a ) {
|
else if( a ) {
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
|
b = mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
|
||||||
: mpi_debug_alloc( a->nlimbs, info );
|
: mpi_debug_alloc( a->nlimbs, info );
|
||||||
#else
|
#else
|
||||||
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
|
b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
|
||||||
: mpi_alloc( a->nlimbs );
|
: mpi_alloc( a->nlimbs );
|
||||||
#endif
|
#endif
|
||||||
b->nlimbs = 0;
|
b->nlimbs = 0;
|
||||||
b->sign = 0;
|
b->sign = 0;
|
||||||
b->flags = a->flags;
|
b->flags = a->flags;
|
||||||
@ -449,11 +448,11 @@ mpi_set_ui( MPI w, unsigned long u)
|
|||||||
MPI
|
MPI
|
||||||
mpi_alloc_set_ui( unsigned long u)
|
mpi_alloc_set_ui( unsigned long u)
|
||||||
{
|
{
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
MPI w = mpi_debug_alloc(1,"alloc_set_ui");
|
MPI w = mpi_debug_alloc(1,"alloc_set_ui");
|
||||||
#else
|
#else
|
||||||
MPI w = mpi_alloc(1);
|
MPI w = mpi_alloc(1);
|
||||||
#endif
|
#endif
|
||||||
w->d[0] = u;
|
w->d[0] = u;
|
||||||
w->nlimbs = u? 1:0;
|
w->nlimbs = u? 1:0;
|
||||||
w->sign = 0;
|
w->sign = 0;
|
||||||
@ -468,4 +467,3 @@ mpi_swap( MPI a, MPI b)
|
|||||||
|
|
||||||
tmp = *a; *a = *b; *b = tmp;
|
tmp = *a; *a = *b; *b = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user