From 704eb738c063d420fa9643bad9d6f692869603a5 Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Fri, 31 Dec 1999 13:02:40 +0000 Subject: [PATCH] See ChangeLog: Fri Dec 31 14:06:56 CET 1999 Werner Koch --- g10/g10.c | 2 +- g10/seckey-cert.c | 2 +- mpi/ChangeLog | 11 +++++++++++ mpi/mpi-bit.c | 5 +++++ mpi/mpiutil.c | 41 ++++++++++++++++++++++++++++++++++++----- util/memory.c | 2 +- 6 files changed, 55 insertions(+), 8 deletions(-) diff --git a/g10/g10.c b/g10/g10.c index 432b73efd..871f31026 100644 --- a/g10/g10.c +++ b/g10/g10.c @@ -596,7 +596,7 @@ main( int argc, char **argv ) log_set_name("gpg"); /* check that the libraries are suitable. Do it here because * the option parse may need services of the library */ - if ( !gcry_check_version ( "1.1.1" ) ) { + if ( !gcry_check_version ( "1.1.0a" ) ) { log_fatal(_("libgcrypt is too old (need %s, have %s)\n"), VERSION, gcry_check_version(NULL) ); } diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c index 7cacb9f5b..af4110590 100644 --- a/g10/seckey-cert.c +++ b/g10/seckey-cert.c @@ -330,7 +330,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek ) csum += checksum_mpi( sk->skey[i] ); buffer = mpi_get_buffer( sk->skey[i], &nbytes, NULL ); gcry_cipher_sync( cipher_hd ); - assert( !mpi_is_opaque(sk->skey[i]) ); + assert( !gcry_mpi_get_flag( sk->skey[i], GCRYMPI_FLAG_OPAQUE ) ); gcry_cipher_encrypt( cipher_hd, buffer, nbytes, NULL, 0 ); mpi_set_buffer( sk->skey[i], buffer, nbytes, 0 ); m_free( buffer ); diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 2a85de0e2..125fa1a68 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,14 @@ +Fri Dec 31 14:06:56 CET 1999 Werner Koch + + * mpi-bit.c (gcry_mpi_get_nbits): New. + + * mpiutil.c (mpi_set_secure): made static. + (gcry_mpi_get_flag): New. + (gcry_mpi_set_flag): New. + (gcry_mpi_clear_flag): New. + (mpi_set_opaque): renamed to gcry_mpi_set_opaque. + (mpi_get_opaque): renamed to gcry_mpi_get_opaque. + Fri Dec 31 12:48:31 CET 1999 Werner Koch * mpicoder.c (mpi_read_from_buffer): Made static. diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index 45ca029ed..b79505f48 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -90,6 +90,11 @@ mpi_get_nbits( MPI a ) return n; } +unsigned int +gcry_mpi_get_nbits( MPI a ) +{ + return mpi_get_nbits( a ); +} /**************** * Test whether bit N is set. diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index 381db4804..58d06970d 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -159,7 +159,7 @@ mpi_free( MPI a ) g10_free(a); } -void +static void mpi_set_secure( MPI a ) { mpi_ptr_t ap, bp; @@ -180,7 +180,7 @@ mpi_set_secure( MPI a ) MPI -mpi_set_opaque( MPI a, void *p, unsigned int nbits ) +gcry_mpi_set_opaque( MPI a, void *p, unsigned int nbits ) { if( !a ) { a = mpi_alloc(0); @@ -202,7 +202,7 @@ mpi_set_opaque( MPI a, void *p, unsigned int nbits ) void * -mpi_get_opaque( MPI a, unsigned int *nbits ) +gcry_mpi_get_opaque( MPI a, unsigned int *nbits ) { if( !(a->flags & 4) ) log_bug("mpi_get_opaque on normal mpi\n"); @@ -226,7 +226,7 @@ mpi_copy( MPI a ) void *p = g10_is_secure(a->d)? g10_xmalloc_secure( (a->sign+7)/8 ) : g10_xmalloc( (a->sign+7)/8 ); memcpy( p, a->d, (a->sign+7)/8 ); - b = mpi_set_opaque( NULL, p, a->sign ); + b = gcry_mpi_set_opaque( NULL, p, a->sign ); } else if( a ) { b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs ) @@ -258,7 +258,7 @@ mpi_alloc_like( MPI a ) void *p = g10_is_secure(a->d)? g10_malloc_secure( n ) : g10_malloc( n ); memcpy( p, a->d, n ); - b = mpi_set_opaque( NULL, p, a->sign ); + b = gcry_mpi_set_opaque( NULL, p, a->sign ); } else if( a ) { b = mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs ) @@ -389,3 +389,34 @@ gcry_mpi_randomize( GCRY_MPI w, } +void +gcry_mpi_set_flag( GCRY_MPI a, enum gcry_mpi_flag flag ) +{ + switch( flag ) { + case GCRYMPI_FLAG_SECURE: mpi_set_secure(a); break; + case GCRYMPI_FLAG_OPAQUE: + default: log_bug("invalid flag value\n"); + } +} + +void +gcry_mpi_clear_flag( GCRY_MPI a, enum gcry_mpi_flag flag ) +{ + switch( flag ) { + case GCRYMPI_FLAG_SECURE: + case GCRYMPI_FLAG_OPAQUE: + default: log_bug("invalid flag value\n"); + } +} + +int +gcry_mpi_get_flag( GCRY_MPI a, enum gcry_mpi_flag flag ) +{ + switch( flag ) { + case GCRYMPI_FLAG_SECURE: return (a->flags & 1); + case GCRYMPI_FLAG_OPAQUE: return (a->flags & 4); + default: log_bug("invalid flag value\n"); + } +} + + diff --git a/util/memory.c b/util/memory.c index db64ceeaf..fba760f04 100644 --- a/util/memory.c +++ b/util/memory.c @@ -38,7 +38,7 @@ #include "util.h" /* FXIME: ugly hack. Need a prototype here but can't include g10lib.h */ -int g10_private_is_secure( void *p ); +int g10_private_is_secure( const void *p ); #define MAGIC_NOR_BYTE 0x55