diff options
143 files changed, 1417 insertions, 1400 deletions
@@ -1,6 +1,6 @@ -Maintainer: wk@gnupg.org +Maintainer: libgcrypt@g10code.com -Libgcrypt used to be part of GnuPG but has been out into it own +Libgcrypt used to be part of GnuPG but has been take out into its own package on 2000-12-21. @@ -1,3 +1,11 @@ +2001-05-31 Werner Koch <wk@gnupg.org> + + Release 1.1.3. + + * configure.in: Use _gcry_ prefix when creating the cipher constructor. + + * acconfig.h (_GCRYPT_IN_LIBGCRYPT): Define it here. + 2001-05-28 Werner Koch <wk@gnupg.org> * acinclude.m4 (GPH_PROG_DOCBOOK): Removed. @@ -2,7 +2,15 @@ ------------------------------------ Version 1.1 - WARNING: This is work in PROGRESS! + WARNING: This is work in PROGRESS! + +Libgcrypt is a general purpose crypto library based on the code used +in GnuPG. We can't start with a new version number becuase libgcrypt +was part of gnupg 1.1 and some applications already used it and tested +for the version number. We believe that the API can stay as it is, +except that new functions may be added in the future. + +This is a development version, the first stable version will be 1.2.0. @@ -1,7 +1,6 @@ -GnuPG was originally written by Werner Koch. Other people contributed by -reporting problems, suggesting various improvements or submitting actual -code. Here is a list of those people. Help me keep it complete and free of -errors. +Libgcrypt is based on the GnuPG code. Here is a list of people, who +helped in GnuPG and Libgcrypt development. Please help us to keep it +complete and free of errors. Allan Clark allanc@sco.com Anand Kumria wildfire@progsoc.uts.edu.au @@ -30,6 +29,7 @@ Felix von Leitner leitner@amdiv.de Frank Heckenbach heckenb@mi.uni-erlangen.de Frank Stajano frank.stajano@cl.cam.ac.uk Gaël Quéri gqueri@mail.dotcom.fr +Gerlinde Klaes gk@u64.de Greg Louis glouis@dynamicro.on.ca Greg Troxel gdt@ir.bbn.com Gregory Steuck steuck@iname.com @@ -107,9 +107,4 @@ Werner Koch werner.koch@guug.de Wim Vandeputte bunbun@reptile.rug.ac.be nbecker@hns.com -Thanks to the German Unix User Group for providing FTP space, -Martin Hamilton for initially hosting the mailing list, HSP for -hosting gnupg.org and Linux Laptops Ltd. for a nice toy. -Many thanks to my wife Gerlinde for having so much patience with -me while hacking late in the evening. @@ -113,4 +113,7 @@ #include "gcrypt-defs.h" +#define _GCRYPT_IN_LIBGCRYPT 1 + + #endif /*GCRYPT_CONFIG_H*/ diff --git a/cipher/ChangeLog b/cipher/ChangeLog index 59367d4d..fa42f7fa 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,12 @@ +2001-05-31 Werner Koch <wk@gnupg.org> + + * sha1.c (sha1_init): Made static. + + Changed all g10_ prefixed function names as well as some mpi_ + function names to cope with the introduced naming changes. + + * md.c (prepare_macpads): Made key const. + 2001-05-28 Werner Koch <wk@gnupg.org> * rndegd.c (gather_random): Removed the use of tty_printf. diff --git a/cipher/arcfour.c b/cipher/arcfour.c index 18e35fff..a915cb79 100644 --- a/cipher/arcfour.c +++ b/cipher/arcfour.c @@ -1,5 +1,5 @@ /* arcfour.c - The arcfour stream cipher - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * For a description of the algorithm, see: * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996. @@ -135,7 +135,7 @@ selftest(void) * we have redesign the interface. */ const char * -arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, +_gcry_arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey)( void *c, byte *key, unsigned keylen ), void (**r_stencrypt)( void *c, byte *outbuf, @@ -147,7 +147,7 @@ arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, *keylen = 128; /* arbitrary value */ *blocksize = 1; *contextsize = sizeof(ARCFOUR_context); - *(int (**)(ARCFOUR_context*, byte*, unsigned))r_setkey + *(int (**)(ARCFOUR_context*, const byte*, unsigned))r_setkey = arcfour_setkey; *(void (**)(ARCFOUR_context*, byte*, const byte*, unsigned))r_stencrypt = encrypt_stream; diff --git a/cipher/arcfour.h b/cipher/arcfour.h index 64c00b40..ded11df2 100644 --- a/cipher/arcfour.h +++ b/cipher/arcfour.h @@ -1,5 +1,5 @@ /* arcfour.h - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -27,7 +27,7 @@ * we have redesigned the interface. */ const char * -arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, +_gcry_arcfour_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey)( void *c, byte *key, unsigned keylen ), void (**r_stencrypt)( void *c, byte *outbuf, diff --git a/cipher/blowfish.c b/cipher/blowfish.c index 660bdd8a..0847de38 100644 --- a/cipher/blowfish.c +++ b/cipher/blowfish.c @@ -574,7 +574,7 @@ bf_setkey( BLOWFISH_context *c, byte *key, unsigned keylen ) * the ALGO is invalid. */ const char * -blowfish_get_info( int algo, size_t *keylen, +_gcry_blowfish_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey)( void *c, byte *key, unsigned keylen ), void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/blowfish.h b/cipher/blowfish.h index 7e900d41..169b6d38 100644 --- a/cipher/blowfish.h +++ b/cipher/blowfish.h @@ -1,5 +1,5 @@ /* blowfish.h - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -24,7 +24,7 @@ const char * -blowfish_get_info( int algo, size_t *keylen, +_gcry_blowfish_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), @@ -34,7 +34,7 @@ blowfish_get_info( int algo, size_t *keylen, /* this is just a kludge for the time we have not yet chnaged the cipher * stuff to the scheme we use for random and digests */ const char * -twofish_get_info( int algo, size_t *keylen, +_gcry_twofish_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), @@ -44,7 +44,7 @@ twofish_get_info( int algo, size_t *keylen, /* this is just a kludge for the time we have not yet chnaged the cipher * stuff to the scheme we use for random and digests */ const char * -rijndael_get_info( int algo, size_t *keylen, +_gcry_rijndael_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/cast5.c b/cipher/cast5.c index 7aaaf479..9811c455 100644 --- a/cipher/cast5.c +++ b/cipher/cast5.c @@ -600,7 +600,7 @@ cast_setkey( CAST5_context *c, byte *key, unsigned keylen ) * the ALGO is invalid. */ const char * -cast5_get_info( int algo, size_t *keylen, +_gcry_cast5_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey)( void *c, byte *key, unsigned keylen ), void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/cast5.h b/cipher/cast5.h index 75c7a00a..af024d20 100644 --- a/cipher/cast5.h +++ b/cipher/cast5.h @@ -1,5 +1,5 @@ /* cast5.h - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -23,7 +23,7 @@ #include "types.h" const char * -cast5_get_info( int algo, size_t *keylen, +_gcry_cast5_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/cipher.c b/cipher/cipher.c index b3796733..0dfe8661 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -104,7 +104,7 @@ setup_cipher_table(void) i = 0; cipher_table[i].algo = GCRY_CIPHER_RIJNDAEL; - cipher_table[i].name = rijndael_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_rijndael_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -115,7 +115,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_RIJNDAEL192; - cipher_table[i].name = rijndael_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_rijndael_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -126,7 +126,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_RIJNDAEL256; - cipher_table[i].name = rijndael_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_rijndael_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -137,7 +137,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_TWOFISH; - cipher_table[i].name = twofish_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_twofish_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -148,7 +148,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_BLOWFISH; - cipher_table[i].name = blowfish_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_blowfish_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -159,7 +159,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_CAST5; - cipher_table[i].name = cast5_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_cast5_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -170,7 +170,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_3DES; - cipher_table[i].name = des_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_des_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -181,7 +181,7 @@ setup_cipher_table(void) BUG(); i++; cipher_table[i].algo = GCRY_CIPHER_ARCFOUR; - cipher_table[i].name = arcfour_get_info( cipher_table[i].algo, + cipher_table[i].name = _gcry_arcfour_get_info( cipher_table[i].algo, &cipher_table[i].keylen, &cipher_table[i].blocksize, &cipher_table[i].contextsize, @@ -220,7 +220,7 @@ load_cipher_modules(void) int any = 0; if( !initialized ) { - cipher_modules_constructor(); + _gcry_cipher_modules_constructor(); setup_cipher_table(); /* load static modules on the first call */ initialized = 1; return 1; @@ -237,7 +237,7 @@ load_cipher_modules(void) if( ct_idx >= TABLE_SIZE-1 ) BUG(); /* table already full */ /* now load all extensions */ - while( (name = enum_gnupgext_ciphers( &context, &ct->algo, + while( (name = _gcry_enum_gnupgext_ciphers( &context, &ct->algo, &ct->keylen, &ct->blocksize, &ct->contextsize, &ct->setkey, &ct->encrypt, &ct->decrypt)) ) { if( ct->blocksize != 8 && ct->blocksize != 16 ) { @@ -252,7 +252,7 @@ load_cipher_modules(void) continue; } /* put it into the table */ - if( g10_log_verbosity( 2 ) ) + if( _gcry_log_verbosity( 2 ) ) log_info("loaded cipher %d (%s)\n", ct->algo, name); ct->name = name; ct_idx++; @@ -264,7 +264,7 @@ load_cipher_modules(void) break; } } - enum_gnupgext_ciphers( &context, NULL, NULL, NULL, NULL, + _gcry_enum_gnupgext_ciphers( &context, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); return any; } @@ -461,10 +461,10 @@ gcry_cipher_open( int algo, int mode, unsigned int flags ) /* ? perform selftest here and mark this with a flag in cipher_table ? */ - h = secure ? g10_calloc_secure( 1, sizeof *h + h = secure ? gcry_calloc_secure( 1, sizeof *h + cipher_table[idx].contextsize - sizeof(PROPERLY_ALIGNED_TYPE) ) - : g10_calloc( 1, sizeof *h + cipher_table[idx].contextsize + : gcry_calloc( 1, sizeof *h + cipher_table[idx].contextsize - sizeof(PROPERLY_ALIGNED_TYPE) ); if( !h ) { set_lasterr( GCRYERR_NO_MEM ); @@ -491,10 +491,10 @@ gcry_cipher_close( GCRY_CIPHER_HD h ) if( !h ) return; if( h->magic != CTX_MAGIC_SECURE && h->magic != CTX_MAGIC_NORMAL ) - g10_fatal_error(GCRYERR_INTERNAL, + _gcry_fatal_error(GCRYERR_INTERNAL, "gcry_cipher_close: already closed/invalid handle"); h->magic = 0; - g10_free(h); + gcry_free(h); } diff --git a/cipher/des.c b/cipher/des.c index ee5d90e1..f421f395 100644 --- a/cipher/des.c +++ b/cipher/des.c @@ -977,7 +977,7 @@ do_tripledes_decrypt( struct _tripledes_ctx *ctx, byte *outbuf, byte *inbuf ) * the ALGO is invalid. */ const char * -des_get_info( int algo, size_t *keylen, +_gcry_des_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey)( void *c, byte *key, unsigned keylen ), void (**r_encrypt)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/des.h b/cipher/des.h index daf94737..82656453 100644 --- a/cipher/des.h +++ b/cipher/des.h @@ -1,5 +1,5 @@ /* des.h - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -24,7 +24,7 @@ const char * -des_get_info( int algo, size_t *keylen, +_gcry_des_get_info( int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), diff --git a/cipher/dsa.c b/cipher/dsa.c index d91fbafa..8d0faed7 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -1,5 +1,5 @@ /* dsa.c - DSA signature scheme - * Copyright (C) 1998, 2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -57,7 +57,7 @@ static void (*progress_cb) ( void *, int ); static void *progress_cb_data; void -register_pk_dsa_progress ( void (*cb)( void *, int), void *cb_data ) +_gcry_register_pk_dsa_progress ( void (*cb)( void *, int), void *cb_data ) { progress_cb = cb; progress_cb_data = cb_data; @@ -93,7 +93,7 @@ gen_k( MPI q ) progress('.'); if( !rndbuf || nbits < 32 ) { - g10_free(rndbuf); + gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( (nbits+7)/8, GCRY_STRONG_RANDOM ); } @@ -103,9 +103,9 @@ gen_k( MPI q ) * maybe it is easier to do this directly in random.c */ char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM ); memcpy( rndbuf,pp, 4 ); - g10_free(pp); + gcry_free(pp); } - mpi_set_buffer( k, rndbuf, nbytes, 0 ); + _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 ); if( mpi_test_bit( k, nbits-1 ) ) mpi_set_highbit( k, nbits-1 ); else { @@ -125,7 +125,7 @@ gen_k( MPI q ) } break; /* okay */ } - g10_free(rndbuf); + gcry_free(rndbuf); if( DBG_CIPHER ) progress('\n'); @@ -178,7 +178,7 @@ generate( DSA_secret_key *sk, unsigned nbits, MPI **ret_factors ) assert( nbits >= 512 && nbits <= 1024 ); qbits = 160; - p = generate_elg_prime( 1, nbits, qbits, NULL, ret_factors ); + p = _gcry_generate_elg_prime( 1, nbits, qbits, NULL, ret_factors ); /* get q out of factors */ q = mpi_copy((*ret_factors)[0]); if( mpi_get_nbits(q) != qbits ) @@ -217,12 +217,12 @@ generate( DSA_secret_key *sk, unsigned nbits, MPI **ret_factors ) char *r = gcry_random_bytes_secure( 2, GCRY_VERY_STRONG_RANDOM ); memcpy(rndbuf, r, 2 ); - g10_free(r); + gcry_free(r); } - mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 ); + _gcry_mpi_set_buffer( x, rndbuf, (qbits+7)/8, 0 ); mpi_clear_highbit( x, qbits+1 ); } while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, h )<0 ) ); - g10_free(rndbuf); + gcry_free(rndbuf); mpi_free( e ); mpi_free( h ); @@ -357,7 +357,7 @@ verify(MPI r, MPI s, MPI hash, DSA_public_key *pkey ) *********************************************/ int -dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) +_gcry_dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) { DSA_secret_key sk; @@ -375,7 +375,7 @@ dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) int -dsa_check_secret_key( int algo, MPI *skey ) +_gcry_dsa_check_secret_key( int algo, MPI *skey ) { DSA_secret_key sk; @@ -398,7 +398,7 @@ dsa_check_secret_key( int algo, MPI *skey ) int -dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) +_gcry_dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) { DSA_secret_key sk; @@ -419,7 +419,7 @@ dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) } int -dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, +_gcry_dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *, MPI), void *opaquev ) { DSA_public_key pk; @@ -441,8 +441,8 @@ dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, -unsigned -dsa_get_nbits( int algo, MPI *pkey ) +unsigned int +_gcry_dsa_get_nbits( int algo, MPI *pkey ) { if( algo != PUBKEY_ALGO_DSA ) return 0; @@ -459,7 +459,7 @@ dsa_get_nbits( int algo, MPI *pkey ) * 1 set : allows encryption */ const char * -dsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, +_gcry_dsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use ) { *npkey = 4; diff --git a/cipher/dsa.h b/cipher/dsa.h index 6a5ad731..c0149e34 100644 --- a/cipher/dsa.h +++ b/cipher/dsa.h @@ -1,5 +1,5 @@ /* dsa.h - DSA signature scheme - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -20,13 +20,13 @@ #ifndef G10_DSA_H #define G10_DSA_H -int dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); -int dsa_check_secret_key( int algo, MPI *skey ); -int dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ); -int dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, +int _gcry_dsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); +int _gcry_dsa_check_secret_key( int algo, MPI *skey ); +int _gcry_dsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ); +int _gcry_dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *, MPI), void *opaquev ); -unsigned dsa_get_nbits( int algo, MPI *pkey ); -const char *dsa_get_info( int algo, int *npkey, int *nskey, +unsigned _gcry_dsa_get_nbits( int algo, MPI *pkey ); +const char *_gcry_dsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use ); #endif /*G10_DSA_H*/ diff --git a/cipher/dynload.c b/cipher/dynload.c index 43f230a2..ad4279cd 100644 --- a/cipher/dynload.c +++ b/cipher/dynload.c @@ -1,5 +1,5 @@ /* dynload.c - load cipher extensions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -129,7 +129,7 @@ cmp_filenames( const char *a, const char *b ) * it is only used in some environments. */ void -register_cipher_extension( const char *mainpgm, const char *fname ) +_gcry_register_cipher_extension( const char *mainpgm, const char *fname ) { EXTLIST r, el, intex; char *p, *pe; @@ -138,7 +138,7 @@ register_cipher_extension( const char *mainpgm, const char *fname ) if( !mainpgm_path && mainpgm && *mainpgm ) mainpgm_path = m_strdup(mainpgm); #endif - el = g10_xcalloc( 1, sizeof *el + strlen(fname) ); + el = gcry_xcalloc( 1, sizeof *el + strlen(fname) ); strcpy(el->name, fname ); /* check whether we have a class hint */ @@ -154,7 +154,7 @@ register_cipher_extension( const char *mainpgm, const char *fname ) for(r = extensions; r; r = r->next ) { if( !cmp_filenames(r->name, el->name) ) { log_info("extension `%s' already registered\n", el->name ); - g10_free(el); + gcry_free(el); return; } else if( r->internal ) @@ -175,14 +175,14 @@ register_cipher_extension( const char *mainpgm, const char *fname ) } void -register_internal_cipher_extension( +_gcry_register_internal_cipher_extension( const char *module_id, void * (*enumfunc)(int, int*, int*, int*) ) { EXTLIST r, el; - el = g10_xcalloc( 1, sizeof *el + strlen(module_id) ); + el = gcry_xcalloc( 1, sizeof *el + strlen(module_id) ); strcpy(el->name, module_id ); el->internal = 1; @@ -190,7 +190,7 @@ register_internal_cipher_extension( for(r = extensions; r; r = r->next ) { if( !cmp_filenames(r->name, el->name) ) { log_info("extension `%s' already registered\n", el->name ); - g10_free(el); + gcry_free(el); return; } } @@ -270,7 +270,7 @@ load_extension( EXTLIST el ) name = (char**)addr; #endif - if( g10_log_verbosity( 2 ) ) + if( _gcry_log_verbosity( 2 ) ) log_info("%s: %s%s%s%s\n", el->name, *name, el->hintstr? " (":"", el->hintstr? el->hintstr:"", @@ -301,7 +301,7 @@ load_extension( EXTLIST el ) #endif #ifdef HAVE_DL_DLOPEN - if( g10_log_verbosity( 3 ) ) { + if( _gcry_log_verbosity( 3 ) ) { /* list the contents of the module */ while( (sym = (*el->enumfunc)(0, &seq, &class, &vers)) ) { if( vers != 1 ) { @@ -341,7 +341,7 @@ load_extension( EXTLIST el ) int -enum_gnupgext_digests( void **enum_context, +_gcry_enum_gnupgext_digests( void **enum_context, int *algo, const char *(**r_get_info)( int, size_t*,byte**, int*, int*, void (**)(void*), @@ -352,13 +352,13 @@ enum_gnupgext_digests( void **enum_context, ENUMCONTEXT *ctx; if( !*enum_context ) { /* init context */ - ctx = g10_xcalloc( 1, sizeof( *ctx ) ); + ctx = gcry_xcalloc( 1, sizeof( *ctx ) ); ctx->r = extensions; ctx->reqalgo = *algo; *enum_context = ctx; } else if( !algo ) { /* release the context */ - g10_free(*enum_context); + gcry_free(*enum_context); *enum_context = NULL; return 0; } @@ -398,7 +398,7 @@ enum_gnupgext_digests( void **enum_context, } const char * -enum_gnupgext_ciphers( void **enum_context, int *algo, +_gcry_enum_gnupgext_ciphers( void **enum_context, int *algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), @@ -413,12 +413,12 @@ enum_gnupgext_ciphers( void **enum_context, int *algo, void (**)( void *, byte *, byte *)); if( !*enum_context ) { /* init context */ - ctx = g10_xcalloc( 1, sizeof( *ctx ) ); + ctx = gcry_xcalloc( 1, sizeof( *ctx ) ); ctx->r = extensions; *enum_context = ctx; } else if( !algo ) { /* release the context */ - g10_free(*enum_context); + gcry_free(*enum_context); *enum_context = NULL; return NULL; } @@ -463,7 +463,7 @@ enum_gnupgext_ciphers( void **enum_context, int *algo, } const char * -enum_gnupgext_pubkeys( void **enum_context, int *algo, +_gcry_enum_gnupgext_pubkeys( void **enum_context, int *algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use, int (**generate)( int algo, unsigned nbits, MPI *skey, MPI **retfactors ), int (**check_secret_key)( int algo, MPI *skey ), @@ -487,12 +487,12 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo, unsigned (**)( int , MPI * ) ); if( !*enum_context ) { /* init context */ - ctx = g10_xcalloc( 1, sizeof( *ctx ) ); + ctx = gcry_xcalloc( 1, sizeof( *ctx ) ); ctx->r = extensions; *enum_context = ctx; } else if( !algo ) { /* release the context */ - g10_free(*enum_context); + gcry_free(*enum_context); *enum_context = NULL; return NULL; } @@ -538,7 +538,7 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo, int (* -dynload_getfnc_gather_random())(void (*)(const void*, size_t, int), int, +_gcry_dynload_getfnc_gather_random())(void (*)(const void*, size_t, int), int, size_t, int) { EXTLIST r; @@ -564,7 +564,7 @@ dynload_getfnc_gather_random())(void (*)(const void*, size_t, int), int, void (* -dynload_getfnc_fast_random_poll())( void (*)(const void*, size_t, int), int) +_gcry_dynload_getfnc_fast_random_poll())( void (*)(const void*, size_t, int), int) { EXTLIST r; void *sym; diff --git a/cipher/dynload.h b/cipher/dynload.h index bd572efc..bdfef9d7 100644 --- a/cipher/dynload.h +++ b/cipher/dynload.h @@ -1,5 +1,5 @@ -/* dynload.5 - * Copyright (C) 1998 Free Software Foundation, Inc. +/* dynload.h + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -23,11 +23,11 @@ #include "mpi.h" -void register_internal_cipher_extension( const char *module_id, +void _gcry_register_internal_cipher_extension( const char *module_id, void * (*enumfunc)(int, int*, int*, int*) ); int -enum_gnupgext_digests( void **enum_context, +_gcry_enum_gnupgext_digests( void **enum_context, int *algo, const char *(**r_get_info)( int, size_t*,byte**, int*, int*, void (**)(void*), @@ -35,7 +35,7 @@ enum_gnupgext_digests( void **enum_context, void (**)(void*),byte *(**)(void*)) ); const char * -enum_gnupgext_ciphers( void **enum_context, int *algo, +_gcry_enum_gnupgext_ciphers( void **enum_context, int *algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**setkeyf)( void *c, byte *key, unsigned keylen ), void (**encryptf)( void *c, byte *outbuf, byte *inbuf ), @@ -44,7 +44,7 @@ enum_gnupgext_ciphers( void **enum_context, int *algo, const char * -enum_gnupgext_pubkeys( void **enum_context, int *algo, +_gcry_enum_gnupgext_pubkeys( void **enum_context, int *algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use, int (**generate)( int algo, unsigned nbits, MPI *skey, MPI **retfactors ), int (**check_secret_key)( int algo, MPI *skey ), @@ -56,13 +56,13 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo, unsigned (**get_nbits)( int algo, MPI *pkey ) ); -int (*dynload_getfnc_gather_random(void))( void (*)(const void*, size_t, int), +int (*_gcry_dynload_getfnc_gather_random(void))( void (*)(const void*, size_t, int), int, size_t, int); -void (*dynload_getfnc_fast_random_poll(void) +void (*_gcry_dynload_getfnc_fast_random_poll(void) )( void (*)(const void*, size_t, int), int ); /** This function is in construct.c **/ -void cipher_modules_constructor(void); +void _gcry_cipher_modules_constructor(void); #endif /*G10_CIPHER_DYNLOAD_H*/ diff --git a/cipher/elgamal.c b/cipher/elgamal.c index 253edae8..60a3ccda 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -1,5 +1,5 @@ /* elgamal.c - ElGamal Public Key encryption - * Copyright (C) 1998, 2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. * * For a description of the algorithm, see: * Bruce Schneier: Applied Cryptography. John Wiley & Sons, 1996. @@ -60,7 +60,7 @@ static void (*progress_cb) ( void *, int ); static void *progress_cb_data; void -register_pk_elg_progress ( void (*cb)( void *, int), void *cb_data ) +_gcry_register_pk_elg_progress ( void (*cb)( void *, int), void *cb_data ) { progress_cb = cb; progress_cb_data = cb_data; @@ -176,7 +176,7 @@ gen_k( MPI p ) mpi_sub_ui( p_1, p, 1); for(;;) { if( !rndbuf || nbits < 32 ) { - g10_free(rndbuf); + gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( nbytes, GCRY_STRONG_RANDOM ); } else { /* change only some of the higher bits */ @@ -187,10 +187,10 @@ gen_k( MPI p ) */ char *pp = gcry_random_bytes_secure( 4, GCRY_STRONG_RANDOM ); memcpy( rndbuf, pp, 4 ); - g10_free(pp); + gcry_free(pp); log_debug("gen_k: tsss, never expected to reach this\n"); } - mpi_set_buffer( k, rndbuf, nbytes, 0 ); + _gcry_mpi_set_buffer( k, rndbuf, nbytes, 0 ); for(;;) { /* Hmm, actually we don't need this step here @@ -206,7 +206,7 @@ gen_k( MPI p ) progress('-'); break; /* no */ } - if( mpi_gcd( temp, k, p_1 ) ) + if( gcry_mpi_gcd( temp, k, p_1 ) ) goto found; /* okay, k is relatively prime to (p-1) */ mpi_add_ui( k, k, 1 ); if( DBG_CIPHER ) @@ -214,7 +214,7 @@ gen_k( MPI p ) } } found: - g10_free(rndbuf); + gcry_free(rndbuf); if( DBG_CIPHER ) progress('\n'); mpi_free(p_1); @@ -247,7 +247,7 @@ generate( ELG_secret_key *sk, unsigned int nbits, MPI **ret_factors ) if( qbits & 1 ) /* better have a even one */ qbits++; g = mpi_alloc(1); - p = generate_elg_prime( 0, nbits, qbits, g, ret_factors ); + p = _gcry_generate_elg_prime( 0, nbits, qbits, g, ret_factors ); mpi_sub_ui(p_min1, p, 1); @@ -274,7 +274,7 @@ generate( ELG_secret_key *sk, unsigned int nbits, MPI **ret_factors ) progress('.'); if( rndbuf ) { /* change only some of the higher bits */ if( xbits < 16 ) {/* should never happen ... */ - g10_free(rndbuf); + gcry_free(rndbuf); rndbuf = gcry_random_bytes_secure( (xbits+7)/8, GCRY_VERY_STRONG_RANDOM ); } @@ -282,17 +282,17 @@ generate( ELG_secret_key *sk, unsigned int nbits, MPI **ret_factors ) char *r = gcry_random_bytes_secure( 2, GCRY_VERY_STRONG_RANDOM ); memcpy(rndbuf, r, 2 ); - g10_free(r); + gcry_free(r); } } else { rndbuf = gcry_random_bytes_secure( (xbits+7)/8, GCRY_VERY_STRONG_RANDOM ); } - mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 ); + _gcry_mpi_set_buffer( x, rndbuf, (xbits+7)/8, 0 ); mpi_clear_highbit( x, xbits+1 ); } while( !( mpi_cmp_ui( x, 0 )>0 && mpi_cmp( x, p_min1 )<0 ) ); - g10_free(rndbuf); + gcry_free(rndbuf); y = gcry_mpi_new (nbits); gcry_mpi_powm( y, g, x, p ); @@ -354,7 +354,7 @@ do_encrypt(MPI a, MPI b, MPI input, ELG_public_key *pkey ) * = ((y^k mod p) * input) mod p */ gcry_mpi_powm( b, pkey->y, k, pkey->p ); - mpi_mulm( b, b, input, pkey->p ); + gcry_mpi_mulm( b, b, input, pkey->p ); #if 0 if( DBG_CIPHER ) { log_mpidump("elg encrypted y= ", pkey->y); @@ -499,7 +499,7 @@ verify(MPI a, MPI b, MPI input, ELG_public_key *pkey ) *********************************************/ int -elg_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) +_gcry_elg_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) { ELG_secret_key sk; @@ -516,7 +516,7 @@ elg_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) int -elg_check_secret_key( int algo, MPI *skey ) +_gcry_elg_check_secret_key( int algo, MPI *skey ) { ELG_secret_key sk; @@ -538,7 +538,7 @@ elg_check_secret_key( int algo, MPI *skey ) int -elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) +_gcry_elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) { ELG_public_key pk; @@ -557,7 +557,7 @@ elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) } int -elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) +_gcry_elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) { ELG_secret_key sk; @@ -577,7 +577,7 @@ elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) } int -elg_sign( int algo, MPI *resarr, MPI data, MPI *skey ) +_gcry_elg_sign( int algo, MPI *resarr, MPI data, MPI *skey ) { ELG_secret_key sk; @@ -597,7 +597,7 @@ elg_sign( int algo, MPI *resarr, MPI data, MPI *skey ) } int -elg_verify( int algo, MPI hash, MPI *data, MPI *pkey, +_gcry_elg_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *, MPI), void *opaquev ) { ELG_public_key pk; @@ -619,7 +619,7 @@ elg_verify( int algo, MPI hash, MPI *data, MPI *pkey, unsigned int -elg_get_nbits( int algo, MPI *pkey ) +_gcry_elg_get_nbits( int algo, MPI *pkey ) { if( !is_ELGAMAL(algo) ) return 0; @@ -639,7 +639,7 @@ elg_get_nbits( int algo, MPI *pkey ) * is done in the gnupg ocde depending on the packet version. */ const char * -elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, +_gcry_elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use ) { *npkey = 3; diff --git a/cipher/elgamal.h b/cipher/elgamal.h index deeea230..1b73d7c3 100644 --- a/cipher/elgamal.h +++ b/cipher/elgamal.h @@ -1,5 +1,5 @@ /* elgamal.h - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -20,15 +20,15 @@ #ifndef G10_ELGAMAL_H #define G10_ELGAMAL_H -int elg_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); -int elg_check_secret_key( int algo, MPI *skey ); -int elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ); -int elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey ); -int elg_sign( int algo, MPI *resarr, MPI data, MPI *skey ); -int elg_verify( int algo, MPI hash, MPI *data, MPI *pkey, +int _gcry_elg_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); +int _gcry_elg_check_secret_key( int algo, MPI *skey ); +int _gcry_elg_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ); +int _gcry_elg_decrypt( int algo, MPI *result, MPI *data, MPI *skey ); +int _gcry_elg_sign( int algo, MPI *resarr, MPI data, MPI *skey ); +int _gcry_elg_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *, MPI), void *opaquev ); -unsigned elg_get_nbits( int algo, MPI *pkey ); -const char *elg_get_info( int algo, int *npkey, int *nskey, +unsigned _gcry_elg_get_nbits( int algo, MPI *pkey ); +const char *_gcry_elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use ); diff --git a/cipher/md.c b/cipher/md.c index 1a26717e..99c4cfa1 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -92,13 +92,13 @@ new_list_item( int algo, { struct md_digest_list_s *r; - r = g10_xcalloc( 1, sizeof *r ); + r = gcry_xcalloc( 1, sizeof *r ); r->algo = algo, r->name = (*get_info)( algo, &r->contextsize, &r->asnoid, &r->asnlen, &r->mdlen, &r->init, &r->write, &r->final, &r->read ); if( !r->name ) { - g10_free(r); + gcry_free(r); r = NULL; } return r; @@ -127,7 +127,7 @@ load_digest_module( int req_algo ) void (**)(void*),byte *(**)(void*)); if( !initialized ) { - cipher_modules_constructor(); + _gcry_cipher_modules_constructor(); initialized = 1; } algo = req_algo; @@ -142,7 +142,7 @@ load_digest_module( int req_algo ) else checked_algos[algo/32] |= (1 << (algo%32)); - while( enum_gnupgext_digests( &context, &algo, &get_info ) ) { + while( _gcry_enum_gnupgext_digests( &context, &algo, &get_info ) ) { if( req_algo != -1 && algo != req_algo ) continue; for(r=digest_list; r; r = r->next ) @@ -158,7 +158,7 @@ load_digest_module( int req_algo ) continue; } /* put it into the list */ - if( g10_log_verbosity( 2 ) ) + if( _gcry_log_verbosity( 2 ) ) log_info("loaded digest %d\n", algo); r->next = digest_list; digest_list = r; @@ -166,7 +166,7 @@ load_digest_module( int req_algo ) if( req_algo != -1 ) break; } - enum_gnupgext_digests( &context, NULL, NULL ); + _gcry_enum_gnupgext_digests( &context, NULL, NULL ); return any; } @@ -266,8 +266,8 @@ md_open( int algo, int secure, int hmac ) / sizeof(PROPERLY_ALIGNED_TYPE) ) * sizeof(PROPERLY_ALIGNED_TYPE); /* allocate and set the Context pointer to the private data */ - hd = secure ? g10_malloc_secure( n + sizeof( struct gcry_md_context ) ) - : g10_malloc( n + sizeof( struct gcry_md_context ) ); + hd = secure ? gcry_malloc_secure( n + sizeof( struct gcry_md_context ) ) + : gcry_malloc( n + sizeof( struct gcry_md_context ) ); if( !hd ) { set_lasterr( GCRYERR_NO_MEM ); return NULL; @@ -282,7 +282,7 @@ md_open( int algo, int secure, int hmac ) ctx->magic = secure ? CTX_MAGIC_SECURE : CTX_MAGIC_NORMAL; ctx->secure = secure; if( hmac ) { - ctx->macpads = g10_malloc_secure( 128 ); + ctx->macpads = gcry_malloc_secure( 128 ); if( !ctx->macpads ) { md_close( hd ); set_lasterr( GCRYERR_NO_MEM ); @@ -331,9 +331,9 @@ md_enable( GCRY_MD_HD hd, int algo ) return set_lasterr( GCRYERR_INV_MD_ALGO ); } /* and allocate a new list entry */ - ac = h->secure? g10_malloc_secure( sizeof *ac + r->contextsize + ac = h->secure? gcry_malloc_secure( sizeof *ac + r->contextsize - sizeof(r->context) ) - : g10_malloc( sizeof *ac + r->contextsize + : gcry_malloc( sizeof *ac + r->contextsize - sizeof(r->context) ); if( !ac ) return set_lasterr( GCRYERR_NO_MEM ); @@ -366,8 +366,8 @@ md_copy( GCRY_MD_HD ahd ) md_write( ahd, NULL, 0 ); n = (char*)ahd->ctx - (char*)ahd; - bhd = a->secure ? g10_malloc_secure( n + sizeof( struct gcry_md_context ) ) - : g10_malloc( n + sizeof( struct gcry_md_context ) ); + bhd = a->secure ? gcry_malloc_secure( n + sizeof( struct gcry_md_context ) ) + : gcry_malloc( n + sizeof( struct gcry_md_context ) ); if( !bhd ) { set_lasterr( GCRYERR_NO_MEM ); return NULL; @@ -382,15 +382,15 @@ md_copy( GCRY_MD_HD ahd ) b->list = NULL; b->debug = NULL; if( a->macpads ) { - b->macpads = g10_malloc_secure( 128 ); + b->macpads = gcry_malloc_secure( 128 ); memcpy( b->macpads, a->macpads, 128 ); } /* and now copy the complete list of algorithms */ /* I know that the copied list is reversed, but that doesn't matter */ for( ar=a->list; ar; ar = ar->next ) { - br = a->secure ? g10_xmalloc_secure( sizeof *br + ar->contextsize + br = a->secure ? gcry_xmalloc_secure( sizeof *br + ar->contextsize - sizeof(ar->context) ) - : g10_xmalloc( sizeof *br + ar->contextsize + : gcry_xmalloc( sizeof *br + ar->contextsize - sizeof(ar->context) ); memcpy( br, ar, sizeof(*br) + ar->contextsize - sizeof(ar->context) ); @@ -440,10 +440,10 @@ md_close(GCRY_MD_HD a) md_stop_debug(a); for(r=a->ctx->list; r; r = r2 ) { r2 = r->next; - g10_free(r); + gcry_free(r); } - g10_free(a->ctx->macpads); - g10_free(a); + gcry_free(a->ctx->macpads); + gcry_free(a); } @@ -504,7 +504,7 @@ md_final(GCRY_MD_HD a) GCRY_MD_HD om = md_open( algo, a->ctx->secure, 0 ); if( !om ) - g10_fatal_error( gcry_errno(), NULL ); + _gcry_fatal_error( gcry_errno(), NULL ); md_write( om, a->ctx->macpads+64, 64 ); md_write( om, p, dlen ); md_final( om ); @@ -517,7 +517,7 @@ md_final(GCRY_MD_HD a) static int -prepare_macpads( GCRY_MD_HD hd, byte *key, size_t keylen) +prepare_macpads( GCRY_MD_HD hd, const byte *key, size_t keylen) { int i; int algo = md_get_algo( hd ); @@ -528,7 +528,7 @@ prepare_macpads( GCRY_MD_HD hd, byte *key, size_t keylen) return GCRYERR_INV_MD_ALGO; /* i.e. no algo enabled */ if( keylen > 64 ) { - helpkey = g10_malloc_secure( md_digest_length( algo ) ); + helpkey = gcry_malloc_secure( md_digest_length( algo ) ); if( !helpkey ) return GCRYERR_NO_MEM; gcry_md_hash_buffer( algo, helpkey, key, keylen ); @@ -546,7 +546,7 @@ prepare_macpads( GCRY_MD_HD hd, byte *key, size_t keylen) ipad[i] ^= 0x36; opad[i] ^= 0x5c; } - g10_free( helpkey ); + gcry_free( helpkey ); return 0; } @@ -658,8 +658,8 @@ md_digest( GCRY_MD_HD a, int algo, byte *buffer, int buflen ) /* I don't want to change the interface, so I simply work on a copy * of the context (extra overhead - should be fixed)*/ - context = a->ctx->secure ? g10_xmalloc_secure( r->contextsize ) - : g10_xmalloc( r->contextsize ); + context = a->ctx->secure ? gcry_xmalloc_secure( r->contextsize ) + : gcry_xmalloc( r->contextsize ); memcpy( context, r->context.c, r->contextsize ); (*r->final)( context ); digest = (*r->read)( context ); @@ -668,7 +668,7 @@ md_digest( GCRY_MD_HD a, int algo, byte *buffer, int buflen ) buflen = r->mdlen; memcpy( buffer, digest, buflen ); - g10_free(context); + gcry_free(context); return buflen; } #endif @@ -694,7 +694,7 @@ void gcry_md_hash_buffer( int algo, char *digest, const char *buffer, size_t length) { if( algo == GCRY_MD_RMD160 ) - rmd160_hash_buffer( digest, buffer, length ); + _gcry_rmd160_hash_buffer( digest, buffer, length ); else { /* for the others we do not have a fast function, so * we use the normal functions to do it */ GCRY_MD_HD h = md_open( algo, 0, 0 ); diff --git a/cipher/md5.c b/cipher/md5.c index f7cc2ed1..60b12270 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -1,5 +1,5 @@ /* md5.c - MD5 Message-Digest Algorithm - * Copyright (C) 1995, 1996, 1998, 1999 Free Software Foundation, Inc. + * Copyright (C) 1995, 1996, 1998, 1999, 2001 Free Software Foundation, Inc. * * according to the definition of MD5 in RFC 1321 from April 1992. * NOTE: This is *not* the same file as the one from glibc. @@ -400,9 +400,9 @@ gnupgext_enum_func( int what, int *sequence, int *class, int *vers ) #ifndef IS_MODULE void -md5_constructor(void) +_gcry_md5_constructor(void) { - register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); + _gcry_register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); } #endif diff --git a/cipher/primegen.c b/cipher/primegen.c index 1469c002..da8b01f5 100644 --- a/cipher/primegen.c +++ b/cipher/primegen.c @@ -1,5 +1,5 @@ /* primegen.c - prime number generator - * Copyright (C) 1998, 2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -42,7 +42,7 @@ static void (*progress_cb) ( void *, int ); static void *progress_cb_data; void -register_primegen_progress ( void (*cb)( void *, int), void *cb_data ) +_gcry_register_primegen_progress ( void (*cb)( void *, int), void *cb_data ) { progress_cb = cb; progress_cb_data = cb_data; @@ -63,7 +63,7 @@ progress( int c ) * Generate a prime number (stored in secure memory) */ MPI -generate_secret_prime( unsigned nbits ) +_gcry_generate_secret_prime( unsigned nbits ) { MPI prime; @@ -73,7 +73,7 @@ generate_secret_prime( unsigned nbits ) } MPI -generate_public_prime( unsigned nbits ) +_gcry_generate_public_prime( unsigned nbits ) { MPI prime; @@ -93,7 +93,7 @@ generate_public_prime( unsigned nbits ) * 1: Make sure that at least one factor is of size qbits. */ MPI -generate_elg_prime( int mode, unsigned pbits, unsigned qbits, +_gcry_generate_elg_prime( int mode, unsigned pbits, unsigned qbits, MPI g, MPI **ret_factors ) { int n; /* number of factors */ @@ -134,7 +134,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, q_factor = mode==1? gen_prime( req_qbits, 0, 0 ) : NULL; /* allocate an array to hold the factors + 2 for later usage */ - factors = g10_xcalloc( n+2, sizeof *factors ); + factors = gcry_xcalloc( n+2, sizeof *factors ); /* make a pool of 3n+5 primes (this is an arbitrary value) */ m = n*3+5; @@ -142,7 +142,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, m += 5; /* need some more for DSA */ if( m < 25 ) m = 25; - pool = g10_xcalloc( m , sizeof *pool ); + pool = gcry_xcalloc( m , sizeof *pool ); /* permutate over the pool of primes */ count1=count2=0; @@ -155,7 +155,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, pool[i] = NULL; } /* init m_out_of_n() */ - perms = g10_xcalloc( 1, m ); + perms = gcry_xcalloc( 1, m ); for(i=0; i < n; i++ ) { perms[i] = 1; pool[i] = gen_prime( fbits, 0, 1 ); @@ -171,7 +171,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, factors[j++] = pool[i]; } if( i == n ) { - g10_free(perms); perms = NULL; + gcry_free(perms); perms = NULL; progress('!'); goto next_try; /* allocate new primes */ } @@ -226,7 +226,7 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, } if( ret_factors ) { /* caller wants the factors */ - *ret_factors = g10_xcalloc( n+2 , sizeof **ret_factors); + *ret_factors = gcry_xcalloc( n+2 , sizeof **ret_factors); if( mode == 1 ) { i = 0; (*ret_factors)[i++] = mpi_copy( q_factor ); @@ -278,11 +278,11 @@ generate_elg_prime( int mode, unsigned pbits, unsigned qbits, if( !DBG_CIPHER ) progress('\n'); - g10_free( factors ); /* (factors are shallow copies) */ + gcry_free( factors ); /* (factors are shallow copies) */ for(i=0; i < m; i++ ) mpi_free( pool[i] ); - g10_free( pool ); - g10_free(perms); + gcry_free( pool ); + gcry_free(perms); mpi_free(val_2); return prime; } @@ -305,7 +305,7 @@ gen_prime( unsigned nbits, int secret, int randomlevel ) for(i=0; small_prime_numbers[i]; i++ ) no_of_small_prime_numbers++; } - mods = g10_xmalloc( no_of_small_prime_numbers * sizeof *mods ); + mods = gcry_xmalloc( no_of_small_prime_numbers * sizeof *mods ); /* make nbits fit into MPI implementation */ val_2 = mpi_alloc_set_ui( 2 ); val_3 = mpi_alloc_set_ui( 3); @@ -361,7 +361,7 @@ gen_prime( unsigned nbits, int secret, int randomlevel ) mpi_free(result); mpi_free(pminus1); mpi_free(prime); - g10_free(mods); + gcry_free(mods); return ptest; } } diff --git a/cipher/pubkey.c b/cipher/pubkey.c index 68004ed8..a8fb88d7 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -143,105 +143,105 @@ setup_pubkey_table(void) i = 0; pubkey_table[i].algo = PUBKEY_ALGO_ELGAMAL; - pubkey_table[i].name = elg_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_elg_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = elg_generate; - pubkey_table[i].check_secret_key = elg_check_secret_key; - pubkey_table[i].encrypt = elg_encrypt; - pubkey_table[i].decrypt = elg_decrypt; - pubkey_table[i].sign = elg_sign; - pubkey_table[i].verify = elg_verify; - pubkey_table[i].get_nbits = elg_get_nbits; + pubkey_table[i].generate = _gcry_elg_generate; + pubkey_table[i].check_secret_key = _gcry_elg_check_secret_key; + pubkey_table[i].encrypt = _gcry_elg_encrypt; + pubkey_table[i].decrypt = _gcry_elg_decrypt; + pubkey_table[i].sign = _gcry_elg_sign; + pubkey_table[i].verify = _gcry_elg_verify; + pubkey_table[i].get_nbits = _gcry_elg_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; pubkey_table[i].algo = PUBKEY_ALGO_ELGAMAL_E; - pubkey_table[i].name = elg_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_elg_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = elg_generate; - pubkey_table[i].check_secret_key = elg_check_secret_key; - pubkey_table[i].encrypt = elg_encrypt; - pubkey_table[i].decrypt = elg_decrypt; - pubkey_table[i].sign = elg_sign; - pubkey_table[i].verify = elg_verify; - pubkey_table[i].get_nbits = elg_get_nbits; + pubkey_table[i].generate = _gcry_elg_generate; + pubkey_table[i].check_secret_key = _gcry_elg_check_secret_key; + pubkey_table[i].encrypt = _gcry_elg_encrypt; + pubkey_table[i].decrypt = _gcry_elg_decrypt; + pubkey_table[i].sign = _gcry_elg_sign; + pubkey_table[i].verify = _gcry_elg_verify; + pubkey_table[i].get_nbits = _gcry_elg_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; pubkey_table[i].algo = PUBKEY_ALGO_DSA; - pubkey_table[i].name = dsa_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_dsa_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = dsa_generate; - pubkey_table[i].check_secret_key = dsa_check_secret_key; + pubkey_table[i].generate = _gcry_dsa_generate; + pubkey_table[i].check_secret_key = _gcry_dsa_check_secret_key; pubkey_table[i].encrypt = dummy_encrypt; pubkey_table[i].decrypt = dummy_decrypt; - pubkey_table[i].sign = dsa_sign; - pubkey_table[i].verify = dsa_verify; - pubkey_table[i].get_nbits = dsa_get_nbits; + pubkey_table[i].sign = _gcry_dsa_sign; + pubkey_table[i].verify = _gcry_dsa_verify; + pubkey_table[i].get_nbits = _gcry_dsa_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; pubkey_table[i].algo = PUBKEY_ALGO_RSA; - pubkey_table[i].name = rsa_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_rsa_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = rsa_generate; - pubkey_table[i].check_secret_key = rsa_check_secret_key; - pubkey_table[i].encrypt = rsa_encrypt; - pubkey_table[i].decrypt = rsa_decrypt; - pubkey_table[i].sign = rsa_sign; - pubkey_table[i].verify = rsa_verify; - pubkey_table[i].get_nbits = rsa_get_nbits; + pubkey_table[i].generate = _gcry_rsa_generate; + pubkey_table[i].check_secret_key = _gcry_rsa_check_secret_key; + pubkey_table[i].encrypt = _gcry_rsa_encrypt; + pubkey_table[i].decrypt = _gcry_rsa_decrypt; + pubkey_table[i].sign = _gcry_rsa_sign; + pubkey_table[i].verify = _gcry_rsa_verify; + pubkey_table[i].get_nbits = _gcry_rsa_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; pubkey_table[i].algo = PUBKEY_ALGO_RSA_E; - pubkey_table[i].name = rsa_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_rsa_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = rsa_generate; - pubkey_table[i].check_secret_key = rsa_check_secret_key; - pubkey_table[i].encrypt = rsa_encrypt; - pubkey_table[i].decrypt = rsa_decrypt; + pubkey_table[i].generate = _gcry_rsa_generate; + pubkey_table[i].check_secret_key = _gcry_rsa_check_secret_key; + pubkey_table[i].encrypt = _gcry_rsa_encrypt; + pubkey_table[i].decrypt = _gcry_rsa_decrypt; pubkey_table[i].sign = dummy_sign; pubkey_table[i].verify = dummy_verify; - pubkey_table[i].get_nbits = rsa_get_nbits; + pubkey_table[i].get_nbits = _gcry_rsa_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; pubkey_table[i].algo = PUBKEY_ALGO_RSA_S; - pubkey_table[i].name = rsa_get_info( pubkey_table[i].algo, + pubkey_table[i].name = _gcry_rsa_get_info( pubkey_table[i].algo, &pubkey_table[i].npkey, &pubkey_table[i].nskey, &pubkey_table[i].nenc, &pubkey_table[i].nsig, &pubkey_table[i].use ); - pubkey_table[i].generate = rsa_generate; - pubkey_table[i].check_secret_key = rsa_check_secret_key; + pubkey_table[i].generate = _gcry_rsa_generate; + pubkey_table[i].check_secret_key = _gcry_rsa_check_secret_key; pubkey_table[i].encrypt = dummy_encrypt; pubkey_table[i].decrypt = dummy_decrypt; - pubkey_table[i].sign = rsa_sign; - pubkey_table[i].verify = rsa_verify; - pubkey_table[i].get_nbits = rsa_get_nbits; + pubkey_table[i].sign = _gcry_rsa_sign; + pubkey_table[i].verify = _gcry_rsa_verify; + pubkey_table[i].get_nbits = _gcry_rsa_get_nbits; if( !pubkey_table[i].name ) BUG(); i++; @@ -276,7 +276,7 @@ load_pubkey_modules(void) if( !initialized ) { - cipher_modules_constructor(); + _gcry_cipher_modules_constructor(); setup_pubkey_table(); initialized = 1; return 1; @@ -291,7 +291,7 @@ load_pubkey_modules(void) if( ct_idx >= TABLE_SIZE-1 ) BUG(); /* table already full */ /* now load all extensions */ - while( (name = enum_gnupgext_pubkeys( &context, &ct->algo, + while( (name = _gcry_enum_gnupgext_pubkeys( &context, &ct->algo, &ct->npkey, &ct->nskey, &ct->nenc, &ct->nsig, &ct->use, &ct->generate, @@ -318,7 +318,7 @@ load_pubkey_modules(void) if( !ct->verify ) ct->verify = dummy_verify; if( !ct->get_nbits ) ct->get_nbits= dummy_get_nbits; /* put it into the table */ - if( g10_log_verbosity( 2 ) ) + if( _gcry_log_verbosity( 2 ) ) log_info("loaded pubkey %d (%s)\n", ct->algo, name); ct->name = name; ct_idx++; @@ -330,7 +330,7 @@ load_pubkey_modules(void) break; } } - enum_gnupgext_pubkeys( &context, NULL, NULL, NULL, NULL, NULL, NULL, + _gcry_enum_gnupgext_pubkeys( &context, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL ); return any; } @@ -709,7 +709,7 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) elems1 = algo_info_table[i].common_elements; elems2 = want_private? algo_info_table[i].secret_elements : algo_info_table[i].public_elements; - array = g10_calloc( strlen(elems1)+strlen(elems2)+1, sizeof *array ); + array = gcry_calloc( strlen(elems1)+strlen(elems2)+1, sizeof *array ); if( !array ) { gcry_sexp_release ( list ); return GCRYERR_NO_MEM; @@ -720,8 +720,8 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { for(i=0; i<idx; i++) - g10_free( array[i] ); - g10_free( array ); + gcry_free( array[i] ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_NO_OBJ; /* required parameter not found */ } @@ -729,8 +729,8 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) gcry_sexp_release ( l2 ); if( !array[idx] ) { for(i=0; i<idx; i++) - g10_free( array[i] ); - g10_free( array ); + gcry_free( array[i] ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -739,8 +739,8 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { for(i=0; i<idx; i++) - g10_free( array[i] ); - g10_free( array ); + gcry_free( array[i] ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_NO_OBJ; /* required parameter not found */ } @@ -748,8 +748,8 @@ sexp_to_key( GCRY_SEXP sexp, int want_private, MPI **retarray, int *retalgo) gcry_sexp_release ( l2 ); if( !array[idx] ) { for(i=0; i<idx; i++) - g10_free( array[i] ); - g10_free( array ); + gcry_free( array[i] ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -798,7 +798,7 @@ sexp_to_sig( GCRY_SEXP sexp, MPI **retarray, int *retalgo) } algo = sig_info_table[i].algo; elems = sig_info_table[i].elements; - array = g10_calloc( (strlen(elems)+1) , sizeof *array ); + array = gcry_calloc( (strlen(elems)+1) , sizeof *array ); if( !array ) { gcry_sexp_release ( list ); return GCRYERR_NO_MEM; @@ -808,14 +808,14 @@ sexp_to_sig( GCRY_SEXP sexp, MPI **retarray, int *retalgo) for(s=elems; *s; s++, idx++ ) { l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { - g10_free( array ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_NO_OBJ; /* required parameter not found */ } array[idx] = gcry_sexp_nth_mpi( l2, 1, GCRYMPI_FMT_USG ); gcry_sexp_release ( l2 ); if( !array[idx] ) { - g10_free( array ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -872,7 +872,7 @@ sexp_to_enc( GCRY_SEXP sexp, MPI **retarray, int *retalgo) algo = enc_info_table[i].algo; elems = enc_info_table[i].elements; - array = g10_calloc( (strlen(elems)+1) , sizeof *array ); + array = gcry_calloc( (strlen(elems)+1) , sizeof *array ); if( !array ) { gcry_sexp_release ( list ); return GCRYERR_NO_MEM; @@ -882,14 +882,14 @@ sexp_to_enc( GCRY_SEXP sexp, MPI **retarray, int *retalgo) for(s=elems; *s; s++, idx++ ) { l2 = gcry_sexp_find_token( list, s, 1 ); if( !l2 ) { - g10_free( array ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_NO_OBJ; /* required parameter not found */ } array[idx] = gcry_sexp_nth_mpi( l2, 1, GCRYMPI_FMT_USG ); gcry_sexp_release ( l2 ); if( !array[idx] ) { - g10_free( array ); + gcry_free( array ); gcry_sexp_release ( list ); return GCRYERR_INV_OBJ; /* required parameter is invalid */ } @@ -954,13 +954,13 @@ gcry_pk_encrypt( GCRY_SEXP *r_ciph, GCRY_SEXP s_data, GCRY_SEXP s_pkey ) } /* Now we can encrypt data to ciph */ - ciph = g10_xcalloc( (strlen(algo_elems)+1) , sizeof *ciph ); + ciph = gcry_xcalloc( (strlen(algo_elems)+1) , sizeof *ciph ); rc = pubkey_encrypt( algo, ciph, data, pkey ); release_mpi_array( pkey ); mpi_free( data ); if( rc ) { release_mpi_array( ciph ); - g10_free( ciph ); + gcry_free( ciph ); return rc; } @@ -973,7 +973,7 @@ gcry_pk_encrypt( GCRY_SEXP *r_ciph, GCRY_SEXP s_data, GCRY_SEXP s_pkey ) for(nelem=0; algo_elems[nelem]; nelem++ ) needed += 10; /* 6 + a safety margin */ /* build the string */ - string = p = g10_xmalloc ( needed ); + string = p = gcry_xmalloc ( needed ); p = stpcpy ( p, "(enc-val(" ); p = stpcpy ( p, algo_name ); for(i=0; algo_elems[i]; i++ ) { @@ -1008,10 +1008,10 @@ gcry_pk_encrypt( GCRY_SEXP *r_ciph, GCRY_SEXP s_data, GCRY_SEXP s_pkey ) } if ( rc ) BUG (); - g10_free ( string ); + gcry_free ( string ); } release_mpi_array( ciph ); - g10_free( ciph ); + gcry_free( ciph ); return 0; @@ -1127,12 +1127,12 @@ gcry_pk_sign( GCRY_SEXP *r_sig, GCRY_SEXP s_hash, GCRY_SEXP s_skey ) release_mpi_array( skey ); return -1; /* fixme: get a real errorcode for this */ } - result = g10_xcalloc( (strlen(algo_elems)+1) , sizeof *result ); + result = gcry_xcalloc( (strlen(algo_elems)+1) , sizeof *result ); rc = pubkey_sign( algo, result, hash, skey ); release_mpi_array( skey ); mpi_free( hash ); if( rc ) { - g10_free( result ); + gcry_free( result ); return rc; } @@ -1144,7 +1144,7 @@ gcry_pk_sign( GCRY_SEXP *r_sig, GCRY_SEXP s_hash, GCRY_SEXP s_skey ) for(nelem=0; algo_elems[nelem]; nelem++ ) needed += 10; /* 6 + a safety margin */ /* build the string */ - string = p = g10_xmalloc ( needed ); + string = p = gcry_xmalloc ( needed ); p = stpcpy ( p, "(sig-val(" ); p = stpcpy ( p, algo_name ); for(i=0; algo_elems[i]; i++ ) { @@ -1179,10 +1179,10 @@ gcry_pk_sign( GCRY_SEXP *r_sig, GCRY_SEXP s_hash, GCRY_SEXP s_skey ) } if ( rc ) BUG (); - g10_free ( string ); + gcry_free ( string ); } release_mpi_array( result ); - g10_free( result ); + gcry_free( result ); return 0; } @@ -1345,11 +1345,11 @@ gcry_pk_genkey( GCRY_SEXP *r_key, GCRY_SEXP s_parms ) return GCRYERR_INV_OBJ; /* nbits without a cdr */ } { - char *p = g10_xmalloc(n+1); + char *p = gcry_xmalloc(n+1); memcpy(p, name, n ); p[n] = 0; nbits = (unsigned int)strtol( p, NULL, 0 ); - g10_free( p ); + gcry_free( p ); } gcry_sexp_release ( list ); @@ -1377,7 +1377,7 @@ gcry_pk_genkey( GCRY_SEXP *r_key, GCRY_SEXP s_parms ) /* build the string */ nelem = 0; - string = p = g10_xmalloc ( needed ); + string = p = gcry_xmalloc ( needed ); p = stpcpy ( p, "(key-data" ); p = stpcpy ( p, "(public-key(" ); @@ -1426,7 +1426,7 @@ gcry_pk_genkey( GCRY_SEXP *r_key, GCRY_SEXP s_parms ) ) ) BUG (); assert ( DIM(mpis) == 30 ); - g10_free ( string ); + gcry_free ( string ); } release_mpi_array ( skey ); release_mpi_array ( factors ); diff --git a/cipher/random.c b/cipher/random.c index 5018fd12..f6eec21b 100644 --- a/cipher/random.c +++ b/cipher/random.c @@ -130,17 +130,17 @@ initialize(void) /* The data buffer is allocated somewhat larger, so that * we can use this extra space (which is allocated in secure memory) * as a temporary hash buffer */ - rndpool = secure_alloc ? g10_xcalloc_secure(1,POOLSIZE+BLOCKLEN) - : g10_xcalloc(1,POOLSIZE+BLOCKLEN); - keypool = secure_alloc ? g10_xcalloc_secure(1,POOLSIZE+BLOCKLEN) - : g10_xcalloc(1,POOLSIZE+BLOCKLEN); + rndpool = secure_alloc ? gcry_xcalloc_secure(1,POOLSIZE+BLOCKLEN) + : gcry_xcalloc(1,POOLSIZE+BLOCKLEN); + keypool = secure_alloc ? gcry_xcalloc_secure(1,POOLSIZE+BLOCKLEN) + : gcry_xcalloc(1,POOLSIZE+BLOCKLEN); is_initialized = 1; - cipher_modules_constructor(); + _gcry_cipher_modules_constructor(); } void -random_dump_stats() +_gcry_random_dump_stats() { fprintf(stderr, "random usage: poolsize=%d mixed=%lu polls=%lu/%lu added=%lu/%lu\n" @@ -152,14 +152,14 @@ random_dump_stats() } void -secure_random_alloc() +_gcry_secure_random_alloc() { secure_alloc = 1; } int -quick_random_gen( int onoff ) +_gcry_quick_random_gen( int onoff ) { int last; @@ -181,12 +181,12 @@ gcry_randomize( byte *buffer, size_t length, enum gcry_random_level level ) { char *p = get_random_bytes( length, level, 1 ); memcpy( buffer, p, length ); - g10_free(p); + gcry_free(p); } int -random_is_faked() +_gcry_random_is_faked() { if( !is_initialized ) initialize(); @@ -215,8 +215,8 @@ get_random_bytes( size_t nbytes, int level, int secure ) rndstats.ngetbytes2++; } - buf = secure && secure_alloc ? g10_xmalloc_secure( nbytes ) - : g10_xmalloc( nbytes ); + buf = secure && secure_alloc ? gcry_xmalloc_secure( nbytes ) + : gcry_xmalloc( nbytes ); for( p = buf; nbytes > 0; ) { size_t n = nbytes > POOLSIZE? POOLSIZE : nbytes; read_pool( p, n, level ); @@ -250,7 +250,7 @@ mix_pool(byte *pool) int i, n; RMD160_CONTEXT md; - rmd160_init( &md ); + _gcry_rmd160_init( &md ); #if DIGESTLEN != 20 #error must have a digest length of 20 for ripe-md-160 #endif @@ -258,7 +258,7 @@ mix_pool(byte *pool) pend = pool + POOLSIZE; memcpy(hashbuf, pend - DIGESTLEN, DIGESTLEN ); memcpy(hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN); - rmd160_mixblock( &md, hashbuf); + _gcry_rmd160_mixblock( &md, hashbuf); memcpy(pool, hashbuf, 20 ); p = pool; @@ -277,17 +277,17 @@ mix_pool(byte *pool) } } - rmd160_mixblock( &md, hashbuf); + _gcry_rmd160_mixblock( &md, hashbuf); memcpy(p, hashbuf, 20 ); } } void -set_random_seed_file( const char *name ) +_gcry_set_random_seed_file( const char *name ) { if( seed_file_name ) BUG(); - seed_file_name = g10_xstrdup( name ); + seed_file_name = gcry_xstrdup( name ); } /**************** @@ -374,7 +374,7 @@ read_seed_file() } void -update_random_seed_file() +_gcry_update_random_seed_file() { ulong *sp, *dp; int fd, i; @@ -550,7 +550,7 @@ random_poll() void -fast_random_poll() +_gcry_fast_random_poll() { static void (*fnc)( void (*)(const void*, size_t, int), int) = NULL; static int initialized = 0; @@ -560,7 +560,7 @@ fast_random_poll() if( !is_initialized ) initialize(); initialized = 1; - fnc = dynload_getfnc_fast_random_poll(); + fnc = _gcry_dynload_getfnc_fast_random_poll(); } if( fnc ) { (*fnc)( add_randomness, 1 ); @@ -632,7 +632,7 @@ read_random_source( int requester, size_t length, int level ) if( !fnc ) { if( !is_initialized ) initialize(); - fnc = dynload_getfnc_gather_random(); + fnc = _gcry_dynload_getfnc_gather_random(); if( !fnc ) { faked_rng = 1; fnc = gather_faked; @@ -672,7 +672,7 @@ gather_faked( void (*add)(const void*, size_t, int), int requester, #endif } - p = buffer = g10_xmalloc( length ); + p = buffer = gcry_xmalloc( length ); n = length; #ifdef HAVE_RAND while( n-- ) @@ -682,7 +682,7 @@ gather_faked( void (*add)(const void*, size_t, int), int requester, *p++ = ((unsigned)(1 + (int) (256.0*random()/(RAND_MAX+1.0)))-1); #endif add_randomness( buffer, length, requester ); - g10_free(buffer); + gcry_free(buffer); return 0; /* okay */ } diff --git a/cipher/random.h b/cipher/random.h index 23b0fd88..a53ab9fb 100644 --- a/cipher/random.h +++ b/cipher/random.h @@ -23,14 +23,14 @@ #include "types.h" /*-- random.c --*/ -void random_dump_stats(void); -void secure_random_alloc(void); -int quick_random_gen( int onoff ); -int random_is_faked(void); -void secure_random_alloc(void); -void random_dump_stats(void); -byte *get_random_bits( size_t nbits, int level, int secure ); -void fast_random_poll( void ); +#define fast_random_poll() _gcry_fast_random_poll () + +void _gcry_random_dump_stats(void); +void _gcry_secure_random_alloc(void); +int _gcry_quick_random_gen( int onoff ); +int _gcry_random_is_faked(void); +byte *_gcry_get_random_bits( size_t nbits, int level, int secure ); +void _gcry_fast_random_poll( void ); /*-- rndw32.c --*/ #ifdef USE_STATIC_RNDW32 @@ -38,3 +38,7 @@ void rndw32_set_dll_name( const char *name ); #endif #endif /*G10_RANDOM_H*/ + + + + diff --git a/cipher/rijndael.c b/cipher/rijndael.c index 2372240e..ec110dc5 100644 --- a/cipher/rijndael.c +++ b/cipher/rijndael.c @@ -1,5 +1,5 @@ /* Rijndael (AES) for GnuPG - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -2093,7 +2093,7 @@ selftest (void) static #endif const char * -rijndael_get_info (int algo, size_t *keylen, +_gcry_rijndael_get_info (int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey) (void *c, byte *key, unsigned keylen), void (**r_encrypt) (void *c, byte *outbuf, byte *inbuf), @@ -2130,7 +2130,7 @@ static struct { int value; void (*func)(void); } func_table[] = { - { 20, 1, 0, (void(*)(void))rijndael_get_info }, + { 20, 1, 0, (void(*)(void))_gcry_rijndael_get_info }, { 21, 1, 7 }, { 21, 1, 8 }, { 21, 1, 9 }, diff --git a/cipher/rmd.h b/cipher/rmd.h index 9ae0e733..2900d496 100644 --- a/cipher/rmd.h +++ b/cipher/rmd.h @@ -1,5 +1,5 @@ /* rmd.h - RIPE-MD hash functions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -29,7 +29,8 @@ typedef struct { int count; } RMD160_CONTEXT; -void rmd160_init( RMD160_CONTEXT *hd ); -void rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ); +void _gcry_rmd160_init( RMD160_CONTEXT *hd ); +void _gcry_rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ); #endif /*G10_RMD_H*/ + diff --git a/cipher/rmd160.c b/cipher/rmd160.c index d7f3bb0c..cce9d3c5 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -1,5 +1,5 @@ /* rmd160.c - RIPE-MD160 - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -143,7 +143,7 @@ void -rmd160_init( RMD160_CONTEXT *hd ) +_gcry_rmd160_init( RMD160_CONTEXT *hd ) { hd->h0 = 0x67452301; hd->h1 = 0xEFCDAB89; @@ -436,7 +436,7 @@ rmd160_write( RMD160_CONTEXT *hd, byte *inbuf, size_t inlen) * Returns: 16 bytes in buffer with the mixed contentes of buffer. */ void -rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ) +_gcry_rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ) { char *p = buffer; transform( hd, buffer ); @@ -526,11 +526,11 @@ rmd160_read( RMD160_CONTEXT *hd ) * into outbuf which must have a size of 20 bytes. */ void -rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length ) +_gcry_rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length ) { RMD160_CONTEXT hd; - rmd160_init( &hd ); + _gcry_rmd160_init( &hd ); rmd160_write( &hd, (byte*)buffer, length ); rmd160_final( &hd ); memcpy( outbuf, hd.buf, 20 ); @@ -563,7 +563,7 @@ rmd160_get_info( int algo, size_t *contextsize, *r_asnoid = asn; *r_asnlen = DIM(asn); *r_mdlen = 20; - *(void (**)(RMD160_CONTEXT *))r_init = rmd160_init; + *(void (**)(RMD160_CONTEXT *))r_init = _gcry_rmd160_init; *(void (**)(RMD160_CONTEXT *, byte*, size_t))r_write = rmd160_write; *(void (**)(RMD160_CONTEXT *))r_final = rmd160_final; *(byte *(**)(RMD160_CONTEXT *))r_read = rmd160_read; @@ -625,9 +625,9 @@ gnupgext_enum_func( int what, int *sequence, int *class, int *vers ) #ifndef IS_MODULE void -rmd160_constructor(void) +_gcry_rmd160_constructor(void) { - register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); + _gcry_register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); } #endif diff --git a/cipher/rndegd.c b/cipher/rndegd.c index 25b789ad..868b2a33 100644 --- a/cipher/rndegd.c +++ b/cipher/rndegd.c @@ -158,12 +158,12 @@ gather_random( void (*add)(const void*, size_t, int), int requester, fd = socket(AF_UNIX, SOCK_STREAM, 0); if( fd == -1 ) - g10_log_fatal("can't create unix domain socket: %s\n", + log_fatal("can't create unix domain socket: %s\n", strerror(errno) ); if( connect( fd, (struct sockaddr*)&addr, addr_len) == -1 ) - g10_log_fatal("can't connect to `%s': %s\n", + log_fatal("can't connect to `%s': %s\n", name, strerror(errno) ); - g10_free(name); + gcry_free(name); } do_restart = 0; @@ -172,10 +172,10 @@ gather_random( void (*add)(const void*, size_t, int), int requester, buffer[0] = 1; /* non blocking */ buffer[1] = nbytes; if( do_write( fd, buffer, 2 ) == -1 ) - g10_log_fatal("can't write to the EGD: %s\n", strerror(errno) ); + log_fatal("can't write to the EGD: %s\n", strerror(errno) ); n = do_read( fd, buffer, 1 ); if( n == -1 ) { - g10_log_error("read error on EGD: %s\n", strerror(errno)); + log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; goto restart; } @@ -183,7 +183,7 @@ gather_random( void (*add)(const void*, size_t, int), int requester, if( n ) { n = do_read( fd, buffer, n ); if( n == -1 ) { - g10_log_error("read error on EGD: %s\n", strerror(errno)); + log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; goto restart; } @@ -203,10 +203,10 @@ gather_random( void (*add)(const void*, size_t, int), int requester, buffer[0] = 2; /* blocking */ buffer[1] = nbytes; if( do_write( fd, buffer, 2 ) == -1 ) - g10_log_fatal("can't write to the EGD: %s\n", strerror(errno) ); + log_fatal("can't write to the EGD: %s\n", strerror(errno) ); n = do_read( fd, buffer, nbytes ); if( n == -1 ) { - g10_log_error("read error on EGD: %s\n", strerror(errno)); + log_error("read error on EGD: %s\n", strerror(errno)); do_restart = 1; goto restart; } diff --git a/cipher/rndlinux.c b/cipher/rndlinux.c index 7e8ff852..cf3df66b 100644 --- a/cipher/rndlinux.c +++ b/cipher/rndlinux.c @@ -1,5 +1,5 @@ /* rndlinux.c - raw random number for OSes with /dev/random - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -56,7 +56,7 @@ get_entropy_count( int fd ) ulong count; if( ioctl( fd, RNDGETENTCNT, &count ) == -1 ) - g10_log_fatal("ioctl(RNDGETENTCNT) failed: %s\n", strerror(errno) ); + log_fatal("ioctl(RNDGETENTCNT) failed: %s\n", strerror(errno) ); return count; } #endif @@ -73,12 +73,12 @@ open_device( const char *name, int minor ) fd = open( name, O_RDONLY ); if( fd == -1 ) - g10_log_fatal("can't open %s: %s\n", name, strerror(errno) ); + log_fatal("can't open %s: %s\n", name, strerror(errno) ); if( fstat( fd, &sb ) ) - g10_log_fatal("stat() off %s failed: %s\n", name, strerror(errno) ); + log_fatal("stat() off %s failed: %s\n", name, strerror(errno) ); /* Don't check device type for better portability */ /* if( (!S_ISCHR(sb.st_mode)) && (!S_ISFIFO(sb.st_mode)) ) - g10_log_fatal("invalid random device!\n" ); */ + log_fatal("invalid random device!\n" ); */ return fd; } @@ -107,7 +107,7 @@ gather_random( void (*add)(const void*, size_t, int), int requester, #if 0 #ifdef HAVE_DEV_RANDOM_IOCTL - g10_log_info("entropy count of %d is %lu\n", fd, get_entropy_count(fd) ); + log_info("entropy count of %d is %lu\n", fd, get_entropy_count(fd) ); #endif #endif while( length ) { @@ -138,12 +138,12 @@ _("\n" int nbytes = length < sizeof(buffer)? length : sizeof(buffer); n = read(fd, buffer, nbytes ); if( n >= 0 && n > nbytes ) { - g10_log_error("bogus read from random device (n=%d)\n", n ); + log_error("bogus read from random device (n=%d)\n", n ); n = nbytes; } } while( n == -1 && errno == EINTR ); if( n == -1 ) - g10_log_fatal("read error on random device: %s\n", strerror(errno)); + log_fatal("read error on random device: %s\n", strerror(errno)); (*add)( buffer, n, requester ); length -= n; } @@ -212,9 +212,9 @@ gnupgext_enum_func( int what, int *sequence, int *class, int *vers ) #ifndef IS_MODULE void -rndlinux_constructor(void) +_gcry_rndlinux_constructor(void) { - register_internal_cipher_extension( gnupgext_version, + _gcry_register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); } #endif diff --git a/cipher/rndunix.c b/cipher/rndunix.c index 6c8e680b..8ef1caed 100644 --- a/cipher/rndunix.c +++ b/cipher/rndunix.c @@ -650,7 +650,7 @@ start_gatherer( int pipefd ) if( s ) { dbgfp = (*s=='-' && !s[1])? stdout : fopen(s, "a"); if( !dbgfp ) - g10_log_info("can't open debug file `%s': %s\n", + log_info("can't open debug file `%s': %s\n", s, strerror(errno) ); else fprintf(dbgfp,"\nSTART RNDUNIX DEBUG pid=%d\n", (int)getpid()); @@ -685,7 +685,7 @@ start_gatherer( int pipefd ) gather_buffer_size = GATHER_BUFSIZE; gather_buffer = malloc( gather_buffer_size ); if( !gather_buffer ) { - g10_log_error("out of core while allocating the gatherer buffer\n"); + log_error("out of core while allocating the gatherer buffer\n"); exit(2); } @@ -787,12 +787,12 @@ gather_random( void (*add)(const void*, size_t, int), int requester, BUG(); /* time to start the gatherer process */ if( pipe( pipedes ) ) { - g10_log_error("pipe() failed: %s\n", strerror(errno)); + log_error("pipe() failed: %s\n", strerror(errno)); return -1; } gatherer_pid = fork(); if( gatherer_pid == -1 ) { - g10_log_error("can't for gatherer process: %s\n", strerror(errno)); + log_error("can't for gatherer process: %s\n", strerror(errno)); return -1; } if( !gatherer_pid ) { @@ -808,7 +808,7 @@ gather_random( void (*add)(const void*, size_t, int), int requester, ulong subtract; if( read_a_msg( pipedes[0], &msg ) ) { - g10_log_error("reading from gatherer pipe failed: %s\n", + log_error("reading from gatherer pipe failed: %s\n", strerror(errno)); return -1; } diff --git a/cipher/rndw32.c b/cipher/rndw32.c index 993fafd2..4f53cdbc 100644 --- a/cipher/rndw32.c +++ b/cipher/rndw32.c @@ -177,27 +177,27 @@ load_and_init_winseed( void ) /* we have all the functions - init the system */ slow_seeder = create_instance( WIN32_SLOW_SEEDER, &reason); if( !slow_seeder ) { - g10_log_fatal("error creating winseed slow seeder: rc=%u\n", reason ); + log_fatal("error creating winseed slow seeder: rc=%u\n", reason ); goto failure; } fast_seeder = create_instance( WIN32_FAST_SEEDER, &reason); if( !fast_seeder ) { - g10_log_fatal("error creating winseed fast seeder: rc=%u\n", reason ); + log_fatal("error creating winseed fast seeder: rc=%u\n", reason ); goto failure; } n1 = get_internal_seed_size( slow_seeder ); - /*g10_log_info("slow buffer size=%u\n", n1);*/ + /*log_info("slow buffer size=%u\n", n1);*/ n2 = get_internal_seed_size( fast_seeder ); - /*g10_log_info("fast buffer size=%u\n", n2);*/ + /*log_info("fast buffer size=%u\n", n2);*/ entropy_buffer_size = n1 > n2? n1: n2; entropy_buffer = m_alloc( entropy_buffer_size ); - /*g10_log_info("using a buffer of size=%u\n", entropy_buffer_size );*/ + /*log_info("using a buffer of size=%u\n", entropy_buffer_size );*/ return; failure: - g10_log_fatal("error loading winseed DLL `%s'\n", dllname ); + log_fatal("error loading winseed DLL `%s'\n", dllname ); } @@ -241,7 +241,7 @@ gather_random( void (*add)(const void*, size_t, int), int requester, unsigned int n1 = get_internal_seed_size( slow_seeder ); if( n1 > MAX_SEEDER_SIZE ) { - g10_log_fatal("rndw32: internal seeder problem (size=%u)\n", + log_fatal("rndw32: internal seeder problem (size=%u)\n", n1); return -1; /* actually never reached */ } @@ -257,10 +257,10 @@ gather_random( void (*add)(const void*, size_t, int), int requester, if( result ) { - g10_log_fatal("rndw32: get_seed(slow) failed: rc=%u\n", result); + log_fatal("rndw32: get_seed(slow) failed: rc=%u\n", result); return -1; /* actually never reached */ } - /*g10_log_info("rndw32: slow poll level %d, need %u, got %u\n", + /*log_info("rndw32: slow poll level %d, need %u, got %u\n", level, (unsigned int)length, (unsigned int)nbytes );*/ (*add)( entropy_buffer, nbytes, requester ); if( length <= nbytes ) @@ -284,10 +284,10 @@ gather_random_fast( void (*add)(const void*, size_t, int), int requester ) nbytes = entropy_buffer_size; result = get_seed( fast_seeder, entropy_buffer, &nbytes); if( result ) { - g10_log_fatal("rndw32: get_seed(fast) failed: rc=%u\n", result); + log_fatal("rndw32: get_seed(fast) failed: rc=%u\n", result); return -1; /* actually never reached */ } - /*g10_log_info("rndw32: fast poll got %u\n", (unsigned int)nbytes );*/ + /*log_info("rndw32: fast poll got %u\n", (unsigned int)nbytes );*/ (*add)( entropy_buffer, nbytes, requester ); return 0; } @@ -428,7 +428,7 @@ slow_gatherer_windows95( void (*add)(const void*, size_t, int), int requester ) /* Obtain the module handle of the kernel to retrieve the addresses * of the Toolhelp32 functions */ if ( ( !(hKernel = GetModuleHandle ("KERNEL32.DLL"))) ) { - g10_log_fatal ( "rndw32: can't get module handle\n" ); + log_fatal ( "rndw32: can't get module handle\n" ); } /* Now get pointers to the functions */ @@ -455,14 +455,14 @@ slow_gatherer_windows95( void (*add)(const void*, size_t, int), int requester ) || !pThread32First || !pThread32Next || !pHeap32ListFirst || !pHeap32ListNext || !pHeap32First || !pHeap32Next ) { - g10_log_fatal ( "rndw32: failed to get a toolhep function\n" ); + log_fatal ( "rndw32: failed to get a toolhep function\n" ); } } /* Take a snapshot of everything we can get to which is currently * in the system */ if ( !(hSnapshot = pCreateToolhelp32Snapshot (TH32CS_SNAPALL, 0)) ) { - g10_log_fatal ( "rndw32: failed to take a toolhelp snapshot\n" ); + log_fatal ( "rndw32: failed to take a toolhelp snapshot\n" ); } /* Walk through the local heap */ @@ -588,7 +588,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) || !pNetApiBufferSize || !pNetApiBufferFree ) { FreeLibrary (hNetAPI32); hNetAPI32 = NULL; - g10_log_debug ("rndw32: No NETAPI found\n" ); + log_debug ("rndw32: No NETAPI found\n" ); } } @@ -702,7 +702,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) (*add) ( pPerfData, dwSize, requester ); } else - g10_log_debug ( "rndw32: no PERF signature\n"); + log_debug ( "rndw32: no PERF signature\n"); break; } else if (status == ERROR_MORE_DATA) { @@ -710,7 +710,7 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) pPerfData = m_realloc (pPerfData, cbPerfData); } else { - g10_log_debug ( "rndw32: get performance data problem\n"); + log_debug ( "rndw32: get performance data problem\n"); break; } } @@ -751,7 +751,7 @@ gather_random( void (*add)(const void*, size_t, int), int requester, is_windows95 = platform == VER_PLATFORM_WIN32_WINDOWS; if ( platform == VER_PLATFORM_WIN32s ) { - g10_log_fatal("can't run on a W32s platform\n" ); + log_fatal("can't run on a W32s platform\n" ); } is_initialized = 1; if ( debug_me ) diff --git a/cipher/rsa.c b/cipher/rsa.c index 6df3bd35..e5ad116c 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -1,6 +1,6 @@ /* rsa.c - RSA function * Copyright (C) 1997, 1998, 1999 by Werner Koch (dd9jn) - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -100,8 +100,8 @@ generate( RSA_secret_key *sk, unsigned nbits ) MPI f; /* select two (very secret) primes */ - p = generate_secret_prime( nbits / 2 ); - q = generate_secret_prime( nbits / 2 ); + p = _gcry_generate_secret_prime( nbits / 2 ); + q = _gcry_generate_secret_prime( nbits / 2 ); if( mpi_cmp( p, q ) > 0 ) /* p shall be smaller than q (for calc of u)*/ mpi_swap(p,q); /* calculate Euler totient: phi = (p-1)(q-1) */ @@ -113,7 +113,7 @@ generate( RSA_secret_key *sk, unsigned nbits ) mpi_sub_ui( t1, p, 1 ); mpi_sub_ui( t2, q, 1 ); mpi_mul( phi, t1, t2 ); - mpi_gcd(g, t1, t2); + gcry_mpi_gcd(g, t1, t2); mpi_fdiv_q(f, phi, g); /* multiply them to make the private key */ n = gcry_mpi_new ( nbits ); @@ -121,7 +121,7 @@ generate( RSA_secret_key *sk, unsigned nbits ) /* find a public exponent */ e = gcry_mpi_new ( 6 ); mpi_set_ui( e, 17); /* start with 17 */ - while( !mpi_gcd(t1, e, phi) ) /* (while gcd is not 1) */ + while( !gcry_mpi_gcd(t1, e, phi) ) /* (while gcd is not 1) */ mpi_add_ui( e, e, 2); /* calculate the secret key d = e^1 mod phi */ d = gcry_mpi_snew ( nbits ); @@ -308,7 +308,7 @@ secret(MPI output, MPI input, RSA_secret_key *skey ) *********************************************/ int -rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) +_gcry_rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) { RSA_secret_key sk; @@ -323,13 +323,13 @@ rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ) skey[4] = sk.q; skey[5] = sk.u; /* make an empty list of factors */ - *retfactors = g10_xcalloc( 1, sizeof **retfactors ); + *retfactors = gcry_xcalloc( 1, sizeof **retfactors ); return 0; } int -rsa_check_secret_key( int algo, MPI *skey ) +_gcry_rsa_check_secret_key( int algo, MPI *skey ) { RSA_secret_key sk; @@ -351,7 +351,7 @@ rsa_check_secret_key( int algo, MPI *skey ) int -rsa_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) +_gcry_rsa_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) { RSA_public_key pk; @@ -366,7 +366,7 @@ rsa_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ) } int -rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) +_gcry_rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) { RSA_secret_key sk; @@ -385,7 +385,7 @@ rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ) } int -rsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) +_gcry_rsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) { RSA_secret_key sk; @@ -405,7 +405,7 @@ rsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ) } int -rsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, +_gcry_rsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *opaque, MPI tmp), void *opaquev ) { RSA_public_key pk; @@ -427,7 +427,7 @@ rsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, unsigned int -rsa_get_nbits( int algo, MPI *pkey ) +_gcry_rsa_get_nbits( int algo, MPI *pkey ) { if( !is_RSA(algo) ) return 0; @@ -444,7 +444,7 @@ rsa_get_nbits( int algo, MPI *pkey ) * 1 set : allows encryption */ const char * -rsa_get_info( int algo, +_gcry_rsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *usage ) { *npkey = 2; diff --git a/cipher/rsa.h b/cipher/rsa.h index 46f9cc3a..f88c7303 100644 --- a/cipher/rsa.h +++ b/cipher/rsa.h @@ -1,6 +1,6 @@ /* rsa.h * Copyright (C) 1997,1998 by Werner Koch (dd9jn) - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -21,15 +21,15 @@ #ifndef G10_RSA_H #define G10_RSA_H -int rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); -int rsa_check_secret_key( int algo, MPI *skey ); -int rsa_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ); -int rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ); -int rsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ); -int rsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, +int _gcry_rsa_generate( int algo, unsigned nbits, MPI *skey, MPI **retfactors ); +int _gcry_rsa_check_secret_key( int algo, MPI *skey ); +int _gcry_rsa_encrypt( int algo, MPI *resarr, MPI data, MPI *pkey ); +int _gcry_rsa_decrypt( int algo, MPI *result, MPI *data, MPI *skey ); +int _gcry_rsa_sign( int algo, MPI *resarr, MPI data, MPI *skey ); +int _gcry_rsa_verify( int algo, MPI hash, MPI *data, MPI *pkey, int (*cmp)(void *, MPI), void *opaquev ); -unsigned rsa_get_nbits( int algo, MPI *pkey ); -const char *rsa_get_info( int algo, int *npkey, int *nskey, +unsigned _gcry_rsa_get_nbits( int algo, MPI *pkey ); +const char *_gcry_rsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig, int *use ); diff --git a/cipher/sha1.c b/cipher/sha1.c index da9bd153..39583208 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -1,5 +1,5 @@ /* sha1.c - SHA1 hash function - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * Please see below for more legal information! * @@ -52,7 +52,7 @@ typedef struct { -void +static void sha1_init( SHA1_CONTEXT *hd ) { hd->h0 = 0x67452301; @@ -401,9 +401,9 @@ gnupgext_enum_func( int what, int *sequence, int *class, int *vers ) #ifndef IS_MODULE void -sha1_constructor(void) +_gcry_sha1_constructor(void) { - register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); + _gcry_register_internal_cipher_extension( gnupgext_version, gnupgext_enum_func ); } #endif diff --git a/cipher/twofish.c b/cipher/twofish.c index ffd75360..a7cbb309 100644 --- a/cipher/twofish.c +++ b/cipher/twofish.c @@ -976,7 +976,7 @@ main() static #endif const char * -twofish_get_info (int algo, size_t *keylen, +_gcry_twofish_get_info (int algo, size_t *keylen, size_t *blocksize, size_t *contextsize, int (**r_setkey) (void *c, byte *key, unsigned keylen), void (**r_encrypt) (void *c, byte *outbuf, byte *inbuf), @@ -1011,7 +1011,7 @@ static struct { int value; void (*func)(void); } func_table[] = { - { 20, 1, 0, (void(*)(void))twofish_get_info }, + { 20, 1, 0, (void(*)(void))_gcry_twofish_get_info }, { 21, 1, 10 }, { 21, 1, 102 }, }; diff --git a/configure.in b/configure.in index e5adf9ac..a1ff1da9 100644 --- a/configure.in +++ b/configure.in @@ -19,9 +19,9 @@ AC_CANONICAL_SYSTEM # AGE, set REVISION to 0. # 3. Interfaces removed (BAD, breaks upward compatibility): Increment # CURRENT, set AGE and REVISION to 0. -AM_INIT_AUTOMAKE(libgcrypt,1.1.2a) -LIBGCRYPT_LT_CURRENT=1 -LIBGCRYPT_LT_AGE=0 +AM_INIT_AUTOMAKE(libgcrypt,1.1.3) +LIBGCRYPT_LT_CURRENT=2 +LIBGCRYPT_LT_AGE=1 LIBGCRYPT_LT_REVISION=0 ############################################## @@ -586,14 +586,14 @@ cat <<G10EOF >cipher/construct.c G10EOF GNUPG_MSG_PRINT([statically linked cipher modules:]) for name in $STATIC_CIPHER_NAMES; do - echo "void ${name}_constructor(void);" >>cipher/construct.c + echo "void _gcry_${name}_constructor(void);" >>cipher/construct.c GNUPG_MSG_PRINT([$name]) done AC_MSG_RESULT() cat <<G10EOF >>cipher/construct.c void -cipher_modules_constructor(void) +_gcry_cipher_modules_constructor(void) { static int done = 0; if( done ) @@ -602,7 +602,7 @@ cipher_modules_constructor(void) G10EOF for name in $STATIC_CIPHER_NAMES; do - echo " ${name}_constructor();" >>cipher/construct.c + echo " _gcry_${name}_constructor();" >>cipher/construct.c done echo '}' >>cipher/construct.c diff --git a/mpi/ChangeLog b/mpi/ChangeLog index 2730fb1b..a97ccf40 100644 --- a/mpi/ChangeLog +++ b/mpi/ChangeLog @@ -1,3 +1,13 @@ +2001-05-31 Werner Koch <wk@gnupg.org> + + * mpih-cmp.c: Removed and moved mpihelp_cmp to .. + * mpi-inline.h: .. here. + + Major function renaming. All global functions are now prefixed + with _gcry_ or gcry_. Renamed also all mpihelp_ to just mpih_ so + that functions names are not getting to long an unreadable and for + better matching with the filenames. + 2001-05-28 Werner Koch <wk@gnupg.org> * mpicoder.c (mpi_fromstr): Made static and assume that all input diff --git a/mpi/Makefile.am b/mpi/Makefile.am index 35120063..8f684bd9 100644 --- a/mpi/Makefile.am +++ b/mpi/Makefile.am @@ -31,7 +31,6 @@ libmpi_la_SOURCES = longlong.h \ mpi-mpow.c \ mpi-scan.c \ mpicoder.c \ - mpih-cmp.c \ mpih-div.c \ mpih-mul.c \ mpiutil.c diff --git a/mpi/alpha/mpih-add1.S b/mpi/alpha/mpih-add1.S index a2ee8eb1..427d1abc 100644 --- a/mpi/alpha/mpih-add1.S +++ b/mpi/alpha/mpih-add1.S @@ -23,7 +23,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, ($16) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, ($16) * mpi_ptr_t s1_ptr, ($17) * mpi_ptr_t s2_ptr, ($18) * mpi_size_t size) ($19) @@ -34,9 +34,9 @@ .set noat .text .align 3 - .globl mpihelp_add_n - .ent mpihelp_add_n -mpihelp_add_n: + .globl _gcry_mpih_add_n + .ent _gcry_mpih_add_n +_gcry_mpih_add_n: .frame $30,0,$26,0 ldq $3,0($17) @@ -120,5 +120,5 @@ mpihelp_add_n: or $0,$1,$0 ret $31,($26),1 - .end mpihelp_add_n + .end _gcry_mpih_add_n diff --git a/mpi/alpha/mpih-lshift.S b/mpi/alpha/mpih-lshift.S index 4ce4879a..54860e44 100644 --- a/mpi/alpha/mpih-lshift.S +++ b/mpi/alpha/mpih-lshift.S @@ -32,7 +32,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (r16) + * _gcry_mpih_lshift( mpi_ptr_t wp, (r16) * mpi_ptr_t up, (r17) * mpi_size_t usize, (r18) * unsigned cnt) (r19) @@ -52,9 +52,9 @@ .set noat .text .align 3 - .globl mpihelp_lshift - .ent mpihelp_lshift -mpihelp_lshift: + .globl _gcry_mpih_lshift + .ent _gcry_mpih_lshift +_gcry_mpih_lshift: .frame $30,0,$26,0 s8addq $18,$17,$17 # make r17 point at end of s1 @@ -118,6 +118,6 @@ mpihelp_lshift: .Lend: sll $4,$19,$8 stq $8,-8($16) ret $31,($26),1 - .end mpihelp_lshift + .end _gcry_mpih_lshift diff --git a/mpi/alpha/mpih-mul1.S b/mpi/alpha/mpih-mul1.S index e62ccbdb..679d912e 100644 --- a/mpi/alpha/mpih-mul1.S +++ b/mpi/alpha/mpih-mul1.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (r16) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r16) * mpi_ptr_t s1_ptr, (r17) * mpi_size_t s1_size, (r18) * mpi_limb_t s2_limb) (r19) @@ -45,9 +45,9 @@ .set noat .text .align 3 - .globl mpihelp_mul_1 - .ent mpihelp_mul_1 2 -mpihelp_mul_1: + .globl _gcry_mpih_mul_1 + .ent _gcry_mpih_mul_1 2 +_gcry_mpih_mul_1: .frame $30,0,$26 ldq $2,0($17) # $2 = s1_limb @@ -85,6 +85,6 @@ Lend2: mulq $2,$19,$3 # $3 = prod_low Lend1: stq $3,0($16) ret $31,($26),1 - .end mpihelp_mul_1 + .end _gcry_mpih_mul_1 diff --git a/mpi/alpha/mpih-mul2.S b/mpi/alpha/mpih-mul2.S index 595af99d..b64f5819 100644 --- a/mpi/alpha/mpih-mul2.S +++ b/mpi/alpha/mpih-mul2.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (r16) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r16) * mpi_ptr_t s1_ptr, (r17) * mpi_size_t s1_size, (r18) * mpi_limb_t s2_limb) (r19) @@ -37,9 +37,9 @@ .set noat .text .align 3 - .globl mpihelp_addmul_1 - .ent mpihelp_addmul_1 2 -mpihelp_addmul_1: + .globl _gcry_mpih_addmul_1 + .ent _gcry_mpih_addmul_1 2 +_gcry_mpih_addmul_1: .frame $30,0,$26 ldq $2,0($17) # $2 = s1_limb @@ -93,5 +93,5 @@ mpihelp_addmul_1: addq $0,$5,$0 ret $31,($26),1 - .end mpihelp_addmul_1 + .end _gcry_mpih_addmul_1 diff --git a/mpi/alpha/mpih-mul3.S b/mpi/alpha/mpih-mul3.S index fa3df92a..f6d80f22 100644 --- a/mpi/alpha/mpih-mul3.S +++ b/mpi/alpha/mpih-mul3.S @@ -23,7 +23,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (r16 ) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r16 ) * mpi_ptr_t s1_ptr, (r17 ) * mpi_size_t s1_size, (r18 ) * mpi_limb_t s2_limb) (r19 ) @@ -35,9 +35,9 @@ .set noat .text .align 3 - .globl mpihelp_submul_1 - .ent mpihelp_submul_1 2 -mpihelp_submul_1: + .globl _gcry_mpih_submul_1 + .ent _gcry_mpih_submul_1 2 +_gcry_mpih_submul_1: .frame $30,0,$26 ldq $2,0($17) # $2 = s1_limb @@ -91,5 +91,5 @@ mpihelp_submul_1: addq $0,$5,$0 ret $31,($26),1 - .end mpihelp_submul_1 + .end _gcry_mpih_submul_1 diff --git a/mpi/alpha/mpih-rshift.S b/mpi/alpha/mpih-rshift.S index e15542de..8396b3cc 100644 --- a/mpi/alpha/mpih-rshift.S +++ b/mpi/alpha/mpih-rshift.S @@ -32,7 +32,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (r16) + * _gcry_mpih_rshift( mpi_ptr_t wp, (r16) * mpi_ptr_t up, (r17) * mpi_size_t usize, (r18) * unsigned cnt) (r19) @@ -52,9 +52,9 @@ .set noat .text .align 3 - .globl mpihelp_rshift - .ent mpihelp_rshift -mpihelp_rshift: + .globl _gcry_mpih_rshift + .ent _gcry_mpih_rshift +_gcry_mpih_rshift: .frame $30,0,$26,0 ldq $4,0($17) # load first limb @@ -116,5 +116,5 @@ mpihelp_rshift: .Rend: srl $4,$19,$8 stq $8,0($16) ret $31,($26),1 - .end mpihelp_rshift + .end _gcry_mpih_rshift diff --git a/mpi/alpha/mpih-sub1.S b/mpi/alpha/mpih-sub1.S index a32b470e..f245e5ce 100644 --- a/mpi/alpha/mpih-sub1.S +++ b/mpi/alpha/mpih-sub1.S @@ -23,7 +23,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (r16) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r16) * mpi_ptr_t s1_ptr, (r17) * mpi_ptr_t s2_ptr, (r18) * mpi_size_t size) (r19) @@ -33,9 +33,9 @@ .set noat .text .align 3 - .globl mpihelp_sub_n - .ent mpihelp_sub_n -mpihelp_sub_n: + .globl _gcry_mpih_sub_n + .ent _gcry_mpih_sub_n +_gcry_mpih_sub_n: .frame $30,0,$26,0 ldq $3,0($17) @@ -119,6 +119,6 @@ mpihelp_sub_n: or $0,$1,$0 ret $31,($26),1 - .end mpihelp_sub_n + .end _gcry_mpih_sub_n diff --git a/mpi/generic/mpih-add1.c b/mpi/generic/mpih-add1.c index d9c3cbb6..9d6c4b6e 100644 --- a/mpi/generic/mpih-add1.c +++ b/mpi/generic/mpih-add1.c @@ -34,7 +34,7 @@ #include "longlong.h" mpi_limb_t -mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size) { mpi_limb_t x, y, cy; diff --git a/mpi/generic/mpih-lshift.c b/mpi/generic/mpih-lshift.c index fba8c052..ed8d4033 100644 --- a/mpi/generic/mpih-lshift.c +++ b/mpi/generic/mpih-lshift.c @@ -41,7 +41,7 @@ */ mpi_limb_t -mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, +_gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned int cnt) { mpi_limb_t high_limb, low_limb; diff --git a/mpi/generic/mpih-mul1.c b/mpi/generic/mpih-mul1.c index 83a81add..61ecacb2 100644 --- a/mpi/generic/mpih-mul1.c +++ b/mpi/generic/mpih-mul1.c @@ -33,7 +33,7 @@ #include "longlong.h" mpi_limb_t -mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, +_gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb) { mpi_limb_t cy_limb; diff --git a/mpi/generic/mpih-mul2.c b/mpi/generic/mpih-mul2.c index ff8f998f..4511b42b 100644 --- a/mpi/generic/mpih-mul2.c +++ b/mpi/generic/mpih-mul2.c @@ -34,7 +34,7 @@ mpi_limb_t -mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb) { mpi_limb_t cy_limb; diff --git a/mpi/generic/mpih-mul3.c b/mpi/generic/mpih-mul3.c index 80eedcc4..76b73190 100644 --- a/mpi/generic/mpih-mul3.c +++ b/mpi/generic/mpih-mul3.c @@ -34,7 +34,7 @@ mpi_limb_t -mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb) { mpi_limb_t cy_limb; diff --git a/mpi/generic/mpih-rshift.c b/mpi/generic/mpih-rshift.c index be73adfb..142dadb4 100644 --- a/mpi/generic/mpih-rshift.c +++ b/mpi/generic/mpih-rshift.c @@ -43,7 +43,7 @@ */ mpi_limb_t -mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt) +_gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt) { mpi_limb_t high_limb, low_limb; unsigned sh_1, sh_2; diff --git a/mpi/generic/mpih-sub1.c b/mpi/generic/mpih-sub1.c index c618fee4..cd3828c0 100644 --- a/mpi/generic/mpih-sub1.c +++ b/mpi/generic/mpih-sub1.c @@ -33,7 +33,7 @@ #include "longlong.h" mpi_limb_t -mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size) { mpi_limb_t x, y, cy; diff --git a/mpi/hppa/mpih-add1.S b/mpi/hppa/mpih-add1.S index 7a2a2c2c..af2981c5 100644 --- a/mpi/hppa/mpih-add1.S +++ b/mpi/hppa/mpih-add1.S @@ -33,7 +33,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, (gr26) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (gr26) * mpi_ptr_t s1_ptr, (gr25) * mpi_ptr_t s2_ptr, (gr24) * mpi_size_t size) (gr23) @@ -44,8 +44,8 @@ */ .code - .export mpihelp_add_n - .label mpihelp_add_n + .export _gcry_mpih_add_n + .label _gcry_mpih_add_n .proc .callinfo frame=0,no_calls .entry diff --git a/mpi/hppa/mpih-lshift.S b/mpi/hppa/mpih-lshift.S index 6a8b2c4c..cec0554c 100644 --- a/mpi/hppa/mpih-lshift.S +++ b/mpi/hppa/mpih-lshift.S @@ -24,15 +24,15 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (gr26) + * _gcry_mpih_lshift( mpi_ptr_t wp, (gr26) * mpi_ptr_t up, (gr25) * mpi_size_t usize, (gr24) * unsigned cnt) (gr23) */ .code - .export mpihelp_lshift - .label mpihelp_lshift + .export _gcry_mpih_lshift + .label _gcry_mpih_lshift .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/hppa/mpih-rshift.S b/mpi/hppa/mpih-rshift.S index b1e6a679..ec020fc4 100644 --- a/mpi/hppa/mpih-rshift.S +++ b/mpi/hppa/mpih-rshift.S @@ -25,15 +25,15 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (gr26) + * _gcry_mpih_rshift( mpi_ptr_t wp, (gr26) * mpi_ptr_t up, (gr25) * mpi_size_t usize, (gr24) * unsigned cnt) (gr23) */ .code - .export mpihelp_rshift - .label mpihelp_rshift + .export _gcry_mpih_rshift + .label _gcry_mpih_rshift .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/hppa/mpih-sub1.S b/mpi/hppa/mpih-sub1.S index 870009e9..6ea1049a 100644 --- a/mpi/hppa/mpih-sub1.S +++ b/mpi/hppa/mpih-sub1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (gr26) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (gr26) * mpi_ptr_t s1_ptr, (gr25) * mpi_ptr_t s2_ptr, (gr24) * mpi_size_t size) (gr23) @@ -48,8 +48,8 @@ .code - .export mpihelp_sub_n - .label mpihelp_sub_n + .export _gcry_mpih_sub_n + .label _gcry_mpih_sub_n .proc .callinfo frame=0,no_calls .entry diff --git a/mpi/hppa1.1/mpih-mul1.S b/mpi/hppa1.1/mpih-mul1.S index ac9baced..b082ab16 100644 --- a/mpi/hppa1.1/mpih-mul1.S +++ b/mpi/hppa1.1/mpih-mul1.S @@ -32,7 +32,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (r26) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r26) * mpi_ptr_t s1_ptr, (r25) * mpi_size_t s1_size, (r24) * mpi_limb_t s2_limb) (r23) @@ -58,8 +58,8 @@ */ .code - .export mpihelp_mul_1 - .label mpihelp_mul_1 + .export _gcry_mpih_mul_1 + .label _gcry_mpih_mul_1 .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/hppa1.1/mpih-mul2.S b/mpi/hppa1.1/mpih-mul2.S index c73397e3..6a5ba5b8 100644 --- a/mpi/hppa1.1/mpih-mul2.S +++ b/mpi/hppa1.1/mpih-mul2.S @@ -32,7 +32,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (r26) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r26) * mpi_ptr_t s1_ptr, (r25) * mpi_size_t s1_size, (r24) * mpi_limb_t s2_limb) (r23) @@ -48,8 +48,8 @@ */ .code - .export mpihelp_addmul_1 - .label mpihelp_addmul_1 + .export _gcry_mpih_addmul_1 + .label _gcry_mpih_addmul_1 .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/hppa1.1/mpih-mul3.S b/mpi/hppa1.1/mpih-mul3.S index f9ccb1b5..61bbd2e0 100644 --- a/mpi/hppa1.1/mpih-mul3.S +++ b/mpi/hppa1.1/mpih-mul3.S @@ -32,7 +32,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (r26) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r26) * mpi_ptr_t s1_ptr, (r25) * mpi_size_t s1_size, (r24) * mpi_limb_t s2_limb) (r23) @@ -55,8 +55,8 @@ .code - .export mpihelp_submul_1 - .label mpihelp_submul_1 + .export _gcry_mpih_submul_1 + .label _gcry_mpih_submul_1 .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/i386/mpih-add1.S b/mpi/i386/mpih-add1.S index 3b3b23c8..7bc1a1bf 100644 --- a/mpi/i386/mpih-add1.S +++ b/mpi/i386/mpih-add1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) @@ -44,8 +44,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_add_n) -C_SYMBOL_NAME(mpihelp_add_n:) + .globl C_SYMBOL_NAME(_gcry_mpih_add_n) +C_SYMBOL_NAME(_gcry_mpih_add_n:) pushl %edi pushl %esi diff --git a/mpi/i386/mpih-lshift.S b/mpi/i386/mpih-lshift.S index 5e6387a4..fdca0252 100644 --- a/mpi/i386/mpih-lshift.S +++ b/mpi/i386/mpih-lshift.S @@ -34,7 +34,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -42,8 +42,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_lshift) -C_SYMBOL_NAME(mpihelp_lshift:) + .globl C_SYMBOL_NAME(_gcry_mpih_lshift) +C_SYMBOL_NAME(_gcry_mpih_lshift:) pushl %edi pushl %esi pushl %ebx diff --git a/mpi/i386/mpih-mul1.S b/mpi/i386/mpih-mul1.S index cf87046f..2a4426a9 100644 --- a/mpi/i386/mpih-mul1.S +++ b/mpi/i386/mpih-mul1.S @@ -35,7 +35,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -48,8 +48,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_mul_1) -C_SYMBOL_NAME(mpihelp_mul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1) +C_SYMBOL_NAME(_gcry_mpih_mul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i386/mpih-mul2.S b/mpi/i386/mpih-mul2.S index f134af70..842a5edb 100644 --- a/mpi/i386/mpih-mul2.S +++ b/mpi/i386/mpih-mul2.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -49,8 +49,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_addmul_1) -C_SYMBOL_NAME(mpihelp_addmul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1) +C_SYMBOL_NAME(_gcry_mpih_addmul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i386/mpih-mul3.S b/mpi/i386/mpih-mul3.S index 2907ed03..8e091e04 100644 --- a/mpi/i386/mpih-mul3.S +++ b/mpi/i386/mpih-mul3.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -49,8 +49,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_submul_1) -C_SYMBOL_NAME(mpihelp_submul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1) +C_SYMBOL_NAME(_gcry_mpih_submul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i386/mpih-rshift.S b/mpi/i386/mpih-rshift.S index 9718204c..9d5e4ac9 100644 --- a/mpi/i386/mpih-rshift.S +++ b/mpi/i386/mpih-rshift.S @@ -35,7 +35,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -43,8 +43,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_rshift) -C_SYMBOL_NAME(mpihelp_rshift:) + .globl C_SYMBOL_NAME(_gcry_mpih_rshift) +C_SYMBOL_NAME(_gcry_mpih_rshift:) pushl %edi pushl %esi pushl %ebx diff --git a/mpi/i386/mpih-sub1.S b/mpi/i386/mpih-sub1.S index 169c5395..28e1fa09 100644 --- a/mpi/i386/mpih-sub1.S +++ b/mpi/i386/mpih-sub1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) @@ -45,8 +45,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_sub_n) -C_SYMBOL_NAME(mpihelp_sub_n:) + .globl C_SYMBOL_NAME(_gcry_mpih_sub_n) +C_SYMBOL_NAME(_gcry_mpih_sub_n:) pushl %edi pushl %esi diff --git a/mpi/i586/mpih-add1.S b/mpi/i586/mpih-add1.S index 248b0c0b..cca32d91 100644 --- a/mpi/i586/mpih-add1.S +++ b/mpi/i586/mpih-add1.S @@ -28,7 +28,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) @@ -36,8 +36,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_add_n) -C_SYMBOL_NAME(mpihelp_add_n:) + .globl C_SYMBOL_NAME(_gcry_mpih_add_n) +C_SYMBOL_NAME(_gcry_mpih_add_n:) pushl %edi pushl %esi pushl %ebx diff --git a/mpi/i586/mpih-lshift.S b/mpi/i586/mpih-lshift.S index ed040912..dcdb4b06 100644 --- a/mpi/i586/mpih-lshift.S +++ b/mpi/i586/mpih-lshift.S @@ -35,7 +35,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -43,8 +43,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_lshift) -C_SYMBOL_NAME(mpihelp_lshift:) + .globl C_SYMBOL_NAME(_gcry_mpih_lshift) +C_SYMBOL_NAME(_gcry_mpih_lshift:) pushl %edi pushl %esi diff --git a/mpi/i586/mpih-mul1.S b/mpi/i586/mpih-mul1.S index 42bcde6b..ea85320b 100644 --- a/mpi/i586/mpih-mul1.S +++ b/mpi/i586/mpih-mul1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -49,8 +49,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_mul_1) -C_SYMBOL_NAME(mpihelp_mul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1) +C_SYMBOL_NAME(_gcry_mpih_mul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i586/mpih-mul2.S b/mpi/i586/mpih-mul2.S index 54c5df96..4253ad77 100644 --- a/mpi/i586/mpih-mul2.S +++ b/mpi/i586/mpih-mul2.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -49,8 +49,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_addmul_1) -C_SYMBOL_NAME(mpihelp_addmul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1) +C_SYMBOL_NAME(_gcry_mpih_addmul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i586/mpih-mul3.S b/mpi/i586/mpih-mul3.S index 0d61ff26..3f86d708 100644 --- a/mpi/i586/mpih-mul3.S +++ b/mpi/i586/mpih-mul3.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -49,8 +49,8 @@ TEXT ALIGN (3) - GLOBL C_SYMBOL_NAME(mpihelp_submul_1) -C_SYMBOL_NAME(mpihelp_submul_1:) + GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1) +C_SYMBOL_NAME(_gcry_mpih_submul_1:) INSN1(push,l ,R(edi)) INSN1(push,l ,R(esi)) diff --git a/mpi/i586/mpih-rshift.S b/mpi/i586/mpih-rshift.S index 2e331621..3b1e8f47 100644 --- a/mpi/i586/mpih-rshift.S +++ b/mpi/i586/mpih-rshift.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -44,8 +44,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_rshift) -C_SYMBOL_NAME(mpihelp_rshift:) + .globl C_SYMBOL_NAME(_gcry_mpih_rshift) +C_SYMBOL_NAME(_gcry_mpih_rshift:) pushl %edi pushl %esi pushl %ebx diff --git a/mpi/i586/mpih-sub1.S b/mpi/i586/mpih-sub1.S index a54be0e9..0c4838bd 100644 --- a/mpi/i586/mpih-sub1.S +++ b/mpi/i586/mpih-sub1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 12) * mpi_size_t size) (sp + 16) @@ -45,8 +45,8 @@ .text ALIGN (3) - .globl C_SYMBOL_NAME(mpihelp_sub_n) -C_SYMBOL_NAME(mpihelp_sub_n:) + .globl C_SYMBOL_NAME(_gcry_mpih_sub_n) +C_SYMBOL_NAME(_gcry_mpih_sub_n:) pushl %edi pushl %esi diff --git a/mpi/m68k/mc68020/mpih-mul1.S b/mpi/m68k/mc68020/mpih-mul1.S index 4872b9ba..b4181a9c 100644 --- a/mpi/m68k/mc68020/mpih-mul1.S +++ b/mpi/m68k/mc68020/mpih-mul1.S @@ -37,7 +37,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -46,10 +46,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_mul_1) + GLOBL C_SYMBOL_NAME(_gcry_mpih_mul_1) -C_SYMBOL_NAME(mpihelp_mul_1:) -PROLOG(mpihelp_mul_1) +C_SYMBOL_NAME(_gcry_mpih_mul_1:) +PROLOG(_gcry_mpih_mul_1) #define res_ptr a0 #define s1_ptr a1 @@ -101,6 +101,6 @@ L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) movel MEM_POSTINC(sp),R(d2) #endif rts -EPILOG(mpihelp_mul_1) +EPILOG(_gcry_mpih_mul_1) diff --git a/mpi/m68k/mc68020/mpih-mul2.S b/mpi/m68k/mc68020/mpih-mul2.S index 7c492ffb..b2f9e7cc 100644 --- a/mpi/m68k/mc68020/mpih-mul2.S +++ b/mpi/m68k/mc68020/mpih-mul2.S @@ -35,7 +35,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -44,10 +44,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_addmul_1) + GLOBL C_SYMBOL_NAME(_gcry_mpih_addmul_1) -C_SYMBOL_NAME(mpihelp_addmul_1:) -PROLOG(mpihelp_addmul_1) +C_SYMBOL_NAME(_gcry_mpih_addmul_1:) +PROLOG(_gcry_mpih_addmul_1) #define res_ptr a0 #define s1_ptr a1 @@ -92,5 +92,5 @@ L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) moveml MEM_POSTINC(sp),R(d2)-R(d5) rts -EPILOG(mpihelp_addmul_1) +EPILOG(_gcry_mpih_addmul_1) diff --git a/mpi/m68k/mc68020/mpih-mul3.S b/mpi/m68k/mc68020/mpih-mul3.S index 1e4ac45d..f72a8120 100644 --- a/mpi/m68k/mc68020/mpih-mul3.S +++ b/mpi/m68k/mc68020/mpih-mul3.S @@ -37,7 +37,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_size_t s1_size, (sp + 12) * mpi_limb_t s2_limb) (sp + 16) @@ -46,10 +46,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_submul_1) + GLOBL C_SYMBOL_NAME(_gcry_mpih_submul_1) -C_SYMBOL_NAME(mpihelp_submul_1:) -PROLOG(mpihelp_submul_1) +C_SYMBOL_NAME(_gcry_mpih_submul_1:) +PROLOG(_gcry_mpih_submul_1) #define res_ptr a0 #define s1_ptr a1 @@ -94,6 +94,6 @@ L(L1:) movel MEM_POSTINC(s1_ptr),R(d3) moveml MEM_POSTINC(sp),R(d2)-R(d5) rts -EPILOG(mpihelp_submul_1) +EPILOG(_gcry_mpih_submul_1) diff --git a/mpi/m68k/mpih-add1.S b/mpi/m68k/mpih-add1.S index 1e9cc640..e05f89cd 100644 --- a/mpi/m68k/mpih-add1.S +++ b/mpi/m68k/mpih-add1.S @@ -36,7 +36,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 16) * mpi_size_t size) (sp + 12) @@ -45,10 +45,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_add_n) + GLOBL C_SYMBOL_NAME(_gcry_mpih_add_n) -C_SYMBOL_NAME(mpihelp_add_n:) -PROLOG(mpihelp_add_n) +C_SYMBOL_NAME(_gcry_mpih_add_n:) +PROLOG(_gcry_mpih_add_n) /* Save used registers on the stack. */ movel R(d2),MEM_PREDEC(sp) movel R(a2),MEM_PREDEC(sp) @@ -89,6 +89,6 @@ L(L2:) movel MEM_POSTINC(sp),R(d2) rts -EPILOG(mpihelp_add_n) +EPILOG(_gcry_mpih_add_n) diff --git a/mpi/m68k/mpih-lshift.S b/mpi/m68k/mpih-lshift.S index cc9dfba6..c7e485a4 100644 --- a/mpi/m68k/mpih-lshift.S +++ b/mpi/m68k/mpih-lshift.S @@ -34,7 +34,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_lshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -47,10 +47,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_lshift) + GLOBL C_SYMBOL_NAME(_gcry_mpih_lshift) -C_SYMBOL_NAME(mpihelp_lshift:) -PROLOG(mpihelp_lshift) +C_SYMBOL_NAME(_gcry_mpih_lshift:) +PROLOG(_gcry_mpih_lshift) /* Save used registers on the stack. */ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp) @@ -158,7 +158,7 @@ L(LLend:) /* Restore used registers from stack frame. */ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) rts -EPILOG(mpihelp_lshift) +EPILOG(_gcry_mpih_lshift) diff --git a/mpi/m68k/mpih-rshift.S b/mpi/m68k/mpih-rshift.S index cc86166a..d9be3e0d 100644 --- a/mpi/m68k/mpih-rshift.S +++ b/mpi/m68k/mpih-rshift.S @@ -34,7 +34,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (sp + 4) + * _gcry_mpih_rshift( mpi_ptr_t wp, (sp + 4) * mpi_ptr_t up, (sp + 8) * mpi_size_t usize, (sp + 12) * unsigned cnt) (sp + 16) @@ -47,10 +47,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_rshift) + GLOBL C_SYMBOL_NAME(_gcry_mpih_rshift) -C_SYMBOL_NAME(mpihelp_rshift:) -PROLOG(mpihelp_rshift) +C_SYMBOL_NAME(_gcry_mpih_rshift:) +PROLOG(_gcry_mpih_rshift) /* Save used registers on the stack. */ moveml R(d2)-R(d6)/R(a2),MEM_PREDEC(sp) @@ -157,7 +157,7 @@ L(LRend:) /* Restore used registers from stack frame. */ moveml MEM_POSTINC(sp),R(d2)-R(d6)/R(a2) rts -EPILOG(mpihelp_rshift) +EPILOG(_gcry_mpih_rshift) diff --git a/mpi/m68k/mpih-sub1.S b/mpi/m68k/mpih-sub1.S index 1847fbd6..945b8d24 100644 --- a/mpi/m68k/mpih-sub1.S +++ b/mpi/m68k/mpih-sub1.S @@ -35,7 +35,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (sp + 4) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (sp + 4) * mpi_ptr_t s1_ptr, (sp + 8) * mpi_ptr_t s2_ptr, (sp + 16) * mpi_size_t size) (sp + 12) @@ -44,10 +44,10 @@ TEXT ALIGN - GLOBL C_SYMBOL_NAME(mpihelp_sub_n) + GLOBL C_SYMBOL_NAME(_gcry_mpih_sub_n) -C_SYMBOL_NAME(mpihelp_sub_n:) -PROLOG(mpihelp_sub_n) +C_SYMBOL_NAME(_gcry_mpih_sub_n:) +PROLOG(_gcry_mpih_sub_n) /* Save used registers on the stack. */ movel R(d2),MEM_PREDEC(sp) movel R(a2),MEM_PREDEC(sp) @@ -88,6 +88,6 @@ L(L2:) movel MEM_POSTINC(sp),R(d2) rts -EPILOG(mpihelp_sub_n) +EPILOG(_gcry_mpih_sub_n) diff --git a/mpi/mips3/mpih-add1.S b/mpi/mips3/mpih-add1.S index a998420d..8b329240 100644 --- a/mpi/mips3/mpih-add1.S +++ b/mpi/mips3/mpih-add1.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, ($4) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, ($4) * mpi_ptr_t s1_ptr, ($5) * mpi_ptr_t s2_ptr, ($6) * mpi_size_t size) ($7) @@ -32,9 +32,9 @@ .text .align 2 - .globl mpihelp_add_n - .ent mpihelp_add_n -mpihelp_add_n: + .globl _gcry_mpih_add_n + .ent _gcry_mpih_add_n +_gcry_mpih_add_n: .set noreorder .set nomacro @@ -120,5 +120,5 @@ mpihelp_add_n: j $31 or $2,$2,$8 - .end mpihelp_add_n + .end _gcry_mpih_add_n diff --git a/mpi/mips3/mpih-lshift.S b/mpi/mips3/mpih-lshift.S index 112383f9..421fe649 100644 --- a/mpi/mips3/mpih-lshift.S +++ b/mpi/mips3/mpih-lshift.S @@ -22,7 +22,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, ($4) + * _gcry_mpih_lshift( mpi_ptr_t wp, ($4) * mpi_ptr_t up, ($5) * mpi_size_t usize, ($6) * unsigned cnt) ($7) @@ -30,9 +30,9 @@ .text .align 2 - .globl mpihelp_lshift - .ent mpihelp_lshift -mpihelp_lshift: + .globl _gcry_mpih_lshift + .ent _gcry_mpih_lshift +_gcry_mpih_lshift: .set noreorder .set nomacro @@ -94,4 +94,4 @@ mpihelp_lshift: .Lend: dsll $8,$10,$7 j $31 sd $8,-8($4) - .end mpihelp_lshift + .end _gcry_mpih_lshift diff --git a/mpi/mips3/mpih-mul1.S b/mpi/mips3/mpih-mul1.S index 70409e8d..99557374 100644 --- a/mpi/mips3/mpih-mul1.S +++ b/mpi/mips3/mpih-mul1.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (r4) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r4) * mpi_ptr_t s1_ptr, (r5) * mpi_size_t s1_size, (r6) * mpi_limb_t s2_limb) (r7) @@ -32,9 +32,9 @@ .text .align 4 - .globl mpihelp_mul_1 - .ent mpihelp_mul_1 -mpihelp_mul_1: + .globl _gcry_mpih_mul_1 + .ent _gcry_mpih_mul_1 +_gcry_mpih_mul_1: .set noreorder .set nomacro @@ -85,5 +85,5 @@ $LC0: mflo $10 j $31 daddu $2,$9,$2 # add high product limb and carry from addition - .end mpihelp_mul_1 + .end _gcry_mpih_mul_1 diff --git a/mpi/mips3/mpih-mul2.S b/mpi/mips3/mpih-mul2.S index 1bddd053..a58e4446 100644 --- a/mpi/mips3/mpih-mul2.S +++ b/mpi/mips3/mpih-mul2.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (r4) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r4) * mpi_ptr_t s1_ptr, (r5) * mpi_size_t s1_size, (r6) * mpi_limb_t s2_limb) (r7) @@ -32,9 +32,9 @@ .text .align 4 - .globl mpihelp_addmul_1 - .ent mpihelp_addmul_1 -mpihelp_addmul_1: + .globl _gcry_mpih_addmul_1 + .ent _gcry_mpih_addmul_1 +_gcry_mpih_addmul_1: .set noreorder .set nomacro @@ -97,5 +97,5 @@ $LC0: ld $10,0($4) j $31 daddu $2,$9,$2 # add high product limb and carry from addition - .end mpihelp_addmul_1 + .end _gcry_mpih_addmul_1 diff --git a/mpi/mips3/mpih-mul3.S b/mpi/mips3/mpih-mul3.S index 82fe47d5..3410c009 100644 --- a/mpi/mips3/mpih-mul3.S +++ b/mpi/mips3/mpih-mul3.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (r4) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r4) * mpi_ptr_t s1_ptr, (r5) * mpi_size_t s1_size, (r6) * mpi_limb_t s2_limb) (r7) @@ -32,9 +32,9 @@ .text .align 4 - .globl mpihelp_submul_1 - .ent mpihelp_submul_1 -mpihelp_submul_1: + .globl _gcry_mpih_submul_1 + .ent _gcry_mpih_submul_1 +_gcry_mpih_submul_1: .set noreorder .set nomacro @@ -97,5 +97,5 @@ $LC0: ld $10,0($4) j $31 daddu $2,$9,$2 # add high product limb and carry from addition - .end mpihelp_submul_1 + .end _gcry_mpih_submul_1 diff --git a/mpi/mips3/mpih-rshift.S b/mpi/mips3/mpih-rshift.S index 74a6cc96..8b43aab5 100644 --- a/mpi/mips3/mpih-rshift.S +++ b/mpi/mips3/mpih-rshift.S @@ -22,7 +22,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, ($4) + * _gcry_mpih_rshift( mpi_ptr_t wp, ($4) * mpi_ptr_t up, ($5) * mpi_size_t usize, ($6) * unsigned cnt) ($7) @@ -30,9 +30,9 @@ .text .align 2 - .globl mpihelp_rshift - .ent mpihelp_rshift -mpihelp_rshift: + .globl _gcry_mpih_rshift + .ent _gcry_mpih_rshift +_gcry_mpih_rshift: .set noreorder .set nomacro @@ -91,5 +91,5 @@ mpihelp_rshift: .Lend: dsrl $8,$10,$7 j $31 sd $8,0($4) - .end mpihelp_rshift + .end _gcry_mpih_rshift diff --git a/mpi/mips3/mpih-sub1.S b/mpi/mips3/mpih-sub1.S index 72f506ea..5af10716 100644 --- a/mpi/mips3/mpih-sub1.S +++ b/mpi/mips3/mpih-sub1.S @@ -24,7 +24,7 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (r4) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r4) * mpi_ptr_t s1_ptr, (r5) * mpi_ptr_t s2_ptr, (r6) * mpi_size_t size) (r7) @@ -33,9 +33,9 @@ .text .align 2 - .globl mpihelp_sub_n - .ent mpihelp_sub_n -mpihelp_sub_n: + .globl _gcry_mpih_sub_n + .ent _gcry_mpih_sub_n +_gcry_mpih_sub_n: .set noreorder .set nomacro @@ -121,5 +121,5 @@ mpihelp_sub_n: j $31 or $2,$2,$8 - .end mpihelp_sub_n + .end _gcry_mpih_sub_n diff --git a/mpi/mpi-add.c b/mpi/mpi-add.c index 1cca9e34..cb9031b6 100644 --- a/mpi/mpi-add.c +++ b/mpi/mpi-add.c @@ -1,6 +1,5 @@ /* mpi-add.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -39,7 +38,7 @@ * result in W. U and V may be the same. */ void -mpi_add_ui(MPI w, MPI u, unsigned long v ) +gcry_mpi_add_ui(MPI w, MPI u, unsigned long v ) { mpi_ptr_t wp, up; mpi_size_t usize, wsize; @@ -64,7 +63,7 @@ mpi_add_ui(MPI w, MPI u, unsigned long v ) } else if( !usign ) { /* mpi is not negative */ mpi_limb_t cy; - cy = mpihelp_add_1(wp, up, usize, v); + cy = _gcry_mpih_add_1(wp, up, usize, v); wp[usize] = cy; wsize = usize + cy; } @@ -75,7 +74,7 @@ mpi_add_ui(MPI w, MPI u, unsigned long v ) wsize = 1; } else { - mpihelp_sub_1(wp, up, usize, v); + _gcry_mpih_sub_1(wp, up, usize, v); /* Size can decrease with at most one limb. */ wsize = usize - (wp[usize-1]==0); wsign = 1; @@ -88,7 +87,7 @@ mpi_add_ui(MPI w, MPI u, unsigned long v ) void -mpi_add(MPI w, MPI u, MPI v) +gcry_mpi_add(MPI w, MPI u, MPI v) { mpi_ptr_t wp, up, vp; mpi_size_t usize, vsize, wsize; @@ -127,20 +126,20 @@ mpi_add(MPI w, MPI u, MPI v) else if( usign != vsign ) { /* different sign */ /* This test is right since USIZE >= VSIZE */ if( usize != vsize ) { - mpihelp_sub(wp, up, usize, vp, vsize); + _gcry_mpih_sub(wp, up, usize, vp, vsize); wsize = usize; MPN_NORMALIZE(wp, wsize); wsign = usign; } - else if( mpihelp_cmp(up, vp, usize) < 0 ) { - mpihelp_sub_n(wp, vp, up, usize); + else if( _gcry_mpih_cmp(up, vp, usize) < 0 ) { + _gcry_mpih_sub_n(wp, vp, up, usize); wsize = usize; MPN_NORMALIZE(wp, wsize); if( !usign ) wsign = 1; } else { - mpihelp_sub_n(wp, up, vp, usize); + _gcry_mpih_sub_n(wp, up, vp, usize); wsize = usize; MPN_NORMALIZE(wp, wsize); if( usign ) @@ -148,7 +147,7 @@ mpi_add(MPI w, MPI u, MPI v) } } else { /* U and V have same sign. Add them. */ - mpi_limb_t cy = mpihelp_add(wp, up, usize, vp, vsize); + mpi_limb_t cy = _gcry_mpih_add(wp, up, usize, vp, vsize); wp[usize] = cy; wsize = usize + cy; if( usign ) @@ -165,7 +164,7 @@ mpi_add(MPI w, MPI u, MPI v) * result in W. */ void -mpi_sub_ui(MPI w, MPI u, unsigned long v ) +gcry_mpi_sub_ui(MPI w, MPI u, unsigned long v ) { mpi_ptr_t wp, up; mpi_size_t usize, wsize; @@ -191,7 +190,7 @@ mpi_sub_ui(MPI w, MPI u, unsigned long v ) } else if( usign ) { /* mpi and v are negative */ mpi_limb_t cy; - cy = mpihelp_add_1(wp, up, usize, v); + cy = _gcry_mpih_add_1(wp, up, usize, v); wp[usize] = cy; wsize = usize + cy; } @@ -203,7 +202,7 @@ mpi_sub_ui(MPI w, MPI u, unsigned long v ) wsign = 1; } else { - mpihelp_sub_1(wp, up, usize, v); + _gcry_mpih_sub_1(wp, up, usize, v); /* Size can decrease with at most one limb. */ wsize = usize - (wp[usize-1]==0); } @@ -214,34 +213,34 @@ mpi_sub_ui(MPI w, MPI u, unsigned long v ) } void -mpi_sub(MPI w, MPI u, MPI v) +gcry_mpi_sub(MPI w, MPI u, MPI v) { if( w == v ) { MPI vv = mpi_copy(v); vv->sign = !vv->sign; - mpi_add( w, u, vv ); + gcry_mpi_add( w, u, vv ); mpi_free(vv); } else { /* fixme: this is not thread-save (we temp. modify v) */ v->sign = !v->sign; - mpi_add( w, u, v ); + gcry_mpi_add( w, u, v ); v->sign = !v->sign; } } void -mpi_addm( MPI w, MPI u, MPI v, MPI m) +gcry_mpi_addm( MPI w, MPI u, MPI v, MPI m) { - mpi_add(w, u, v); - mpi_fdiv_r( w, w, m ); + gcry_mpi_add(w, u, v); + _gcry_mpi_fdiv_r( w, w, m ); } void -mpi_subm( MPI w, MPI u, MPI v, MPI m) +gcry_mpi_subm( MPI w, MPI u, MPI v, MPI m) { - mpi_sub(w, u, v); - mpi_fdiv_r( w, w, m ); + gcry_mpi_sub(w, u, v); + _gcry_mpi_fdiv_r( w, w, m ); } diff --git a/mpi/mpi-bit.c b/mpi/mpi-bit.c index ff1dfe3b..d9c2f6c3 100644 --- a/mpi/mpi-bit.c +++ b/mpi/mpi-bit.c @@ -1,5 +1,5 @@ /* mpi-bit.c - MPI bit level fucntions - * Copyright (C) 1998, 1999 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -53,7 +53,7 @@ __clz_tab[] = * this is for some reasons not good, so this function removes them. */ void -mpi_normalize( MPI a ) +_gcry_mpi_normalize( MPI a ) { if( mpi_is_opaque(a) ) return; @@ -68,7 +68,7 @@ mpi_normalize( MPI a ) * Return the number of bits in A. */ unsigned int -mpi_get_nbits( MPI a ) +gcry_mpi_get_nbits( MPI a ) { unsigned n; @@ -76,7 +76,7 @@ mpi_get_nbits( MPI a ) return a->sign; /* which holds the number of bits */ } - mpi_normalize( a ); + _gcry_mpi_normalize( a ); if( a->nlimbs ) { mpi_limb_t alimb = a->d[a->nlimbs-1]; if( alimb ) @@ -90,19 +90,14 @@ 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. */ int -mpi_test_bit( MPI a, unsigned n ) +gcry_mpi_test_bit( MPI a, unsigned int n ) { - unsigned limbno, bitno; + unsigned int limbno, bitno; mpi_limb_t limb; limbno = n / BITS_PER_MPI_LIMB; @@ -119,9 +114,9 @@ mpi_test_bit( MPI a, unsigned n ) * Set bit N of A. */ void -mpi_set_bit( MPI a, unsigned n ) +gcry_mpi_set_bit( MPI a, unsigned int n ) { - unsigned limbno, bitno; + unsigned int limbno, bitno; limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; @@ -138,9 +133,9 @@ mpi_set_bit( MPI a, unsigned n ) * Set bit N of A. and clear all bits above */ void -mpi_set_highbit( MPI a, unsigned n ) +gcry_mpi_set_highbit( MPI a, unsigned int n ) { - unsigned limbno, bitno; + unsigned int limbno, bitno; limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; @@ -160,9 +155,9 @@ mpi_set_highbit( MPI a, unsigned n ) * clear bit N of A and all bits above */ void -mpi_clear_highbit( MPI a, unsigned n ) +gcry_mpi_clear_highbit( MPI a, unsigned int n ) { - unsigned limbno, bitno; + unsigned int limbno, bitno; limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; @@ -179,9 +174,9 @@ mpi_clear_highbit( MPI a, unsigned n ) * Clear bit N of A. */ void -mpi_clear_bit( MPI a, unsigned n ) +gcry_mpi_clear_bit( MPI a, unsigned int n ) { - unsigned limbno, bitno; + unsigned int limbno, bitno; limbno = n / BITS_PER_MPI_LIMB; bitno = n % BITS_PER_MPI_LIMB; @@ -197,7 +192,7 @@ mpi_clear_bit( MPI a, unsigned n ) * FIXME: should use alloc_limb if X and A are same. */ void -mpi_rshift( MPI x, MPI a, unsigned n ) +gcry_mpi_rshift( MPI x, MPI a, unsigned n ) { mpi_ptr_t xp; mpi_size_t xsize; @@ -208,7 +203,7 @@ mpi_rshift( MPI x, MPI a, unsigned n ) xp = x->d; if( xsize ) { - mpihelp_rshift( xp, a->d, xsize, n); + _gcry_mpih_rshift( xp, a->d, xsize, n); MPN_NORMALIZE( xp, xsize); } x->nlimbs = xsize; @@ -220,7 +215,7 @@ mpi_rshift( MPI x, MPI a, unsigned n ) * This is used only within the MPI library */ void -mpi_lshift_limbs( MPI a, unsigned int count ) +_gcry_mpi_lshift_limbs( MPI a, unsigned int count ) { mpi_ptr_t ap = a->d; int n = a->nlimbs; @@ -244,7 +239,7 @@ mpi_lshift_limbs( MPI a, unsigned int count ) * This is used only within the MPI library */ void -mpi_rshift_limbs( MPI a, unsigned int count ) +_gcry_mpi_rshift_limbs( MPI a, unsigned int count ) { mpi_ptr_t ap = a->d; mpi_size_t n = a->nlimbs; @@ -260,5 +255,3 @@ mpi_rshift_limbs( MPI a, unsigned int count ) ap[i] = 0; a->nlimbs -= count; } - - diff --git a/mpi/mpi-cmp.c b/mpi/mpi-cmp.c index 367855dd..485b147c 100644 --- a/mpi/mpi-cmp.c +++ b/mpi/mpi-cmp.c @@ -1,5 +1,5 @@ /* mpi-cmp.c - MPI functions - * Copyright (C) 1998, 1999 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -24,11 +24,11 @@ #include "mpi-internal.h" int -mpi_cmp_ui( MPI u, unsigned long v ) +gcry_mpi_cmp_ui( MPI u, unsigned long v ) { mpi_limb_t limb = v; - mpi_normalize( u ); + _gcry_mpi_normalize( u ); if( !u->nlimbs && !limb ) return 0; if( u->sign ) @@ -45,13 +45,13 @@ mpi_cmp_ui( MPI u, unsigned long v ) } int -mpi_cmp( MPI u, MPI v ) +gcry_mpi_cmp( MPI u, MPI v ) { mpi_size_t usize, vsize; int cmp; - mpi_normalize( u ); - mpi_normalize( v ); + _gcry_mpi_normalize( u ); + _gcry_mpi_normalize( v ); usize = u->nlimbs; vsize = v->nlimbs; if( !u->sign && v->sign ) @@ -64,7 +64,7 @@ mpi_cmp( MPI u, MPI v ) return vsize + usize; if( !usize ) return 0; - if( !(cmp=mpihelp_cmp( u->d, v->d, usize )) ) + if( !(cmp = _gcry_mpih_cmp( u->d, v->d, usize )) ) return 0; if( (cmp < 0?1:0) == (u->sign?1:0)) return 1; diff --git a/mpi/mpi-div.c b/mpi/mpi-div.c index e706c004..a439c46d 100644 --- a/mpi/mpi-div.c +++ b/mpi/mpi-div.c @@ -1,6 +1,5 @@ /* mpi-div.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -32,11 +31,11 @@ #include <stdlib.h> #include "mpi-internal.h" #include "longlong.h" - +#include "g10lib.h" void -mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ) +_gcry_mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ) { int divisor_sign = divisor->sign; MPI temp_divisor = NULL; @@ -49,10 +48,10 @@ mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ) divisor = temp_divisor; } - mpi_tdiv_r( rem, dividend, divisor ); + _gcry_mpi_tdiv_r( rem, dividend, divisor ); if( ((divisor_sign?1:0) ^ (dividend->sign?1:0)) && rem->nlimbs ) - mpi_add( rem, rem, divisor); + gcry_mpi_add( rem, rem, divisor); if( temp_divisor ) mpi_free(temp_divisor); @@ -67,11 +66,11 @@ mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ) */ ulong -mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor ) +_gcry_mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor ) { mpi_limb_t rlimb; - rlimb = mpihelp_mod_1( dividend->d, dividend->nlimbs, divisor ); + rlimb = _gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor ); if( rlimb && dividend->sign ) rlimb = divisor - rlimb; @@ -84,15 +83,15 @@ mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor ) void -mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor ) +_gcry_mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor ) { MPI tmp = mpi_alloc( mpi_get_nlimbs(quot) ); - mpi_fdiv_qr( quot, tmp, dividend, divisor); + _gcry_mpi_fdiv_qr( quot, tmp, dividend, divisor); mpi_free(tmp); } void -mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ) +_gcry_mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ) { int divisor_sign = divisor->sign; MPI temp_divisor = NULL; @@ -102,11 +101,11 @@ mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ) divisor = temp_divisor; } - mpi_tdiv_qr( quot, rem, dividend, divisor ); + _gcry_mpi_tdiv_qr( quot, rem, dividend, divisor ); if( (divisor_sign ^ dividend->sign) && rem->nlimbs ) { - mpi_sub_ui( quot, quot, 1 ); - mpi_add( rem, rem, divisor); + gcry_mpi_sub_ui( quot, quot, 1 ); + gcry_mpi_add( rem, rem, divisor); } if( temp_divisor ) @@ -122,13 +121,13 @@ mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ) */ void -mpi_tdiv_r( MPI rem, MPI num, MPI den) +_gcry_mpi_tdiv_r( MPI rem, MPI num, MPI den) { - mpi_tdiv_qr(NULL, rem, num, den ); + _gcry_mpi_tdiv_qr(NULL, rem, num, den ); } void -mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) +_gcry_mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) { mpi_ptr_t np, dp; mpi_ptr_t qp, rp; @@ -177,13 +176,13 @@ mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) mpi_limb_t rlimb; if( quot ) { qp = quot->d; - rlimb = mpihelp_divmod_1( qp, np, nsize, dp[0] ); + rlimb = _gcry_mpih_divmod_1( qp, np, nsize, dp[0] ); qsize -= qp[qsize - 1] == 0; quot->nlimbs = qsize; quot->sign = sign_quotient; } else - rlimb = mpihelp_mod_1( np, nsize, dp[0] ); + rlimb = _gcry_mpih_mod_1( np, nsize, dp[0] ); rp[0] = rlimb; rsize = rlimb != 0?1:0; rem->nlimbs = rsize; @@ -219,13 +218,13 @@ mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) * the most significant word. Use temporary storage not to clobber * the original contents of the denominator. */ tp = marker[markidx++] = mpi_alloc_limb_space(dsize,mpi_is_secure(den)); - mpihelp_lshift( tp, dp, dsize, normalization_steps ); + _gcry_mpih_lshift( tp, dp, dsize, normalization_steps ); dp = tp; /* Shift up the numerator, possibly introducing a new most * significant word. Move the shifted numerator in the remainder * meanwhile. */ - nlimb = mpihelp_lshift(rp, np, nsize, normalization_steps); + nlimb = _gcry_mpih_lshift(rp, np, nsize, normalization_steps); if( nlimb ) { rp[nsize] = nlimb; rsize = nsize + 1; @@ -251,7 +250,7 @@ mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) rsize = nsize; } - q_limb = mpihelp_divrem( qp, 0, rp, rsize, dp, dsize ); + q_limb = _gcry_mpih_divrem( qp, 0, rp, rsize, dp, dsize ); if( quot ) { qsize = rsize - dsize; @@ -268,7 +267,7 @@ mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) MPN_NORMALIZE (rp, rsize); if( normalization_steps && rsize ) { - mpihelp_rshift(rp, rp, rsize, normalization_steps); + _gcry_mpih_rshift(rp, rp, rsize, normalization_steps); rsize -= rp[rsize - 1] == 0?1:0; } @@ -279,7 +278,7 @@ mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den) } void -mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count ) +_gcry_mpi_tdiv_q_2exp( MPI w, MPI u, unsigned int count ) { mpi_size_t usize, wsize; mpi_size_t limb_cnt; @@ -299,7 +298,7 @@ mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count ) count %= BITS_PER_MPI_LIMB; if( count ) { - mpihelp_rshift( wp, up + limb_cnt, wsize, count ); + _gcry_mpih_rshift( wp, up + limb_cnt, wsize, count ); wsize -= !wp[wsize - 1]; } else { @@ -315,8 +314,8 @@ mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count ) * (note: divisor must fit into a limb) */ int -mpi_divisible_ui(MPI dividend, ulong divisor ) +_gcry_mpi_divisible_ui(MPI dividend, ulong divisor ) { - return !mpihelp_mod_1( dividend->d, dividend->nlimbs, divisor ); + return !_gcry_mpih_mod_1( dividend->d, dividend->nlimbs, divisor ); } diff --git a/mpi/mpi-gcd.c b/mpi/mpi-gcd.c index 5576db20..5242adaf 100644 --- a/mpi/mpi-gcd.c +++ b/mpi/mpi-gcd.c @@ -1,5 +1,5 @@ /* mpi-gcd.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -28,7 +28,7 @@ * Return: true if this 1, false in all other cases */ int -mpi_gcd( MPI g, MPI xa, MPI xb ) +gcry_mpi_gcd( MPI g, MPI xa, MPI xb ) { MPI a, b; @@ -38,8 +38,8 @@ mpi_gcd( MPI g, MPI xa, MPI xb ) /* TAOCP Vol II, 4.5.2, Algorithm A */ a->sign = 0; b->sign = 0; - while( mpi_cmp_ui( b, 0 ) ) { - mpi_fdiv_r( g, a, b ); /* g used as temorary variable */ + while( gcry_mpi_cmp_ui( b, 0 ) ) { + _gcry_mpi_fdiv_r( g, a, b ); /* g used as temorary variable */ mpi_set(a,b); mpi_set(b,g); } @@ -47,7 +47,7 @@ mpi_gcd( MPI g, MPI xa, MPI xb ) mpi_free(a); mpi_free(b); - return !mpi_cmp_ui( g, 1); + return !gcry_mpi_cmp_ui( g, 1); } diff --git a/mpi/mpi-inline.h b/mpi/mpi-inline.h index 2f246c87..6a53e721 100644 --- a/mpi/mpi-inline.h +++ b/mpi/mpi-inline.h @@ -1,6 +1,5 @@ /* mpi-inline.h - Internal to the Multi Precision Integers - * Copyright (C) 1998, 1999 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 1999, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -35,7 +34,7 @@ #endif G10_MPI_INLINE_DECL mpi_limb_t -mpihelp_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb) { mpi_limb_t x; @@ -65,23 +64,23 @@ mpihelp_add_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, G10_MPI_INLINE_DECL mpi_limb_t -mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, +_gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size) { mpi_limb_t cy = 0; if( s2_size ) - cy = mpihelp_add_n( res_ptr, s1_ptr, s2_ptr, s2_size ); + cy = _gcry_mpih_add_n( res_ptr, s1_ptr, s2_ptr, s2_size ); if( s1_size - s2_size ) - cy = mpihelp_add_1( res_ptr + s2_size, s1_ptr + s2_size, + cy = _gcry_mpih_add_1( res_ptr + s2_size, s1_ptr + s2_size, s1_size - s2_size, cy); return cy; } G10_MPI_INLINE_DECL mpi_limb_t -mpihelp_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +_gcry_mpih_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb ) { mpi_limb_t x; @@ -111,19 +110,46 @@ mpihelp_sub_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, G10_MPI_INLINE_DECL mpi_limb_t -mpihelp_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, +_gcry_mpih_sub( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size) { mpi_limb_t cy = 0; if( s2_size ) - cy = mpihelp_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size); + cy = _gcry_mpih_sub_n(res_ptr, s1_ptr, s2_ptr, s2_size); if( s1_size - s2_size ) - cy = mpihelp_sub_1(res_ptr + s2_size, s1_ptr + s2_size, + cy = _gcry_mpih_sub_1(res_ptr + s2_size, s1_ptr + s2_size, s1_size - s2_size, cy); return cy; } +/**************** + * Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE. + * There are no restrictions on the relative sizes of + * the two arguments. + * Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2. + */ +G10_MPI_INLINE_DECL int +_gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size ) +{ + mpi_size_t i; + mpi_limb_t op1_word, op2_word; + + for( i = size - 1; i >= 0 ; i--) { + op1_word = op1_ptr[i]; + op2_word = op2_ptr[i]; + if( op1_word != op2_word ) + goto diff; + } + return 0; + + diff: + /* This can *not* be simplified to + * op2_word - op2_word + * since that expression might give signed overflow. */ + return (op1_word > op2_word) ? 1 : -1; +} + #endif /*G10_MPI_INLINE_H*/ diff --git a/mpi/mpi-internal.h b/mpi/mpi-internal.h index fe90521d..ec26ef30 100644 --- a/mpi/mpi-internal.h +++ b/mpi/mpi-internal.h @@ -172,41 +172,43 @@ typedef int mpi_size_t; /* (must be a signed type) */ /*-- mpiutil.c --*/ #ifdef M_DEBUG - #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__ ) ) - 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 ); + #define mpi_alloc_limb_space(n,f) _gcry_mpi_debug_alloc_limb_space((n),(f), M_DBGINFO( __LINE__ ) ) + #define mpi_free_limb_space(n) _gcry_mpi_debug_free_limb_space((n), M_DBGINFO( __LINE__ ) ) + mpi_ptr_t _gcry_mpi_debug_alloc_limb_space( unsigned nlimbs, int sec, const char *info ); + void _gcry_mpi_debug_free_limb_space( mpi_ptr_t a, const char *info ); #else - mpi_ptr_t mpi_alloc_limb_space( unsigned nlimbs, int sec ); - void mpi_free_limb_space( mpi_ptr_t a ); + #define mpi_alloc_limb_space(n,f) _gcry_mpi_alloc_limb_space((n),(f)) + #define mpi_free_limb_space(n) _gcry_mpi_free_limb_space((n)) + mpi_ptr_t _gcry_mpi_alloc_limb_space( unsigned nlimbs, int sec ); + void _gcry_mpi_free_limb_space( mpi_ptr_t a ); #endif -void mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs ); +void _gcry_mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs ); /*-- mpi-bit.c --*/ -void mpi_rshift_limbs( MPI a, unsigned int count ); -void mpi_lshift_limbs( MPI a, unsigned int count ); +void _gcry_mpi_rshift_limbs( MPI a, unsigned int count ); +void _gcry_mpi_lshift_limbs( MPI a, unsigned int count ); -/*-- mpihelp-add.c --*/ -mpi_limb_t mpihelp_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +/*-- mpih-add.c --*/ +mpi_limb_t _gcry_mpih_add_1(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb ); -mpi_limb_t mpihelp_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +mpi_limb_t _gcry_mpih_add_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size); -mpi_limb_t mpihelp_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, +mpi_limb_t _gcry_mpih_add(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size); -/*-- mpihelp-sub.c --*/ -mpi_limb_t mpihelp_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +/*-- mpih-sub.c --*/ +mpi_limb_t _gcry_mpih_sub_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb ); -mpi_limb_t mpihelp_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +mpi_limb_t _gcry_mpih_sub_n( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_ptr_t s2_ptr, mpi_size_t size); -mpi_limb_t mpihelp_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, +mpi_limb_t _gcry_mpih_sub(mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_ptr_t s2_ptr, mpi_size_t s2_size); -/*-- mpihelp-cmp.c --*/ -int mpihelp_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size ); +/*-- mpih-cmp.c --*/ +int _gcry_mpih_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size ); -/*-- mpihelp-mul.c --*/ +/*-- mpih-mul.c --*/ struct karatsuba_ctx { struct karatsuba_ctx *next; @@ -216,44 +218,44 @@ struct karatsuba_ctx { mpi_size_t tp_size; }; -void mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx ); +void _gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx ); -mpi_limb_t mpihelp_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +mpi_limb_t _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb); -mpi_limb_t mpihelp_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +mpi_limb_t _gcry_mpih_submul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb); -void mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, +void _gcry_mpih_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size); -mpi_limb_t mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, +mpi_limb_t _gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, mpi_ptr_t vp, mpi_size_t vsize); -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, +void _gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ); +void _gcry_mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace); -void mpihelp_mul_karatsuba_case( mpi_ptr_t prodp, +void _gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, mpi_ptr_t vp, mpi_size_t vsize, struct karatsuba_ctx *ctx ); -/*-- mpihelp-mul_1.c (or xxx/cpu/ *.S) --*/ -mpi_limb_t mpihelp_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, +/*-- mpih-mul_1.c (or xxx/cpu/ *.S) --*/ +mpi_limb_t _gcry_mpih_mul_1( mpi_ptr_t res_ptr, mpi_ptr_t s1_ptr, mpi_size_t s1_size, mpi_limb_t s2_limb); -/*-- mpihelp-div.c --*/ -mpi_limb_t mpihelp_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, +/*-- mpih-div.c --*/ +mpi_limb_t _gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, mpi_limb_t divisor_limb); -mpi_limb_t mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, +mpi_limb_t _gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, mpi_ptr_t np, mpi_size_t nsize, mpi_ptr_t dp, mpi_size_t dsize); -mpi_limb_t mpihelp_divmod_1( mpi_ptr_t quot_ptr, +mpi_limb_t _gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, mpi_limb_t divisor_limb); -/*-- mpihelp-shift.c --*/ -mpi_limb_t mpihelp_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, +/*-- mpih-shift.c --*/ +mpi_limb_t _gcry_mpih_lshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt); -mpi_limb_t mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, +mpi_limb_t _gcry_mpih_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, unsigned cnt); @@ -278,3 +280,4 @@ mpi_limb_t mpihelp_rshift( mpi_ptr_t wp, mpi_ptr_t up, mpi_size_t usize, #endif #endif /*G10_MPI_INTERNAL_H*/ + diff --git a/mpi/mpi-inv.c b/mpi/mpi-inv.c index f8cb85a7..ab890a7a 100644 --- a/mpi/mpi-inv.c +++ b/mpi/mpi-inv.c @@ -1,5 +1,5 @@ /* mpi-inv.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -22,7 +22,7 @@ #include <stdio.h> #include <stdlib.h> #include "mpi-internal.h" - +#include "g10lib.h" /**************** * Calculate the multiplicative inverse X of A mod N @@ -30,7 +30,7 @@ * 1 = (a*x) mod n */ void -mpi_invm( MPI x, MPI a, MPI n ) +_gcry_mpi_invm( MPI x, MPI a, MPI n ) { #if 0 MPI u, v, u1, u2, u3, v1, v2, v3, q, t1, t2, t3; diff --git a/mpi/mpi-mpow.c b/mpi/mpi-mpow.c index 9414844d..9df505e3 100644 --- a/mpi/mpi-mpow.c +++ b/mpi/mpi-mpow.c @@ -1,5 +1,5 @@ /* mpi-mpow.c - MPI functions - * Copyright (C) 1998, 1999 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -23,8 +23,10 @@ #include <stdlib.h> #include "mpi-internal.h" #include "longlong.h" +#include "g10lib.h" #include <assert.h> + /* Barrett is slower than the classical way. It can be tweaked by * using partial multiplications */ @@ -37,7 +39,7 @@ static void barrett_mulm( MPI w, MPI u, MPI v, MPI m, MPI y, int k, MPI r1, MPI static MPI init_barrett( MPI m, int *k, MPI *r1, MPI *r2 ); static int calc_barrett( MPI r, MPI x, MPI m, MPI y, int k, MPI r1, MPI r2 ); #else -#define barrett_mulm( w, u, v, m, y, k, r1, r2 ) mpi_mulm( (w), (u), (v), (m) ) +#define barrett_mulm( w, u, v, m, y, k, r1, r2 ) gcry_mpi_mulm( (w), (u), (v), (m) ) #endif @@ -61,7 +63,7 @@ build_index( MPI *exparray, int k, int i, int t ) * RES = (BASE[0] ^ EXP[0]) * (BASE[1] ^ EXP[1]) * ... * mod M */ void -mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI m) +_gcry_mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI m) { int k; /* number of elements */ int t; /* bit size of largest exponent */ @@ -87,7 +89,7 @@ mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI m) assert(t); assert( k < 10 ); - G = g10_xcalloc( (1<<k) , sizeof *G ); + G = gcry_xcalloc( (1<<k) , sizeof *G ); #ifdef USE_BARRETT barrett_y = init_barrett( m, &barrett_k, &barrett_r1, &barrett_r2 ); #endif @@ -128,7 +130,7 @@ mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI m) #endif for(i=0; i < (1<<k); i++ ) mpi_free(G[i]); - g10_free(G); + gcry_free(G); } diff --git a/mpi/mpi-mul.c b/mpi/mpi-mul.c index 280e47a9..4a7dd7d6 100644 --- a/mpi/mpi-mul.c +++ b/mpi/mpi-mul.c @@ -1,6 +1,5 @@ /* mpi-mul.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -34,7 +33,7 @@ void -mpi_mul_ui( MPI prod, MPI mult, unsigned long small_mult ) +gcry_mpi_mul_ui( MPI prod, MPI mult, unsigned long small_mult ) { mpi_size_t size, prod_size; mpi_ptr_t prod_ptr; @@ -55,7 +54,7 @@ mpi_mul_ui( MPI prod, MPI mult, unsigned long small_mult ) mpi_resize( prod, prod_size ); prod_ptr = prod->d; - cy = mpihelp_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult ); + cy = _gcry_mpih_mul_1( prod_ptr, mult->d, size, (mpi_limb_t)small_mult ); if( cy ) prod_ptr[size++] = cy; prod->nlimbs = size; @@ -64,7 +63,7 @@ mpi_mul_ui( MPI prod, MPI mult, unsigned long small_mult ) void -mpi_mul_2exp( MPI w, MPI u, unsigned long cnt) +_gcry_mpi_mul_2exp( MPI w, MPI u, unsigned long cnt) { mpi_size_t usize, wsize, limb_cnt; mpi_ptr_t wp; @@ -90,7 +89,7 @@ mpi_mul_2exp( MPI w, MPI u, unsigned long cnt) cnt %= BITS_PER_MPI_LIMB; if( cnt ) { - wlimb = mpihelp_lshift( wp + limb_cnt, u->d, usize, cnt ); + wlimb = _gcry_mpih_lshift( wp + limb_cnt, u->d, usize, cnt ); if( wlimb ) { wp[wsize] = wlimb; wsize++; @@ -111,7 +110,7 @@ mpi_mul_2exp( MPI w, MPI u, unsigned long cnt) void -mpi_mul( MPI w, MPI u, MPI v) +gcry_mpi_mul( MPI w, MPI u, MPI v) { mpi_size_t usize, vsize, wsize; mpi_ptr_t up, vp, wp; @@ -185,7 +184,7 @@ mpi_mul( MPI w, MPI u, MPI v) if( !vsize ) wsize = 0; else { - cy = mpihelp_mul( wp, up, usize, vp, vsize ); + cy = _gcry_mpih_mul( wp, up, usize, vp, vsize ); wsize -= cy? 0:1; } @@ -197,7 +196,7 @@ mpi_mul( MPI w, MPI u, MPI v) mpi_free_limb_space (wp); wp = tmp_wp; } - mpi_assign_limb_space( w, wp, wsize ); + _gcry_mpi_assign_limb_space( w, wp, wsize ); } w->nlimbs = wsize; w->sign = sign_product; @@ -207,9 +206,9 @@ mpi_mul( MPI w, MPI u, MPI v) void -mpi_mulm( MPI w, MPI u, MPI v, MPI m) +gcry_mpi_mulm( MPI w, MPI u, MPI v, MPI m) { - mpi_mul(w, u, v); - mpi_fdiv_r( w, w, m ); + gcry_mpi_mul(w, u, v); + _gcry_mpi_fdiv_r( w, w, m ); } diff --git a/mpi/mpi-pow.c b/mpi/mpi-pow.c index c9322f1a..7538d3e1 100644 --- a/mpi/mpi-pow.c +++ b/mpi/mpi-pow.c @@ -1,6 +1,5 @@ /* mpi-pow.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996, 2000 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 2000 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -89,7 +88,7 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) mp = mp_marker = mpi_alloc_limb_space(msize, msec); count_leading_zeros( mod_shift_cnt, mod->d[msize-1] ); if( mod_shift_cnt ) - mpihelp_lshift( mp, mod->d, msize, mod_shift_cnt ); + _gcry_mpih_lshift( mp, mod->d, msize, mod_shift_cnt ); else MPN_COPY( mp, mod->d, msize ); @@ -102,7 +101,7 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) MPN_COPY( bp, base->d, bsize ); /* We don't care about the quotient, store it above the remainder, * at BP + MSIZE. */ - mpihelp_divrem( bp + msize, 0, bp, bsize, mp, msize ); + _gcry_mpih_divrem( bp + msize, 0, bp, bsize, mp, msize ); bsize = msize; /* Canonicalize the base, since we are going to multiply with it * quite a few times. */ @@ -175,7 +174,7 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) * * Make the result be pointed to alternately by XP and RP. This * helps us avoid block copying, which would otherwise be necessary - * with the overlap restrictions of mpihelp_divmod. With 50% probability + * with the overlap restrictions of _gcry_mpih_divmod. With 50% probability * the result after this loop will be in the area originally pointed * by RP (==RES->d), and with 50% probability in the area originally * pointed to by XP. @@ -186,9 +185,9 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) mpi_ptr_t tp; mpi_size_t xsize; - /*mpihelp_mul_n(xp, rp, rp, rsize);*/ + /*mpih_mul_n(xp, rp, rp, rsize);*/ if( rsize < KARATSUBA_THRESHOLD ) - mpih_sqr_n_basecase( xp, rp, rsize ); + _gcry_mpih_sqr_n_basecase( xp, rp, rsize ); else { if( !tspace ) { tsize = 2 * rsize; @@ -199,12 +198,12 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) tsize = 2 * rsize; tspace = mpi_alloc_limb_space( tsize, 0 ); } - mpih_sqr_n( xp, rp, rsize, tspace ); + _gcry_mpih_sqr_n( xp, rp, rsize, tspace ); } xsize = 2 * rsize; if( xsize > msize ) { - mpihelp_divrem(xp + msize, 0, xp, xsize, mp, msize); + _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize); xsize = msize; } @@ -212,18 +211,18 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) rsize = xsize; if( (mpi_limb_signed_t)e < 0 ) { - /*mpihelp_mul( xp, rp, rsize, bp, bsize );*/ + /*mpih_mul( xp, rp, rsize, bp, bsize );*/ if( bsize < KARATSUBA_THRESHOLD ) { - mpihelp_mul( xp, rp, rsize, bp, bsize ); + _gcry_mpih_mul( xp, rp, rsize, bp, bsize ); } else { - mpihelp_mul_karatsuba_case( + _gcry_mpih_mul_karatsuba_case( xp, rp, rsize, bp, bsize, &karactx ); } xsize = rsize + bsize; if( xsize > msize ) { - mpihelp_divrem(xp + msize, 0, xp, xsize, mp, msize); + _gcry_mpih_divrem(xp + msize, 0, xp, xsize, mp, msize); xsize = msize; } @@ -248,7 +247,7 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) * might be, see above). */ if( mod_shift_cnt ) { - carry_limb = mpihelp_lshift( res->d, rp, rsize, mod_shift_cnt); + carry_limb = _gcry_mpih_lshift( res->d, rp, rsize, mod_shift_cnt); rp = res->d; if( carry_limb ) { rp[rsize] = carry_limb; @@ -261,22 +260,22 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) } if( rsize >= msize ) { - mpihelp_divrem(rp + msize, 0, rp, rsize, mp, msize); + _gcry_mpih_divrem(rp + msize, 0, rp, rsize, mp, msize); rsize = msize; } /* Remove any leading zero words from the result. */ if( mod_shift_cnt ) - mpihelp_rshift( rp, rp, rsize, mod_shift_cnt); + _gcry_mpih_rshift( rp, rp, rsize, mod_shift_cnt); MPN_NORMALIZE (rp, rsize); - mpihelp_release_karatsuba_ctx( &karactx ); + _gcry_mpih_release_karatsuba_ctx( &karactx ); } if( negative_result && rsize ) { if( mod_shift_cnt ) - mpihelp_rshift( mp, mp, msize, mod_shift_cnt); - mpihelp_sub( rp, mp, msize, rp, rsize); + _gcry_mpih_rshift( mp, mp, msize, mod_shift_cnt); + _gcry_mpih_sub( rp, mp, msize, rp, rsize); rsize = msize; rsign = msign; MPN_NORMALIZE(rp, rsize); @@ -285,11 +284,11 @@ gcry_mpi_powm( MPI res, MPI base, MPI exp, MPI mod) res->sign = rsign; leave: - if( assign_rp ) mpi_assign_limb_space( res, rp, size ); - if( mp_marker ) mpi_free_limb_space( mp_marker ); - if( bp_marker ) mpi_free_limb_space( bp_marker ); - if( ep_marker ) mpi_free_limb_space( ep_marker ); - if( xp_marker ) mpi_free_limb_space( xp_marker ); - if( tspace ) mpi_free_limb_space( tspace ); + if( assign_rp ) _gcry_mpi_assign_limb_space( res, rp, size ); + if( mp_marker ) _gcry_mpi_free_limb_space( mp_marker ); + if( bp_marker ) _gcry_mpi_free_limb_space( bp_marker ); + if( ep_marker ) _gcry_mpi_free_limb_space( ep_marker ); + if( xp_marker ) _gcry_mpi_free_limb_space( xp_marker ); + if( tspace ) _gcry_mpi_free_limb_space( tspace ); } diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c index 117f3751..c8b96ac0 100644 --- a/mpi/mpi-scan.c +++ b/mpi/mpi-scan.c @@ -1,5 +1,5 @@ /* mpi-scan.c - MPI functions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -32,7 +32,7 @@ * FIXME: This code is VERY ugly! */ int -mpi_getbyte( MPI a, unsigned idx ) +_gcry_mpi_getbyte( MPI a, unsigned idx ) { int i, j; unsigned n; @@ -54,7 +54,7 @@ mpi_getbyte( MPI a, unsigned idx ) * Put a value at position IDX into A. idx counts from lsb to msb */ void -mpi_putbyte( MPI a, unsigned idx, int xc ) +_gcry_mpi_putbyte( MPI a, unsigned idx, int xc ) { int i, j; unsigned n; @@ -110,7 +110,7 @@ mpi_putbyte( MPI a, unsigned idx, int xc ) * Count the number of zerobits at the low end of A */ unsigned -mpi_trailing_zeros( MPI a ) +_gcry_mpi_trailing_zeros( MPI a ) { unsigned n, count = 0; diff --git a/mpi/mpicoder.c b/mpi/mpicoder.c index aea641bb..d1f30b56 100644 --- a/mpi/mpicoder.c +++ b/mpi/mpicoder.c @@ -1,5 +1,5 @@ /* mpicoder.c - Coder for the external representation of MPIs - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -188,9 +188,9 @@ mpi_print( FILE *fp, MPI a, int mode ) return n; } - +#warning We should move this function to elsewhere void -g10_log_mpidump( const char *text, MPI a ) +_gcry_log_mpidump( const char *text, MPI a ) { FILE *fp = stderr; /* used to be log_stream() */ @@ -219,8 +219,8 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure ) if( sign ) *sign = a->sign; *nbytes = a->nlimbs * BYTES_PER_MPI_LIMB; - p = buffer = force_secure || mpi_is_secure(a) ? g10_xmalloc_secure( *nbytes) - : g10_xmalloc( *nbytes ); + p = buffer = force_secure || mpi_is_secure(a) ? gcry_xmalloc_secure( *nbytes) + : gcry_xmalloc( *nbytes ); for(i=a->nlimbs-1; i >= 0; i-- ) { alimb = a->d[i]; @@ -254,13 +254,13 @@ do_get_buffer( MPI a, unsigned *nbytes, int *sign, int force_secure ) byte * -mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) +_gcry_mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ) { return do_get_buffer( a, nbytes, sign, 0 ); } byte * -mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ) +_gcry_mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ) { return do_get_buffer( a, nbytes, sign, 1 ); } @@ -269,7 +269,7 @@ mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ) * Use BUFFER to update MPI. */ void -mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ) +_gcry_mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ) { const byte *p; mpi_limb_t alimb; @@ -351,7 +351,7 @@ gcry_mpi_scan( struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, return GCRYERR_INTERNAL; } else - mpi_set_buffer( a, s, len, 0 ); + _gcry_mpi_set_buffer( a, s, len, 0 ); } if( ret_mpi ) { mpi_normalize ( a ); @@ -364,7 +364,7 @@ gcry_mpi_scan( struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, else if( format == GCRYMPI_FMT_USG ) { a = mpi_alloc( (len+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB ); if( len ) /* not zero */ - mpi_set_buffer( a, buffer, len, 0 ); + _gcry_mpi_set_buffer( a, buffer, len, 0 ); if( ret_mpi ) { mpi_normalize ( a ); *ret_mpi = a; @@ -405,7 +405,7 @@ gcry_mpi_scan( struct gcry_mpi **ret_mpi, enum gcry_mpi_format format, return GCRYERR_INTERNAL; } else - mpi_set_buffer( a, s, n, 0 ); + _gcry_mpi_set_buffer( a, s, n, 0 ); } if( nbytes ) *nbytes = n+4; @@ -460,14 +460,14 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, if( a->sign ) return GCRYERR_INTERNAL; /* can't handle it yet */ - tmp = mpi_get_buffer( a, &n, NULL ); + tmp = _gcry_mpi_get_buffer( a, &n, NULL ); if( n && (*tmp & 0x80) ) { n++; extra=1; } if( n > len && buffer ) { - g10_free(tmp); + gcry_free(tmp); return GCRYERR_TOO_SHORT; /* the provided buffer is too short */ } if( buffer ) { @@ -477,7 +477,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, memcpy( s, tmp, n-extra ); } - g10_free(tmp); + gcry_free(tmp); *nbytes = n; return 0; } @@ -491,9 +491,9 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, return GCRYERR_TOO_SHORT; /* the provided buffer is too short */ if( buffer ) { char *tmp; - tmp = mpi_get_buffer( a, &n, NULL ); + tmp = _gcry_mpi_get_buffer( a, &n, NULL ); memcpy( buffer, tmp, n ); - g10_free(tmp); + gcry_free(tmp); } *nbytes = n; return 0; @@ -512,9 +512,9 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, s[0] = nbits >> 8; s[1] = nbits; - tmp = mpi_get_buffer( a, &n, NULL ); + tmp = _gcry_mpi_get_buffer( a, &n, NULL ); memcpy( s+2, tmp, n ); - g10_free(tmp); + gcry_free(tmp); } *nbytes = n+2; return 0; @@ -527,14 +527,14 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, if( a->sign ) return GCRYERR_INTERNAL; /* can't handle it yet */ - tmp = mpi_get_buffer( a, &n, NULL ); + tmp = _gcry_mpi_get_buffer( a, &n, NULL ); if( n && (*tmp & 0x80) ) { n++; extra=1; } if( n+4 > len && buffer ) { - g10_free(tmp); + gcry_free(tmp); return GCRYERR_TOO_SHORT; /* the provided buffer is too short */ } if( buffer ) { @@ -548,7 +548,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, memcpy( s, tmp, n-extra ); } - g10_free(tmp); + gcry_free(tmp); *nbytes = 4+n; return 0; } @@ -558,12 +558,12 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, int extra = 0; unsigned int n=0; - tmp = mpi_get_buffer( a, &n, NULL ); + tmp = _gcry_mpi_get_buffer( a, &n, NULL ); if( !n || (*tmp & 0x80) ) extra=2; if( 2*n + extra + !!a->sign + 1 > len && buffer ) { - g10_free(tmp); + gcry_free(tmp); return GCRYERR_TOO_SHORT; /* the provided buffer is too short */ } if( buffer ) { @@ -587,7 +587,7 @@ gcry_mpi_print( enum gcry_mpi_format format, char *buffer, size_t *nbytes, else { *nbytes = 2*n + extra + !!a->sign + 1; } - g10_free(tmp); + gcry_free(tmp); return 0; } else @@ -610,10 +610,10 @@ gcry_mpi_aprint( enum gcry_mpi_format format, void **buffer, size_t *nbytes, rc = gcry_mpi_print( format, NULL, &n, a ); if( rc ) return rc; - *buffer = mpi_is_secure(a) ? g10_xmalloc_secure( n ) : g10_xmalloc( n ); + *buffer = mpi_is_secure(a) ? gcry_xmalloc_secure( n ) : gcry_xmalloc( n ); rc = gcry_mpi_print( format, *buffer, &n, a ); if( rc ) { - g10_free(*buffer); + gcry_free(*buffer); *buffer = NULL; } else if( nbytes ) diff --git a/mpi/mpih-cmp.c b/mpi/mpih-cmp.c deleted file mode 100644 index a7c5c9f7..00000000 --- a/mpi/mpih-cmp.c +++ /dev/null @@ -1,62 +0,0 @@ -/* mpihelp-sub.c - MPI helper functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996 Free Software Foundation, Inc. - * - * This file is part of Libgcrypt. - * - * Libgcrypt is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Libgcrypt is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - * - * Note: This code is heavily based on the GNU MP Library. - * Actually it's the same code with only minor changes in the - * way the data is stored; this is to support the abstraction - * of an optional secure memory allocation which may be used - * to avoid revealing of sensitive data due to paging etc. - * The GNU MP Library itself is published under the LGPL; - * however I decided to publish this code under the plain GPL. - */ - -#include <config.h> -#include <stdio.h> -#include <stdlib.h> - -#include "mpi-internal.h" - -/**************** - * Compare OP1_PTR/OP1_SIZE with OP2_PTR/OP2_SIZE. - * There are no restrictions on the relative sizes of - * the two arguments. - * Return 1 if OP1 > OP2, 0 if they are equal, and -1 if OP1 < OP2. - */ -int -mpihelp_cmp( mpi_ptr_t op1_ptr, mpi_ptr_t op2_ptr, mpi_size_t size ) -{ - mpi_size_t i; - mpi_limb_t op1_word, op2_word; - - for( i = size - 1; i >= 0 ; i--) { - op1_word = op1_ptr[i]; - op2_word = op2_ptr[i]; - if( op1_word != op2_word ) - goto diff; - } - return 0; - - diff: - /* This can *not* be simplified to - * op2_word - op2_word - * since that expression might give signed overflow. */ - return (op1_word > op2_word) ? 1 : -1; -} - diff --git a/mpi/mpih-div.c b/mpi/mpih-div.c index 3462ba6d..0a2f2a2a 100644 --- a/mpi/mpih-div.c +++ b/mpi/mpih-div.c @@ -1,6 +1,5 @@ -/* mpihelp-div.c - MPI helper functions - * Copyright (C) 1998 Free Software Foundation, Inc. - * Copyright (C) 1994, 1996, 2000 Free Software Foundation, Inc. +/* mpih-div.c - MPI helper functions + * Copyright (C) 1994, 1996, 1998, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -45,7 +44,7 @@ */ mpi_limb_t -mpihelp_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, +_gcry_mpih_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, mpi_limb_t divisor_limb) { mpi_size_t i; @@ -206,9 +205,9 @@ mpihelp_mod_1(mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, */ mpi_limb_t -mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, - mpi_ptr_t np, mpi_size_t nsize, - mpi_ptr_t dp, mpi_size_t dsize) +_gcry_mpih_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, + mpi_ptr_t np, mpi_size_t nsize, + mpi_ptr_t dp, mpi_size_t dsize) { mpi_limb_t most_significant_q_limb = 0; @@ -320,8 +319,8 @@ mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, n0 = np[dsize - 1]; if( n0 >= dX ) { - if(n0 > dX || mpihelp_cmp(np, dp, dsize - 1) >= 0 ) { - mpihelp_sub_n(np, np, dp, dsize); + if(n0 > dX || _gcry_mpih_cmp(np, dp, dsize - 1) >= 0 ) { + _gcry_mpih_sub_n(np, np, dp, dsize); n0 = np[dsize - 1]; most_significant_q_limb = 1; } @@ -366,10 +365,10 @@ mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, /* Possible optimization: We already have (q * n0) and (1 * n1) * after the calculation of q. Taking advantage of that, we * could make this loop make two iterations less. */ - cy_limb = mpihelp_submul_1(np, dp, dsize, q); + cy_limb = _gcry_mpih_submul_1(np, dp, dsize, q); if( n2 != cy_limb ) { - mpihelp_add_n(np, np, dp, dsize); + _gcry_mpih_add_n(np, np, dp, dsize); q--; } @@ -393,9 +392,9 @@ mpihelp_divrem( mpi_ptr_t qp, mpi_size_t qextra_limbs, */ mpi_limb_t -mpihelp_divmod_1( mpi_ptr_t quot_ptr, - mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, - mpi_limb_t divisor_limb) +_gcry_mpih_divmod_1( mpi_ptr_t quot_ptr, + mpi_ptr_t dividend_ptr, mpi_size_t dividend_size, + mpi_limb_t divisor_limb) { mpi_size_t i; mpi_limb_t n1, n0, r; diff --git a/mpi/mpih-mul.c b/mpi/mpih-mul.c index fa2d9d1f..d2b32b8e 100644 --- a/mpi/mpih-mul.c +++ b/mpi/mpih-mul.c @@ -1,5 +1,6 @@ -/* mpihelp-mul.c - MPI helper functions - * Copyright (C) 1994, 1996, 1998, 1999, 2000 Free Software Foundation, Inc. +/* mpih-mul.c - MPI helper functions + * Copyright (C) 1994, 1996, 1998, 1999, 2000, + * 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -32,8 +33,7 @@ #include <string.h> #include "mpi-internal.h" #include "longlong.h" -#include "g10lib.h" /* g10_is_secure() */ - +#include "g10lib.h" #define MPN_MUL_N_RECURSE(prodp, up, vp, size, tspace) \ do { \ @@ -46,9 +46,9 @@ #define MPN_SQR_N_RECURSE(prodp, up, size, tspace) \ do { \ if ((size) < KARATSUBA_THRESHOLD) \ - mpih_sqr_n_basecase (prodp, up, size); \ + _gcry_mpih_sqr_n_basecase (prodp, up, size); \ else \ - mpih_sqr_n (prodp, up, size, tspace); \ + _gcry_mpih_sqr_n (prodp, up, size, tspace); \ } while (0); @@ -90,7 +90,7 @@ mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, cy = 0; } else - cy = mpihelp_mul_1( prodp, up, size, v_limb ); + cy = _gcry_mpih_mul_1( prodp, up, size, v_limb ); prodp[size] = cy; prodp++; @@ -102,10 +102,10 @@ mul_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, if( v_limb <= 1 ) { cy = 0; if( v_limb == 1 ) - cy = mpihelp_add_n(prodp, prodp, up, size); + cy = _gcry_mpih_add_n(prodp, prodp, up, size); } else - cy = mpihelp_addmul_1(prodp, up, size, v_limb); + cy = _gcry_mpih_addmul_1(prodp, up, size, v_limb); prodp[size] = cy; prodp++; @@ -134,9 +134,9 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_limb_t cy_limb; MPN_MUL_N_RECURSE( prodp, up, vp, esize, tspace ); - cy_limb = mpihelp_addmul_1( prodp + esize, up, esize, vp[esize] ); + cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, vp[esize] ); prodp[esize + esize] = cy_limb; - cy_limb = mpihelp_addmul_1( prodp + esize, vp, size, up[esize] ); + cy_limb = _gcry_mpih_addmul_1( prodp + esize, vp, size, up[esize] ); prodp[esize + size] = cy_limb; } else { @@ -169,20 +169,20 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, /* Product M. ________________ * |_(U1-U0)(V0-V1)_| */ - if( mpihelp_cmp(up + hsize, up, hsize) >= 0 ) { - mpihelp_sub_n(prodp, up + hsize, up, hsize); + if( _gcry_mpih_cmp(up + hsize, up, hsize) >= 0 ) { + _gcry_mpih_sub_n(prodp, up + hsize, up, hsize); negflg = 0; } else { - mpihelp_sub_n(prodp, up, up + hsize, hsize); + _gcry_mpih_sub_n(prodp, up, up + hsize, hsize); negflg = 1; } - if( mpihelp_cmp(vp + hsize, vp, hsize) >= 0 ) { - mpihelp_sub_n(prodp + hsize, vp + hsize, vp, hsize); + if( _gcry_mpih_cmp(vp + hsize, vp, hsize) >= 0 ) { + _gcry_mpih_sub_n(prodp + hsize, vp + hsize, vp, hsize); negflg ^= 1; } else { - mpihelp_sub_n(prodp + hsize, vp, vp + hsize, hsize); + _gcry_mpih_sub_n(prodp + hsize, vp, vp + hsize, hsize); /* No change of NEGFLG. */ } /* Read temporary operands from low part of PROD. @@ -193,14 +193,14 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, /* Add/copy product H. */ MPN_COPY (prodp + hsize, prodp + size, hsize); - cy = mpihelp_add_n( prodp + size, prodp + size, + cy = _gcry_mpih_add_n( prodp + size, prodp + size, prodp + size + hsize, hsize); /* Add product M (if NEGFLG M is a negative number) */ if(negflg) - cy -= mpihelp_sub_n(prodp + hsize, prodp + hsize, tspace, size); + cy -= _gcry_mpih_sub_n(prodp + hsize, prodp + hsize, tspace, size); else - cy += mpihelp_add_n(prodp + hsize, prodp + hsize, tspace, size); + cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size); /* Product L. ________________ ________________ * |________________||____U0 x V0_____| @@ -212,20 +212,20 @@ mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, /* Add/copy Product L (twice) */ - cy += mpihelp_add_n(prodp + hsize, prodp + hsize, tspace, size); + cy += _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace, size); if( cy ) - mpihelp_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy); + _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy); MPN_COPY(prodp, tspace, hsize); - cy = mpihelp_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize); + cy = _gcry_mpih_add_n(prodp + hsize, prodp + hsize, tspace + hsize, hsize); if( cy ) - mpihelp_add_1(prodp + size, prodp + size, size, 1); + _gcry_mpih_add_1(prodp + size, prodp + size, size, 1); } } void -mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) +_gcry_mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) { mpi_size_t i; mpi_limb_t cy_limb; @@ -242,7 +242,7 @@ mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) cy_limb = 0; } else - cy_limb = mpihelp_mul_1( prodp, up, size, v_limb ); + cy_limb = _gcry_mpih_mul_1( prodp, up, size, v_limb ); prodp[size] = cy_limb; prodp++; @@ -254,10 +254,10 @@ mpih_sqr_n_basecase( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size ) if( v_limb <= 1 ) { cy_limb = 0; if( v_limb == 1 ) - cy_limb = mpihelp_add_n(prodp, prodp, up, size); + cy_limb = _gcry_mpih_add_n(prodp, prodp, up, size); } else - cy_limb = mpihelp_addmul_1(prodp, up, size, v_limb); + cy_limb = _gcry_mpih_addmul_1(prodp, up, size, v_limb); prodp[size] = cy_limb; prodp++; @@ -266,7 +266,8 @@ 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) +_gcry_mpih_sqr_n( mpi_ptr_t prodp, + mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) { if( size & 1 ) { /* The size is odd, and the code below doesn't handle that. @@ -283,9 +284,9 @@ mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) mpi_limb_t cy_limb; MPN_SQR_N_RECURSE( prodp, up, esize, tspace ); - cy_limb = mpihelp_addmul_1( prodp + esize, up, esize, up[esize] ); + cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, esize, up[esize] ); prodp[esize + esize] = cy_limb; - cy_limb = mpihelp_addmul_1( prodp + esize, up, size, up[esize] ); + cy_limb = _gcry_mpih_addmul_1( prodp + esize, up, size, up[esize] ); prodp[esize + size] = cy_limb; } @@ -303,10 +304,10 @@ mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) /* Product M. ________________ * |_(U1-U0)(U0-U1)_| */ - if( mpihelp_cmp( up + hsize, up, hsize) >= 0 ) - mpihelp_sub_n( prodp, up + hsize, up, hsize); + if( _gcry_mpih_cmp( up + hsize, up, hsize) >= 0 ) + _gcry_mpih_sub_n( prodp, up + hsize, up, hsize); else - mpihelp_sub_n (prodp, up, up + hsize, hsize); + _gcry_mpih_sub_n (prodp, up, up + hsize, hsize); /* Read temporary operands from low part of PROD. * Put result in low part of TSPACE using upper part of TSPACE @@ -315,11 +316,11 @@ mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) /* Add/copy product H */ MPN_COPY(prodp + hsize, prodp + size, hsize); - cy = mpihelp_add_n(prodp + size, prodp + size, + cy = _gcry_mpih_add_n(prodp + size, prodp + size, prodp + size + hsize, hsize); /* Add product M (if NEGFLG M is a negative number). */ - cy -= mpihelp_sub_n (prodp + hsize, prodp + hsize, tspace, size); + cy -= _gcry_mpih_sub_n (prodp + hsize, prodp + hsize, tspace, size); /* Product L. ________________ ________________ * |________________||____U0 x U0_____| @@ -329,33 +330,34 @@ mpih_sqr_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t size, mpi_ptr_t tspace) MPN_SQR_N_RECURSE (tspace, up, hsize, tspace + size); /* Add/copy Product L (twice). */ - cy += mpihelp_add_n (prodp + hsize, prodp + hsize, tspace, size); + cy += _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace, size); if( cy ) - mpihelp_add_1(prodp + hsize + size, prodp + hsize + size, + _gcry_mpih_add_1(prodp + hsize + size, prodp + hsize + size, hsize, cy); MPN_COPY(prodp, tspace, hsize); - cy = mpihelp_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize); + cy = _gcry_mpih_add_n (prodp + hsize, prodp + hsize, tspace + hsize, hsize); if( cy ) - mpihelp_add_1 (prodp + size, prodp + size, size, 1); + _gcry_mpih_add_1 (prodp + size, prodp + size, size, 1); } } /* This should be made into an inline function in gmp.h. */ void -mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size) +_gcry_mpih_mul_n( mpi_ptr_t prodp, + mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size) { int secure; if( up == vp ) { if( size < KARATSUBA_THRESHOLD ) - mpih_sqr_n_basecase( prodp, up, size ); + _gcry_mpih_sqr_n_basecase( prodp, up, size ); else { mpi_ptr_t tspace; - secure = g10_is_secure( up ); + secure = gcry_is_secure( up ); tspace = mpi_alloc_limb_space( 2 * size, secure ); - mpih_sqr_n( prodp, up, size, tspace ); + _gcry_mpih_sqr_n( prodp, up, size, tspace ); mpi_free_limb_space( tspace ); } } @@ -364,7 +366,7 @@ mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size) mul_n_basecase( prodp, up, vp, size ); else { mpi_ptr_t tspace; - secure = g10_is_secure( up ) || g10_is_secure( vp ); + secure = gcry_is_secure( up ) || gcry_is_secure( vp ); tspace = mpi_alloc_limb_space( 2 * size, secure ); mul_n (prodp, up, vp, size, tspace); mpi_free_limb_space( tspace ); @@ -375,10 +377,10 @@ mpihelp_mul_n( mpi_ptr_t prodp, mpi_ptr_t up, mpi_ptr_t vp, mpi_size_t size) void -mpihelp_mul_karatsuba_case( mpi_ptr_t prodp, - mpi_ptr_t up, mpi_size_t usize, - mpi_ptr_t vp, mpi_size_t vsize, - struct karatsuba_ctx *ctx ) +_gcry_mpih_mul_karatsuba_case( mpi_ptr_t prodp, + mpi_ptr_t up, mpi_size_t usize, + mpi_ptr_t vp, mpi_size_t vsize, + struct karatsuba_ctx *ctx ) { mpi_limb_t cy; @@ -386,7 +388,7 @@ mpihelp_mul_karatsuba_case( mpi_ptr_t prodp, if( ctx->tspace ) mpi_free_limb_space( ctx->tspace ); ctx->tspace = mpi_alloc_limb_space( 2 * vsize, - g10_is_secure( up ) || g10_is_secure( vp ) ); + gcry_is_secure( up ) || gcry_is_secure( vp ) ); ctx->tspace_size = vsize; } @@ -399,15 +401,15 @@ mpihelp_mul_karatsuba_case( mpi_ptr_t prodp, if( !ctx->tp || ctx->tp_size < vsize ) { if( ctx->tp ) mpi_free_limb_space( ctx->tp ); - ctx->tp = mpi_alloc_limb_space( 2 * vsize, g10_is_secure( up ) - || g10_is_secure( vp ) ); + ctx->tp = mpi_alloc_limb_space( 2 * vsize, gcry_is_secure( up ) + || gcry_is_secure( vp ) ); ctx->tp_size = vsize; } do { MPN_MUL_N_RECURSE( ctx->tp, up, vp, vsize, ctx->tspace ); - cy = mpihelp_add_n( prodp, prodp, ctx->tp, vsize ); - mpihelp_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy ); + cy = _gcry_mpih_add_n( prodp, prodp, ctx->tp, vsize ); + _gcry_mpih_add_1( prodp + vsize, ctx->tp + vsize, vsize, cy ); prodp += vsize; up += vsize; usize -= vsize; @@ -416,26 +418,26 @@ mpihelp_mul_karatsuba_case( mpi_ptr_t prodp, if( usize ) { if( usize < KARATSUBA_THRESHOLD ) { - mpihelp_mul( ctx->tspace, vp, vsize, up, usize ); + _gcry_mpih_mul( ctx->tspace, vp, vsize, up, usize ); } else { if( !ctx->next ) { - ctx->next = g10_xcalloc( 1, sizeof *ctx ); + ctx->next = gcry_xcalloc( 1, sizeof *ctx ); } - mpihelp_mul_karatsuba_case( ctx->tspace, + _gcry_mpih_mul_karatsuba_case( ctx->tspace, vp, vsize, up, usize, ctx->next ); } - cy = mpihelp_add_n( prodp, prodp, ctx->tspace, vsize); - mpihelp_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy ); + cy = _gcry_mpih_add_n( prodp, prodp, ctx->tspace, vsize); + _gcry_mpih_add_1( prodp + vsize, ctx->tspace + vsize, usize, cy ); } } void -mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx ) +_gcry_mpih_release_karatsuba_ctx( struct karatsuba_ctx *ctx ) { struct karatsuba_ctx *ctx2; @@ -449,7 +451,7 @@ mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx ) mpi_free_limb_space( ctx->tp ); if( ctx->tspace ) mpi_free_limb_space( ctx->tspace ); - g10_free( ctx ); + gcry_free( ctx ); } } @@ -469,8 +471,8 @@ mpihelp_release_karatsuba_ctx( struct karatsuba_ctx *ctx ) */ mpi_limb_t -mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, - mpi_ptr_t vp, mpi_size_t vsize) +_gcry_mpih_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, + mpi_ptr_t vp, mpi_size_t vsize) { mpi_ptr_t prod_endp = prodp + usize + vsize - 1; mpi_limb_t cy; @@ -494,7 +496,7 @@ mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, cy = 0; } else - cy = mpihelp_mul_1( prodp, up, usize, v_limb ); + cy = _gcry_mpih_mul_1( prodp, up, usize, v_limb ); prodp[usize] = cy; prodp++; @@ -506,10 +508,10 @@ mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, if( v_limb <= 1 ) { cy = 0; if( v_limb == 1 ) - cy = mpihelp_add_n(prodp, prodp, up, usize); + cy = _gcry_mpih_add_n(prodp, prodp, up, usize); } else - cy = mpihelp_addmul_1(prodp, up, usize, v_limb); + cy = _gcry_mpih_addmul_1(prodp, up, usize, v_limb); prodp[usize] = cy; prodp++; @@ -519,8 +521,8 @@ mpihelp_mul( mpi_ptr_t prodp, mpi_ptr_t up, mpi_size_t usize, } memset( &ctx, 0, sizeof ctx ); - mpihelp_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx ); - mpihelp_release_karatsuba_ctx( &ctx ); + _gcry_mpih_mul_karatsuba_case( prodp, up, usize, vp, vsize, &ctx ); + _gcry_mpih_release_karatsuba_ctx( &ctx ); return *prod_endp; } diff --git a/mpi/mpiutil.c b/mpi/mpiutil.c index c38c0083..6946e20a 100644 --- a/mpi/mpiutil.c +++ b/mpi/mpiutil.c @@ -1,5 +1,5 @@ /* mpiutil.ac - Utility functions for MPI - * Copyright (C) 1998, 2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -36,11 +36,11 @@ * But mpi_alloc is used in a lot of places :-) */ MPI -mpi_alloc( unsigned nlimbs ) +_gcry_mpi_alloc( unsigned nlimbs ) { MPI a; - a = g10_xmalloc( sizeof *a ); + a = gcry_xmalloc( sizeof *a ); a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 0 ) : NULL; a->alloced = nlimbs; a->nlimbs = 0; @@ -50,18 +50,18 @@ mpi_alloc( unsigned nlimbs ) } void -mpi_m_check( MPI a ) +_gcry_mpi_m_check( MPI a ) { - g10_check_heap(a); - g10_check_heap(a->d); + _gcry_check_heap(a); + _gcry_check_heap(a->d); } MPI -mpi_alloc_secure( unsigned nlimbs ) +_gcry_mpi_alloc_secure( unsigned nlimbs ) { MPI a; - a = g10_xmalloc( sizeof *a ); + a = gcry_xmalloc( sizeof *a ); a->d = nlimbs? mpi_alloc_limb_space( nlimbs, 1 ) : NULL; a->alloced = nlimbs; a->flags = 1; @@ -73,27 +73,27 @@ mpi_alloc_secure( unsigned nlimbs ) mpi_ptr_t -mpi_alloc_limb_space( unsigned nlimbs, int secure ) +_gcry_mpi_alloc_limb_space( unsigned nlimbs, int secure ) { size_t len = nlimbs * sizeof(mpi_limb_t); mpi_ptr_t p; - p = secure? g10_xmalloc_secure( len ) : g10_xmalloc( len ); + p = secure? gcry_xmalloc_secure( len ) : gcry_xmalloc( len ); return p; } void -mpi_free_limb_space( mpi_ptr_t a ) +_gcry_mpi_free_limb_space( mpi_ptr_t a ) { if( !a ) return; - g10_free(a); + gcry_free(a); } void -mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs ) +_gcry_mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs ) { mpi_free_limb_space(a->d); a->d = ap; @@ -104,27 +104,27 @@ mpi_assign_limb_space( MPI a, mpi_ptr_t ap, unsigned nlimbs ) /**************** * Resize the array of A to NLIMBS. the additional space is cleared - * (set to 0) [done by g10_realloc()] + * (set to 0) [done by gcry_realloc()] */ void -mpi_resize( MPI a, unsigned nlimbs ) +_gcry_mpi_resize( MPI a, unsigned nlimbs ) { if( nlimbs <= a->alloced ) return; /* no need to do it */ /* Note: a->secure is not used - instead the realloc functions * take care of it. Maybe we should drop a->secure completely * and rely on a mpi_is_secure function, which would be - * a wrapper around g10_is_secure + * a wrapper around gcry_is_secure */ if( a->d ) - a->d = g10_xrealloc(a->d, nlimbs * sizeof(mpi_limb_t) ); + a->d = gcry_xrealloc(a->d, nlimbs * sizeof(mpi_limb_t) ); else /* FIXME: It may not be allocted in secure memory */ - a->d = g10_xcalloc( nlimbs , sizeof(mpi_limb_t) ); + a->d = gcry_xcalloc( nlimbs , sizeof(mpi_limb_t) ); a->alloced = nlimbs; } void -mpi_clear( MPI a ) +_gcry_mpi_clear( MPI a ) { a->nlimbs = 0; a->flags = 0; @@ -132,18 +132,18 @@ mpi_clear( MPI a ) void -mpi_free( MPI a ) +_gcry_mpi_free( MPI a ) { if( !a ) return; if( a->flags & 4 ) - g10_free( a->d ); + gcry_free( a->d ); else { mpi_free_limb_space(a->d); } if( a->flags & ~7 ) log_bug("invalid flag value in mpi\n"); - g10_free(a); + gcry_free(a); } static void @@ -174,7 +174,7 @@ gcry_mpi_set_opaque( MPI a, void *p, unsigned int nbits ) } if( a->flags & 4 ) - g10_free( a->d ); + gcry_free( a->d ); else { mpi_free_limb_space(a->d); } @@ -204,14 +204,14 @@ gcry_mpi_get_opaque( MPI a, unsigned int *nbits ) * but copy it transparently. */ MPI -mpi_copy( MPI a ) +_gcry_mpi_copy( MPI a ) { int i; MPI b; if( a && (a->flags & 4) ) { - void *p = g10_is_secure(a->d)? g10_xmalloc_secure( (a->sign+7)/8 ) - : g10_xmalloc( (a->sign+7)/8 ); + void *p = gcry_is_secure(a->d)? gcry_xmalloc_secure( (a->sign+7)/8 ) + : gcry_xmalloc( (a->sign+7)/8 ); memcpy( p, a->d, (a->sign+7)/8 ); b = gcry_mpi_set_opaque( NULL, p, a->sign ); } @@ -232,18 +232,18 @@ mpi_copy( MPI a ) /**************** * This function allocates an MPI which is optimized to hold - * a value as large as the one given in the arhgument and allocates it + * a value as large as the one given in the argument and allocates it * with the same flags as A. */ MPI -mpi_alloc_like( MPI a ) +_gcry_mpi_alloc_like( MPI a ) { MPI b; if( a && (a->flags & 4) ) { int n = (a->sign+7)/8; - void *p = g10_is_secure(a->d)? g10_malloc_secure( n ) - : g10_malloc( n ); + void *p = gcry_is_secure(a->d)? gcry_malloc_secure( n ) + : gcry_malloc( n ); memcpy( p, a->d, n ); b = gcry_mpi_set_opaque( NULL, p, a->sign ); } @@ -261,7 +261,7 @@ mpi_alloc_like( MPI a ) void -mpi_set( MPI w, MPI u) +_gcry_mpi_set( MPI w, MPI u) { mpi_ptr_t wp, up; mpi_size_t usize = u->nlimbs; @@ -278,7 +278,7 @@ mpi_set( MPI w, MPI u) void -mpi_set_ui( MPI w, unsigned long u) +_gcry_mpi_set_ui( MPI w, unsigned long u) { RESIZE_IF_NEEDED(w, 1); w->d[0] = u; @@ -289,7 +289,7 @@ mpi_set_ui( MPI w, unsigned long u) MPI -mpi_alloc_set_ui( unsigned long u) +_gcry_mpi_alloc_set_ui( unsigned long u) { MPI w = mpi_alloc(1); w->d[0] = u; @@ -300,7 +300,7 @@ mpi_alloc_set_ui( unsigned long u) void -mpi_swap( MPI a, MPI b) +_gcry_mpi_swap( MPI a, MPI b) { struct gcry_mpi tmp; @@ -311,34 +311,34 @@ mpi_swap( MPI a, MPI b) GCRY_MPI gcry_mpi_new( unsigned int nbits ) { - return mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB ); + return _gcry_mpi_alloc( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB ); } GCRY_MPI gcry_mpi_snew( unsigned int nbits ) { - return mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB ); + return _gcry_mpi_alloc_secure( (nbits+BITS_PER_MPI_LIMB-1) / BITS_PER_MPI_LIMB ); } void gcry_mpi_release( GCRY_MPI a ) { - mpi_free( a ); + _gcry_mpi_free( a ); } GCRY_MPI gcry_mpi_copy( const GCRY_MPI a ) { - return mpi_copy( (GCRY_MPI)a ); + return _gcry_mpi_copy( (GCRY_MPI)a ); } GCRY_MPI gcry_mpi_set( GCRY_MPI w, const GCRY_MPI u ) { if( !w ) - w = mpi_alloc( mpi_get_nlimbs(u) ); - mpi_set( w, (GCRY_MPI)u ); + w = _gcry_mpi_alloc( mpi_get_nlimbs(u) ); + _gcry_mpi_set( w, (GCRY_MPI)u ); return w; } @@ -346,33 +346,20 @@ GCRY_MPI gcry_mpi_set_ui( GCRY_MPI w, unsigned long u ) { if( !w ) - w = mpi_alloc(1); - mpi_set_ui( w, u ); + w = _gcry_mpi_alloc(1); + _gcry_mpi_set_ui( w, u ); return w; } -int -gcry_mpi_cmp( const GCRY_MPI u, const GCRY_MPI v ) -{ - return mpi_cmp( (GCRY_MPI)u, (GCRY_MPI)v ); -} - -int -gcry_mpi_cmp_ui( const GCRY_MPI u, unsigned long v ) -{ - return mpi_cmp_ui( (GCRY_MPI)u, v ); -} - - void gcry_mpi_randomize( GCRY_MPI w, unsigned int nbits, enum gcry_random_level level ) { char *p = mpi_is_secure(w) ? gcry_random_bytes( (nbits+7)/8, level ) : gcry_random_bytes_secure( (nbits+7)/8, level ); - mpi_set_buffer( w, p, (nbits+7)/8, 0 ); - g10_free(p); + _gcry_mpi_set_buffer( w, p, (nbits+7)/8, 0 ); + gcry_free(p); } @@ -406,4 +393,3 @@ gcry_mpi_get_flag( GCRY_MPI a, enum gcry_mpi_flag flag ) } } - diff --git a/mpi/pa7100/mpih-lshift.S b/mpi/pa7100/mpih-lshift.S index 76368fe7..acd3067e 100644 --- a/mpi/pa7100/mpih-lshift.S +++ b/mpi/pa7100/mpih-lshift.S @@ -25,15 +25,15 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (gr26) + * _gcry_mpih_lshift( mpi_ptr_t wp, (gr26) * mpi_ptr_t up, (gr25) * mpi_size_t usize, (gr24) * unsigned cnt) (gr23) */ .code - .export mpihelp_lshift - .label mpihelp_lshift + .export _gcry_mpih_lshift + .label _gcry_mpih_lshift .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/pa7100/mpih-rshift.S b/mpi/pa7100/mpih-rshift.S index 3bada7ce..4858c44a 100644 --- a/mpi/pa7100/mpih-rshift.S +++ b/mpi/pa7100/mpih-rshift.S @@ -25,15 +25,15 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (gr26) + * _gcry_mpih_rshift( mpi_ptr_t wp, (gr26) * mpi_ptr_t up, (gr25) * mpi_size_t usize, (gr24) * unsigned cnt) (gr23) */ .code - .export mpihelp_rshift - .label mpihelp_rshift + .export _gcry_mpih_rshift + .label _gcry_mpih_rshift .proc .callinfo frame=64,no_calls .entry diff --git a/mpi/power/mpih-add1.S b/mpi/power/mpih-add1.S index 7313ac61..ee9571a6 100644 --- a/mpi/power/mpih-add1.S +++ b/mpi/power/mpih-add1.S @@ -31,17 +31,17 @@ */ .toc - .extern mpihelp_add_n[DS] - .extern .mpihelp_add_n + .extern _gcry_mpih_add_n[DS] + .extern ._gcry_mpih_add_n .csect [PR] .align 2 - .globl mpihelp_add_n - .globl .mpihelp_add_n - .csect mpihelp_add_n[DS] -mpihelp_add_n: - .long .mpihelp_add_n, TOC[tc0], 0 + .globl _gcry_mpih_add_n + .globl ._gcry_mpih_add_n + .csect _gcry_mpih_add_n[DS] +_gcry_mpih_add_n: + .long ._gcry_mpih_add_n, TOC[tc0], 0 .csect [PR] -.mpihelp_add_n: +._gcry_mpih_add_n: andil. 10,6,1 # odd or even number of limbs? l 8,0(4) # load least significant s1 limb l 0,0(5) # load least significant s2 limb diff --git a/mpi/power/mpih-lshift.S b/mpi/power/mpih-lshift.S index 20cf4535..a012a4e0 100644 --- a/mpi/power/mpih-lshift.S +++ b/mpi/power/mpih-lshift.S @@ -31,17 +31,17 @@ */ .toc - .extern mpihelp_lshift[DS] - .extern .mpihelp_lshift + .extern _gcry_mpih_lshift[DS] + .extern ._gcry_mpih_lshift .csect [PR] .align 2 - .globl mpihelp_lshift - .globl .mpihelp_lshift - .csect mpihelp_lshift[DS] -mpihelp_lshift: - .long .mpihelp_lshift, TOC[tc0], 0 + .globl _gcry_mpih_lshift + .globl ._gcry_mpih_lshift + .csect _gcry_mpih_lshift[DS] +_gcry_mpih_lshift: + .long ._gcry_mpih_lshift, TOC[tc0], 0 .csect [PR] -.mpihelp_lshift: +._gcry_mpih_lshift: sli 0,5,2 cax 9,3,0 cax 4,4,0 diff --git a/mpi/power/mpih-mul1.S b/mpi/power/mpih-mul1.S index 03fff4f9..e770e3b8 100644 --- a/mpi/power/mpih-mul1.S +++ b/mpi/power/mpih-mul1.S @@ -42,15 +42,15 @@ */ .toc - .csect .mpihelp_mul_1[PR] + .csect ._gcry_mpih_mul_1[PR] .align 2 - .globl mpihelp_mul_1 - .globl .mpihelp_mul_1 - .csect mpihelp_mul_1[DS] -mpihelp_mul_1: - .long .mpihelp_mul_1[PR], TOC[tc0], 0 - .csect .mpihelp_mul_1[PR] -.mpihelp_mul_1: + .globl _gcry_mpih_mul_1 + .globl ._gcry_mpih_mul_1 + .csect _gcry_mpih_mul_1[DS] +_gcry_mpih_mul_1: + .long ._gcry_mpih_mul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_mul_1[PR] +._gcry_mpih_mul_1: cal 3,-4(3) l 0,0(4) diff --git a/mpi/power/mpih-mul2.S b/mpi/power/mpih-mul2.S index 3d7fc153..1fcb0333 100644 --- a/mpi/power/mpih-mul2.S +++ b/mpi/power/mpih-mul2.S @@ -44,15 +44,15 @@ */ .toc - .csect .mpihelp_addmul_1[PR] + .csect ._gcry_mpih_addmul_1[PR] .align 2 - .globl mpihelp_addmul_1 - .globl .mpihelp_addmul_1 - .csect mpihelp_addmul_1[DS] -mpihelp_addmul_1: - .long .mpihelp_addmul_1[PR], TOC[tc0], 0 - .csect .mpihelp_addmul_1[PR] -.mpihelp_addmul_1: + .globl _gcry_mpih_addmul_1 + .globl ._gcry_mpih_addmul_1 + .csect _gcry_mpih_addmul_1[DS] +_gcry_mpih_addmul_1: + .long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_addmul_1[PR] +._gcry_mpih_addmul_1: cal 3,-4(3) l 0,0(4) diff --git a/mpi/power/mpih-mul3.S b/mpi/power/mpih-mul3.S index f94018ca..92308df5 100644 --- a/mpi/power/mpih-mul3.S +++ b/mpi/power/mpih-mul3.S @@ -44,15 +44,15 @@ */ .toc - .csect .mpihelp_submul_1[PR] + .csect ._gcry_mpih_submul_1[PR] .align 2 - .globl mpihelp_submul_1 - .globl .mpihelp_submul_1 - .csect mpihelp_submul_1[DS] -mpihelp_submul_1: - .long .mpihelp_submul_1[PR], TOC[tc0], 0 - .csect .mpihelp_submul_1[PR] -.mpihelp_submul_1: + .globl _gcry_mpih_submul_1 + .globl ._gcry_mpih_submul_1 + .csect _gcry_mpih_submul_1[DS] +_gcry_mpih_submul_1: + .long ._gcry_mpih_submul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_submul_1[PR] +._gcry_mpih_submul_1: cal 3,-4(3) l 0,0(4) diff --git a/mpi/power/mpih-rshift.S b/mpi/power/mpih-rshift.S index 04fb5942..848d764e 100644 --- a/mpi/power/mpih-rshift.S +++ b/mpi/power/mpih-rshift.S @@ -32,17 +32,17 @@ */ .toc - .extern mpihelp_rshift[DS] - .extern .mpihelp_rshift + .extern _gcry_mpih_rshift[DS] + .extern ._gcry_mpih_rshift .csect [PR] .align 2 - .globl mpihelp_rshift - .globl .mpihelp_rshift - .csect mpihelp_rshift[DS] -mpihelp_rshift: - .long .mpihelp_rshift, TOC[tc0], 0 + .globl _gcry_mpih_rshift + .globl ._gcry_mpih_rshift + .csect _gcry_mpih_rshift[DS] +_gcry_mpih_rshift: + .long ._gcry_mpih_rshift, TOC[tc0], 0 .csect [PR] -.mpihelp_rshift: +._gcry_mpih_rshift: sfi 8,6,32 mtctr 5 # put limb count in CTR loop register l 0,0(4) # read least significant limb diff --git a/mpi/power/mpih-sub1.S b/mpi/power/mpih-sub1.S index 375a5be8..14d9dbf6 100644 --- a/mpi/power/mpih-sub1.S +++ b/mpi/power/mpih-sub1.S @@ -32,17 +32,17 @@ */ .toc - .extern mpihelp_sub_n[DS] - .extern .mpihelp_sub_n + .extern _gcry_mpih_sub_n[DS] + .extern ._gcry_mpih_sub_n .csect [PR] .align 2 - .globl mpihelp_sub_n - .globl .mpihelp_sub_n - .csect mpihelp_sub_n[DS] -mpihelp_sub_n: - .long .mpihelp_sub_n, TOC[tc0], 0 + .globl _gcry_mpih_sub_n + .globl ._gcry_mpih_sub_n + .csect _gcry_mpih_sub_n[DS] +_gcry_mpih_sub_n: + .long ._gcry_mpih_sub_n, TOC[tc0], 0 .csect [PR] -.mpihelp_sub_n: +._gcry_mpih_sub_n: andil. 10,6,1 # odd or even number of limbs? l 8,0(4) # load least significant s1 limb l 0,0(5) # load least significant s2 limb diff --git a/mpi/powerpc32/mpih-add1.S b/mpi/powerpc32/mpih-add1.S index 81c4e20f..12841604 100644 --- a/mpi/powerpc32/mpih-add1.S +++ b/mpi/powerpc32/mpih-add1.S @@ -27,24 +27,24 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, (r3) + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, (r3) * mpi_ptr_t s1_ptr, (r4) * mpi_ptr_t s2_ptr, (r5) * mpi_size_t size) (r6) */ .toc - .extern mpihelp_add_n[DS] - .extern .mpihelp_add_n + .extern _gcry_mpih_add_n[DS] + .extern ._gcry_mpih_add_n .csect [PR] .align 2 - .globl mpihelp_add_n - .globl .mpihelp_add_n - .csect mpihelp_add_n[DS] -mpihelp_add_n: - .long .mpihelp_add_n, TOC[tc0], 0 + .globl _gcry_mpih_add_n + .globl ._gcry_mpih_add_n + .csect _gcry_mpih_add_n[DS] +_gcry_mpih_add_n: + .long ._gcry_mpih_add_n, TOC[tc0], 0 .csect [PR] -.mpihelp_add_n: +._gcry_mpih_add_n: mtctr 6 # copy size into CTR lwz 8,0(4) # load least significant s1 limb lwz 0,0(5) # load least significant s2 limb @@ -93,7 +93,7 @@ Lend: stw 7,4(3) # store ultimate result limb possible 2-unrolled inner loop will not be. Also, watch out for the alignment... */ -EALIGN(mpihelp_add_n,3,0) +EALIGN(_gcry_mpih_add_n,3,0) /* Set up for loop below. */ mtcrf 0x01,%r6 srwi. %r7,%r6,1 @@ -131,6 +131,6 @@ EALIGN(mpihelp_add_n,3,0) /* Return the carry. */ 1: addze %r3,%r10 blr -END(mpihelp_add_n) +END(_gcry_mpih_add_n) #endif diff --git a/mpi/powerpc32/mpih-lshift.S b/mpi/powerpc32/mpih-lshift.S index 20ca7f92..73b025a1 100644 --- a/mpi/powerpc32/mpih-lshift.S +++ b/mpi/powerpc32/mpih-lshift.S @@ -27,7 +27,7 @@ /******************* * mpi_limb_t - * mpihelp_lshift( mpi_ptr_t wp, (r3) + * _gcry_mpih_lshift( mpi_ptr_t wp, (r3) * mpi_ptr_t up, (r4) * mpi_size_t usize, (r5) * unsigned cnt) (r6) @@ -36,13 +36,13 @@ .toc .csect .text[PR] .align 2 - .globl mpihelp_lshift - .globl .mpihelp_lshift - .csect mpihelp_lshift[DS] -mpihelp_lshift: - .long .mpihelp_lshift, TOC[tc0], 0 + .globl _gcry_mpih_lshift + .globl ._gcry_mpih_lshift + .csect _gcry_mpih_lshift[DS] +_gcry_mpih_lshift: + .long ._gcry_mpih_lshift, TOC[tc0], 0 .csect .text[PR] -.mpihelp_lshift: +._gcry_mpih_lshift: mtctr 5 # copy size into CTR slwi 0,5,2 add 7,3,0 # make r7 point at end of res @@ -96,7 +96,7 @@ Lend2: slw 0,10,6 /* mp_limb_t mpn_lshift (mp_ptr wp, mp_srcptr up, mp_size_t usize, unsigned int cnt) */ -EALIGN(mpihelp_lshift,3,0) +EALIGN(_gcry_mpih_lshift,3,0) mtctr %r5 # copy size into CTR cmplwi %cr0,%r5,16 # is size < 16 slwi %r0,%r5,2 @@ -194,5 +194,5 @@ L(end2):slw %r0,%r10,%r6 DO_LSHIFT(30) DO_LSHIFT(31) -END(mpihelp_lshift) +END(_gcry_mpih_lshift) #endif diff --git a/mpi/powerpc32/mpih-mul1.S b/mpi/powerpc32/mpih-mul1.S index b3cb62f3..2ab7528a 100644 --- a/mpi/powerpc32/mpih-mul1.S +++ b/mpi/powerpc32/mpih-mul1.S @@ -29,7 +29,7 @@ /******************* * mpi_limb_t - * mpihelp_mul_1( mpi_ptr_t res_ptr, (r3) + * _gcry_mpih_mul_1( mpi_ptr_t res_ptr, (r3) * mpi_ptr_t s1_ptr, (r4) * mpi_size_t s1_size, (r5) * mpi_limb_t s2_limb) (r6) @@ -42,15 +42,15 @@ */ .toc - .csect .mpihelp_mul_1[PR] + .csect ._gcry_mpih_mul_1[PR] .align 2 - .globl mpihelp_mul_1 - .globl .mpihelp_mul_1 - .csect mpihelp_mul_1[DS] -mpihelp_mul_1: - .long .mpihelp_mul_1[PR], TOC[tc0], 0 - .csect .mpihelp_mul_1[PR] -.mpihelp_mul_1: + .globl _gcry_mpih_mul_1 + .globl ._gcry_mpih_mul_1 + .csect _gcry_mpih_mul_1[DS] +_gcry_mpih_mul_1: + .long ._gcry_mpih_mul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_mul_1[PR] +._gcry_mpih_mul_1: mtctr 5 lwz 0,0(4) @@ -96,7 +96,7 @@ Lend: stw 7,4(3) mp_size_t s1_size, mp_limb_t s2_limb) Calculate s1*s2 and put result in res_ptr; return carry. */ -ENTRY(mpihelp_mul_1) +ENTRY(_gcry_mpih_mul_1) mtctr %r5 lwz %r0,0(%r4) @@ -116,5 +116,5 @@ ENTRY(mpihelp_mul_1) 1: stw %r7,4(%r3) addze %r3,%r10 blr -END(mpihelp_mul_1) +END(_gcry_mpih_mul_1) #endif diff --git a/mpi/powerpc32/mpih-mul2.S b/mpi/powerpc32/mpih-mul2.S index d3b39bc0..9c7793ed 100644 --- a/mpi/powerpc32/mpih-mul2.S +++ b/mpi/powerpc32/mpih-mul2.S @@ -28,7 +28,7 @@ /******************* * mpi_limb_t - * mpihelp_addmul_1( mpi_ptr_t res_ptr, (r3) + * _gcry_mpih_addmul_1( mpi_ptr_t res_ptr, (r3) * mpi_ptr_t s1_ptr, (r4) * mpi_size_t s1_size, (r5) * mpi_limb_t s2_limb) (r6) @@ -42,15 +42,15 @@ .toc - .csect .mpihelp_addmul_1[PR] + .csect ._gcry_mpih_addmul_1[PR] .align 2 - .globl mpihelp_addmul_1 - .globl .mpihelp_addmul_1 - .csect mpihelp_addmul_1[DS] -mpihelp_addmul_1: - .long .mpihelp_addmul_1[PR], TOC[tc0], 0 - .csect .mpihelp_addmul_1[PR] -.mpihelp_addmul_1: + .globl _gcry_mpih_addmul_1 + .globl ._gcry_mpih_addmul_1 + .csect _gcry_mpih_addmul_1[DS] +_gcry_mpih_addmul_1: + .long ._gcry_mpih_addmul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_addmul_1[PR] +._gcry_mpih_addmul_1: mtctr 5 lwz 0,0(4) @@ -99,7 +99,7 @@ Lend: stw 8,4(3) /* mp_limb_t mpn_addmul_1 (mp_ptr res_ptr, mp_srcptr s1_ptr, mp_size_t s1_size, mp_limb_t s2_limb) Calculate res+s1*s2 and put result back in res; return carry. */ -ENTRY(mpihelp_addmul_1) +ENTRY(_gcry_mpih_addmul_1) mtctr %r5 lwz %r0,0(%r4) @@ -123,5 +123,5 @@ ENTRY(mpihelp_addmul_1) 1: stw %r8,4(%r3) addze %r3,%r10 blr -END(mpihelp_addmul_1) +END(_gcry_mpih_addmul_1) #endif diff --git a/mpi/powerpc32/mpih-mul3.S b/mpi/powerpc32/mpih-mul3.S index d84f853b..d3ffdb93 100644 --- a/mpi/powerpc32/mpih-mul3.S +++ b/mpi/powerpc32/mpih-mul3.S @@ -28,7 +28,7 @@ /******************* * mpi_limb_t - * mpihelp_submul_1( mpi_ptr_t res_ptr, (r3) + * _gcry_mpih_submul_1( mpi_ptr_t res_ptr, (r3) * mpi_ptr_t s1_ptr, (r4) * mpi_size_t s1_size, (r5) * mpi_limb_t s2_limb) (r6) @@ -41,15 +41,15 @@ */ .toc - .csect .mpihelp_submul_1[PR] + .csect ._gcry_mpih_submul_1[PR] .align 2 - .globl mpihelp_submul_1 - .globl .mpihelp_submul_1 - .csect mpihelp_submul_1[DS] -mpihelp_submul_1: - .long .mpihelp_submul_1[PR], TOC[tc0], 0 - .csect .mpihelp_submul_1[PR] -.mpihelp_submul_1: + .globl _gcry_mpih_submul_1 + .globl ._gcry_mpih_submul_1 + .csect _gcry_mpih_submul_1[DS] +_gcry_mpih_submul_1: + .long ._gcry_mpih_submul_1[PR], TOC[tc0], 0 + .csect ._gcry_mpih_submul_1[PR] +._gcry_mpih_submul_1: mtctr 5 lwz 0,0(4) @@ -100,7 +100,7 @@ Lend: stw 8,4(3) mp_size_t s1_size, mp_limb_t s2_limb) Calculate res-s1*s2 and put result back in res; return carry. */ -ENTRY(mpihelp_submul_1) +ENTRY(_gcry_mpih_submul_1) mtctr %r5 lwz %r0,0(%r4) @@ -126,5 +126,5 @@ ENTRY(mpihelp_submul_1) 1: stw %r8,4(%r3) addze %r3,%r10 blr -END(mpihelp_submul_1) +END(_gcry_mpih_submul_1) #endif diff --git a/mpi/powerpc32/mpih-rshift.S b/mpi/powerpc32/mpih-rshift.S index e9704db9..260691e7 100644 --- a/mpi/powerpc32/mpih-rshift.S +++ b/mpi/powerpc32/mpih-rshift.S @@ -28,7 +28,7 @@ /******************* * mpi_limb_t - * mpihelp_rshift( mpi_ptr_t wp, (r3) + * _gcry_mpih_rshift( mpi_ptr_t wp, (r3) * mpi_ptr_t up, (r4) * mpi_size_t usize, (r5) * unsigned cnt) (r6) @@ -37,13 +37,13 @@ .toc .csect .text[PR] .align 2 - .globl mpihelp_rshift - .globl .mpihelp_rshift - .csect mpihelp_rshift[DS] -mpihelp_rshift: - .long .mpihelp_rshift, TOC[tc0], 0 + .globl _gcry_mpih_rshift + .globl ._gcry_mpih_rshift + .csect _gcry_mpih_rshift[DS] +_gcry_mpih_rshift: + .long ._gcry_mpih_rshift, TOC[tc0], 0 .csect .text[PR] -.mpihelp_rshift: +._gcry_mpih_rshift: mtctr 5 # copy size into CTR addi 7,3,-4 # move adjusted res_ptr to free return reg subfic 8,6,32 @@ -99,7 +99,7 @@ Lend2: srw 0,10,6 size r5 cnt r6 */ -ENTRY(mpihelp_rshift) +ENTRY(_gcry_mpih_rshift) mtctr 5 # copy size into CTR addi 7,3,-4 # move adjusted res_ptr to free return reg subfic 8,6,32 @@ -127,5 +127,5 @@ ENTRY(mpihelp_rshift) 2: srw 0,10,6 stw 0,4(7) blr -END(mpihelp_rshift) +END(_gcry_mpih_rshift) #endif diff --git a/mpi/powerpc32/mpih-sub1.S b/mpi/powerpc32/mpih-sub1.S index 8c67d988..5499f0cc 100644 --- a/mpi/powerpc32/mpih-sub1.S +++ b/mpi/powerpc32/mpih-sub1.S @@ -28,24 +28,24 @@ /******************* * mpi_limb_t - * mpihelp_sub_n( mpi_ptr_t res_ptr, (r3) + * _gcry_mpih_sub_n( mpi_ptr_t res_ptr, (r3) * mpi_ptr_t s1_ptr, (r4) * mpi_ptr_t s2_ptr, (r5) * mpi_size_t size) (r6) */ .toc - .extern mpihelp_sub_n[DS] - .extern .mpihelp_sub_n + .extern _gcry_mpih_sub_n[DS] + .extern ._gcry_mpih_sub_n .csect [PR] .align 2 - .globl mpihelp_sub_n - .globl .mpihelp_sub_n - .csect mpihelp_sub_n[DS] -mpihelp_sub_n: - .long .mpihelp_sub_n, TOC[tc0], 0 + .globl _gcry_mpih_sub_n + .globl ._gcry_mpih_sub_n + .csect _gcry_mpih_sub_n[DS] +_gcry_mpih_sub_n: + .long ._gcry_mpih_sub_n, TOC[tc0], 0 .csect [PR] -.mpihelp_sub_n: +._gcry_mpih_sub_n: mtctr 6 # copy size into CTR lwz 8,0(4) # load least significant s1 limb lwz 0,0(5) # load least significant s2 limb @@ -90,7 +90,7 @@ Lend: stw 7,4(3) # store ultimate result limb possible 2-unrolled inner loop will not be. Also, watch out for the alignment... */ -EALIGN(mpihelp_sub_n,3,1) +EALIGN(_gcry_mpih_sub_n,3,1) /* Set up for loop below. */ mtcrf 0x01,%r6 srwi. %r7,%r6,1 @@ -128,5 +128,5 @@ EALIGN(mpihelp_sub_n,3,1) 1: subfe %r3,%r3,%r3 neg %r3,%r3 blr -END(mpihelp_sub_n) +END(_gcry_mpih_sub_n) #endif diff --git a/mpi/sparc32/mpih-add1.S b/mpi/sparc32/mpih-add1.S index b8faadb5..809e4d73 100644 --- a/mpi/sparc32/mpih-add1.S +++ b/mpi/sparc32/mpih-add1.S @@ -25,7 +25,7 @@ /******************* * mpi_limb_t - * mpihelp_add_n( mpi_ptr_t res_ptr, + * _gcry_mpih_add_n( mpi_ptr_t res_ptr, * mpi_ptr_t s1_ptr, * mpi_ptr_t s2_ptr, * mpi_size_t size) @@ -41,8 +41,8 @@ .text .align 4 - .global C_SYMBOL_NAME(mpihelp_add_n) -C_SYMBOL_NAME(mpihelp_add_n): + .global C_SYMBOL_NAME(_gcry_mpih_add_n) +C_SYMBOL_NAME(_gcry_mpih_add_n): xor s2_ptr,res_ptr,%g1 andcc %g1,4,%g0 bne L1 ! branch if alignment differs diff --git a/mpi/sparc32/mpih-lshift.S b/mpi/sparc32/mpih-lshift.S index b217d5e6..d5d064c0 100644 --- a/mpi/sparc32/mpih-lshift.S +++ b/mpi/sparc32/mpih-lshift.S @@ -31,8 +31,8 @@ .text .align 4 - .global C_SYMBOL_NAME(mpihelp_lshift) -C_SYMBOL_NAME(mpihelp_lshift): + .global C_SYMBOL_NAME(_gcry_mpih_lshift) +C_SYMBOL_NAME(_gcry_mpih_lshift): sll %o2,2,%g1 add %o1,%g1,%o1 ! make %o1 point at end of src ld [%o1-4],%g2 ! load first limb diff --git a/mpi/sparc32/mpih-rshift.S b/mpi/sparc32/mpih-rshift.S index 62902cbe..a517aa80 100644 --- a/mpi/sparc32/mpih-rshift.S +++ b/mpi/sparc32/mpih-rshift.S @@ -30,8 +30,8 @@ .text .align 4 - .global C_SYMBOL_NAME(mpihelp_rshift) -C_SYMBOL_NAME(mpihelp_rshift): + .global C_SYMBOL_NAME(_gcry_mpih_rshift) +C_SYMBOL_NAME(_gcry_mpih_rshift): ld [%o1],%g2 ! load first limb sub %g0,%o3,%o5 ! negate shift count add %o2,-1,%o2 diff --git a/mpi/sparc32v8/mpih-mul1.S b/mpi/sparc32v8/mpih-mul1.S index 55145006..21e8808c 100644 --- a/mpi/sparc32v8/mpih-mul1.S +++ b/mpi/sparc32v8/mpih-mul1.S @@ -41,8 +41,8 @@ .text .align 8 - .global C_SYMBOL_NAME(mpihelp_mul_1) -C_SYMBOL_NAME(mpihelp_mul_1): + .global C_SYMBOL_NAME(_gcry_mpih_mul_1) +C_SYMBOL_NAME(_gcry_mpih_mul_1): sll %o2,4,%g1 and %g1,(4-1)<<4,%g1 #if PIC diff --git a/mpi/sparc32v8/mpih-mul2.S b/mpi/sparc32v8/mpih-mul2.S index 55f37814..afe3723d 100644 --- a/mpi/sparc32v8/mpih-mul2.S +++ b/mpi/sparc32v8/mpih-mul2.S @@ -41,8 +41,8 @@ .text .align 4 - .global C_SYMBOL_NAME(mpihelp_addmul_1) -C_SYMBOL_NAME(mpihelp_addmul_1): + .global C_SYMBOL_NAME(_gcry_mpih_addmul_1) +C_SYMBOL_NAME(_gcry_mpih_addmul_1): orcc %g0,%g0,%g2 ld [%o1+0],%o4 ! 1 diff --git a/mpi/sparc32v8/mpih-mul3.S b/mpi/sparc32v8/mpih-mul3.S index cfd0a157..50bb59fb 100644 --- a/mpi/sparc32v8/mpih-mul3.S +++ b/mpi/sparc32v8/mpih-mul3.S @@ -40,8 +40,8 @@ .text .align 4 - .global C_SYMBOL_NAME(mpihelp_submul_1) -C_SYMBOL_NAME(mpihelp_submul_1): + .global C_SYMBOL_NAME(_gcry_mpih_submul_1) +C_SYMBOL_NAME(_gcry_mpih_submul_1): sub %g0,%o2,%o2 ! negate ... sll %o2,2,%o2 ! ... and scale size sub %o1,%o2,%o1 ! o1 is offset s1_ptr diff --git a/src/ChangeLog b/src/ChangeLog index 1d5f769b..2ba366d9 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2001-05-31 Werner Koch <wk@gnupg.org> + + * gcrypt.h, mpi.h: Made some mpi functions public. + + * wrapper.c: Removed. + * global.c: Renamed all g10_ prefixed functions which had wrappers + to gcry_xxx. So we now use the exported memory functions inernally. + + Renamed all g10_ prefixed functions to _gcry_ prefixed ones. + + * g10lib.h (_GCRYPT_IN_LIBGCRYPT): Replace defintion by a test on it. + 2001-05-28 Werner Koch <wk@gnupg.org> * libgcrypt.m4: Check GCRYPT_VERSION macro and not LIBGCRYPT_VERSION. diff --git a/src/Makefile.am b/src/Makefile.am index 9febd7a8..f4a08445 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -36,7 +36,8 @@ include_HEADERS = gcrypt.h libgcrypt_la_LDFLAGS = -version-info \ @LIBGCRYPT_LT_CURRENT@:@LIBGCRYPT_LT_REVISION@:@LIBGCRYPT_LT_AGE@ -# -export-symbols libgcrypt.sym +# limiting the exported symbols is not good for debugging. +# -export-symbols libgcrypt.sym libgcrypt_la_SOURCES = g10lib.h \ types.h \ @@ -44,7 +45,6 @@ libgcrypt_la_SOURCES = g10lib.h \ misc.c \ global.c \ sexp.c \ - wrapper.c \ stdmem.c \ stdmem.h \ secmem.c \ @@ -65,5 +65,3 @@ libgcrypt.sym: $(libgcrypt_la_OBJECTS) $(NM) $(libgcrypt_la_OBJECTS) \ | $(AWK) '$$2=="T" && $$3 ~ /^gcry_/ {print $$3}' >libgcrypt.sym - - diff --git a/src/cipher.h b/src/cipher.h index b9bbd085..712d8a2d 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -20,7 +20,7 @@ #ifndef G10_CIPHER_H #define G10_CIPHER_H -#define DBG_CIPHER g10_get_debug_flag( 1 ) +#define DBG_CIPHER _gcry_get_debug_flag( 1 ) #include "../cipher/random.h" @@ -60,10 +60,10 @@ /*-- dynload.c --*/ -void register_cipher_extension( const char *mainpgm, const char *fname ); +void _gcry_register_cipher_extension( const char *mainpgm, const char *fname ); /*-- rmd160.c --*/ -void rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length ); +void _gcry_rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length ); /*-- smallprime.c --*/ diff --git a/src/g10lib.h b/src/g10lib.h index 060383c4..ae5b9269 100644 --- a/src/g10lib.h +++ b/src/g10lib.h @@ -1,8 +1,8 @@ /* g10lib.h - internal defintions for libgcrypt - * Copyright (C) 1998,1999,2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This header is to be used inside of libgcrypt in place of gcrypt.h. - * This way we can easily distinguish between internal and external + * This way we can better distinguish between internal and external * usage of gcrypt.h * * This file is part of Libgcrypt. @@ -28,10 +28,10 @@ #ifdef _GCRYPT_H #error gcrypt.h already included #endif -/* because libgcrypt is distributed along with GnuPG, we need some way - * to do a sanity check. If this macro is defined, we are inside of - * libgcrypt */ -#define _GCRYPT_IN_LIBGCRYPT 1 + +#ifndef _GCRYPT_IN_LIBGCRYPT + #error something is wrong with config.h +#endif #include <gcrypt.h> #include "types.h" @@ -41,63 +41,50 @@ #error i18n should not be included here #endif -#define _(a) g10_gettext(a) +#define _(a) _gcry_gettext(a) #define N_(a) (a) /*-- gcrypt/global.c --*/ -int set_lasterr( int ec ); - -void *g10_malloc( size_t n ); -void *g10_calloc( size_t n, size_t m ); -void *g10_malloc_secure( size_t n ); -void *g10_calloc_secure( size_t n, size_t m ); -void *g10_realloc( void *a, size_t n ); -char *g10_strdup( const char * a); -void *g10_xmalloc( size_t n ); -void *g10_xcalloc( size_t n, size_t m ); -void *g10_xmalloc_secure( size_t n ); -void *g10_xcalloc_secure( size_t n, size_t m ); -void *g10_xrealloc( void *a, size_t n ); -char *g10_xstrdup( const char * a); -void g10_free( void *p ); -int g10_is_secure( const void *a ); -void g10_check_heap( const void *a ); - -int g10_get_debug_flag( unsigned int mask ); +#define set_lasterr(a) _gcry_set_lasterr ((a)) +int _gcry_set_lasterr( int ec ); + +void _gcry_check_heap( const void *a ); + +int _gcry_get_debug_flag( unsigned int mask ); /*-- gcrypt/misc.c --*/ #ifdef JNLIB_GCC_M_FUNCTION -void g10_bug( const char *file, int line, const char *func ) JNLIB_GCC_A_NR; +void _gcry_bug( const char *file, int line, const char *func ) JNLIB_GCC_A_NR; #else -void g10_bug( const char *file, int line ); +void _gcry_bug( const char *file, int line ); #endif -const char *g10_gettext( const char *key ); -void g10_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR; -void g10_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3); -void g10_log_bug( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); -void g10_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); -void g10_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); -void g10_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); -void g10_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); +const char *_gcry_gettext( const char *key ); +void _gcry_fatal_error(int rc, const char *text ) JNLIB_GCC_A_NR; +void _gcry_log( int level, const char *fmt, ... ) JNLIB_GCC_A_PRINTF(2,3); +void _gcry_log_bug( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); +void _gcry_log_fatal( const char *fmt, ... ) JNLIB_GCC_A_NR_PRINTF(1,2); +void _gcry_log_error( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); +void _gcry_log_info( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); +void _gcry_log_debug( const char *fmt, ... ) JNLIB_GCC_A_PRINTF(1,2); -void g10_set_log_verbosity( int level ); -int g10_log_verbosity( int level ); +void _gcry_set_log_verbosity( int level ); +int _gcry_log_verbosity( int level ); #ifdef JNLIB_GCC_M_FUNCTION - #define BUG() g10_bug( __FILE__ , __LINE__, __FUNCTION__ ) + #define BUG() _gcry_bug( __FILE__ , __LINE__, __FUNCTION__ ) #else - #define BUG() g10_bug( __FILE__ , __LINE__ ) + #define BUG() _gcry_bug( __FILE__ , __LINE__ ) #endif -#define log_hexdump g10_log_hexdump -#define log_bug g10_log_bug -#define log_fatal g10_log_fatal -#define log_error g10_log_error -#define log_info g10_log_info -#define log_debug g10_log_debug +#define log_hexdump _gcry_log_hexdump +#define log_bug _gcry_log_bug +#define log_fatal _gcry_log_fatal +#define log_error _gcry_log_error +#define log_info _gcry_log_info +#define log_debug _gcry_log_debug @@ -120,9 +107,9 @@ unsigned pubkey_nbits( int algo, MPI *pkey ); /*-- primegen.c --*/ -MPI generate_secret_prime( unsigned nbits ); -MPI generate_public_prime( unsigned nbits ); -MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits, +MPI _gcry_generate_secret_prime( unsigned nbits ); +MPI _gcry_generate_public_prime( unsigned nbits ); +MPI _gcry_generate_elg_prime( int mode, unsigned pbits, unsigned qbits, MPI g, MPI **factors ); diff --git a/src/gcrypt.h b/src/gcrypt.h index 7fe5c470..63f121d3 100644 --- a/src/gcrypt.h +++ b/src/gcrypt.h @@ -35,7 +35,7 @@ extern "C" { * header matches the installed library. * Note: Do not edit the next line as configure may fix the string here. */ -#define GCRYPT_VERSION "1.1.2a" +#define GCRYPT_VERSION "1.1.3" #ifndef HAVE_BYTE_TYPEDEF @@ -219,14 +219,35 @@ int gcry_mpi_print( enum gcry_mpi_format format, int gcry_mpi_aprint( enum gcry_mpi_format format, void **buffer, size_t *nbytes, const GCRY_MPI a ); -void gcry_mpi_powm( GCRY_MPI w, - const GCRY_MPI b, const GCRY_MPI e, const GCRY_MPI m ); -GCRY_MPI gcry_mpi_set_opaque( GCRY_MPI a, void *p, unsigned int nbits ); -void *gcry_mpi_get_opaque( GCRY_MPI a, unsigned int *nbits ); -void gcry_mpi_set_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); -void gcry_mpi_clear_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); -int gcry_mpi_get_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); + +void gcry_mpi_add(GCRY_MPI w, GCRY_MPI u, GCRY_MPI v); +void gcry_mpi_add_ui(GCRY_MPI w, GCRY_MPI u, unsigned long v ); +void gcry_mpi_addm(GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m); +void gcry_mpi_sub( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v); +void gcry_mpi_sub_ui(GCRY_MPI w, GCRY_MPI u, ulong v ); +void gcry_mpi_subm( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m); +void gcry_mpi_mul_ui(GCRY_MPI w, GCRY_MPI u, unsigned long v ); +void gcry_mpi_mul_2exp( GCRY_MPI w, GCRY_MPI u, unsigned long cnt); +void gcry_mpi_mul( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v); +void gcry_mpi_mulm( GCRY_MPI w, GCRY_MPI u, GCRY_MPI v, GCRY_MPI m); + +void gcry_mpi_powm( GCRY_MPI w, + const GCRY_MPI b, const GCRY_MPI e, const GCRY_MPI m ); +int gcry_mpi_gcd( GCRY_MPI g, GCRY_MPI a, GCRY_MPI b ); + unsigned int gcry_mpi_get_nbits( GCRY_MPI a ); +int gcry_mpi_test_bit( GCRY_MPI a, unsigned int n ); +void gcry_mpi_set_bit( GCRY_MPI a, unsigned int n ); +void gcry_mpi_clear_bit( GCRY_MPI a, unsigned int n ); +void gcry_mpi_set_highbit( GCRY_MPI a, unsigned int n ); +void gcry_mpi_clear_highbit( GCRY_MPI a, unsigned int n ); +void gcry_mpi_rshift( GCRY_MPI x, GCRY_MPI a, unsigned int n ); + +GCRY_MPI gcry_mpi_set_opaque( GCRY_MPI a, void *p, unsigned int nbits ); +void * gcry_mpi_get_opaque( GCRY_MPI a, unsigned int *nbits ); +void gcry_mpi_set_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); +void gcry_mpi_clear_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); +int gcry_mpi_get_flag( GCRY_MPI a, enum gcry_mpi_flag flag ); #ifndef GCRYPT_NO_MPI_MACROS @@ -240,7 +261,27 @@ unsigned int gcry_mpi_get_nbits( GCRY_MPI a ); #define mpi_cmp( u, v ) gcry_mpi_cmp( (u), (v) ) #define mpi_cmp_ui( u, v ) gcry_mpi_cmp_ui( (u), (v) ) +#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v)) +#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v)) +#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m)) +#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v)) +#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v)) +#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m)) +#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v)) +#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v)) +#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v)) +#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m)) #define mpi_powm(w,b,e,m) gcry_mpi_powm( (w), (b), (e), (m) ) +#define mpi_gcd(g,a,b) gcry_mpi_gcd( (g), (a), (b) ) + +#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a)) +#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b)) +#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b)) +#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b)) +#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b)) +#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b)) +#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c)) + #define mpi_set_opaque(a,b,c) gcry_mpi_set_opaque( (a), (b), (c) ) #define mpi_get_opaque(a,b) gcry_mpi_get_opaque( (a), (b) ) #endif /* GCRYPT_NO_MPI_MACROS */ @@ -268,6 +309,11 @@ enum gcry_cipher_algos { GCRY_CIPHER_ARCFOUR = 301 }; +#define GCRY_CIPHER_AES GCRY_CIPHER_RIJNDAEL +#define GCRY_CIPHER_AES128 GCRY_CIPHER_RIJNDAEL128 +#define GCRY_CIPHER_AES192 GCRY_CIPHER_RIJNDAEL192 +#define GCRY_CIPHER_AES256 GCRY_CIPHER_RIJNDAEL256 + enum gcry_cipher_modes { GCRY_CIPHER_MODE_NONE = 0, GCRY_CIPHER_MODE_ECB = 1, diff --git a/src/global.c b/src/global.c index e8f9d2de..8466dace 100644 --- a/src/global.c +++ b/src/global.c @@ -1,5 +1,5 @@ /* global.c - global control functions - * Copyright (C) 1998 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -27,6 +27,7 @@ #include <assert.h> #include "g10lib.h" +#include "../cipher/random.h" #include "stdmem.h" /* our own memory allocator */ #include "secmem.h" /* our own secmem allocator */ @@ -131,11 +132,11 @@ gcry_control( enum gcry_ctl_cmds cmd, ... ) #endif case GCRYCTL_ENABLE_M_GUARD: - g10_private_enable_m_guard(); + _gcry_private_enable_m_guard(); break; case GCRYCTL_DUMP_RANDOM_STATS: - random_dump_stats(); + _gcry_random_dump_stats(); break; case GCRYCTL_DUMP_MEMORY_STATS: @@ -143,39 +144,39 @@ gcry_control( enum gcry_ctl_cmds cmd, ... ) break; case GCRYCTL_DUMP_SECMEM_STATS: - secmem_dump_stats(); + _gcry_secmem_dump_stats(); break; case GCRYCTL_DROP_PRIVS: - secmem_init( 0 ); + _gcry_secmem_init( 0 ); break; case GCRYCTL_INIT_SECMEM: - secmem_init( va_arg( arg_ptr, unsigned int ) ); + _gcry_secmem_init( va_arg( arg_ptr, unsigned int ) ); break; case GCRYCTL_TERM_SECMEM: - secmem_term(); + _gcry_secmem_term(); break; case GCRYCTL_DISABLE_SECMEM_WARN: - secmem_set_flags( secmem_get_flags() | 1 ); + _gcry_secmem_set_flags( (_gcry_secmem_get_flags() | 1) ); break; case GCRYCTL_SUSPEND_SECMEM_WARN: - secmem_set_flags( secmem_get_flags() | 2 ); + _gcry_secmem_set_flags( (_gcry_secmem_get_flags() | 2) ); break; case GCRYCTL_RESUME_SECMEM_WARN: - secmem_set_flags( secmem_get_flags() & ~2 ); + _gcry_secmem_set_flags( (_gcry_secmem_get_flags() & ~2) ); break; case GCRYCTL_USE_SECURE_RNDPOOL: - secure_random_alloc(); /* put random number into secure memory */ + _gcry_secure_random_alloc(); /* put random number into secure memory */ break; case GCRYCTL_SET_VERBOSITY: - g10_set_log_verbosity( va_arg( arg_ptr, int ) ); + _gcry_set_log_verbosity( va_arg( arg_ptr, int ) ); break; case GCRYCTL_SET_DEBUG_FLAGS: @@ -237,7 +238,7 @@ gcry_strerror( int ec ) int -set_lasterr( int ec ) +_gcry_set_lasterr( int ec ) { if( ec ) last_ec = ec == -1 ? GCRYERR_EOF : ec; @@ -290,53 +291,53 @@ gcry_set_outofcore_handler( int (*f)( void*, size_t, unsigned int ), void * -g10_malloc( size_t n ) +gcry_malloc( size_t n ) { if( alloc_func ) return alloc_func( n ) ; - return g10_private_malloc( n ); + return _gcry_private_malloc( n ); } void * -g10_malloc_secure( size_t n ) +gcry_malloc_secure( size_t n ) { if( alloc_secure_func ) return alloc_secure_func( n ) ; - return g10_private_malloc_secure( n ); + return _gcry_private_malloc_secure( n ); } int -g10_is_secure( const void *a ) +gcry_is_secure( const void *a ) { if( is_secure_func ) return is_secure_func( a ) ; - return g10_private_is_secure( a ); + return _gcry_private_is_secure( a ); } void -g10_check_heap( const void *a ) +_gcry_check_heap( const void *a ) { /* FIXME: implement this*/ #if 0 if( some_handler ) some_handler(a) else - g10_private_check_heap(a) + _gcry_private_check_heap(a) #endif } void * -g10_realloc( void *a, size_t n ) +gcry_realloc( void *a, size_t n ) { /* FIXME: Make sure that the realloced memory is cleared out */ if( realloc_func ) return realloc_func( a, n ) ; - return g10_private_realloc( a, n ); + return _gcry_private_realloc( a, n ); } void -g10_free( void *p ) +gcry_free( void *p ) { if( !p ) return; @@ -344,22 +345,22 @@ g10_free( void *p ) if( free_func ) free_func( p ); else - g10_private_free( p ); + _gcry_private_free( p ); } void * -g10_calloc( size_t n, size_t m ) +gcry_calloc( size_t n, size_t m ) { - void *p = g10_malloc( n*m ); + void *p = gcry_malloc( n*m ); if( p ) memset( p, 0, n*m ); return p; } void * -g10_calloc_secure( size_t n, size_t m ) +gcry_calloc_secure( size_t n, size_t m ) { - void *p = g10_malloc_secure( n*m ); + void *p = gcry_malloc_secure( n*m ); if( p ) memset( p, 0, n*m ); return p; @@ -367,42 +368,42 @@ g10_calloc_secure( size_t n, size_t m ) void * -g10_xmalloc( size_t n ) +gcry_xmalloc( size_t n ) { void *p; - while ( !(p = g10_malloc( n )) ) { + while ( !(p = gcry_malloc( n )) ) { if( !outofcore_handler || !outofcore_handler( outofcore_handler_value, n, 0 ) ) { - g10_fatal_error(GCRYERR_NO_MEM, NULL ); + _gcry_fatal_error(GCRYERR_NO_MEM, NULL ); } } return p; } void * -g10_xrealloc( void *a, size_t n ) +gcry_xrealloc( void *a, size_t n ) { void *p; - while ( !(p = g10_realloc( a, n )) ) { + while ( !(p = gcry_realloc( a, n )) ) { if( !outofcore_handler || !outofcore_handler( outofcore_handler_value, n, 2 ) ) { - g10_fatal_error(GCRYERR_NO_MEM, NULL ); + _gcry_fatal_error(GCRYERR_NO_MEM, NULL ); } } return p; } void * -g10_xmalloc_secure( size_t n ) +gcry_xmalloc_secure( size_t n ) { void *p; - while ( !(p = g10_malloc_secure( n )) ) { + while ( !(p = gcry_malloc_secure( n )) ) { if( !outofcore_handler || !outofcore_handler( outofcore_handler_value, n, 1 ) ) { - g10_fatal_error(GCRYERR_NO_MEM, + _gcry_fatal_error(GCRYERR_NO_MEM, _("out of core in secure memory")); } } @@ -410,32 +411,32 @@ g10_xmalloc_secure( size_t n ) } void * -g10_xcalloc( size_t n, size_t m ) +gcry_xcalloc( size_t n, size_t m ) { - void *p = g10_xmalloc( n*m ); + void *p = gcry_xmalloc( n*m ); memset( p, 0, n*m ); return p; } void * -g10_xcalloc_secure( size_t n, size_t m ) +gcry_xcalloc_secure( size_t n, size_t m ) { - void *p = g10_xmalloc_secure( n* m ); + void *p = gcry_xmalloc_secure( n* m ); memset( p, 0, n*m ); return p; } char * -g10_xstrdup( const char *string ) +gcry_xstrdup( const char *string ) { - void *p = g10_xmalloc( strlen(string)+1 ); + void *p = gcry_xmalloc( strlen(string)+1 ); strcpy( p, string ); return p; } int -g10_get_debug_flag( unsigned int mask ) +_gcry_get_debug_flag( unsigned int mask ) { return debug_flags & mask; } @@ -1,5 +1,5 @@ /* misc.c - * Copyright (C) 1999 Free Software Foundation, Inc. + * Copyright (C) 1999, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -45,7 +45,7 @@ gcry_set_gettext_handler( const char *(*f)(const char*) ) const char * -g10_gettext( const char *key ) +_gcry_gettext( const char *key ) { if( user_gettext_handler ) return user_gettext_handler( key ); @@ -71,7 +71,7 @@ write2stderr( const char *s ) * set his own handler becuase this function simply calls abort(). */ void -g10_fatal_error(int rc, const char *text ) +_gcry_fatal_error(int rc, const char *text ) { if( !text ) /* get a default text */ text = gcry_strerror(rc); @@ -95,13 +95,13 @@ gcry_set_log_handler( void (*logf)(void*,int, const char*, va_list ), } void -g10_set_log_verbosity( int level ) +_gcry_set_log_verbosity( int level ) { verbosity_level = level; } int -g10_log_verbosity( int level ) +_gcry_log_verbosity( int level ) { return verbosity_level >= level; } @@ -111,7 +111,7 @@ g10_log_verbosity( int level ) * using the function defined with gcry_set_log_handler(). */ static void -g10_logv( int level, const char *fmt, va_list arg_ptr ) +_gcry_logv( int level, const char *fmt, va_list arg_ptr ) { if( log_handler ) log_handler( log_handler_value, level, fmt, arg_ptr ); @@ -136,84 +136,84 @@ g10_logv( int level, const char *fmt, va_list arg_ptr ) } void -g10_log( int level, const char *fmt, ... ) +_gcry_log( int level, const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( level, fmt, arg_ptr ); + _gcry_logv( level, fmt, arg_ptr ); va_end(arg_ptr); } #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 ) void -g10_bug( const char *file, int line, const char *func ) +_gcry_bug( const char *file, int line, const char *func ) { - g10_log( GCRY_LOG_BUG, + _gcry_log( GCRY_LOG_BUG, ("... this is a bug (%s:%d:%s)\n"), file, line, func ); abort(); /* never called, but it makes the compiler happy */ } #else void -g10_bug( const char *file, int line ) +_gcry_bug( const char *file, int line ) { - g10_log( GCRY_LOG_BUG, + _gcry_log( GCRY_LOG_BUG, _("you found a bug ... (%s:%d)\n"), file, line); abort(); /* never called, but it makes the compiler happy */ } #endif void -g10_log_info( const char *fmt, ... ) +_gcry_log_info( const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( GCRY_LOG_INFO, fmt, arg_ptr ); + _gcry_logv( GCRY_LOG_INFO, fmt, arg_ptr ); va_end(arg_ptr); } void -g10_log_error( const char *fmt, ... ) +_gcry_log_error( const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( GCRY_LOG_ERROR, fmt, arg_ptr ); + _gcry_logv( GCRY_LOG_ERROR, fmt, arg_ptr ); va_end(arg_ptr); } void -g10_log_fatal( const char *fmt, ... ) +_gcry_log_fatal( const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( GCRY_LOG_FATAL, fmt, arg_ptr ); + _gcry_logv( GCRY_LOG_FATAL, fmt, arg_ptr ); va_end(arg_ptr); abort(); /* never called, bugs it makes the compiler happy */ } void -g10_log_bug( const char *fmt, ... ) +_gcry_log_bug( const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( GCRY_LOG_BUG, fmt, arg_ptr ); + _gcry_logv( GCRY_LOG_BUG, fmt, arg_ptr ); va_end(arg_ptr); abort(); /* never called, bugs it makes the compiler happy */ } void -g10_log_debug( const char *fmt, ... ) +_gcry_log_debug( const char *fmt, ... ) { va_list arg_ptr ; va_start( arg_ptr, fmt ) ; - g10_logv( GCRY_LOG_DEBUG, fmt, arg_ptr ); + _gcry_logv( GCRY_LOG_DEBUG, fmt, arg_ptr ); va_end(arg_ptr); } @@ -1,5 +1,5 @@ /* mpi.h - Multi Precision Integers - * Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc. + * Copyright (C) 1994, 1996, 1998, 2001 Free Software Foundation, Inc. * * This file is part of GNUPG. * @@ -35,6 +35,10 @@ #include "memory.h" #include "../mpi/mpi-asm-defs.h" +#ifndef _GCRYPT_IN_LIBGCRYPT + #error this file should only be used inside libgcrypt +#endif + #ifndef BITS_PER_MPI_LIMB #if BYTES_PER_MPI_LIMB == SIZEOF_UNSIGNED_INT typedef unsigned int mpi_limb_t; @@ -54,7 +58,7 @@ #define BITS_PER_MPI_LIMB (8*BYTES_PER_MPI_LIMB) #endif /*BITS_PER_MPI_LIMB*/ -#define DBG_MPI g10_get_debug_flag( 2 ); +#define DBG_MPI _gcry_get_debug_flag( 2 ); struct gcry_mpi { int alloced; /* array size (# of allocated limbs) */ @@ -79,93 +83,122 @@ struct gcry_mpi { /*-- mpiutil.c --*/ #ifdef M_DEBUG - #define mpi_alloc(n) mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) ) - #define mpi_alloc_secure(n) mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) ) - #define mpi_free(a) mpi_debug_free((a), M_DBGINFO(__LINE__) ) - #define mpi_resize(a,b) mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) ) - #define mpi_copy(a) mpi_debug_copy((a), M_DBGINFO(__LINE__) ) - MPI mpi_debug_alloc( unsigned nlimbs, const char *info ); - MPI mpi_debug_alloc_secure( unsigned nlimbs, const char *info ); - void mpi_debug_free( MPI a, const char *info ); - void mpi_debug_resize( MPI a, unsigned nlimbs, const char *info ); - MPI mpi_debug_copy( MPI a, const char *info ); + #define mpi_alloc(n) _gcry_mpi_debug_alloc((n), M_DBGINFO( __LINE__ ) ) + #define mpi_alloc_secure(n) _gcry_mpi_debug_alloc_secure((n), M_DBGINFO( __LINE__ ) ) + #define mpi_free(a) _gcry_mpi_debug_free((a), M_DBGINFO(__LINE__) ) + #define mpi_resize(a,b) _gcry_mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) ) + #define mpi_copy(a) _gcry_mpi_debug_copy((a), M_DBGINFO(__LINE__) ) + MPI _gcry_mpi_debug_alloc( unsigned nlimbs, const char *info ); + MPI _gcry_mpi_debug_alloc_secure( unsigned nlimbs, const char *info ); + void _gcry_mpi_debug_free( MPI a, const char *info ); + void _gcry_mpi_debug_resize( MPI a, unsigned nlimbs, const char *info ); + MPI _gcry_mpi_debug_copy( MPI a, const char *info ); #else - MPI mpi_alloc( unsigned nlimbs ); - MPI mpi_alloc_secure( unsigned nlimbs ); - void mpi_free( MPI a ); - void mpi_resize( MPI a, unsigned nlimbs ); - MPI mpi_copy( MPI a ); + #define mpi_alloc(n) _gcry_mpi_alloc((n) ) + #define mpi_alloc_secure(n) _gcry_mpi_alloc_secure((n) ) + #define mpi_free(a) _gcry_mpi_free((a) ) + #define mpi_resize(a,b) _gcry_mpi_resize((a),(b)) + #define mpi_copy(a) _gcry_mpi_copy((a)) + MPI _gcry_mpi_alloc( unsigned nlimbs ); + MPI _gcry_mpi_alloc_secure( unsigned nlimbs ); + void _gcry_mpi_free( MPI a ); + void _gcry_mpi_resize( MPI a, unsigned nlimbs ); + MPI _gcry_mpi_copy( MPI a ); #endif #define mpi_is_opaque(a) ((a) && ((a)->flags&4)) #define mpi_is_secure(a) ((a) && ((a)->flags&1)) -void mpi_clear( MPI a ); -MPI mpi_alloc_like( MPI a ); -void mpi_set( MPI w, MPI u); -void mpi_set_ui( MPI w, ulong u); -MPI mpi_alloc_set_ui( unsigned long u); -void mpi_m_check( MPI a ); -void mpi_swap( MPI a, MPI b); +#define mpi_clear(a) _gcry_mpi_clear ((a)) +#define mpi_alloc_like(a) _gcry_mpi_alloc_like((a)) +#define mpi_set(a,b) _gcry_mpi_set ((a),(b)) +#define mpi_set_ui(a,b) _gcry_mpi_set_ui ((a),(b)) +#define mpi_alloc_set_ui(a) _gcry_mpi_alloc_set_ui ((a)) +#define mpi_m_check(a) _gcry_mpi_m_check ((a)) +#define mpi_swap(a,b) _gcry_mpi_swap ((a),(b)) + +void _gcry_mpi_clear( MPI a ); +MPI _gcry_mpi_alloc_like( MPI a ); +void _gcry_mpi_set( MPI w, MPI u); +void _gcry_mpi_set_ui( MPI w, ulong u); +MPI _gcry_mpi_alloc_set_ui( unsigned long u); +void _gcry_mpi_m_check( MPI a ); +void _gcry_mpi_swap( MPI a, MPI b); /*-- mpicoder.c --*/ -void g10_log_mpidump( const char *text, MPI a ); -u32 mpi_get_keyid( MPI a, u32 *keyid ); -byte *mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ); -byte *mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ); -void mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ); +void _gcry_log_mpidump( const char *text, MPI a ); +u32 _gcry_mpi_get_keyid( MPI a, u32 *keyid ); +byte *_gcry_mpi_get_buffer( MPI a, unsigned *nbytes, int *sign ); +byte *_gcry_mpi_get_secure_buffer( MPI a, unsigned *nbytes, int *sign ); +void _gcry_mpi_set_buffer( MPI a, const byte *buffer, unsigned nbytes, int sign ); -#define log_mpidump g10_log_mpidump +#define log_mpidump _gcry_log_mpidump /*-- mpi-add.c --*/ -void mpi_add_ui(MPI w, MPI u, ulong v ); -void mpi_add(MPI w, MPI u, MPI v); -void mpi_addm(MPI w, MPI u, MPI v, MPI m); -void mpi_sub_ui(MPI w, MPI u, ulong v ); -void mpi_sub( MPI w, MPI u, MPI v); -void mpi_subm( MPI w, MPI u, MPI v, MPI m); +#define mpi_add_ui(w,u,v) gcry_mpi_add_ui((w),(u),(v)) +#define mpi_add(w,u,v) gcry_mpi_add ((w),(u),(v)) +#define mpi_addm(w,u,v,m) gcry_mpi_addm ((w),(u),(v),(m)) +#define mpi_sub_ui(w,u,v) gcry_mpi_sub_ui ((w),(u),(v)) +#define mpi_sub(w,u,v) gcry_mpi_sub ((w),(u),(v)) +#define mpi_subm(w,u,v,m) gcry_mpi_subm ((w),(u),(v),(m)) + /*-- mpi-mul.c --*/ -void mpi_mul_ui(MPI w, MPI u, ulong v ); -void mpi_mul_2exp( MPI w, MPI u, ulong cnt); -void mpi_mul( MPI w, MPI u, MPI v); -void mpi_mulm( MPI w, MPI u, MPI v, MPI m); +#define mpi_mul_ui(w,u,v) gcry_mpi_mul_ui ((w),(u),(v)) +#define mpi_mul_2exp(w,u,v) gcry_mpi_mul_2exp ((w),(u),(v)) +#define mpi_mul(w,u,v) gcry_mpi_mul ((w),(u),(v)) +#define mpi_mulm(w,u,v,m) gcry_mpi_mulm ((w),(u),(v),(m)) + /*-- mpi-div.c --*/ -ulong mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor ); -void mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ); -void mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor ); -void mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ); -void mpi_tdiv_r( MPI rem, MPI num, MPI den); -void mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den); -void mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count ); -int mpi_divisible_ui(MPI dividend, ulong divisor ); +#define mpi_fdiv_r_ui(a,b,c) _gcry_mpi_fdiv_r_ui((a),(b),(c)) +#define mpi_fdiv_r(a,b,c) _gcry_mpi_fdiv_r((a),(b),(c)) +#define mpi_fdiv_q(a,b,c) _gcry_mpi_fdiv_q((a),(b),(c)) +#define mpi_fdiv_qr(a,b,c,d) _gcry_mpi_fdiv_qr((a),(b),(c),(d)) +#define mpi_tdiv_r(a,b,c) _gcry_mpi_tdiv_r((a),(b),(c)) +#define mpi_tdiv_qr(a,b,c,d) _gcry_mpi_tdiv_qr((a),(b),(c),(d)) +#define mpi_tdiv_q_2exp(a,b,c) _gcry_mpi_tdiv_q_2exp((a),(b),(c)) +#define mpi_divisible_ui(a,b) _gcry_mpi_divisible_ui((a),(b)) +ulong _gcry_mpi_fdiv_r_ui( MPI rem, MPI dividend, ulong divisor ); +void _gcry_mpi_fdiv_r( MPI rem, MPI dividend, MPI divisor ); +void _gcry_mpi_fdiv_q( MPI quot, MPI dividend, MPI divisor ); +void _gcry_mpi_fdiv_qr( MPI quot, MPI rem, MPI dividend, MPI divisor ); +void _gcry_mpi_tdiv_r( MPI rem, MPI num, MPI den); +void _gcry_mpi_tdiv_qr( MPI quot, MPI rem, MPI num, MPI den); +void _gcry_mpi_tdiv_q_2exp( MPI w, MPI u, unsigned count ); +int _gcry_mpi_divisible_ui(MPI dividend, ulong divisor ); /*-- mpi-gcd.c --*/ -int mpi_gcd( MPI g, MPI a, MPI b ); /*-- mpi-mpow.c --*/ -void mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod); +#define mpi_mulpowm(a,b,c,d) _gcry_mpi_mulpowm ((a),(b),(c),(d)) +void _gcry_mpi_mulpowm( MPI res, MPI *basearray, MPI *exparray, MPI mod); /*-- mpi-cmp.c --*/ -int mpi_cmp_ui( MPI u, ulong v ); -int mpi_cmp( MPI u, MPI v ); +#define mpi_cmp_ui(a,b) gcry_mpi_cmp_ui ((a),(b)) +#define mpi_cmp(a,b) gcry_mpi_cmp ((a),(b)) +int gcry_mpi_cmp_ui( MPI u, ulong v ); +int gcry_mpi_cmp( MPI u, MPI v ); /*-- mpi-scan.c --*/ -int mpi_getbyte( MPI a, unsigned idx ); -void mpi_putbyte( MPI a, unsigned idx, int value ); -unsigned mpi_trailing_zeros( MPI a ); +#define mpi_trailing_zeros(a) _gcry_mpi_trailing_zeros ((a)) +int _gcry_mpi_getbyte( MPI a, unsigned idx ); +void _gcry_mpi_putbyte( MPI a, unsigned idx, int value ); +unsigned _gcry_mpi_trailing_zeros( MPI a ); /*-- mpi-bit.c --*/ -void mpi_normalize( MPI a ); -unsigned int mpi_get_nbits( MPI a ); -int mpi_test_bit( MPI a, unsigned n ); -void mpi_set_bit( MPI a, unsigned n ); -void mpi_set_highbit( MPI a, unsigned n ); -void mpi_clear_highbit( MPI a, unsigned n ); -void mpi_clear_bit( MPI a, unsigned n ); -void mpi_rshift( MPI x, MPI a, unsigned n ); +#define mpi_normalize(a) _gcry_mpi_normalize ((a)) +#define mpi_get_nbits(a) gcry_mpi_get_nbits ((a)) +#define mpi_test_bit(a,b) gcry_mpi_test_bit ((a),(b)) +#define mpi_set_bit(a,b) gcry_mpi_set_bit ((a),(b)) +#define mpi_set_highbit(a,b) gcry_mpi_set_highbit ((a),(b)) +#define mpi_clear_bit(a,b) gcry_mpi_clear_bit ((a),(b)) +#define mpi_clear_highbit(a,b) gcry_mpi_clear_highbit ((a),(b)) +#define mpi_rshift(a,b,c) gcry_mpi_rshift ((a),(b),(c)) + +void _gcry_mpi_normalize( MPI a ); /*-- mpi-inv.c --*/ -void mpi_invm( MPI x, MPI u, MPI v ); +#define mpi_invm(a,b,c) _gcry_mpi_invm ((a),(b),(c)) +void _gcry_mpi_invm( MPI x, MPI u, MPI v ); #endif /*G10_MPI_H*/ diff --git a/src/secmem.c b/src/secmem.c index 706513a8..4ef44e5f 100644 --- a/src/secmem.c +++ b/src/secmem.c @@ -1,5 +1,5 @@ /* secmem.c - memory allocation from a secure heap - * Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1998, 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -222,7 +222,7 @@ compress_pool(void) } void -secmem_set_flags( unsigned flags ) +_gcry_secmem_set_flags( unsigned flags ) { int was_susp = suspend_warning; @@ -237,7 +237,7 @@ secmem_set_flags( unsigned flags ) } unsigned -secmem_get_flags(void) +_gcry_secmem_get_flags(void) { unsigned flags; @@ -247,7 +247,7 @@ secmem_get_flags(void) } void -secmem_init( size_t n ) +_gcry_secmem_init( size_t n ) { if( !n ) { #ifdef USE_CAPABILITIES @@ -277,7 +277,7 @@ secmem_init( size_t n ) void * -secmem_malloc( size_t size ) +_gcry_secmem_malloc( size_t size ) { MEMBLOCK *mb, *mb2; int compressed=0; @@ -334,7 +334,7 @@ secmem_malloc( size_t size ) void * -secmem_realloc( void *p, size_t newsize ) +_gcry_secmem_realloc( void *p, size_t newsize ) { MEMBLOCK *mb; size_t size; @@ -344,18 +344,18 @@ secmem_realloc( void *p, size_t newsize ) size = mb->size; if( newsize < size ) return p; /* it is easier not to shrink the memory */ - a = secmem_malloc( newsize ); + a = _gcry_secmem_malloc( newsize ); if ( a ) { memcpy(a, p, size); memset((char*)a+size, 0, newsize-size); - secmem_free(p); + _gcry_secmem_free(p); } return a; } void -secmem_free( void *a ) +_gcry_secmem_free( void *a ) { MEMBLOCK *mb; size_t size; @@ -380,7 +380,7 @@ secmem_free( void *a ) int -g10_private_is_secure( const void *p ) +_gcry_private_is_secure( const void *p ) { return p >= pool && p < (void*)((char*)pool+poolsize); } @@ -396,7 +396,7 @@ g10_private_is_secure( const void *p ) * there is no chance to get the secure memory cleaned. */ void -secmem_term() +_gcry_secmem_term() { if( !pool_okay ) return; @@ -418,7 +418,7 @@ secmem_term() void -secmem_dump_stats() +_gcry_secmem_dump_stats() { if( disable_secmem ) return; diff --git a/src/secmem.h b/src/secmem.h index 769c82f0..24110d51 100644 --- a/src/secmem.h +++ b/src/secmem.h @@ -1,5 +1,5 @@ /* secmem.h - internal definitions for secmem - * Copyright (C) 2000 Free Software Foundation, Inc. + * Copyright (C) 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -21,15 +21,15 @@ #ifndef G10_SECMEM_H #define G10_SECMEM_H 1 -void secmem_init( size_t npool ); -void secmem_term( void ); -void *secmem_malloc( size_t size ); -void *secmem_realloc( void *a, size_t newsize ); -void secmem_free( void *a ); -void secmem_dump_stats(void); -void secmem_set_flags( unsigned flags ); -unsigned secmem_get_flags(void); +void _gcry_secmem_init( size_t npool ); +void _gcry_secmem_term( void ); +void *_gcry_secmem_malloc( size_t size ); +void *_gcry_secmem_realloc( void *a, size_t newsize ); +void _gcry_secmem_free( void *a ); +void _gcry_secmem_dump_stats(void); +void _gcry_secmem_set_flags( unsigned flags ); +unsigned _gcry_secmem_get_flags(void); -int g10_private_is_secure( const void *p ); +int _gcry_private_is_secure( const void *p ); #endif /* G10_SECMEM_H */ @@ -1,5 +1,5 @@ /* sexp.c - S-Expression handling - * Copyright (C) 1999, 2000 Free Software Foundation, Inc. + * Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -159,7 +159,7 @@ normalize ( GCRY_SEXP list ) void gcry_sexp_release( GCRY_SEXP sexp ) { - g10_free ( sexp ); + gcry_free ( sexp ); } @@ -269,7 +269,7 @@ gcry_sexp_find_token( const GCRY_SEXP list, const char *tok, size_t toklen ) } while ( level ); n = p - head; - newlist = g10_xmalloc ( sizeof *newlist + n ); + newlist = gcry_xmalloc ( sizeof *newlist + n ); d = newlist->d; memcpy ( d, head, n ); d += n; *d++ = ST_STOP; @@ -367,7 +367,7 @@ gcry_sexp_nth( const GCRY_SEXP list, int number ) if ( *p == ST_DATA ) { memcpy ( &n, p, sizeof n ); p += sizeof n; - newlist = g10_xmalloc ( sizeof *newlist + n + 1 ); + newlist = gcry_xmalloc ( sizeof *newlist + n + 1 ); d = newlist->d; memcpy ( d, p, n ); d += n; *d++ = ST_STOP; @@ -395,7 +395,7 @@ gcry_sexp_nth( const GCRY_SEXP list, int number ) } while ( level ); n = p + 1 - head; - newlist = g10_xmalloc ( sizeof *newlist + n ); + newlist = gcry_xmalloc ( sizeof *newlist + n ); d = newlist->d; memcpy ( d, head, n ); d += n; *d++ = ST_STOP; @@ -587,7 +587,7 @@ gcry_sexp_cdr( const GCRY_SEXP list ) } while ( level ); n = p - head; - newlist = g10_xmalloc ( sizeof *newlist + n + 2 ); + newlist = gcry_xmalloc ( sizeof *newlist + n + 2 ); d = newlist->d; *d++ = ST_OPEN; memcpy ( d, head, n ); d += n; @@ -649,7 +649,7 @@ make_space ( struct make_space_ctx *c, size_t n ) byte *newhead; c->allocated += 2*(n+sizeof(DATALEN)+1); - newsexp = g10_xrealloc ( c->sexp, sizeof *newsexp + c->allocated - 1 ); + newsexp = gcry_xrealloc ( c->sexp, sizeof *newsexp + c->allocated - 1 ); newhead = newsexp->d; c->pos = newhead + used; c->sexp = newsexp; @@ -716,7 +716,7 @@ sexp_sscan( GCRY_SEXP *retsexp, size_t *erroff , * than the provided one. However, we add space for one extra datalen * so that the code which does the ST_CLOSE can use MAKE_SPACE */ c.allocated = length + sizeof(DATALEN); - c.sexp = g10_xmalloc ( sizeof *c.sexp + c.allocated - 1 ); + c.sexp = gcry_xmalloc ( sizeof *c.sexp + c.allocated - 1 ); c.pos = c.sexp->d; for(p=buffer,n=length; n; p++, n-- ) { @@ -857,18 +857,18 @@ sexp_sscan( GCRY_SEXP *retsexp, size_t *erroff , BUG (); MAKE_SPACE (nm); - if ( !g10_is_secure ( c.sexp->d ) + if ( !gcry_is_secure ( c.sexp->d ) && gcry_mpi_get_flag ( m, GCRYMPI_FLAG_SECURE ) ) { /* we have to switch to secure allocation */ GCRY_SEXP newsexp; byte *newhead; - newsexp = g10_xmalloc_secure ( sizeof *newsexp + newsexp = gcry_xmalloc_secure ( sizeof *newsexp + c.allocated - 1 ); newhead = newsexp->d; memcpy ( newhead, c.sexp->d, (c.pos - c.sexp->d) ); c.pos = newhead + ( c.pos - c.sexp->d ); - g10_free ( c.sexp ); + gcry_free ( c.sexp ); c.sexp = newsexp; } diff --git a/src/stdmem.c b/src/stdmem.c index fcbd4b1d..fe459bd5 100644 --- a/src/stdmem.c +++ b/src/stdmem.c @@ -47,7 +47,7 @@ static int use_m_guard = 1; * here have been used. */ void -g10_private_enable_m_guard(void) +_gcry_private_enable_m_guard(void) { use_m_guard = 1; } @@ -57,7 +57,7 @@ g10_private_enable_m_guard(void) * Return NULL if we are out of memory. */ void * -g10_private_malloc( size_t n) +_gcry_private_malloc( size_t n) { if( use_m_guard ) { char *p; @@ -81,12 +81,12 @@ g10_private_malloc( size_t n) * Return NULL if we are out of memory. */ void * -g10_private_malloc_secure( size_t n) +_gcry_private_malloc_secure( size_t n) { if( use_m_guard ) { char *p; - if( !(p = secmem_malloc( n +EXTRA_ALIGN+ 5 )) ) + if( !(p = _gcry_secmem_malloc( n +EXTRA_ALIGN+ 5 )) ) return NULL; ((byte*)p)[EXTRA_ALIGN+0] = n; ((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ; @@ -96,7 +96,7 @@ g10_private_malloc_secure( size_t n) return p+EXTRA_ALIGN+4; } else { - return secmem_malloc( n ); + return _gcry_secmem_malloc( n ); } } @@ -106,32 +106,32 @@ g10_private_malloc_secure( size_t n) * Return NULL if there is not enoug memory. */ void * -g10_private_realloc( void *a, size_t n ) +_gcry_private_realloc( void *a, size_t n ) { if( use_m_guard ) { unsigned char *p = a; void *b; size_t len; - g10_private_check_heap(p); + _gcry_private_check_heap(p); len = p[-4]; len |= p[-3] << 8; len |= p[-2] << 16; if( len >= n ) /* we don't shrink for now */ return a; if( p[-1] == MAGIC_SEC_BYTE ) - b = g10_private_malloc_secure(n); + b = _gcry_private_malloc_secure(n); else - b = g10_private_malloc(n); + b = _gcry_private_malloc(n); if( !b ) return NULL; memcpy(b, a, len ); memset(b+len, 0, n-len ); - g10_private_free( p ); + _gcry_private_free( p ); return b; } - else if( g10_private_is_secure(a) ) { - return secmem_realloc( a, n ); + else if( _gcry_private_is_secure(a) ) { + return _gcry_secmem_realloc( a, n ); } else { return realloc( a, n ); @@ -140,7 +140,7 @@ g10_private_realloc( void *a, size_t n ) void -g10_private_check_heap( const void *a ) +_gcry_private_check_heap( const void *a ) { if( use_m_guard ) { const byte *p = a; @@ -150,12 +150,12 @@ g10_private_check_heap( const void *a ) return; if( !(p[-1] == MAGIC_NOR_BYTE || p[-1] == MAGIC_SEC_BYTE) ) - g10_log_fatal("memory at %p corrupted (underflow=%02x)\n", p, p[-1] ); + _gcry_log_fatal("memory at %p corrupted (underflow=%02x)\n", p, p[-1] ); len = p[-4]; len |= p[-3] << 8; len |= p[-2] << 16; if( p[len] != MAGIC_END_BYTE ) - g10_log_fatal("memory at %p corrupted (overflow=%02x)\n", p, p[-1] ); + _gcry_log_fatal("memory at %p corrupted (overflow=%02x)\n", p, p[-1] ); } } @@ -163,22 +163,22 @@ g10_private_check_heap( const void *a ) * Free a memory block allocated by this opr the secmem module */ void -g10_private_free( void *a ) +_gcry_private_free( void *a ) { byte *p = a; if( !p ) return; if( use_m_guard ) { - g10_private_check_heap(p); - if( g10_private_is_secure(a) ) - secmem_free(p-EXTRA_ALIGN-4); + _gcry_private_check_heap(p); + if( _gcry_private_is_secure(a) ) + _gcry_secmem_free(p-EXTRA_ALIGN-4); else { free(p-EXTRA_ALIGN-4); } } - else if( g10_private_is_secure(a) ) - secmem_free(p); + else if( _gcry_private_is_secure(a) ) + _gcry_secmem_free(p); else free(p); } diff --git a/src/stdmem.h b/src/stdmem.h index 0d260f59..001d178b 100644 --- a/src/stdmem.h +++ b/src/stdmem.h @@ -21,12 +21,12 @@ #ifndef G10_STDMEM_H #define G10_STDMEM_H 1 -void g10_private_enable_m_guard(void); +void _gcry_private_enable_m_guard(void); -void *g10_private_malloc( size_t n); -void *g10_private_malloc_secure( size_t n); -void *g10_private_realloc( void *a, size_t n ); -void g10_private_check_heap( const void *a ); -void g10_private_free( void *a ); +void *_gcry_private_malloc( size_t n); +void *_gcry_private_malloc_secure( size_t n); +void *_gcry_private_realloc( void *a, size_t n ); +void _gcry_private_check_heap( const void *a ); +void _gcry_private_free( void *a ); #endif /* G10_STDMEM_H */ diff --git a/src/wrapper.c b/src/wrapper.c deleted file mode 100644 index c48dfc50..00000000 --- a/src/wrapper.c +++ /dev/null @@ -1,42 +0,0 @@ -/* wrapper.c - wrapper around the internal functions - * Copyright (C) 1999 Free Software Foundation, Inc. - * - * This file is part of Libgcrypt. - * - * Libgcrypt is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Libgcrypt is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA - */ - -#include <config.h> -#include <stdlib.h> - -#include "g10lib.h" - - -void *gcry_malloc( size_t n ) { return g10_malloc( n ); } -void *gcry_calloc( size_t n, size_t m ) { return g10_calloc( n, m ); } -void *gcry_malloc_secure( size_t n ) { return g10_malloc_secure( n );} -void *gcry_calloc_secure( size_t n, size_t m ) - { return g10_calloc_secure( n, m ); } -void *gcry_realloc( void *a, size_t n ) { return g10_realloc( a, n ); } -void *gcry_xmalloc( size_t n ) { return g10_xmalloc( n ); } -void *gcry_xcalloc( size_t n, size_t m ) { return g10_xcalloc( n, m ); } -void *gcry_xmalloc_secure( size_t n ) { return g10_xmalloc_secure( n ); } -void *gcry_xcalloc_secure( size_t n, size_t m ) - { return g10_xcalloc_secure( n, m ); } -void *gcry_xrealloc( void *a, size_t n ) { return g10_xrealloc( a, n ); } -char *gcry_xstrdup( const char * a) { return g10_xstrdup( a); } -void gcry_free( void *p ) { g10_free( p ); } -int gcry_is_secure( const void *p ) { return g10_is_secure( p ); } - |