From cvs at cvs.gnupg.org Thu Feb 1 05:21:08 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 01 Feb 2007 05:21:08 +0100 Subject: [svn] GnuPG - r4422 - branches/STABLE-BRANCH-1-4/util Message-ID: Author: dshaw Date: 2007-02-01 05:21:07 +0100 (Thu, 01 Feb 2007) New Revision: 4422 Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/ttyio.c Log: * ttyio.c (do_get): Assume that anything read from the user without echoing to the screen is sensitive and put it in secure memory. Suggested by Benjamin Bennett. Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-01-31 21:39:26 UTC (rev 4421) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-01 04:21:07 UTC (rev 4422) @@ -1,3 +1,9 @@ +2007-01-31 David Shaw + + * ttyio.c (do_get): Assume that anything read from the user + without echoing to the screen is sensitive and put it in secure + memory. Suggested by Benjamin Bennett. + 2006-12-14 Werner Koch * http.c (http_wait_response): No more shutdown. Fixes bug#739. Modified: branches/STABLE-BRANCH-1-4/util/ttyio.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/ttyio.c 2007-01-31 21:39:26 UTC (rev 4421) +++ branches/STABLE-BRANCH-1-4/util/ttyio.c 2007-02-01 04:21:07 UTC (rev 4422) @@ -405,7 +405,8 @@ init_ttyfp(); last_prompt_len = 0; - buf = xmalloc(n=50); + n = 50; + buf = hidden ? xmalloc_secure(n) : xmalloc(n); i = 0; #ifdef _WIN32 /* windoze version */ From cvs at cvs.gnupg.org Thu Feb 1 16:14:32 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 16:14:32 +0100 Subject: [svn] gcry - r1199 - in branches/LIBGCRYPT-1-2-BRANCH: . src Message-ID: Author: wk Date: 2007-02-01 16:14:31 +0100 (Thu, 01 Feb 2007) New Revision: 1199 Modified: branches/LIBGCRYPT-1-2-BRANCH/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/NEWS branches/LIBGCRYPT-1-2-BRANCH/README branches/LIBGCRYPT-1-2-BRANCH/configure.ac branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c Log: Preparing a new release Modified: branches/LIBGCRYPT-1-2-BRANCH/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/ChangeLog 2007-01-31 18:00:36 UTC (rev 1198) +++ branches/LIBGCRYPT-1-2-BRANCH/ChangeLog 2007-02-01 15:14:31 UTC (rev 1199) @@ -1,3 +1,9 @@ +2007-02-01 Werner Koch + + Released 1.2.4. + + * configure.ac: Set LT to C13/A2/R3. + 2006-11-30 Werner Koch * autogen.sh: New option --force. @@ -15,7 +21,7 @@ Released 1.2.3. - * configure.ac: Set LT to C13/A1/R2. + * configure.ac: Set LT to C13/A2/R2. 2006-07-26 Werner Koch @@ -30,7 +36,7 @@ Released 1.2.2. - * configure.ac: Set LT to C13/A1/R1. + * configure.ac: Set LT to C13/A2/R1. 2005-09-14 Werner Koch Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-01-31 18:00:36 UTC (rev 1198) +++ branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 15:14:31 UTC (rev 1199) @@ -1,9 +1,12 @@ -Noteworthy changes in version 1.2.4 +Noteworthy changes in version 1.2.4 (2007-02-01) ------------------------------------------------ - * Minor bug fixes. + * Fixed a bug in the memory allocator which could have been the + reason for some of non-duplicable bugs. + * Other minor bug fixes. + Noteworthy changes in version 1.2.3 (2006-08-28) ------------------------------------------------ Modified: branches/LIBGCRYPT-1-2-BRANCH/README =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/README 2007-01-31 18:00:36 UTC (rev 1198) +++ branches/LIBGCRYPT-1-2-BRANCH/README 2007-02-01 15:14:31 UTC (rev 1199) @@ -1,8 +1,9 @@ libgcrypt - The GNU crypto library ------------------------------------ - Version 1.2.1 + Version 1.2.4 - Copyright 2000, 2002, 2003, 2004, 2005 Free Software Foundation, Inc. + Copyright 2000, 2002, 2003, 2004, 2005, 2006, + 2007 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: branches/LIBGCRYPT-1-2-BRANCH/configure.ac =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-01-31 18:00:36 UTC (rev 1198) +++ branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 15:14:31 UTC (rev 1199) @@ -28,7 +28,7 @@ # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. m4_define([my_version], [1.2.4]) -m4_define([my_issvn], [yes]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) @@ -41,7 +41,7 @@ # (No interfaces changed: REVISION++) LIBGCRYPT_LT_CURRENT=13 LIBGCRYPT_LT_AGE=2 -LIBGCRYPT_LT_REVISION=2 +LIBGCRYPT_LT_REVISION=3 # If the API is changed in an incompatible way: increment the next counter. LIBGCRYPT_CONFIG_API_VERSION=1 Modified: branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-01-31 18:00:36 UTC (rev 1198) +++ branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-02-01 15:14:31 UTC (rev 1199) @@ -589,7 +589,7 @@ { return (pool_okay && p >= pool - && p < (const void*)((const char*)pool+pool_size)); + && p < pool+pool_size); } From cvs at cvs.gnupg.org Thu Feb 1 16:51:03 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 16:51:03 +0100 Subject: [svn] gcry - r1200 - branches/LIBGCRYPT-1-2-BRANCH/tests Message-ID: Author: wk Date: 2007-02-01 16:51:02 +0100 (Thu, 01 Feb 2007) New Revision: 1200 Modified: branches/LIBGCRYPT-1-2-BRANCH/tests/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/tests/basic.c branches/LIBGCRYPT-1-2-BRANCH/tests/pubkey.c Log: Use quick random mode for tests. Modified: branches/LIBGCRYPT-1-2-BRANCH/tests/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/tests/ChangeLog 2007-02-01 15:14:31 UTC (rev 1199) +++ branches/LIBGCRYPT-1-2-BRANCH/tests/ChangeLog 2007-02-01 15:51:02 UTC (rev 1200) @@ -1,3 +1,7 @@ +2007-02-01 Werner Koch + + * pubkey.c, basic.c (main): Enable quick random mode. + 2006-11-30 Werner Koch * ac.c (main): Set quick random flag. Modified: branches/LIBGCRYPT-1-2-BRANCH/tests/basic.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/tests/basic.c 2007-02-01 15:14:31 UTC (rev 1199) +++ branches/LIBGCRYPT-1-2-BRANCH/tests/basic.c 2007-02-01 15:51:02 UTC (rev 1200) @@ -1081,6 +1081,8 @@ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); + check_ciphers (); check_aes128_cbc_cts_cipher (); check_cbc_mac_cipher (); Modified: branches/LIBGCRYPT-1-2-BRANCH/tests/pubkey.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/tests/pubkey.c 2007-02-01 15:14:31 UTC (rev 1199) +++ branches/LIBGCRYPT-1-2-BRANCH/tests/pubkey.c 2007-02-01 15:51:02 UTC (rev 1200) @@ -244,6 +244,7 @@ gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); if (debug) gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u , 0); + gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); for (; i > 0; i--) check_run (); From cvs at cvs.gnupg.org Thu Feb 1 17:00:57 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 17:00:57 +0100 Subject: [svn] gcry - r1201 - tags Message-ID: Author: wk Date: 2007-02-01 17:00:57 +0100 (Thu, 01 Feb 2007) New Revision: 1201 Added: tags/libgcrypt-1.2.4/ Log: Release 1.2.4 Copied: tags/libgcrypt-1.2.4 (from rev 1200, branches/LIBGCRYPT-1-2-BRANCH) From cvs at cvs.gnupg.org Thu Feb 1 17:11:28 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 17:11:28 +0100 Subject: [svn] gcry - r1202 - branches/LIBGCRYPT-1-2-BRANCH Message-ID: Author: wk Date: 2007-02-01 17:11:14 +0100 (Thu, 01 Feb 2007) New Revision: 1202 Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS branches/LIBGCRYPT-1-2-BRANCH/configure.ac Log: Post release updates Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 16:00:57 UTC (rev 1201) +++ branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 16:11:14 UTC (rev 1202) @@ -1,3 +1,8 @@ +Noteworthy changes in version 1.2.5 +------------------------------------------------ + + + Noteworthy changes in version 1.2.4 (2007-02-01) ------------------------------------------------ Modified: branches/LIBGCRYPT-1-2-BRANCH/configure.ac =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 16:00:57 UTC (rev 1201) +++ branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 16:11:14 UTC (rev 1202) @@ -27,8 +27,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.2.4]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.2.5]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Thu Feb 1 17:50:34 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 17:50:34 +0100 Subject: [svn] gcry - r1203 - tags Message-ID: Author: wk Date: 2007-02-01 17:50:34 +0100 (Thu, 01 Feb 2007) New Revision: 1203 Removed: tags/libgcrypt-1.2.4/ Log: Found a little proble, need to build it again. From cvs at cvs.gnupg.org Thu Feb 1 19:53:24 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 19:53:24 +0100 Subject: [svn] gcry - r1204 - in branches/LIBGCRYPT-1-2-BRANCH: . src Message-ID: Author: wk Date: 2007-02-01 19:53:23 +0100 (Thu, 01 Feb 2007) New Revision: 1204 Modified: branches/LIBGCRYPT-1-2-BRANCH/autogen.sh branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c Log: Removed GCCism. Modified: branches/LIBGCRYPT-1-2-BRANCH/autogen.sh =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/autogen.sh 2007-02-01 16:50:34 UTC (rev 1203) +++ branches/LIBGCRYPT-1-2-BRANCH/autogen.sh 2007-02-01 18:53:23 UTC (rev 1204) @@ -154,4 +154,4 @@ echo "Running autoconf${FORCE} ..." $AUTOCONF${FORCE} -echo "You may now run \"./configure --enable-maintainer-mode && make\"." +echo "You may now run \"./configure --enable-maintainer-mode --enable-gcc-warnings && make\"." Modified: branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog 2007-02-01 16:50:34 UTC (rev 1203) +++ branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog 2007-02-01 18:53:23 UTC (rev 1204) @@ -1,3 +1,8 @@ +2007-02-01 Werner Koch + + * secmem.c (_gcry_private_is_secure): Trapped by gcc, void* has a + size only in gcc. Reported by Christian Biere. + 2007-01-31 Werner Koch * secmem.c (_gcry_private_is_secure): Fixed severe implementation Modified: branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-02-01 16:50:34 UTC (rev 1203) +++ branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-02-01 18:53:23 UTC (rev 1204) @@ -589,7 +589,7 @@ { return (pool_okay && p >= pool - && p < pool+pool_size); + && p < (void*)((char*)pool+pool_size)); } From cvs at cvs.gnupg.org Thu Feb 1 20:22:06 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 20:22:06 +0100 Subject: [svn] gcry - r1205 - in branches/LIBGCRYPT-1-2-BRANCH: . cipher Message-ID: Author: wk Date: 2007-02-01 20:22:04 +0100 (Thu, 01 Feb 2007) New Revision: 1205 Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS branches/LIBGCRYPT-1-2-BRANCH/cipher/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/cipher/blowfish.c branches/LIBGCRYPT-1-2-BRANCH/cipher/cast5.c branches/LIBGCRYPT-1-2-BRANCH/cipher/cipher.c branches/LIBGCRYPT-1-2-BRANCH/cipher/des.c branches/LIBGCRYPT-1-2-BRANCH/cipher/rfc2268.c branches/LIBGCRYPT-1-2-BRANCH/cipher/rijndael.c branches/LIBGCRYPT-1-2-BRANCH/cipher/serpent.c branches/LIBGCRYPT-1-2-BRANCH/cipher/twofish.c Log: Added some superflous initializatins to shutup gcc a bit. Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 19:22:04 UTC (rev 1205) @@ -1,8 +1,3 @@ -Noteworthy changes in version 1.2.5 ------------------------------------------------- - - - Noteworthy changes in version 1.2.4 (2007-02-01) ------------------------------------------------ Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/ChangeLog 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/ChangeLog 2007-02-01 19:22:04 UTC (rev 1205) @@ -1,3 +1,8 @@ +2007-02-01 Werner Koch + + * serpent.c: Add some missing struct element inits. Also for all + other cipher modules. + 2007-01-30 Werner Koch * sha256.c (oid_spec_sha256): Add alias from pkcs#1. Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/blowfish.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/blowfish.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/blowfish.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -602,5 +602,5 @@ { "BLOWFISH", NULL, NULL, BLOWFISH_BLOCKSIZE, 128, sizeof (BLOWFISH_context), - bf_setkey, encrypt_block, decrypt_block, + bf_setkey, encrypt_block, decrypt_block, NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/cast5.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/cast5.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/cast5.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -616,5 +616,5 @@ gcry_cipher_spec_t _gcry_cipher_spec_cast5 = { "CAST5", NULL, NULL, CAST5_BLOCKSIZE, 128, sizeof (CAST5_context), - cast_setkey, encrypt_block, decrypt_block, + cast_setkey, encrypt_block, decrypt_block, NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/cipher.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/cipher.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/cipher.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -72,7 +72,7 @@ #ifdef USE_RFC2268 { &_gcry_cipher_spec_rfc2268_40, GCRY_CIPHER_RFC2268_40 }, #endif - { NULL }, + { NULL, 0 } }; /* List of registered ciphers. */ @@ -1057,6 +1057,7 @@ break; default: log_fatal("cipher_encrypt: invalid mode %d\n", c->mode ); + /*NOTREACHED*/ rc = GPG_ERR_INV_CIPHER_MODE; break; } @@ -1143,6 +1144,7 @@ break; default: log_fatal ("cipher_decrypt: invalid mode %d\n", c->mode ); + /*NOTREACHED*/ rc = GPG_ERR_INV_CIPHER_MODE; break; } Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/des.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/des.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/des.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -1091,7 +1091,7 @@ 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 + do_des_setkey, do_des_encrypt, do_des_decrypt, NULL, NULL }; static gcry_cipher_oid_spec_t oids_tripledes[] = @@ -1107,5 +1107,6 @@ 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 + do_tripledes_setkey, do_tripledes_encrypt, do_tripledes_decrypt, + NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/rfc2268.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/rfc2268.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/rfc2268.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -340,6 +340,6 @@ gcry_cipher_spec_t _gcry_cipher_spec_rfc2268_40 = { "RFC2268_40", NULL, oids_rfc2268_40, RFC2268_BLOCKSIZE, 40, sizeof(RFC2268_context), - do_setkey, do_encrypt, do_decrypt + do_setkey, do_encrypt, do_decrypt, NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/rijndael.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/rijndael.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/rijndael.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -2228,7 +2228,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes = { "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt, NULL, NULL }; static const char *rijndael192_names[] = @@ -2249,7 +2249,7 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes192 = { "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt, NULL, NULL }; static const char *rijndael256_names[] = @@ -2271,5 +2271,5 @@ { "AES256", rijndael256_names, rijndael256_oids, 16, 256, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt, NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/serpent.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/serpent.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/serpent.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -907,7 +907,7 @@ }, { 0 - }, + } }; for (i = 0; test_data[i].key_length; i++) @@ -960,19 +960,19 @@ { "SERPENT128", cipher_spec_serpent128_aliases, NULL, 16, 128, sizeof (serpent_context_t), - serpent_setkey, serpent_encrypt, serpent_decrypt, + serpent_setkey, serpent_encrypt, serpent_decrypt, NULL, NULL }; gcry_cipher_spec_t _gcry_cipher_spec_serpent192 = { "SERPENT192", NULL, NULL, 16, 192, sizeof (serpent_context_t), - serpent_setkey, serpent_encrypt, serpent_decrypt, + serpent_setkey, serpent_encrypt, serpent_decrypt, NULL, NULL }; gcry_cipher_spec_t _gcry_cipher_spec_serpent256 = { "SERPENT256", NULL, NULL, 16, 256, sizeof (serpent_context_t), - serpent_setkey, serpent_encrypt, serpent_decrypt, + serpent_setkey, serpent_encrypt, serpent_decrypt, NULL, NULL }; Modified: branches/LIBGCRYPT-1-2-BRANCH/cipher/twofish.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/cipher/twofish.c 2007-02-01 18:53:23 UTC (rev 1204) +++ branches/LIBGCRYPT-1-2-BRANCH/cipher/twofish.c 2007-02-01 19:22:04 UTC (rev 1205) @@ -1030,11 +1030,11 @@ gcry_cipher_spec_t _gcry_cipher_spec_twofish = { "TWOFISH", NULL, NULL, 16, 256, sizeof (TWOFISH_context), - twofish_setkey, twofish_encrypt, twofish_decrypt, + twofish_setkey, twofish_encrypt, twofish_decrypt, NULL, NULL }; gcry_cipher_spec_t _gcry_cipher_spec_twofish128 = { "TWOFISH128", NULL, NULL, 16, 128, sizeof (TWOFISH_context), - twofish_setkey, twofish_encrypt, twofish_decrypt, + twofish_setkey, twofish_encrypt, twofish_decrypt, NULL, NULL }; From cvs at cvs.gnupg.org Thu Feb 1 20:22:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 20:22:44 +0100 Subject: [svn] gcry - r1206 - branches/LIBGCRYPT-1-2-BRANCH Message-ID: Author: wk Date: 2007-02-01 20:22:44 +0100 (Thu, 01 Feb 2007) New Revision: 1206 Modified: branches/LIBGCRYPT-1-2-BRANCH/configure.ac Log: ah weel, we need to build 1.2.4 first Modified: branches/LIBGCRYPT-1-2-BRANCH/configure.ac =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 19:22:04 UTC (rev 1205) +++ branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 19:22:44 UTC (rev 1206) @@ -27,8 +27,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.2.5]) -m4_define([my_issvn], [yes]) +m4_define([my_version], [1.2.4]) +m4_define([my_issvn], [no]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Thu Feb 1 20:32:18 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 01 Feb 2007 20:32:18 +0100 Subject: [svn] GnuPG - r4423 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-02-01 20:32:16 +0100 (Thu, 01 Feb 2007) New Revision: 4423 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/gpg.c branches/STABLE-BRANCH-1-4/g10/keyedit.c branches/STABLE-BRANCH-1-4/g10/keygen.c branches/STABLE-BRANCH-1-4/g10/main.h branches/STABLE-BRANCH-1-4/g10/sign.c Log: * main.h, keygen.c (ask_expire_interval, parse_expire_string): Pass in the time to use to calculate the expiration offset, rather than querying it internally. Change all callers. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-01 19:32:16 UTC (rev 4423) @@ -1,3 +1,9 @@ +2007-02-01 David Shaw + + * main.h, keygen.c (ask_expire_interval, parse_expire_string): + Pass in the time to use to calculate the expiration offset, rather + than querying it internally. Change all callers. + 2007-01-31 David Shaw * keygen.c (do_generate_keypair, proc_parameter_file, Modified: branches/STABLE-BRANCH-1-4/g10/gpg.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/gpg.c 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/gpg.c 2007-02-01 19:32:16 UTC (rev 4423) @@ -2397,7 +2397,7 @@ case oDefSigExpire: if(*pargs.r.ret_str!='\0') { - if(parse_expire_string(pargs.r.ret_str)==(u32)-1) + if(parse_expire_string(0,pargs.r.ret_str)==(u32)-1) log_error(_("`%s' is not a valid signature expiration\n"), pargs.r.ret_str); else @@ -2409,7 +2409,7 @@ case oDefCertExpire: if(*pargs.r.ret_str!='\0') { - if(parse_expire_string(pargs.r.ret_str)==(u32)-1) + if(parse_expire_string(0,pargs.r.ret_str)==(u32)-1) log_error(_("`%s' is not a valid signature expiration\n"), pargs.r.ret_str); else Modified: branches/STABLE-BRANCH-1-4/g10/keyedit.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/keyedit.c 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/keyedit.c 2007-02-01 19:32:16 UTC (rev 4423) @@ -866,9 +866,9 @@ if(!duration && !selfsig) { if(opt.ask_cert_expire) - duration=ask_expire_interval(1,opt.def_cert_expire); + duration=ask_expire_interval(timestamp,1,opt.def_cert_expire); else - duration=parse_expire_string(opt.def_cert_expire); + duration=parse_expire_string(timestamp,opt.def_cert_expire); } if(duration) @@ -3514,6 +3514,7 @@ PKT_user_id *uid; KBNODE node; u32 keyid[2]; + u32 timestamp=make_timestamp(); if( count_selected_keys( sec_keyblock ) ) { tty_printf(_("Please remove selections from the secret keys.\n")); @@ -3534,9 +3535,9 @@ no_primary_warning(pub_keyblock); } - expiredate=ask_expire_interval(0,NULL); + expiredate=ask_expire_interval(timestamp,0,NULL); if(expiredate) - expiredate+=make_timestamp(); + expiredate+=timestamp; node = find_kbnode( sec_keyblock, PKT_SECRET_KEY ); sk = copy_secret_key( NULL, node->pkt->pkt.secret_key); @@ -3596,6 +3597,13 @@ if( !sn ) log_info(_("No corresponding signature in secret ring\n")); + /* Note the potential oddity that the expiration date + is calculated from the time when this function + started ("timestamp"), but the signature is + calculated from the time within + update_keysig_packet(). On a slow or loaded + machine, these two values may not match, making the + expiration date off by a second or two. */ if( mainkey ) rc = update_keysig_packet(&newsig, sig, main_pk, uid, NULL, sk, keygen_add_key_expire, main_pk); Modified: branches/STABLE-BRANCH-1-4/g10/keygen.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/keygen.c 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/keygen.c 2007-02-01 19:32:16 UTC (rev 4423) @@ -1584,17 +1584,17 @@ * similar. */ u32 -parse_expire_string( const char *string ) +parse_expire_string(u32 timestamp,const char *string) { int mult; - u32 seconds,abs_date=0,curtime = make_timestamp(); + u32 seconds,abs_date=0; if( !*string ) seconds = 0; else if ( !strncmp (string, "seconds=", 8) ) seconds = atoi (string+8); - else if( (abs_date = scan_isodatestr(string)) && abs_date > curtime ) - seconds = abs_date - curtime; + else if( (abs_date = scan_isodatestr(string)) && abs_date > timestamp ) + seconds = abs_date - timestamp; else if( (mult=check_valid_days(string)) ) seconds = atoi(string) * 86400L * mult; else @@ -1605,7 +1605,7 @@ /* object == 0 for a key, and 1 for a sig */ u32 -ask_expire_interval(int object,const char *def_expire) +ask_expire_interval(u32 timestamp,int object,const char *def_expire) { u32 interval; char *answer; @@ -1645,8 +1645,6 @@ answer = NULL; for(;;) { - u32 curtime=make_timestamp(); - xfree(answer); if(object==0) answer = cpr_get("keygen.valid",_("Key is valid for? (0) ")); @@ -1669,7 +1667,7 @@ } cpr_kill_prompt(); trim_spaces(answer); - interval = parse_expire_string( answer ); + interval = parse_expire_string( timestamp, answer ); if( interval == (u32)-1 ) { tty_printf(_("invalid value\n")); @@ -1687,11 +1685,11 @@ tty_printf(object==0 ? _("Key expires at %s\n") : _("Signature expires at %s\n"), - asctimestamp((ulong)(curtime + interval) ) ); + asctimestamp((ulong)(timestamp + interval) ) ); /* FIXME: This check yields warning on alhas: Write a configure check and to this check here only for 32 bit machines */ - if( (time_t)((ulong)(curtime+interval)) < 0 ) + if( (time_t)((ulong)(timestamp+interval)) < 0 ) tty_printf(_("Your system can't display dates beyond 2038.\n" "However, it will be correctly handled up to 2106.\n")); } @@ -2314,7 +2312,7 @@ { u32 seconds; - seconds = parse_expire_string( r->u.value ); + seconds = parse_expire_string( timestamp, r->u.value ); if( seconds == (u32)-1 ) { log_error("%s:%d: invalid expire date\n", fname, r->lnr ); @@ -2706,7 +2704,7 @@ para = r; } - expire = ask_expire_interval(0,NULL); + expire = ask_expire_interval(timestamp,0,NULL); r = xmalloc_clear( sizeof *r + 20 ); r->key = pKEYEXPIRE; r->u.expire = expire; @@ -3233,7 +3231,7 @@ algo = ask_algo( 1, &use ); assert(algo); nbits = ask_keysize( algo ); - expire = ask_expire_interval(0,NULL); + expire = ask_expire_interval(timestamp,0,NULL); if( !cpr_enabled() && !cpr_get_answer_is_yes("keygen.sub.okay", _("Really create? (y/N) "))) goto leave; Modified: branches/STABLE-BRANCH-1-4/g10/main.h =================================================================== --- branches/STABLE-BRANCH-1-4/g10/main.h 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/main.h 2007-02-01 19:32:16 UTC (rev 4423) @@ -170,8 +170,8 @@ void show_basic_key_info (KBNODE keyblock); /*-- keygen.c --*/ -u32 parse_expire_string(const char *string); -u32 ask_expire_interval(int object,const char *def_expire); +u32 parse_expire_string(u32 timestamp,const char *string); +u32 ask_expire_interval(u32 timestamp,int object,const char *def_expire); void generate_keypair( const char *fname, const char *card_serialno, const char *backup_encryption_dir ); int keygen_set_std_prefs (const char *string,int personal); Modified: branches/STABLE-BRANCH-1-4/g10/sign.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/sign.c 2007-02-01 04:21:07 UTC (rev 4422) +++ branches/STABLE-BRANCH-1-4/g10/sign.c 2007-02-01 19:32:16 UTC (rev 4423) @@ -775,9 +775,9 @@ if(!opt.force_v3_sigs && !RFC1991) { if(opt.ask_sig_expire && !opt.batch) - duration=ask_expire_interval(1,opt.def_sig_expire); + duration=ask_expire_interval(create_time,1,opt.def_sig_expire); else - duration=parse_expire_string(opt.def_sig_expire); + duration=parse_expire_string(create_time,opt.def_sig_expire); } if( (rc=build_sk_list( locusr, &sk_list, 1, PUBKEY_USAGE_SIG )) ) @@ -1085,9 +1085,9 @@ if(!opt.force_v3_sigs && !RFC1991) { if(opt.ask_sig_expire && !opt.batch) - duration=ask_expire_interval(1,opt.def_sig_expire); + duration=ask_expire_interval(create_time,1,opt.def_sig_expire); else - duration=parse_expire_string(opt.def_sig_expire); + duration=parse_expire_string(create_time,opt.def_sig_expire); } if( (rc=build_sk_list( locusr, &sk_list, 1, PUBKEY_USAGE_SIG )) ) @@ -1245,9 +1245,9 @@ if(!opt.force_v3_sigs && !RFC1991) { if(opt.ask_sig_expire && !opt.batch) - duration=ask_expire_interval(1,opt.def_sig_expire); + duration=ask_expire_interval(create_time,1,opt.def_sig_expire); else - duration=parse_expire_string(opt.def_sig_expire); + duration=parse_expire_string(create_time,opt.def_sig_expire); } rc = build_sk_list (locusr, &sk_list, 1, PUBKEY_USAGE_SIG); From cvs at cvs.gnupg.org Thu Feb 1 20:48:50 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 20:48:50 +0100 Subject: [svn] gcry - r1207 - tags Message-ID: Author: wk Date: 2007-02-01 20:48:50 +0100 (Thu, 01 Feb 2007) New Revision: 1207 Added: tags/libgcrypt-1.2.4/ Log: tagged release Copied: tags/libgcrypt-1.2.4 (from rev 1206, branches/LIBGCRYPT-1-2-BRANCH) From cvs at cvs.gnupg.org Thu Feb 1 20:49:33 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 01 Feb 2007 20:49:33 +0100 Subject: [svn] gcry - r1208 - branches/LIBGCRYPT-1-2-BRANCH Message-ID: Author: wk Date: 2007-02-01 20:49:33 +0100 (Thu, 01 Feb 2007) New Revision: 1208 Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS branches/LIBGCRYPT-1-2-BRANCH/configure.ac Log: Post release updates Modified: branches/LIBGCRYPT-1-2-BRANCH/NEWS =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 19:48:50 UTC (rev 1207) +++ branches/LIBGCRYPT-1-2-BRANCH/NEWS 2007-02-01 19:49:33 UTC (rev 1208) @@ -1,3 +1,8 @@ +Noteworthy changes in version 1.2.5 +------------------------------------------------ + + + Noteworthy changes in version 1.2.4 (2007-02-01) ------------------------------------------------ Modified: branches/LIBGCRYPT-1-2-BRANCH/configure.ac =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 19:48:50 UTC (rev 1207) +++ branches/LIBGCRYPT-1-2-BRANCH/configure.ac 2007-02-01 19:49:33 UTC (rev 1208) @@ -27,8 +27,8 @@ # Remember to change the version number immediately *after* a release. # Set my_issvn to "yes" for non-released code. Remember to run an # "svn up" and "autogen.sh" right before creating a distribution. -m4_define([my_version], [1.2.4]) -m4_define([my_issvn], [no]) +m4_define([my_version], [1.2.5]) +m4_define([my_issvn], [yes]) m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) From cvs at cvs.gnupg.org Thu Feb 1 21:51:15 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Thu, 01 Feb 2007 21:51:15 +0100 Subject: [svn] GnuPG - r4424 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-02-01 21:51:15 +0100 (Thu, 01 Feb 2007) New Revision: 4424 Modified: branches/STABLE-BRANCH-1-4/g10/keygen.c Log: Missed one caller. Modified: branches/STABLE-BRANCH-1-4/g10/keygen.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/keygen.c 2007-02-01 19:32:16 UTC (rev 4423) +++ branches/STABLE-BRANCH-1-4/g10/keygen.c 2007-02-01 20:51:15 UTC (rev 4424) @@ -3348,7 +3348,7 @@ goto leave; algo = PUBKEY_ALGO_RSA; - expire = ask_expire_interval (0,NULL); + expire = ask_expire_interval (timestamp,0,NULL); if (keyno == 1) use = PUBKEY_USAGE_SIG; else if (keyno == 2) From cvs at cvs.gnupg.org Fri Feb 2 16:52:57 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 02 Feb 2007 16:52:57 +0100 Subject: [svn] gcry - r1209 - branches/LIBGCRYPT-1-2-BRANCH/mpi Message-ID: Author: wk Date: 2007-02-02 16:52:57 +0100 (Fri, 02 Feb 2007) New Revision: 1209 Modified: branches/LIBGCRYPT-1-2-BRANCH/mpi/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/mpi/config.links Log: * config.links (mpi_optional_modules): Make sure that powerpc64 is matched before a generic powerpc. Reported by Andreas Metzler. Should fix Debian bug 284609. Fixed in trunk on 2006-10-23. Modified: branches/LIBGCRYPT-1-2-BRANCH/mpi/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/mpi/ChangeLog 2007-02-01 19:49:33 UTC (rev 1208) +++ branches/LIBGCRYPT-1-2-BRANCH/mpi/ChangeLog 2007-02-02 15:52:57 UTC (rev 1209) @@ -1,3 +1,9 @@ +2007-02-02 Werner Koch + + * config.links (mpi_optional_modules): Make sure that powerpc64 is + matched before a generic powerpc. Reported by Andreas Metzler. + Should fix Debian bug 284609. Fixed in trunk on 2006-10-23. + 2006-08-29 Werner Koch * mpiutil.c (gcry_mpi_get_flag): Let it return a value to silent Modified: branches/LIBGCRYPT-1-2-BRANCH/mpi/config.links =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/mpi/config.links 2007-02-01 19:49:33 UTC (rev 1208) +++ branches/LIBGCRYPT-1-2-BRANCH/mpi/config.links 2007-02-02 15:52:57 UTC (rev 1209) @@ -1,4 +1,4 @@ -# config.links - helper for ../configure +# config.links - helper for ../configure -*- mode: sh -*- # Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. # # This file is part of Libgcrypt. @@ -221,13 +221,6 @@ path="m68k/mc68020 m68k" ;; - powerpc*-*-linux*) - echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h - echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h - cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h - path="powerpc32" - ;; - powerpc*-*-netbsd* | powerpc*-*-openbsd*) echo '/* configured {Open,Net}BSD on powerpc */' >>./mpi/asm-syntax.h echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h @@ -236,6 +229,18 @@ path="powerpc32" ;; + ppc620-*-* | \ + powerpc64*-*-*) + mpi_sflags="-Wa,-mppc" + path="powerpc64" + ;; + powerpc*-*-linux*) + echo '/* configured for powerpc/ELF */' >>./mpi/asm-syntax.h + echo '#define ELF_SYNTAX' >>./mpi/asm-syntax.h + cat $srcdir/mpi/powerpc32/syntax.h >>./mpi/asm-syntax.h + path="powerpc32" + ;; + rs6000-*-aix[456789]* | \ rs6000-*-aix3.2.[456789]) mpi_sflags="-Wa,-mpwr" @@ -264,11 +269,6 @@ mpi_sflags="-Wa,-mppc" path="powerpc32" ;; - ppc620-*-* | \ - powerpc64*-*-*) - mpi_sflags="-Wa,-mppc" - path="powerpc64" - ;; powerpc*-*-*) mpi_sflags="-Wa,-mppc" path="powerpc32" From cvs at cvs.gnupg.org Sun Feb 4 18:20:25 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 04 Feb 2007 18:20:25 +0100 Subject: [svn] GnuPG - r4425 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: wk Date: 2007-02-04 18:20:24 +0100 (Sun, 04 Feb 2007) New Revision: 4425 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/parse-packet.c Log: Fix for Debian bug 402592 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-01 20:51:15 UTC (rev 4424) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-04 17:20:24 UTC (rev 4425) @@ -1,3 +1,8 @@ +2007-02-04 Werner Koch + + * parse-packet.c (parse_signature): Limit bytes read for an + unknown alogorithm. Fixes Debian bug#402592. + 2007-02-01 David Shaw * main.h, keygen.c (ask_expire_interval, parse_expire_string): Modified: branches/STABLE-BRANCH-1-4/g10/parse-packet.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/parse-packet.c 2007-02-01 20:51:15 UTC (rev 4424) +++ branches/STABLE-BRANCH-1-4/g10/parse-packet.c 2007-02-04 17:20:24 UTC (rev 4425) @@ -38,6 +38,11 @@ #include "main.h" #include "i18n.h" +#ifndef MAX_EXTERN_MPI_BITS +#define MAX_EXTERN_MPI_BITS 16384 +#endif + + static int mpi_print_mode; static int list_mode; static FILE *listfp; @@ -1437,10 +1442,21 @@ if( list_mode ) fprintf (listfp, "\tunknown algorithm %d\n", sig->pubkey_algo ); unknown_pubkey_warning( sig->pubkey_algo ); - /* we store the plain material in data[0], so that we are able + /* We store the plain material in data[0], so that we are able * to write it back with build_packet() */ - sig->data[0]= mpi_set_opaque(NULL, read_rest(inp, pktlen, 0), pktlen ); - pktlen = 0; + if (pktlen > (5 * MAX_EXTERN_MPI_BITS/8)) + { + /* However we include a limit to avoid too trivial DoS + attacks by having gpg allocate too much memory. */ + log_error ("signature packet: too much data\n"); + rc = G10ERR_INVALID_PACKET; + } + else + { + sig->data[0]= mpi_set_opaque (NULL, read_rest(inp, pktlen, 0), + pktlen ); + pktlen = 0; + } } else { for( i=0; i < ndata; i++ ) { From cvs at cvs.gnupg.org Sun Feb 4 18:23:02 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 04 Feb 2007 18:23:02 +0100 Subject: [svn] GnuPG - r4426 - trunk/g10 Message-ID: Author: wk Date: 2007-02-04 18:23:00 +0100 (Sun, 04 Feb 2007) New Revision: 4426 Modified: trunk/g10/ChangeLog trunk/g10/parse-packet.c Log: Fix for Debian bug 402592 Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-02-04 17:20:24 UTC (rev 4425) +++ trunk/g10/ChangeLog 2007-02-04 17:23:00 UTC (rev 4426) @@ -1,3 +1,8 @@ +2007-02-04 Werner Koch + + * parse-packet.c (parse_signature): Limit bytes read for an + unknown alogorithm. Fixes Debian bug#402592. + 2007-01-31 Werner Koch * verify.c (verify_signatures): Do no dereference a NULL afx. Modified: trunk/g10/parse-packet.c =================================================================== --- trunk/g10/parse-packet.c 2007-02-04 17:20:24 UTC (rev 4425) +++ trunk/g10/parse-packet.c 2007-02-04 17:23:00 UTC (rev 4426) @@ -1494,9 +1494,19 @@ unknown_pubkey_warning( sig->pubkey_algo ); /* We store the plain material in data[0], so that we are able * to write it back with build_packet() */ - sig->data[0]= gcry_mpi_set_opaque (NULL, read_rest(inp, pktlen, 0), - pktlen*8 ); - pktlen = 0; + if (pktlen > (5 * MAX_EXTERN_MPI_BITS/8)) + { + /* However we include a limit to avoid too trivial DoS + attacks by having gpg allocate too much memory. */ + log_error ("signature packet: too much data\n"); + rc = G10ERR_INVALID_PACKET; + } + else + { + sig->data[0]= gcry_mpi_set_opaque (NULL, read_rest(inp, pktlen, 0), + pktlen*8 ); + pktlen = 0; + } } else { for( i=0; i < ndata; i++ ) { From cvs at cvs.gnupg.org Mon Feb 5 12:46:58 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 05 Feb 2007 12:46:58 +0100 Subject: [svn] GnuPG - r4427 - trunk/doc Message-ID: Author: wk Date: 2007-02-05 12:46:58 +0100 (Mon, 05 Feb 2007) New Revision: 4427 Modified: trunk/doc/ChangeLog trunk/doc/debugging.texi Log: Fix for aegypten issue 720 Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-02-04 17:23:00 UTC (rev 4426) +++ trunk/doc/ChangeLog 2007-02-05 11:46:58 UTC (rev 4427) @@ -1,3 +1,8 @@ +2007-02-05 Werner Koch + + * debugging.texi (Common Problems): Tell how to export a private + key without a certificate. + 2007-01-30 Werner Koch * com-certs.pem: Added the current root certifcates of D-Trust and Modified: trunk/doc/debugging.texi =================================================================== --- trunk/doc/debugging.texi 2007-02-04 17:23:00 UTC (rev 4426) +++ trunk/doc/debugging.texi 2007-02-05 11:46:58 UTC (rev 4427) @@ -125,6 +125,46 @@ making use of ssh. + at item Exporting a secret key without a certificate + +I may happen that you have created a certificate request using + at command{gpgsm} but not yet received and imported the certificate from +the CA. However, you want to export the secret key to another machine +right now to import the certificate over there then. You can do this +with a little trick but it requires that you know the approximate time +you created the signing request. By running the command + + at smallexample + ls -ltr ~/.gnupg/private-keys-v1.d + at end smallexample + +you get a listing of all private keys under control of @command{gpg-agent}. +Pick the key which best matches the creation time and run the command + + at smallexample + /usr/local/libexec/gpg-protect-tool --p12-export ~/.gnupg/private-keys-v1.d/@var{foo} >@var{foo}.p12 + at end smallexample + +(Please adjust the path to @command{gpg-protect-tool} to the approriate +location). @var{foo} is the name of the key file you picked (it should +have the suffix @file{.key}). A Pinentry box will pop up and ask you +for the current passphrase of the key and a new passphrase to protect it +in the pkcs#12 file. + +To import the created file on the machine you use this command: + + at smallexample + /usr/local/libexec/gpg-protect-tool --p12-import --store @var{foo}.p12 + at end smallexample + +You will be asked for the pkcs#12 passphrase and a new passphrase to +protect the imported private key at its new location. + +Note that there is no easy way to match existing certificates with +stored private keys because some private keys are used for Secure Shell +or other purposes and don't have a corresponding certificate. + + @end itemize From cvs at cvs.gnupg.org Tue Feb 6 23:40:33 2007 From: cvs at cvs.gnupg.org (cvs user marcus) Date: Tue, 06 Feb 2007 23:40:33 +0100 Subject: oftpd/src (6 files) Message-ID: Date: Tuesday, February 6, 2007 @ 23:40:33 Author: marcus Path: /cvs/wk/oftpd/src Modified: config.h.in daemon_assert.c file_list.c ftp_listener.c ftp_session.c oftpd.c 2007-02-06 Marcus Brinkmann * configure.in (AC_CHECK_HEADERS): Check for sys/sendfile.h. * src/file_list.c (file_nlst): Remove unused variable HIDDEN. * src/ftp_session.c [HAVE_SYS_SENDFILE_H]: Include . (do_user, do_pass): Remove unused variable addr_port. (do_eprt): Remove unused variable HOST_PORT. (do_retr): Remove unused variable host_port. Adjust format output parameter for timespec members, cast these to the format type. [!HAVE_FREEBSD_SENDFILE]: Do not define otherwise unused variable AMT_SENT. * src/ftp_listener.c (addr2string) [!INET6]: Do not define variables ERROR and ADDR to suppress compiler warning. (addr_to_string): Replace with prototype for addr2string. * src/oftpd.c: Remove extra argument EXE_NAME in syslog invocation. (my_syslog_fd): Remove unused global variable. * src/daemon_assert.c: Include . -----------------+ config.h.in | 3 +++ daemon_assert.c | 1 + file_list.c | 3 +-- ftp_listener.c | 6 ++++-- ftp_session.c | 21 +++++++++++---------- oftpd.c | 6 ++---- 6 files changed, 22 insertions(+), 18 deletions(-) From cvs at cvs.gnupg.org Tue Feb 6 23:40:34 2007 From: cvs at cvs.gnupg.org (cvs user marcus) Date: Tue, 06 Feb 2007 23:40:34 +0100 Subject: oftpd (ChangeLog configure.in) Message-ID: Date: Tuesday, February 6, 2007 @ 23:40:34 Author: marcus Path: /cvs/wk/oftpd Modified: ChangeLog configure.in 2007-02-06 Marcus Brinkmann * configure.in (AC_CHECK_HEADERS): Check for sys/sendfile.h. * src/file_list.c (file_nlst): Remove unused variable HIDDEN. * src/ftp_session.c [HAVE_SYS_SENDFILE_H]: Include . (do_user, do_pass): Remove unused variable addr_port. (do_eprt): Remove unused variable HOST_PORT. (do_retr): Remove unused variable host_port. Adjust format output parameter for timespec members, cast these to the format type. [!HAVE_FREEBSD_SENDFILE]: Do not define otherwise unused variable AMT_SENT. * src/ftp_listener.c (addr2string) [!INET6]: Do not define variables ERROR and ADDR to suppress compiler warning. (addr_to_string): Replace with prototype for addr2string. * src/oftpd.c: Remove extra argument EXE_NAME in syslog invocation. (my_syslog_fd): Remove unused global variable. * src/daemon_assert.c: Include . --------------+ ChangeLog | 20 ++++++++++++++++++++ configure.in | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) From cvs at cvs.gnupg.org Thu Feb 8 01:29:43 2007 From: cvs at cvs.gnupg.org (cvs user marcus) Date: Thu, 08 Feb 2007 01:29:43 +0100 Subject: oftpd (ChangeLog) Message-ID: Date: Thursday, February 8, 2007 @ 01:29:43 Author: marcus Path: /cvs/wk/oftpd Modified: ChangeLog 2007-02-08 Marcus Brinkmann * src/telnet_session.c: Include . (process_data): Enable cancellation. * src/ftp_session.c (netscape_hack): Likewise. (send_readme, do_list, do_nlst): Use cancellation cleanup handler. (set_pasv): Release socket_fd before invoking reply() in case of failure. (open_connection): Likewise. (do_pasv): Close outstanding passive port before invoking reply(). (do_lpsv): Likewise. (do_epsv): Likewise. * src/file_list.c: Always include . (fdprintf): Bump buffer size to PATH_MAX + 3. Enable cancellation while writing. * src/ftp_listener.c (connection_handler): Do not use asynchronous cancellation. Disable cancellation until further notice. -----------+ ChangeLog | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+) From cvs at cvs.gnupg.org Thu Feb 8 01:29:42 2007 From: cvs at cvs.gnupg.org (cvs user marcus) Date: Thu, 08 Feb 2007 01:29:42 +0100 Subject: oftpd/src (4 files) Message-ID: Date: Thursday, February 8, 2007 @ 01:29:42 Author: marcus Path: /cvs/wk/oftpd/src Modified: file_list.c ftp_listener.c ftp_session.c telnet_session.c 2007-02-08 Marcus Brinkmann * src/telnet_session.c: Include . (process_data): Enable cancellation. * src/ftp_session.c (netscape_hack): Likewise. (send_readme, do_list, do_nlst): Use cancellation cleanup handler. (set_pasv): Release socket_fd before invoking reply() in case of failure. (open_connection): Likewise. (do_pasv): Close outstanding passive port before invoking reply(). (do_lpsv): Likewise. (do_epsv): Likewise. * src/file_list.c: Always include . (fdprintf): Bump buffer size to PATH_MAX + 3. Enable cancellation while writing. * src/ftp_listener.c (connection_handler): Do not use asynchronous cancellation. Disable cancellation until further notice. ------------------+ file_list.c | 62 +++++++++++++++---- ftp_listener.c | 7 +- ftp_session.c | 167 ++++++++++++++++++++++++++++------------------------- telnet_session.c | 8 ++ 4 files changed, 150 insertions(+), 94 deletions(-) From cvs at cvs.gnupg.org Thu Feb 8 20:12:34 2007 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu, 08 Feb 2007 20:12:34 +0100 Subject: oftpd/src (oftpd.c) Message-ID: Date: Thursday, February 8, 2007 @ 20:12:34 Author: werner Path: /cvs/wk/oftpd/src Modified: oftpd.c Changed another VERSION ---------+ oftpd.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) From cvs at cvs.gnupg.org Thu Feb 8 19:53:43 2007 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu, 08 Feb 2007 19:53:43 +0100 Subject: oftpd (8 files) Message-ID: Date: Thursday, February 8, 2007 @ 19:53:43 Author: werner Path: /cvs/wk/oftpd Added: configure.ac Modified: ChangeLog INSTALL install-sh missing mkinstalldirs Removed: acconfig.h configure.in Updated build system to configure.ac style ---------------+ ChangeLog | 6 INSTALL | 174 +++++++++++++------ acconfig.h | 13 - configure.ac | 124 ++++++++++++++ configure.in | 118 ------------- install-sh | 490 ++++++++++++++++++++++++++++++++------------------------ missing | 220 ++++++++++++++++++++++--- mkinstalldirs | 170 ++++++++++++++++--- 8 files changed, 864 insertions(+), 451 deletions(-) From cvs at cvs.gnupg.org Thu Feb 8 19:53:43 2007 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu, 08 Feb 2007 19:53:43 +0100 Subject: oftpd/src (config.h.in) Message-ID: Date: Thursday, February 8, 2007 @ 19:53:43 Author: werner Path: /cvs/wk/oftpd/src Removed: config.h.in Updated build system to configure.ac style -------------+ config.h.in | 185 ---------------------------------------------------------- 1 files changed, 185 deletions(-) From cvs at cvs.gnupg.org Thu Feb 8 20:01:45 2007 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu, 08 Feb 2007 20:01:45 +0100 Subject: oftpd/src (oftpd.c) Message-ID: Date: Thursday, February 8, 2007 @ 20:01:45 Author: werner Path: /cvs/wk/oftpd/src Modified: oftpd.c Do not use the obsolete VERSION and PACKAGE ---------+ oftpd.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) From cvs at cvs.gnupg.org Thu Feb 8 20:01:44 2007 From: cvs at cvs.gnupg.org (cvs user werner) Date: Thu, 08 Feb 2007 20:01:44 +0100 Subject: oftpd (ChangeLog) Message-ID: Date: Thursday, February 8, 2007 @ 20:01:44 Author: werner Path: /cvs/wk/oftpd Modified: ChangeLog Do not use the obsolete VERSION and PACKAGE -----------+ ChangeLog | 3 +++ 1 files changed, 3 insertions(+) From cvs at cvs.gnupg.org Sun Feb 11 04:10:13 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sun, 11 Feb 2007 04:10:13 +0100 Subject: [svn] GnuPG - r4428 - branches/STABLE-BRANCH-1-4/util Message-ID: Author: dshaw Date: 2007-02-11 04:10:12 +0100 (Sun, 11 Feb 2007) New Revision: 4428 Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/http.c Log: * http.c (do_parse_uri): Remove the hkp port 11371 detection. We implement hkp in the keyserver handler, and the support here makes it appear like a bad hkp request actually succeeded. Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-05 11:46:58 UTC (rev 4427) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-11 03:10:12 UTC (rev 4428) @@ -1,3 +1,9 @@ +2007-02-10 David Shaw + + * http.c (do_parse_uri): Remove the hkp port 11371 detection. We + implement hkp in the keyserver handler, and the support here makes + it appear like a bad hkp request actually succeeded. + 2007-01-31 David Shaw * ttyio.c (do_get): Assume that anything read from the user Modified: branches/STABLE-BRANCH-1-4/util/http.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/http.c 2007-02-05 11:46:58 UTC (rev 4427) +++ branches/STABLE-BRANCH-1-4/util/http.c 2007-02-11 03:10:12 UTC (rev 4428) @@ -321,8 +321,6 @@ uri->scheme = p; if(strcmp(uri->scheme,"http")==0) uri->port = 80; - else if(strcmp(uri->scheme,"hkp")==0) - uri->port = 11371; else return G10ERR_INVALID_URI; /* Unsupported scheme */ From cvs at cvs.gnupg.org Sun Feb 11 04:57:00 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Sun, 11 Feb 2007 04:57:00 +0100 Subject: [svn] GnuPG - r4429 - branches/STABLE-BRANCH-1-4/keyserver Message-ID: Author: dshaw Date: 2007-02-11 04:56:59 +0100 (Sun, 11 Feb 2007) New Revision: 4429 Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c Log: * gpgkeys_ldap.c (send_key): Missing a free(). * curl-shim.c (curl_easy_perform): Some debugging items that may be handy. Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-02-11 03:10:12 UTC (rev 4428) +++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-02-11 03:56:59 UTC (rev 4429) @@ -1,3 +1,10 @@ +2007-02-10 David Shaw + + * gpgkeys_ldap.c (send_key): Missing a free(). + + * curl-shim.c (curl_easy_perform): Some debugging items that may + be handy. + 2007-01-16 David Shaw * curl-shim.h, curl-shim.c, gpgkeys_hkp.c: Rename curl_escape() to Modified: branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c 2007-02-11 03:10:12 UTC (rev 4428) +++ branches/STABLE-BRANCH-1-4/keyserver/curl-shim.c 2007-02-11 03:56:59 UTC (rev 4429) @@ -173,7 +173,14 @@ proxy=getenv(HTTP_PROXY_ENV); if(curl->flags.verbose) - fprintf(curl->errors,"* HTTP proxy is \"%s\"\n",proxy?proxy:"null"); + { + fprintf(curl->errors,"* HTTP proxy is \"%s\"\n",proxy?proxy:"null"); + fprintf(curl->errors,"* HTTP URL is \"%s\"\n",curl->url); + fprintf(curl->errors,"* HTTP auth is \"%s\"\n", + curl->auth?curl->auth:"null"); + fprintf(curl->errors,"* HTTP method is %s\n", + curl->flags.post?"POST":"GET"); + } if(curl->flags.post) { Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c =================================================================== --- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-02-11 03:10:12 UTC (rev 4428) +++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_ldap.c 2007-02-11 03:56:59 UTC (rev 4429) @@ -782,6 +782,7 @@ free(modlist); free(addlist); free(dn); + free(key); if(ret!=0 && begin) fprintf(output,"KEY %s FAILED %d\n",keyid,ret); From cvs at cvs.gnupg.org Mon Feb 12 15:03:49 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 12 Feb 2007 15:03:49 +0100 Subject: [svn] gcry - r1210 - trunk/src Message-ID: Author: wk Date: 2007-02-12 15:03:48 +0100 (Mon, 12 Feb 2007) New Revision: 1210 Modified: trunk/src/ChangeLog trunk/src/gcrypt.h.in trunk/src/secmem.c Log: * gcrypt.h.in: Include stdlib.h for the sake fo the trheading macros. Suggested by Andreas Metzler. * secmem.c (ptr_into_pool_p): New. (_gcry_private_is_secure): Implement in terms of new function. (BLOCK_VALID): Removed. Replaced all users by new function. Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-02-02 15:52:57 UTC (rev 1209) +++ trunk/src/ChangeLog 2007-02-12 14:03:48 UTC (rev 1210) @@ -1,3 +1,18 @@ +2007-02-12 Werner Koch + + * gcrypt.h.in: Include stdlib.h for the sake fo the trheading + macros. Suggested by Andreas Metzler. + + * secmem.c (ptr_into_pool_p): New. + (_gcry_private_is_secure): Implement in terms of new function. + (BLOCK_VALID): Removed. Replaced all users by new function. + +2007-01-31 Werner Koch + + * secmem.c (_gcry_private_is_secure): Fixed severe implementation + flaw. Might be the reason for some of the more obscure bugs. + (MB_WIPE_OUT): Use wipememory2. + 2006-10-23 Werner Koch * gcrypt.h.in (GCRY_THREAD_OPTION_PTHREAD_IMPL): Add some cast for Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-02-02 15:52:57 UTC (rev 1209) +++ trunk/src/gcrypt.h.in 2007-02-12 14:03:48 UTC (rev 1210) @@ -22,6 +22,7 @@ #ifndef _GCRYPT_H #define _GCRYPT_H +#include #include #include Modified: trunk/src/secmem.c =================================================================== --- trunk/src/secmem.c 2007-02-02 15:52:57 UTC (rev 1209) +++ trunk/src/secmem.c 2007-02-12 14:03:48 UTC (rev 1210) @@ -1,6 +1,6 @@ /* secmem.c - memory allocation from a secure heap * Copyright (C) 1998, 1999, 2000, 2001, 2002, - * 2003 Free Software Foundation, Inc. + * 2003, 2007 Free Software Foundation, Inc. * * This file is part of Libgcrypt. * @@ -98,10 +98,21 @@ #define ADDR_TO_BLOCK(addr) \ (memblock_t *) ((char *) addr - BLOCK_HEAD_SIZE) -/* Check wether MB is a valid block. */ -#define BLOCK_VALID(mb) \ - (((char *) mb - (char *) pool) < pool_size) +/* Check whether P points into the pool. */ +static int +ptr_into_pool_p (const void *p) +{ + /* We need to convert pointers to addresses. This is required by + C-99 6.5.8 to avoid undefeined behavious. Using size_t is at + least only implementation defined. See also + http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html + */ + size_t p_addr = (size_t)p; + size_t pool_addr = (size_t)pool; + return p_addr >= pool_addr && p_addr < pool_addr+pool_size; +} + /* Update the stats. */ static void stats_update (size_t add, size_t sub) @@ -126,7 +137,7 @@ mb_next = (memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size); - if (! BLOCK_VALID (mb_next)) + if (! ptr_into_pool_p (mb_next)) mb_next = NULL; return mb_next; @@ -182,7 +193,7 @@ { memblock_t *mb, *mb_split; - for (mb = block; BLOCK_VALID (mb); mb = mb_get_next (mb)) + for (mb = block; ptr_into_pool_p (mb); mb = mb_get_next (mb)) if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size) { /* Found a free block. */ @@ -205,7 +216,7 @@ break; } - if (! BLOCK_VALID (mb)) + if (! ptr_into_pool_p (mb)) mb = NULL; return mb; @@ -360,7 +371,7 @@ else { pool = mmap (0, pool_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); - close (fd); + close (fd); } } #endif @@ -411,7 +422,7 @@ SECMEM_UNLOCK; } -unsigned +unsigned int _gcry_secmem_get_flags (void) { unsigned flags; @@ -458,7 +469,7 @@ { if (n < DEFAULT_POOL_SIZE) n = DEFAULT_POOL_SIZE; - if (!pool_okay) + if (! pool_okay) { init_pool (n); lock_pool (pool, n); @@ -525,7 +536,7 @@ /* This does not make much sense: probably this memory is held in the * cache. We do it anyway: */ #define MB_WIPE_OUT(byte) \ - memset ((memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE), (byte), size); + wipememory2 ((memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE), (byte), size); MB_WIPE_OUT (0xff); MB_WIPE_OUT (0xaa); @@ -583,19 +594,12 @@ return a; } + +/* Return true if P points into the secure memory area. */ int _gcry_private_is_secure (const void *p) { - int ret = 0; - - SECMEM_LOCK; - - if (pool_okay && BLOCK_VALID (ADDR_TO_BLOCK (p))) - ret = 1; - - SECMEM_UNLOCK; - - return ret; + return pool_okay && ptr_into_pool_p (p); } @@ -624,6 +628,7 @@ pool = NULL; pool_okay = 0; pool_size = 0; + not_locked = 0; } @@ -644,7 +649,7 @@ SECMEM_LOCK; for (i = 0, mb = (memblock_t *) pool; - BLOCK_VALID (mb); + ptr_into_pool_p (mb); mb = mb_get_next (mb), i++) log_info ("SECMEM: [%s] block: %i; size: %i\n", (mb->flags & MB_FLAG_ACTIVE) ? "used" : "free", From cvs at cvs.gnupg.org Mon Feb 12 15:13:38 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 12 Feb 2007 15:13:38 +0100 Subject: [svn] GnuPG - r4430 - branches/STABLE-BRANCH-1-4/util Message-ID: Author: wk Date: 2007-02-12 15:13:37 +0100 (Mon, 12 Feb 2007) New Revision: 4430 Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/secmem.c Log: * secmem.c (ptr_into_pool_p): New. (m_is_secure): Implement in terms of above. Also check that the pool has been initialized. Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-11 03:56:59 UTC (rev 4429) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-12 14:13:37 UTC (rev 4430) @@ -1,3 +1,9 @@ +2007-02-12 Werner Koch + + * secmem.c (ptr_into_pool_p): New. + (m_is_secure): Implement in terms of above. Also check that the + pool has been initialized. + 2007-02-10 David Shaw * http.c (do_parse_uri): Remove the hkp port 11371 detection. We Modified: branches/STABLE-BRANCH-1-4/util/secmem.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/secmem.c 2007-02-11 03:56:59 UTC (rev 4429) +++ branches/STABLE-BRANCH-1-4/util/secmem.c 2007-02-12 14:13:37 UTC (rev 4430) @@ -449,10 +449,27 @@ cur_alloced -= size; } + +/* Check whether P points into the pool. */ +static int +ptr_into_pool_p (const void *p) +{ + /* We need to convert pointers to addresses. This is required by + C-99 6.5.8 to avoid undefined behaviour. Using size_t is at + least only implementation defined. See also + http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html + */ + size_t p_addr = (size_t)p; + size_t pool_addr = (size_t)pool; + + return p_addr >= pool_addr && p_addr < pool_addr+poolsize; +} + + int m_is_secure( const void *p ) { - return p >= pool && p < (void*)((char*)pool+poolsize); + return pool_okay && ptr_into_pool_p (p); } From cvs at cvs.gnupg.org Mon Feb 12 15:05:42 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 12 Feb 2007 15:05:42 +0100 Subject: [svn] gcry - r1211 - branches/LIBGCRYPT-1-2-BRANCH/src Message-ID: Author: wk Date: 2007-02-12 15:05:42 +0100 (Mon, 12 Feb 2007) New Revision: 1211 Modified: branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog branches/LIBGCRYPT-1-2-BRANCH/src/gcrypt.h.in branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c Log: 2007-02-12 Werner Koch * gcrypt.h.in: Include stdlib.h for the sake fo the trheading macros. Suggested by Andreas Metzler. 2007-02-04 Werner Koch * secmem.c (ptr_into_pool_p): New. (_gcry_private_is_secure): Implement in terms of new function. (BLOCK_VALID): Removed. Replaced all users by new function. Modified: branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog 2007-02-12 14:03:48 UTC (rev 1210) +++ branches/LIBGCRYPT-1-2-BRANCH/src/ChangeLog 2007-02-12 14:05:42 UTC (rev 1211) @@ -1,3 +1,14 @@ +2007-02-12 Werner Koch + + * gcrypt.h.in: Include stdlib.h for the sake fo the trheading + macros. Suggested by Andreas Metzler. + +2007-02-04 Werner Koch + + * secmem.c (ptr_into_pool_p): New. + (_gcry_private_is_secure): Implement in terms of new function. + (BLOCK_VALID): Removed. Replaced all users by new function. + 2007-02-01 Werner Koch * secmem.c (_gcry_private_is_secure): Trapped by gcc, void* has a Modified: branches/LIBGCRYPT-1-2-BRANCH/src/gcrypt.h.in =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/gcrypt.h.in 2007-02-12 14:03:48 UTC (rev 1210) +++ branches/LIBGCRYPT-1-2-BRANCH/src/gcrypt.h.in 2007-02-12 14:05:42 UTC (rev 1211) @@ -23,6 +23,7 @@ #ifndef _GCRYPT_H #define _GCRYPT_H +#include #include #include Modified: branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-02-12 14:03:48 UTC (rev 1210) +++ branches/LIBGCRYPT-1-2-BRANCH/src/secmem.c 2007-02-12 14:05:42 UTC (rev 1211) @@ -98,10 +98,21 @@ #define ADDR_TO_BLOCK(addr) \ (memblock_t *) ((char *) addr - BLOCK_HEAD_SIZE) -/* Check wether MB is a valid block. */ -#define BLOCK_VALID(mb) \ - (((char *) mb - (char *) pool) < pool_size) +/* Check whether P points into the pool. */ +static int +ptr_into_pool_p (const void *p) +{ + /* We need to convert pointers to addresses. This is required by + C-99 6.5.8 to avoid undefeined behavious. Using size_t is at + least only implementation defined. See also + http://lists.gnupg.org/pipermail/gcrypt-devel/2007-February/001102.html + */ + size_t p_addr = (size_t)p; + size_t pool_addr = (size_t)pool; + return p_addr >= pool_addr && p_addr < pool_addr+pool_size; +} + /* Update the stats. */ static void stats_update (size_t add, size_t sub) @@ -126,7 +137,7 @@ mb_next = (memblock_t *) ((char *) mb + BLOCK_HEAD_SIZE + mb->size); - if (! BLOCK_VALID (mb_next)) + if (! ptr_into_pool_p (mb_next)) mb_next = NULL; return mb_next; @@ -182,7 +193,7 @@ { memblock_t *mb, *mb_split; - for (mb = block; BLOCK_VALID (mb); mb = mb_get_next (mb)) + for (mb = block; ptr_into_pool_p (mb); mb = mb_get_next (mb)) if (! (mb->flags & MB_FLAG_ACTIVE) && mb->size >= size) { /* Found a free block. */ @@ -205,7 +216,7 @@ break; } - if (! BLOCK_VALID (mb)) + if (! ptr_into_pool_p (mb)) mb = NULL; return mb; @@ -587,9 +598,7 @@ int _gcry_private_is_secure (const void *p) { - return (pool_okay - && p >= pool - && p < (void*)((char*)pool+pool_size)); + return pool_okay && ptr_into_pool_p (p); } @@ -639,7 +648,7 @@ SECMEM_LOCK; for (i = 0, mb = (memblock_t *) pool; - BLOCK_VALID (mb); + ptr_into_pool_p (mb); mb = mb_get_next (mb), i++) log_info ("SECMEM: [%s] block: %i; size: %i\n", (mb->flags & MB_FLAG_ACTIVE) ? "used" : "free", From cvs at cvs.gnupg.org Wed Feb 14 04:41:28 2007 From: cvs at cvs.gnupg.org (svn author dshaw) Date: Wed, 14 Feb 2007 04:41:28 +0100 Subject: [svn] GnuPG - r4431 - branches/STABLE-BRANCH-1-4/g10 Message-ID: Author: dshaw Date: 2007-02-14 04:41:24 +0100 (Wed, 14 Feb 2007) New Revision: 4431 Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog branches/STABLE-BRANCH-1-4/g10/getkey.c branches/STABLE-BRANCH-1-4/g10/parse-packet.c Log: * parse-packet.c (parse_signature): It's hex. * getkey.c (merge_selfsigs_subkey): Avoid listing the contents of a backsig when list mode is on. Noted by Timo Schulz. Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-12 14:13:37 UTC (rev 4430) +++ branches/STABLE-BRANCH-1-4/g10/ChangeLog 2007-02-14 03:41:24 UTC (rev 4431) @@ -1,3 +1,10 @@ +2007-02-13 David Shaw + + * parse-packet.c (parse_signature): It's hex. + + * getkey.c (merge_selfsigs_subkey): Avoid listing the contents of + a backsig when list mode is on. Noted by Timo Schulz. + 2007-02-04 Werner Koch * parse-packet.c (parse_signature): Limit bytes read for an Modified: branches/STABLE-BRANCH-1-4/g10/getkey.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/getkey.c 2007-02-12 14:13:37 UTC (rev 4430) +++ branches/STABLE-BRANCH-1-4/g10/getkey.c 2007-02-14 03:41:24 UTC (rev 4431) @@ -2169,6 +2169,7 @@ { PKT_signature *backsig=xmalloc_clear(sizeof(PKT_signature)); IOBUF backsig_buf=iobuf_temp_with_content(p,n); + int save_mode=set_packet_list_mode(0); if(parse_signature(backsig_buf,PKT_SIGNATURE,n,backsig)==0) { @@ -2178,6 +2179,8 @@ subpk->backsig=1; } + set_packet_list_mode(save_mode); + iobuf_close(backsig_buf); free_seckey_enc(backsig); } Modified: branches/STABLE-BRANCH-1-4/g10/parse-packet.c =================================================================== --- branches/STABLE-BRANCH-1-4/g10/parse-packet.c 2007-02-12 14:13:37 UTC (rev 4430) +++ branches/STABLE-BRANCH-1-4/g10/parse-packet.c 2007-02-14 03:41:24 UTC (rev 4431) @@ -1424,7 +1424,7 @@ if( list_mode ) { fprintf (listfp, ":signature packet: algo %d, keyid %08lX%08lX\n" - "\tversion %d, created %lu, md5len %d, sigclass %02x\n" + "\tversion %d, created %lu, md5len %d, sigclass 0x%02x\n" "\tdigest algo %d, begin of digest %02x %02x\n", sig->pubkey_algo, (ulong)sig->keyid[0], (ulong)sig->keyid[1], From cvs at cvs.gnupg.org Wed Feb 14 17:24:03 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Feb 2007 17:24:03 +0100 Subject: [svn] pinentry - r155 - in trunk: . pinentry Message-ID: Author: wk Date: 2007-02-14 17:24:02 +0100 (Wed, 14 Feb 2007) New Revision: 155 Modified: trunk/ChangeLog trunk/NEWS trunk/configure.ac trunk/pinentry/pinentry-curses.c trunk/pinentry/pinentry.c trunk/pinentry/pinentry.h Log: * pinentry/pinentry.h (struct pinentry): Add TOUCH_FILE. * pinentry/pinentry.c (option_handler): New option "touch-file". (pinentry_have_display): Ignore an empty DISPLAY. * pinentry/pinentry-curses.c (do_touch_file): New. (curses_cmd_handler): Call it. * configure.ac: Check for utime.h. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/ChangeLog 2007-02-14 16:24:02 UTC (rev 155) @@ -1,3 +1,12 @@ +2007-02-14 Werner Koch + + * pinentry/pinentry.h (struct pinentry): Add TOUCH_FILE. + * pinentry/pinentry.c (option_handler): New option "touch-file". + (pinentry_have_display): Ignore an empty DISPLAY. + * pinentry/pinentry-curses.c (do_touch_file): New. + (curses_cmd_handler): Call it. + * configure.ac: Check for utime.h. + 2007-01-24 Werner Koch * pinentry/pinentry.c (cmd_message): New. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/NEWS 2007-02-14 16:24:02 UTC (rev 155) @@ -4,7 +4,10 @@ * New command MESSAGE and --one-button compatibility option to CONFIRM. + * New Assuan option touch-file to set a file which will be touched + after ncurses does not need the display anymore. + Noteworthy changes in version 0.7.2 (2005-01-27) ------------------------------------------------ Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/configure.ac 2007-02-14 16:24:02 UTC (rev 155) @@ -102,7 +102,7 @@ # Checks for header files. AC_HEADER_STDC -AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h) +AC_CHECK_HEADERS(string.h unistd.h langinfo.h termio.h locale.h utime.h) dnl Checks for library functions. AC_CHECK_FUNCS(seteuid stpcpy mmap) Modified: trunk/pinentry/pinentry-curses.c =================================================================== --- trunk/pinentry/pinentry-curses.c 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/pinentry/pinentry-curses.c 2007-02-14 16:24:02 UTC (rev 155) @@ -33,6 +33,12 @@ #include #include #include +#include +#include +#include +#ifdef HAVE_UTIME_H +#include +#endif /*HAVE_UTIME_H*/ #include @@ -723,8 +729,38 @@ return diag.pin ? (done < 0 ? -1 : diag.pin_len) : (done < 0 ? 0 : 1); } + +/* If a touch has been registered, touch that file. */ +static void +do_touch_file (pinentry_t pinentry) +{ +#ifdef HAVE_UTIME_H + struct stat st; + time_t tim; + + if (!pinentry->touch_file || !*pinentry->touch_file) + return; + + if (stat (pinentry->touch_file, &st)) + return; /* Oops. */ + + /* Make sure that we actually update the mtime. */ + while ( (tim = time (NULL)) == st.st_mtime ) + sleep (1); + + /* Update but ignore errors as we can't do anything in that case. + Printing error messages may even clubber the display further. */ + utime (pinentry->touch_file, NULL); +#endif /*HAVE_UTIME_H*/ +} + + int curses_cmd_handler (pinentry_t pinentry) { - return dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype); + int rc; + + rc = dialog_run (pinentry, pinentry->ttyname, pinentry->ttytype); + do_touch_file (pinentry); + return rc; } Modified: trunk/pinentry/pinentry.c =================================================================== --- trunk/pinentry/pinentry.c 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/pinentry/pinentry.c 2007-02-14 16:24:02 UTC (rev 155) @@ -65,6 +65,7 @@ 0, /* Enhanced mode. */ 1, /* Global grab. */ 0, /* Parent Window ID. */ + NULL, /* Touch file. */ 0, /* Result. */ 0, /* Locale error flag. */ 0 /* One-button flag. */ @@ -256,7 +257,10 @@ int pinentry_have_display (int argc, char **argv) { - if (getenv ("DISPLAY")) + const char *s; + + s = getenv ("DISPLAY"); + if (s && *s) return 1; for (; argc; argc--, argv++) if (!strcmp (*argv, "--display")) @@ -451,6 +455,14 @@ pinentry.parent_wid = atoi (value); /* FIXME: Use strtol and add some error handling. */ } + else if (!strcmp (key, "touch-file")) + { + if (pinentry.touch_file) + free (pinentry.touch_file); + pinentry.touch_file = strdup (value); + if (!pinentry.touch_file) + return ASSUAN_Out_Of_Core; + } else return ASSUAN_Invalid_Option; return 0; Modified: trunk/pinentry/pinentry.h =================================================================== --- trunk/pinentry/pinentry.h 2007-01-24 18:25:10 UTC (rev 154) +++ trunk/pinentry/pinentry.h 2007-02-14 16:24:02 UTC (rev 155) @@ -67,6 +67,10 @@ should be displayed. */ int parent_wid; + /* The name of an optional file which will be touched after a curses + entry has been displayed. */ + char *touch_file; + /* The user should set this to -1 if the user canceled the request, and to the length of the PIN stored in pin otherwise. */ int result; From cvs at cvs.gnupg.org Wed Feb 14 17:25:39 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Feb 2007 17:25:39 +0100 Subject: [svn] GnuPG - r4432 - trunk/scd Message-ID: Author: wk Date: 2007-02-14 17:25:38 +0100 (Wed, 14 Feb 2007) New Revision: 4432 Modified: trunk/scd/app-nks.c Log: Typo fixes Modified: trunk/scd/app-nks.c =================================================================== --- trunk/scd/app-nks.c 2007-02-14 03:41:24 UTC (rev 4431) +++ trunk/scd/app-nks.c 2007-02-14 16:25:38 UTC (rev 4432) @@ -33,7 +33,8 @@ #include "app-common.h" #include "tlv.h" -static struct { +static struct +{ int fid; /* File ID. */ int certtype; /* Type of certificate or 0 if it is not a certificate. */ int iskeypair; /* If true has the FID of the correspoding certificate. */ @@ -208,8 +209,8 @@ /* If the requested objects is a plain public key, redirect it to the corresponding certificate. The whole system is a bit messy - becuase we sometime use the key directly or let the caller - retrieve the key from the certificate. The valid point behind + because we sometime use the key directly or let the caller + retrieve the key from the certificate. The rationale for that is to support not-yet stored certificates. */ if (filelist[i].iskeypair) fid = filelist[i].iskeypair; @@ -385,7 +386,7 @@ return gpg_error (GPG_ERR_INV_VALUE); /* Check that the provided ID is vaid. This is not really needed - but we do it to to enforce correct usage by the caller. */ + but we do it to enforce correct usage by the caller. */ if (strncmp (keyidstr, "NKS-DF01.", 9) ) return gpg_error (GPG_ERR_INV_ID); keyidstr += 9; @@ -488,7 +489,7 @@ -/* Select the NKS 2.0 application on the card in SLOT. */ +/* Select the NKS 2.0 application. */ gpg_error_t app_select_nks (app_t app) { From cvs at cvs.gnupg.org Wed Feb 14 17:26:06 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Feb 2007 17:26:06 +0100 Subject: [svn] GnuPG - r4433 - trunk/g10 Message-ID: Author: wk Date: 2007-02-14 17:26:05 +0100 (Wed, 14 Feb 2007) New Revision: 4433 Modified: trunk/g10/ChangeLog trunk/g10/export.c Log: * export.c (do_export_stream): Allow reset-subkey-passwd along with sexp-format. Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-02-14 16:25:38 UTC (rev 4432) +++ trunk/g10/ChangeLog 2007-02-14 16:26:05 UTC (rev 4433) @@ -1,3 +1,8 @@ +2007-02-06 Werner Koch + + * export.c (do_export_stream): Allow reset-subkey-passwd along + with sexp-format. + 2007-02-04 Werner Koch * parse-packet.c (parse_signature): Limit bytes read for an Modified: trunk/g10/export.c =================================================================== --- trunk/g10/export.c 2007-02-14 16:25:38 UTC (rev 4432) +++ trunk/g10/export.c 2007-02-14 16:26:05 UTC (rev 4433) @@ -564,7 +564,10 @@ goto leave; } - rc = build_packet (out, node->pkt); + if ((options&EXPORT_SEXP_FORMAT)) + rc = build_sexp (out, node->pkt, &indent); + else + rc = build_packet (out, node->pkt); node->pkt->pkt.secret_key = sk_save; free_secret_key (sk); From cvs at cvs.gnupg.org Wed Feb 14 17:27:56 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 14 Feb 2007 17:27:56 +0100 Subject: [svn] GnuPG - r4434 - in trunk: agent doc Message-ID: Author: wk Date: 2007-02-14 17:27:55 +0100 (Wed, 14 Feb 2007) New Revision: 4434 Modified: trunk/agent/ChangeLog trunk/agent/agent.h trunk/agent/call-pinentry.c trunk/agent/gpg-agent.c trunk/doc/ChangeLog trunk/doc/gpg-agent.texi trunk/doc/scdaemon.texi Log: agent/ * gpg-agent.c: New option --pinentry-touch-file. (get_agent_socket_name): New. * agent.h (opt): Add pinentry_touch_file. * call-pinentry.c (start_pinentry): Send new option to the pinentry. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/agent/ChangeLog 2007-02-14 16:27:55 UTC (rev 4434) @@ -1,3 +1,11 @@ +2007-02-14 Werner Koch + + * gpg-agent.c: New option --pinentry-touch-file. + (get_agent_socket_name): New. + * agent.h (opt): Add pinentry_touch_file. + * call-pinentry.c (start_pinentry): Send new option to the + pinentry. + 2007-01-31 Moritz Schulte (wk) * command-ssh.c (stream_read_string): Initialize LENGTH to zero. Modified: trunk/agent/agent.h =================================================================== --- trunk/agent/agent.h 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/agent/agent.h 2007-02-14 16:27:55 UTC (rev 4434) @@ -72,6 +72,10 @@ int disable_scdaemon; /* Never use the SCdaemon. */ int no_grab; /* Don't let the pinentry grab the keyboard */ + /* The name of the file pinentry shall tocuh before exiting. If + this is not set the filoe name of the standard socket is used. */ + const char *pinentry_touch_file; + /* The default and maximum TTL of cache entries. */ unsigned long def_cache_ttl; /* Default. */ unsigned long def_cache_ttl_ssh; /* for SSH. */ @@ -186,6 +190,7 @@ /*-- gpg-agent.c --*/ void agent_exit (int rc) JNLIB_GCC_A_NR; /* Also implemented in other tools */ +const char *get_agent_socket_name (void); /*-- command.c --*/ gpg_error_t agent_write_status (ctrl_t ctrl, const char *keyword, ...); Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/agent/call-pinentry.c 2007-02-14 16:27:55 UTC (rev 4434) @@ -181,6 +181,7 @@ int no_close_list[3]; int i; pth_event_t evt; + const char *tmpstr; evt = pth_event (PTH_EVENT_TIME, pth_timeout (LOCK_TIMEOUT, 0)); if (!pth_mutex_acquire (&entry_lock, 0, evt)) @@ -297,6 +298,30 @@ if (rc) return unlock_pinentry (rc); } + + + /* Tell the pinentry the name of a file it shall touch after having + messed with the tty. This is optional and only supported by + newer pinentries and thus we do no error checking. */ + tmpstr = opt.pinentry_touch_file; + if (tmpstr && !strcmp (tmpstr, "/dev/null")) + tmpstr = NULL; + else if (!tmpstr) + tmpstr = get_agent_socket_name (); + if (tmpstr) + { + char *optstr; + + if (asprintf (&optstr, "OPTION touch-file=%s", tmpstr ) < 0 ) + ; + else + { + assuan_transact (entry_ctx, optstr, NULL, NULL, NULL, NULL, NULL, + NULL); + free (optstr); + } + } + return 0; } Modified: trunk/agent/gpg-agent.c =================================================================== --- trunk/agent/gpg-agent.c 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/agent/gpg-agent.c 2007-02-14 16:27:55 UTC (rev 4434) @@ -78,6 +78,7 @@ oBatch, oPinentryProgram, + oPinentryTouchFile, oDisplay, oTTYname, oTTYtype, @@ -131,6 +132,7 @@ { oPinentryProgram, "pinentry-program", 2 , N_("|PGM|use PGM as the PIN-Entry program") }, + { oPinentryTouchFile, "pinentry-touch-file", 2 , "@" }, { oScdaemonProgram, "scdaemon-program", 2 , N_("|PGM|use PGM as the SCdaemon program") }, { oDisableScdaemon, "disable-scdaemon", 0, N_("do not use the SCdaemon") }, @@ -401,6 +403,7 @@ opt.debug = 0; opt.no_grab = 0; opt.pinentry_program = NULL; + opt.pinentry_touch_file = NULL; opt.scdaemon_program = NULL; opt.def_cache_ttl = DEFAULT_CACHE_TTL; opt.def_cache_ttl_ssh = DEFAULT_CACHE_TTL_SSH; @@ -437,6 +440,7 @@ case oNoGrab: opt.no_grab = 1; break; case oPinentryProgram: opt.pinentry_program = pargs->r.ret_str; break; + case oPinentryTouchFile: opt.pinentry_touch_file = pargs->r.ret_str; break; case oScdaemonProgram: opt.scdaemon_program = pargs->r.ret_str; break; case oDisableScdaemon: opt.disable_scdaemon = 1; break; @@ -1186,8 +1190,18 @@ } +/* Return the file name of the socket we are using for native + requests. */ +const char * +get_agent_socket_name (void) +{ + const char *s = socket_name; + return (s && *s)? s : NULL; +} + + /* Create a name for the socket. With USE_STANDARD_SOCKET given as true using STANDARD_NAME in the home directory or if given has false from the mkdir type name TEMPLATE. In the latter case a Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/doc/ChangeLog 2007-02-14 16:27:55 UTC (rev 4434) @@ -1,3 +1,7 @@ +2007-02-14 Werner Koch + + * gpg-agent.texi (Agent Options): Doc --pinentry-touch-file. + 2007-02-05 Werner Koch * debugging.texi (Common Problems): Tell how to export a private Modified: trunk/doc/gpg-agent.texi =================================================================== --- trunk/doc/gpg-agent.texi 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/doc/gpg-agent.texi 2007-02-14 16:27:55 UTC (rev 4434) @@ -344,6 +344,17 @@ Use program @var{filename} as the PIN entry. The default is installation dependend and can be shown with the @code{--version} command. + at item --pinentry-touch-file @var{filename} + at opindex pinentry-touch-file +By default the file name of the socket gpg-agent is listening for +requests is passed to Pinentry, so that it can touch that file before +exiting (it does this only in curses mode). This option changes the +file passed to Pinentry to @var{filename}. The special name + at code{/dev/null} may be used to completely disable this feature. Note +that Pinentry will not create that file, it will only change the +modification and access time. + + @item --scdaemon-program @var{filename} @opindex scdaemon-program Use program @var{filename} as the Smartcard daemon. The default is Modified: trunk/doc/scdaemon.texi =================================================================== --- trunk/doc/scdaemon.texi 2007-02-14 16:26:05 UTC (rev 4433) +++ trunk/doc/scdaemon.texi 2007-02-14 16:27:55 UTC (rev 4434) @@ -311,7 +311,7 @@ @subsection The DINSIG card application ``dinsig'' This is an application as described in the German draft standard - at emph{DIN V 66291-1}. It is intended to be used by cards supporteing + at emph{DIN V 66291-1}. It is intended to be used by cards supporting the German signature law and its bylaws (SigG and SigV). @node PKCS#15 Card From cvs at cvs.gnupg.org Sun Feb 18 14:48:04 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Sun, 18 Feb 2007 14:48:04 +0100 Subject: [svn] GnuPG - r4435 - in trunk: . doc scd Message-ID: Author: wk Date: 2007-02-18 14:48:03 +0100 (Sun, 18 Feb 2007) New Revision: 4435 Modified: trunk/NEWS trunk/doc/ChangeLog trunk/doc/gpg.texi trunk/scd/ChangeLog trunk/scd/scdaemon.c Log: doc/ * gpg.texi (GPG Esoteric Options): No card reader options for gpg2. scd/ * scdaemon.c (DEFAULT_PCSC_DRIVER): Add a default for OS X. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-02-14 16:27:55 UTC (rev 4434) +++ trunk/NEWS 2007-02-18 13:48:03 UTC (rev 4435) @@ -10,7 +10,7 @@ * Using a PIN pad does now also work for the signing key. - * A warning is displayed bu gpg-agent if a new passphrase is too + * A warning is displayed by gpg-agent if a new passphrase is too short. New option --min-passphrase-len defaults to 8. * The status code BEGIN_SIGNING now shows the used hash algorithms. Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-02-14 16:27:55 UTC (rev 4434) +++ trunk/doc/ChangeLog 2007-02-18 13:48:03 UTC (rev 4435) @@ -1,3 +1,7 @@ +2007-02-18 Werner Koch + + * gpg.texi (GPG Esoteric Options): No card reader options for gpg2. + 2007-02-14 Werner Koch * gpg-agent.texi (Agent Options): Doc --pinentry-touch-file. Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2007-02-14 16:27:55 UTC (rev 4434) +++ trunk/doc/gpg.texi 2007-02-18 13:48:03 UTC (rev 4435) @@ -1076,18 +1076,23 @@ @include opt-homedir.texi + at ifset gpgone @item --pcsc-driver @code{file} Use @code{file} to access the smartcard reader. The current default is `libpcsclite.so.1' for GLIBC based systems, `/System/Library/Frameworks/PCSC.framework/PCSC' for MAC OS X, `winscard.dll' for Windows and `libpcsclite.so' for other systems. + at end ifset + at ifset gpgone @item --disable-ccid Disable the integrated support for CCID compliant readers. This allows to fall back to one of the other drivers even if the internal CCID driver can handle the reader. Note, that CCID support is only available if libusb was available at build time. + at end ifset + at ifset gpgone @item --reader-port @code{number_or_string} This option may be used to specify the port of the card terminal. A value of 0 refers to the first serial device; add 32768 to access USB @@ -1095,6 +1100,7 @@ readers might need a string here; run the program in verbose mode to get a list of available readers. The default is then the first reader found. + at end ifset @item --display-charset @code{name} Set the name of the native character set. This is used to convert @@ -2451,10 +2457,12 @@ keyring a given key resides on. This option is deprecated: use @option{--list-options [no-]show-keyring} instead. + at ifset gpgone @item --ctapi-driver @code{file} Use @code{file} to access the smartcard reader. The current default is `libtowitoko.so'. Note that the use of this interface is deprecated; it may be removed in future releases. + at end ifset @item --always-trust Identical to @option{--trust-model always}. This option is deprecated. Modified: trunk/scd/ChangeLog =================================================================== --- trunk/scd/ChangeLog 2007-02-14 16:27:55 UTC (rev 4434) +++ trunk/scd/ChangeLog 2007-02-18 13:48:03 UTC (rev 4435) @@ -1,3 +1,7 @@ +2007-02-18 Werner Koch + + * scdaemon.c (DEFAULT_PCSC_DRIVER): Add a default for OS X. + 2007-01-25 Werner Koch * Makefile.am (scdaemon_LDADD): Added LIBICONV. Noted by Billy Modified: trunk/scd/scdaemon.c =================================================================== --- trunk/scd/scdaemon.c 2007-02-14 16:27:55 UTC (rev 4434) +++ trunk/scd/scdaemon.c 2007-02-18 13:48:03 UTC (rev 4435) @@ -139,9 +139,11 @@ }; -/* The card dirver we use by default for PC/SC. */ +/* The card driver we use by default for PC/SC. */ #if defined(HAVE_W32_SYSTEM) || defined(__CYGWIN__) #define DEFAULT_PCSC_DRIVER "winscard.dll" +#elif defined(__APPLE__) +#define DEFAULT_PCSC_DRIVER "/System/Library/Frameworks/PCSC.framework/PCSC" #elif defined(__GLIBC__) #define DEFAULT_PCSC_DRIVER "libpcsclite.so.1" #else From cvs at cvs.gnupg.org Tue Feb 20 12:28:14 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Feb 2007 12:28:14 +0100 Subject: [svn] gcry - r1212 - trunk Message-ID: Author: wk Date: 2007-02-20 12:28:12 +0100 (Tue, 20 Feb 2007) New Revision: 1212 Modified: trunk/ChangeLog trunk/README trunk/THANKS trunk/TODO trunk/configure.ac Log: New configure option --disable-endian-check. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-02-12 14:05:42 UTC (rev 1211) +++ trunk/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) @@ -1,3 +1,11 @@ +2007-02-20 Werner Koch + + * configure.ac: New option --disable-endian-check. + +2007-02-02 Werner Koch + + * configure.ac (FALLBACK_SOCKLEN_T): Special case for mingw32. + 2006-11-15 Werner Koch * autogen.sh: Add convenience option --build-amd64. Modified: trunk/README =================================================================== --- trunk/README 2007-02-12 14:05:42 UTC (rev 1211) +++ trunk/README 2007-02-20 11:28:12 UTC (rev 1212) @@ -114,6 +114,12 @@ to select exactly those algorithm modules, which should be built. + --disable-endian-check + Don't let configure test for the endianness but + try to use the OS provided macros at compile + time. This is helpful to create OS X fat binaries. + + Contact ------- Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-02-12 14:05:42 UTC (rev 1211) +++ trunk/THANKS 2007-02-20 11:28:12 UTC (rev 1212) @@ -4,6 +4,7 @@ Allan Clark allanc at sco.com Anand Kumria wildfire at progsoc.uts.edu.au +Andreas Metzler ametzler at downhill.at.eu.org Ariel T Glenn ariel at columbia.edu Bodo Moeller Bodo_Moeller at public.uni-hamburg.de Brenno de Winter brenno at dewinter.com Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-02-12 14:05:42 UTC (rev 1211) +++ trunk/TODO 2007-02-20 11:28:12 UTC (rev 1212) @@ -77,5 +77,7 @@ * gcryptrnd.c Requires test for pth and other stuff. +* secmem.c + Check whether the memory block is valid before releasing it and + print a diagnosic, like glibc does. - Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-02-12 14:05:42 UTC (rev 1211) +++ trunk/configure.ac 2007-02-20 11:28:12 UTC (rev 1212) @@ -60,6 +60,19 @@ AH_BOTTOM([ #define _GCRYPT_IN_LIBGCRYPT 1 + +/* If the configure check for endianness has been disabled, get it from + OS macros. This is intended for making fat binary builds on OS X. */ +#ifdef DISABLED_ENDIAN_CHECK +# if defined(__BIG_ENDIAN__) +# define WORDS_BIGENDIAN 1 +# elif defined(__LITTLE_ENDIAN__) +# undef WORDS_BIGENDIAN +# else +# error "No endianness found" +# endif +#endif /*DISABLED_ENDIAN_CHECK*/ + ]) AH_VERBATIM([_REENTRANT], @@ -247,8 +260,17 @@ esac -AC_C_BIGENDIAN +AC_ARG_ENABLE(endian-check, + AC_HELP_STRING([--disable-endian-check], + [disable the endian check and trust the OS provided macros]), + endiancheck=$enableval,endiancheck=yes) +if test x"$endiancheck" = xyes ; then + AC_C_BIGENDIAN +else + AC_DEFINE(DISABLED_ENDIAN_CHECK,1,[configure did not test for endianess]) +fi + AC_CHECK_SIZEOF(unsigned short, 2) AC_CHECK_SIZEOF(unsigned int, 4) AC_CHECK_SIZEOF(unsigned long, 4) @@ -521,14 +543,23 @@ GNUPG_CHECK_TYPEDEF(u32, HAVE_U32_TYPEDEF) gl_TYPE_SOCKLEN_T -if test ".$gl_cv_socklen_t_equiv" = "."; then - FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;" -else - FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;" -fi +case "${host}" in + *-*-mingw32*) + # socklen_t may or may not be defined depending on what headers + # are included. To be safe we use int as this is the actual type. + FALLBACK_SOCKLEN_T="typedef int gcry_socklen_t;" + ;; + *) + if test ".$gl_cv_socklen_t_equiv" = "."; then + FALLBACK_SOCKLEN_T="typedef socklen_t gcry_socklen_t;" + else + FALLBACK_SOCKLEN_T="typedef ${gl_cv_socklen_t_equiv} gcry_socklen_t;" + fi +esac AC_SUBST(FALLBACK_SOCKLEN_T) + ####################################### #### Checks for library functions. #### ####################################### From cvs at cvs.gnupg.org Tue Feb 20 15:55:32 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Tue, 20 Feb 2007 15:55:32 +0100 Subject: [svn] GnuPG - r4436 - trunk/agent Message-ID: Author: wk Date: 2007-02-20 15:55:32 +0100 (Tue, 20 Feb 2007) New Revision: 4436 Modified: trunk/agent/ChangeLog trunk/agent/call-pinentry.c Log: * call-pinentry.c (start_pinentry): Fix for OS X to allow loading of the bundle. Tested by Benjamin Donnachie. Modified: trunk/agent/ChangeLog =================================================================== --- trunk/agent/ChangeLog 2007-02-18 13:48:03 UTC (rev 4435) +++ trunk/agent/ChangeLog 2007-02-20 14:55:32 UTC (rev 4436) @@ -1,3 +1,8 @@ +2007-02-20 Werner Koch + + * call-pinentry.c (start_pinentry): Fix for OS X to allow loading + of the bundle. Tested by Benjamin Donnachie. + 2007-02-14 Werner Koch * gpg-agent.c: New option --pinentry-touch-file. Modified: trunk/agent/call-pinentry.c =================================================================== --- trunk/agent/call-pinentry.c 2007-02-18 13:48:03 UTC (rev 4435) +++ trunk/agent/call-pinentry.c 2007-02-20 14:55:32 UTC (rev 4436) @@ -214,12 +214,21 @@ if (!opt.pinentry_program || !*opt.pinentry_program) opt.pinentry_program = GNUPG_DEFAULT_PINENTRY; + pgmname = opt.pinentry_program; if ( !(pgmname = strrchr (opt.pinentry_program, '/'))) pgmname = opt.pinentry_program; else pgmname++; + /* OS X needs the entire file name in argv[0], so that it can locate + the resource bundle. For other systems we stick to the the usual + convention of supplying only the name of the program. */ +#ifdef __APPLE__ + argv[0] = opt.pinentry_program; +#else /*!__APPLE__*/ argv[0] = pgmname; +#endif /*__APPLE__*/ + if (ctrl->display && !opt.keep_display) { argv[1] = "--display"; From cvs at cvs.gnupg.org Wed Feb 21 14:26:44 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Wed, 21 Feb 2007 14:26:44 +0100 Subject: [svn] gcry - r1213 - in trunk: . cipher doc m4 mpi src tests Message-ID: Author: wk Date: 2007-02-21 14:26:38 +0100 (Wed, 21 Feb 2007) New Revision: 1213 Added: trunk/m4/Makefile.am trunk/m4/noexecstack.m4 Modified: trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/README trunk/autogen.sh trunk/cipher/ trunk/cipher/ChangeLog trunk/cipher/ac.c trunk/cipher/blowfish.c trunk/cipher/cast5.c trunk/cipher/cipher.c trunk/cipher/crc.c trunk/cipher/dsa.c trunk/cipher/elgamal.c trunk/cipher/md.c trunk/cipher/md4.c trunk/cipher/md5.c trunk/cipher/primegen.c trunk/cipher/pubkey.c trunk/cipher/random-daemon.c trunk/cipher/random.c trunk/cipher/random.h trunk/cipher/rijndael.c trunk/cipher/rmd.h trunk/cipher/rmd160.c trunk/cipher/rndlinux.c trunk/cipher/rsa.c trunk/cipher/serpent.c trunk/cipher/sha1.c trunk/cipher/sha256.c trunk/cipher/sha512.c trunk/cipher/tiger.c trunk/cipher/twofish.c trunk/cipher/whirlpool.c trunk/configure.ac trunk/doc/ trunk/doc/gcrypt.texi trunk/m4/ChangeLog trunk/mpi/ trunk/mpi/ChangeLog trunk/mpi/mpicoder.c trunk/mpi/mpiutil.c trunk/src/ trunk/src/ChangeLog trunk/src/cipher.h trunk/src/gcrypt-module.h trunk/src/gcrypt.h.in trunk/src/gcryptrnd.c trunk/src/getrandom.c trunk/src/global.c trunk/src/libgcrypt.vers trunk/src/mpi.h trunk/src/sexp.c trunk/tests/ trunk/tests/ChangeLog trunk/tests/basic.c trunk/tests/hmac.c trunk/tests/keygen.c trunk/tests/keygrip.c trunk/tests/register.c trunk/tests/tsexp.c Log: A lot of cleanups as well as minor API changes. Ported some changes from 1.2 to here. Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,7 +1,13 @@ 2007-02-20 Werner Koch - * configure.ac: New option --disable-endian-check. + * configure.ac: Bump LT version to C14/A3/R0 in preparation for a + release. + * autogen.sh: Add option --force. + * configure.ac: New option --disable-endian-check. Use a real + noexecstack test instead of requiring an option. Add SVN version + magic. + 2007-02-02 Werner Koch * configure.ac (FALLBACK_SOCKLEN_T): Special case for mingw32. Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) @@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 -DIST_SUBDIRS = mpi cipher src doc tests w32-dll +DIST_SUBDIRS = m4 mpi cipher src doc tests w32-dll SUBDIRS = mpi cipher src doc tests EXTRA_DIST = BUGS autogen.sh README.apichanges README.SVN DISTCLEANFILES = Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/NEWS 2007-02-21 13:26:38 UTC (rev 1213) @@ -14,12 +14,17 @@ * Support for the SEED cipher. + * Support for OFB encryption mode. + * gcry_mpi_rshift does not anymore truncate the shift count. * Reserved algorithm ranges for use by applications. * Support for DSA2. + * The new function gcry_md_debug should be used instead of the + gcry_md_start_debug and gcry_md_stop_debug macros. + * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_fast_random_poll NEW @@ -32,6 +37,13 @@ GCRY_PK_USAGE_UNKN NEW gcry_mpi_scan CHANGED: Argument BUFFER is now void*. GCR_CIPHER_SEED NEW + gcry_pk_spec_t CHANGED (minor change, bug fix) + gcry_md_write_t CHANGED (minor change, bug fix) + gcry_md_debug NEW + gcry_cipher_encrypt CHANGED (minor change) + gcry_cipher_decrypt CHANGED (minor change) + gcry_randomize CHANGED (minor change) + gcry_cipher_register CHANGED (minor change) FIXME: Please add API changes immediatley so that we don't forget about them. Modified: trunk/README =================================================================== --- trunk/README 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/README 2007-02-21 13:26:38 UTC (rev 1213) @@ -6,7 +6,7 @@ version is 1.2.x. - Copyright 2000, 2002, 2003, 2004 Free Software Foundation, Inc. + Copyright 2000, 2002, 2003, 2004, 2007 Free Software Foundation, Inc. This file is free software; as a special exception the author gives unlimited permission to copy and/or distribute it, with or without Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/autogen.sh 2007-02-21 13:26:38 UTC (rev 1213) @@ -30,6 +30,11 @@ DIE=no +FORCE= +if test "$1" == "--force"; then + FORCE=" --force" + shift +fi # ***** W32 build script ******* # Used to cross-compile for Windows. @@ -189,7 +194,8 @@ $AUTOHEADER echo "Running automake --gnu ..." $AUTOMAKE --gnu; -echo "Running autoconf..." -$AUTOCONF +echo "Running autoconf${FORCE} ..." +$AUTOCONF${FORCE} echo "You may now run \"./configure --enable-maintainer-mode && make\"." +echo "(gcc users may want to add the option \"--enable-gcc-warnings\")" Property changes on: trunk/cipher ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,3 +1,45 @@ +2007-02-21 Werner Koch + + * random.c (rndpool, keypool): Make unsigned. + (mix_pool): Change char* variables to unsigned char*. + (gcry_randomize): Make arg BUFFER a void*. + (gcry_create_nonce): Ditto. + + * rmd160.c (gcry_rmd160_mixblock): Make BUFFER a void*. + (_gcry_rmd160_hash_buffer): Make OUTBUF and BUFFER void*. + * sha1.c (_gcry_sha1_hash_buffer): Ditto. + + * cipher.c (gcry_cipher_encrypt, cry_cipher_decrypt): Change + buffer args to void*. + (gcry_cipher_register): Make ALGORITHM_ID a int *. + + * md.c (md_start_debug): Make SUFFIX a const char*. Use snprintf. + (gcry_md_debug): New. + (gcry_md_ctl): Changed arg BUFFER from unsigned char*. + + * md.c (md_write): Make INBUF a const void*. + (gcry_md_write): Remove needless cast. + * crc.c (crc32_write): Make INBUF a const void* + (update_crc32, crc24rfc2440_write): Ditto. + * sha512.c (sha512_write, transform): Ditto. + * sha256.c (sha256_write, transform): Ditto. + * rmd160.c (rmd160_write, transform): Ditto. + * md5.c (md5_write, transform): Ditto. + * md4.c (md4_write, transform): Ditto. + * sha1.c (sha1_write, transform): Ditto. + + * tiger.c (tiger_write, transform): Ditto. + * whirlpool.c (whirlpool_write, whirlpool_add, transform): Ditto. + + * elgamal.c (elg_names): Change to a const*. + * dsa.c (dsa_names): Ditto. + * rsa.c (rsa_names): Ditto. + * pubkey.c (gcry_pk_lookup_func_name): Make ALIASES a const. + +2007-02-20 Werner Koch + + * rndlinux.c (open_device): Remove unsused arg MINOR. + 2007-01-30 Werner Koch * sha256.c (oid_spec_sha256): Add alias from pkcs#1. Modified: trunk/cipher/ac.c =================================================================== --- trunk/cipher/ac.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/ac.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -71,7 +71,7 @@ } ac_key_generate_specs[] = { { GCRY_AC_RSA, "rsa-use-e", offsetof (gcry_ac_key_spec_rsa_t, e) }, - { 0 }, + { 0 } }; /* Handle structure. */ @@ -1373,10 +1373,12 @@ /* Fill list with MPIs. */ for (i = 0; i < data_length; i++) { - /* FIXME!! */ - arg_list[(i * 2) + 0] = (data->data[i].name - ? (void **) &data->data[i].name - : (void **) &data->data[i].name_provided); + /* FIXME!! name_provided is a const char* whereas name is char. */ + char **nameaddr = (data->data[i].name + ? &data->data[i].name + : &data->data[i].name_provided); + + arg_list[(i * 2) + 0] = nameaddr; arg_list[(i * 2) + 1] = &data->data[i].mpi; } @@ -1552,6 +1554,8 @@ gcry_ac_key_t key_new; gcry_error_t err; + (void)handle; + /* Allocate. */ key_new = gcry_malloc (sizeof (*key_new)); if (! key_new) @@ -1617,6 +1621,8 @@ unsigned int i; unsigned int j; + (void)misc_data; + key_data_secret = NULL; key_data_public = NULL; key_secret = NULL; @@ -2415,6 +2421,8 @@ unsigned int ps_n; unsigned int k; + (void)flags; + options = opts; buffer = NULL; m = NULL; @@ -2487,6 +2495,8 @@ unsigned int i; unsigned int k; + (void)flags; + options = opts; buffer = NULL; em = NULL; @@ -2567,6 +2577,8 @@ unsigned char asn[100]; /* FIXME, always enough? */ size_t asn_n; unsigned int i; + + (void)flags; options = opts; buffer = NULL; @@ -2948,6 +2960,8 @@ unsigned int nbits; gcry_error_t err; + (void)opts; + err = _gcry_ac_key_get_nbits (handle, key, &nbits); if (err) goto out; @@ -3112,6 +3126,8 @@ void *opts_em; ac_scheme_t *scheme; + (void)flags; + data_encrypted = NULL; mpi_encrypted = NULL; mpi_plain = NULL; @@ -3217,6 +3233,8 @@ unsigned char *c; size_t c_n; + (void)flags; + data_encrypted = NULL; mpi_encrypted = NULL; mpi_decrypted = NULL; @@ -3341,6 +3359,8 @@ gcry_mpi_t mpi_signed; ac_scheme_t *scheme; + (void)flags; + data_signed = NULL; mpi_signed = NULL; opts_em = NULL; @@ -3448,6 +3468,8 @@ unsigned char *s; size_t s_n; + (void)flags; + mpi_signature = NULL; elements_sig = NULL; data_signed = NULL; Modified: trunk/cipher/blowfish.c =================================================================== --- trunk/cipher/blowfish.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/blowfish.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -601,5 +601,5 @@ { "BLOWFISH", NULL, NULL, BLOWFISH_BLOCKSIZE, 128, sizeof (BLOWFISH_context), - bf_setkey, encrypt_block, decrypt_block, + bf_setkey, encrypt_block, decrypt_block }; Modified: trunk/cipher/cast5.c =================================================================== --- trunk/cipher/cast5.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/cast5.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -616,5 +616,5 @@ gcry_cipher_spec_t _gcry_cipher_spec_cast5 = { "CAST5", NULL, NULL, CAST5_BLOCKSIZE, 128, sizeof (CAST5_context), - cast_setkey, encrypt_block, decrypt_block, + cast_setkey, encrypt_block, decrypt_block }; Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/cipher.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -75,7 +75,7 @@ #ifdef USE_SEED { &_gcry_cipher_spec_seed, GCRY_CIPHER_SEED }, #endif - { NULL }, + { NULL } }; /* List of registered ciphers. */ @@ -123,8 +123,11 @@ refuses to provide it's own functions. */ static gcry_err_code_t -dummy_setkey (void *c, const unsigned char *key, unsigned keylen) +dummy_setkey (void *c, const unsigned char *key, unsigned int keylen) { + (void)c; + (void)key; + (void)keylen; return GPG_ERR_NO_ERROR; } @@ -132,6 +135,9 @@ dummy_encrypt_block (void *c, unsigned char *outbuf, const unsigned char *inbuf) { + (void)c; + (void)outbuf; + (void)inbuf; BUG(); } @@ -139,6 +145,9 @@ dummy_decrypt_block (void *c, unsigned char *outbuf, const unsigned char *inbuf) { + (void)c; + (void)outbuf; + (void)inbuf; BUG(); } @@ -147,6 +156,10 @@ unsigned char *outbuf, const unsigned char *inbuf, unsigned int n) { + (void)c; + (void)outbuf; + (void)inbuf; + (void)n; BUG(); } @@ -155,6 +168,10 @@ unsigned char *outbuf, const unsigned char *inbuf, unsigned int n) { + (void)c; + (void)outbuf; + (void)inbuf; + (void)n; BUG(); } @@ -253,7 +270,7 @@ and a pointer representhing this module is stored in MODULE. */ gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher, - unsigned int *algorithm_id, + int *algorithm_id, gcry_module_t *module) { gcry_err_code_t err = 0; @@ -1172,15 +1189,15 @@ * been requested. */ gcry_error_t -gcry_cipher_encrypt (gcry_cipher_hd_t h, byte *out, size_t outsize, - const byte *in, size_t inlen) +gcry_cipher_encrypt (gcry_cipher_hd_t h, void *out, size_t outsize, + const void *in, size_t inlen) { gcry_err_code_t err; if (!in) /* Caller requested in-place encryption. */ - /* Actullay cipher_encrypt() does not need to know about it, but - * we may change this to get better performance. */ + /* Actually cipher_encrypt() does not need to know about it, but + * we may change it in the future to get better performance. */ err = cipher_encrypt (h, out, out, outsize); else if (outsize < ((h->flags & GCRY_CIPHER_CBC_MAC) ? h->cipher->blocksize : inlen)) @@ -1257,15 +1274,15 @@ gcry_error_t -gcry_cipher_decrypt (gcry_cipher_hd_t h, byte *out, size_t outsize, - const byte *in, size_t inlen) +gcry_cipher_decrypt (gcry_cipher_hd_t h, void *out, size_t outsize, + const void *in, size_t inlen) { - gcry_err_code_t err = GPG_ERR_NO_ERROR; + gcry_err_code_t err = 0; - if (! in) + if (!in) /* Caller requested in-place encryption. */ - /* Actullay cipher_encrypt() does not need to know about it, but - * we may chnage this to get better performance. */ + /* Actually cipher_encrypt() does not need to know about it, but + * we may change it in the future to get better performance. */ err = cipher_decrypt (h, out, out, outsize); else if (outsize < inlen) err = GPG_ERR_TOO_SHORT; @@ -1368,6 +1385,10 @@ { gcry_err_code_t err = GPG_ERR_NO_ERROR; + (void)h; + (void)buffer; + (void)nbytes; + switch (cmd) { default: Modified: trunk/cipher/crc.c =================================================================== --- trunk/cipher/crc.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/crc.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -129,8 +129,9 @@ * */ static u32 -update_crc32 (u32 crc, char *buf, size_t len) +update_crc32 (u32 crc, const void *buf_arg, size_t len) { + const char *buf = buf_arg; size_t n; for (n = 0; n < len; n++) @@ -156,7 +157,7 @@ } static void -crc32_write (void *context, byte * inbuf, size_t inlen) +crc32_write (void *context, const void *inbuf, size_t inlen) { CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; if (!inbuf) @@ -244,8 +245,9 @@ } static void -crc24rfc2440_write (void *context, byte * inbuf, size_t inlen) +crc24rfc2440_write (void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; int i; CRC_CONTEXT *ctx = (CRC_CONTEXT *) context; Modified: trunk/cipher/dsa.c =================================================================== --- trunk/cipher/dsa.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/dsa.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -398,6 +398,9 @@ gpg_err_code_t err; DSA_secret_key sk; + (void)algo; + (void)dummy; + err = generate (&sk, nbits, 0, retfactors); if (!err) { @@ -425,6 +428,9 @@ gpg_err_code_t err; DSA_secret_key sk; + (void)algo; + (void)dummy; + err = generate (&sk, nbits, qbits, retfactors); if (!err) { @@ -445,6 +451,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; DSA_secret_key sk; + (void)algo; + if ((! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]) || (! skey[4])) err = GPG_ERR_BAD_MPI; else @@ -468,6 +476,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; DSA_secret_key sk; + (void)algo; + if ((! data) || (! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3]) || (! skey[4])) @@ -493,6 +503,10 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; DSA_public_key pk; + (void)algo; + (void)cmp; + (void)opaquev; + if ((! data[0]) || (! data[1]) || (! hash) || (! pkey[0]) || (! pkey[1]) || (! pkey[2]) || (! pkey[3])) err = GPG_ERR_BAD_MPI; @@ -512,10 +526,12 @@ unsigned int _gcry_dsa_get_nbits (int algo, gcry_mpi_t *pkey) { + (void)algo; + return mpi_get_nbits (pkey[0]); } -static char *dsa_names[] = +static const char *dsa_names[] = { "dsa", "openpgp-dsa", Modified: trunk/cipher/elgamal.c =================================================================== --- trunk/cipher/elgamal.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/elgamal.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -528,6 +528,9 @@ { ELG_secret_key sk; + (void)algo; + (void)dummy; + generate (&sk, nbits, retfactors); skey[0] = sk.p; skey[1] = sk.g; @@ -544,6 +547,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; ELG_secret_key sk; + (void)algo; + if ((! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3])) err = GPG_ERR_BAD_MPI; else @@ -568,6 +573,9 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; ELG_public_key pk; + (void)algo; + (void)flags; + if ((! data) || (! pkey[0]) || (! pkey[1]) || (! pkey[2])) err = GPG_ERR_BAD_MPI; else @@ -590,6 +598,9 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; ELG_secret_key sk; + (void)algo; + (void)flags; + if ((! data[0]) || (! data[1]) || (! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3])) err = GPG_ERR_BAD_MPI; @@ -612,6 +623,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; ELG_secret_key sk; + (void)algo; + if ((! data) || (! skey[0]) || (! skey[1]) || (! skey[2]) || (! skey[3])) err = GPG_ERR_BAD_MPI; @@ -636,6 +649,10 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; ELG_public_key pk; + (void)algo; + (void)cmp; + (void)opaquev; + if ((! data[0]) || (! data[1]) || (! hash) || (! pkey[0]) || (! pkey[1]) || (! pkey[2])) err = GPG_ERR_BAD_MPI; @@ -655,10 +672,12 @@ unsigned int _gcry_elg_get_nbits (int algo, gcry_mpi_t *pkey) { + (void)algo; + return mpi_get_nbits (pkey[0]); } -static char *elg_names[] = +static const char *elg_names[] = { "elg", "openpgp-elg", Modified: trunk/cipher/md.c =================================================================== --- trunk/cipher/md.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/md.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -130,14 +130,14 @@ static gcry_err_code_t md_enable (gcry_md_hd_t hd, int algo); static gcry_err_code_t md_copy (gcry_md_hd_t a, gcry_md_hd_t *b); static void md_close (gcry_md_hd_t a); -static void md_write (gcry_md_hd_t a, byte *inbuf, size_t inlen); +static void md_write (gcry_md_hd_t a, const void *inbuf, size_t inlen); static void md_final(gcry_md_hd_t a); static byte *md_read( gcry_md_hd_t a, int algo ); static int md_get_algo( gcry_md_hd_t a ); static int md_digest_length( int algo ); static const byte *md_asn_oid( int algo, size_t *asnlen, size_t *mdlen ); -static void md_start_debug( gcry_md_hd_t a, char *suffix ); -static void md_stop_debug( gcry_md_hd_t a ); +static void md_start_debug ( gcry_md_hd_t a, const char *suffix ); +static void md_stop_debug ( gcry_md_hd_t a ); @@ -717,7 +717,7 @@ } static void -md_write (gcry_md_hd_t a, byte *inbuf, size_t inlen) +md_write (gcry_md_hd_t a, const void *inbuf, size_t inlen) { GcryDigestEntry *r; @@ -741,7 +741,7 @@ void gcry_md_write (gcry_md_hd_t hd, const void *inbuf, size_t inlen) { - md_write (hd, (unsigned char *) inbuf, inlen); + md_write (hd, inbuf, inlen); } static void @@ -818,7 +818,7 @@ } gcry_error_t -gcry_md_ctl (gcry_md_hd_t hd, int cmd, byte *buffer, size_t buflen) +gcry_md_ctl (gcry_md_hd_t hd, int cmd, void *buffer, size_t buflen) { gcry_err_code_t rc = 0; @@ -831,10 +831,10 @@ rc = gcry_err_code (gcry_md_setkey (hd, buffer, buflen)); break; case GCRYCTL_START_DUMP: - md_start_debug (hd, (char*)buffer); + md_start_debug (hd, buffer); break; case GCRYCTL_STOP_DUMP: - md_stop_debug( hd ); + md_stop_debug ( hd ); break; default: rc = GPG_ERR_INV_OP; @@ -859,7 +859,20 @@ return gcry_error (rc); } +/* The new debug interface. If SUFFIX is a string it creates an debug + file for the context HD. IF suffix is NULL, the file is closed and + debugging is stopped. */ +void +gcry_md_debug (gcry_md_hd_t hd, const char *suffix) +{ + if (suffix) + md_start_debug (hd, suffix); + else + md_stop_debug (hd); +} + + /**************** * if ALGO is null get the digest for the used algo (which should be only one) */ @@ -954,6 +967,11 @@ gcry_err_code_t gcry_md_get (gcry_md_hd_t hd, int algo, byte *buffer, int buflen) { + (void)hd; + (void)algo; + (void)buffer; + (void)buflen; + /*md_digest ... */ return GPG_ERR_INTERNAL; } @@ -1136,31 +1154,34 @@ static void -md_start_debug( gcry_md_hd_t md, char *suffix ) +md_start_debug ( gcry_md_hd_t md, const char *suffix ) { static int idx=0; char buf[50]; - - if( md->ctx->debug ) { - log_debug("Oops: md debug already started\n"); - return; - } + + if ( md->ctx->debug ) + { + log_debug("Oops: md debug already started\n"); + return; + } idx++; - sprintf(buf, "dbgmd-%05d.%.10s", idx, suffix ); + snprintf (buf, DIM(buf)-1, "dbgmd-%05d.%.10s", idx, suffix ); md->ctx->debug = fopen(buf, "w"); - if( !md->ctx->debug ) + if ( !md->ctx->debug ) log_debug("md debug: can't open %s\n", buf ); } static void md_stop_debug( gcry_md_hd_t md ) { - if( md->ctx->debug ) { - if( md->bufpos ) - md_write( md, NULL, 0 ); - fclose(md->ctx->debug); - md->ctx->debug = NULL; - } + if ( md->ctx->debug ) + { + if ( md->bufpos ) + md_write ( md, NULL, 0 ); + fclose (md->ctx->debug); + md->ctx->debug = NULL; + } + #ifdef HAVE_U64_TYPEDEF { /* a kludge to pull in the __muldi3 for Solaris */ volatile u32 a = (u32)(ulong)md; Modified: trunk/cipher/md4.c =================================================================== --- trunk/cipher/md4.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/md4.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -90,7 +90,7 @@ * transform 64 bytes */ static void -transform( MD4_CONTEXT *ctx, byte *data ) +transform ( MD4_CONTEXT *ctx, const unsigned char *data ) { u32 in[16]; register u32 A = ctx->A; @@ -192,8 +192,9 @@ * in the message whose digest is being computed. */ static void -md4_write( void *context, byte *inbuf, size_t inlen) +md4_write ( void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; MD4_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ Modified: trunk/cipher/md5.c =================================================================== --- trunk/cipher/md5.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/md5.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -80,7 +80,7 @@ * transform n*64 bytes */ static void -transform( MD5_CONTEXT *ctx, byte *data ) +transform ( MD5_CONTEXT *ctx, const unsigned char *data ) { u32 correct_words[16]; register u32 A = ctx->A; @@ -217,8 +217,9 @@ * in the message whose digest is being computed. */ static void -md5_write( void *context, byte *inbuf, size_t inlen) +md5_write( void *context, const void *inbuf_arg , size_t inlen) { + const unsigned char *inbuf = inbuf_arg; MD5_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ Modified: trunk/cipher/primegen.c =================================================================== --- trunk/cipher/primegen.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/primegen.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -1172,6 +1172,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; gcry_mpi_t val_2 = mpi_alloc_set_ui (2); /* Used by the Fermat test. */ + (void)flags; + /* We use 64 rounds because the prime we are going to test is not guaranteed to be a random one. */ if (! check_prime (x, val_2, 64, NULL, NULL)) Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/pubkey.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -93,12 +93,19 @@ dummy_generate (int algorithm, unsigned int nbits, unsigned long dummy, gcry_mpi_t *skey, gcry_mpi_t **retfactors) { + (void)algorithm; + (void)nbits; + (void)dummy; + (void)skey; + (void)retfactors; return GPG_ERR_NOT_IMPLEMENTED; } static gcry_err_code_t dummy_check_secret_key (int algorithm, gcry_mpi_t *skey) { + (void)algorithm; + (void)skey; return GPG_ERR_NOT_IMPLEMENTED; } @@ -106,6 +113,11 @@ dummy_encrypt (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *pkey, int flags) { + (void)algorithm; + (void)resarr; + (void)data; + (void)pkey; + (void)flags; return GPG_ERR_NOT_IMPLEMENTED; } @@ -113,6 +125,11 @@ dummy_decrypt (int algorithm, gcry_mpi_t *result, gcry_mpi_t *data, gcry_mpi_t *skey, int flags) { + (void)algorithm; + (void)result; + (void)data; + (void)skey; + (void)flags; return GPG_ERR_NOT_IMPLEMENTED; } @@ -120,6 +137,10 @@ dummy_sign (int algorithm, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey) { + (void)algorithm; + (void)resarr; + (void)data; + (void)skey; return GPG_ERR_NOT_IMPLEMENTED; } @@ -128,12 +149,20 @@ gcry_mpi_t *pkey, int (*cmp) (void *, gcry_mpi_t), void *opaquev) { + (void)algorithm; + (void)hash; + (void)data; + (void)pkey; + (void)cmp; + (void)opaquev; return GPG_ERR_NOT_IMPLEMENTED; } static unsigned dummy_get_nbits (int algorithm, gcry_mpi_t *pkey) { + (void)algorithm; + (void)pkey; return 0; } @@ -174,7 +203,7 @@ { gcry_pk_spec_t *pubkey = (gcry_pk_spec_t *) spec; char *name = (char *) data; - char **aliases = pubkey->aliases; + const char **aliases = pubkey->aliases; int ret = stricmp (name, pubkey->name); while (ret && *aliases) @@ -1280,7 +1309,7 @@ { "md4", GCRY_MD_MD4 }, { "tiger", GCRY_MD_TIGER }, { "haval", GCRY_MD_HAVAL }, - { NULL } + { NULL, 0 } }; int algo; byte asn[100]; Modified: trunk/cipher/random-daemon.c =================================================================== --- trunk/cipher/random-daemon.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/random-daemon.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -160,7 +160,7 @@ return -1; /* write error */ } length -= n; - buffer += n; + buffer = (const char*)buffer + n; } return 0; /* Okay */ } Modified: trunk/cipher/random.c =================================================================== --- trunk/cipher/random.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/random.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -96,8 +96,8 @@ static int is_initialized; static int allow_daemon; /* If true, try to use the daemon first. */ #define MASK_LEVEL(a) do { (a) &= 3; } while(0) -static char *rndpool; /* allocated size is POOLSIZE+BLOCKLEN */ -static char *keypool; /* allocated size is POOLSIZE+BLOCKLEN */ +static unsigned char *rndpool; /* Allocated size is POOLSIZE+BLOCKLEN. */ +static unsigned char *keypool; /* Allocated size is POOLSIZE+BLOCKLEN. */ static size_t pool_readpos; static size_t pool_writepos; static int pool_filled; @@ -404,9 +404,9 @@ 1 is strong enough for most usage, 2 is good for key generation stuff but may be very slow. */ void -gcry_randomize (byte *buffer, size_t length, enum gcry_random_level level) +gcry_randomize (void *buffer, size_t length, enum gcry_random_level level) { - byte *p; + unsigned char *p; int err; /* Make sure we are initialized. */ @@ -500,16 +500,16 @@ To better protect against implementation errors in this code, we xor a digest of the entire pool into the pool before mixing. - Note, that this function muts only be called with a locked pool. + Note: this function must only be called with a locked pool. */ static void -mix_pool(byte *pool) +mix_pool(unsigned char *pool) { static unsigned char failsafe_digest[DIGESTLEN]; static int failsafe_digest_valid; - char *hashbuf = pool + POOLSIZE; - char *p, *pend; + unsigned char *hashbuf = pool + POOLSIZE; + unsigned char *p, *pend; int i, n; RMD160_CONTEXT md; @@ -520,14 +520,14 @@ assert (pool_is_locked); _gcry_rmd160_init( &md ); - /* loop over the pool */ + /* Loop over the pool. */ pend = pool + POOLSIZE; memcpy(hashbuf, pend - DIGESTLEN, DIGESTLEN ); memcpy(hashbuf+DIGESTLEN, pool, BLOCKLEN-DIGESTLEN); _gcry_rmd160_mixblock( &md, hashbuf); memcpy(pool, hashbuf, 20 ); - if (failsafe_digest_valid && (char *)pool == rndpool) + if (failsafe_digest_valid && pool == rndpool) { for (i=0; i < 20; i++) pool[i] ^= failsafe_digest[i]; @@ -543,7 +543,7 @@ memcpy (hashbuf+DIGESTLEN, p+DIGESTLEN, BLOCKLEN-DIGESTLEN); else { - char *pp = p + DIGESTLEN; + unsigned char *pp = p + DIGESTLEN; for (i=DIGESTLEN; i < BLOCKLEN; i++ ) { @@ -553,7 +553,7 @@ } } - _gcry_rmd160_mixblock( &md, hashbuf); + _gcry_rmd160_mixblock ( &md, hashbuf); memcpy(p, hashbuf, 20 ); } @@ -561,7 +561,7 @@ of the pool on the stack, so it is okay not to require secure memory here. Before we use this pool, it will be copied to the help buffer anyway. */ - if ( (char*)pool == rndpool) + if ( pool == rndpool) { _gcry_rmd160_hash_buffer (failsafe_digest, pool, POOLSIZE); failsafe_digest_valid = 1; @@ -1186,6 +1186,9 @@ size_t n; char *buffer, *p; + (void)add; + (void)level; + if( !initialized ) { log_info(_("WARNING: using insecure random number generator!!\n")); /* we can't use tty_printf here - do we need this function at @@ -1221,7 +1224,7 @@ /* Create an unpredicable nonce of LENGTH bytes in BUFFER. */ void -gcry_create_nonce (unsigned char *buffer, size_t length) +gcry_create_nonce (void *buffer, size_t length) { static unsigned char nonce_buffer[20+8]; static int nonce_buffer_initialized = 0; Modified: trunk/cipher/random.h =================================================================== --- trunk/cipher/random.h 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/random.h 2007-02-21 13:26:38 UTC (rev 1213) @@ -29,6 +29,7 @@ void _gcry_secure_random_alloc(void); int _gcry_quick_random_gen( int onoff ); int _gcry_random_is_faked(void); +void _gcry_set_random_daemon_socket (const char *socketname); int _gcry_use_random_daemon (int onoff); void _gcry_set_random_seed_file (const char *name); void _gcry_update_random_seed_file (void); Modified: trunk/cipher/rijndael.c =================================================================== --- trunk/cipher/rijndael.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/rijndael.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -2213,7 +2213,7 @@ static const char *rijndael_names[] = { "RIJNDAEL", - NULL, + NULL }; static gcry_cipher_oid_spec_t rijndael_oids[] = @@ -2228,13 +2228,13 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes = { "AES", rijndael_names, rijndael_oids, 16, 128, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; static const char *rijndael192_names[] = { "RIJNDAEL192", - NULL, + NULL }; static gcry_cipher_oid_spec_t rijndael192_oids[] = @@ -2249,13 +2249,13 @@ gcry_cipher_spec_t _gcry_cipher_spec_aes192 = { "AES192", rijndael192_names, rijndael192_oids, 16, 192, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; static const char *rijndael256_names[] = { "RIJNDAEL256", - NULL, + NULL }; static gcry_cipher_oid_spec_t rijndael256_oids[] = @@ -2271,5 +2271,5 @@ { "AES256", rijndael256_names, rijndael256_oids, 16, 256, sizeof (RIJNDAEL_context), - rijndael_setkey, rijndael_encrypt, rijndael_decrypt, + rijndael_setkey, rijndael_encrypt, rijndael_decrypt }; Modified: trunk/cipher/rmd.h =================================================================== --- trunk/cipher/rmd.h 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/rmd.h 2007-02-21 13:26:38 UTC (rev 1213) @@ -21,16 +21,17 @@ #define G10_RMD_H -/* we need this here because random.c must have direct access */ -typedef struct { - u32 h0,h1,h2,h3,h4; - u32 nblocks; - byte buf[64]; - int count; +/* We need this here because random.c must have direct access. */ +typedef struct +{ + u32 h0,h1,h2,h3,h4; + u32 nblocks; + byte buf[64]; + int count; } RMD160_CONTEXT; -void _gcry_rmd160_init( void *context ); -void _gcry_rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ); +void _gcry_rmd160_init ( void *context ); +void _gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte ); #endif /*G10_RMD_H*/ Modified: trunk/cipher/rmd160.c =================================================================== --- trunk/cipher/rmd160.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/rmd160.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -26,7 +26,7 @@ #include "g10lib.h" #include "memory.h" #include "rmd.h" -#include "cipher.h" /* only used for the rmd160_hash_buffer() prototype */ +#include "cipher.h" /* Only used for the rmd160_hash_buffer() prototype. */ #include "bithelp.h" @@ -161,7 +161,7 @@ * Transform the message X which consists of 16 32-bit-words */ static void -transform( RMD160_CONTEXT *hd, byte *data ) +transform ( RMD160_CONTEXT *hd, const unsigned char *data ) { register u32 a,b,c,d,e; u32 aa,bb,cc,dd,ee,t; @@ -401,8 +401,9 @@ * of INBUF with length INLEN. */ static void -rmd160_write( void *context, byte *inbuf, size_t inlen) +rmd160_write ( void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; RMD160_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ @@ -443,11 +444,11 @@ * Returns: 16 bytes in buffer with the mixed contentes of buffer. */ void -_gcry_rmd160_mixblock( RMD160_CONTEXT *hd, char *buffer ) +_gcry_rmd160_mixblock ( RMD160_CONTEXT *hd, void *blockof64byte ) { - char *p = buffer; + char *p = blockof64byte; - transform( hd, (unsigned char *)buffer ); + transform ( hd, blockof64byte ); #define X(a) do { *(u32*)p = hd->h##a ; p += 4; } while(0) X(0); X(1); @@ -540,14 +541,14 @@ * into outbuf which must have a size of 20 bytes. */ void -_gcry_rmd160_hash_buffer( char *outbuf, const char *buffer, size_t length ) +_gcry_rmd160_hash_buffer (void *outbuf, const void *buffer, size_t length ) { RMD160_CONTEXT hd; - _gcry_rmd160_init( &hd ); - rmd160_write( &hd, (byte*)buffer, length ); - rmd160_final( &hd ); - memcpy( outbuf, hd.buf, 20 ); + _gcry_rmd160_init ( &hd ); + rmd160_write ( &hd, buffer, length ); + rmd160_final ( &hd ); + memcpy ( outbuf, hd.buf, 20 ); } static byte asn[15] = /* Object ID is 1.3.36.3.2.1 */ Modified: trunk/cipher/rndlinux.c =================================================================== --- trunk/cipher/rndlinux.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/rndlinux.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -36,7 +36,7 @@ #include "g10lib.h" #include "rand-internal.h" -static int open_device( const char *name, int minor ); +static int open_device ( const char *name ); int _gcry_rndlinux_gather_random (void (*add)(const void*, size_t, int), int requester, size_t length, int level ); @@ -60,7 +60,7 @@ * Used to open the /dev/random devices (Linux, xBSD, Solaris (if it exists)). */ static int -open_device( const char *name, int minor ) +open_device ( const char *name ) { int fd; @@ -72,9 +72,9 @@ log_error ("error setting FD_CLOEXEC on fd %d: %s\n", fd, strerror (errno)); - /* We used to do the follwing check, however it turned out that this + /* We used to do the following check, however it turned out that this is not portable since more OSes provide a random device which is - sometimes implemented as anoteher device type. + sometimes implemented as another device type. struct stat sb; @@ -102,13 +102,13 @@ if( level >= 2 ) { if( fd_random == -1 ) - fd_random = open_device( NAME_OF_DEV_RANDOM, 8 ); + fd_random = open_device ( NAME_OF_DEV_RANDOM ); fd = fd_random; } else { if( fd_urandom == -1 ) - fd_urandom = open_device( NAME_OF_DEV_URANDOM, 9 ); + fd_urandom = open_device ( NAME_OF_DEV_URANDOM ); fd = fd_urandom; } Modified: trunk/cipher/rsa.c =================================================================== --- trunk/cipher/rsa.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/rsa.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -445,6 +445,8 @@ gpg_err_code_t rc; int i; + (void)algo; + generate (&sk, nbits, use_e); skey[0] = sk.n; skey[1] = sk.e; @@ -477,6 +479,8 @@ gcry_err_code_t err = GPG_ERR_NO_ERROR; RSA_secret_key sk; + (void)algo; + sk.n = skey[0]; sk.e = skey[1]; sk.d = skey[2]; @@ -496,6 +500,9 @@ gcry_mpi_t *pkey, int flags) { RSA_public_key pk; + + (void)algo; + (void)flags; pk.n = pkey[0]; pk.e = pkey[1]; @@ -516,6 +523,8 @@ gcry_mpi_t x = MPI_NULL; /* Data to decrypt. */ gcry_mpi_t y; /* Result. */ + (void)algo; + /* Extract private key. */ sk.n = skey[0]; sk.e = skey[1]; @@ -584,6 +593,8 @@ _gcry_rsa_sign (int algo, gcry_mpi_t *resarr, gcry_mpi_t data, gcry_mpi_t *skey) { RSA_secret_key sk; + + (void)algo; sk.n = skey[0]; sk.e = skey[1]; @@ -606,6 +617,10 @@ gcry_mpi_t result; gcry_err_code_t rc; + (void)algo; + (void)cmp; + (void)opaquev; + pk.n = pkey[0]; pk.e = pkey[1]; result = gcry_mpi_new ( 160 ); @@ -621,10 +636,12 @@ unsigned int _gcry_rsa_get_nbits (int algo, gcry_mpi_t *pkey) { + (void)algo; + return mpi_get_nbits (pkey[0]); } -static char *rsa_names[] = +static const char *rsa_names[] = { "rsa", "openpgp-rsa", Modified: trunk/cipher/serpent.c =================================================================== --- trunk/cipher/serpent.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/serpent.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -953,26 +953,26 @@ static const char *cipher_spec_serpent128_aliases[] = { "SERPENT", - NULL, + NULL }; 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, + serpent_setkey, serpent_encrypt, serpent_decrypt }; gcry_cipher_spec_t _gcry_cipher_spec_serpent192 = { "SERPENT192", NULL, NULL, 16, 192, sizeof (serpent_context_t), - serpent_setkey, serpent_encrypt, serpent_decrypt, + serpent_setkey, serpent_encrypt, serpent_decrypt }; gcry_cipher_spec_t _gcry_cipher_spec_serpent256 = { "SERPENT256", NULL, NULL, 16, 256, sizeof (serpent_context_t), - serpent_setkey, serpent_encrypt, serpent_decrypt, + serpent_setkey, serpent_encrypt, serpent_decrypt }; Modified: trunk/cipher/sha1.c =================================================================== --- trunk/cipher/sha1.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/sha1.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -66,7 +66,7 @@ * Transform the message X which consists of 16 32-bit-words */ static void -transform( SHA1_CONTEXT *hd, byte *data ) +transform ( SHA1_CONTEXT *hd, const unsigned char *data ) { register u32 a,b,c,d,e,tm; u32 x[16]; @@ -209,8 +209,9 @@ * of INBUF with length INLEN. */ static void -sha1_write( void *context, byte *inbuf, size_t inlen) +sha1_write( void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; SHA1_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ @@ -332,12 +333,12 @@ * into outbuf which must have a size of 20 bytes. */ void -_gcry_sha1_hash_buffer (char *outbuf, const char *buffer, size_t length) +_gcry_sha1_hash_buffer (void *outbuf, const void *buffer, size_t length) { SHA1_CONTEXT hd; sha1_init (&hd); - sha1_write (&hd, (byte*)buffer, length); + sha1_write (&hd, buffer, length); sha1_final (&hd); memcpy (outbuf, hd.buf, 20); } Modified: trunk/cipher/sha256.c =================================================================== --- trunk/cipher/sha256.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/sha256.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -116,7 +116,7 @@ } while (0) static void -transform (SHA256_CONTEXT *hd, byte *data) +transform (SHA256_CONTEXT *hd, const unsigned char *data) { static const u32 K[64] = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, @@ -196,8 +196,9 @@ /* Update the message digest with the contents of INBUF with length INLEN. */ static void -sha256_write (void *context, byte *inbuf, size_t inlen) +sha256_write (void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; SHA256_CONTEXT *hd = context; if (hd->count == 64) Modified: trunk/cipher/sha512.c =================================================================== --- trunk/cipher/sha512.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/sha512.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -104,7 +104,7 @@ * Transform the message W which consists of 16 64-bit-words */ static void -transform (SHA512_CONTEXT *hd, byte *data) +transform (SHA512_CONTEXT *hd, const unsigned char *data) { u64 a, b, c, d, e, f, g, h; u64 w[80]; @@ -230,8 +230,9 @@ * of INBUF with length INLEN. */ static void -sha512_write (void *context, byte *inbuf, size_t inlen) +sha512_write (void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; SHA512_CONTEXT *hd = context; if (hd->count == 128) Modified: trunk/cipher/tiger.c =================================================================== --- trunk/cipher/tiger.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/tiger.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -667,7 +667,7 @@ * Transform the message DATA which consists of 512 bytes (8 words) */ static void -transform( TIGER_CONTEXT *hd, byte *data ) +transform ( TIGER_CONTEXT *hd, const unsigned char *data ) { u64 a,b,c,aa,bb,cc; u64 x[8]; @@ -717,8 +717,9 @@ * of INBUF with length INLEN. */ static void -tiger_write( void *context, byte *inbuf, size_t inlen) +tiger_write ( void *context, const void *inbuf_arg, size_t inlen) { + const unsigned char *inbuf = inbuf_arg; TIGER_CONTEXT *hd = context; if( hd->count == 64 ) /* flush the buffer */ Modified: trunk/cipher/twofish.c =================================================================== --- trunk/cipher/twofish.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/twofish.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -1030,11 +1030,11 @@ gcry_cipher_spec_t _gcry_cipher_spec_twofish = { "TWOFISH", NULL, NULL, 16, 256, sizeof (TWOFISH_context), - twofish_setkey, twofish_encrypt, twofish_decrypt, + twofish_setkey, twofish_encrypt, twofish_decrypt }; gcry_cipher_spec_t _gcry_cipher_spec_twofish128 = { "TWOFISH128", NULL, NULL, 16, 128, sizeof (TWOFISH_context), - twofish_setkey, twofish_encrypt, twofish_decrypt, + twofish_setkey, twofish_encrypt, twofish_decrypt }; Modified: trunk/cipher/whirlpool.c =================================================================== --- trunk/cipher/whirlpool.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/cipher/whirlpool.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -1194,7 +1194,7 @@ * Transform block. */ static void -whirlpool_transform (whirlpool_context_t *context, unsigned char *data) +whirlpool_transform (whirlpool_context_t *context, const unsigned char *data) { whirlpool_block_t data_block; whirlpool_block_t key; @@ -1291,8 +1291,9 @@ static void whirlpool_add (whirlpool_context_t *context, - unsigned char *buffer, size_t buffer_n) + const void *buffer_arg, size_t buffer_n) { + const unsigned char *buffer = buffer_arg; u64 buffer_size; unsigned int carry; unsigned int i; @@ -1303,12 +1304,11 @@ { /* Flush the buffer. */ whirlpool_transform (context, context->buffer); - //_gcry_burn_stack (80+6*sizeof(void*)); /* FIXME */ + /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */ context->count = 0; } if (! buffer) - /* Nothing to add. */ - return; + return; /* Nothing to add. */ if (context->count) { @@ -1322,7 +1322,7 @@ /* Done. */ return; } - //_gcry_burn_stack (80+6*sizeof(void*)); /* FIXME */ + /*_gcry_burn_stack (80+6*sizeof(void*));*/ /* FIXME */ while (buffer_n >= BLOCK_SIZE) { @@ -1354,7 +1354,7 @@ } static void -whirlpool_write (void *ctx, unsigned char *buffer, size_t buffer_n) +whirlpool_write (void *ctx, const void *buffer, size_t buffer_n) { whirlpool_context_t *context = ctx; Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/configure.ac 2007-02-21 13:26:38 UTC (rev 1213) @@ -23,20 +23,26 @@ AC_PREREQ(2.59) min_automake_version="1.9.3" -# Version number: Remember to change it immediately *after* a release -# but remove a "-cvs" prefix right *before* a release and append it -# soon later. -AC_INIT(libgcrypt, 1.3.0-cvs, bug-libgcrypt at gnupg.org) +# Remember to change the version number immediately *after* a release. +# Set my_issvn to "yes" for non-released code. Remember to run an +# "svn up" and "autogen.sh" right before creating a distribution. +m4_define([my_version], [1.3.0]) +m4_define([my_issvn], [yes]) +m4_define([svn_revision], m4_esyscmd([echo -n $( (svn info 2>/dev/null \ + || echo 'Revision: 0')|sed -n '/^Revision:/ {s/[^0-9]//gp;q;}')])) +AC_INIT([libgcrypt], my_version[]m4_if(my_issvn,[yes],[-svn[]svn_revision]), + [bug-libgcrypt at gnupg.org]) # LT Version numbers, remember to change them just *before* a release. # (Interfaces removed: CURRENT++, AGE=0, REVISION=0) # (Interfaces added: CURRENT++, AGE++, REVISION=0) # (No interfaces changed: REVISION++) -LIBGCRYPT_LT_CURRENT=12 -LIBGCRYPT_LT_AGE=1 -LIBGCRYPT_LT_REVISION=1 +LIBGCRYPT_LT_CURRENT=14 +LIBGCRYPT_LT_AGE=3 +LIBGCRYPT_LT_REVISION=0 + # If the API is changed in an incompatible way: increment the next counter. LIBGCRYPT_CONFIG_API_VERSION=1 @@ -422,16 +428,6 @@ [use_capabilities="$withval"],[use_capabilities=no]) AC_MSG_RESULT($use_capabilities) -# We don't have a test to check whether as(1) knows about the -# non executable stack option. Thus we provide an option to enable it. -AC_MSG_CHECKING([whether non excutable stack support is requested]) -AC_ARG_ENABLE(noexecstack, - AC_HELP_STRING([--enable-noexecstack], - [enable non executable stack support (gcc only)]), - noexecstack_support=$enableval, noexecstack_support=no) -AC_MSG_RESULT($noexecstack_support) - - AC_DEFINE_UNQUOTED(PRINTABLE_OS_NAME, "$PRINTABLE_OS_NAME", [A human readable text with the name of the OS]) @@ -710,23 +706,25 @@ test "$more_gcc_warnings" = "yes"; then CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes" if test "$more_gcc_warnings" = "yes"; then - CFLAGS="$CFLAGS -W -Wpointer-arith -Wbad-function-cast" - CFLAGS="$CFLAGS -Wwrite-strings -Wunreachable-code" + CFLAGS="$CFLAGS -W -Wextra -Wpointer-arith -Wbad-function-cast" + CFLAGS="$CFLAGS -Wwrite-strings" + CFLAGS="$CFLAGS -Wdeclaration-after-statement" + CFLAGS="$CFLAGS -Wno-missing-field-initializers" CFLAGS="$CFLAGS -Wno-sign-compare" + # Note: We don't use -Wunreachable-code because this gives + # warnings for all asserts and many inline functions like + # gpg_error (gcc 4.1.2 20060928). fi else CFLAGS="$CFLAGS -Wall" fi - - # Non exec stack hack. Fixme: Write a test to check whether as - # can cope with it and use the enable-noexecstack option only to - # disable it in case it is required on some platforms. - if test "$noexecstack_support" = yes; then - NOEXECSTACK_FLAGS="-Wa,--noexecstack" - fi fi -AC_SUBST(NOEXECSTACK_FLAGS) +# Check whether as(1) supports a noeexecstack feature. This test +# includes an override option. +CL_AS_NOEXECSTACK + + AC_SUBST(LIBGCRYPT_CONFIG_API_VERSION) AC_SUBST(LIBGCRYPT_CONFIG_LIBS) AC_SUBST(LIBGCRYPT_CONFIG_CFLAGS) @@ -886,6 +884,7 @@ AC_CONFIG_FILES([ Makefile +m4/Makefile mpi/Makefile cipher/Makefile doc/Makefile Property changes on: trunk/doc ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile gcrypt.info stamp-vti version.texi Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/doc/gcrypt.texi 2007-02-21 13:26:38 UTC (rev 1213) @@ -2033,11 +2033,26 @@ Tracking bugs related to hashing is often a cumbersome task which -requires to add a lot of printf statements into the code. @acronym{Libgcrypt} -provides an easy way to avoid this. The actual data hashed can be -written to files on request. The following 2 macros should be used to -implement such a debugging facility: +requires to add a lot of printf statements into the code. + at acronym{Libgcrypt} provides an easy way to avoid this. The actual data +hashed can be written to files on request. + at deftypefun void gcry_md_debug (gcry_md_hd_t @var{h}, const char *@var{suffix}) + +Enable debugging for the digest object with handle @var{h}. This +creates create files named @file{dbgmd-.} while doing the +actual hashing. @var{suffix} is the string part in the filename. The +number is a counter incremented for each new hashing. The data in the +file is the raw data as passed to @code{gcry_md_write} or + at code{gcry_md_putc}. If @code{NULL} is used for @var{suffix}, the +debugging is stopped and the file closed. This is only rarely required +because @code{gcry_md_close} implicitly stops debugging. + at end deftypefun + + +The following two deprecated macros are used for debugging by old code. +They shopuld be replaced by @code{gcry_md_debug}. + @deftypefun void gcry_md_start_debug (gcry_md_hd_t @var{h}, const char *@var{suffix}) Enable debugging for the digest object with handle @var{h}. This Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/m4/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,3 +1,9 @@ +2007-02-20 Werner Koch + + * Makefile.am: New. + + * noexecstack.m4: New. Taken from gnupg 1.4 + 2006-10-11 Marcus Brinkmann * fallback.m4: Removed again. Added: trunk/m4/Makefile.am =================================================================== --- trunk/m4/Makefile.am 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/m4/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) @@ -0,0 +1 @@ +EXTRA_DIST = libtool.m4 onceonly.m4 socklen.m4 sys_socket_h.m4 noexecstack.m4 Added: trunk/m4/noexecstack.m4 =================================================================== --- trunk/m4/noexecstack.m4 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/m4/noexecstack.m4 2007-02-21 13:26:38 UTC (rev 1213) @@ -0,0 +1,55 @@ +# noexecstack.m4 +dnl Copyright (C) 1995-2006 Free Software Foundation, Inc. +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License, or (at your option) any later version. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +dnl Checks whether the stack can be marked nonexecutable by passing an +dnl option to the C-compiler when acting on .s files. Returns that +dnl option in NOEXECSTACK_FLAGS. +dnl This macro is adapted from one found in GLIBC-2.3.5. +AC_DEFUN([CL_AS_NOEXECSTACK],[ +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AM_PROG_AS]) + +AC_MSG_CHECKING([whether non excutable stack support is requested]) +AC_ARG_ENABLE(noexecstack, + AC_HELP_STRING([--enable-noexecstack], + [enable non executable stack support (gcc only)]), + noexecstack_support=$enableval, noexecstack_support=no) +AC_MSG_RESULT($noexecstack_support) + +AC_CACHE_CHECK([whether assembler supports --noexecstack option], +cl_cv_as_noexecstack, [dnl + cat > conftest.c </dev/null]) \ + && grep -q .note.GNU-stack conftest.s \ + && AC_TRY_COMMAND([${CCAS} $CCASFLAGS $CPPFLAGS -Wa,--noexecstack + -c -o conftest.o conftest.s >/dev/null]) + then + cl_cv_as_noexecstack=yes + else + cl_cv_as_noexecstack=no + fi + rm -f conftest*]) + if test "$noexecstack_support" = yes -a "$cl_cv_as_noexecstack" = yes; then + NOEXECSTACK_FLAGS="-Wa,--noexecstack" + else + NOEXECSTACK_FLAGS= + fi + AC_SUBST(NOEXECSTACK_FLAGS) +]) Property changes on: trunk/mpi ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile asm-syntax.h mpi-asm-defs.h mpih-add1.S mpih-lshift.S mpih-mul1.S mpih-mul2.S mpih-mul3.S mpih-rshift.S mpih-sub1.S sysdep.h Modified: trunk/mpi/ChangeLog =================================================================== --- trunk/mpi/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/mpi/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,3 +1,7 @@ +2007-02-21 Werner Koch + + * mpicoder.c (_gcry_mpi_set_buffer): Made BUFFER a void*. + 2006-11-15 Werner Koch * Makefile.am (.S.o): Check for srcdir also in in CPP pass. Modified: trunk/mpi/mpicoder.c =================================================================== --- trunk/mpi/mpicoder.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/mpi/mpicoder.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -274,8 +274,10 @@ * Use BUFFER to update MPI. */ void -_gcry_mpi_set_buffer( gcry_mpi_t a, const byte *buffer, unsigned nbytes, int sign ) +_gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer_arg, + unsigned int nbytes, int sign ) { + const unsigned char *buffer = (const unsigned char*)buffer_arg; const byte *p; mpi_limb_t alimb; int nlimbs; Modified: trunk/mpi/mpiutil.c =================================================================== --- trunk/mpi/mpiutil.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/mpi/mpiutil.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -450,10 +450,13 @@ void gcry_mpi_clear_flag( gcry_mpi_t a, enum gcry_mpi_flag flag ) { - switch( flag ) { - case GCRYMPI_FLAG_SECURE: - case GCRYMPI_FLAG_OPAQUE: - default: log_bug("invalid flag value\n"); + (void)a; /* Not yet used. */ + + switch (flag) + { + case GCRYMPI_FLAG_SECURE: + case GCRYMPI_FLAG_OPAQUE: + default: log_bug("invalid flag value\n"); } } Property changes on: trunk/src ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile gcrypt.h gcryptrnd getrandom libgcrypt-config Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,3 +1,29 @@ +2007-02-21 Werner Koch + + * gcrypt.h.in (gcry_sexp_sprint): Change BUFFER from char* to void*. + (gcry_md_ctl): Change BUFFER from unsigned char* to void*. + (gcry_md_debug): New. + (gcry_cipher_encrypt, gcry_cipher_decrypt): Change buffer args to + void*. + (gcry_randomize): Change BUFFER to void. + (gcry_create_nonce): Ditto. + + * libgcrypt.vers (gcry_md_debug): New. + + * sexp.c (gcry_sexp_sprint): Ditto. + (normalize): Make P unsigned. + (gcry_sexp_nth_data): Cast return value to char*. + (sexp_sscan): Fix sign/unsigned conflicts. + (whitespacep): Change P to char*. + (unquote_string): Change STRING to char*. + (convert_to_hex): Change DEST to char*. + (convert_to_string): Change DEST and P to char*. + (convert_to_token): Chnage DEST to char*. + (gcry_sexp_canon_len): Change DISPHINT to unsigned char*. + + * gcrypt-module.h (gcry_pk_spec): Made ALIASES a const. + (gcry_md_write_t): Changed BUF to a const void*. + 2007-02-12 Werner Koch * gcrypt.h.in: Include stdlib.h for the sake fo the trheading Modified: trunk/src/cipher.h =================================================================== --- trunk/src/cipher.h 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/cipher.h 2007-02-21 13:26:38 UTC (rev 1213) @@ -29,9 +29,11 @@ #define PUBKEY_FLAG_NO_BLINDING (1 << 0) /*-- rmd160.c --*/ -void _gcry_rmd160_hash_buffer (char *outbuf, const char *buffer, size_t length); +void _gcry_rmd160_hash_buffer (void *outbuf, + const void *buffer, size_t length); /*-- sha1.c --*/ -void _gcry_sha1_hash_buffer (char *outbuf, const char *buffer, size_t length); +void _gcry_sha1_hash_buffer (void *outbuf, + const void *buffer, size_t length); /*-- dsa.c --*/ void _gcry_register_pk_dsa_progress (gcry_handler_progress_t cbc, void *cb_data); Modified: trunk/src/gcrypt-module.h =================================================================== --- trunk/src/gcrypt-module.h 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/gcrypt-module.h 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,26 +1,28 @@ -/* gcrypt-module.h - GNU cryptographic library interface - * 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 +/* gcrypt-module.h - GNU Cryptographic Library Interface + Copyright (C) 2003, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. */ + +/* + This file contains the necessary declarations/definitions for + working with Libgcrypt modules. */ -/* This file contains the necessary declarations/definitions for - working with Libgcrypt modules. */ - #ifndef _GCRYPT_MODULE_H #define _GCRYPT_MODULE_H @@ -89,7 +91,7 @@ CIPHER. On success, a new algorithm ID is stored in ALGORITHM_ID and a pointer representhing this module is stored in MODULE. */ gcry_error_t gcry_cipher_register (gcry_cipher_spec_t *cipher, - unsigned int *algorithm_id, + int *algorithm_id, gcry_module_t *module); /* Unregister the cipher identified by MODULE, which must have been @@ -144,7 +146,7 @@ typedef struct gcry_pk_spec { const char *name; - char **aliases; + const char **aliases; const char *elements_pkey; const char *elements_skey; const char *elements_enc; @@ -177,7 +179,7 @@ typedef void (*gcry_md_init_t) (void *c); /* Type for the md_write function. */ -typedef void (*gcry_md_write_t) (void *c, unsigned char *buf, size_t nbytes); +typedef void (*gcry_md_write_t) (void *c, const void *buf, size_t nbytes); /* Type for the md_final function. */ typedef void (*gcry_md_final_t) (void *c); Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/gcrypt.h.in 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,24 +1,26 @@ -/* gcrypt.h - GNU cryptographic library interface -*- c -*- - * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, - * 2004, 2006 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 - */ +/* gcrypt.h - GNU Cryptographic Library Interface -*- c -*- + Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, + 2004, 2006, 2007 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, + USA. + File: @configure_input@ */ + #ifndef _GCRYPT_H #define _GCRYPT_H @@ -417,7 +419,7 @@ /* Copies the S-expression object SEXP into BUFFER using the format specified in MODE. */ -size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, char *buffer, +size_t gcry_sexp_sprint (gcry_sexp_t sexp, int mode, void *buffer, size_t maxlength); /* Dumps the S-expression object A in a aformat suitable for debugging @@ -826,13 +828,13 @@ most algorithms it is possible to pass NULL for in and 0 for INLEN and do a in-place decryption of the data provided in OUT. */ gcry_error_t gcry_cipher_encrypt (gcry_cipher_hd_t h, - unsigned char *out, size_t outsize, - const unsigned char *in, size_t inlen); + void *out, size_t outsize, + const void *in, size_t inlen); /* The counterpart to gcry_cipher_encrypt. */ gcry_error_t gcry_cipher_decrypt (gcry_cipher_hd_t h, - unsigned char *out, size_t outsize, - const unsigned char *in, size_t inlen); + void *out, size_t outsize, + const void *in, size_t inlen); /* Set key K of length L for the cipher handle H. (We have to cast away a const char* here - this catch-all ctl function was probably @@ -1045,9 +1047,9 @@ /* Reset the digest object HD to its initial state. */ void gcry_md_reset (gcry_md_hd_t hd); -/* Perform various operations on the digets object HD. */ -gcry_error_t gcry_md_ctl (gcry_md_hd_t hd, int cmd, unsigned char *buffer, - size_t buflen); +/* Perform various operations on the digest object HD. */ +gcry_error_t gcry_md_ctl (gcry_md_hd_t hd, int cmd, + void *buffer, size_t buflen); /* Pass LENGTH bytes of data in BUFFER to the digest object HD so that it can update the digest values. This is the actual hash @@ -1102,6 +1104,12 @@ KEYLEN. */ gcry_error_t gcry_md_setkey (gcry_md_hd_t hd, const void *key, size_t keylen); +/* Start or stop debugging for digest handle HD; i.e. create a file + named dbgmd-. while hashing. If SUFFIX is NULL, + debugging stops and the file will be closed. */ +void gcry_md_debug (gcry_md_hd_t hd, const char *suffix); + + /* Update the hash(s) of H with the character C. This is a buffered version of the gcry_md_write function. */ #define gcry_md_putc(h,c) \ @@ -1128,13 +1136,14 @@ #define gcry_md_get_asnoid(a,b,n) \ gcry_md_algo_info((a), GCRYCTL_GET_ASNOID, (b), (n)) -/* Enable debugging for digets object A; i.e. create files named +/* Enable debugging for digest object A; i.e. create files named dbgmd-. while hashing. B is a string used as the suffix - for the filename. */ + for the filename. This macro is deprecated, use gcry_md_debug. */ #define gcry_md_start_debug(a,b) \ gcry_md_ctl( (a), GCRYCTL_START_DUMP, (b), 0 ) -/* Disable the debugging of A. */ +/* Disable the debugging of A. This macro is deprecated, use + gcry_md_debug. */ #define gcry_md_stop_debug(a,b) \ gcry_md_ctl( (a), GCRYCTL_STOP_DUMP, (b), 0 ) @@ -1537,7 +1546,7 @@ /* Fill BUFFER with LENGTH bytes of random, using random numbers of quality LEVEL. */ -void gcry_randomize (unsigned char *buffer, size_t length, +void gcry_randomize (void *buffer, size_t length, enum gcry_random_level level); /* Add the external random from BUFFER with LENGTH bytes into the @@ -1571,7 +1580,7 @@ /* Create an unpredicable nonce of LENGTH bytes in BUFFER. */ -void gcry_create_nonce (unsigned char *buffer, size_t length); +void gcry_create_nonce (void *buffer, size_t length); Modified: trunk/src/gcryptrnd.c =================================================================== --- trunk/src/gcryptrnd.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/gcryptrnd.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -106,6 +106,8 @@ static void my_gcry_logger (void *dummy, int level, const char *format, va_list arg_ptr) { + (void)dummy; + /* Map the log levels. */ switch (level) { @@ -391,7 +393,7 @@ return -1; /* write error */ } length -= n; - buffer += n; + buffer = (const char*)buffer + n; } return 0; /* Okay */ } Modified: trunk/src/getrandom.c =================================================================== --- trunk/src/getrandom.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/getrandom.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -66,7 +66,7 @@ return -1; /* write error */ } length -= n; - buffer += n; + buffer = (const char *)buffer + n; } return 0; /* Okay */ } Modified: trunk/src/global.c =================================================================== --- trunk/src/global.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/global.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -525,6 +525,8 @@ void _gcry_check_heap( const void *a ) { + (void)a; + /* FIXME: implement this*/ #if 0 if( some_handler ) Modified: trunk/src/libgcrypt.vers =================================================================== --- trunk/src/libgcrypt.vers 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/libgcrypt.vers 2007-02-21 13:26:38 UTC (rev 1213) @@ -39,7 +39,7 @@ gcry_md_info; gcry_md_is_enabled; gcry_md_is_secure; gcry_md_list; gcry_md_map_name; gcry_md_open; gcry_md_read; gcry_md_register; gcry_md_reset; gcry_md_setkey; - gcry_md_unregister; gcry_md_write; + gcry_md_unregister; gcry_md_write; gcry_md_debug; gcry_cipher_algo_info; gcry_cipher_algo_name; gcry_cipher_close; gcry_cipher_ctl; gcry_cipher_decrypt; gcry_cipher_encrypt; Modified: trunk/src/mpi.h =================================================================== --- trunk/src/mpi.h 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/mpi.h 2007-02-21 13:26:38 UTC (rev 1213) @@ -126,7 +126,8 @@ u32 _gcry_mpi_get_keyid( gcry_mpi_t a, u32 *keyid ); byte *_gcry_mpi_get_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign ); byte *_gcry_mpi_get_secure_buffer( gcry_mpi_t a, unsigned *nbytes, int *sign ); -void _gcry_mpi_set_buffer( gcry_mpi_t a, const byte *buffer, unsigned nbytes, int sign ); +void _gcry_mpi_set_buffer ( gcry_mpi_t a, const void *buffer, + unsigned int nbytes, int sign ); #define log_mpidump _gcry_log_mpidump Modified: trunk/src/sexp.c =================================================================== --- trunk/src/sexp.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/src/sexp.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -63,7 +63,7 @@ to the S-expressions definition. */ #undef whitespacep static GPG_ERR_INLINE int -whitespacep (const unsigned char *p) +whitespacep (const char *p) { switch (*p) { @@ -169,22 +169,25 @@ static gcry_sexp_t normalize ( gcry_sexp_t list ) { - char *p; - if ( !list ) - return NULL; - p = list->d; - if ( *p == ST_STOP ) { - /* this is "" */ - gcry_sexp_release ( list ); - return NULL; + unsigned char *p; + + if ( !list ) + return NULL; + p = list->d; + if ( *p == ST_STOP ) + { + /* this is "" */ + gcry_sexp_release ( list ); + return NULL; } - if( *p == ST_OPEN && p[1] == ST_CLOSE ) { - /* this is "()" */ - gcry_sexp_release ( list ); - return NULL; + if ( *p == ST_OPEN && p[1] == ST_CLOSE ) + { + /* this is "()" */ + gcry_sexp_release ( list ); + return NULL; } - - return list; + + return list; } /* Create a new S-expression object by reading LENGTH bytes from @@ -304,6 +307,9 @@ gcry_sexp_t gcry_sexp_cons( const gcry_sexp_t a, const gcry_sexp_t b ) { + (void)a; + (void)b; + /* NYI: Implementation should be quite easy with our new data representation */ BUG (); @@ -318,6 +324,8 @@ gcry_sexp_t gcry_sexp_alist( const gcry_sexp_t *array ) { + (void)array; + /* NYI: Implementation should be quite easy with our new data representation. */ BUG (); @@ -330,6 +338,7 @@ gcry_sexp_t gcry_sexp_vlist( const gcry_sexp_t a, ... ) { + (void)a; /* NYI: Implementation should be quite easy with our new data representation. */ BUG (); @@ -344,6 +353,8 @@ gcry_sexp_t gcry_sexp_append( const gcry_sexp_t a, const gcry_sexp_t n ) { + (void)a; + (void)n; /* NYI: Implementation should be quite easy with our new data representation. */ BUG (); @@ -353,6 +364,8 @@ gcry_sexp_t gcry_sexp_prepend( const gcry_sexp_t a, const gcry_sexp_t n ) { + (void)a; + (void)n; /* NYI: Implementation should be quite easy with our new data representation. */ BUG (); @@ -617,7 +630,7 @@ if ( *p == ST_DATA ) { memcpy ( &n, ++p, sizeof n ); *datalen = n; - return p + sizeof n; + return (const char*)p + sizeof n; } return NULL; @@ -828,10 +841,10 @@ quotes are must already be removed from STRING. We assume that the quoted string is syntacillay correct. */ static size_t -unquote_string (const unsigned char *string, size_t length, unsigned char *buf) +unquote_string (const char *string, size_t length, unsigned char *buf) { int esc = 0; - const unsigned char *s = string; + const unsigned char *s = (const unsigned char*)string; unsigned char *d = buf; size_t n = length; @@ -1088,7 +1101,7 @@ { /* Keep it easy - we know that the unquoted string will never be larger. */ - char *save; + unsigned char *save; size_t len; quoted++; /* Skip leading quote. */ @@ -1123,7 +1136,7 @@ { if (whitespacep (hexfmt)) continue; - *c.pos++ = hextobyte (hexfmt); + *c.pos++ = hextobyte ((const unsigned char*)hexfmt); hexfmt++; } hexfmt = NULL; @@ -1517,7 +1530,7 @@ static int -convert_to_hex (const unsigned char *src, size_t len, unsigned char *dest) +convert_to_hex (const unsigned char *src, size_t len, char *dest) { int i; @@ -1532,11 +1545,11 @@ } static int -convert_to_string (const unsigned char *s, size_t len, unsigned char *dest) +convert_to_string (const unsigned char *s, size_t len, char *dest) { if (dest) { - unsigned char *p = dest; + char *p = dest; *p++ = '\"'; for (; len; len--, s++ ) { @@ -1594,7 +1607,7 @@ static int -convert_to_token (const unsigned char *src, size_t len, unsigned char *dest) +convert_to_token (const unsigned char *src, size_t len, char *dest) { if (dest) memcpy (dest, src, len); @@ -1609,11 +1622,11 @@ * the required length is returned. */ size_t -gcry_sexp_sprint( const gcry_sexp_t list, int mode, - char *buffer, size_t maxlength ) +gcry_sexp_sprint (const gcry_sexp_t list, int mode, + void *buffer, size_t maxlength ) { - static byte empty[3] = { ST_OPEN, ST_CLOSE, ST_STOP }; - const byte *s; + static unsigned char empty[3] = { ST_OPEN, ST_CLOSE, ST_STOP }; + const unsigned char *s; char *d; DATALEN n; char numbuf[20]; @@ -1764,7 +1777,7 @@ size_t *erroff, gcry_error_t *errcode) { const unsigned char *p; - const char *disphint=NULL; + const unsigned char *disphint = NULL; unsigned int datalen = 0; size_t dummy_erroff; gcry_error_t dummy_errcode; @@ -1857,7 +1870,7 @@ } else if (*p == ']') { - if( !disphint ) + if ( !disphint ) { *erroff = count; *errcode = gcry_error (GPG_ERR_SEXP_UNMATCHED_DH); Property changes on: trunk/tests ___________________________________________________________________ Name: svn:ignore + ac-data ac-schemes ac basic benchmark hmac keygen keygrip pkbench prime pubkey register t-mpi-bit tsexp Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) @@ -1,3 +1,12 @@ +2007-02-21 Werner Koch + + * hmac.c (check_one_mac): Make pointer args const. + * basic.c (check_one_md): Ditto. + (check_one_hmac): Ditto. + + * keygen.c (progress_cb): Filter out line feeds. + * basic.c (progress_handler): Ditto. + 2006-12-18 Werner Koch * Makefile.am (AM_CFLAGS, AM_CPPFLAGS): Splitted and merged with Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/basic.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -79,7 +79,16 @@ progress_handler (void *cb_data, const char *what, int printchar, int current, int total) { - putchar (printchar); + (void)cb_data; + (void)what; + (void)current; + (void)total; + + if (printchar == '\n') + fputs ( "", stdout); + else + putchar (printchar); + fflush (stdout); } static void @@ -1004,7 +1013,7 @@ static void -check_one_md (int algo, char *data, int len, char *expect) +check_one_md (int algo, const char *data, int len, const char *expect) { gcry_md_hd_t hd, hd2; unsigned char *p; @@ -1069,8 +1078,8 @@ static struct algos { int md; - char *data; - char *expect; + const char *data; + const char *expect; } algos[] = { { GCRY_MD_MD4, "", @@ -1245,8 +1254,8 @@ } static void -check_one_hmac (int algo, char *data, int datalen, - char *key, int keylen, char *expect) +check_one_hmac (int algo, const char *data, int datalen, + const char *key, int keylen, const char *expect) { gcry_md_hd_t hd, hd2; unsigned char *p; @@ -1306,9 +1315,9 @@ static struct algos { int md; - char *data; - char *key; - char *expect; + const char *data; + const char *key; + const char *expect; } algos[] = { { GCRY_MD_MD5, "what do ya want for nothing?", "Jefe", @@ -1666,6 +1675,8 @@ { NULL } }; + (void)n; + rc = gcry_sexp_sscan (&badhash, NULL, baddata, strlen (baddata)); if (rc) die ("converting data failed: %s\n", gpg_strerror (rc)); @@ -1736,7 +1747,8 @@ if (err) die ("converting sample key failed: %s\n", gpg_strerror (err)); - do_check_one_pubkey (n, skey, pkey, spec.key.grip, spec.flags); + do_check_one_pubkey (n, skey, pkey, + (const unsigned char*)spec.key.grip, spec.flags); gcry_sexp_release (skey); gcry_sexp_release (pkey); Modified: trunk/tests/hmac.c =================================================================== --- trunk/tests/hmac.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/hmac.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -57,12 +57,12 @@ static void check_one_mac (int algo, - void *key, size_t keylen, - void *data, size_t datalen, - char *expect) + const void *key, size_t keylen, + const void *data, size_t datalen, + const char *expect) { gcry_md_hd_t hd; - char *p; + unsigned char *p; int mdlen; int i; gcry_error_t err = 0; Modified: trunk/tests/keygen.c =================================================================== --- trunk/tests/keygen.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/keygen.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -271,7 +271,15 @@ progress_cb (void *cb_data, const char *what, int printchar, int current, int total) { - putchar (printchar); + (void)cb_data; + (void)what; + (void)current; + (void)total; + + if (printchar == '\n') + fputs ( "", stdout); + else + putchar (printchar); fflush (stdout); } Modified: trunk/tests/keygrip.c =================================================================== --- trunk/tests/keygrip.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/keygrip.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -113,6 +113,11 @@ progress_handler (void *cb_data, const char *what, int printchar, int current, int total) { + (void)cb_data; + (void)what; + (void)current; + (void)total; + putchar (printchar); } Modified: trunk/tests/register.c =================================================================== --- trunk/tests/register.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/register.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -45,6 +45,10 @@ gcry_err_code_t foo_setkey (void *c, const unsigned char *key, unsigned keylen) { + (void)c; + (void)key; + (void)keylen; + return 0; } @@ -55,6 +59,8 @@ { int i; + (void)c; + for (i = 0; i < FOO_BLOCKSIZE; i++) outbuf[i] = inbuf[i] ^ 0x42; } @@ -64,6 +70,8 @@ { int i; + (void)c; + for (i = 0; i < FOO_BLOCKSIZE; i++) outbuf[i] = inbuf[i] ^ 0x42; } Modified: trunk/tests/tsexp.c =================================================================== --- trunk/tests/tsexp.c 2007-02-20 11:28:12 UTC (rev 1212) +++ trunk/tests/tsexp.c 2007-02-21 13:26:38 UTC (rev 1213) @@ -222,7 +222,7 @@ size_t expected;/* expected length or 0 on error and then ... */ size_t erroff; /* ... and at this offset */ gcry_error_t errcode; /* ... with this error code */ - unsigned char *text; + const char *text; } values[] = { { 14, 13, 0, GPG_ERR_NO_ERROR, "(9:abcdefghi) " }, { 16, 15, 0, GPG_ERR_NO_ERROR, "(10:abcdefghix)" }, @@ -341,7 +341,7 @@ static void back_and_forth (void) { - static struct { char *buf; int len; } tests[] = { + static struct { const char *buf; int len; } tests[] = { { "(7:g34:fgh1::2:())", 0 }, { "(7:g34:fgh1::2:())", 18 }, { From cvs at cvs.gnupg.org Thu Feb 22 17:37:14 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 22 Feb 2007 17:37:14 +0100 Subject: [svn] gcry - r1214 - in trunk: . cipher doc m4 src tests Message-ID: Author: wk Date: 2007-02-22 17:37:12 +0100 (Thu, 22 Feb 2007) New Revision: 1214 Modified: trunk/ trunk/ChangeLog trunk/Makefile.am trunk/NEWS trunk/README trunk/autogen.sh trunk/cipher/ChangeLog trunk/cipher/Makefile.am trunk/cipher/cipher.c trunk/cipher/rand-internal.h trunk/cipher/random.c trunk/cipher/random.h trunk/cipher/rndw32.c trunk/configure.ac trunk/doc/Makefile.am trunk/doc/gcrypt.texi trunk/m4/ trunk/m4/ChangeLog trunk/m4/noexecstack.m4 trunk/src/ChangeLog trunk/src/Makefile.am trunk/src/ath.c trunk/src/ath.h trunk/src/gcrypt.h.in trunk/src/libgcrypt-config.in trunk/src/libgcrypt.def trunk/src/missing-string.c trunk/src/versioninfo.rc.in trunk/tests/ChangeLog trunk/tests/Makefile.am trunk/tests/pkbench.c trunk/tests/tsexp.c Log: Tweaks for W32 Property changes on: trunk ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile aclocal.m4 autom4te.cache config.h.in config.h config.log config.status configure libtool stamp-h1 Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,3 +1,12 @@ +2007-02-22 Werner Koch + + * configure.ac: New option --enable-random-daemon. + Create versioninfo.rc and provide the build information. + +2007-02-21 Werner Koch + + * Makefile.am, configure.ac: Ignore w32-dll/ + 2007-02-20 Werner Koch * configure.ac: Bump LT version to C14/A3/R0 in preparation for a Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) @@ -20,7 +20,7 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 -DIST_SUBDIRS = m4 mpi cipher src doc tests w32-dll +DIST_SUBDIRS = m4 mpi cipher src doc tests SUBDIRS = mpi cipher src doc tests EXTRA_DIST = BUGS autogen.sh README.apichanges README.SVN DISTCLEANFILES = Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/NEWS 2007-02-22 16:37:12 UTC (rev 1214) @@ -7,6 +7,8 @@ general a good idea to spread this macro into the application code to make sure that these polls happen often enough. + * Made the RNG immune against fork without exec. + * Reading and writing the random seed file is now protected by a fcntl style file lock on systems that provide this function. @@ -25,29 +27,42 @@ * The new function gcry_md_debug should be used instead of the gcry_md_start_debug and gcry_md_stop_debug macros. + * New configure option --enable-random-daemon to support a system + wide random daemon. The daemon code is experimental and not yet + very well working. It will eventually allow to keep a global + random pool for the sake of short living processes. + + * Non executable stack support is now used by default on systems + supporting it. + + * Support for Microsoft Windows OSes. + + * Minor changes to some function declarations. Buffer arguments are + now typed as void pointer. This should not affect any compilation. + Fixed two bugs in return values and clarified documentation. + * Interface changes relative to the 1.2.0 release: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ gcry_fast_random_poll NEW + gcry_md_debug NEW GCRYCTL_FAKED_RANDOM_P NEW - gcry_pk_algo_name CHANGED (minor change in respect to return value) - gcry_cipher_algo_name CHANGED (minor change in respect to return value) GCRY_MD_SHA224 NEW GCRY_PK_USAGE_CERT NEW GCRY_PK_USAGE_AUTH NEW GCRY_PK_USAGE_UNKN NEW + GCR_CIPHER_SEED NEW gcry_mpi_scan CHANGED: Argument BUFFER is now void*. - GCR_CIPHER_SEED NEW - gcry_pk_spec_t CHANGED (minor change, bug fix) - gcry_md_write_t CHANGED (minor change, bug fix) - gcry_md_debug NEW - gcry_cipher_encrypt CHANGED (minor change) - gcry_cipher_decrypt CHANGED (minor change) - gcry_randomize CHANGED (minor change) - gcry_cipher_register CHANGED (minor change) - - FIXME: Please add API changes immediatley so that we don't - forget about them. - + gcry_pk_algo_name CHANGED: Returns "?" instead of NULL. + gcry_cipher_algo_name CHANGED: Returns "?" instead of "". + gcry_pk_spec_t CHANGED: Element ALIASES is now const ptr. + gcry_md_write_t CHANGED: Argument BUF is now a const void*. + gcry_md_ctl CHANGED: Argument BUFFER is now void*. + gcry_cipher_encrypt CHANGED: Arguments IN and OUT are now void*. + gcry_cipher_decrypt CHANGED: Arguments IN and OUT are now void*. + gcry_sexp_sprint CHANGED: Argument BUFFER is now void*. + gcry_create_nonce CHANGED: Argument BUFFER is now void*. + gcry_randomize CHANGED: Argument BUFFER is now void*. + gcry_cipher_register CHANGED: Argument ALGORITHM_ID is now int*. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Modified: trunk/README =================================================================== --- trunk/README 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/README 2007-02-22 16:37:12 UTC (rev 1214) @@ -119,7 +119,12 @@ try to use the OS provided macros at compile time. This is helpful to create OS X fat binaries. + --enable-random-daemon + Include support for a global random damon and + build the daemon. The daemon itself is in an + experimental state. + Contact ------- Modified: trunk/autogen.sh =================================================================== --- trunk/autogen.sh 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/autogen.sh 2007-02-22 16:37:12 UTC (rev 1214) @@ -77,8 +77,7 @@ ./configure --enable-maintainer-mode --prefix=${w32root} \ --host=${host} --build=${build} \ - --with-gpg-error-prefix=${w32root} \ - --disable-shared + --with-gpg-error-prefix=${w32root} exit $? fi Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,3 +1,14 @@ +2007-02-22 Werner Koch + + * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void. + + * cipher.c (gcry_cipher_algo_name): Simplified. + + * random.c: Use the daemon only if compiled with USE_RANDOM_DAEMON. + + * Makefile.am (libcipher_la_SOURCES): Build random-daemon support + only if requested. + 2007-02-21 Werner Koch * random.c (rndpool, keypool): Make unsigned. Modified: trunk/cipher/Makefile.am =================================================================== --- trunk/cipher/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) @@ -40,10 +40,15 @@ cipher.c pubkey.c ac.c md.c \ bithelp.h \ primegen.c \ -random.c random-daemon.c random.h \ +random.c random.h \ rand-internal.h \ rmd.h +if USE_RANDOM_DAEMON +libcipher_la_SOURCES += random-daemon.c +endif USE_RANDOM_DAEMON + + EXTRA_libcipher_la_SOURCES = \ arcfour.c \ blowfish.c \ Modified: trunk/cipher/cipher.c =================================================================== --- trunk/cipher/cipher.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/cipher.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -431,8 +431,7 @@ const char * gcry_cipher_algo_name (int algorithm) { - const char *s = cipher_algo_to_string (algorithm); - return s ? s : ""; + return cipher_algo_to_string (algorithm); } Modified: trunk/cipher/rand-internal.h =================================================================== --- trunk/cipher/rand-internal.h 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/rand-internal.h 2007-02-22 16:37:12 UTC (rev 1214) @@ -33,8 +33,8 @@ 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 ); +void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, int), + int requester ); Modified: trunk/cipher/random.c =================================================================== --- trunk/cipher/random.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/random.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -94,7 +94,7 @@ static int is_initialized; -static int allow_daemon; /* If true, try to use the daemon first. */ + #define MASK_LEVEL(a) do { (a) &= 3; } while(0) static unsigned char *rndpool; /* Allocated size is POOLSIZE+BLOCKLEN. */ static unsigned char *keypool; /* Allocated size is POOLSIZE+BLOCKLEN. */ @@ -105,9 +105,13 @@ static int just_mixed; static int did_initial_extra_seeding; static char *seed_file_name; -static char *daemon_socket_name; static int allow_seed_file_update; +#ifdef USE_RANDOM_DAEMON +static int allow_daemon; /* If true, try to use the daemon first. */ +static char *daemon_socket_name; /* User supplied name of the socket. */ +#endif /*USE_RANDOM_DAEMON*/ + static int secure_alloc; static int quick_test; static int faked_rng; @@ -161,7 +165,9 @@ if (err) log_fatal ("failed to create the nonce buffer lock: %s\n", strerror (err) ); +#ifdef USE_RANDOM_DAEMON _gcry_daemon_initialize_basics (); +#endif /*USE_RANDOM_DAEMON*/ } } @@ -255,10 +261,14 @@ void _gcry_set_random_daemon_socket (const char *socketname) { +#ifdef USE_RANDOM_DAEMON if (daemon_socket_name) BUG (); daemon_socket_name = gcry_xstrdup (socketname); +#else /*!USE_RANDOM_DAEMON*/ + (void)socketname; +#endif /*!USE_RANDOM_DAEMON*/ } /* With ONOFF set to 1, enable the use of the daemon. With ONOFF set @@ -267,6 +277,7 @@ int _gcry_use_random_daemon (int onoff) { +#ifdef USE_RANDOM_DAEMON int last; /* FIXME: This is not really thread safe. */ @@ -275,6 +286,10 @@ allow_daemon = onoff; return last; +#else /*!USE_RANDOM_DAEMON*/ + (void)onoff; + return 0; +#endif /*!USE_RANDOM_DAEMON*/ } @@ -304,11 +319,13 @@ /* Make sure the requested level is in range. */ MASK_LEVEL(level); +#ifdef USE_RANDOM_DAEMON if (allow_daemon && (p=_gcry_daemon_get_random_bytes (daemon_socket_name, nbytes, level,secure))) return p; /* The daemon succeeded. */ allow_daemon = 0; /* Daemon failed - switch off. */ +#endif /*USE_RANDOM_DAEMON*/ /* Lock the pool. */ err = ath_mutex_lock (&pool_lock); @@ -420,10 +437,12 @@ /* Make sure the level is okay. */ MASK_LEVEL(level); +#ifdef USE_RANDOM_DAEMON if (allow_daemon && !_gcry_daemon_randomize (daemon_socket_name, buffer, length, level)) return; /* The daemon succeeded. */ allow_daemon = 0; /* Daemon failed - switch off. */ +#endif /*USE_RANDOM_DAEMON*/ /* Acquire the pool lock. */ err = ath_mutex_lock (&pool_lock); @@ -1241,10 +1260,12 @@ if (!is_initialized) initialize (); +#ifdef USE_RANDOM_DAEMON if (allow_daemon && !_gcry_daemon_create_nonce (daemon_socket_name, buffer, length)) return; /* The daemon succeeded. */ allow_daemon = 0; /* Daemon failed - switch off. */ +#endif /*USE_RANDOM_DAEMON*/ /* Acquire the nonce buffer lock. */ err = ath_mutex_lock (&nonce_buffer_lock); Modified: trunk/cipher/random.h =================================================================== --- trunk/cipher/random.h 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/random.h 2007-02-22 16:37:12 UTC (rev 1214) @@ -38,6 +38,7 @@ void _gcry_fast_random_poll( void ); /*-- random-daemon.c (only used from random.c) --*/ +#ifdef USE_RANDOM_DAEMON void _gcry_daemon_initialize_basics (void); int _gcry_daemon_randomize (const char *socketname, void *buffer, size_t length, @@ -46,8 +47,8 @@ size_t nbytes, int level, int secure); int _gcry_daemon_create_nonce (const char *socketname, void *buffer, size_t length); +#endif /*USE_RANDOM_DAEMON*/ - #endif /*G10_RANDOM_H*/ Modified: trunk/cipher/rndw32.c =================================================================== --- trunk/cipher/rndw32.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/cipher/rndw32.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -548,7 +548,7 @@ } -int +void _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t, int), int requester ) { @@ -677,7 +677,5 @@ (*add) (&aword, sizeof (aword), requester ); } } - - return 0; } Modified: trunk/configure.ac =================================================================== --- trunk/configure.ac 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/configure.ac 2007-02-22 16:37:12 UTC (rev 1214) @@ -48,7 +48,7 @@ NEED_GPG_ERROR_VERSION=1.0 - +BUILD_REVISION=svn_revision PACKAGE=$PACKAGE_NAME VERSION=$PACKAGE_VERSION @@ -215,7 +215,7 @@ -# A printable OS Name is sometime useful. +# A printable OS Name is sometimes useful. case "${target}" in *-*-mingw32*) PRINTABLE_OS_NAME="MingW32" @@ -238,7 +238,7 @@ ;; esac - +# Figure out the name of the random device case "${target}" in *-openbsd*) # FIXME: Are these the best flags for OpenBSD? @@ -401,6 +401,21 @@ [Define if you don't want the default EGD socket name. For details see cipher/rndegd.c]) +# Implementation of the --enable-random-daemon +AC_MSG_CHECKING([whether the experimental random daemon is requested]) +AC_ARG_ENABLE([random-daemon], + AC_HELP_STRING([--enable-random-daemon], + [Build and support the experimental gcryptrnd]), + [use_random_daemon=$enableval], + [use_random_daemon=no]) +AC_MSG_RESULT($use_random_daemon) +if test x$use_random_daemon = xyes ; then + AC_DEFINE(USE_RANDOM_DAEMON,1, + [Define to support the experimental random daemon]) +fi +AM_CONDITIONAL(USE_RANDOM_DAEMON, test x$use_random_daemon = xyes) + + # Implementation of --disable-asm. AC_MSG_CHECKING([whether assembler modules are requested]) AC_ARG_ENABLE([asm], @@ -482,8 +497,9 @@ if test x$pth_config_prefix != x ; then PTH_CONFIG="$pth_config_prefix/bin/pth-config" fi -AC_PATH_PROG(PTH_CONFIG, pth-config, no) -if test "$PTH_CONFIG" = "no"; then +if test "$use_random_daemon" = "yes"; then + AC_PATH_PROG(PTH_CONFIG, pth-config, no) + if test "$PTH_CONFIG" = "no"; then AC_MSG_WARN([[ *** *** To build the Libgcrypt's random humber daemon @@ -492,16 +508,17 @@ *** On a Debian GNU/Linux system you might want to try *** apt-get install libpth-dev ***]]) - else - GNUPG_PTH_VERSION_CHECK([1.3.7]) - if test $have_pth = yes; then - PTH_CFLAGS=`$PTH_CONFIG --cflags` - PTH_LIBS=`$PTH_CONFIG --ldflags` - PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`" - AC_DEFINE(USE_GNU_PTH, 1, - [Defined if the GNU Portable Thread Library should be used]) - AC_DEFINE(HAVE_PTH, 1, - [Defined if the GNU Pth is available]) + else + GNUPG_PTH_VERSION_CHECK([1.3.7]) + if test $have_pth = yes; then + PTH_CFLAGS=`$PTH_CONFIG --cflags` + PTH_LIBS=`$PTH_CONFIG --ldflags` + PTH_LIBS="$PTH_LIBS `$PTH_CONFIG --libs --all`" + AC_DEFINE(USE_GNU_PTH, 1, + [Defined if the GNU Portable Thread Library should be used]) + AC_DEFINE(HAVE_PTH, 1, + [Defined if the GNU Pth is available]) + fi fi fi AC_SUBST(PTH_CFLAGS) @@ -882,6 +899,23 @@ AC_SUBST(LIBGCRYPT_DIGESTS, $enabled_digests) +# Generate extended version information for W32. +if test "$have_w32_system" = yes; then + BUILD_TIMESTAMP=`date --iso-8601=minutes` + changequote(,)dnl + BUILD_FILEVERSION=`echo "$VERSION" | sed 's/\([0-9.]*\).*/\1./;s/\./,/g'` + changequote([,])dnl + BUILD_FILEVERSION="${BUILD_FILEVERSION}${BUILD_REVISION}" +fi +AC_SUBST(BUILD_REVISION) +AC_SUBST(BUILD_TIMESTAMP) +AC_SUBST(BUILD_FILEVERSION) +AC_DEFINE_UNQUOTED(BUILD_REVISION, "$BUILD_REVISION", + [Subversion revision used to build this package]) + + + +# And create the files. AC_CONFIG_FILES([ Makefile m4/Makefile @@ -891,8 +925,8 @@ src/Makefile src/gcrypt.h src/libgcrypt-config +src/versioninfo.rc tests/Makefile -w32-dll/Makefile ]) AC_OUTPUT Modified: trunk/doc/Makefile.am =================================================================== --- trunk/doc/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/doc/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) @@ -23,11 +23,11 @@ gcrypt_TEXINFOS = lgpl.texi gpl.texi -online: gcrypt.html gcrypt.pdf +online: gcrypt.html gcrypt.pdf gcrypt.info set -e; \ echo "Uploading current manuals to www.gnupg.org ..."; \ - user=werner ; \ + user=werner ; dir="webspace/manuals/gcrypt-devel/" ; \ (cd gcrypt.html && rsync -vr --exclude='.svn' . \ - $${user}@cvs.gnupg.org:webspace/manuals/gcrypt/ ); \ - rsync -v gcrypt.pdf $${user}@cvs.gnupg.org:webspace/manuals/ + $${user}@cvs.gnupg.org:$${dir} ); \ + rsync -v gcrypt.pdf gcrypt.info $${user}@cvs.gnupg.org:$${dir} Modified: trunk/doc/gcrypt.texi =================================================================== --- trunk/doc/gcrypt.texi 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/doc/gcrypt.texi 2007-02-22 16:37:12 UTC (rev 1214) @@ -12,7 +12,7 @@ (version @value{VERSION}, @value{UPDATED}), which is GNU's library of cryptographic building blocks. -Copyright @copyright{} 2000, 2002, 2003, 2004, 2006 Free Software Foundation, Inc. +Copyright @copyright{} 2000, 2002, 2003, 2004, 2006, 2007 Free Software Foundation, Inc. @quotation Permission is granted to copy, distribute and/or modify this document @@ -46,10 +46,11 @@ @insertcopying @end titlepage - + at ifnothtml @summarycontents @contents @page + at end ifnothtml @ifnottex @@ -168,7 +169,13 @@ @end menu + at ifhtml + at page + at summarycontents + at contents + at end ifhtml + @c ********************************************************** @c ******************* Introduction *********************** @c ********************************************************** @@ -1567,8 +1574,8 @@ @code{gcry_cipher_algo_name} returns a string with the name of the cipher algorithm @var{algo}. If the algorithm is not known or another -error occurred, an empty string is returned. This function will never -return @code{NULL}. +error occurred, the string @code{"?"} is returned. This function should +not be used to test for the availability of an algorithm. @end deftypefun @deftypefun int gcry_cipher_map_name (const char *@var{name}) @@ -1956,8 +1963,8 @@ @deftypefun const char *gcry_md_algo_name (int @var{algo}) Map the digest algorithm id @var{algo} to a string representation of the -algorithm name. For unknown algorithms this function returns an -empty string. This function should not be used to test for the +algorithm name. For unknown algorithms this function returns the +string @code{"?"}. This function should not be used to test for the availability of an algorithm. @end deftypefun @@ -2565,8 +2572,9 @@ @deftypefun {const char *} gcry_pk_algo_name (int @var{algo}) Map the public key algorithm id @var{algo} to a string representation of -the algorithm name. For unknown algorithms this functions returns an -empty string. +the algorithm name. For unknown algorithms this functions returns the +string @code{"?"}. This function should not be used to test for the +availability of an algorithm. @end deftypefun @deftypefun int gcry_pk_map_name (const char *@var{name}) @@ -3025,7 +3033,7 @@ @var{algorithm} must be a valid algorithm ID, see @xref{Available algorithms}, for a list of supported algorithms and the according constants. Besides using the listed constants directly, the functions - at code{gcry_ac_name_to_id} may be used to convert the textual name of + at code{gcry_pk_name_to_id} may be used to convert the textual name of an algorithm into the according numeric ID. @end deftypefun @@ -3307,14 +3315,17 @@ @node Handle-independent functions @section Handle-independent functions +These two functions are deprecated; do not use them for new code. + @deftypefun gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t @var{algorithm}, const char **@var{name}) Stores the textual representation of the algorithm whose id is given -in @var{algorithm} in @var{name}. +in @var{algorithm} in @var{name}. Deprecated; use @code{gcry_pk_algo_name}. @end deftypefun @deftypefun gcry_error_t gcry_ac_name_to_id (const char *@var{name}, gcry_ac_id_t *@var{algorithm}) Stores the numeric ID of the algorithm whose textual representation is -contained in @var{name} in @var{algorithm}. +contained in @var{name} in @var{algorithm}. Deprecated; use + at code{gcry_pk_map_name}. @end deftypefun @c ********************************************************** Property changes on: trunk/m4 ___________________________________________________________________ Name: svn:ignore + Makefile.in Makefile Modified: trunk/m4/ChangeLog =================================================================== --- trunk/m4/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/m4/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,3 +1,7 @@ +2007-02-22 Werner Koch + + * noexecstack.m4: Change default to enable it. + 2007-02-20 Werner Koch * Makefile.am: New. Modified: trunk/m4/noexecstack.m4 =================================================================== --- trunk/m4/noexecstack.m4 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/m4/noexecstack.m4 2007-02-22 16:37:12 UTC (rev 1214) @@ -25,9 +25,9 @@ AC_MSG_CHECKING([whether non excutable stack support is requested]) AC_ARG_ENABLE(noexecstack, - AC_HELP_STRING([--enable-noexecstack], - [enable non executable stack support (gcc only)]), - noexecstack_support=$enableval, noexecstack_support=no) + AC_HELP_STRING([--disable-noexecstack], + [disable non executable stack support]), + noexecstack_support=$enableval, noexecstack_support=yes) AC_MSG_RESULT($noexecstack_support) AC_CACHE_CHECK([whether assembler supports --noexecstack option], Modified: trunk/src/ChangeLog =================================================================== --- trunk/src/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,5 +1,29 @@ +2007-02-22 Werner Koch + + * gcrypt.h.in (gcry_ac_id_to_name, gcry_ac_name_to_id): Mark as + deprecated. + + * libgcrypt.def (gcry_fast_random_poll): Removed - it is a macro. + (gcry_cipher_register, gcry_cipher_unregister): New. + (gcry_md_register, gcry_md_unregister): New. + (gcry_pk_register, gcry_pk_unregister): New. + (gcry_ac_data_from_sexp, gcry_ac_data_to_sexp): New. + (gcry_ac_io_init, gcry_ac_io_init_va): New. + (gcry_ac_data_encrypt_scheme, gcry_ac_data_decrypt_scheme): New. + (gcry_ac_data_sign_scheme, gcry_ac_data_verify_scheme): New. + + * missing-string.c: Include stdio.h for the vsprintf prototype. + + * ath.h (struct ath_ops) [_WIN32]: Use int instead of socklen_t. + 2007-02-21 Werner Koch + * libgcrypt.def (gcry_create_nonce, gcry_fast_random_poll) + (gcry_md_debug): New. + + * libgcrypt-config.in: Remove duplicates from --cflags and --libs. + Print a error for option --thread. + * gcrypt.h.in (gcry_sexp_sprint): Change BUFFER from char* to void*. (gcry_md_ctl): Change BUFFER from unsigned char* to void*. (gcry_md_debug): New. Modified: trunk/src/Makefile.am =================================================================== --- trunk/src/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,4 +1,6 @@ -# Copyright (C) 1998,1999,2000,2001,2002,2003,2004,2005,2006 Free Software Foundation, Inc. +# Makefile.am - for gcrypt/src +# Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, +# 2006, 2007 Free Software Foundation, Inc. # # This file is part of Libgcrypt. # @@ -26,8 +28,10 @@ include_HEADERS = gcrypt.h gcrypt-module.h lib_LTLIBRARIES = libgcrypt.la +if USE_RANDOM_DAEMON sbin_PROGRAMS = gcryptrnd bin_PROGRAMS = getrandom +endif USE_RANDOM_DAEMON if HAVE_LD_VERSION_SCRIPT libgcrypt_version_script_cmd = -Wl,--version-script=$(srcdir)/libgcrypt.vers @@ -65,7 +69,8 @@ gcrypt_deps = $(gcrypt_res) libgcrypt.def -else +else !HAVE_W32_SYSTEM + gcrypt_res = gcrypt_res_ldflag = no_undefined = @@ -74,8 +79,10 @@ uninstall-def-file: gcrypt_deps = -endif +endif !HAVE_W32_SYSTEM + + libgcrypt_la_LDFLAGS = $(gcrypt_res_ldflag) $(no_undefined) $(export_symbols) \ $(libgcrypt_version_script_cmd) -version-info \ @LIBGCRYPT_LT_CURRENT@:@LIBGCRYPT_LT_REVISION@:@LIBGCRYPT_LT_AGE@ @@ -84,12 +91,16 @@ libgcrypt_la_LIBADD = ../cipher/libcipher.la ../mpi/libmpi.la \ @LTLIBOBJS@ @GPG_ERROR_LIBS@ + +if USE_RANDOM_DAEMON gcryptrnd_SOURCES = gcryptrnd.c gcryptrnd_CFLAGS = $(GPG_ERROR_CFLAGS) $(PTH_CFLAGS) gcryptrnd_LDADD = ../src/libgcrypt.la $(PTH_LIBS) getrandom_SOURCES = getrandom.c +endif USE_RANDOM_DAEMON + install-data-local: install-def-file uninstall-local: uninstall-def-file Modified: trunk/src/ath.c =================================================================== --- trunk/src/ath.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/ath.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -285,7 +285,7 @@ int #ifdef _WIN32 -ath_connect (int s, void *addr, socklen_t length) +ath_connect (int s, void *addr, int length) #else ath_connect (int s, struct sockaddr *addr, socklen_t length) #endif Modified: trunk/src/ath.h =================================================================== --- trunk/src/ath.h 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/ath.h 2007-02-22 16:37:12 UTC (rev 1214) @@ -80,7 +80,7 @@ struct timeval *timeout); ssize_t (*waitpid) (pid_t pid, int *status, int options); int (*accept) (int s, void *addr, int *length_ptr); - int (*connect) (int s, void *addr, socklen_t length); + int (*connect) (int s, void *addr, int length); int (*sendmsg) (int s, const void *msg, int flags); int (*recvmsg) (int s, void *msg, int flags); #else Modified: trunk/src/gcrypt.h.in =================================================================== --- trunk/src/gcrypt.h.in 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/gcrypt.h.in 2007-02-22 16:37:12 UTC (rev 1214) @@ -1092,8 +1092,8 @@ size_t *nbytes); /* Map the digest algorithm id ALGO to a string representation of the - algorithm name. For unknown algorithms this functions returns an - empty string. */ + algorithm name. For unknown algorithms this functions returns + "?". */ const char *gcry_md_algo_name (int algo) _GCRY_GCC_ATTR_PURE; /* Map the algorithm NAME to a digest algorithm Id. Return 0 if @@ -1515,14 +1515,16 @@ gcry_ac_io_t *io_signature); /* Store the textual representation of the algorithm whose id is given - in ALGORITHM in NAME. */ + in ALGORITHM in NAME. This function is deprecated; use + gcry_pk_algo_name. */ gcry_error_t gcry_ac_id_to_name (gcry_ac_id_t algorithm, - const char **name); - + const char **name) _GCRY_GCC_ATTR_DEPRECATED; /* Store the numeric ID of the algorithm whose textual representation - is contained in NAME in ALGORITHM. */ + is contained in NAME in ALGORITHM. This function is deprecated; + use gcry_pk_map_name. */ gcry_error_t gcry_ac_name_to_id (const char *name, - gcry_ac_id_t *algorithm); + gcry_ac_id_t *algorithm + ) _GCRY_GCC_ATTR_DEPRECATED;; Modified: trunk/src/libgcrypt-config.in =================================================================== --- trunk/src/libgcrypt-config.in 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/libgcrypt-config.in 2007-02-22 16:37:12 UTC (rev 1214) @@ -8,6 +8,8 @@ # This file is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY, to the extent permitted by law; without even the # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# File: @configure_input@ # General. prefix="@prefix@" @@ -75,7 +77,7 @@ case $1 in --thread=*) echo "$0: --thread option obsolete: use the thread callback interface" 1>&2 - # exit 1 <-- enable this for 1.2.0. + exit 1 ;; --prefix=*) # For compatibility reasons with old M4 macros, we ignore @@ -130,7 +132,13 @@ # Set up `cflags_final'. cflags_final="$cflags_final $gpg_error_cflags" - echo "$includes $cflags_final" + tmp="" + for i in $includes $cflags_final; do + if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then + tmp="$tmp $i" + fi + done + echo $tmp fi if test "$echo_libs" = "yes"; then @@ -145,7 +153,13 @@ # Set up `libs_final'. libs_final="$libs_final $gpg_error_libs" - echo "$libdirs $libs_final" + tmp="" + for i in $libdirs $libs_final; do + if echo "$tmp" | fgrep -v -- "$i" >/dev/null; then + tmp="$tmp $i" + fi + done + echo $tmp fi if test "$echo_version" = "yes"; then Modified: trunk/src/libgcrypt.def =================================================================== --- trunk/src/libgcrypt.def 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/libgcrypt.def 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,5 +1,5 @@ ;; libgcrypt.defs - Exported symbols for W32 -;; Copyright (C) 2003 Free Software Foundation, Inc. +;; Copyright (C) 2003, 2007 Free Software Foundation, Inc. ;; ;; This file is part of Libgcrypt. ;; @@ -204,3 +204,23 @@ gcry_prime_group_generator @168 gcry_prime_release_factors @169 gcry_prime_check @170 + + gcry_create_nonce @171 + + gcry_md_debug @172 + + gcry_cipher_register @173 + gcry_cipher_unregister @174 + gcry_md_register @175 + gcry_md_unregister @176 + gcry_pk_register @177 + gcry_pk_unregister @178 + + gcry_ac_data_from_sexp @179 + gcry_ac_data_to_sexp @180 + gcry_ac_io_init @181 + gcry_ac_io_init_va @182 + gcry_ac_data_encrypt_scheme @183 + gcry_ac_data_decrypt_scheme @184 + gcry_ac_data_sign_scheme @185 + gcry_ac_data_verify_scheme @186 Modified: trunk/src/missing-string.c =================================================================== --- trunk/src/missing-string.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/missing-string.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -20,6 +20,7 @@ */ #include +#include #include #include #include Modified: trunk/src/versioninfo.rc.in =================================================================== --- trunk/src/versioninfo.rc.in 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/src/versioninfo.rc.in 2007-02-22 16:37:12 UTC (rev 1214) @@ -34,12 +34,13 @@ BEGIN BLOCK "040904b0" BEGIN - VALUE "Comments", "Provided under the terms of the GNU Lesser General Public License.\0" + /* Note that the Windows versioin falls under the GPL. */ + VALUE "Comments", "Provided under the terms of the GNU General Public License.\0" VALUE "CompanyName", "g10 Code GmbH\0" - VALUE "FileDescription", "libgcrypt - The GNU crypto library\0" + VALUE "FileDescription", "Libgcrypt - The GNU Crypto Library\0" VALUE "FileVersion", "@LIBGCRYPT_LT_CURRENT at .@LIBGCRYPT_LT_AGE at .@LIBGCRYPT_LT_REVISION at .@BUILD_REVISION@\0" VALUE "InternalName", "libgcrypt\0" - VALUE "LegalCopyright", "Copyright ? 2005, 2006 g10 Code GmbH\0" + VALUE "LegalCopyright", "Copyright ? 2007 Free Software Foundation, Inc.\0" VALUE "LegalTrademarks", "\0" VALUE "OriginalFilename", "libgcrypt.dll\0" VALUE "PrivateBuild", "\0" Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/tests/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) @@ -1,3 +1,8 @@ +2007-02-22 Werner Koch + + * Makefile.am (TESTS) [W32]: Removed pkbench for now. + * pkbench.c (benchmark): Fixed for W32. + 2007-02-21 Werner Koch * hmac.c (check_one_mac): Make pointer args const. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/tests/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) @@ -19,8 +19,15 @@ ## Process this file with automake to produce Makefile.in TESTS = t-mpi-bit prime register ac ac-schemes ac-data basic \ - tsexp keygen pubkey benchmark pkbench hmac keygrip + tsexp keygen pubkey benchmark hmac keygrip +# pkbench uses mmap for no good reason. Needs to be fixed. Code for +# this can be found in libksba/tests. +if !HAVE_W32_SYSTEM +TESTS += pkbench +endif + + # Need to include ../src in addition to top_srcdir because gcrypt.h is # a built header. AM_CPPFLAGS = -I../src -I$(top_srcdir)/src Modified: trunk/tests/pkbench.c =================================================================== --- trunk/tests/pkbench.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/tests/pkbench.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -27,7 +27,9 @@ #include #include #include +#ifndef HAVE_W32_SYSTEM #include +#endif HAVE_W32_SYSTEM #include #include #include @@ -52,16 +54,24 @@ struct tms timer; int ret = 0; +#ifdef HAVE_W32_SYSTEM + timer_start = clock (); +#else times (&timer); timer_start = timer.tms_utime; +#endif for (i = 0; i < loop; i++) { ret = (*worker) (context, (i + 1) == loop); if (! ret) break; } +#ifdef HAVE_W32_SYSTEM + timer_stop = clock (); +#else times (&timer); timer_stop = timer.tms_utime; +#endif if (ret) printf ("%.0f ms\n", Modified: trunk/tests/tsexp.c =================================================================== --- trunk/tests/tsexp.c 2007-02-21 13:26:38 UTC (rev 1213) +++ trunk/tests/tsexp.c 2007-02-22 16:37:12 UTC (rev 1214) @@ -248,7 +248,8 @@ info ("checking canoncial length test function\n"); for (idx=0; values[idx].text; idx++) { - n = gcry_sexp_canon_len (values[idx].text, values[idx].textlen, + n = gcry_sexp_canon_len ((const unsigned char*)values[idx].text, + values[idx].textlen, &erroff, &errcode); if (n && n == values[idx].expected) From cvs at cvs.gnupg.org Thu Feb 22 19:25:31 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Thu, 22 Feb 2007 19:25:31 +0100 Subject: [svn] gcry - r1215 - in trunk: . cipher tests Message-ID: Author: wk Date: 2007-02-22 19:25:27 +0100 (Thu, 22 Feb 2007) New Revision: 1215 Modified: trunk/ChangeLog trunk/Makefile.am trunk/THANKS trunk/TODO trunk/cipher/ChangeLog trunk/cipher/md.c trunk/cipher/pubkey.c trunk/tests/ChangeLog trunk/tests/basic.c trunk/tests/pkbench.c Log: Fixed bug#596 adn minor cleanups Modified: trunk/ChangeLog =================================================================== --- trunk/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) @@ -1,11 +1,14 @@ 2007-02-22 Werner Koch + * Makefile.am (DISTCHECK_CONFIGURE_FLAGS): Use + --enable-random-daemon. + * configure.ac: New option --enable-random-daemon. Create versioninfo.rc and provide the build information. 2007-02-21 Werner Koch - * Makefile.am, configure.ac: Ignore w32-dll/ + * Makefile.am, configure.ac: Ignore w32-dll/. 2007-02-20 Werner Koch Modified: trunk/Makefile.am =================================================================== --- trunk/Makefile.am 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/Makefile.am 2007-02-22 18:25:27 UTC (rev 1215) @@ -19,6 +19,7 @@ ACLOCAL_AMFLAGS = -I m4 AUTOMAKE_OPTIONS = dist-bzip2 +DISTCHECK_CONFIGURE_FLAGS = --enable-random-daemon DIST_SUBDIRS = m4 mpi cipher src doc tests SUBDIRS = mpi cipher src doc tests Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/THANKS 2007-02-22 18:25:27 UTC (rev 1215) @@ -79,6 +79,7 @@ Michael Sobolev mss at despair.transas.com Michele Baldessari michele at pupazzo.org Modestas Vainius geromanas at mailas.com +Neil Dunbar neil.dunbar at pobox.com Neil Spring nspring at cs.washington.edu Newton Hammet newton at hammet.net Nicolas Graner Nicolas.Graner at cri.u-psud.fr Modified: trunk/TODO =================================================================== --- trunk/TODO 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/TODO 2007-02-22 18:25:27 UTC (rev 1215) @@ -2,8 +2,6 @@ * Updated the FSF's directory. -* Add more tests. - * udiv-qrnbd.o should get build as *.lo [HPUX] * Allow operation using RSA keys consisting of the OpenSSL list of @@ -14,15 +12,14 @@ been compiled with thread support when used by a threaded application. -* write an autoconf test to check whether the linker supports a - version script. +* linker script test + Write an autoconf test to check whether the linker supports a + version script. * Make use of the forthcoming visibility attribute. * Add attributes to the MPI functions. -* Write tests for the progress function - * In case the ac interface will be more popular than the pk interface, the asymmetric ciphers could be changed for convenient interaction with the ac interface (i.e. by using ac's `data sets') and the pk @@ -39,8 +36,8 @@ * Use builtin bit functions of gcc 3.4 * Consider using a daemon to maintain he random pool - - The down side of this is that we can't assume that the random das + [Partly done] + The down side of this is that we can't assume that the random has has always been stored in "secure memory". And we rely on that sniffing of Unix domain sockets is not possible. We can implement this simply by detecting a special prefixed random seed name and @@ -56,9 +53,6 @@ There is no shortage of standard memory, so logging is most likely possible. -* signed vs. unsigned. - Sync the code with 1.2 where we have fixed all these issues. - * mpi_print does not use secure memory for internal variables. @@ -71,13 +65,18 @@ Remove use of anonymous union. * ac.c - There are still some things fishy. The fixes I did todat + There are still some things fishy. The fixes I did today (2006-10-23) seem to cure just a symptom. Needs a complete review. * gcryptrnd.c - Requires test for pth and other stuff. + Requires a test for pth [done] as well as some other tests. * secmem.c Check whether the memory block is valid before releasing it and print a diagnosic, like glibc does. +* Tests + We need a lot more tests. Lets keep an ever growing list here. +** Write tests for the progress function + + Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/cipher/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) @@ -1,5 +1,8 @@ 2007-02-22 Werner Koch + * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated + algorithms. Suggested by Neil Dunbar. Fixes bug#596. + * rndw32.c (_gcry_rndw32_gather_random_fast): Make it return void. * cipher.c (gcry_cipher_algo_name): Simplified. Modified: trunk/cipher/md.c =================================================================== --- trunk/cipher/md.c 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/cipher/md.c 2007-02-22 18:25:27 UTC (rev 1215) @@ -303,7 +303,7 @@ ret = search_oid (string, &algorithm, NULL); if (! ret) { - /* Not found, search for an acording diget name. */ + /* Not found, search a matching digest name. */ digest = gcry_md_lookup_name (string); if (digest) { Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/cipher/pubkey.c 2007-02-22 18:25:27 UTC (rev 1215) @@ -1325,12 +1325,32 @@ && !memcmp (hashnames[i].name, s, n)) break; } + if (hashnames[i].name) + algo = hashnames[i].algo; + else + { + /* In case of not listed or dynamically allocated hash + algorithm we fall back to this somewhat slower + method. Further, it also allows to use OIDs as + algorithm names. */ + char *tmpname; - algo = hashnames[i].algo; + tmpname = gcry_malloc (n+1); + if (!tmpname) + algo = 0; /* Out of core - silently give up. */ + else + { + memcpy (tmpname, s, n); + tmpname[n] = 0; + algo = gcry_md_map_name (tmpname); + gcry_free (tmpname); + } + } + asnlen = DIM(asn); dlen = gcry_md_get_algo_dlen (algo); - if (!hashnames[i].name) + if (!algo) rc = GPG_ERR_DIGEST_ALGO; else if ( !(value=gcry_sexp_nth_data (lhash, 2, &valuelen)) || !valuelen ) Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/tests/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) @@ -1,5 +1,7 @@ 2007-02-22 Werner Koch + * basic.c (check_pubkey_sign): Also try signing using an OID. + * Makefile.am (TESTS) [W32]: Removed pkbench for now. * pkbench.c (benchmark): Fixed for W32. Modified: trunk/tests/basic.c =================================================================== --- trunk/tests/basic.c 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/tests/basic.c 2007-02-22 18:25:27 UTC (rev 1215) @@ -1654,6 +1654,12 @@ { "(data\n (flags pkcs1)\n" " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n", 0 }, + /* This test is to see whether hash algorithms not hard wired in + pubkey.c are detected: */ + { "(data\n (flags pkcs1)\n" + " (hash oid.1.3.14.3.2.29 " + " #11223344556677889900AABBCCDDEEFF10203040#))\n", + 0 }, { "(data\n (flags )\n" " (hash sha1 #11223344556677889900AABBCCDDEEFF10203040#))\n", GPG_ERR_CONFLICT }, Modified: trunk/tests/pkbench.c =================================================================== --- trunk/tests/pkbench.c 2007-02-22 16:37:12 UTC (rev 1214) +++ trunk/tests/pkbench.c 2007-02-22 18:25:27 UTC (rev 1215) @@ -29,7 +29,7 @@ #include #ifndef HAVE_W32_SYSTEM #include -#endif HAVE_W32_SYSTEM +#endif /*HAVE_W32_SYSTEM*/ #include #include #include From cvs at cvs.gnupg.org Fri Feb 23 18:47:58 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Fri, 23 Feb 2007 18:47:58 +0100 Subject: [svn] gcry - r1216 - in trunk: cipher mpi src tests Message-ID: Author: wk Date: 2007-02-23 18:47:56 +0100 (Fri, 23 Feb 2007) New Revision: 1216 Added: trunk/tests/random.c Modified: trunk/cipher/ChangeLog trunk/cipher/elgamal.c trunk/cipher/pubkey.c trunk/mpi/ChangeLog trunk/mpi/mpi-pow.c trunk/mpi/mpiutil.c trunk/src/cipher.h trunk/tests/ChangeLog trunk/tests/Makefile.am trunk/tests/ac-data.c trunk/tests/pubkey.c Log: Ported last changes from 1.2. Updated some tests. Support for passphrase generated Elgamal keys. Modified: trunk/cipher/ChangeLog =================================================================== --- trunk/cipher/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/cipher/ChangeLog 2007-02-23 17:47:56 UTC (rev 1216) @@ -1,3 +1,12 @@ +2007-02-23 Werner Koch + + * elgamal.c (generate): Removed unused variable TEMP. + (test_keys): New arg NODIE. + (generate_using_x, _gcry_elg_generate_using_x): New. + * pubkey.c (pubkey_generate): New arg XVALUE and direct call to + the new elgamal generate fucntion. + (gcry_pk_genkey): Parse the new "xvalue" tag. + 2007-02-22 Werner Koch * pubkey.c (sexp_data_to_mpi): Handle dynamically allocated Modified: trunk/cipher/elgamal.c =================================================================== --- trunk/cipher/elgamal.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/cipher/elgamal.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -1,4 +1,4 @@ -/* Elgamal.c - ElGamal Public Key encryption +/* Elgamal.c - Elgamal Public Key encryption * Copyright (C) 1998, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. * * This file is part of Libgcrypt. @@ -47,7 +47,7 @@ } ELG_secret_key; -static void test_keys (ELG_secret_key *sk, unsigned nbits); +static int test_keys (ELG_secret_key *sk, unsigned int nbits, int nodie); static gcry_mpi_t gen_k (gcry_mpi_t p, int small_k); static void generate (ELG_secret_key *sk, unsigned nbits, gcry_mpi_t **factors); static int check_secret_key (ELG_secret_key *sk); @@ -123,34 +123,46 @@ return n / 8 + 200; } -static void -test_keys( ELG_secret_key *sk, unsigned nbits ) +static int +test_keys ( ELG_secret_key *sk, unsigned int nbits, int nodie ) { ELG_public_key pk; gcry_mpi_t test = gcry_mpi_new ( 0 ); gcry_mpi_t out1_a = gcry_mpi_new ( nbits ); gcry_mpi_t out1_b = gcry_mpi_new ( nbits ); gcry_mpi_t out2 = gcry_mpi_new ( nbits ); + int failed = 0; pk.p = sk->p; pk.g = sk->g; pk.y = sk->y; - gcry_mpi_randomize( test, nbits, GCRY_WEAK_RANDOM ); + gcry_mpi_randomize ( test, nbits, GCRY_WEAK_RANDOM ); - do_encrypt( out1_a, out1_b, test, &pk ); - decrypt( out2, out1_a, out1_b, sk ); - if( mpi_cmp( test, out2 ) ) - log_fatal("ElGamal operation: encrypt, decrypt failed\n"); + do_encrypt ( out1_a, out1_b, test, &pk ); + decrypt ( out2, out1_a, out1_b, sk ); + if ( mpi_cmp( test, out2 ) ) + failed |= 1; - sign( out1_a, out1_b, test, sk ); - if( !verify( out1_a, out1_b, test, &pk ) ) - log_fatal("ElGamal operation: sign, verify failed\n"); + sign ( out1_a, out1_b, test, sk ); + if ( !verify( out1_a, out1_b, test, &pk ) ) + failed |= 2; gcry_mpi_release ( test ); gcry_mpi_release ( out1_a ); gcry_mpi_release ( out1_b ); gcry_mpi_release ( out2 ); + + if (failed && !nodie) + log_fatal ("Elgamal test key for %s %s failed\n", + (failed & 1)? "encrypt+decrypt":"", + (failed & 2)? "sign+verify":""); + if (failed && DBG_CIPHER) + log_debug ("Elgamal test key for %s %s failed\n", + (failed & 1)? "encrypt+decrypt":"", + (failed & 2)? "sign+verify":""); + + return failed; } @@ -239,7 +251,7 @@ /**************** * Generate a key pair with a key of size NBITS - * Returns: 2 structures filles with all needed values + * Returns: 2 structures filled with all needed values * and an array with n-1 factors of (p-1) */ static void @@ -250,13 +262,11 @@ gcry_mpi_t g; gcry_mpi_t x; /* the secret exponent */ gcry_mpi_t y; - gcry_mpi_t temp; unsigned int qbits; unsigned int xbits; byte *rndbuf; p_min1 = gcry_mpi_new ( nbits ); - temp = gcry_mpi_new( nbits ); qbits = wiener_map( nbits ); if( qbits & 1 ) /* better have a even one */ qbits++; @@ -332,11 +342,90 @@ sk->y = y; sk->x = x; + gcry_mpi_release ( p_min1 ); + /* Now we can test our keys (this should never fail!) */ - test_keys( sk, nbits - 64 ); + test_keys ( sk, nbits - 64, 0 ); +} + +/* Generate a key pair with a key of size NBITS not using a random + value for the secret key but the one given as X. This is useful to + implement a passphrase based decryption for a public key based + encryption. It has appliactions in backup systems. + + Returns: A structure filled with all needed values and an array + with n-1 factors of (p-1). */ +static gcry_err_code_t +generate_using_x (ELG_secret_key *sk, unsigned int nbits, gcry_mpi_t x, + gcry_mpi_t **ret_factors ) +{ + gcry_mpi_t p; /* The prime. */ + gcry_mpi_t p_min1; /* The prime minus 1. */ + gcry_mpi_t g; /* The generator. */ + gcry_mpi_t y; /* g^x mod p. */ + unsigned int qbits; + unsigned int xbits; + + sk->p = NULL; + sk->g = NULL; + sk->y = NULL; + sk->x = NULL; + + /* Do a quick check to see whether X is suitable. */ + xbits = mpi_get_nbits (x); + if ( xbits < 64 || xbits >= nbits ) + return GPG_ERR_INV_VALUE; + + p_min1 = gcry_mpi_new ( nbits ); + qbits = wiener_map ( nbits ); + if ( (qbits & 1) ) /* Better have an even one. */ + qbits++; + g = mpi_alloc (1); + p = _gcry_generate_elg_prime ( 0, nbits, qbits, g, ret_factors ); + mpi_sub_ui (p_min1, p, 1); + + if (DBG_CIPHER) + log_debug ("using a supplied x of size %u", xbits ); + if ( !(mpi_cmp_ui ( x, 0 ) > 0 && mpi_cmp ( x, p_min1 ) <0 ) ) + { + gcry_mpi_release ( p_min1 ); + gcry_mpi_release ( p ); + gcry_mpi_release ( g ); + return GPG_ERR_INV_VALUE; + } + + y = gcry_mpi_new (nbits); + gcry_mpi_powm ( y, g, x, p ); + + if ( DBG_CIPHER ) + { + progress ('\n'); + log_mpidump ("elg p= ", p ); + log_mpidump ("elg g= ", g ); + log_mpidump ("elg y= ", y ); + log_mpidump ("elg x= ", x ); + } + + /* Copy the stuff to the key structures */ + sk->p = p; + sk->g = g; + sk->y = y; + sk->x = gcry_mpi_copy (x); + gcry_mpi_release ( p_min1 ); - gcry_mpi_release ( temp ); + + /* Now we can test our keys. */ + if ( test_keys ( sk, nbits - 64, 1 ) ) + { + gcry_mpi_release ( sk->p ); sk->p = NULL; + gcry_mpi_release ( sk->g ); sk->g = NULL; + gcry_mpi_release ( sk->y ); sk->y = NULL; + gcry_mpi_release ( sk->x ); sk->x = NULL; + return GPG_ERR_BAD_SECKEY; + } + + return 0; } @@ -523,7 +612,7 @@ *********************************************/ gcry_err_code_t -_gcry_elg_generate (int algo, unsigned nbits, unsigned long dummy, +_gcry_elg_generate (int algo, unsigned int nbits, unsigned long dummy, gcry_mpi_t *skey, gcry_mpi_t **retfactors) { ELG_secret_key sk; @@ -541,7 +630,30 @@ } +/* This is a specila generate function which is not called via the + module interface. */ gcry_err_code_t +_gcry_elg_generate_using_x (int algo, unsigned int nbits, gcry_mpi_t x, + gcry_mpi_t *skey, gcry_mpi_t **retfactors) +{ + gcry_err_code_t ec; + ELG_secret_key sk; + + (void)algo; + + ec = generate_using_x (&sk, nbits, x, retfactors); + if (!ec) + { + skey[0] = sk.p; + skey[1] = sk.g; + skey[2] = sk.y; + skey[3] = sk.x; + } + return ec; +} + + +gcry_err_code_t _gcry_elg_check_secret_key (int algo, gcry_mpi_t *skey) { gcry_err_code_t err = GPG_ERR_NO_ERROR; Modified: trunk/cipher/pubkey.c =================================================================== --- trunk/cipher/pubkey.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/cipher/pubkey.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -497,7 +497,7 @@ static gcry_err_code_t pubkey_generate (int algorithm, unsigned int nbits, unsigned int qbits, - unsigned long use_e, + unsigned long use_e, gcry_mpi_t xvalue, gcry_mpi_t *skey, gcry_mpi_t **retfactors) { gcry_err_code_t err = GPG_ERR_PUBKEY_ALGO; @@ -511,11 +511,22 @@ { /* Hack to pass QBITS to the DSA generation. */ if (qbits && pubkey->spec == &_gcry_pubkey_spec_dsa) - err = _gcry_dsa_generate2 - (algorithm, nbits, qbits, 0, skey, retfactors); + { + err = _gcry_dsa_generate2 + (algorithm, nbits, qbits, 0, skey, retfactors); + } +#ifdef USE_ELGAMAL + else if (xvalue && pubkey->spec == &_gcry_pubkey_spec_elg) + { + err = _gcry_elg_generate_using_x + (algorithm, nbits, xvalue, skey, retfactors); + } +#endif /*USE_ELGAMAL*/ else - err = ((gcry_pk_spec_t *) pubkey->spec)->generate - (algorithm, nbits, use_e, skey, retfactors); + { + err = ((gcry_pk_spec_t *) pubkey->spec)->generate + (algorithm, nbits, use_e, skey, retfactors); + } _gcry_module_release (pubkey); } ath_mutex_unlock (&pubkeys_registered_lock); @@ -1918,6 +1929,7 @@ unsigned int nbits = 0; unsigned long use_e = 0; unsigned int qbits; + gcry_mpi_t xvalue = NULL; char *name_terminated; REGISTER_DEFAULT_PUBKEYS; @@ -2018,6 +2030,18 @@ else qbits = 0; + /* Parse the optional xvalue element. */ + l2 = gcry_sexp_find_token (list, "xvalue", 0); + if (l2) + { + xvalue = gcry_sexp_nth_mpi (l2, 1, 0); + if (!xvalue) + { + rc = GPG_ERR_BAD_MPI; + goto leave; + } + } + /* Now parse the required nbits element. */ l2 = gcry_sexp_find_token (list, "nbits", 0); gcry_sexp_release (list); @@ -2048,7 +2072,8 @@ nbits = (unsigned int) strtoul (name_terminated, NULL, 0); gcry_free (name_terminated); - rc = pubkey_generate (module->mod_id, nbits, qbits, use_e, skey, &factors); + rc = pubkey_generate (module->mod_id, nbits, qbits, use_e, xvalue, + skey, &factors); if (rc) goto leave; @@ -2140,7 +2165,9 @@ leave: release_mpi_array (skey); /* Don't free SKEY itself, it is a static array. */ - + + gcry_mpi_release (xvalue); + if (factors) { release_mpi_array ( factors ); @@ -2151,7 +2178,7 @@ gcry_sexp_release (l2); if (list) gcry_sexp_release (list); - + if (module) { ath_mutex_lock (&pubkeys_registered_lock); Modified: trunk/mpi/ChangeLog =================================================================== --- trunk/mpi/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/mpi/ChangeLog 2007-02-23 17:47:56 UTC (rev 1216) @@ -1,3 +1,10 @@ +2007-02-23 Werner Koch + + * mpi-pow.c (gcry_mpi_powm): Remove unused var ESIGN. + + * mpiutil.c (gcry_mpi_get_flag): Let it return a value to silent + MIPSpro cc warning. + 2007-02-21 Werner Koch * mpicoder.c (_gcry_mpi_set_buffer): Made BUFFER a void*. Modified: trunk/mpi/mpi-pow.c =================================================================== --- trunk/mpi/mpi-pow.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/mpi/mpi-pow.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -41,7 +41,7 @@ { mpi_ptr_t rp, ep, mp, bp; mpi_size_t esize, msize, bsize, rsize; - int esign, msign, bsign, rsign; + int msign, bsign, rsign; int esec, msec, bsec, rsec; mpi_size_t size; int mod_shift_cnt; @@ -58,7 +58,6 @@ esize = expo->nlimbs; msize = mod->nlimbs; size = 2 * msize; - esign = expo->sign; msign = mod->sign; esec = mpi_is_secure(expo); Modified: trunk/mpi/mpiutil.c =================================================================== --- trunk/mpi/mpiutil.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/mpi/mpiutil.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -463,10 +463,13 @@ int gcry_mpi_get_flag( gcry_mpi_t a, enum gcry_mpi_flag flag ) { - switch( flag ) { - case GCRYMPI_FLAG_SECURE: return (a->flags & 1); - case GCRYMPI_FLAG_OPAQUE: return (a->flags & 4); - default: log_bug("invalid flag value\n"); + switch (flag) + { + case GCRYMPI_FLAG_SECURE: return (a->flags & 1); + case GCRYMPI_FLAG_OPAQUE: return (a->flags & 4); + default: log_bug("invalid flag value\n"); } + /*NOTREACHED*/ + return 0; } Modified: trunk/src/cipher.h =================================================================== --- trunk/src/cipher.h 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/src/cipher.h 2007-02-23 17:47:56 UTC (rev 1216) @@ -45,6 +45,11 @@ /*-- elgamal.c --*/ void _gcry_register_pk_elg_progress (gcry_handler_progress_t cb, void *cb_data); +gcry_err_code_t _gcry_elg_generate_using_x (int algo, unsigned int nbits, + gcry_mpi_t x, + gcry_mpi_t *skey, + gcry_mpi_t **retfactors); + /*-- primegen.c --*/ void _gcry_register_primegen_progress (gcry_handler_progress_t cb, void *cb_data); Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/tests/ChangeLog 2007-02-23 17:47:56 UTC (rev 1216) @@ -1,3 +1,18 @@ +2007-02-23 Werner Koch + + * Makefile.am (TEST): Run benchmark as last. + + * ac-data.c (check_sexp_conversion): Print label only in verbose + mode. + + * pubkey.c (main): Run test just 2 times instead of 10. + (get_elg_key_new): New. + (check_run): Also run tests with Elgamal keys. + (check_keys): New arg NBITS_DATA. + (get_elg_key_new): Use only 400 for the 512 bit Elgamal test. + + * random.c: New. + 2007-02-22 Werner Koch * basic.c (check_pubkey_sign): Also try signing using an OID. Modified: trunk/tests/Makefile.am =================================================================== --- trunk/tests/Makefile.am 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/tests/Makefile.am 2007-02-23 17:47:56 UTC (rev 1216) @@ -19,15 +19,19 @@ ## Process this file with automake to produce Makefile.in TESTS = t-mpi-bit prime register ac ac-schemes ac-data basic \ - tsexp keygen pubkey benchmark hmac keygrip + tsexp keygen pubkey hmac keygrip # pkbench uses mmap for no good reason. Needs to be fixed. Code for -# this can be found in libksba/tests. +# this can be found in libksba/tests. +# random tests forking thus no a test for W32 does not make any sense. if !HAVE_W32_SYSTEM -TESTS += pkbench +TESTS += pkbench random endif +# The last test to run. +TESTS += benchmark + # Need to include ../src in addition to top_srcdir because gcrypt.h is # a built header. AM_CPPFLAGS = -I../src -I$(top_srcdir)/src Modified: trunk/tests/ac-data.c =================================================================== --- trunk/tests/ac-data.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/tests/ac-data.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -78,8 +78,11 @@ assert_err (err); err = gcry_ac_data_get_index (data2, 0, i, &label2, &mpi2); assert_err (err); - fprintf (stderr, "Label1=`%s'\n", label1); - fprintf (stderr, "Label1=`%s'\n", label2); + if (verbose) + { + fprintf (stderr, "Label1=`%s'\n", label1); + fprintf (stderr, "Label2=`%s'\n", label2); + } assert (! strcmp (label1, label2)); assert (! gcry_mpi_cmp (mpi1, mpi2)); } Modified: trunk/tests/pubkey.c =================================================================== --- trunk/tests/pubkey.c 2007-02-22 18:25:27 UTC (rev 1215) +++ trunk/tests/pubkey.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -63,7 +63,6 @@ " )\n" ")\n"; -#define RANDOM_DATA_NBITS 800 static int verbose; @@ -134,15 +133,15 @@ } static void -check_keys (gcry_sexp_t pkey, gcry_sexp_t skey) +check_keys (gcry_sexp_t pkey, gcry_sexp_t skey, unsigned int nbits_data) { gcry_sexp_t plain; gcry_mpi_t x; int rc; /* Create plain text. */ - x = gcry_mpi_new (RANDOM_DATA_NBITS); - gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM); + x = gcry_mpi_new (nbits_data); + gcry_mpi_randomize (x, nbits_data, GCRY_WEAK_RANDOM); rc = gcry_sexp_build (&plain, NULL, "(data (flags raw) (value %m))", x); if (rc) @@ -154,10 +153,11 @@ gcry_mpi_release (x); /* Create plain text. */ - x = gcry_mpi_new (RANDOM_DATA_NBITS); - gcry_mpi_randomize (x, RANDOM_DATA_NBITS, GCRY_WEAK_RANDOM); + x = gcry_mpi_new (nbits_data); + gcry_mpi_randomize (x, nbits_data, GCRY_WEAK_RANDOM); - rc = gcry_sexp_build (&plain, NULL, "(data (flags raw no-blinding) (value %m))", x); + rc = gcry_sexp_build (&plain, NULL, + "(data (flags raw no-blinding) (value %m))", x); if (rc) die ("converting data for encryption failed: %s\n", gcry_strerror (rc)); @@ -212,29 +212,79 @@ *skey = sec_key; } + static void +get_elg_key_new (gcry_sexp_t *pkey, gcry_sexp_t *skey, int fixed_x) +{ + gcry_sexp_t key_spec, key, pub_key, sec_key; + int rc; + + rc = gcry_sexp_new + (&key_spec, + (fixed_x + ? "(genkey (elg (nbits 4:1024)(xvalue my.not-so-secret.key)))" + : "(genkey (elg (nbits 3:512)))"), + 0, 1); + + if (rc) + die ("error creating S-expression: %s\n", gcry_strerror (rc)); + rc = gcry_pk_genkey (&key, key_spec); + gcry_sexp_release (key_spec); + if (rc) + die ("error generating Elgamal key: %s\n", gcry_strerror (rc)); + + pub_key = gcry_sexp_find_token (key, "public-key", 0); + if (!pub_key) + die ("public part missing in key\n"); + + sec_key = gcry_sexp_find_token (key, "private-key", 0); + if (!sec_key) + die ("private part missing in key\n"); + + gcry_sexp_release (key); + *pkey = pub_key; + *skey = sec_key; +} + +static void check_run (void) { gcry_sexp_t pkey, skey; - /* Check sample keys. */ + if (verbose) + fprintf (stderr, "Checking sample key.\n"); get_keys_sample (&pkey, &skey); - check_keys (pkey, skey); + check_keys (pkey, skey, 800); gcry_sexp_release (pkey); gcry_sexp_release (skey); - /* Check newly generated keys. */ + if (verbose) + fprintf (stderr, "Checking generated RSA key.\n"); get_keys_new (&pkey, &skey); - check_keys (pkey, skey); + check_keys (pkey, skey, 800); gcry_sexp_release (pkey); gcry_sexp_release (skey); + + if (verbose) + fprintf (stderr, "Checking generated Elgamal key.\n"); + get_elg_key_new (&pkey, &skey, 0); + check_keys (pkey, skey, 400 ); + gcry_sexp_release (pkey); + gcry_sexp_release (skey); + + if (verbose) + fprintf (stderr, "Checking passphrase generated Elgamal key.\n"); + get_elg_key_new (&pkey, &skey, 1); + check_keys (pkey, skey, 800); + gcry_sexp_release (pkey); + gcry_sexp_release (skey); } int main (int argc, char **argv) { int debug = 0; - int i = 10; + int i; if (argc > 1 && !strcmp (argv[1], "--verbose")) verbose = 1; @@ -250,7 +300,7 @@ /* No valuable keys are create, so we can speed up our RNG. */ gcry_control (GCRYCTL_ENABLE_QUICK_RANDOM, 0); - for (; i > 0; i--) + for (i=0; i < 2; i++) check_run (); return 0; Copied: trunk/tests/random.c (from rev 1208, branches/LIBGCRYPT-1-2-BRANCH/tests/random.c) =================================================================== --- branches/LIBGCRYPT-1-2-BRANCH/tests/random.c 2007-02-01 19:49:33 UTC (rev 1208) +++ trunk/tests/random.c 2007-02-23 17:47:56 UTC (rev 1216) @@ -0,0 +1,255 @@ +/* random.c - part of the Libgcrypt test suite. + Copyright (C) 2005 Free Software Foundation, Inc. + + This program 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. + + This program 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. */ + +#ifdef HAVE_CONFIG_H +#include +#endif +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../src/gcrypt.h" + +static int verbose; + +static void +die (const char *format, ...) +{ + va_list arg_ptr; + + va_start (arg_ptr, format); + vfprintf (stderr, format, arg_ptr); + va_end (arg_ptr); + exit (1); +} + + +static void +print_hex (const char *text, const void *buf, size_t n) +{ + const unsigned char *p = buf; + + fputs (text, stdout); + for (; n; n--, p++) + printf ("%02X", *p); + putchar ('\n'); +} + + +static int +writen (int fd, const void *buf, size_t nbytes) +{ + size_t nleft = nbytes; + int nwritten; + + while (nleft > 0) + { + nwritten = write (fd, buf, nleft); + if (nwritten < 0) + { + if (errno == EINTR) + nwritten = 0; + else + return -1; + } + nleft -= nwritten; + buf = (const char*)buf + nwritten; + } + + return 0; +} + +static int +readn (int fd, void *buf, size_t buflen, size_t *ret_nread) +{ + size_t nleft = buflen; + int nread; + char *p; + + p = buf; + while ( nleft > 0 ) + { + nread = read ( fd, buf, nleft ); + if (nread < 0) + { + if (nread == EINTR) + nread = 0; + else + return -1; + } + else if (!nread) + break; /* EOF */ + nleft -= nread; + buf = (char*)buf + nread; + } + if (ret_nread) + *ret_nread = buflen - nleft; + return 0; +} + + + +/* Check that forking won't return the same random. */ +static void +check_forking (void) +{ + pid_t pid; + int rp[2]; + int i, status; + size_t nread; + char tmp1[16], tmp1c[16], tmp1p[16]; + + /* We better make sure that the RNG has been initialzied. */ + gcry_randomize (tmp1, sizeof tmp1, GCRY_STRONG_RANDOM); + if (verbose) + print_hex ("initial random: ", tmp1, sizeof tmp1); + + if (pipe (rp) == -1) + die ("pipe failed: %s\n", strerror (errno)); + + pid = fork (); + if (pid == (pid_t)(-1)) + die ("fork failed: %s\n", strerror (errno)); + if (!pid) + { + gcry_randomize (tmp1c, sizeof tmp1c, GCRY_STRONG_RANDOM); + if (writen (rp[1], tmp1c, sizeof tmp1c)) + die ("write failed: %s\n", strerror (errno)); + if (verbose) + { + print_hex (" child random: ", tmp1c, sizeof tmp1c); + fflush (stdout); + } + _exit (0); + } + gcry_randomize (tmp1p, sizeof tmp1p, GCRY_STRONG_RANDOM); + if (verbose) + print_hex (" parent random: ", tmp1p, sizeof tmp1p); + + close (rp[1]); + if (readn (rp[0], tmp1c, sizeof tmp1c, &nread)) + die ("read failed: %s\n", strerror (errno)); + if (nread != sizeof tmp1c) + die ("read too short\n"); + + while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR) + ; + if (i != (pid_t)(-1) + && WIFEXITED (status) && !WEXITSTATUS (status)) + ; + else + die ("child failed\n"); + + if (!memcmp (tmp1p, tmp1c, sizeof tmp1c)) + die ("parent and child got the same random number\n"); +} + + + +/* Check that forking won't return the same nonce. */ +static void +check_nonce_forking (void) +{ + pid_t pid; + int rp[2]; + int i, status; + size_t nread; + char nonce1[10], nonce1c[10], nonce1p[10]; + + /* We won't get the same nonce back if we never initialized the + nonce subsystem, thus we get one nonce here and forget about + it. */ + gcry_create_nonce (nonce1, sizeof nonce1); + if (verbose) + print_hex ("initial nonce: ", nonce1, sizeof nonce1); + + if (pipe (rp) == -1) + die ("pipe failed: %s\n", strerror (errno)); + + pid = fork (); + if (pid == (pid_t)(-1)) + die ("fork failed: %s\n", strerror (errno)); + if (!pid) + { + gcry_create_nonce (nonce1c, sizeof nonce1c); + if (writen (rp[1], nonce1c, sizeof nonce1c)) + die ("write failed: %s\n", strerror (errno)); + if (verbose) + { + print_hex (" child nonce: ", nonce1c, sizeof nonce1c); + fflush (stdout); + } + _exit (0); + } + gcry_create_nonce (nonce1p, sizeof nonce1p); + if (verbose) + print_hex (" parent nonce: ", nonce1p, sizeof nonce1p); + + close (rp[1]); + if (readn (rp[0], nonce1c, sizeof nonce1c, &nread)) + die ("read failed: %s\n", strerror (errno)); + if (nread != sizeof nonce1c) + die ("read too short\n"); + + while ( (i=waitpid (pid, &status, 0)) == -1 && errno == EINTR) + ; + if (i != (pid_t)(-1) + && WIFEXITED (status) && !WEXITSTATUS (status)) + ; + else + die ("child failed\n"); + + if (!memcmp (nonce1p, nonce1c, sizeof nonce1c)) + die ("parent and child got the same nonce\n"); +} + + + + + + +int +main (int argc, char **argv) +{ + int debug = 0; + + if ((argc > 1) && (! strcmp (argv[1], "--verbose"))) + verbose = 1; + else if ((argc > 1) && (! strcmp (argv[1], "--debug"))) + verbose = debug = 1; + + signal (SIGPIPE, SIG_IGN); + + gcry_control (GCRYCTL_DISABLE_SECMEM, 0); + if (!gcry_check_version (GCRYPT_VERSION)) + die ("version mismatch\n"); + + gcry_control (GCRYCTL_INITIALIZATION_FINISHED, 0); + if (debug) + gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1u, 0); + + check_forking (); + check_nonce_forking (); + + return 0; +} From cvs at cvs.gnupg.org Mon Feb 26 11:36:11 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Feb 2007 11:36:11 +0100 Subject: [svn] gpgme - r1209 - in trunk: . doc gpgme tests tests/gpg Message-ID: Author: wk Date: 2007-02-26 11:36:08 +0100 (Mon, 26 Feb 2007) New Revision: 1209 Modified: trunk/ trunk/NEWS trunk/doc/ trunk/gpgme/ trunk/gpgme/ChangeLog trunk/gpgme/gpgme.h trunk/gpgme/verify.c trunk/tests/ChangeLog trunk/tests/gpg/t-verify.c Log: Detect and bailo out on double plaintext messages. Property changes on: trunk ___________________________________________________________________ Name: svn:ignore - Makefile Makefile.in aclocal.m4 config.cache config.h config.h.in config.log config.status configure stamp-h stamp-h.in stamp-h1 libtool + Makefile Makefile.in aclocal.m4 config.cache config.h config.h.in config.log config.status configure stamp-h stamp-h.in stamp-h1 libtool autom4te.cache *.bz2 *.gz Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/NEWS 2007-02-26 10:36:08 UTC (rev 1209) @@ -1,3 +1,9 @@ +Noteworthy changes in version 1.1.4 +------------------------------------------------ + + * Detect and bail out on double plaintext messages. + + Noteworthy changes in version 1.1.3 (2007-01-29) ------------------------------------------------ Property changes on: trunk/doc ___________________________________________________________________ Name: svn:ignore - Makefile.in Makefile + Makefile.in Makefile *.info stamp-vti version.texi Property changes on: trunk/gpgme ___________________________________________________________________ Name: svn:ignore - Makefile.in Makefile .deps .libs *.lo *.la errors.c gpgme-config status-table.h + Makefile.in Makefile .deps .libs *.lo *.la errors.c gpgme-config status-table.h *.pdf Modified: trunk/gpgme/ChangeLog =================================================================== --- trunk/gpgme/ChangeLog 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/gpgme/ChangeLog 2007-02-26 10:36:08 UTC (rev 1209) @@ -1,3 +1,11 @@ +2007-02-26 Werner Koch + + * verify.c (op_data_t): New element PLAINTEXT_SEEN. + (_gpgme_verify_status_handler): Return an error if more than one + plaintext has been seen. + (parse_error): New arg SET_STATUS. Also detect it based on an + ERROR status (gpg > 1.4.6). + 2007-01-26 Werner Koch * w32-io.c (build_commandline): Fixed stupid quoting bug. Modified: trunk/gpgme/gpgme.h =================================================================== --- trunk/gpgme/gpgme.h 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/gpgme/gpgme.h 2007-02-26 10:36:08 UTC (rev 1209) @@ -72,7 +72,7 @@ AM_PATH_GPGME macro) check that this header matches the installed library. Warning: Do not edit the next line. configure will do that for you! */ -#define GPGME_VERSION "1.1.3-cvs1202" +#define GPGME_VERSION "1.1.3" Modified: trunk/gpgme/verify.c =================================================================== --- trunk/gpgme/verify.c 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/gpgme/verify.c 2007-02-26 10:36:08 UTC (rev 1209) @@ -40,6 +40,7 @@ gpgme_signature_t current_sig; int did_prepare_new_sig; int only_newsig_seen; + int plaintext_seen; } *op_data_t; @@ -549,8 +550,11 @@ } +/* Parse an error status line and if SET_STATUS is true update the + result status as appropriate. With SET_STATUS being false, only + check for an error. */ static gpgme_error_t -parse_error (gpgme_signature_t sig, char *args) +parse_error (gpgme_signature_t sig, char *args, int set_status) { gpgme_error_t err; char *where = strchr (args, ' '); @@ -572,7 +576,16 @@ err = _gpgme_map_gnupg_error (which); - if (!strcmp (where, "verify.findkey")) + if (!strcmp (where, "proc_pkt.plaintext") + && gpg_err_code (err) == GPG_ERR_BAD_DATA) + { + /* This indicates a double plaintext. The only solid way to + handle this is by failing the oepration. */ + return gpg_error (GPG_ERR_BAD_DATA); + } + else if (!set_status) + ; + else if (!strcmp (where, "verify.findkey")) sig->status = err; else if (!strcmp (where, "verify.keyusage") && gpg_err_code (err) == GPG_ERR_WRONG_KEY_USAGE) @@ -670,9 +683,9 @@ case GPGME_STATUS_ERROR: opd->only_newsig_seen = 0; - /* The error status is informational, so we don't return an - error code if we are not ready to process this status. */ - return sig ? parse_error (sig, args) : 0; + /* Some error stati are informational, so we don't return an + error code if we are not ready to process this status. */ + return parse_error (sig, args, !!sig ); case GPGME_STATUS_EOF: if (sig && !opd->did_prepare_new_sig) @@ -703,6 +716,8 @@ break; case GPGME_STATUS_PLAINTEXT: + if (++opd->only_newsig_seen > 1) + return gpg_error (GPG_ERR_BAD_DATA); err = _gpgme_parse_plaintext (args, &opd->result.file_name); if (err) return err; @@ -816,8 +831,9 @@ successful verify operation in R_STAT (if non-null). The creation time stamp of the signature is returned in R_CREATED (if non-null). The function returns a string containing the fingerprint. */ -const char *gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, - _gpgme_sig_stat_t *r_stat, time_t *r_created) +const char * +gpgme_get_sig_status (gpgme_ctx_t ctx, int idx, + _gpgme_sig_stat_t *r_stat, time_t *r_created) { gpgme_verify_result_t result; gpgme_signature_t sig; @@ -876,8 +892,9 @@ number of the signature after a successful verify operation. WHAT is an attribute where GPGME_ATTR_EXPIRE is probably the most useful one. WHATIDX is to be passed as 0 for most attributes . */ -unsigned long gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx, - _gpgme_attr_t what, int whatidx) +unsigned long +gpgme_get_sig_ulong_attr (gpgme_ctx_t ctx, int idx, + _gpgme_attr_t what, int whatidx) { gpgme_verify_result_t result; gpgme_signature_t sig; @@ -939,8 +956,9 @@ } -const char *gpgme_get_sig_string_attr (gpgme_ctx_t ctx, int idx, - _gpgme_attr_t what, int whatidx) +const char * +gpgme_get_sig_string_attr (gpgme_ctx_t ctx, int idx, + _gpgme_attr_t what, int whatidx) { gpgme_verify_result_t result; gpgme_signature_t sig; Modified: trunk/tests/ChangeLog =================================================================== --- trunk/tests/ChangeLog 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/tests/ChangeLog 2007-02-26 10:36:08 UTC (rev 1209) @@ -1,3 +1,8 @@ +2007-02-26 Werner Koch + + * gpg/t-verify.c (double_plaintext_sig): New. + (main): Check it. + 2006-12-02 Marcus Brinkmann * gpgsm/t-keylist.c (main): Skip unknown keys. Newer versions of Modified: trunk/tests/gpg/t-verify.c =================================================================== --- trunk/tests/gpg/t-verify.c 2007-01-29 20:53:59 UTC (rev 1208) +++ trunk/tests/gpg/t-verify.c 2007-02-26 10:36:08 UTC (rev 1209) @@ -76,7 +76,21 @@ "=Crq6\n" "-----END PGP MESSAGE-----\n"; +/* A message with a prepended but unsigned plaintext packet. */ +static const char double_plaintext_sig[] = +"-----BEGIN PGP MESSAGE-----\n" +"\n" +"rDRiCmZvb2Jhci50eHRF4pxNVGhpcyBpcyBteSBzbmVha3kgcGxhaW50ZXh0IG1l\n" +"c3NhZ2UKowGbwMvMwCSoW1RzPCOz3IRxTWISa6JebnG666MFD1wzSzJSixQ81XMV\n" +"UlITUxTyixRyKxXKE0uSMxQyEosVikvyCwpSU/S4FNCArq6Ce1F+aXJGvoJvYlGF\n" +"erFCTmJxiUJ5flFKMVeHGwuDIBMDGysTyA4GLk4BmO036xgWzMgzt9V85jCtfDFn\n" +"UqVooWlGXHwNw/xg/fVzt9VNbtjtJ/fhUqYo0/LyCGEA\n" +"=6+AK\n" +"-----END PGP MESSAGE-----\n"; + + + static void check_result (gpgme_verify_result_t result, unsigned int summary, char *fpr, gpgme_error_t status, int notation) @@ -235,8 +249,25 @@ check_result (result, 0, "A0FF4590BB6122EDEF6E3C542D727CC768697734", GPG_ERR_NO_ERROR, 0); + + /* Checking an invalid message. */ gpgme_data_release (sig); gpgme_data_release (text); + err = gpgme_data_new_from_mem (&sig, double_plaintext_sig, + strlen (double_plaintext_sig), 0); + fail_if_err (err); + err = gpgme_data_new (&text); + fail_if_err (err); + err = gpgme_op_verify (ctx, sig, NULL, text); + if (gpg_err_code (err) != GPG_ERR_BAD_DATA) + { + fprintf (stderr, "%s:%i: Double plaintext message not detected\n", + __FILE__, __LINE__); + exit (1); + } + + gpgme_data_release (sig); + gpgme_data_release (text); gpgme_release (ctx); return 0; } From cvs at cvs.gnupg.org Mon Feb 26 11:44:57 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Feb 2007 11:44:57 +0100 Subject: [svn] gpgme - r1210 - trunk/gpgme Message-ID: Author: wk Date: 2007-02-26 11:44:57 +0100 (Mon, 26 Feb 2007) New Revision: 1210 Modified: trunk/gpgme/verify.c Log: Fixed last chnage. Modified: trunk/gpgme/verify.c =================================================================== --- trunk/gpgme/verify.c 2007-02-26 10:36:08 UTC (rev 1209) +++ trunk/gpgme/verify.c 2007-02-26 10:44:57 UTC (rev 1210) @@ -716,7 +716,7 @@ break; case GPGME_STATUS_PLAINTEXT: - if (++opd->only_newsig_seen > 1) + if (++opd->plaintext_seen > 1) return gpg_error (GPG_ERR_BAD_DATA); err = _gpgme_parse_plaintext (args, &opd->result.file_name); if (err) From cvs at cvs.gnupg.org Mon Feb 26 15:26:34 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Feb 2007 15:26:34 +0100 Subject: [svn] GnuPG - r4437 - in branches/STABLE-BRANCH-1-4: . util Message-ID: Author: wk Date: 2007-02-26 15:26:32 +0100 (Mon, 26 Feb 2007) New Revision: 4437 Modified: branches/STABLE-BRANCH-1-4/NEWS branches/STABLE-BRANCH-1-4/util/ChangeLog branches/STABLE-BRANCH-1-4/util/simple-gettext.c Log: [W32] Make use of the LANGUAGE envvar. Modified: branches/STABLE-BRANCH-1-4/NEWS =================================================================== --- branches/STABLE-BRANCH-1-4/NEWS 2007-02-20 14:55:32 UTC (rev 4436) +++ branches/STABLE-BRANCH-1-4/NEWS 2007-02-26 14:26:32 UTC (rev 4437) @@ -1,7 +1,12 @@ Noteworthy changes in version 1.4.7 ------------------------------------------------ + * [W32] The environment variable LANGUAGE may be used to override + the language given by HKCU\Software\GNU\GnuPG:Lang. The + language files "*.mo" are expected in a directory named + "gnupg.nls" below the directory with the gpg.exe binary. + Noteworthy changes in version 1.4.6 (2006-12-06) ------------------------------------------------ Modified: branches/STABLE-BRANCH-1-4/util/ChangeLog =================================================================== --- branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-20 14:55:32 UTC (rev 4436) +++ branches/STABLE-BRANCH-1-4/util/ChangeLog 2007-02-26 14:26:32 UTC (rev 4437) @@ -1,3 +1,8 @@ +2007-02-26 Werner Koch + + * simple-gettext.c (set_gettext_file): Make use of the envvar + LANGUAGE to allow overriding of the registry setting. + 2007-02-12 Werner Koch * secmem.c (ptr_into_pool_p): New. Modified: branches/STABLE-BRANCH-1-4/util/simple-gettext.c =================================================================== --- branches/STABLE-BRANCH-1-4/util/simple-gettext.c 2007-02-20 14:55:32 UTC (rev 4436) +++ branches/STABLE-BRANCH-1-4/util/simple-gettext.c 2007-02-26 14:26:32 UTC (rev 4437) @@ -43,6 +43,7 @@ #include "types.h" #include "util.h" +#include "windows.h" /* For GetModuleFileName. */ /* The magic number of the GNU message catalog format. */ #define MAGIC 0x950412de @@ -232,96 +233,154 @@ } -/**************** - * Set the file used for translations. Pass a NULL to disable - * translation. A new filename may be set at anytime. If REGKEY is - * not NULL, the function tries to selected the language the registry - * key "Lang" below that key. WARNING: After changing the filename you - * should not access any data retrieved by gettext(). +/* Set the file used for translations. Pass a NULL to disable + translation. A new filename may be set at anytime. WARNING: After + changing the filename you should not access any data retrieved by + gettext(). + + If REGKEY is not NULL, the function tries to selected the language + the registry key "Lang" below that key. If in addition the + environment variable LANGUAGE has been set, that value will + override a value set by the registry key. */ int set_gettext_file ( const char *filename, const char *regkey ) { - struct loaded_domain *domain = NULL; + struct loaded_domain *domain = NULL; - if( filename && *filename ) { - if( filename[0] == '/' + if ( filename && *filename ) + { + if ( filename[0] == '/' #ifdef HAVE_DRIVE_LETTERS - || ( isalpha(filename[0]) - && filename[1] == ':' - && (filename[2] == '/' || filename[2] == '\\') ) + || ( isalpha(filename[0]) + && filename[1] == ':' + && (filename[2] == '/' || filename[2] == '\\') ) #endif - ) { - /* absolute path - use it as is */ - domain = load_domain( filename ); + ) + { + /* absolute path - use it as is */ + domain = load_domain( filename ); } - else if (regkey) { /* Standard. */ - char *instdir, *langid, *fname; - char *p; - - instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", - regkey, - "Install Directory"); - if (!instdir) + else if (regkey) /* Standard. */ + { + char *instdir, *langid, *fname; + char *p; + int envvar_mode = 0; + + again: + if (!envvar_mode && (p = getenv ("LANGUAGE")) && *p) + { + envvar_mode = 1; + langid = malloc (strlen (p)+1); + if (!langid) return -1; - langid = read_w32_registry_string (NULL, /* HKCU then HKLM */ - regkey, - "Lang"); - if (!langid) { - free (instdir); - return -1; + strcpy (langid, p); + /* We only make use of the first language given. Strip + the rest. */ + p = strchr (langid, ':'); + if (p) + *p = 0; + + /* In the $LANGUAGE case we do not use the registered + installation directory but the one where the gpg + binary has been found. */ + instdir = malloc (MAX_PATH+5); + if ( !instdir || !GetModuleFileName (NULL, instdir, MAX_PATH) ) + { + free (langid); + free (instdir); + return -1; /* Error getting the process' file name. */ + } + p = strrchr (instdir, DIRSEP_C); + if (!p) + { + free (langid); + free (instdir); + return -1; /* Invalid file name returned. */ + } + *p = 0; } - /* Strip stuff after a dot in case the user tried to enter - * the entire locale synatcs as usual for POSIX. */ - p = strchr (langid, '.'); - if (p) - *p = 0; - - /* Build the key: "/.nls/.mo" We - use a directory below the installation directory with - the domain included in case the software has been - insalled with other software altogether at the same - place. */ - fname = malloc (strlen (instdir) + 1 + strlen (filename) + 5 - + strlen (langid) + 3 + 1); - if (!fname) { - free (instdir); - free (langid); + else + { + instdir = read_w32_registry_string ("HKEY_LOCAL_MACHINE", + regkey, + "Install Directory"); + if (!instdir) return -1; + langid = read_w32_registry_string (NULL, /* HKCU then HKLM */ + regkey, + "Lang"); + if (!langid) + { + free (instdir); + return -1; + } } - strcpy (stpcpy (stpcpy (stpcpy (stpcpy ( stpcpy (fname, - instdir),"\\"), filename), ".nls\\"), langid), ".mo"); - free (instdir); - free (langid); + + /* Strip stuff after a dot in case the user tried to enter + the entire locale syntacs as usual for POSIX. */ + p = strchr (langid, '.'); + if (p) + *p = 0; + + /* Build the key: "/.nls/.mo" We + use a directory below the installation directory with the + domain included in case the software has been insalled + with other software altogether at the same place. */ + fname = malloc (strlen (instdir) + 1 + strlen (filename) + 5 + + strlen (langid) + 3 + 1); + if (!fname) + { + free (instdir); + free (langid); + return -1; + } + strcpy (stpcpy (stpcpy (stpcpy (stpcpy ( stpcpy (fname, + instdir),"\\"), filename), ".nls\\"), langid), ".mo"); + free (instdir); + free (langid); - /* Better make sure that we don't mix forward and - backward slashes. It seems that some Windoze - versions don't accept this. */ - for (p=fname; *p; p++) { - if (*p == '/') - *p = '\\'; + /* Better make sure that we don't mix forward and backward + slashes. It seems that some Windoze versions don't + accept this. */ + for (p=fname; *p; p++) + { + if (*p == '/') + *p = '\\'; } - domain = load_domain (fname); - free(fname); + domain = load_domain (fname); + free(fname); + + if (!domain && envvar_mode == 1) + { + /* In case it failed, we try again using the registry + method. */ + envvar_mode++; + goto again; + } } + - if (!domain) - return -1; + if (!domain) + return -1; } - if( the_domain ) { - struct overflow_space_s *os, *os2; - free( the_domain->data ); - free( the_domain->mapped ); - for (os=the_domain->overflow_space; os; os = os2) { - os2 = os->next; - free (os); + if ( the_domain ) + { + struct overflow_space_s *os, *os2; + + free ( the_domain->data ); + free ( the_domain->mapped ); + for (os=the_domain->overflow_space; os; os = os2) + { + os2 = os->next; + free (os); } - free( the_domain ); - the_domain = NULL; + free ( the_domain ); + the_domain = NULL; } - the_domain = domain; - return 0; + the_domain = domain; + return 0; } From cvs at cvs.gnupg.org Mon Feb 26 16:38:39 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Feb 2007 16:38:39 +0100 Subject: [svn] gpg-error - r192 - trunk/po Message-ID: Author: wk Date: 2007-02-26 16:38:39 +0100 (Mon, 26 Feb 2007) New Revision: 192 Modified: trunk/po/ChangeLog trunk/po/sv.po Log: Updated Modified: trunk/po/ChangeLog =================================================================== --- trunk/po/ChangeLog 2006-12-22 15:37:30 UTC (rev 191) +++ trunk/po/ChangeLog 2007-02-26 15:38:39 UTC (rev 192) @@ -1,3 +1,11 @@ +2007-02-26 Werner Koch + + * sv.po: Update from Daniel. + +2006-12-22 Werner Koch + + * LINGUAS, sv.po: Installed Swedish translation by Daniel Nylander. + 2006-11-23 gettextize * Makefile.in.in: Upgrade to gettext-0.15. Modified: trunk/po/sv.po =================================================================== --- trunk/po/sv.po 2006-12-22 15:37:30 UTC (rev 191) +++ trunk/po/sv.po 2007-02-26 15:38:39 UTC (rev 192) @@ -8,7 +8,7 @@ "Project-Id-Version: libgpg-error\n" "Report-Msgid-Bugs-To: translations at gnupg.org\n" "POT-Creation-Date: 2006-03-14 12:56+0100\n" -"PO-Revision-Date: 2006-12-10 20:07+0100\n" +"PO-Revision-Date: 2007-02-01 02:13+0100\n" "Last-Translator: Daniel Nylander \n" "Language-Team: Swedish \n" "MIME-Version: 1.0\n" @@ -101,7 +101,7 @@ #: src/err-codes.h:32 msgid "Invalid public key algorithm" -msgstr "Ogiltig publik nyckelalgoritm" +msgstr "Ogiltig publik nyckel-algoritm" #: src/err-codes.h:33 msgid "Invalid digest algorithm" @@ -249,7 +249,7 @@ #: src/err-codes.h:69 msgid "Wrong public key algorithm" -msgstr "Fel publik nyckelalgoritm" +msgstr "Fel publik nyckel-algoritm" #: src/err-codes.h:70 msgid "Tribute to D. A." From cvs at cvs.gnupg.org Mon Feb 26 21:24:33 2007 From: cvs at cvs.gnupg.org (svn author wk) Date: Mon, 26 Feb 2007 21:24:33 +0100 Subject: [svn] GnuPG - r4440 - in trunk: . doc g10 sm Message-ID: Author: wk Date: 2007-02-26 21:24:29 +0100 (Mon, 26 Feb 2007) New Revision: 4440 Added: trunk/README.maint Modified: trunk/NEWS trunk/THANKS trunk/doc/ChangeLog trunk/doc/DETAILS trunk/doc/gpg.texi trunk/g10/ChangeLog trunk/g10/encr-data.c trunk/g10/gpg.c trunk/g10/import.c trunk/g10/keyedit.c trunk/g10/mainproc.c trunk/g10/options.h trunk/sm/encrypt.c Log: Add new SVN only file README.maint doc/ * gpg.texi (GPG Configuration): Document envvar LANGUAGE. (GPG Configuration Options): Document show-primary-uid-only. g10/ * gpg.c (main): Add verify option show-primary-uid-only. * options.h (VERIFY_SHOW_PRIMARY_UID_ONLY): New. * mainproc.c (check_sig_and_print): Implement it. * encr-data.c (decrypt_data): Correctly test for unknown algorithm. * import.c (check_prefs): Ditto. * keyedit.c (show_prefs): Ditto. * mainproc.c (proc_symkey_enc): Ditto. Modified: trunk/NEWS =================================================================== --- trunk/NEWS 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/NEWS 2007-02-26 20:24:29 UTC (rev 4440) @@ -1,3 +1,9 @@ +Noteworthy changes in version 2.0.3 +------------------------------------------------ + + * New --verify-option show-primary-uid-only. + + Noteworthy changes in version 2.0.2 (2007-01-31) ------------------------------------------------ @@ -14,8 +20,8 @@ short. New option --min-passphrase-len defaults to 8. * The status code BEGIN_SIGNING now shows the used hash algorithms. - + Noteworthy changes in version 2.0.1 (2006-11-28) ------------------------------------------------ Added: trunk/README.maint =================================================================== --- trunk/README.maint 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/README.maint 2007-02-26 20:24:29 UTC (rev 4440) @@ -0,0 +1,42 @@ + Notes for the GnuPG maintainer (SVN only) + ============================================ + +Here are some notes on how to maintain GnuPG. + + +Release process: +================ + + * Make sure that all new PO files are checked in. + * Decide whether you want to update the automake standard files + (Mainly config.guess and config.sub). + * [1.4 only] Update gpg.texi and gpgv.texi from the trunk. + * Run "make update-po". + * Write NEWS entries and set the release date in NEWS. + * In configure.ac set "my_issvn" to "no". + * Commit all changes to the SVN. + * Update the SVN then (to sync the release number of all files). + * Run "./autogen.sh --force" + (--force is required for the svn magic in configure.ac and a good + idea in any case) + * Run "make distcheck" + * Build and test the new tarball (best on a different machine). + * [1.4 only] Build and test the W32 vesion. + * Sign the tarball + * Get the previous tarball and run "mkdiff gnupg". + You might need to set a different signature key than mine. mkdiff + has an option for this. + * If you are satisied with the result tag the release. Use "svn + info" to get the current URL and use an svn cp command similar to + "svn cp svn+ssh://host/gnupg/trunk svn+ssh://host/gnupg/tags/2.n.m" + (for 1.4 you should see "branches/STABLE-BRANCH-1-4" instead of "trunk", + however tags are all below tags). + * Copy the files to the FTP server + * Update the webpages - at least the file swdb.wml needs an update. + * Add a new headline to NEWS. + * Bump "my_version" up and set "my_issvn" back to "yes" in configure.ac + * Write an announcement. + + + + Modified: trunk/THANKS =================================================================== --- trunk/THANKS 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/THANKS 2007-02-26 20:24:29 UTC (rev 4440) @@ -17,6 +17,7 @@ Anthony Mulcahy anthony at kcn.ne.jp Ariel T Glenn ariel at columbia.edu ARIGA Seiji ariga at os.rim.or.jp +Benjamin Donnachie benjamin at py-soft.co.uk Bernhard Herzog bh at intevation.de Bernhard Reiter bernhard at intevation.de Billy Halsey bshalsey at paxoo.com Modified: trunk/doc/ChangeLog =================================================================== --- trunk/doc/ChangeLog 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/doc/ChangeLog 2007-02-26 20:24:29 UTC (rev 4440) @@ -1,3 +1,8 @@ +2007-02-26 Werner Koch + + * gpg.texi (GPG Configuration): Document envvar LANGUAGE. + (GPG Configuration Options): Document show-primary-uid-only. + 2007-02-18 Werner Koch * gpg.texi (GPG Esoteric Options): No card reader options for gpg2. Modified: trunk/doc/DETAILS =================================================================== --- trunk/doc/DETAILS 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/doc/DETAILS 2007-02-26 20:24:29 UTC (rev 4440) @@ -559,14 +559,14 @@ The output was truncated to MAXNO items. This status code is issued for certain external requests - ERROR + ERROR [] This is a generic error status message, it might be followed - by error location specific data. and - should not contain a space. The error code - is a either a string commencing with a letter or such string - prefix with a numerical error code and an underscore; e.g.: - "151011327_EOF" + by error location specific data. and + should not contain spaces. The error code is + a either a string commencing with a letter or such a string + prefixed with a numerical error code and an underscore; e.g.: + "151011327_EOF". ATTRIBUTE Modified: trunk/doc/gpg.texi =================================================================== --- trunk/doc/gpg.texi 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/doc/gpg.texi 2007-02-26 20:24:29 UTC (rev 4440) @@ -1003,6 +1003,11 @@ Show revoked and expired user IDs during signature verification. Defaults to no. + at item show-primary-uid-only +Show only the primary user ID during signature verification. That is +all the AKA lines as well as photo Ids are not shown with the signature +verification status. + @item pka-lookups Enable PKA lookups to verify sender addresses. Note that PKA is based on DNS, and so enabling this option may disclose information on when @@ -2581,6 +2586,16 @@ @itemx LINES Used to size some displays to the full size of the screen. + + at item LANGUAGE +Apart from its use by GNU, it is used in the W32 version to override the +language selection done through the Registry. If used and set to a a +valid and available language name (@var{langid}), the file with the +translation is loaded from + at code{@var{gpgdir}/gnupg.nls/@var{langid}.mo}. Here @var{gpgdir} is the +directory out of which the gpg binary has been laoded. If it can't be +loaded the Registry is tried as a fallback. + @end table Modified: trunk/g10/ChangeLog =================================================================== --- trunk/g10/ChangeLog 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/ChangeLog 2007-02-26 20:24:29 UTC (rev 4440) @@ -1,3 +1,16 @@ +2007-02-26 Werner Koch + + * gpg.c (main): Add verify option show-primary-uid-only. + * options.h (VERIFY_SHOW_PRIMARY_UID_ONLY): New. + * mainproc.c (check_sig_and_print): Implement it. + +2007-02-22 Werner Koch + + * encr-data.c (decrypt_data): Correctly test for unknown algorithm. + * import.c (check_prefs): Ditto. + * keyedit.c (show_prefs): Ditto. + * mainproc.c (proc_symkey_enc): Ditto. + 2007-02-06 Werner Koch * export.c (do_export_stream): Allow reset-subkey-passwd along Modified: trunk/g10/encr-data.c =================================================================== --- trunk/g10/encr-data.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/encr-data.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -90,11 +90,10 @@ if ( opt.verbose && !dek->algo_info_printed ) { - const char *s = gcry_cipher_algo_name (dek->algo); - if (s && *s) - log_info(_("%s encrypted data\n"), s ); + if (!gcry_cipher_test_algo (dek->algo)) + log_info (_("%s encrypted data\n"), gcry_cipher_algo_name (dek->algo)); else - log_info(_("encrypted with unknown algorithm %d\n"), dek->algo ); + log_info (_("encrypted with unknown algorithm %d\n"), dek->algo ); dek->algo_info_printed = 1; } rc = openpgp_cipher_test_algo (dek->algo); Modified: trunk/g10/gpg.c =================================================================== --- trunk/g10/gpg.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/gpg.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -2601,6 +2601,8 @@ N_("show user ID validity during signature verification")}, {"show-unusable-uids",VERIFY_SHOW_UNUSABLE_UIDS,NULL, N_("show revoked and expired user IDs in signature verification")}, + {"show-primary-uid-only",VERIFY_SHOW_PRIMARY_UID_ONLY,NULL, + N_("show only the primary user ID in signature verification")}, {"pka-lookups",VERIFY_PKA_LOOKUPS,NULL, N_("validate signatures with PKA data")}, {"pka-trust-increase",VERIFY_PKA_TRUST_INCREASE,NULL, Modified: trunk/g10/import.c =================================================================== --- trunk/g10/import.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/import.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -603,11 +603,14 @@ { if (openpgp_cipher_test_algo (prefs->value)) { - const char *algo = gcry_cipher_algo_name (prefs->value); + const char *algo = + (gcry_cipher_test_algo (prefs->value) + ? num + : gcry_cipher_algo_name (prefs->value)); if(!problem) check_prefs_warning(pk); log_info(_(" \"%s\": preference for cipher" - " algorithm %s\n"),user,algo?algo:num); + " algorithm %s\n"), user, algo); problem=1; } } @@ -615,11 +618,14 @@ { if(openpgp_md_test_algo(prefs->value)) { - const char *algo = gcry_md_algo_name (prefs->value); + const char *algo = + (gcry_md_test_algo (prefs->value) + ? num + : gcry_md_algo_name (prefs->value)); if(!problem) check_prefs_warning(pk); log_info(_(" \"%s\": preference for digest" - " algorithm %s\n"),user,algo?algo:num); + " algorithm %s\n"), user, algo); problem=1; } } Modified: trunk/g10/keyedit.c =================================================================== --- trunk/g10/keyedit.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/keyedit.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -2319,14 +2319,13 @@ tty_printf (_("Cipher: ")); for(i=any=0; prefs[i].type; i++ ) { if( prefs[i].type == PREFTYPE_SYM ) { - const char *s = gcry_cipher_algo_name (prefs[i].value); - if (any) tty_printf (", "); any = 1; /* We don't want to display strings for experimental algos */ - if (s && prefs[i].value < 100 ) - tty_printf ("%s", s ); + if (!gcry_cipher_test_algo (prefs[i].value) + && prefs[i].value < 100 ) + tty_printf ("%s", gcry_cipher_algo_name (prefs[i].value)); else tty_printf ("[%d]", prefs[i].value); if (prefs[i].value == CIPHER_ALGO_3DES ) @@ -2342,14 +2341,13 @@ tty_printf (_("Digest: ")); for(i=any=0; prefs[i].type; i++ ) { if( prefs[i].type == PREFTYPE_HASH ) { - const char *s = gcry_md_algo_name (prefs[i].value); - if (any) tty_printf (", "); any = 1; /* We don't want to display strings for experimental algos */ - if (s && prefs[i].value < 100 ) - tty_printf ("%s", s ); + if (!gcry_md_test_algo (prefs[i].value) + && prefs[i].value < 100 ) + tty_printf ("%s", gcry_md_algo_name (prefs[i].value) ); else tty_printf ("[%d]", prefs[i].value); if (prefs[i].value == DIGEST_ALGO_SHA1 ) Modified: trunk/g10/mainproc.c =================================================================== --- trunk/g10/mainproc.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/mainproc.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -273,7 +273,7 @@ int algo = enc->cipher_algo; const char *s = gcry_cipher_algo_name (algo); - if(s) + if (!gcry_cipher_test_algo (algo)) { if(!opt.quiet) { @@ -1768,7 +1768,8 @@ /* If we have a good signature and already printed * the primary user ID, print all the other user IDs */ - if ( count && !rc ) { + if ( count && !rc + && !(opt.verify_options&VERIFY_SHOW_PRIMARY_UID_ONLY)) { char *p; for( un=keyblock; un; un = un->next ) { if( un->pkt->pkttype != PKT_USER_ID ) Modified: trunk/g10/options.h =================================================================== --- trunk/g10/options.h 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/g10/options.h 2007-02-26 20:24:29 UTC (rev 4440) @@ -341,6 +341,7 @@ #define VERIFY_SHOW_UNUSABLE_UIDS (1<<6) #define VERIFY_PKA_LOOKUPS (1<<7) #define VERIFY_PKA_TRUST_INCREASE (1<<8) +#define VERIFY_SHOW_PRIMARY_UID_ONLY (1<<9) #define KEYSERVER_USE_TEMP_FILES (1<<0) #define KEYSERVER_KEEP_TEMP_FILES (1<<1) Modified: trunk/sm/encrypt.c =================================================================== --- trunk/sm/encrypt.c 2007-02-26 15:45:29 UTC (rev 4439) +++ trunk/sm/encrypt.c 2007-02-26 20:24:29 UTC (rev 4440) @@ -76,8 +76,8 @@ return gpg_error (GPG_ERR_UNSUPPORTED_ALGORITHM); } - /* Extra check for algorithms we considere to be to weak for - encryption, qlthough we suppor them fro decryption. Note that + /* Extra check for algorithms we consider to be too weak for + encryption, although we support them for decryption. Note that there is another check below discriminating on the key length. */ switch (dek->algo) {