1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

added some trust model stuff

This commit is contained in:
Werner Koch 1998-01-16 21:15:24 +00:00
parent 1ce26aa6d6
commit 4ec1775f3e
49 changed files with 1580 additions and 331 deletions

View file

@ -32,8 +32,7 @@
unsigned
mpi_get_nbits( MPI a )
{
unsigned nbits;
unsigned n, count = 0;
unsigned n;
if( a->nlimbs ) {
mpi_limb_t alimb = a->d[a->nlimbs-1];

View file

@ -193,7 +193,7 @@ void mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size );
void mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size,
mpi_ptr_t tspace);
/*-- mpihelp-mul_1.c (or xxx/cpu/*.S) --*/
/*-- mpihelp-mul_1.c (or xxx/cpu/ *.S) --*/
mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr,
mpi_size_t s1_size, mpi_limb_t s2_limb);

View file

@ -52,7 +52,7 @@ mpi_powm( MPI res, MPI base, MPI exp, MPI mod)
mpi_ptr_t xp_marker=NULL;
int assign_rp=0;
mpi_ptr_t tspace = NULL;
mpi_size_t tsize;
mpi_size_t tsize=0; /* to avoid compiler warning, fixme: check */
esize = exp->nlimbs;
msize = mod->nlimbs;

View file

@ -41,36 +41,23 @@
int
mpi_write( IOBUF out, MPI a )
{
int i;
unsigned nbits = a->nlimbs * BITS_PER_MPI_LIMB;
mpi_limb_t limb;
int rc;
unsigned nbits = mpi_get_nbits(a);
byte *p, *buf;
unsigned n;
/* fixme: use a->nbits if valid */
if( nbits > MAX_EXTERN_MPI_BITS )
log_bug("mpi_encode: mpi too large (%u bits)\n", nbits);
iobuf_put(out, (nbits >>8) );
iobuf_put(out, (nbits) );
for(i=a->nlimbs-1; i >= 0; i-- ) {
limb = a->d[i];
#if BYTES_PER_MPI_LIMB == 4
iobuf_put(out, (limb >> 24) );
iobuf_put(out, (limb >> 16) );
iobuf_put(out, (limb >> 8) );
iobuf_put(out, (limb ) );
#elif BYTES_PER_MPI_LIMB == 8
iobuf_put(out, (limb >> 56) );
iobuf_put(out, (limb >> 48) );
iobuf_put(out, (limb >> 40) );
iobuf_put(out, (limb >> 32) );
iobuf_put(out, (limb >> 24) );
iobuf_put(out, (limb >> 16) );
iobuf_put(out, (limb >> 8) );
iobuf_put(out, (limb ) );
#else
#error Make this function work with other LIMB sizes
#endif
}
return 0;
p = buf = mpi_get_buffer( a, &n, NULL );
for( ; !*p && n; p++, n-- )
;
rc = iobuf_write( out, p, n );
m_free(buf);
return rc;
}
@ -225,13 +212,22 @@ mpi_print( FILE *fp, MPI a, int mode )
if( a == MPI_NULL )
return fprintf(fp, "[MPI_NULL]");
if( !mode )
n += fprintf(fp, "[%d bits]", a->nlimbs * BITS_PER_MPI_LIMB );
n += fprintf(fp, "[%u bits]", mpi_get_nbits(a) );
else {
if( a->sign )
putc('-', fp);
#if BYTES_PER_MPI_LIMB == 2
#define X "4"
#elif BYTES_PER_MPI_LIMB == 4
#define X "8"
#elif BYTES_PER_MPI_LIMB == 8
#define X "16"
#else
#error please define the format here
#endif
for(i=a->nlimbs; i > 0 ; i-- ) {
n += fprintf(fp, i!=a->nlimbs? "%0" STR2(BYTES_PER_MPI_LIMB2)
"lX":"%lX", (unsigned long)a->d[i-1] );
n += fprintf(fp, i!=a->nlimbs? "%0" X "lX":"%lX", (ulong)a->d[i-1]);
#undef X
}
if( !a->nlimbs )
putc('0', fp );

View file

@ -45,7 +45,7 @@ mpi_alloc( unsigned nlimbs )
MPI a;
if( DBG_MEMORY )
log_debug("mpi_alloc(%lu)\n", nlimbs*BITS_PER_MPI_LIMB );
log_debug("mpi_alloc(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
#ifdef M_DEBUG
a = m_debug_alloc( sizeof *a, info );
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 0, info ) : NULL;
@ -77,7 +77,7 @@ mpi_alloc_secure( unsigned nlimbs )
MPI a;
if( DBG_MEMORY )
log_debug("mpi_alloc_secure(%lu)\n", nlimbs*BITS_PER_MPI_LIMB );
log_debug("mpi_alloc_secure(%u)\n", nlimbs*BITS_PER_MPI_LIMB );
#ifdef M_DEBUG
a = m_debug_alloc( sizeof *a, info );
a->d = nlimbs? mpi_debug_alloc_limb_space( nlimbs, 1, info ) : NULL;