From cc0fe4e847c7855e90b9af730f1ce092bb35993f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Mon, 27 Oct 2003 13:08:05 +0000 Subject: * configure.ac: Give a hint on where libgpg-error is available. Reformatted long lines. Don't include gcrypt-defs.h. * ac.c (ac_key_identifiers): Made static. * random.c (getfnc_gather_random,getfnc_fast_random_poll): Move prototypes to .. * rand-internal.h: .. here * random.c (getfnc_gather_random): Include rndw32 gatherer. * rndunix.c, rndw32.c, rndegd.c: Include them here. * rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_ prefix. Changed all callers. * rndegd.c (_gcry_rndegd_gather_random): Likewise. (_gcry_rndegd_connect_socket): Likewise. * rndunix.c (_gcry_rndunix_gather_random): Likewise. (waitpid): Made static. * rndw32.c: Removed the old and unused winseed.dll cruft. (_gcry_rndw32_gather_random_fast): Renamed from gather_random_fast. (_gcry_rndw32_gather_random): Renamed from gather_random. Note, that the changes 2003-04-08 somehow got lost. * sha512.c (sha512_init, sha384_init): Made static. * cipher.c (do_ctr_decrypt): Removed "return" from this void function. * gcrypt.h (gcry_pk_testkey): Doc fix. * libgcrypt.def: Manually wrote this file. * build-def: This file should not be used anymore. --- ChangeLog | 6 + Makefile.am | 2 +- TODO | 4 +- cipher/ChangeLog | 29 +++++ cipher/ac.c | 2 +- cipher/arcfour.c | 2 +- cipher/blowfish.c | 2 +- cipher/cast5.c | 2 +- cipher/cipher.c | 32 ++--- cipher/crc.c | 6 +- cipher/des.c | 4 +- cipher/dsa.c | 2 +- cipher/elgamal.c | 2 +- cipher/md.c | 22 ++-- cipher/md4.c | 2 +- cipher/md5.c | 2 +- cipher/pubkey.c | 6 +- cipher/rand-internal.h | 14 +++ cipher/random.c | 27 ++-- cipher/rijndael.c | 6 +- cipher/rmd160.c | 2 +- cipher/rndegd.c | 10 +- cipher/rndlinux.c | 10 +- cipher/rndunix.c | 9 +- cipher/rndw32.c | 231 ++-------------------------------- cipher/rsa.c | 2 +- cipher/serpent.c | 6 +- cipher/sha1.c | 2 +- cipher/sha256.c | 2 +- cipher/sha512.c | 8 +- cipher/tiger.c | 2 +- cipher/twofish.c | 4 +- configure.ac | 113 +++++++++-------- doc/gcrypt.texi | 1 + src/ChangeLog | 6 +- src/cipher.h | 54 ++++---- src/gcrypt.h | 2 +- w32-dll/ChangeLog | 5 + w32-dll/build-def | 5 +- w32-dll/libgcrypt.def | 329 ++++++++++++++++++++++++++++++------------------- 40 files changed, 462 insertions(+), 515 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2c1fad88..073aab4e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2003-10-27 Werner Koch + + * configure.ac: Give a hint on where libgpg-error is available. + Reformatted long lines. Don't include gcrypt-defs.h. + + 2003-10-24 Moritz Schulte * configure.ac: Check for socklen_t. diff --git a/Makefile.am b/Makefile.am index 663bbb56..2043930d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -21,7 +21,7 @@ DIST_SUBDIRS = mpi cipher src doc tests w32-dll SUBDIRS = mpi cipher src doc tests EXTRA_DIST = README-alpha BUGS autogen.sh COPYING.DOC README.apichanges -DISTCLEANFILES = gcrypt-defs.h +DISTCLEANFILES = # Add all the files listed in "distfiles" files to the distribution, diff --git a/TODO b/TODO index b1963354..342d2dbd 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,6 @@ -* Run w32-dll/build-def when we introduce a new fucntion. +* Remove _gcry_generate_elg_prime from .vers for 1.2 -* add more tests. Even basic is very minimal. +* Add more tests. Even basic is very minimal. * udiv-qrnbd.o should get build as *.lo [HPUX] diff --git a/cipher/ChangeLog b/cipher/ChangeLog index d8694b1d..7dbc3a5d 100644 --- a/cipher/ChangeLog +++ b/cipher/ChangeLog @@ -1,3 +1,32 @@ +2003-10-27 Werner Koch + + Prefixed all (pubkey,digest,cipher}_spec_* globale varaibles with + _gcry_. + + * ac.c (ac_key_identifiers): Made static. + + * random.c (getfnc_gather_random,getfnc_fast_random_poll): Move + prototypes to .. + * rand-internal.h: .. here + * random.c (getfnc_gather_random): Include rndw32 gatherer. + * rndunix.c, rndw32.c, rndegd.c: Include them here. + * rndlinux.c (_gcry_rndlinux_gather_random): Prepend the _gcry_ + prefix. Changed all callers. + * rndegd.c (_gcry_rndegd_gather_random): Likewise. + (_gcry_rndegd_connect_socket): Likewise. + * rndunix.c (_gcry_rndunix_gather_random): Likewise. + (waitpid): Made static. + * rndw32.c: Removed the old and unused winseed.dll cruft. + (_gcry_rndw32_gather_random_fast): Renamed from + gather_random_fast. + (_gcry_rndw32_gather_random): Renamed from gather_random. Note, + that the changes 2003-04-08 somehow got lost. + + * sha512.c (sha512_init, sha384_init): Made static. + + * cipher.c (do_ctr_decrypt): Removed "return" from this void + function. + 2003-10-24 Moritz Schulte * serpent.c: Fix an issue on big-endian systems. diff --git a/cipher/ac.c b/cipher/ac.c index ffc80daf..a7239584 100644 --- a/cipher/ac.c +++ b/cipher/ac.c @@ -49,7 +49,7 @@ struct number_string /* The positions in this list correspond to the values contained in the gcry_ac_key_type_t enumeration list. */ -const char *ac_key_identifiers[] = +static const char *ac_key_identifiers[] = { "private-key", "public-key", diff --git a/cipher/arcfour.c b/cipher/arcfour.c index 57c439c4..c41ff0d5 100644 --- a/cipher/arcfour.c +++ b/cipher/arcfour.c @@ -147,7 +147,7 @@ selftest(void) -gcry_cipher_spec_t cipher_spec_arcfour = +gcry_cipher_spec_t _gcry_cipher_spec_arcfour = { "ARCFOUR", NULL, NULL, 1, 128, sizeof (ARCFOUR_context), arcfour_setkey, NULL, NULL, encrypt_stream, encrypt_stream, diff --git a/cipher/blowfish.c b/cipher/blowfish.c index 84d8fd6b..11b55411 100644 --- a/cipher/blowfish.c +++ b/cipher/blowfish.c @@ -585,7 +585,7 @@ bf_setkey (void *context, const byte *key, unsigned keylen) -gcry_cipher_spec_t cipher_spec_blowfish = +gcry_cipher_spec_t _gcry_cipher_spec_blowfish = { "BLOWFISH", NULL, NULL, BLOWFISH_BLOCKSIZE, 128, sizeof (BLOWFISH_context), diff --git a/cipher/cast5.c b/cipher/cast5.c index 01840891..5dad9193 100644 --- a/cipher/cast5.c +++ b/cipher/cast5.c @@ -614,7 +614,7 @@ cast_setkey (void *context, const byte *key, unsigned keylen ) } -gcry_cipher_spec_t cipher_spec_cast5 = +gcry_cipher_spec_t _gcry_cipher_spec_cast5 = { "CAST5", NULL, NULL, CAST5_BLOCKSIZE, 128, sizeof (CAST5_context), cast_setkey, encrypt_block, decrypt_block, diff --git a/cipher/cipher.c b/cipher/cipher.c index 73544d23..a1d8e5ef 100644 --- a/cipher/cipher.c +++ b/cipher/cipher.c @@ -43,31 +43,31 @@ static struct cipher_table_entry } cipher_table[] = { #if USE_BLOWFISH - { &cipher_spec_blowfish, GCRY_CIPHER_BLOWFISH }, + { &_gcry_cipher_spec_blowfish, GCRY_CIPHER_BLOWFISH }, #endif #if USE_DES - { &cipher_spec_des, GCRY_CIPHER_DES }, - { &cipher_spec_tripledes, GCRY_CIPHER_3DES }, + { &_gcry_cipher_spec_des, GCRY_CIPHER_DES }, + { &_gcry_cipher_spec_tripledes, GCRY_CIPHER_3DES }, #endif #if USE_ARCFOUR - { &cipher_spec_arcfour, GCRY_CIPHER_ARCFOUR }, + { &_gcry_cipher_spec_arcfour, GCRY_CIPHER_ARCFOUR }, #endif #if USE_CAST5 - { &cipher_spec_cast5, GCRY_CIPHER_CAST5 }, + { &_gcry_cipher_spec_cast5, GCRY_CIPHER_CAST5 }, #endif #if USE_AES - { &cipher_spec_aes, GCRY_CIPHER_AES }, - { &cipher_spec_aes192, GCRY_CIPHER_AES192 }, - { &cipher_spec_aes256, GCRY_CIPHER_AES256 }, + { &_gcry_cipher_spec_aes, GCRY_CIPHER_AES }, + { &_gcry_cipher_spec_aes192, GCRY_CIPHER_AES192 }, + { &_gcry_cipher_spec_aes256, GCRY_CIPHER_AES256 }, #endif #if USE_TWOFISH - { &cipher_spec_twofish, GCRY_CIPHER_TWOFISH }, - { &cipher_spec_twofish128, GCRY_CIPHER_TWOFISH128 }, + { &_gcry_cipher_spec_twofish, GCRY_CIPHER_TWOFISH }, + { &_gcry_cipher_spec_twofish128, GCRY_CIPHER_TWOFISH128 }, #endif #if USE_SERPENT - { &cipher_spec_serpent128, GCRY_CIPHER_SERPENT128 }, - { &cipher_spec_serpent192, GCRY_CIPHER_SERPENT192 }, - { &cipher_spec_serpent256, GCRY_CIPHER_SERPENT256 }, + { &_gcry_cipher_spec_serpent128, GCRY_CIPHER_SERPENT128 }, + { &_gcry_cipher_spec_serpent192, GCRY_CIPHER_SERPENT192 }, + { &_gcry_cipher_spec_serpent256, GCRY_CIPHER_SERPENT256 }, #endif { NULL }, }; @@ -772,7 +772,7 @@ do_cbc_decrypt( gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned nb * to save the original ciphertext block. We use lastiv * for this here because it is not used otherwise */ memcpy(c->lastiv, inbuf, blocksize ); - (*c->cipher->decrypt)( &c->context.c, outbuf, (char*)/*argggg*/inbuf ); + (*c->cipher->decrypt)( &c->context.c, outbuf, inbuf ); for(ivp=c->iv,i=0; i < blocksize; i++ ) outbuf[i] ^= *ivp++; memcpy(c->iv, c->lastiv, blocksize ); @@ -791,7 +791,7 @@ do_cbc_decrypt( gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned nb memcpy(c->lastiv, c->iv, blocksize ); /* save Cn-2 */ memcpy(c->iv, inbuf + blocksize, restbytes ); /* save Cn */ - (*c->cipher->decrypt)( &c->context.c, outbuf, (char*)/*argggg*/inbuf ); + (*c->cipher->decrypt)( &c->context.c, outbuf, inbuf ); for(ivp=c->iv,i=0; i < restbytes; i++ ) outbuf[i] ^= *ivp++; @@ -939,7 +939,7 @@ do_ctr_encrypt( gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned nb static void do_ctr_decrypt( gcry_cipher_hd_t c, byte *outbuf, const byte *inbuf, unsigned nbytes ) { - return do_ctr_encrypt (c, outbuf, inbuf, nbytes); + do_ctr_encrypt (c, outbuf, inbuf, nbytes); } diff --git a/cipher/crc.c b/cipher/crc.c index 8769a8da..3d16a107 100644 --- a/cipher/crc.c +++ b/cipher/crc.c @@ -271,14 +271,14 @@ crc24rfc2440_final (void *context) ctx->buf[2] = (ctx->CRC ) & 0xFF; } -gcry_md_spec_t digest_spec_crc32 = +gcry_md_spec_t _gcry_digest_spec_crc32 = { "CRC32", NULL, 0, NULL, 4, crc32_init, crc32_write, crc32_final, crc32_read, sizeof (CRC_CONTEXT) }; -gcry_md_spec_t digest_spec_crc32_rfc1510 = +gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510 = { "CRC32RFC1510", NULL, 0, NULL, 4, crc32rfc1510_init, crc32_write, @@ -286,7 +286,7 @@ gcry_md_spec_t digest_spec_crc32_rfc1510 = sizeof (CRC_CONTEXT) }; -gcry_md_spec_t digest_spec_crc24_rfc2440 = +gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440 = { "CRC24RFC2440", NULL, 0, NULL, 3, crc24rfc2440_init, crc24rfc2440_write, diff --git a/cipher/des.c b/cipher/des.c index c408d851..7e3d0841 100644 --- a/cipher/des.c +++ b/cipher/des.c @@ -1066,7 +1066,7 @@ do_des_decrypt( void *context, byte *outbuf, const byte *inbuf ) _gcry_burn_stack (32); } -gcry_cipher_spec_t cipher_spec_des = +gcry_cipher_spec_t _gcry_cipher_spec_des = { "DES", NULL, NULL, 8, 64, sizeof (struct _des_ctx), do_des_setkey, do_des_encrypt, do_des_decrypt @@ -1080,7 +1080,7 @@ static gcry_cipher_oid_spec_t oids_tripledes[] = { NULL } }; -gcry_cipher_spec_t cipher_spec_tripledes = +gcry_cipher_spec_t _gcry_cipher_spec_tripledes = { "3DES", NULL, oids_tripledes, 8, 192, sizeof (struct _tripledes_ctx), do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt diff --git a/cipher/dsa.c b/cipher/dsa.c index 62fd082a..a75413b1 100644 --- a/cipher/dsa.c +++ b/cipher/dsa.c @@ -456,7 +456,7 @@ static char *dsa_names[] = NULL, }; -gcry_pk_spec_t pubkey_spec_dsa = +gcry_pk_spec_t _gcry_pubkey_spec_dsa = { "DSA", dsa_names, "pqgy", "pqgyx", "", "rs", "pqgy", diff --git a/cipher/elgamal.c b/cipher/elgamal.c index 04c37330..51e5c559 100644 --- a/cipher/elgamal.c +++ b/cipher/elgamal.c @@ -641,7 +641,7 @@ static char *elg_names[] = }; -gcry_pk_spec_t pubkey_spec_elg = +gcry_pk_spec_t _gcry_pubkey_spec_elg = { "ELG", elg_names, "pgy", "pgyx", "ab", "rs", "pgy", diff --git a/cipher/md.c b/cipher/md.c index 0958b079..34914856 100644 --- a/cipher/md.c +++ b/cipher/md.c @@ -38,31 +38,31 @@ static struct digest_table_entry } digest_table[] = { #if USE_CRC - { &digest_spec_crc32, GCRY_MD_CRC32 }, - { &digest_spec_crc32_rfc1510, GCRY_MD_CRC32_RFC1510 }, - { &digest_spec_crc24_rfc2440, GCRY_MD_CRC24_RFC2440 }, + { &_gcry_digest_spec_crc32, GCRY_MD_CRC32 }, + { &_gcry_digest_spec_crc32_rfc1510, GCRY_MD_CRC32_RFC1510 }, + { &_gcry_digest_spec_crc24_rfc2440, GCRY_MD_CRC24_RFC2440 }, #endif #if USE_MD4 - { &digest_spec_md4, GCRY_MD_MD4 }, + { &_gcry_digest_spec_md4, GCRY_MD_MD4 }, #endif #if USE_MD5 - { &digest_spec_md5, GCRY_MD_MD5 }, + { &_gcry_digest_spec_md5, GCRY_MD_MD5 }, #endif #if USE_RMD160 - { &digest_spec_rmd160, GCRY_MD_RMD160 }, + { &_gcry_digest_spec_rmd160, GCRY_MD_RMD160 }, #endif #if USE_SHA1 - { &digest_spec_sha1, GCRY_MD_SHA1 }, + { &_gcry_digest_spec_sha1, GCRY_MD_SHA1 }, #endif #if USE_SHA256 - { &digest_spec_sha256, GCRY_MD_SHA256 }, + { &_gcry_digest_spec_sha256, GCRY_MD_SHA256 }, #endif #if USE_SHA512 - { &digest_spec_sha512, GCRY_MD_SHA512 }, - { &digest_spec_sha384, GCRY_MD_SHA384 }, + { &_gcry_digest_spec_sha512, GCRY_MD_SHA512 }, + { &_gcry_digest_spec_sha384, GCRY_MD_SHA384 }, #endif #if USE_TIGER - { &digest_spec_tiger, GCRY_MD_TIGER }, + { &_gcry_digest_spec_tiger, GCRY_MD_TIGER }, #endif { NULL }, }; diff --git a/cipher/md4.c b/cipher/md4.c index 4a3edd76..fd51d034 100644 --- a/cipher/md4.c +++ b/cipher/md4.c @@ -310,7 +310,7 @@ static gcry_md_oid_spec_t oid_spec_md4[] = { NULL }, }; -gcry_md_spec_t digest_spec_md4 = +gcry_md_spec_t _gcry_digest_spec_md4 = { "MD4", asn, DIM (asn), oid_spec_md4,16, md4_init, md4_write, md4_final, md4_read, diff --git a/cipher/md5.c b/cipher/md5.c index 808cfba0..ecbf1725 100644 --- a/cipher/md5.c +++ b/cipher/md5.c @@ -337,7 +337,7 @@ static gcry_md_oid_spec_t oid_spec_md5[] = { NULL }, }; -gcry_md_spec_t digest_spec_md5 = +gcry_md_spec_t _gcry_digest_spec_md5 = { "MD5", asn, DIM (asn), oid_spec_md5, 16, md5_init, md5_write, md5_final, md5_read, diff --git a/cipher/pubkey.c b/cipher/pubkey.c index de7c810b..da54c4ae 100644 --- a/cipher/pubkey.c +++ b/cipher/pubkey.c @@ -44,13 +44,13 @@ static struct pubkey_table_entry } pubkey_table[] = { #if USE_RSA - { &pubkey_spec_rsa, GCRY_PK_RSA }, + { &_gcry_pubkey_spec_rsa, GCRY_PK_RSA }, #endif #if USE_ELGAMAL - { &pubkey_spec_elg, GCRY_PK_ELG }, + { &_gcry_pubkey_spec_elg, GCRY_PK_ELG }, #endif #if USE_DSA - { &pubkey_spec_dsa, GCRY_PK_DSA }, + { &_gcry_pubkey_spec_dsa, GCRY_PK_DSA }, #endif { NULL }, }; diff --git a/cipher/rand-internal.h b/cipher/rand-internal.h index 8c9abb61..bf1b2af0 100644 --- a/cipher/rand-internal.h +++ b/cipher/rand-internal.h @@ -24,4 +24,18 @@ void _gcry_random_progress (const char *what, int printchar, int current, int total); +int _gcry_rndlinux_gather_random (void (*add) (const void *, size_t, int), + int requester, size_t length, int level); +int _gcry_rndunix_gather_random (void (*add) (const void *, size_t, int), + int requester, size_t length, int level); +int _gcry_rndegd_gather_random (void (*add) (const void *, size_t, int), + int requester, size_t length, int level); +int _gcry_rndegd_connect_socket (int nofail); +int _gcry_rndw32_gather_random (void (*add) (const void *, size_t, int), + int requester, size_t length, int level); +int _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, int), + int requester ); + + + #endif /*G10_RAND_INTERNAL_H*/ diff --git a/cipher/random.c b/cipher/random.c index 953686d2..c86ad9bd 100644 --- a/cipher/random.c +++ b/cipher/random.c @@ -741,16 +741,6 @@ static int (* getfnc_gather_random (void))(void (*)(const void*, size_t, int), int, size_t, int) { - int rndlinux_gather_random (void (*add) (const void *, size_t, int), - int requester, size_t length, int level); - int rndunix_gather_random (void (*add) (const void *, size_t, int), - int requester, size_t length, int level); - int rndegd_gather_random (void (*add) (const void *, size_t, int), - int requester, size_t length, int level); - int rndegd_connect_socket (int nofail); - int rndw32_gather_random (void (*add) (const void *, size_t, int), - int requester, size_t length, int level); - static int (*fnc)(void (*)(const void*, size_t, int), int, size_t, int); if (fnc) @@ -760,21 +750,26 @@ getfnc_gather_random (void))(void (*)(const void*, size_t, int), int, if ( !access (NAME_OF_DEV_RANDOM, R_OK) && !access (NAME_OF_DEV_URANDOM, R_OK)) { - fnc = rndlinux_gather_random; + fnc = _gcry_rndlinux_gather_random; return fnc; } #endif #if USE_RNDEGD - if ( rndegd_connect_socket (1) != -1 ) + if ( _gcry_rndegd_connect_socket (1) != -1 ) { - fnc = rndegd_gather_random; + fnc = _gcry_rndegd_gather_random; return fnc; } #endif #if USE_RNDUNIX - fnc = rndunix_gather_random; + fnc = _gcry_rndunix_gather_random; + return fnc; +#endif + +#if USE_RNDW32 + fnc = _gcry_rndw32_gather_random; return fnc; #endif @@ -787,9 +782,7 @@ static void (* getfnc_fast_random_poll (void))( void (*)(const void*, size_t, int), int) { #if USE_RNDW32 - int rndw32_gather_random_fast (void (*add) (const void *, size_t, int), - int requester); - return rndw32_gather_random_fast; + return _gcry_rndw32_gather_random_fast; #endif return NULL; } diff --git a/cipher/rijndael.c b/cipher/rijndael.c index b2b50d89..d9c60fd0 100644 --- a/cipher/rijndael.c +++ b/cipher/rijndael.c @@ -2146,7 +2146,7 @@ static gcry_cipher_oid_spec_t rijndael_oids[] = { NULL } }; -gcry_cipher_spec_t cipher_spec_aes = +gcry_cipher_spec_t _gcry_cipher_spec_aes = { "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context), rijndael_setkey, rijndael_encrypt, rijndael_decrypt, @@ -2167,7 +2167,7 @@ static gcry_cipher_oid_spec_t rijndael192_oids[] = { NULL } }; -gcry_cipher_spec_t cipher_spec_aes192 = +gcry_cipher_spec_t _gcry_cipher_spec_aes192 = { "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context), rijndael_setkey, rijndael_encrypt, rijndael_decrypt, @@ -2188,7 +2188,7 @@ static gcry_cipher_oid_spec_t rijndael256_oids[] = { NULL } }; -gcry_cipher_spec_t cipher_spec_aes256 = +gcry_cipher_spec_t _gcry_cipher_spec_aes256 = { "AES256", rijndael256_names, rijndael256_oids, 16, 256, sizeof (RIJNDAEL_context), rijndael_setkey, rijndael_encrypt, rijndael_decrypt, diff --git a/cipher/rmd160.c b/cipher/rmd160.c index 5b3ea2dd..e32917f8 100644 --- a/cipher/rmd160.c +++ b/cipher/rmd160.c @@ -550,7 +550,7 @@ static gcry_md_oid_spec_t oid_spec_rmd160[] = { NULL }, }; -gcry_md_spec_t digest_spec_rmd160 = +gcry_md_spec_t _gcry_digest_spec_rmd160 = { "RIPEMD160", asn, DIM (asn), oid_spec_rmd160, 20, _gcry_rmd160_init, rmd160_write, rmd160_final, rmd160_read, diff --git a/cipher/rndegd.c b/cipher/rndegd.c index e3f534e2..098ff3e1 100644 --- a/cipher/rndegd.c +++ b/cipher/rndegd.c @@ -33,6 +33,7 @@ #include "types.h" #include "g10lib.h" #include "cipher.h" +#include "rand-internal.h" #ifndef offsetof #define offsetof(type, member) ((size_t) &((type *)0)->member) @@ -117,7 +118,7 @@ do_read( int fd, void *buf, size_t nbytes ) error. With NOFAIL set to true, silently fail and return the error, otherwise print an error message and die. */ int -rndegd_connect_socket (int nofail) +_gcry_rndegd_connect_socket (int nofail) { int fd; const char *bname = NULL; @@ -175,8 +176,9 @@ rndegd_connect_socket (int nofail) * to the pool. So this is just a dummy for EGD. */ int -rndegd_gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ) +_gcry_rndegd_gather_random (void (*add)(const void*, size_t, int), + int requester, + size_t length, int level ) { int fd = egd_socket; int n; @@ -191,7 +193,7 @@ rndegd_gather_random( void (*add)(const void*, size_t, int), int requester, restart: if (fd == -1 || do_restart) - fd = rndegd_connect_socket (0); + fd = _gcry_rndegd_connect_socket (0); do_restart = 0; diff --git a/cipher/rndlinux.c b/cipher/rndlinux.c index 3cfcb453..05a8e039 100644 --- a/cipher/rndlinux.c +++ b/cipher/rndlinux.c @@ -45,8 +45,9 @@ #include "rand-internal.h" static int open_device( const char *name, int minor ); -int rndlinux_gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ); +int _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, int), + int requester, + size_t length, int level ); #if 0 #ifdef HAVE_DEV_RANDOM_IOCTL @@ -84,8 +85,9 @@ open_device( const char *name, int minor ) int -rndlinux_gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ) +_gcry_rndlinux_gather_random (void (*add)(const void*, size_t, int), + int requester, + size_t length, int level ) { static int fd_urandom = -1; static int fd_random = -1; diff --git a/cipher/rndunix.c b/cipher/rndunix.c index fa37d0aa..c95e2079 100644 --- a/cipher/rndunix.c +++ b/cipher/rndunix.c @@ -100,6 +100,7 @@ #include "types.h" /* for byte and u32 typedefs */ #include "g10lib.h" +#include "rand-internal.h" #ifndef EAGAIN #define EAGAIN EWOULDBLOCK @@ -320,7 +321,7 @@ typedef struct { } GATHER_MSG; #ifndef HAVE_WAITPID -pid_t +static pid_t waitpid(pid_t pid, int *statptr, int options) { #ifdef HAVE_WAIT4 @@ -358,7 +359,6 @@ waitpid(pid_t pid, int *statptr, int options) static FILE * my_popen(struct RI *entry) { - int pipedes[2]; FILE *stream; @@ -768,8 +768,9 @@ read_a_msg( int fd, GATHER_MSG *msg ) * to the pool. So this is just a dummy for this gatherer. */ int -rndunix_gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ) +_gcry_rndunix_gather_random (void (*add)(const void*, size_t, int), + int requester, + size_t length, int level ) { static pid_t gatherer_pid = 0; static int pipedes[2]; diff --git a/cipher/rndw32.c b/cipher/rndw32.c index 21d0af6a..3db42e46 100644 --- a/cipher/rndw32.c +++ b/cipher/rndw32.c @@ -57,220 +57,11 @@ #include "types.h" #include "g10lib.h" +#include "rand-internal.h" -/* We do not use the netropy DLL anymore because a standalone program is - * easier to maintain and */ -/*#define USE_ENTROPY_DLL*/ static int debug_me; -#ifdef USE_ENTROPY_DLL - -#define WIN32_SLOW_SEEDER 0 -#define WIN32_FAST_SEEDER 1 - -#define PCP_SUCCESS 0 -#define PCP_NULL_POINTER 1 -#define PCP_SEEDER_FAILED 2 -#define PCP_SEEDER_NO_MEM 3 -#define PCP_SEEDER_TOO_SMALL 4 -#define PCP_DLL_LOAD_FAILED 5 -#define PCP_UNKNOWN_PLATFORM 6 -#define PCP_ERROR_VERSION 7 -#define PCP_DLL_FUNC 8 -#define PCP_UNKNOWN_SEEDER_TYPE 9 - - -/**************** - * We sometimes get a SEEDER_TOO_SMALL error, in which case we increment - * the internal buffer by SEEDER_INC_CHUNK until we reach MAX_SEEDER_SIZE - * MAX_SEEDER_SIZE is used as an arbitrary limit to protect against - * bugs in Winseed. - */ -#define MAX_SEEDER_SIZE 500000 -#define SEEDER_INC_CHUNK 50000 - - -typedef void *WIN32_SEEDER; - -static WIN32_SEEDER (WINAPI *create_instance)( byte type, unsigned int *reason); -static void (WINAPI *delete_instance)( WIN32_SEEDER that ); -static unsigned int (WINAPI *get_internal_seed_size)( WIN32_SEEDER that ); -static void (WINAPI *set_internal_seed_size)( WIN32_SEEDER that, - unsigned int new_size); -static unsigned int (WINAPI *get_expected_seed_size)( WIN32_SEEDER that); -static unsigned int (WINAPI *get_seed)( WIN32_SEEDER that, byte *buffer, - unsigned int *desired_length); - -static WIN32_SEEDER slow_seeder, fast_seeder; -static byte *entropy_buffer; -static size_t entropy_buffer_size; - -/**************** - * Load and initialize the winseed DLL - * NOTE: winseed is not part of the GnuPG distribution. It should be available - * at the GNU crypto FTP server site. - * We do not load the DLL on demand to have a better control over the - * location of the library. - */ -static void -load_and_init_winseed( void ) -{ - HANDLE hInstance; - void *addr; - unsigned int reason = 0; - unsigned int n1, n2; - const char *dllname; - - dllname = read_w32_registry_string( "HKEY_LOCAL_MACHINE", - "Software\\GNU\\GnuPG", - "EntropyDLL" ); - if( !dllname ) - dllname = "c:/gnupg/entropy.dll"; - - hInstance = LoadLibrary( dllname ); - if( !hInstance ) - goto failure; - if( !(addr = GetProcAddress( hInstance, "WS_create_instance" )) ) - goto failure; - create_instance = addr; - if( !(addr = GetProcAddress( hInstance, "WS_delete_instance" )) ) - goto failure; - delete_instance = addr; - if( !(addr = GetProcAddress( hInstance, "WS_get_internal_seed_size" )) ) - goto failure; - get_internal_seed_size = addr; - if( !(addr = GetProcAddress( hInstance, "WS_set_internal_seed_size" )) ) - goto failure; - set_internal_seed_size = addr; - if( !(addr = GetProcAddress( hInstance, "WS_get_expected_seed_size" )) ) - goto failure; - get_expected_seed_size = addr; - if( !(addr = GetProcAddress( hInstance, "WS_get_seed" )) ) - goto failure; - get_seed = addr; - - /* we have all the functions - init the system */ - slow_seeder = create_instance( WIN32_SLOW_SEEDER, &reason); - if( !slow_seeder ) { - log_fatal("error creating winseed slow seeder: rc=%u\n", reason ); - goto failure; - } - fast_seeder = create_instance( WIN32_FAST_SEEDER, &reason); - if( !fast_seeder ) { - log_fatal("error creating winseed fast seeder: rc=%u\n", reason ); - goto failure; - } - n1 = get_internal_seed_size( slow_seeder ); - /*log_info("slow buffer size=%u\n", n1);*/ - n2 = get_internal_seed_size( fast_seeder ); - /*log_info("fast buffer size=%u\n", n2);*/ - - entropy_buffer_size = n1 > n2? n1: n2; - entropy_buffer = gcry_xmalloc( entropy_buffer_size ); - /*log_info("using a buffer of size=%u\n", entropy_buffer_size );*/ - - return; - - failure: - log_fatal("error loading winseed DLL `%s'\n", dllname ); -} - - - - - -/* Note: we always use the highest level. - * TO boost the performance we may want to add some - * additional code for level 1 - */ -int -rndw32_gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ) -{ - unsigned int result; - unsigned int nbytes; - - if( !level ) - return 0; - - if( !slow_seeder ) - load_and_init_winseed(); - - /* Our estimation on how much entropy we should use is very vague. - * Winseed delivers some amount of entropy on each slow poll and - * we add it to our random pool. Depending on the required quality - * level we adjust the requested length so that for higher quality - * we make sure to add more entropy to our pool. However, as we don't - * like to waste any entropy collected by winseed, we always add - * at least everything we got from winseed. - */ - if( level > 1 ) - length *= 100; - else if( level > 0 ) - length *= 10; - - for(;;) { - nbytes = entropy_buffer_size; - result = get_seed( slow_seeder, entropy_buffer, &nbytes); - if( result == PCP_SEEDER_TOO_SMALL ) { - unsigned int n1 = get_internal_seed_size( slow_seeder ); - - if( n1 > MAX_SEEDER_SIZE ) { - log_fatal("rndw32: internal seeder problem (size=%u)\n", - n1); - return -1; /* actually never reached */ - } - n1 += SEEDER_INC_CHUNK; - set_internal_seed_size( slow_seeder, n1 ); - if( n1 > entropy_buffer_size ) { - entropy_buffer_size = n1; - entropy_buffer = gcry_realloc( entropy_buffer, - entropy_buffer_size ); - } - continue; - } - - - if( result ) { - log_fatal("rndw32: get_seed(slow) failed: rc=%u\n", result); - return -1; /* actually never reached */ - } - /*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 ) - return 0; /* okay */ - length -= nbytes; - } -} - -int -rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester ) -{ - unsigned int result; - unsigned int nbytes; - - if( !fast_seeder ) - load_and_init_winseed(); - - /* winseed delivers a constant ammount of entropy for a fast - * poll. We can simply use this and add it to the pool; no need - * a loop like it is used in the slow poll */ - nbytes = entropy_buffer_size; - result = get_seed( fast_seeder, entropy_buffer, &nbytes); - if( result ) { - log_fatal("rndw32: get_seed(fast) failed: rc=%u\n", result); - return -1; /* actually never reached */ - } - /*log_info("rndw32: fast poll got %u\n", (unsigned int)nbytes );*/ - (*add)( entropy_buffer, nbytes, requester ); - return 0; -} - -#else /* !USE_ENTROPY_DLL */ -/* This is the new code which does not require the entropy.dll */ - /* * Definitions which are missing from the current GNU Windows32Api */ @@ -291,6 +82,10 @@ rndw32_gather_random_fast( void (*add)(const void*, size_t, int), int requester #define VER_PLATFORM_WIN32_WINDOWS 1 #endif +/* This used to be (6*8+5*4+8*2), but Peter Gutmann figured a larger + value in a newer release. So we use a far larger value. */ +#define SIZEOF_DISK_PERFORMANCE_STRUCT 256 + typedef struct { DWORD dwSize; @@ -431,7 +226,7 @@ slow_gatherer_windows95( void (*add)(const void*, size_t, int), int requester ) || !pThread32First || !pThread32Next || !pHeap32ListFirst || !pHeap32ListNext || !pHeap32First || !pHeap32Next ) { - log_fatal ( "rndw32: failed to get a toolhep function\n" ); + log_fatal ( "rndw32: failed to get a toolhelp function\n" ); } } @@ -701,9 +496,10 @@ slow_gatherer_windowsNT( void (*add)(const void*, size_t, int), int requester ) } -static int -gather_random( void (*add)(const void*, size_t, int), int requester, - size_t length, int level ) +int +_gcry_rndw32_gather_random( void (*add)(const void*, size_t, int), + int requester, + size_t length, int level ) { static int is_initialized; static int is_windowsNT, has_toolhelp; @@ -752,8 +548,9 @@ gather_random( void (*add)(const void*, size_t, int), int requester, } -static int -gather_random_fast( void (*add)(const void*, size_t, int), int requester ) +int +_gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, int), + int requester ) { static int addedFixedItems = 0; @@ -883,5 +680,3 @@ gather_random_fast( void (*add)(const void*, size_t, int), int requester ) return 0; } - -#endif /* !USE_ENTROPY_DLL */ diff --git a/cipher/rsa.c b/cipher/rsa.c index d62ae04f..a2200e33 100644 --- a/cipher/rsa.c +++ b/cipher/rsa.c @@ -611,7 +611,7 @@ static char *rsa_names[] = NULL, }; -gcry_pk_spec_t pubkey_spec_rsa = +gcry_pk_spec_t _gcry_pubkey_spec_rsa = { "RSA", rsa_names, "ne", "nedpqu", "a", "s", "n", diff --git a/cipher/serpent.c b/cipher/serpent.c index babca2fd..afb5af9f 100644 --- a/cipher/serpent.c +++ b/cipher/serpent.c @@ -956,21 +956,21 @@ static const char *cipher_spec_serpent128_aliases[] = NULL, }; -gcry_cipher_spec_t cipher_spec_serpent128 = +gcry_cipher_spec_t _gcry_cipher_spec_serpent128 = { "SERPENT128", cipher_spec_serpent128_aliases, NULL, 16, 128, sizeof (serpent_context_t), serpent_setkey, serpent_encrypt, serpent_decrypt, }; -gcry_cipher_spec_t cipher_spec_serpent192 = +gcry_cipher_spec_t _gcry_cipher_spec_serpent192 = { "SERPENT192", NULL, NULL, 16, 192, sizeof (serpent_context_t), serpent_setkey, serpent_encrypt, serpent_decrypt, }; -gcry_cipher_spec_t cipher_spec_serpent256 = +gcry_cipher_spec_t _gcry_cipher_spec_serpent256 = { "SERPENT256", NULL, NULL, 16, 256, sizeof (serpent_context_t), diff --git a/cipher/sha1.c b/cipher/sha1.c index ae584864..eb8a616a 100644 --- a/cipher/sha1.c +++ b/cipher/sha1.c @@ -332,7 +332,7 @@ static gcry_md_oid_spec_t oid_spec_sha1[] = { NULL }, }; -gcry_md_spec_t digest_spec_sha1 = +gcry_md_spec_t _gcry_digest_spec_sha1 = { "SHA1", asn, DIM (asn), oid_spec_sha1, 20, sha1_init, sha1_write, sha1_final, sha1_read, diff --git a/cipher/sha256.c b/cipher/sha256.c index b1a0d87e..657c8820 100644 --- a/cipher/sha256.c +++ b/cipher/sha256.c @@ -300,7 +300,7 @@ static gcry_md_oid_spec_t oid_spec_sha256[] = { NULL }, }; -gcry_md_spec_t digest_spec_sha256 = +gcry_md_spec_t _gcry_digest_spec_sha256 = { "SHA256", asn, DIM (asn), oid_spec_sha256, 32, sha256_init, sha256_write, sha256_final, sha256_read, diff --git a/cipher/sha512.c b/cipher/sha512.c index cdb6c392..cc33b805 100644 --- a/cipher/sha512.c +++ b/cipher/sha512.c @@ -63,7 +63,7 @@ typedef struct int count; } SHA512_CONTEXT; -void +static void sha512_init (void *context) { SHA512_CONTEXT *hd = (SHA512_CONTEXT *) context; @@ -81,7 +81,7 @@ sha512_init (void *context) hd->count = 0; } -void +static void sha384_init (void *context) { SHA512_CONTEXT *hd = (SHA512_CONTEXT *) context; @@ -373,7 +373,7 @@ static gcry_md_oid_spec_t oid_spec_sha512[] = { NULL } }; -gcry_md_spec_t digest_spec_sha512 = { +gcry_md_spec_t _gcry_digest_spec_sha512 = { "SHA512", sha512_asn, DIM (sha512_asn), oid_spec_sha512, 64, sha512_init, sha512_write, sha512_final, sha512_read, sizeof (SHA512_CONTEXT), @@ -392,7 +392,7 @@ static gcry_md_oid_spec_t oid_spec_sha384[] = { NULL }, }; -gcry_md_spec_t digest_spec_sha384 = { +gcry_md_spec_t _gcry_digest_spec_sha384 = { "SHA384", sha384_asn, DIM (sha384_asn), oid_spec_sha384, 48, sha384_init, sha512_write, sha512_final, sha512_read, sizeof (SHA512_CONTEXT), diff --git a/cipher/tiger.c b/cipher/tiger.c index 9ec3a769..0488988d 100644 --- a/cipher/tiger.c +++ b/cipher/tiger.c @@ -833,7 +833,7 @@ static gcry_md_oid_spec_t oid_spec_tiger[] = { NULL } }; -gcry_md_spec_t digest_spec_tiger = +gcry_md_spec_t _gcry_digest_spec_tiger = { "TIGER192", asn, DIM (asn), oid_spec_tiger, 24, tiger_init, tiger_write, tiger_final, tiger_read, diff --git a/cipher/twofish.c b/cipher/twofish.c index 157aa43a..fd3651e8 100644 --- a/cipher/twofish.c +++ b/cipher/twofish.c @@ -1019,13 +1019,13 @@ main() -gcry_cipher_spec_t cipher_spec_twofish = +gcry_cipher_spec_t _gcry_cipher_spec_twofish = { "TWOFISH", NULL, NULL, 16, 256, sizeof (TWOFISH_context), twofish_setkey, twofish_encrypt, twofish_decrypt, }; -gcry_cipher_spec_t cipher_spec_twofish128 = +gcry_cipher_spec_t _gcry_cipher_spec_twofish128 = { "TWOFISH128", NULL, NULL, 16, 128, sizeof (TWOFISH_context), twofish_setkey, twofish_encrypt, twofish_decrypt, diff --git a/configure.ac b/configure.ac index bc6941b0..e3b93559 100644 --- a/configure.ac +++ b/configure.ac @@ -56,7 +56,6 @@ AH_TOP([ ]) AH_BOTTOM([ -#include "gcrypt-defs.h" #define _GCRYPT_IN_LIBGCRYPT 1 ]) @@ -417,7 +416,8 @@ AC_DEFINE_UNQUOTED(NAME_OF_DEV_URANDOM, "$NAME_OF_DEV_URANDOM", AM_PATH_GPG_ERROR("$NEED_GPG_ERROR_VERSION") if test "x$GPG_ERROR_LIBS" = "x"; then - AC_MSG_ERROR([libgpg-error is needed]) + AC_MSG_ERROR([libgpg-error is needed. + See ftp://ftp.gnupg.org/gcrypt/libgpg-error/ .]) fi AC_DEFINE(GPG_ERR_SOURCE_DEFAULT, GPG_ERR_SOURCE_GCRYPT, @@ -646,34 +646,8 @@ AC_SUBST(LIBGCRYPT_CONFIG_LIBS_PTH) AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS_PTH) AC_SUBST(LIBGCRYPT_THREAD_MODULES) -AC_CONFIG_COMMANDS([gcrypt-defs],[[ +AC_CONFIG_COMMANDS([gcrypt-conf],[[ chmod +x src/libgcrypt-config -cat >gcrypt-defs.tmp </dev/null; then - echo "gcrypt-defs.h is unchanged" - rm -f gcrypt-defs.tmp -else - rm -f gcrypt-defs.h - mv gcrypt-defs.tmp gcrypt-defs.h - echo "gcrypt-defs.h created" -fi ]],[[ prefix=$prefix exec_prefix=$exec_prefix @@ -691,57 +665,89 @@ DATADIRNAME=$DATADIRNAME LIST_MEMBER(arcfour, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS arcfour.lo" -AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_ARCFOUR, $found, + [Defined if this module should be included]) + LIST_MEMBER(blowfish, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS blowfish.lo" -AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_BLOWFISH, $found, + [Defined if this module should be included]) + LIST_MEMBER(cast5, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS cast5.lo" -AC_DEFINE_UNQUOTED(USE_CAST5, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_CAST5, $found, + [Defined if this module should be included]) + LIST_MEMBER(des, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS des.lo" -AC_DEFINE_UNQUOTED(USE_DES, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_DES, $found, + [Defined if this module should be included]) + LIST_MEMBER(aes, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS rijndael.lo" -AC_DEFINE_UNQUOTED(USE_AES, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_AES, $found, + [Defined if this module should be included]) + LIST_MEMBER(twofish, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS twofish.lo" -AC_DEFINE_UNQUOTED(USE_TWOFISH, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_TWOFISH, $found, + [Defined if this module should be included]) + LIST_MEMBER(serpent, $enabled_ciphers) test "$found" = "1" && GCRYPT_CIPHERS="$GCRYPT_CIPHERS serpent.lo" -AC_DEFINE_UNQUOTED(USE_SERPENT, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_SERPENT, $found, + [Defined if this module should be included]) LIST_MEMBER(dsa, $enabled_pubkey_ciphers) test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS dsa.lo" -AC_DEFINE_UNQUOTED(USE_DSA, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_DSA, $found, + [Defined if this module should be included]) + LIST_MEMBER(rsa, $enabled_pubkey_ciphers) test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS rsa.lo" -AC_DEFINE_UNQUOTED(USE_RSA, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_RSA, $found, + [Defined if this module should be included]) + LIST_MEMBER(elgamal, $enabled_pubkey_ciphers) -test "$found" = "1" && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo" -AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found, [Defined if this module should be included]) +test "$found" = "1" \ + && GCRYPT_PUBKEY_CIPHERS="$GCRYPT_PUBKEY_CIPHERS elgamal.lo" +AC_DEFINE_UNQUOTED(USE_ELGAMAL, $found, + [Defined if this module should be included]) LIST_MEMBER(crc, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS crc.lo" -AC_DEFINE_UNQUOTED(USE_CRC, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_CRC, $found, + [Defined if this module should be included]) + LIST_MEMBER(md4, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md4.lo" -AC_DEFINE_UNQUOTED(USE_MD4, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_MD4, $found, + [Defined if this module should be included]) + LIST_MEMBER(md5, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS md5.lo" -AC_DEFINE_UNQUOTED(USE_MD5, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_MD5, $found, + [Defined if this module should be included]) + LIST_MEMBER(sha1, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha1.lo" -AC_DEFINE_UNQUOTED(USE_SHA1, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_SHA1, $found, + [Defined if this module should be included]) + LIST_MEMBER(sha256, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha256.lo" -AC_DEFINE_UNQUOTED(USE_SHA256, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_SHA256, $found, + [Defined if this module should be included]) + LIST_MEMBER(sha512, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS sha512.lo" -AC_DEFINE_UNQUOTED(USE_SHA512, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_SHA512, $found, + [Defined if this module should be included]) + LIST_MEMBER(tiger, $enabled_digests) test "$found" = "1" && GCRYPT_DIGESTS="$GCRYPT_DIGESTS tiger.lo" -AC_DEFINE_UNQUOTED(USE_TIGER, $found, [Defined if this module should be included]) +AC_DEFINE_UNQUOTED(USE_TIGER, $found, + [Defined if this module should be included]) # rmd160 should be included always. GCRYPT_DIGESTS="$GCRYPT_DIGESTS rmd160.lo" @@ -750,22 +756,27 @@ AC_DEFINE_UNQUOTED(USE_RMD160, 1, [Defined if this module should be included]) LIST_MEMBER(linux, $random_modules) test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndlinux.lo" -AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found, [Defined if the /dev/random based RNG should be used.]) +AC_DEFINE_UNQUOTED(USE_RNDLINUX, $found, + [Defined if the /dev/random based RNG should be used.]) + LIST_MEMBER(unix, $random_modules) test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndunix.lo" -AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found, [Defined if the default Unix RNG should be used.]) +AC_DEFINE_UNQUOTED(USE_RNDUNIX, $found, + [Defined if the default Unix RNG should be used.]) if test "$found" = "1"; then print_egd_notice=yes fi LIST_MEMBER(egd, $random_modules) test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndegd.lo" -AC_DEFINE_UNQUOTED(USE_RNDEGD, $found, [Defined if the EGD based RNG should be used.]) +AC_DEFINE_UNQUOTED(USE_RNDEGD, $found, + [Defined if the EGD based RNG should be used.]) LIST_MEMBER(w32, $random_modules) test "$found" = "1" && GCRYPT_RANDOM="$GCRYPT_RANDOM rndw32.lo" -AC_DEFINE_UNQUOTED(USE_RNDW32, $found, [Defined if the Windows specific RNG should be used.]) +AC_DEFINE_UNQUOTED(USE_RNDW32, $found, + [Defined if the Windows specific RNG should be used.]) AC_SUBST([GCRYPT_CIPHERS]) AC_SUBST([GCRYPT_PUBKEY_CIPHERS]) diff --git a/doc/gcrypt.texi b/doc/gcrypt.texi index e3f103c9..6ba8cafc 100644 --- a/doc/gcrypt.texi +++ b/doc/gcrypt.texi @@ -2475,6 +2475,7 @@ The function accepts public or secret keys in @var{key}. @deftypefun gcry_error_t gcry_pk_testkey (gcry_sexp_t @var{key}) Return zero if the private key @var{key} is `sane', an error code otherwise. +Note, that it is not possible to chek the `saneness' of a public key. @end deftypefun diff --git a/src/ChangeLog b/src/ChangeLog index c4e73de1..d42b25ac 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,10 +1,14 @@ +2003-10-27 Werner Koch + + * gcrypt.h (gcry_pk_testkey): Doc fix. + 2003-09-29 Moritz Schulte * libgcrypt-config.in: Fix --algorithms option. 2003-10-23 Werner Koch - * gcrypt.h (gcry_err_code): Use GPG_ERR_INLINE instyead of + * gcrypt.h (gcry_err_code): Use GPG_ERR_INLINE instead of __inline__. * secmem.c (lock_pool): Don't print the warning for certain diff --git a/src/cipher.h b/src/cipher.h index 8af097a5..265e4769 100644 --- a/src/cipher.h +++ b/src/cipher.h @@ -47,36 +47,36 @@ const char * _gcry_pk_aliased_algo_name (int algorithm); /* Declarations for the cipher specifications. */ -extern gcry_cipher_spec_t cipher_spec_blowfish; -extern gcry_cipher_spec_t cipher_spec_des; -extern gcry_cipher_spec_t cipher_spec_tripledes; -extern gcry_cipher_spec_t cipher_spec_arcfour; -extern gcry_cipher_spec_t cipher_spec_cast5; -extern gcry_cipher_spec_t cipher_spec_aes; -extern gcry_cipher_spec_t cipher_spec_aes192; -extern gcry_cipher_spec_t cipher_spec_aes256; -extern gcry_cipher_spec_t cipher_spec_twofish; -extern gcry_cipher_spec_t cipher_spec_twofish128; -extern gcry_cipher_spec_t cipher_spec_serpent128; -extern gcry_cipher_spec_t cipher_spec_serpent192; -extern gcry_cipher_spec_t cipher_spec_serpent256; +extern gcry_cipher_spec_t _gcry_cipher_spec_blowfish; +extern gcry_cipher_spec_t _gcry_cipher_spec_des; +extern gcry_cipher_spec_t _gcry_cipher_spec_tripledes; +extern gcry_cipher_spec_t _gcry_cipher_spec_arcfour; +extern gcry_cipher_spec_t _gcry_cipher_spec_cast5; +extern gcry_cipher_spec_t _gcry_cipher_spec_aes; +extern gcry_cipher_spec_t _gcry_cipher_spec_aes192; +extern gcry_cipher_spec_t _gcry_cipher_spec_aes256; +extern gcry_cipher_spec_t _gcry_cipher_spec_twofish; +extern gcry_cipher_spec_t _gcry_cipher_spec_twofish128; +extern gcry_cipher_spec_t _gcry_cipher_spec_serpent128; +extern gcry_cipher_spec_t _gcry_cipher_spec_serpent192; +extern gcry_cipher_spec_t _gcry_cipher_spec_serpent256; /* Declarations for the digest specifications. */ -extern gcry_md_spec_t digest_spec_crc32; -extern gcry_md_spec_t digest_spec_crc32_rfc1510; -extern gcry_md_spec_t digest_spec_crc24_rfc2440; -extern gcry_md_spec_t digest_spec_md4; -extern gcry_md_spec_t digest_spec_md5; -extern gcry_md_spec_t digest_spec_rmd160; -extern gcry_md_spec_t digest_spec_sha1; -extern gcry_md_spec_t digest_spec_sha256; -extern gcry_md_spec_t digest_spec_sha512; -extern gcry_md_spec_t digest_spec_sha384; -extern gcry_md_spec_t digest_spec_tiger; +extern gcry_md_spec_t _gcry_digest_spec_crc32; +extern gcry_md_spec_t _gcry_digest_spec_crc32_rfc1510; +extern gcry_md_spec_t _gcry_digest_spec_crc24_rfc2440; +extern gcry_md_spec_t _gcry_digest_spec_md4; +extern gcry_md_spec_t _gcry_digest_spec_md5; +extern gcry_md_spec_t _gcry_digest_spec_rmd160; +extern gcry_md_spec_t _gcry_digest_spec_sha1; +extern gcry_md_spec_t _gcry_digest_spec_sha256; +extern gcry_md_spec_t _gcry_digest_spec_sha512; +extern gcry_md_spec_t _gcry_digest_spec_sha384; +extern gcry_md_spec_t _gcry_digest_spec_tiger; /* Declarations for the pubkey cipher specifications. */ -extern gcry_pk_spec_t pubkey_spec_rsa; -extern gcry_pk_spec_t pubkey_spec_elg; -extern gcry_pk_spec_t pubkey_spec_dsa; +extern gcry_pk_spec_t _gcry_pubkey_spec_rsa; +extern gcry_pk_spec_t _gcry_pubkey_spec_elg; +extern gcry_pk_spec_t _gcry_pubkey_spec_dsa; #endif /*G10_CIPHER_H*/ diff --git a/src/gcrypt.h b/src/gcrypt.h index 4b361bb1..51a53e30 100644 --- a/src/gcrypt.h +++ b/src/gcrypt.h @@ -765,7 +765,7 @@ gcry_error_t gcry_pk_sign (gcry_sexp_t *result, gcry_sexp_t data, gcry_sexp_t sk /* Check the signature SIGVAL on DATA using the public key PKEY. */ gcry_error_t gcry_pk_verify (gcry_sexp_t sigval, gcry_sexp_t data, gcry_sexp_t pkey); -/* Check that KEY (either private or public) is sane. */ +/* Check that private KEY is sane. */ gcry_error_t gcry_pk_testkey (gcry_sexp_t key); /* Generate a new key pair according to the parameters given in diff --git a/w32-dll/ChangeLog b/w32-dll/ChangeLog index 1ca92d3f..561a85d2 100644 --- a/w32-dll/ChangeLog +++ b/w32-dll/ChangeLog @@ -1,3 +1,8 @@ +2003-10-27 Werner Koch + + * libgcrypt.def: Manually wrote this file. + * build-def: This file should not be used anymore. + 2002-09-18 Timo Schulz * build-def: Now there are no duplicates in the libgcrypt.def diff --git a/w32-dll/build-def b/w32-dll/build-def index 75b39fa5..41dd6f9c 100755 --- a/w32-dll/build-def +++ b/w32-dll/build-def @@ -11,6 +11,9 @@ # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +DO NOT USE + + $gcrypt_h = "../src/gcrypt.h"; $i = 1; $header_passed = 0; @@ -19,7 +22,7 @@ open( FD, $gcrypt_h ) || die "$gcrypt_h: $!"; @filebuf = ; close( FD ); -open( FD, ">libgcrypt.def" ) || die "$!"; +open( FD, ">libgcrypt.deffoooo" ) || die "$!"; print FD "EXPORTS\n"; foreach $in( @filebuf ) { if( $in =~ m/GCRYPT_VERSION/ ) { diff --git a/w32-dll/libgcrypt.def b/w32-dll/libgcrypt.def index 3b5344b5..eb82fe77 100644 --- a/w32-dll/libgcrypt.def +++ b/w32-dll/libgcrypt.def @@ -1,125 +1,206 @@ +;; libgcrypt.defs - Exported symbols for W32 +;; Copyright (C) 2003 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 Lesser General Public License as +;; published by the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details. +;; +;; You should have received a copy of the GNU Lesser 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 file should be updated manually and the ordinals shall +;; never be changed. + + EXPORTS - gcry_check_version @1 - gcry_errno @2 - gcry_strerror @3 - gcry_control @4 - gcry_sexp_new @5 - gcry_sexp_create @6 - gcry_sexp_sscan @7 - gcry_sexp_build @8 - gcry_sexp_release @9 - gcry_sexp_canon_len @10 - gcry_sexp_sprint @11 - gcry_sexp_cons @12 - gcry_sexp_alist @13 - gcry_sexp_vlist @14 - gcry_sexp_append @15 - gcry_sexp_prepend @16 - gcry_sexp_find_token @17 - gcry_sexp_nth @18 - gcry_sexp_car @19 - gcry_sexp_cdr @20 - gcry_sexp_cadr @21 - gcry_sexp_nth_data @22 - gcry_sexp_nth_mpi @23 - gcry_mpi_new @24 - gcry_mpi_snew @25 - gcry_mpi_release @26 - gcry_mpi_copy @27 - gcry_mpi_set @28 - gcry_mpi_set_ui @29 - gcry_mpi_swap @30 - gcry_mpi_cmp @31 - gcry_mpi_cmp_ui @32 - gcry_mpi_scan @33 - gcry_mpi_print @34 - gcry_mpi_aprint @35 - gcry_mpi_add @36 - gcry_mpi_add_ui @37 - gcry_mpi_addm @38 - gcry_mpi_sub @39 - gcry_mpi_sub_ui @40 - gcry_mpi_subm @41 - gcry_mpi_mul @42 - gcry_mpi_mul_ui @43 - gcry_mpi_mulm @44 - gcry_mpi_mul_2exp @45 - gcry_mpi_div @46 - gcry_mpi_mod @47 - gcry_mpi_powm @48 - gcry_mpi_gcd @49 - gcry_mpi_invm @50 - gcry_mpi_get_nbits @51 - gcry_mpi_test_bit @52 - gcry_mpi_set_bit @53 - gcry_mpi_clear_bit @54 - gcry_mpi_set_highbit @55 - gcry_mpi_clear_highbit @56 - gcry_mpi_rshift @57 - gcry_mpi_set_opaque @58 - gcry_mpi_get_opaque @59 - gcry_mpi_set_flag @60 - gcry_mpi_clear_flag @61 - gcry_mpi_get_flag @62 - gcry_cipher_open @63 - gcry_cipher_close @64 - gcry_cipher_ctl @65 - gcry_cipher_info @66 - gcry_cipher_algo_info @67 - gcry_cipher_algo_name @68 - gcry_cipher_map_name @69 - gcry_cipher_mode_from_oid @70 - gcry_cipher_encrypt @71 - gcry_cipher_decrypt @72 - gcry_pk_encrypt @73 - gcry_pk_decrypt @74 - gcry_pk_sign @75 - gcry_pk_verify @76 - gcry_pk_testkey @77 - gcry_pk_genkey @78 - gcry_pk_ctl @79 - gcry_pk_algo_info @80 - gcry_pk_algo_name @81 - gcry_pk_map_name @82 - gcry_pk_get_nbits @83 - gcry_pk_get_keygrip @84 - gcry_md_open @85 - gcry_md_close @86 - gcry_md_enable @87 - gcry_md_copy @88 - gcry_md_reset @89 - gcry_md_ctl @90 - gcry_md_write @91 - gcry_md_read @92 - gcry_md_hash_buffer @93 - gcry_md_get_algo @94 - gcry_md_get_algo_dlen @95 - gcry_md_info @96 - gcry_md_algo_info @97 - gcry_md_algo_name @98 - gcry_md_map_name @99 - gcry_md_setkey @100 - gcry_randomize @101 - gcry_random_bytes @102 - gcry_random_bytes_secure @103 - gcry_mpi_randomize @104 - gcry_set_progress_handler @105 - gcry_set_allocation_handler @106 - gcry_set_outofcore_handler @107 - gcry_set_fatalerror_handler @108 - gcry_set_gettext_handler @109 - gcry_set_log_handler @110 - gcry_malloc @111 - gcry_calloc @112 - gcry_malloc_secure @113 - gcry_calloc_secure @114 - gcry_realloc @115 - gcry_strdup @116 - gcry_xmalloc @117 - gcry_xcalloc @118 - gcry_xmalloc_secure @119 - gcry_xcalloc_secure @120 - gcry_xrealloc @121 - gcry_xstrdup @122 - gcry_free @123 - gcry_is_secure @124 + gcry_check_version @1 + gcry_control @2 + + gcry_malloc @3 + gcry_calloc @4 + gcry_malloc_secure @5 + gcry_calloc_secure @6 + gcry_realloc @7 + gcry_strdup @8 + gcry_xmalloc @9 + gcry_xcalloc @10 + gcry_xmalloc_secure @11 + gcry_xcalloc_secure @12 + gcry_xrealloc @13 + gcry_xstrdup @14 + gcry_is_secure @15 + gcry_free @16 + + gcry_set_progress_handler @17 + gcry_set_allocation_handler @18 + gcry_set_outofcore_handler @19 + gcry_set_fatalerror_handler @20 + gcry_set_log_handler @21 + gcry_set_gettext_handler @22 + + gcry_strerror @23 + gcry_strsource @24 + gcry_err_code_from_errno @25 + gcry_err_code_to_errno @26 + gcry_err_make_from_errno @27 + gcry_error_from_errno @28 + + gcry_sexp_new @29 + gcry_sexp_create @30 + gcry_sexp_sscan @31 + gcry_sexp_build @32 + gcry_sexp_build_array @33 + gcry_sexp_release @34 + gcry_sexp_canon_len @35 + gcry_sexp_sprint @36 + gcry_sexp_dump @37 + gcry_sexp_cons @38 + gcry_sexp_alist @39 + gcry_sexp_vlist @40 + gcry_sexp_append @41 + gcry_sexp_prepend @42 + gcry_sexp_find_token @43 + gcry_sexp_length @44 + gcry_sexp_nth @45 + gcry_sexp_car @46 + gcry_sexp_cdr @47 + gcry_sexp_cadr @48 + gcry_sexp_nth_data @49 + gcry_sexp_nth_mpi @50 + + gcry_mpi_new @51 + gcry_mpi_snew @52 + gcry_mpi_release @53 + gcry_mpi_copy @54 + gcry_mpi_set @55 + gcry_mpi_set_ui @56 + gcry_mpi_swap @57 + gcry_mpi_cmp @58 + gcry_mpi_cmp_ui @59 + gcry_mpi_scan @60 + gcry_mpi_print @61 + gcry_mpi_aprint @62 + gcry_mpi_dump @63 + gcry_mpi_add @64 + gcry_mpi_add_ui @65 + gcry_mpi_addm @66 + gcry_mpi_sub @67 + gcry_mpi_sub_ui @68 + gcry_mpi_subm @69 + gcry_mpi_mul @70 + gcry_mpi_mul_ui @71 + gcry_mpi_mulm @72 + gcry_mpi_mul_2exp @73 + gcry_mpi_div @74 + gcry_mpi_mod @75 + gcry_mpi_powm @76 + gcry_mpi_gcd @77 + gcry_mpi_invm @78 + gcry_mpi_get_nbits @79 + gcry_mpi_test_bit @80 + gcry_mpi_set_bit @81 + gcry_mpi_clear_bit @82 + gcry_mpi_set_highbit @83 + gcry_mpi_clear_highbit @84 + gcry_mpi_rshift @85 + gcry_mpi_set_opaque @86 + gcry_mpi_get_opaque @87 + gcry_mpi_set_flag @88 + gcry_mpi_clear_flag @89 + gcry_mpi_get_flag @90 + + + gcry_cipher_open @92 + gcry_cipher_close @93 + gcry_cipher_ctl @94 + gcry_cipher_info @95 + gcry_cipher_algo_info @96 + gcry_cipher_algo_name @97 + gcry_cipher_map_name @98 + gcry_cipher_mode_from_oid @99 + gcry_cipher_encrypt @100 + gcry_cipher_decrypt @101 + gcry_cipher_get_algo_keylen @102 + gcry_cipher_get_algo_blklen @103 + gcry_cipher_list @104 + + gcry_pk_encrypt @105 + gcry_pk_decrypt @106 + gcry_pk_sign @107 + gcry_pk_verify @108 + gcry_pk_testkey @109 + gcry_pk_genkey @110 + gcry_pk_ctl @111 + gcry_pk_algo_info @112 + gcry_pk_algo_name @113 + gcry_pk_map_name @114 + gcry_pk_get_nbits @115 + gcry_pk_get_keygrip @116 + gcry_pk_list @117 + + gcry_ac_data_new @118 + gcry_ac_data_destroy @119 + gcry_ac_data_set @120 + gcry_ac_data_copy @121 + gcry_ac_data_length @122 + gcry_ac_data_get_name @123 + gcry_ac_data_get_index @124 + gcry_ac_data_clear @125 + gcry_ac_open @126 + gcry_ac_close @127 + gcry_ac_key_init @128 + gcry_ac_key_pair_generate @129 + gcry_ac_key_pair_extract @130 + gcry_ac_key_data_get @131 + gcry_ac_key_test @132 + gcry_ac_key_get_nbits @133 + gcry_ac_key_get_grip @134 + gcry_ac_key_destroy @135 + gcry_ac_key_pair_destroy @136 + gcry_ac_data_encrypt @137 + gcry_ac_data_decrypt @138 + gcry_ac_data_sign @139 + gcry_ac_data_verify @140 + gcry_ac_id_to_name @141 + gcry_ac_name_to_id @142 + + gcry_md_open @143 + gcry_md_close @144 + gcry_md_enable @145 + gcry_md_copy @146 + gcry_md_reset @147 + gcry_md_ctl @148 + gcry_md_write @149 + gcry_md_read @150 + gcry_md_hash_buffer @151 + gcry_md_get_algo @152 + gcry_md_get_algo_dlen @153 + gcry_md_is_enabled @154 + gcry_md_is_secure @155 + gcry_md_info @156 + gcry_md_algo_info @157 + gcry_md_algo_name @158 + gcry_md_map_name @159 + gcry_md_setkey @160 + gcry_md_list @161 + + gcry_randomize @162 + gcry_random_add_bytes @163 + gcry_random_bytes @164 + gcry_random_bytes_secure @165 + gcry_mpi_randomize @166 + + gcry_prime_generate @167 + gcry_prime_group_generator @168 + gcry_prime_release_factors @169 + gcry_prime_check @170 -- cgit v1.2.1