diff --git a/g10/ChangeLog b/g10/ChangeLog
index 23a79cf72..335f28fdf 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,8432 +1,8455 @@
+2003-07-29  Werner Koch  <wk@gnupg.org>
+
+	* g10.c (main): Add secmem features and set the random seed file.
+	(g10_exit): Update the random seed file.
+
+	* parse-packet.c (parse_signature,read_protected_v3_mpi)
+	(parse_key): Fixed use of mpi_set_opaque.
+	* keygen.c (gen_card_key): Ditto.
+
+2003-07-28  Werner Koch  <wk@gnupg.org>
+
+	* status.c (progress_cb): Adjusted for use with Libcgrypt.
+	(set_status_fd): Register that callback.
+
+	* keygen.c (smartcard_change_login_data): New.
+	(smartcard_change_lang): New.
+	(smartcard_change_sex): New.
+	(check_smartcard): Add menu entries to edit the above.
+	(gen_elg,gen_dsa,gen_rsa): Reimplemented in terms of Libgcrypt.
+	(genhelp_protect, genhelp_factors, key_from_sexp): New.
+	* comment.c (make_comment_node_from_buffer): New.
+	(make_comment_node): Reimplemented in terms of above.
+
 2003-07-27  Werner Koch  <wk@gnupg.org>
 
 	Adjusted for gcry_mpi_print and gcry_mpi_scan API change.
 
 2003-07-24  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New command --card-status.
 	* card-util.c (card_status): New.
 	* call-agent.c (learn_status_cb): Parse more information.
 
 	* keylist.c (print_pubkey_info): Add FP arg for optinal printing
 	to a stream.  Changed all callers.
 
 2003-07-23  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (generate_keypair): Create an AUTHKEYTYPE entry for cards.
 	(do_generate_keypair): Abd generate the authkey.
 	(check_smartcard): Changed menu accordingly.
 
 2003-07-22  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New command --change-pin.
 	* card-util.c: New.
 	* call-agent.c (agent_scd_change_pin): New.
 	(agent_release_card_info): New.
 	* keygen.c (check_smartcard): Use it here.
 
 2003-07-16  Werner Koch  <wk@gnupg.org>
 
 	* export.c (parse_export_options): New option sexp-format.
 	(export_seckeys,export_secsubkeys): Check sexp-format option.
 	(do_export): Ignore armor for sexp format.
 	(do_export_stream): Handle sexp-format.
 	(write_sexp_line,write_sexp_keyparm, build_sexp_seckey): New.
 	(build_sexp): New.
 
 2003-07-03  Werner Koch  <wk@gnupg.org>
 
 	* options.h (DBG_CIPHER): Reintroduced it. 
 	* seskey.c (encode_session_key): Debug output of the session key.
 
 	* pubkey-enc.c (get_it): Handle card case.
 	* call-agent.c (agent_scd_pkdecrypt): New.
 	* pkglue.c (pk_encrypt): Add RSA support.
 
 	* g10.c (main): Default to --use-agent.
 
 	* keygen.c (show_smartcard): Print info about the public key.
 	(check_smartcard): Check for existing key here.
 	(gen_card_key): And not anymore here.
 	(fpr_is_zero): New.
 	(generate_keypair): Generate both keys for a card.
 	(smartcard_change_url): Nw.
 
 2003-07-02  Werner Koch  <wk@gnupg.org>
 
 	* seckey-cert.c (is_secret_key_protected): Let it handle mode 1002.
 
 2003-07-01  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (gen_card_key): Obviously we should use the creation
 	date received from SCDAEMON, so that the fingerprints will match.
 	* sign.c (do_sign): Pass the serialno to the sign code.
 	* keyid.c (serialno_and_fpr_from_sk): New.
 
 2003-06-30  Werner Koch  <wk@gnupg.org>
 
 	* call-agent.h (agent_card_info_s): Add field serialno.
 	* call-agent.c (store_serialno): New.
 	(learn_status_cb): Store the serial number.
 	* keygen.c (gen_card_key): Store the serial number
 	(check_smartcard): New argument to return the serial number.
 	(generate_keypair): Get the serial number from check_smartcard and
 	store it as a parameter.
 	* parse-packet.c (parse_key): Use the protect.iv field to store the
 	serial number.
 	* build-packet.c (do_secret_key): Write the serial number.
 
 2003-06-27  Werner Koch  <wk@gnupg.org>
 
 	* seckey-cert.c (check_secret_key): Bypass the unprotection for
 	mode 1002.
 	* sign.c (do_sign): Handle card case (i.e. mode 1002).
 
 2003-06-26  Werner Koch  <wk@gnupg.org>
 
 	* build-packet.c (do_secret_key): Implement special protection
 	mode 1002.
 	* parse-packet.c (parse_key): Likewise.
 
 	* keygen.c (smartcard_gen_key): New.
 	* call-agent.c (agent_scd_setattr): New.
 
 2003-06-24  Werner Koch  <wk@gnupg.org>
 
 	* Makefile.am: Removed signal.c
 
 	* g10.c (emergency_cleanup): New.
 	(main): Use gnupg_init_signals and register malloc for assuan.
 
 2003-06-23  Werner Koch  <wk@gnupg.org>
 
 	* keyid.c (do_fingerprint_md): Made it work again.
 
 2003-06-19  Werner Koch  <wk@gnupg.org>
 
 	Fixed all "==" comparisons against error code constants to use
 	gpg_err_code().
 
 	* import.c (import_secret_one): 
 	(import_revoke_cert): 
 	(chk_self_sigs): 
 
 	* misc.c (openpgp_md_map_name): Check also for the Hx format.
 	(openpgp_cipher_map_name): Check also for the Sx format.
 	(pubkey_get_npkey): Adjusted for changed gcrypt API.
 	(pubkey_get_nskey): Ditto.
 	(pubkey_get_nsig): Ditto.
 	(pubkey_get_nenc): Ditto.
 
 2003-06-18  Werner Koch  <wk@gnupg.org>
 
         Finished the bulk of changes for gnupg 1.9.  This included
 	switching to libgcrypt functions, using shared error codes from
 	libgpg-error, replacing the old functions we used to have in
 	../util by those in ../jnlib and ../common, renaming the malloc
 	functions and a couple of types.  Note, that not all changes are
 	listed below becuause they are too similar and done at far too
 	many places.  As of today the code builds using the current
 	libgcrypt from CVS but it is very unlikely that it actually works.
 	
 	* sig-check.c (cmp_help): Removed.  Was never used.
 
 	* pkglue.c: New. Most stuff taken from gnupg 1.1.2.
 	* pkglue.h: New.
 
 	* misc.c (pull_in_libs): Removed.
 
 	* keygen.c (count_chr): New.
 	(ask_user_id): Removed faked RNG support.
 
 	* misc.c (openpgp_md_map_name,openpgp_cipher_map_name)
 	(openpgp_pk_map_name): New.
 
 	* skclist.c (build_sk_list): Removed faked RNG support.
 	(is_insecure): Removed.
 
 	* comment.c (make_mpi_comment_node): Use gcry MPI print function.
 
 	* keyid.c (v3_keyid): New.
 
 	* misc.c (mpi_write,mpi_write_opaque,mpi_read,mpi_read_opaque)
 	(mpi_print): New.  Taken from gnupg 1.1.2.
 	(checksum_mpi): Replaced by implementation from 1.1.2.
 
 	* g10.c (my_strusage): Renamed from strusage and return NULL
 	instead calling a default function.
 	(add_to_strlist2): New.  Taken from ../util/strgutil.c of gnupg 1.2.
 
 	* plaintext.c (handle_plaintext): New arg CREATE_FILE to cope with
 	the fact that gpg-error does not have this error code anymore.
 
 	* mainproc.c (symkey_decrypt_sesskey): Ditto.
 
 	* seskey.c (make_session_key): Adjusted for use with libgcrypt.
 	(encode_session_key): Ditto.
 	(do_encode_md): Ditto.
 	(encode_md_value): Ditto.
 
 	* keyring.c: Use libgpg-error instead of READ_ERROR etc.
 
 	* g10.c: Adjusted all algorithm name/id mapping functions.
 	(set_debug): Pass MPI and CRYPTO debug values to libgcrypt.
 
 	* Makefile.am (INCLUDES): Define LOCALEDIR and the default error
 	source.
 
 	* g10.c (i18n_init): s/G10_LOCALEDIR/LOCALEDIR/.
 
 	Renamed m_alloc et al to xmalloc et al.
 	s/g10_errstr/gpg_strerror/
 	s/MPI/gcry_mpi_t/
 	Adjusted all md_open calls to the libgcrypt API.
 	
 	* build-packet.c (do_comment): Return error code from iobuf write
 	function.
 	(do_user_id): Ditto.
 	(do_public_key): Ditto.
 
 	* Makefile.am: Add new files, link gpg with libgpg-error.
 	* g10.c, options.h: New option --agent-program.
 	* call-agent.c: New.
 	* gpg.h, call-agent.h: New.
 
 2003-06-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), keylist.c (list_keyblock_print): Add
 	"show-validity" and "show-long-keyid" list-options.
 
 	* gpgv.c (get_validity, trust_value_to_string): Stubs.
 
 	* g10.c (main): Use SAFE_VERSION instead of VERSION in the
 	version-specific gpg.conf file so it can be overridden on RISCOS.
 
 2003-06-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main), keylist.c (show_policy_url, show_notation),
 	mainproc.c (check_sig_and_print): Emulate the old policy and
 	notation behavior (display by default).  Send to status-fd whether
 	it is displayed on the screen or not.
 
 	* g10.c (main): Since we now have some options in devel that won't
 	work in a stable branch gpg.conf file, try for a version-specific
 	gpg.conf-VERSION file before falling back to gpg.conf.
 
 	* main.h, options.h: Move various option flags to options.h.
 
 2003-05-31  David Shaw  <dshaw@jabberwocky.com>
 
 	* mainproc.c (check_sig_and_print), main.h, keylist.c
 	(show_policy, show_notation): Collapse the old print_notation_data
 	into show_policy() and show_notation() so there is only one
 	function to print notations and policy URLs.
 
 	* options.h, main.h, g10.c (main), keyedit.c
 	(print_and_check_one_sig), keylist.c (list_one,
 	list_keyblock_print), pkclist.c (do_edit_ownertrust), sign.c
 	(mk_notation_and_policy): New "list-options" and "verify-options"
 	commands.  These replace the existing
 	--show-photos/--no-show-photos,
 	--show-notation/--no-show-notation,
 	--show-policy-url/--no-show-policy-url, and --show-keyring
 	options.  The new method is more flexible since a user can specify
 	(for example) showing photos during sig verification, but not in
 	key listings.  The old options are emulated.
 
 	* main.h, misc.c (parse_options): New general option line
 	parser. Fix the bug in the old version that did not handle report
 	syntax errors after a valid entry.
 
 	* import.c (parse_import_options), export.c
 	(parse_export_options): Call it here instead of duplicating the
 	code.
 
 2003-05-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* keylist.c (list_one): Don't show the keyring filename when in
 	--with-colons mode.  Actually translate "Keyring" string.
 
 	* mainproc.c (proc_tree): We can't currently handle multiple
 	signatures of different classes or digests (we'd pretty much have
 	to run a different hash context for each), but if they are all the
 	same, make an exception.  This is Debian bug #194292.
 
 	* sig-check.c (check_key_signature2): Make string translatable.
 
 	* packet.h, getkey.c (fixup_uidnode): Mark real primary uids
 	differently than assumed primaries.
 
 	* keyedit.c (no_primary_warning): Use the differently marked
 	primaries here in a new function to warn when an --edit-key
 	command might rearrange the self-sig dates enough to change which
 	uid is primary.
 	(menu_expire, menu_set_preferences): Use no_primary_warning()
 	here.
 
 	* Makefile.am: Use @DLLIBS@ for -ldl.
 
 2003-05-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (premerge_public_with_secret): Made "no secret subkey
 	for" warning a verbose item and translatable. (From wk on stable
 	branch)
 
 	* sig-check.c (check_key_signature2): Made "no subkey for subkey
 	binding packet" a verbose item instead of a !quiet one.  There are
 	too many garbled keys out in the wild. (From wk on stable branch)
 
 	* filter.h: Remove const from WHAT. (From wk on stable branch)
 
 	* progress.c (handle_progress): Store a copy of
 	NAME. (progress_filter): Release WHAT, make sure not to print a
 	NULL WHAT. (From wk on stable branch)
 
 	* openfile.c (open_sigfile): Adjust free for new progress
 	semantics. (From wk on stable branch)
 
 	* plaintext.c (ask_for_detached_datafile): Don't dealloc
 	pfx->WHAT. (From wk on stable branch)
 
 	* seckey-cert.c (do_check): Issue the RSA_OR_IDEA status when the
 	cipher algo is IDEA to make it easier to track down the
 	problem. (From twoaday on stable branch)
 	
 2003-05-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* armor.c, g10.c, kbnode.c, misc.c, pkclist.c, sign.c,
 	build-packet.c, getkey.c, keydb.c, openfile.c, plaintext.c,
 	status.c, gpgv.c, keygen.c, options.h, sig-check.c, tdbio.h,
 	encode.c, mainproc.c, parse-packet.c, signal.c, textfilter.c: Edit
 	all preprocessor instructions to remove whitespace before the '#'.
 	This is not required by C89, but there are some compilers out
 	there that don't like it.
 
 2003-05-21  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.h, trustdb.c (is_disabled), gpgv.c (is_disabled): Rename
 	is_disabled to cache_disabled_value, which now takes a pk and not
 	just the keyid. This is for speed since there is no need to
 	re-fetch a key when we already have that key handy.  Cache the
 	result of the check so we don't need to hit the trustdb more than
 	once.
 	
 	* getkey.c (skip_disabled): New function to get a pk and call
 	is_disabled on it. (key_byname): Use it here.
 	
 	* packet.h, getkey.c (skip_disabled), keylist.c
 	(print_capabilities): New "pk_is_disabled" macro to retrieve the
 	cached disabled value if available, and fill it in via
 	cache_disabled_value if not available.
 
 	* trustdb.c (get_validity): Cache the disabled value since we have
 	it handy and it might be useful later.
 
 	* parse-packet.c (parse_key): Clear disabled flag when parsing a
 	new key.  Just in case someone forgets to clear the whole key.
 
 	* getkey.c (merge_selfsigs_main): Add an "if all else fails" path
 	for setting a single user ID primary when there are multiple set
 	primaries all at the same second, or no primaries set and the most
 	recent user IDs are at the same second, or no signed user IDs at
 	all. This is arbitrary, but deterministic.
 
 	* exec.h, photoid.h: Add copyright message.
 
 	* keylist.c (list_keyblock_print): Don't dump attribs for
 	revoked/expired/etc uids for non-colon key listings.  This is for
 	consistency with --show-photos.
 
 	* main.h, keylist.c (dump_attribs), mainproc.c
 	(check_sig_and_print): Dump attribs if --attrib-fd is set when
 	verifying signatures.
 	
 	* g10.c (main): New --gnupg option to disable the various
 	--openpgp, --pgpX, etc. options.  This is the same as --no-XXXX
 	for those options.
 
 	* revoke.c (ask_revocation_reason): Clear old reason if user
 	elects to repeat question.  This is bug 153.
 
 	* keyedit.c (sign_uids): Show keyid of the key making the
 	signature.
 
 2003-05-21  Werner Koch  <wk@gnupg.org>
 
 	* progress.c (handle_progress)
 	* sign.c (write_plaintext_packet)
 	* encode.c (encode_simple,encode_crypt): Make sure that a filename
 	of "-" is considered to be stdin so that iobuf_get_filelength
 	won't get called.  This fixes bug 156 reported by Gregery Barton.
 
 2003-05-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, build-packet.c (build_sig_subpkt), export.c
 	(do_export_stream), import.c (remove_bad_stuff, import),
 	parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt): Remove
 	vestigal code for the old sig cache subpacket.  This wasn't
 	completely harmless as it caused subpacket 101 to disappear on
 	import and export.
 
 	* options.h, armor.c, cipher.c, g10.c, keyedit.c, pkclist.c,
 	sign.c, encode.c, getkey.c, revoke.c: The current flags for
 	different levels of PGP-ness are massively complex.  This is step
 	one in simplifying them. No functional change yet, just use a
 	macro to check for compliance level.
 
 	* sign.c (sign_file): Fix bug that causes spurious compression
 	preference warning.
 
 	* sign.c (clearsign_file): Fix bug that prevents proper warning
 	message from appearing when clearsigning in --pgp2 mode with a
 	non-v3 RSA key.
 
 	* main.h, misc.c (compliance_option_string, compliance_string,
 	compliance_failure), pkclist.c (build_pk_list), sign.c (sign_file,
 	clearsign_file), encode.c (encode_crypt,
 	write_pubkey_enc_from_list): New functions to put the "this
 	message may not be usable...." warning in one place.
 
 	* options.h, g10.c (main): Part two of the simplification.  Use a
 	single enum to indicate what we are compliant to (1991, 2440,
 	PGPx, etc.)
 
 	* g10.c (main): Show errors for failure in export, send-keys,
 	recv-keys, and refresh-keys.
 
 	* options.h, g10.c (main): Give algorithm warnings for algorithms
 	chosen against the --pgpX and --openpgp rules.
 
 	* keydb.h, pkclist.c (algo_available): Make TIGER192 invalid in
 	--openpgp mode.
 
 	* sign.c (sign_file), pkclist.c (algo_available): Allow passing a
 	hint of 0.
 
 2003-05-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* tdbio.c (create_version_record): Only create new trustdbs with
 	TM_CLASSIC or TM_PGP.
 
 	* trustdb.h, trustdb.c (trust_string, get_ownertrust_string,
 	get_validity_string, ask_ownertrust, validate_keys), pkclist.c
 	(do_edit_ownertrust): Rename trust_string to trust_value_to_string
 	for naming consistency.
 
 	* trustdb.h, trustdb.c (string_to_trust_value): New function to
 	translate a string to a trust value.
 
 	* g10.c (main): Use string_to_trust_value here for
 	--force-ownertrust.
 	
 	* options.h, g10.c (main), trustdb.c (trust_model_string,
 	init_trustdb, check_trustdb, update_trustdb, get_validity,
 	validate_one_keyblock): An "OpenPGP" trust model is misleading
 	since there is no official OpenPGP trust model.  Use "PGP"
 	instead.
 
 2003-04-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* build-packet.c (build_sig_subpkt): Comments.
 
 	* exec.c (exec_write): Cast NULL to void* to properly terminate
 	varargs list.
 
 	* keyedit.c (show_key_with_all_names): Just for safety, catch an
 	invalid pk algorithm.
 
 	* sign.c (make_keysig_packet): Crucial that the call to mksubpkt
 	comes LAST before the calls to finalize the sig as that makes it
 	possible for the mksubpkt function to get a reliable pointer to
 	the subpacket area.
 
 	* pkclist.c (do_we_trust_pre): If an untrusted key was chosen by a
 	particular user ID, use that ID as the one to ask about when
 	prompting whether to use the key anyway.
 	(build_pk_list): Similar change here when adding keys to the
 	recipient list.
 
 	* trustdb.c (update_validity): Fix bug that prevented more than
 	one validity record per trust record.
 	(get_validity): When retrieving validity for a (user) supplied
 	user ID, return the validity for that user ID only, and do not
 	fall back to the general key validity.
 	(validate_one_keyblock): Some commentary on whether
 	non-self-signed user IDs belong in the web of trust (arguably,
 	they do).
 
 2003-04-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Add --no-textmode.
 
 	* export.c (do_export_stream), keyedit.c (show_key_with_all_names,
 	menu_addrevoker), mainproc.c (check_sig_and_print), photoid.c
 	(show_photos), sign.c (mk_notation_and_policy), trustdb.c
 	(get_validity, reset_trust_records, validate_keys): Make some
 	strings translatable.
 
 	* mainproc.c (check_sig_and_print): Show digest algorithm and sig
 	class when verifying a sig with --verbose on, and add version, pk
 	and hash algorithms and sig class to VALIDSIG.
 	
 	* parse-packet.c (enum_sig_subpkt): Make a warning message a
 	--verbose warning message since we don't need to warn every time
 	we see an unknown critical (we only need to invalidate the
 	signature).
 
 	* trustdb.c (init_trustdb): Check the trustdb options even with
 	TM_AUTO since the auto may become TM_CLASSIC or TM_OPENPGP.
 
 2003-04-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (do_sign): Show the hash used when making a signature in
 	verbose mode.
 
 	* tdbio.h, tdbio.c (tdbio_read_model): New function to return the
 	trust model used in a given trustdb.
 
 	* options.h, g10.c (main), trustdb.c (init_trustdb, check_trustdb,
 	update_trustdb): Use tdbio_read_model to implement an "auto" trust
 	model which is set via the trustdb.
 
 2003-04-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_revoke_cert): Remove ultimate trust when
 	revoking an ultimately trusted key.
 
 	* keyedit.c (sign_uids): Allow replacing expired signatures.
 	Allow duplicate signatures with --expert.
 
 	* pkclist.c (check_signatures_trust): Don't display a null
 	fingerprint when checking a signature with --always-trust enabled.
 
 	* filter.h (progress_filter_context_t), progress.c
 	(handle_progress), plaintext.c (ask_for_detached_datafile,
 	hash_datafiles): Fix compiler warnings.  Make "what" constant.
 
 	* build-packet.c (do_plaintext): Do not create invalid literal
 	packets with >255-byte names.
 
 2003-04-15  Werner Koch  <wk@gnupg.org>
 
 	* Makefile.am (AM_CFLAGS): Make use of AM_CFLAGS and AM_LDFLAGS.
 
 	* g10.c, options.h: New option --enable-progress-filter.
 	* progress.c (handle_progress): Make use of it.
 
 2003-04-15  Marcus Brinkmann  <marcus@g10code.de>
 
 	* progress.c: New file.
 	* Makefile.am (common_source): Add progress.c.
 	* filter.h (progress_filter_context_t): New type.
 	(progress_filter, handle_progress): New prototypes.
 	* main.h (open_sigfile): New argument for prototype.
 	* openfile.c (open_sigfile): New argument to install progress
 	filter.
 	* encode.c (encode_simple): New variable PFX.  Register
 	progress filter.  Install text_filter after that.
 	(encode_crypt): Likewise.
 	* sign.c (sign_file): Likewise.
 	(clearsign_file): Likewise.
 	* decrypt.c (decrypt_message): Likewise.
 	(decrypt_messages): Likewise.
 	* verify.c (verify_signatures): Likewise.
 	(verify_one_file): Likewise.
 	* plaintext.c (hash_datafiles): Likewise.
 	(ask_for_detached_datafile): Likewise.
 
 2003-04-10  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (read_passphrase_from_fd): Do a dummy read if the
 	agent is to be used.  Noted by Ingo Kl�cker.
 	(agent_get_passphrase): Inhibit caching when we have no
 	fingerprint.  This is required for key generation as well as for
 	symmetric only encryption.
 
 	* passphrase .c (agent_get_passphrase): New arg CANCELED.
 	(passphrase_to_dek): Ditto.  Passed to above.  Changed all
 	callers to pass NULL.
 	* seckey-cert.c (do_check): New arg CANCELED.
 	(check_secret_key): Terminate loop when canceled.
 
 	* keyedit.c (change_passphrase): Pass ERRTEXT untranslated to
 	passphrase_to_dek and translate where appropriate.
 	* seckey-cert.c (check_secret_key): Ditto.
 	* keygen.c (ask_passphrase): Ditto.
 	* passphrase.c (agent_get_passphrase): Translate the TRYAGAIN_TEXT.
 	Switch the codeset to utf-8.
 
 2003-04-09  Werner Koch  <wk@gnupg.org>
 
 	* decrypt.c (decrypt_messages): Fixed error handling; the function
 	used to re-loop with same file after an error.  Reported by Joseph
 	Walton.
 
 2003-04-08  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, g10.c (main), import.c (parse_import_options,
 	fix_pks_corruption): It's really PKS corruption, not HKP
 	corruption.  Keep the old repair-hkp-subkey-bug command as an
 	alias.
 
 	* g10.c (main): Rename --no-version to --no-emit-version for
 	consistency.  Keep --no-version as an alias.
 
 2003-04-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* pkclist.c (algo_available): PGP 8 can use the SHA-256 hash.
 
 	* sign.c (sign_file, clearsign_file, sign_symencrypt_file): Remove
 	unused code.
 
 2003-04-01  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (check_sig_and_print): Add primary key fpr to VALIDSIG
 	status.
 
 2003-03-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* keydb.h: Err on the side of making an unknown signature a SIG
 	rather than a CERT.
 
 	* import.c (delete_inv_parts): Discard any key signatures that
 	aren't key types (i.e. 0x00, 0x01, etc.)
 
 	* g10.c (main): Add deprecated option warning for
 	--list-ownertrust.  Add --compression-algo alias for
 	--compress-algo.  Change --version output strings to match
 	"showpref" strings, and make translatable.
 
 	* status.c (do_get_from_fd): Accept 'y' as well as 'Y' for
 	--command-fd boolean input.
 
 	* trustdb.c: Fix typo (DISABLE_REGEXP -> DISABLE_REGEX)
 
 	* keyedit.c (show_key_with_all_names_colon): Show no-ks-modify
 	flag.
 
 2003-03-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), keyserver.c (kopts): Add "try-dns-srv"
 	keyserver option.  Defaults to on.
 
 	* passphrase.c (agent_get_passphrase): Fix memory leak with
 	symmetric messages.  Fix segfault with symmetric messages.  Fix
 	incorrect prompt with symmetric messages.
 
 2003-03-10  Werner Koch  <wk@gnupg.org>
 
 	* compress.c (init_uncompress): Use a 15 bit window size so that
 	the output of implementations which don't run for PGP 2
 	compatibility won't get garbled.
 
 2003-03-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (validate_keys): Mask the ownertrust when building the
 	list of fully valid keys so that disabled keys are still counted
 	in the web of trust.
 	(get_ownertrust_with_min): Do the same for the minimum ownertrust
 	calculation.
 
 	* parse-packet.c (dump_sig_subpkt): Show the notation names for
 	not-human-readable notations.  Fix cosmetic off-by-one length
 	counter.
 
 	* options.skel: Add explantion and commented-out
 	"no-mangle-dos-filenames".
 
 	* mainproc.c (proc_encrypted): Make string translatable.
 
 	* keyserver.c (keyserver_spawn): Quote ':', '%', and any 8-bit
 	characters in the uid strings sent to the keyserver helper.
 
 	* keyring.c (keyring_rebuild_cache): Lock the keyring while
 	rebuilding the signature caches to prevent another gpg from
 	tampering with the temporary copy.
 
 	* keygen.c (keygen_set_std_prefs): Include AES192 and AES256 in
 	default prefs.
 
 	* keyedit.c (show_prefs): Make strings translatable.
 
 	* keydb.c: Double the maximum number of keyrings to 40.
 
 	* gpgv.c (main): Fix bug #113 - gpgv should accept the
 	--ignore-time-conflict option.
 
 	* g10.c (main): --openpgp disables --pgpX.  Double the amount of
 	secure memory to 32k (keys are getting bigger these days).
 
 	* Makefile.am: Makefile.am: Use @CAPLIBS@ to link in -lcap if we
 	are using capabilities.
 
 2003-02-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Include various pieces of
 	information about the key in the data sent to the keyserver
 	helper.  This allows the helper to use it in instructing a remote
 	server which may not have any actual OpenPGP smarts in parsing
 	keys.
 
 	* main.h, export.c (export_pubkeys_stream, do_export_stream): Add
 	ability to return only the first match in an exported keyblock for
 	keyserver usage.  This should be replaced at some point with a
 	more flexible solution where each key can be armored seperately.
 
 2003-02-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (sign_file): Do not push textmode filter onto an unopened
 	IOBUF (segfault).  Noted by Marcus Brinkmann.  Push and
 	reinitialize textmode filter for each file in a multiple file
 	list.
 
 	* packet.h, getkey.c (fixup_uidnode), keyedit.c (show_prefs): Set
 	and show the keyserver no-modify flag.
 
 	* keygen.c (add_keyserver_modify): New.
 	(keygen_upd_std_prefs): Call it here.
 	(keygen_set_std_prefs): Accept "ks-modify" and "no-ks-modify" as
 	prefs to set and unset keyserver modify flag.
 
 	* g10.c (main): Accept "s1" in addition to "idea" to match the
 	other ciphers.
 
 	* main.h, misc.c (idea_cipher_warn): We don't need this if IDEA
 	has been disabled.
 
 2003-02-21  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (keygen_set_std_prefs): Don't put AES or CAST5 in
 	default prefs if they are disabled.
 
 	* g10.c (main): Use 3DES instead of CAST5 if we don't have CAST5
 	support.  Use 3DES for the s2k cipher in --openpgp mode.
 	(print_mds): #ifdef all of the optional digest algorithms.
 
 2003-02-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* keydb.h, getkey.c (classify_user_id, classify_user_id2): Make
 	'exact' a per-desc item.  Merge into one function since
 	'force_exact' is no longer needed.
 	(key_byname): Use new classify_user_id function, and new exact
 	flag in KEYDB_SEARCH_DESC.
 
 	* keyring.h, keyring.c (keyring_search): Return an optional index
 	to show which KEYDB_SEARCH_DESC was the matching one.
 
 	* keydb.h, keydb.c (keydb_search): Rename to keydb_search2, and
 	pass the optional index to keyring_search.  Add a macro version of
 	keydb_search that calls this new function.
 
 	* export.c (do_export_stream): If the keyid! syntax is used,
 	export only that specified key.  If the key in question is a
 	subkey, export the primary plus that subkey only.
 
 2003-02-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* exec.c (set_exec_path): Add debugging line.
 
 	* g10.c (print_hex, print_mds): Print long hash strings a lot
 	neater.  This assumes at least an 80-character display, as there
 	are a few other similar assumptions here and there.  Users who
 	need unformatted hashes can still use with-colons.  Check that
 	SHA384 and 512 are available before using them as they are no
 	longer always available.
 
 	* Makefile.am: Use a local copy of libexecdir along with @PACKAGE@
 	as GNUPG_LIBEXECDIR so it can be easily overridden at make time.
 
 2003-02-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* armor.c (parse_hash_header, armor_filter): Accept the new SHAs
 	in the armor Hash: header.
 
 	* g10.c (print_hex): Print long hash strings a little neater.
 	(print_mds): Add the new SHAs to the hash list.
 
 2003-02-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_revuid): Properly handle a nonselfsigned uid on
 	a v4 key (treat as a v4 revocation).
 
 	* import.c (print_import_check): Do not re-utf8 convert user IDs.
 
 2003-01-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* mainproc.c (list_node): Show signature expiration date in
 	with-colons sig records.
 
 	* keylist.c (list_keyblock_colon), mainproc.c (list_node): Show
 	trust sig information in with-colons sig records.
 
 2003-01-16  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (add_group): Trim whitespace after a group name so it does
 	not matter where the user puts the = sign.
 
 	* options.skel: Comment out the first three lines in case someone
 	manually copies the skel file to their homedir.
 
 	* sign.c (clearsign_file): Only use pgp2mode with v3 keys and
 	MD5. This matches what we do when decoding such messages and
 	prevents creating a message (v3+RIPEMD/160) that we can't verify.
 
 	* sig-check.c (signature_check2): Use G10ERR_GENERAL as the error
 	for signature digest conflict.  BAD_SIGN implies that a signature
 	was checked and we may try and print out a user ID for a key that
 	doesn't exist.
 
 2003-01-15  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (init_trustdb, get_validity): Don't use a changed
 	trust model to indicate a dirty trustdb, and never auto-rebuild a
 	dirty trustdb with the "always" trust model.
 
 	* g10.c (add_group): Last commit missed the \t ;)
 
 2003-01-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, parse-packet.c (setup_user_id), free-packet.c
 	(free_user_id), keydb.h, keyid.c (namehash_from_uid): New function
 	to rmd160-hash the contents of a user ID packet and cache it in
 	the uid object.
 
 	* keylist.c (list_keyblock_colon): Use namehash in field 8 of
 	uids.  Show dates for creation (selfsig date), and expiration in
 	fields 6 and 7.
 
 	* trustdb.c (get_validity, get_validity_counts, update_validity):
 	Use new namehash function rather than hashing it locally.
 
 2003-01-14  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (add_group): Fixed group parsing to allow more than one
 	delimiter in a row and also allow tab as delimiter.
 
 2003-01-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* tdbio.c (tdbio_set_dbname): Fix assertion failure with
 	non-fully-qualified trustdb names.
 
 2003-01-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (get_validity_info, get_ownertrust_info,
 	trust_letter): Simplify by returning a ? for error directly.
 
 	* keyedit.c (show_key_with_all_names): Use get_validity_string and
 	get_ownertrust_string to show full word versions of trust
 	(i.e. "full" instead of 'f').
 
 	* trustdb.h, trustdb.c (get_ownertrust_string,
 	get_validity_string): Same as get_ownertrust_info, and
 	get_validity_info, except returns a full string.
 
 	* trustdb.c (get_ownertrust_with_min): New.  Same as
 	'get_ownertrust' but takes the min_ownertrust value into account.
 
 2003-01-10  David Shaw  <dshaw@jabberwocky.com>
 
 	* armor.c (armor_filter): Comment about PGP's end of line tab
 	problem.
 
 	* trustdb.h, trustdb.c (trust_letter): Make
 	static. (get_ownertrust_info, get_validity_info): Don't mask the
 	trust level twice.
 
 	* trustdb.h, gpgv.c, trustdb.c (get_validity, get_validity_info),
 	keylist.c (list_keyblock_colon), keyedit.c
 	(show_key_with_all_names_colon, menu_revuid): Pass a user ID in
 	rather than a namehash, so we only have to do the hashing in one
 	place.
 
 	* packet.h, pkclist.c (build_pk_list), free-packet.c
 	(release_public_key_parts): Remove unused namehash element for
 	public keys.
 
 2003-01-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (keygen_set_std_prefs): Warn when setting an IDEA
 	preference when IDEA is not available.
 
 2003-01-06  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (get_validity_info): 'd' for disabled is not a
 	validity value any more.
 
 	* packet.h, tdbio.h, tdbio.c (tdbio_read_record,
 	tdbio_write_record), trustdb.c (update_validity): Store temporary
 	full & marginal counts in the trustdb.
 	(clear_validity, get_validity_counts): Return and clear temp
 	counts.
 	(store_validation_status): Keep track of which keyids have been
 	stored.
 	(validate_one_keyblock, validate_key_list): Use per-uid copies of
 	the full & marginal counts so they can be recalled for multiple
 	levels.
 	(validate_keys): Only use unused keys for each new round.
 	(reset_unconnected_keys): Rename to reset_trust_records, and only
 	skip specifically excluded records.
 
 	* keylist.c (print_capabilities): Show 'D' for disabled keys in
 	capabilities section.
 
 	* trustdb.c (is_disabled): Remove incorrect comment.
 
 2003-01-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_one): Only do the work to create the status
 	display for interactive import if status is enabled.
 
 	* keyring.c (keyring_search): skipfnc didn't work properly with
 	non-keyid searches.  Noted by Stefan Bellon.
 
 	* getkey.c (merge_selfsigs_main): Remove some unused code and make
 	sure that the pk selfsigversion member accounts for 1F direct
 	sigs.
 
 2003-01-02  Werner Koch  <wk@gnupg.org>
 
 	* keydb.c (keydb_add_resource): Don't assume that try_make_homedir
 	terminates but check again for the existence of the directory and
 	continue then.
 	* openfile.c (copy_options_file): Print a warning if the skeleton
 	file has active options.
 
 2002-12-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (merge_selfsigs_main), main.h, sig-check.c
 	(check_key_signature2): Pass the ultimately trusted pk directly to
 	check_key_signature2 to avoid going through the key selection
 	mechanism.  This prevents a deadly embrace when two keys without
 	selfsigs each sign the other.
 
 2002-12-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_refresh): Don't print the "refreshing..."
 	line if there are no keys to refresh or if there is no keyserver
 	set.
 
 	* getkey.c (merge_selfsigs_main): Any valid user ID should make a
 	key valid, not just the last one.  This also fixes Debian bug
 	#174276.
 
 2002-12-27  Stefan Bellon  <sbellon@sbellon.de>
 
 	* import.c (print_import_check): Changed int to size_t.
 
 2002-12-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (keyedit_menu, menu_revuid): Add "revuid" feature to
 	revoke a user ID.  This is the same as issuing a revocation for
 	the self-signature, but a much simpler interface to do it.
 
 2002-12-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* keydb.h, getkey.c (key_byname): Flag to enable or disable
 	including disabled keys.  Keys specified via keyid (i.e. 0x...)
 	are always included.
 
 	* getkey.c (get_pubkey_byname, get_seckey_byname2,
 	get_seckey_bynames), keyedit.c (keyedit_menu, menu_addrevoker):
 	Include disabled keys in these functions.
 
 	* pkclist.c (build_pk_list): Do not include disabled keys for -r
 	or the key prompt.  Do include disabled keys for the default key
 	and --encrypt-to.
 
 	* trustdb.h, trustdb.c (is_disabled): New skipfnc for skipping
 	disabled keys.
 
 	* gpgv.c (is_disabled): Stub.
 
 	* keygen.c (keygen_add_key_expire): Properly handle updating a key
 	expiration to a no-expiration value.
 
 	* keyedit.c (enable_disable_key): Comment.
 
 	* import.c (import_one): When in interactive mode and --verbose,
 	don't repeat some key information twice.
 
 2002-12-22  Timo Schulz  <ts@winpt.org>
 	
 	* import.c (print_import_check): New.
 	(import_one): Use it here.
         Use merge_keys_and_selfsig in the interactive mode to avoid
         wrong key information.
         * status.h: Add new status code.
         * status.c: Ditto.
 	
 2002-12-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* pkclist.c (do_we_trust): Tweak language to refer to the "named
 	user" rather than "owner".  Noted by Stefan Bellon.
 
 	* trustdb.h, trustdb.c (trustdb_pending_check): New function to
 	check if the trustdb needs a check.
 
 	* import.c (import_keys_internal): Used here so we don't rebuild
 	the trustdb if it is still clean.
 	(import_one, chk_self_sigs): Only mark trustdb dirty if the key
 	that is being imported has any sigs other than self-sigs.
 	Suggested by Adrian von Bidder.
 
 	* options.skel: Include the required '=' sign in the sample
 	'group' option.  Noted by Stefan Bellon.
 
 	* import.c (chk_self_sigs): Don't try and check a subkey as if it
 	was a signature.
 
 2002-12-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* tdbio.c (tdbio_read_record, tdbio_write_record): Compact the
 	RECTYPE_TRUST records a bit.
 
 	* g10.c (main): Comment out --list-trust-path until it can be
 	implemented.
 
 	* import.c (import_one): Warn when importing an Elgamal primary
 	that this may take some time (to verify self-sigs).
 	(chk_self_sigs): Try and cache all self-sigs so the keyblock is
 	written to the keyring with a good rich cache.
 
 	* keygen.c (ask_algo): Make the Elgamal sign+encrypt warning
 	stronger, and remove the RSA sign+encrypt warning.
 
 2002-12-06  Stefan Bellon  <sbellon@sbellon.de>
 
 	* options.h: Fixed typo (mangle_dos_names instead of
 	mangle_dos_filenames).
 
 2002-12-05  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New options --[no-]mangle-dos-filenames.
 	* options.h (opt): Added mangle-dos-filenames.
 	* openfile.c (open_outfile) [USE_ONLY_8DOT3]: Truncate the
 	filename only when this option is set; this is the default.
 
 2002-12-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, keyedit.c, keygen.c: Back out previous (2002-12-01)
 	change.  Minimal isn't always best.
 
 	* sign.c (update_keysig_packet): Use the current time rather then
 	a modification of the original signature time.  Make sure that
 	this doesn't cause a time warp.
 
 	* keygen.c (keygen_add_key_expire): Properly handle a key
 	expiration date in the past (use a duration of 0).
 
 	* keyedit.c (menu_expire): Use update_keysig_packet so any sig
 	subpackets are maintained during the update.
 
 	* build-packet.c (build_sig_subpkt): Mark sig expired or unexpired
 	when the sig expiration subpacket is added.
 	(build_sig_subpkt_from_sig): Handle making an expiration subpacket
 	from a sig that has already expired (use a duration of 0).
 
 	* packet.h, sign.c (update_keysig_packet), keyedit.c
 	(menu_set_primary_uid, menu_set_preferences): Add ability to issue
 	0x18 subkey binding sigs to update_keysig_packet and change all
 	callers.
 
 	* trustdb.c (validate_keys): Show trust parameters when building
 	the trustdb, and make sure that the version record update was
 	successful.
 	(init_trustdb): If the current parameters aren't what was used for
 	building the trustdb, the trustdb is invalid.
 
 	* tbio.c (tdbio_db_matches_options): Update to work with new
 	trustdbs.
 
 2002-12-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record): Store
 	trust model in the trustdb version record.
 	(tdbio_update_version_record): New function to update version
 	record values during a trustdb check or update.
 	(tdbio_dump_record): Show trust model in dump.
 
 	* trustdb.c (validate_keys): Call tdbio_update_version_record on
 	success so that the correct options are stored in the trustdb.
 
 	* options.h: rearrange trust models so that CLASSIC is 0 and
 	OPENPGP is 1.
 
 	* options.h, g10.c (main), encode.c (write_pubkey_enc_from_list),
 	pkclist.c (algo_available), revoke.c (gen_revoke): Add --pgp8
 	mode.  This is basically identical to --pgp7 in all ways except
 	that signing subkeys, v4 data sigs (including expiration), and SK
 	comments are allowed.
 
 	* getkey.c (finish_lookup): Comment.
 
 	* main.h, keylist.c (reorder_keyblock), keyedit.c (keyedit_menu):
 	Reorder user ID display in the --edit-key menu to match that of
 	the --list-keys display.
 
 	* g10.c (add_notation_data): Fix initialization.
 
 2002-12-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_expire): Don't lose key flags when changing the
 	expiration date of a subkey.  This is not the most optimal
 	solution, but it is minimal change on the stable branch.
 
 	* main.h, keygen.c (do_copy_key_flags): New function to copy key
 	flags, if any, from one sig to another.
 	(do_add_key_expire): New function to add key expiration to a sig.
 	(keygen_copy_flags_add_expire): New version of
 	keygen_add_key_expire that also copies key flags.
 	(keygen_add_key_flags_and_expire): Use do_add_key_expire.
 
 	* import.c (fix_hkp_corruption): Comment.
 
 2002-11-25  Stefan Bellon  <sbellon@sbellon.de>
 
 	* plaintext.c (handle_plaintext) [__riscos__]: If nooutput is set,
 	no filetype is needed obviously.
 
 2002-11-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, misc.c (default_cipher_algo, default_compress_algo):
 	New.  Return the default algorithm by trying
 	--cipher-algo/--compress-algo, then the first item in the pref
 	list, then s2k-cipher-algo or ZIP.
 
 	* sign.c (sign_file, sign_symencrypt_file), encode.c
 	(encode_simple, encode_crypt): Call default_cipher_algo and
 	default_compress_algo to get algorithms.
 
 	* g10.c (main): Allow pref selection for compress algo with
 	--openpgp.
 
 	* mainproc.c (proc_encrypted): Use --s2k-digest-algo for
 	passphrase mangling rather than --digest-algo.
 
 	* sign.c (hash_for): If --digest-algo is not set, but
 	--personal-digest-preferences is, then use the first hash
 	algorithm in the personal list.  If the signing algorithm is DSA,
 	then use the first 160-bit hash algorithm in the personal list.
 	If --pgp2 is set and it's a v3 RSA key, use MD5.
 
 	* g10.c (main), keydb.c (keydb_add_resource,
 	keydb_locate_writable): Rename --default-keyring as
 	--primary-keyring.  Stefan wins the naming contest.
 
 2002-11-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (add_notation_data): Disallow notation names that do not
 	contain a '@', unless --expert is set.  This is to help prevent
 	people from polluting the (as yet unused) IETF namespace.
 
 	* main.h: Comments about default algorithms.
 
 	* photoid.c (image_type_to_string): Comments about 3-letter file
 	extensions.
 
 	* encode.c (encode_simple), passphrase.c (passphrase_to_dek),
 	sign.c (sign_symencrypt_file): Use --s2k-digest-algo for
 	passphrase mangling rather than --digest-algo.
 
 2002-11-21  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (keygen_set_std_prefs): Properly handle an empty
 	preference string.
 
 	* misc.c (string_to_compress_algo): "none" is a bad choice since
 	it conflicts with the "none" in setpref.
 
 2002-11-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Allow compression algorithm names as the argument
 	to --compress-algo.  The old algorithm names still work for
 	backwards compatibility.
 
 	* misc.c (string_to_compress_algo): Allow "none" as an alias for
 	"uncompressed".
 
 2002-11-13  Stefan Bellon  <sbellon@sbellon.de>
 
 	* getkey.c (get_pubkey_byfprint_fast): Fixed type incompatibility,
 	was unsigned char instead of byte.
 
 2002-11-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* encode.c (encode_simple): Make sure that files larger than about
 	4G use partial length encoding.  This is required because OpenPGP
 	allows only for 32 bit length fields.  From Werner on stable
 	branch.
 
 	* getkey.c (get_pubkey_direct): Renamed to...
 	(get_pubkey_fast): this and made extern.
 	(get_pubkey_byfprint_fast): New.  From Werner on stable branch.
 
 	* keydb.h, import.c (import_one): Use get_pubkey_fast instead of
 	get_pubkey.  We don't need a merged key and actually this might
 	lead to recursions.
 	(revocation_present): Likewise for search by fingerprint.  From
 	Werner on stable branch.
 
 	* g10.c (main): Try to create the trustdb even for non-colon-mode
 	list-key operations.  This is required because getkey needs to
 	know whether a a key is ultimately trusted.  From Werner on stable
 	branch.
 	
 	* exec.c [__CYGWIN32__]: Keep cygwin separate from Mingw32;
 	we don't need it here as it behaves more like a Posix system.
 	From Werner on stable branch.
 
 	* passphrase.c (agent_get_passphrase): Ditto.  From Werner on
 	stable branch.
 
 	* tdbio.c (MY_O_BINARY): Need binary mode with Cygwin.  From
 	Werner on stable branch.
 
        	* g10.c, gpgv.c (main) [__CYGWIN32__]: Don't get the homedir from
 	the registry.  From Werner on stable branch.
 	
 	* keyedit.c (show_key_with_all_names_colon): Make --with-colons
 	--edit display match the validity and trust of --with-colons
 	--list-keys.
 
 	* passphrase.c (agent_send_all_options): Fix compile warning.
 
 	* keylist.c (list_keyblock_colon): Validity for subkeys should
 	match that of the primary key, and not that of the last user ID.
 
 	* getkey.c (merge_selfsigs): Revoked/expired/invalid primary keys
 	carry these facts onto all their subkeys, but only after the
 	subkey has a chance to be marked valid.  This is to fix an
 	incorrect "invalid public key" error verifying a signature made by
 	a revoked signing subkey, with a valid unrevoked primary key.
 
 2002-11-09  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (agent_send_all_options): Use tty_get_ttyname to
 	get the default ttyname.
 
 2002-11-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyring.h, keyring.c (keyring_register_filename): Return the
 	pointer if a given keyring is registered twice.
 
 	* keydb.h, keydb.c (keydb_add_resource): Use flags to indicate a
 	default keyring.
 	(keydb_locate_writable): Prefer the default keyring if possible.
 
 	* g10.c (main): Add --default-keyring option.
 
 2002-11-06  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), trustdb.c (ask_ownertrust): Add
 	--force-ownertrust option for debugging purposes.  This allows
 	setting a whole keyring to a given trust during an
 	--update-trustdb.  Not for normal use - it's just easier than
 	hitting "4" all the time to test a large trustdb.
 
 	* pubkey-enc.c (get_session_key): With hidden recipients or try a
 	given passphrase against all secret keys rather than trying all
 	secret keys in turn.  Don't if --try-all-secrets or --status-fd is
 	enabled.
 
 	* passphrase.c (passphrase_to_dek): Mode 1 means do a regular
 	passphrase query, but don't prompt with the key info.
 
 	* seckey-cert.c (do_check, check_secret_key): A negative ask count
 	means to enable passphrase mode 1.
 
 	* keydb.h, getkey.c (enum_secret_keys): Add flag to include
 	secret-parts-missing keys (or not) in the list.
 
 2002-11-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_search_prompt): When --with-colons is
 	enabled, don't try and fit the search output to the screen size -
 	just dump the whole list.
 
 2002-11-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_search_prompt): When --with-colons is
 	enabled, just dump the raw keyserver protocol to stdout and don't
 	print the menu.
 
 	* keyserver.c (show_prompt): Don't show a prompt when command-fd
 	is being used.
 
 	* trustdb.c (trust_model_string, check_trustdb, update_trustdb,
 	validate_one_keyblock): It's not clear what a trustdb rebuild or
 	check means with a trust model other than "classic" or "openpgp",
 	so disallow this.
 
 2002-11-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main): Add --trust-model option.  Current
 	models are "openpgp" which is classic+trustsigs, "classic" which
 	is classic only, and "always" which is the same as the current
 	option --always-trust (which still works).  Default is "openpgp".
 
 	* trustdb.c (validate_one_keyblock): Use "openpgp" trust model to
 	enable trust sigs.
 
 	* gpgv.c (main), mainproc.c (check_sig_and_print), pkclist.c
 	(do_we_trust, do_we_trust_pre, check_signatures_trust): Use new
 	--trust-model option in place of --always-trust.
 
 	* keyedit.c (sign_mk_attrib, trustsig_prompt, sign_uids,
 	keyedit_menu): Prompt for and create a trust signature with
 	"tsign".  This is functional, but needs better UI text.
 
 	* build-packet.c (build_sig_subpkt): Able to build trust and
 	regexp subpackets.
 
 	* pkclist.c (do_edit_ownertrust): Comment.
 
 2002-11-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (set_one_pref, keygen_set_std_prefs): Allow using the
 	full algorithm name (CAST5, SHA1) rather than the short form (S3,
 	H2).
 
 	* main.h, keygen.c (keygen_get_std_prefs), keyedit.c
 	(keyedit_menu): Return and use a fake uid packet rather than a
 	string since we already have a nice parser/printer in
 	keyedit.c:show_prefs.
 
 	* main.h, misc.c (string_to_compress_algo): New.
 
 2002-11-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Add --no-throw-keyid.
 
 	* keydb.h, encode.c (write_pubkey_enc_from_list), g10.c (main),
 	pkclist.c (build_pk_list): Add --hidden-recipient (-R) and
 	--hidden-encrypt-to, which do a single-user variation on
 	--throw-keyid.  The "hide this key" flag is carried in bit 0 of
 	the pk_list flags field.
 
 	* keyserver.c (parse_keyrec): Fix shadowing warning.
 
 2002-10-31  Stefan Bellon  <sbellon@sbellon.de>
 
 	* compress.c (init_compress) [__riscos__]: Use
 	riscos_load_module() to load ZLib module.
 
 	* g10.c (main) [__riscos__]: Renames due to changes in riscos.c
 	(e.g. prefixes all RISC OS specific functions with riscos_*).
 	* photoid.c (show_photos) [__riscos__]: Likewise.
 	* signal.c (got_fatal_signal) [__riscos__]: Likewise.
 
 	* trustdb.c (check_regexp) [__riscos__]: Branch to RISC OS RegEx
 	handling.
 
 2002-10-31  David Shaw  <dshaw@jabberwocky.com>
 
 	* build-packet.c (do_plaintext), encode.c (encode_sesskey,
 	encode_simple, encode_crypt), sign.c (write_plaintext_packet): Use
 	wipememory() instead of memset() to wipe sensitive memory as the
 	memset() might be optimized away.
 
 2002-10-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (check_regexp): Modern regexps require REG_EXTENDED.
 
 2002-10-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, trustdb.h, trustdb.c (trust_string): New.  Return a
 	string like "fully trusted", "marginally trusted", etc.
 	(get_min_ownertrust): New.  Return minimum ownertrust.
 	(update_min_ownertrust): New.  Set minimum ownertrust.
 	(check_regexp): New.  Check a regular epression against a user ID.
 	(ask_ownertrust): Allow specifying a minimum value.
 	(get_ownertrust_info): Follow the minimum ownertrust when
 	returning a letter.
 	(clear_validity): Remove minimum ownertrust when a key becomes
 	invalid.
 	(release_key_items): Release regexp along with the rest of the
 	info.
 	(validate_one_keyblock, validate_keys): Build a trust sig chain
 	while validating.  Call check_regexp for regexps.  Use the minimum
 	ownertrust if the user does not specify a genuine ownertrust.
 
 	* pkclist.c (do_edit_ownertrust): Only allow user to select a
 	trust level greater than the minimum value.
 
 	* parse-packet.c (can_handle_critical): Can handle critical trust
 	and regexp subpackets.
 
 	* trustdb.h, trustdb.c (clear_ownertrusts), delkey.c
 	(do_delete_key), import.c (import_one): Rename clear_ownertrust to
 	clear_ownertrusts and have it clear the min_ownertrust value as
 	well.
 
 	* keylist.c (list_keyblock_print): Indent uid to match pub and
 	sig.
 
 	* keyedit.c (print_and_check_one_sig, show_key_and_fingerprint,
 	menu_addrevoker), keylist.c (list_keyblock_print,
 	print_fingerprint): Show "T" or the trust depth for trust
 	signatures, and add spaces to some strings to make room for it.
 
 	* packet.h, parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt,
 	parse_signature): Parse trust signature values.
 
 	* tdbio.h, tdbio.c (tdbio_read_record, tdbio_write_record):
 	Reserve a byte for the minimum ownertrust value (for use with
 	trust signatures).
 
 2002-10-29  Stefan Bellon  <sbellon@sbellon.de>
 
 	* build-packet.c (calc_plaintext, do_plaintext): Removed RISC OS
 	specific filetype parts (it's now done in make_basename()).
 
 	* plaintext.c (handle_plaintext): Tidied up RISC OS specific
 	filetype parts.
 
 	* encode.c (encode_simple, encode_crypt): Added argument to
 	make_basename() call.
 
 	* sign.c (write_plaintext_packet): Added argument to
 	make_basename() call.
 
 2002-10-28  Stefan Bellon  <sbellon@sbellon.de>
 
 	* build-packet.c (calc_plaintext, do_plaintext): Added filetype
 	handling for RISC OS' file types.
 
 	* plaintext.c (handle_plaintext) [__riscos__]: Added filetype
 	handling for RISC OS' file types.
 
 2002-10-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, import.c (sec_to_pub_keyblock, import_secret_one,
 	parse_import_options), g10.c (main): New import-option
 	"convert-sk-to-pk" to convert a secret key into a public key
 	during import.  It is on by default.
 
 2002-10-23  Werner Koch  <wk@gnupg.org>
 
 	* pubkey-enc.c (get_it): Fix segv, test for revoked only when PK
 	has been assigned.
 
 2002-10-18  Timo Schulz  <ts@winpt.org>
 
 	* keylist.c: (print_pubkey_info): New.
 	(print_seckey_info): New.
 	* main.h: Prototypes for the new functions.       
 	* delkey.c (do_delete_key): Use it here.
 	* revoke.c (gen_desig_revoke): Ditto.
 	
 2002-10-17  Werner Koch  <wk@gnupg.org>
 
 	* pkclist.c (do_edit_ownertrust): Show all user IDs.  This should
 	be enhanced to also show the current trust level.  Suggested by
 	Florian Weimer.
 
 2002-10-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Handle --strict and --no-strict from the command
 	line before the options file is loaded.
 
 2002-10-15  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Disable --textmode when encrypting (symmetric or
 	pk) in --pgp2 mode as PGP 2 can't handle the unknown length
 	literal packet.  Reported by Michael Richardson.
 
 2002-10-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver-internal.h, keyserver.c (print_keyrec, parse_keyrec,
 	show_prompt, keyserver_search_prompt, keyserver_spawn): Go to
 	version 1 of the keyserver protocol.  This is a better design,
 	similar to --with-colons, that allows for keys with multiple user
 	IDs rather than using multiple keys.  It also matches the machine
 	readable pksd format.  Also use a prettier --search-keys listing
 	format that can fill different size windows (currently set at 24
 	lines).
 
 2002-10-12  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (print_status_key_created): New.
 	(do_generate_keypair): Use it to print the fingerprint.
 	(generate_subkeypair): Likewise.
 
 2002-10-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_addrevoker): Properly back out if the signature
 	fails.  Also, do not allow appointing the same revoker twice, and
 	report ALREADY_SIGNED if the user tries it.
 
 2002-10-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_keys_internal): Missed one s/inp/inp2/.
 
 	* keylist.c (print_capabilities): Properly indicate per-key
 	capabilities of sign&encrypt primary keys that have
 	secret-parts-missing (i.e. no capabilities at all)
 
 	* mainproc.c (symkey_decrypt_sesskey): Fix compiler warning.
 
 2002-10-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (get_pubkey_direct): Don't cache keys retrieved via
 	this function as they may not have all their fields filled in.
 
 	* sig-check.c (signature_check2): Use new is_primary flag to check
 	rather than comparing main_keyid with keyid as this still works in
 	the case of a not fully filled in pk.
 
 2002-10-04  Werner Koch  <wk@gnupg.org>
 
 	* import.c (import_keys_internal): s/inp/inp2/ to avoid shadowing
 	warning.
 
 	* passphrase.c (agent_get_passphrase): Fixed signed/unsigned char
 	problem in %-escaping.  Noted by Ingo Kl�cker.
 
 2002-10-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main): Add --strict and --no-strict to switch
 	the log_warning severity level from info to error.
 
 	* keylist.c (print_capabilities): Secret-parts-missing keys should
 	show that fact in the capabilities, and only primary signing keys
 	can certify other keys.
 
 	* packet.h, parse_packet.c (parse_key): Add is_primary flag for
 	public keys (it already exists for secret keys).
 
 2002-10-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_secret_one): Check for an illegal (>110)
 	protection cipher when importing a secret key.
 
 	* keylist.c (list_keyblock_print): Show a '#' for a
 	secret-parts-missing key.
 
 	* parse_packet.c (parse_key): Some comments.
 
 	* revoke.c (gen_revoke): Remove some debugging code.
 
 	* trustdb.c (verify_own_keys): Make trusted-key a non-deprecated
 	option again.
 
 	* seckey-cert.c (do_check): Don't give the IDEA warning unless the
 	cipher in question is in fact IDEA.
 
 2002-10-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_one): Make sure that a newly imported key
 	starts with a clean ownertrust.
 
 2002-10-01  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (get_pubkey_direct): New.
 	(merge_selfsigs_main): Use it here to look for an ultimately
 	trusted key.  Using the full get_pubkey might lead to an
 	infinitive recursion.
 
 2002-09-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (parse_keyserver_uri): Force the keyserver URI
 	scheme to lowercase to be case-insensitive.
 
 2002-09-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* export.c (do_export_stream): Comment.
 
 	* sig-check.c (check_key_signature2): Properly handle a
 	non-designated revocation import.
 
 2002-09-26  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (set_homedir): New. Changed all direct assignments to use
 	this.
 	* gpgv.c (set_homedir): Ditto.
 
 2002-09-25  David Shaw  <dshaw@jabberwocky.com>
 
 	* Makefile.am: Link gpg with EGDLIBS (i.e. NETLIBS) as EGD uses
 	sockets.  Remove the old NETLIBS variable since the keyserver
 	stuff is no longer internal.
 
 2002-09-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_keys_stream): Fix compiler type warning.
 
 	* keyring.c (keyring_rebuild_cache), sig-check.c
 	(check_key_signature2), import.c (import, chk_self_sigs): Minor
 	language cleanups.
 
 2002-09-23  Stefan Bellon  <sbellon@sbellon.de>
 
 	* main.h: Introduced fast-import as import option. Removed
 	fast as separate option from prototypes.
 	* import.c (parse_import_options): Added fast-import option.
 	(import_*): Removed fast as separate option.
 	* g10.c (main): Added option fast-import, removed old fast
 	as separate argument.
 	* keyserver.c (keyserver_spawn): Removed old fast as separate
 	argument.
 
 2002-09-22  Stefan Bellon  <sbellon@sbellon.de>
 
 	* import.c (import_keys, import_keys_stream,
 	import_keys_internal): Added trustdb update/check to key import if
 	not fast-import and interactive set/no-auto-check-trustdb unset.
 	Avoided function clone by introducing import_keys_internal.
 
 2002-09-19  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Properly handle line truncation.
 	Don't leak memory (~10-20 bytes) on searches.
 	(keyserver_search_prompt): Cleanup.
 
 	* keylist.c (list_keyblock_colon): Show 1F direct key signatures
 	in --with-colons listing.
 
 2002-09-16  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_addrevoker): The direct key signature for
 	revocation keys must be at least v4 to carry the revocation key
 	subpacket.  Add a PGP 2.x warning for revocation keys.
 
 2002-09-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (check_permissions): Rearrange strings to make translating
 	easier (don't incorporate string parts).
 
 	* keyedit.c (sign_uids): Make strings translatable.
 
 	* sig-check.c (check_key_signature2): Make string translatable.
 
 2002-09-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (check_revocation_keys): Move....
 	* main.h, sig-check.c (check_revocation_keys): to here.  Also
 	return the signature_check error code rather than 0/1 and cache
 	the sig result.
 
 	* sig-check.c (check_key_signature2): Divert to
 	check_revocation_keys if a revocation sig is made by someone other
 	than the pk owner.
 
 	* getkey.c (merge_selfsigs_main): Tidy.
 
 2002-09-13  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main) [__MINGW32__]: Activate oLoadExtension.
 
 2002-09-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* Makefile.am, hkp.c, hkp.h, keyserver.c (keyserver_work): Remove
 	internal HKP support.
 
 	* keyserver.c (keyserver_spawn): Remove whitespace after keyserver
 	commands.
 
 2002-09-10  David Shaw  <dshaw@jabberwocky.com>
 
 	* exec.c (expand_args): Remove loop left over from earlier
 	implementation.
 	(exec_write): Missed one tick.
 
 2002-09-10  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: Removed option --emulate-checksum-bug.
 	* misc.c (checksum_u16_nobug): Removed.
 	(checksum_u16): Removed the bug emulation.
 	(checksum_mpi): Ditto.
 	(checksum_mpi_counted_nbits): Removed and replaced all calls
 	with checksum_mpi.
 
 	* parse-packet.c (read_protected_v3_mpi): New.
 	(parse_key): Use it here to store it as an opaque MPI.
 	* seckey-cert.c (do_check): Changed the v3 unprotection to the new
 	why to store these keys.
 	(protect_secret_key): Likewise.
 	* build-packet.c (do_secret_key): And changed the writing.
 
 	* tdbio.c (tdbio_set_dbname, open_db): Use new macro MY_O_BINARY
 	to avoid silly ifdefs.
 	(open_db): Fallback to RDONLY so that gpg may be used from a
 	RO-medium.
 
 	* encode.c (encode_simple): Make sure we don't use an ESK packet
 	when we don't have a salt in the S2K.
 
 	* misc.c (pct_expando) <case f>: Make sure that LEN is initialized.
 
 	* exec.c (exec_finish): Use ticks to denote filenames in messages.
 	(make_tempdir, exec_write): Changed format of messages.
 
 	* keyserver.c (print_keyinfo): Release USERID in on error.
 	(keyserver_work) [!DISABLE_KEYSERVER_HELPERS]: Exclude the unused
 	code.
 
 2002-09-09  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (make_attribute_uidname): Add new ar MAX_NAMELEN
 	for sanity checks.  Changed both callers. Limit the size of an %s.
 
 	* options.skel: Comment lock-once out, so that this file does not
 	change anything when copied to a new home directory.
 	* openfile.c (try_make_homedir): Don't exit after copying the
 	option skeleton.
 
 	* options.h: Don't use a comma when declaring variables over more
 	than one line.
 
 	* mainproc.c (symkey_decrypt_sesskey): Check length of the session
 	key.
 
 	* hkp.c (dehtmlize): Use ascii_tolower to protect against weird
 	locales.  Cast the argument for isspace for the sake of broken
 	HP/UXes.
 	(parse_hkp_index): s/ascii_memcasecmp/ascii_strncasecmp/.
 
 	* g10.c: Removed option --emulate-3des-s2k-bug.
 
 	* passphrase.c (hash_passphrase): Was used here.
 
 	* export.c (parse_export_options)
 	* keyserver.c (parse_keyserver_options)
 	* import.c (parse_import_options)
 	* g10.c (check_permissions): s/ascii_memcasecmp/ascii_strncasecmp/.
 
 2002-09-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (add_group): Use '=' to separate group name from group
 	members.  Use a better error message for when no = is found.
 
 	* hkp.c (hkp_export): Use CRLF in headers.
 
 2002-09-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* mainproc.c (print_pkenc_list): Don't increment the error counter
 	when printing the list of keys a message was encrypted to.  This
 	would make gpg give a non-zero exit code even for completely valid
 	messages if the message was encrypted to more than one key that
 	the user owned.
 
 2002-09-02  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Try to set a default character set.  Print the
 	used one in verbosity level 3.
 	* gpgv.c (main): Try to set a default character set.
 
 	* status.c, status.h (STATUS_IMPORT_OK): New.
 	* import.c (import_one,import_secret_one): Print new status.
 
 2002-08-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* pkclist.c (build_pk_list): Add new status code to indicate an
 	untrusted user.  This (or a disabled key) fail with "unavailable
 	pubkey" (G10ERR_UNU_PUBKEY).
 
 	* pkclist.c (build_pk_list): Fail if any recipient keys are
 	unusable.
 
 	* options.skel: The PGP LDAP keyserver is back.  Use MIT keyserver
 	as a sample rather than cryptnet as cryptnet does not support
 	searching yet.
 
 	* keyedit.c (show_key_with_all_names): Fix error message
 	(preferences are userid/selfsig and not key specific).
 
 2002-08-30  Werner Koch  <wk@gnupg.org>
 
 	* pkclist.c (do_we_trust_pre): Changed the wording of a warning.
 
 	* encode.c (encode_simple,encode_crypt): Use new style CTB for
 	compressssed packets when using MDC.  We need to do this so that
 	concatenated messages are properly decrypted.  Old style
 	compression assumes that it is the last packet; given that we
 	can't determine the length in advance, the uncompressor does not
 	know where to start.  Actually we should use the new CTB always
 	but this would break PGP 2 compatibility.
 
 	* parse-packet.c (parse): Special treatment for new style CTB
 	compressed packets.
 
 	* build-packet.c (do_mdc): Removed. Was not used.
 	(do_encrypted_mdc): Count in the version number and the MDC packet.
 
 2002-08-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* sig-check.c (do_check_messages, do_check): Show keyid in error
 	messages.
 
 	* keyserver.c (print_keyinfo): More readable key listings for
 	--search-keys responses.
 
 2002-08-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index, dehtmlize): Move HTML functionality into
 	new "dehtmlize" function.  Remove HTML before trying to parse each
 	line from the keyserver.  If the keyserver provides key type
 	information in the listing, use it.
 
 2002-08-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* sig-check.c (do_check, do_check_messages): Emit the usual sig
 	warnings even for cached sigs.  This also serves to protect
 	against missing a sig expiring while cached.
 
 	* getkey.c (merge_selfsigs_main): Don't check UID self-sigs twice.
 
 2002-08-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (clean_subkeys, chk_self_sigs): Merge clean_subkeys
 	into chk_self_sigs.  This improves efficiency as the same
 	signatures are not checked multiple times.  Clarify when a subkey
 	is revoked (any revocation signature, even if it is dated before
 	the binding signature).
 
 	* getkey.c (merge_selfsigs_subkey): Subkey revocation comments.
 
 	* keylist.c (list_one): Stats are only for public key listings.
 
 	* g10.c (main), options.skel: Default should be include-revoked
 	for keyserver operations.
 
 2002-08-21  Werner Koch  <wk@gnupg.org>
 
 	* import.c (import_print_stats): Print new non_imported counter
 	which is currently not used because we terminate on errors.
 
 2002-08-20  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel: Document no-include-attributes for
 	keyserver-options.
 
 	* keylist.c, keyedit.c, keyserver.c, sign.c: Some TODOs and
 	comments.
 
 	* export.c (do_export_stream): Fix noop bug in exporting sensitive
 	revocation keys.
 
 	* pkclist.c (do_edit_ownertrust): Comment out the option for
 	showing trust paths until it can be implemented.
 
 2002-08-19  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (get_user_id_native): Renamed to ..
 	(get_user_id_printable): this.  Filter out all dangerous
 	characters.  Checked all usages.
 	(get_user_id_string_native): Renamed to..
 	(get_user_id_string_printable): this.  Filter out all dangerous
 	characters.  Checked all usages.
 	* keyedit.c (show_basic_key_info): New.
 	* keylist.c (print_fingerprint): New mode 3.
 	* import.c (import_one): Use new function to display the user ID.
 
 2002-08-16  Timo Schulz  <ts@winpt.org>
 
 	* g10.c (main): Enable opt.interactive.
 
 	* import.c (import_one): Ask the user if the key shall be
 	imported when the interactive mode is used. Useful to extract
 	selected keys from a file.
 	
 2002-08-16  Werner Koch  <wk@gnupg.org>
 
 	* seckey-cert.c: Workaround to allow decryption of v3 keys created
 	with a bug in the mpi_get_secure_buffer.
 
 2002-08-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index): Properly handle really large keys
 	(5 digit key length) in HKP searches.
 
 2002-08-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* encode.c (encode_simple): Fix problem with using compression
 	algo 2 and symmetric compressed files.
 
 	* encode.c (encode_simple, encode_crypt): If we are not using a
 	MDC, compress even if a file is already compressed.  This is to
 	help against the chosen ciphertext attack.
 
 	* pkclist.c (select_algo_from_prefs): Fix requested algorithm bug
 	so the request succeeds even if the requested algorithm is not the
 	first found.
 
 	* cipher.c (write_header), encode.c (use_mdc, encode_simple,
 	encode_crypt, encrypt_filter), g10.c (main): Be more eager to use
 	a MDC.  We use a MDC if the keys directly support it, if the keys
 	list AES (any) or TWOFISH anywhere in the prefs, or if the cipher
 	chosen does not have a 64 bit blocksize.
 
 2002-08-08  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel: Some language tweaks, and remove the
 	load-extension section for random gatherers.
 
 	* keyring.c (create_tmp_file, rename_tmp_file): Create tmp files
 	with user-only permissions, but restore the original permissions
 	if the user has something special set.
 
 	* openfile.c (copy_options_file): Create new options file
 	(gpg.conf) with user-only permissions.
 
 	* keydb.c (keydb_add_resource): Create new keyrings with user-only
 	permissions.
 
 	* tdbio.c (tdbio_set_dbname): Create new trustdbs with user-only
 	permissions.
 
 2002-08-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* sig-check.c (signature_check2): Sanity check that the md has a
 	context for the hash that the sig is expecting.  This can happen
 	if a onepass sig header does not match the actual sig, and also if
 	the clearsign "Hash:" header is missing or does not match the
 	actual sig.
 
 	* keyedit.c (menu_revsig): Properly show a uid is revoked without
 	restarting gpg.  This is Debian bug 124219, though their supplied
 	patch will not do the right thing.
 
 	* main.h, tdbio.c (tdbio_set_dbname), misc.c (removed
 	check_permissions), keydb.c (keydb_add_resource), g10.c (main,
 	check_permissions): Significant reworking of the permission check
 	mechanism.  The new behavior is to check everything in the homedir
 	by checking the homedir itself.  If the user wants to put
 	(possibly shared) keyrings outside the homedir, they are not
 	checked.  The options file and any extension files are checked
 	wherever they are, as well as their enclosing directories.  This
 	is Debian bug 147760.
 	
 2002-08-06  Stefan Bellon  <sbellon@sbellon.de>
 
 	* g10.c (main): Use of EXTSEP_S in new gpg.conf string.
 	* openfile.c (copy_options_file): Ditto.
 
 2002-08-06  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), mainproc.c (proc_encrypted):
 	--ignore-mdc-error option to turn a MDC check error into a
 	warning.
 
 	* encode.c (encode_crypt), g10.c (main), sign.c (sign_file,
 	clearsign_file): Use the same --pgpX warning string everywhere to
 	ease translations.
 
 	* encode.c (write_pubkey_enc_from_list): Warn when using
 	--throw-keyid with --pgpX.  Noted by Vedaal Nistar.
 
 	* revoke.c (export_minimal_pk, gen_desig_revoke, gen_revoke):
 	Export a minimal pk along with the revocation cert when in --pgpX
 	mode so that PGP can import it.
 
 2002-08-06  Werner Koch  <wk@gnupg.org>
 
 	* options.skel: Changed comments.
 
 	* g10.c (main): Try to use "gpg.conf" as default option file.
 	* openfile.c (copy_options_file): Changed name of created file.
 
 2002-08-02  Werner Koch  <wk@gnupg.org>
 
 	* Makefile.am (LDFLAGS): Removed DYNLINK_LDFLAGS.
 
 2002-07-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), mainproc.c (proc_encrypted): Return a
 	decryption failed error if a MDC does not verify.  Warn if a MDC
 	is not present (can disable via --no-mdc-warning).
 
 	* exec.c (exec_write), g10.c (main), keyserver.c
 	(keyserver_spawn): Use new DISABLE_KEYSERVER_PATH rather than
 	FIXED_EXEC_PATH.
 
 2002-07-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* sig-check.c (do_check): Properly validate v4 sigs with no hashed
 	section at all.
 
 2002-07-25  Werner Koch  <wk@gnupg.org>
 
 	* delkey.c (do_delete_key): Always allow to delete a key in batch mode
 	when specified by fingerprint.  Suggested by Enzo Michelangeli.
 
 2002-07-25  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_revsig): Change "revsig" to honor selected uids
 	so the user can revoke sigs from particular uids only.
 
 	* keylist.c (list_keyblock_print): Don't display expired uids in
 	--list-keys unless -v and not --list-sigs (just like revoked
 	uids).
 
 	* exec.c, export.c, import.c, keyedit.c, keyserver.c, misc.c:
 	"Warning" -> "WARNING"
 
 2002-07-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, import.c (parse_import_options, fix_hkp_corruption,
 	import_one, delete_inv_parts), g10.c (main): New import-option
 	"repair-hkp-subkey-bug", which repairs as much as possible the HKP
 	mangling multiple subkeys bug.  It is on by default for keyserver
 	receives, and off by default for regular --import.
 
 	* main.h, import.c (import, import_one, delete_inv_parts), hkp.c
 	(hkp_ask_import), keyserver.c (keyserver_spawn): Use keyserver
 	import options when doing keyserver receives.
 
 	* options.h, exec.h, exec.c (set_exec_path, exec_write), g10.c
 	(main), keyserver.c (keyserver_spawn): If the user does not use
 	"exec-path", completely replace $PATH with GNUPG_LIBEXECDIR before
 	calling the keyserver helper.  If the user does use "exec-path",
 	append GNUPG_LIBEXECDIR after the specified path.
 
 2002-07-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (parse_import_options), export.c
 	(parse_export_options): Fix offset problem with reversed ("no-")
 	meanings.
 
 	* import.c (delete_inv_parts): Discard subkey signatures (0x18 and
 	0x28) if found in the userid section of the key.
 
 	* sig-check.c (signature_check2): Signatures made by invalid
 	subkeys (bad/missing binding sig) are also invalid.
 
 	* keylist.c (print_fingerprint): Show the primary as well as the
 	secondary key fingerprint in modes 1 & 2.
 
 2002-07-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, main.h, g10.c (main), import.c
 	(parse_import_options, delete_inv_parts), keyserver.c
 	(parse_keyserver_options): add new --import-options option.  The
 	only current flag is "allow-local-sigs".
 
 	* g10.c (main): Don't disable MDC in pgp7 mode.
 
 	* options.h, g10.c (main), keyserver.c (parse_keyserver_options):
 	Remove old keyserver-option include-attributes now that there is
 	an export-option for the same thing.
 
 	* options.h, main.h, export.c (parse_export_options,
 	do_export_stream), g10.c (main): add new --export-options option.
 	Current flags are "include-non-rfc", "include-local-sigs",
 	"include-attributes", and "include-sensitive-revkeys".
 
 	* options.h, hkp.c (hkp_export), keyserver.c
 	(parse_keyserver_options, keyserver_spawn): try passing unknown
 	keyserver options to export options, and if successful, use them
 	when doing a keyserver --send-key.
 
 	* build-packet.c (build_sig_subpkt): We do not generate
 	SIGSUBPKT_PRIV_VERIFY_CACHE anymore.
 
 	* revoke.c (gen_desig_revoke): Lots more comments about including
 	sensitive revkeys along with the revocation sig itself.
 
 	* keyserver.c (parse_keyserver_options): Simpler implementation
 	that can skip one pass over the options.
 
 2002-07-18  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (keyedit_menu, menu_addrevoker): Allow specifying
 	"sensitive" as an argument to an addrevoker command.  This sets
 	the 0x40 sensitive revoker flag.
 
 	* revoke.c (gen_desig_revoke): When generating a designated
 	revocation, include the direct key sig that contains the
 	designated revoker subpacket.  This allows sensitive designated
 	revocation subpackets to be exported.  Also indicate which
 	revokers are sensitive in the first place.
 
 2002-07-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (show_key_with_all_names_colon): The 0x40 class bit in
 	a designated revoker means "sensitive", not "local".  It's
 	exportable under the right circumstances.
 
 	* main.h, options.h, export.c (do_export_stream), g10.c (main),
 	hkp.c (hkp_export), keyserver.c (keyserver_spawn: Add a flag to
 	skip attribute packets and their signatures while exporting.  This
 	is to accomodate keyservers (pksd again) that choke on attributes.
 	Use keyserver-option "include-attributes" to control it.  This
 	defaults to ON (i.e. don't skip).
 
 2002-07-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, keyserver.c (parse_keyserver_uri, keyserver_spawn,
 	keyserver_work), hkp.c (hkp_ask_import, hkp_export, hkp_search):
 	Use a much more strict reading of RFC-2396 for the keyserver URIs.
 	Specifically, don't try and be smart about checking the value of
 	":port" so long as it is all digits, and properly handle opaque
 	data (those scheme specific parts that do not start with "//").
 
 2002-07-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* photoid.c (get_default_photo_command, show_photos): Honor
 	FIXED_PHOTO_VIEWER and DISABLE_PHOTO_VIEWER.
 
 	* mainproc.c (check_sig_and_print): Use --show-photos to show
 	photos when verifying a sig made by a key with a photo.
 
 	* keyserver.c (parse_keyserver_uri): Properly parse a URI with no
 	:port section and an empty file path, but with a terminating '/'.
 	(keyserver_work): Honor DISABLE_KEYSERVER_HELPERS.
 
 	* hkp.c (hkp_ask_import): Display keyserver URI as a URI, but only
 	if verbose.
 
 	* exec.c, g10.c: USE_EXEC_PATH -> FIXED_EXEC_PATH
 
 2002-07-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* exec.h, exec.c (set_exec_path, exec_write), g10.c (main): If
 	USE_EXEC_PATH is defined at compile time, use it to lock the
 	exec-path and not allow the user to change it.
 
 2002-07-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), keyserver.c (keyserver_refresh):
 	Maintain and use the original keyserver URI for cosmetics rather
 	than trying to recreate it when needed.
 
 	* mainproc.c (check_sig_and_print): Properly disregard expired
 	uids.  Make sure that the first uid listed is a real uid and not
 	an attribute (attributes should only be listed in the "aka"
 	section).  When there are no valid textual userids, try for an
 	invalid textual userid before using any attribute uid.
 
 2002-07-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel: Fix a few typos, clarify "group", and remove
 	sample photo viewers for Win32 since they are the defaults now.
 
 	* parse-packet.c (make_attribute_uidname), keylist.c
 	(dump_attribs): Fix two typecast warnings.
 
 	* packet.h, build-packet.c (build_attribute_subpkt), exec.c
 	(expand_args), mkdtemp.c (mkdtemp), photoid.c
 	(parse_image_header): Fix some signedness compiler warnings.
 
 2002-07-01  Werner Koch  <wk@gnupg.org>
 
 	* photoid.c (get_default_photo_command): Also use __MINGW32__
 	instead of HAVE_DOSISH_SYSTEM.
 
 	* encode.c (encode_symmetric): Do not use the new encryption code.
 
 2002-06-30  Werner Koch  <wk@gnupg.org>
 
 	* photoid.c: Use __MINGW32__ to include windows because
 	HAVE_DOSISH_SYSTEM is also set for OS/2 and plain DOS.  Provide
 	constant missing in older mingw installations. 
 
 2002-06-21  Stefan Bellon  <sbellon@sbellon.de>
 
 	* g10.c [__riscos__]: Moved RISC OS specific stuff to util/riscos.c
 	and include/util.h.
 
 	* gpgv.c [__riscos__]: Likewise.
 
 2002-06-20  David Shaw  <dshaw@jabberwocky.com>
 
 	* keydb.h, pkclist.c (select_algo_from_prefs): Allow passing a
 	suggested algorithm which will be used if available.
 
 	* encode.c (encode_crypt, encrypt_filter), sign.c (sign_file): Use
 	new select_algo_from_prefs feature to check if forcing an
 	algorithm would violate the recipient preferences.
 
 	* photoid.c (get_default_photo_command, show_photos): Use
 	different default viewers on different platforms.  Currently we
 	have Win 9x, Win NT (2k, xp), Mac OSX, RISC OS, and "everybody
 	else".  These are #ifdefs as much as possible to avoid clutter.
 
 	* g10.c (strusage, build_list), keyedit.c (show_prefs), main.h,
 	misc.c (compress_algo_to_string, check_compress_algo), pkclist.c
 	(algo_available), keygen.c (keygen_set_std_prefs): New
 	algo_to_string and check functions for compress algorithms.
 
 2002-06-20  Werner Koch  <wk@gnupg.org>
 
 	* misc.c (setsysinfo): Removed a #warning for Alpha's uniligedn
 	trap disabling - it is quite possible that this is a debug relict.
 
 2002-06-20  Stefan Bellon  <sbellon@sbellon.de>
 
 	* g10.c [__riscos__]: Added image file system feature.
 
 	* gpgv.c [__riscos__]: Added image file system feature.
 
 	* photoid.c (show_photos) [__riscos__]: Set RISC OS filetype of
 	photo id according to MIME type.
 
 2002-06-19  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index): Don't leak memory when failing out of a
 	bad HKP keyserver.
 
 	* g10.c (add_notation_data): Relax slightly the rules as to what
 	can go into a notation name - 2440 allows "@", for example.
 
 2002-06-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (clean_subkeys, import_one): Only allow at most 1
 	binding sig and at most 1 revocation sig on a subkey, as per
 	2440:11.1.
 
 	* hkp.c (parse_hkp_index, hkp_search): Error if the keyserver
 	returns an unparseable HKP response.
 
 2002-06-15  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (show_key_with_all_names), keylist.c
 	(list_keyblock_print): Show "[expired]" before expired uids.
 
 	* keyedit.c (show_key_with_all_names_colon), mainproc.c
 	(list_node), keylist.c (list_keyblock_colon): Show flag 'e' for
 	expired user ids.  Use "uat" for user attribute packets instead of
 	"uid".  Also use '<count> <length>' rather than the fake user id
 	string on attributes.
 
 	* keygen.c (keygen_add_revkey): Remove unused code.
 
 	* misc.c (check_permissions): Check directory permissions
 	properly - they are not special files.
 
 	* pkclist.c (expand_id, expand_group, build_pk_list): When
 	expanding groups before building a pk list, inherit flags from the
 	original pre-expanded string.
 
 	* pubkey-enc.c (is_algo_in_prefs): Don't use prefs from expired
 	uids.
 
 2002-06-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* free-packet.c (copy_signature): Properly copy a signature that
 	carries a revocation key on it.
 
 	* pkclist.c (expand_id, expand_group, build_pk_list): Groups now
 	work properly when used in the "Enter the user ID" prompt.
 
 2002-06-14  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (show_key_with_all_names): Display warning if a user
 	tries to show prefs on a v3 key with a v3 selfsig.
 
 	* kbnode.c (dump_kbnode): Show if a uid is expired.
 
 	* import.c (merge_blocks, import_revoke_cert): Show user ID
 	receiving a revocation certificate.
 
 	* free-packet.c (cmp_user_ids): Properly compare attribute ids.
 
 	* pkclist.c (expand_groups): Maintain the strlist flags while
 	expanding.  Members of an expansion inherit their flags from the
 	expansion key.
 
 	* options.h, cipher.c (write_header), g10.c (main), keygen.c
 	(keygen_set_std_prefs): remove the personal_mdc flag.  It no
 	longer serves a purpose now that the personal preference lists are
 	split into cipher/digest/zip.
 
 2002-06-14  Timo Schulz  <ts@winpt.org>
 
 	* skclist.c (is_insecure): Implemented.
 	
 2002-06-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Properly handle PROGRAM responses
 	when they have a CRLF ending.  Noted by Keith Ray.
 
 	* keyserver.c (keyserver_spawn): Handle CRLF endings from
 	keyserver helpers.  Also don't leak the last line worth of memory
 	from the keyserver response.
 
 	* main.h, misc.c (deprecated_warning): New function to warn about
 	deprecated options and commands.
 
 	* g10.c (main), keyserver-internal.h, keyserver.c
 	(parse_keyserver_uri): Use new deprecated function to warn about
 	honor-http-proxy, auto-key-retrieve, and x-broken-hkp.
 
 2002-06-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* Makefile.am: link gpg with NETLIBS for the built-in HKP access.
 
 2002-06-10  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, keyserver.c (keyserver_opts), g10.c (main): New
 	keyserver option "include-subkeys".  This feature already existed,
 	but now can be turned off.  It defaults to on.
 
 	* options.h, keyserver.c (parse_keyserver_options,
 	keyserver_spawn): There are now enough options to justify making a
 	structure for the keyserver options rather than a page of
 	if-then-else-if-then-etc.
 
 	* getkey.c (merge_keys_and_selfsig, merge_selfsigs_main): Fix bug
 	in calculating key expiration dates.
 
 2002-06-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* keydb.h, getkey.c (get_user_id_native), import.c (import_one):
 	Display user ID while importing a key.  Note this applies to both
 	--import and keyserver --recv-keys.
 
 	* exec.c (exec_finish): Log unnatural exit (core dump, killed
 	manually, etc) for fork/exec/pipe child processes.
 
 2002-06-08  Timo Schulz  <ts@winpt.org>
 
 	* encode.c (encode_symmetric): Disable the compat flag
 	when the expert mode is enabled.
 	
 2002-06-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel, options.h, main.h, keydb.h, pkclist.c
 	(build_pk_list, expand_groups), g10.c (main, add_group): Add new
 	"group" command to allow one name to expand into multiple keys.
 	For simplicity, and to avoid potential loops, we only expand once
 	- you can't make an alias that points to an alias.
 
 	* main.h, g10.c (main), keygen.c (build_personal_digest_list):
 	Simplify the default digest list - there is really no need for the
 	other hashes since they will never be used after SHA-1 in the
 	list.
 
 	* options.skel, options.h, g10.c (main), hkp.c (hkp_ask_import,
 	hkp_export, hkp_search), keyserver.c (parse_keyserver_options,
 	parse_keyserver_uri, keyserver_work, keyserver_refresh): Make the
 	"x-broken-hkp" keyserver scheme into keyserver-option
 	"broken-http-proxy".  Move honor_http_proxy into
 	keyserver_options.  Canonicalize the three variations of "hkp",
 	"x-hkp", and "x-broken-hkp" into "hkp".
 
 2002-06-07  Stefan Bellon  <sbellon@sbellon.de>
 
 	* g10.c [__riscos__]: Added --attribute-file to do the same as
 	--attribute-fd, but with a filename not a fd as argument.
 	Added magic symbol for RISC OS to use different memory management.
 
 	* gpgv.c [__riscos__]: Added magic symbol for RISC OS to use
 	different memory management.
 
 2002-06-06  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, g10.c (main), keygen.c (build_personal_digest_list): Put
 	in a default digest preference list consisting of SHA-1, followed
 	by every other installed digest except MD5.  Note this is the same
 	as having no digest preference at all except for SHA-1 being
 	favored.
 
 	* options.h, g10.c (main), keygen.c (keygen_set_std_prefs),
 	pkclist.c (select_algo_from_prefs): Split
 	--personal-preference-list into three:
 	--personal-{cipher|digest|compress}-preferences.  This allows a
 	user to set one without affecting another (i.e. setting only a
 	digest pref doesn't imply an empty cipher pref).
 
 	* exec.c (exec_read): This is a safer way of guessing the return
 	value of system().  Noted by Stefan Bellon.
 
 2002-06-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index): Be more robust with keyservers
 	returning very unparseable responses.
 
 	* exec.c (exec_read): Catch and display an error when the remote
 	process exits unnaturally (i.e. segfault) so the user knows what
 	happened.  Also fix exec_write stub which has a different number
 	of arguments now.
 
 2002-06-05  Timo Schulz  <ts@winpt.org>
 
 	* encode.c (encode_simple): Ignore the new mode for RFC1991.
 	* mainproc.c (symkey_decrypt_sesskey): Better check for weird
 	keysizes.
 	
 2002-06-05  Timo Schulz  <ts@winpt.org>
 
 	* encode.c (encode_sesskey): New.
 	(encode_simple): Use it here. But by default we use the compat
 	mode which supress to generate encrypted session keys.
 	
 2002-06-05  Timo Schulz  <ts@winpt.org>
 
 	* mainproc.c (symkey_decrypt_sesskey): New.
 	(proc_symkey_enc): Support for encrypted session keys.
 	
 2002-06-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (hash_for, sign_file): When encrypting and signing at the
 	same time, consult the various hash prefs to pick a hash algorithm
 	to use.  Pass in a 160-bit hint if any of the signing keys are
 	DSA.
 
 	* keydb.h, pkclist.c (select_algo_from_prefs, algo_available):
 	Pass a "hints" opaque pointer in to let the caller give hints as
 	to what algorithms would be acceptable.  The only current hint is
 	for PREFTYPE_HASH to require a 160-bit hash for DSA.  Change all
 	callers in encode.c (encode_crypt, encrypt_filter) and sign.c
 	(sign_file).  If we settle on MD5 as the best algorithm based
 	solely on recepient keys and SHA1 is also a possibility, use SHA1
 	unless the user intentionally chose MD5.  This is as per 2440:13.
 
 	* exec.c (make_tempdir): Fix duplicated filename problem.
 
 2002-06-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, parse-packet.c (enum_sig_subpkt): Report back from
 	enum_sig_subpkt when a subpacket is critical and change all
 	callers in keylist.c (show_policy_url, show_notation), mainproc.c
 	(print_notation_data), and pkclist.c (do_show_revocation_reason).
 
 	* keylist.c (show_policy_url, show_notation): Display if the
 	policy or notation is critical.
 	
 2002-06-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, g10.c (main), keylist.c (dump_attribs, set_attrib_fd,
 	list_keyblock_print, list_keyblock_colon), status.h, status.c
 	(get_status_string): New --attribute-fd feature to dump the
 	contents of attribute subpackets for frontends.  If --status-fd is
 	also used, then a new status tag ATTRIBUTE is provided for each
 	subpacket.
 
 	* packet.h, getkey.c (fixup_uidnode, merge_selfsigs_main,
 	merge_selfsigs_subkey), parse-packet.c (setup_user_id): Keep track
 	of the expiration time of a user ID, and while we're at it, use
 	the expired flag from the selfsig rather than reparsing the
 	SIG_EXPIRE subpacket.
 
 	* photoid.c (generate_photo_id): When adding a new photo ID,
 	showing the photo for confirmation is not safe when noninteractive
 	since the "user" may not be able to dismiss a viewer window.
 	Noted by Timo Schulz.
 	
 2002-06-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel: Sample photo viewers for Win32.
 
 	* misc.c (pct_expando): Use the seckey for %k/%K if the pubkey is
 	not available.
 
 	* photoid.h, photoid.c (show_photos): Include the seckey in case a
 	user tries to view a photo on a secret key, and change all callers
 	in keyedit.c (menu_showphoto), keylist.c (list_keyblock_print),
 	and photoid.c (generate_photo_id).
 
 2002-06-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* photoid.c (show_photos): Work properly when not called with a
 	public key.
 
 2002-05-31  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (mk_notation_and_policy): Free unneeded buffer.
 
 	* hkp.c (parse_hkp_index): Properly handle the '&' character
 	(i.e. "&amp;") in HKP responses.
 
 	* getkey.c (merge_selfsigs_main): Fix reversed expiration time
 	check with self-sigs.
 
 	* keyedit.c (sign_uids): When making a new self-sig on a v3 key,
 	make a v3 self-sig unless it is currently a v3 self-sig being
 	promoted to v4.
 
 2002-05-31  Timo Schulz  <ts@winpt.org>
 
 	* pkclist.c (do_show_revocation_reason): Don't use capital
 	letters for non-interactive output.
 	(show_revocation_reason): Now it is global.
 	* pubkey-enc.c (get_it): Show if the key has been revoked.
 	
 2002-05-30  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (write_signature_packets, sign_file, clearsign_file,
 	sign_symencrypt_file): Make a v4 signature if a policy URL or
 	notation is set, unless v3 sigs are forced via rfc1991 or
 	force-v3-sigs.  Also remove some doubled code and clarify an error
 	message (we don't sign in PGP2 mode - just detach-sign).
 
 	* parse-packet.c (parse_one_sig_subpkt): Add KS_FLAGS to the "any
 	size" section.
 
 2002-05-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (keygen_set_std_prefs, add_feature_mdc): Use "mdc" and
 	"no-mdc" in the prefs string to allow switching on and off the MDC
 	feature.  This is needed to properly export a key from GnuPG for
 	use on PGP which does not support MDC - without this, MDC-capable
 	implementations will still try and generate MDCs which will break
 	PGP.
 
 	* keygen.c (keygen_get_std_prefs): Show "[mdc]" in prefs string if
 	it is enabled.
 
 	* options.h, g10.c (main), cipher.c (write_header), keygen.c
 	(keygen_set_std_prefs): For consistency, allow the user to specify
 	mdc/no-mdc in the --personal-preference-list.  If disabled, it
 	acts just like --disable-mdc.
 
 2002-05-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, exec.c: Add some debugging info, using the 1024 debug
 	flag.
 
 	* exec.c (win_system): New system()-like function for win32 that
 	does not return until the child process terminates.  Of course,
 	this doesn't help if the process itself exits before it is
 	finished.
 
 2002-05-29  Werner Koch  <wk@gnupg.org>
 
 	* encode.c (encode_simple): Intialize PKT when --no-literal is used.
 
 	* keyedit.c (show_key_with_all_names_colon): Renamed the record
 	for revocation keys to "rvk".
 
 2002-05-27  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (show_key_with_all_names_colon): New.
 	(show_key_with_all_names): Divert to new function when required.
 	Sanitize printing of revoker name.
 
 2002-05-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* build-packet.c (build_sig_subpkt): Handle setting sig flags for
 	certain subpacket types (notation, policy url, exportable,
 	revocable).  keyedit.c (sign_mk_attrib): Flags no longer need to
 	be set here.
 
 	* packet.h, parse-packet.c (parse_one_sig_subpkt), build-packet.c
 	(build_sig_subpkt): Call parse_one_sig_subpkt to sanity check
 	buffer lengths before building a sig subpacket.
 
 2002-05-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (mk_notation_and_policy): Include secret key to enable %s
 	expandos, and pass notations through pct_expando as well.
 
 	* main.h, misc.c (pct_expando): Add %s and %S expandos for
 	signer's keyid.
 
 2002-05-25  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (strusage, build_list): Add compress algorithms to
 	--version list.  Show algorithm numbers when --verbose --version
 	is done.
 
 2002-05-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, main.h, keygen.c (keygen_set_set_prefs,
 	keygen_get_std_prefs, keygen_upd_std_prefs), keyedit.c
 	(keyedit_menu), g10.c (main), pkclist.c (select_algo_from_prefs):
 	Add --personal-preference-list which allows the user to factor in
 	their own preferred algorithms when the preference lists are
 	consulted.  Obviously, this does not let the user violate a
 	recepient's preferences (and the RFC) - this only influences the
 	ranking of the agreed-on (and available) algorithms from the
 	recepients.  Suggested by David Hollenberg.
 
 	* options.h, keygen.c (keygen_set_std_prefs), g10.c (main): Rename
 	--preference-list to --default-preference-list (as that is what it
 	really is), and make it a true default in that if the user selects
 	"default" they get this list and not the compiled-in list.
 
 2002-05-22  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Add missing LF in a info printout and made it
 	translatable.  Noted by Michael Tokarev.
 
 2002-05-21  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Removed the undef of USE_SHM_COPROCESSING which
 	was erroneously introduced on 2002-01-09.
 
 	* signal.c (got_fatal_signal): Don't write the Nul to stderr.
 	Reported by David Hollenberg.
 
 2002-05-18  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, g10.c (main), revoke.c (gen_desig_revoke): Generate a
 	designated revocation via --desig-revoke
 
 	* keyedit.c (keyedit_menu, menu_addrevoker): New "addrevoker"
 	command to add a designated revoker to a key.
 
 2002-05-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* gpgv.c: Add stub for get_ownertrust().
 
 	* g10.c (main): --allow-freeform-uid should be implied by
 	OpenPGP.  Add --no-allow-freeform-uid.
 
 	* keyedit.c (sign_uids): Issue a warning when signing a
 	non-selfsigned uid.
 
 	* getkey.c (merge_selfsigs_main): If a key has no selfsigs, and
 	allow-non-selfsigned-uid is not set, still try and make the key
 	valid by checking all uids for a signature from an ultimately
 	trusted key.
 
 2002-05-16  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, keygen.c (keygen_add_revkey): Add revocation key
 	subpackets to a signature (callable by
 	make_keysig_packet). (write_direct_sig): Write a 1F direct key
 	signature. (parse_revocation_key): Parse a string in
 	algo:fpr:sensitive format into a revocation
 	key. (get_parameter_revkey, do_generate_keypair): Call above
 	functions when prompted from a batch key generation file.
 
 	* build-packet.c (build_sig_subpkt): Allow multiple revocation key
 	subpackets in a single sig.
 
 	* keydb.h, getkey.c (get_seckey_byfprint): Same as
 	get_pubkey_byfprint, except for secret keys.  We only know the
 	fingerprint of a revocation key, so this is needed to retrieve the
 	secret key needed to issue a revokation.
 
 	* packet.h, parse-packet.c (parse_signature, parse_revkeys): Split
 	revkey parsing off into a new function that can be used to reparse
 	after manipulating the revkey list.
 
 	* sign.c (make_keysig_packet): Ability to make 1F direct key
 	signatures.
 
 2002-05-15  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.skel: keyserver.pgp.com is gone, so list pgp.surfnet.nl
 	as a sample LDAP server instead.
 
 	* getkey.c (merge_selfsigs_main): Properly handle multiple
 	revocation keys in a single packet.  Properly handle revocation
 	keys that are in out-of-order packets.  Remove duplicates in
 	revocation key list.
 
 2002-05-14  Timo Schulz   <ts@winpt.org>
 
 	* exec.c (make_tempdir) [MINGW32]: Added missing '\'.
 	
 2002-05-14  Stefan Bellon  <sbellon@sbellon.de>
 
 	* exec.c (make_tempdir): Make use of EXTSEP_S instead of hardcoded
 	dot as extension separator.
 
 2002-05-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* photoid.c (show_photos): Use the long keyid as the filename for
 	the photo.  Use the short keyid as the filename on 8.3 systems.
 
 	* exec.h, exec.c (make_tempdir, exec_write, exec_finish): Allow
 	caller to specify filename.  This should make things easier on
 	windows and macs where the file extension is required, but a whole
 	filename is even better.
 
 	* keyedit.c (show_key_with_all_names, show_prefs): Show proper
 	prefs for a v4 key uid with no selfsig at all.
 
 	* misc.c (check_permissions): Don't check permissions on
 	non-normal files (pipes, character devices, etc.)
 
 2002-05-11  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (proc_symkey_enc): Avoid segv in case the parser
 	encountered an invalid packet.
 
 	* keyserver.c (keyserver_export): Get confirmation before sending
 	all keys.
 
 2002-05-10  Stefan Bellon  <sbellon@sbellon.de>
 
 	* g10.c, hkp.c, keyedit.c, keyserver.c: Replaced all occurrances
 	of strcasecmp with ascii_strcasecmp and all occurrances of
 	strncasecmp with ascii_memcasecmp.
 
 2002-05-10  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, getkey.c (fixup_uidnode), keyedit.c (show_prefs): Show
 	assumed prefs for hash and compression as well as the cipher pref.
 	Show assumed prefs if there are no prefs at all on a v4
 	self-signed key.
 
 	* options.h, g10.c (main), sign.c (make_keysig_packet): New
 	--cert-digest-algo function to override the default key signing
 	hash algorithm.
 
 2002-05-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (merge_selfsigs_main): Make sure the revocation key
 	list starts clean as this function may be called more than once
 	(e.g. from functions in --edit).
 
 	* g10.c, encode.c (encode_crypt), sign.c (sign_file,
 	sign_symencrypt_file): Make --compress-algo work like the
 	documentation says.  It should be like --cipher-algo and
 	--digest-algo in that it can override the preferences calculation
 	and impose the setting the user wants.  No --compress-algo setting
 	allows the usual preferences calculation to take place.
 
 	* main.h, compress.c (compress_filter): use new
 	DEFAULT_COMPRESS_ALGO define, and add a sanity check for compress
 	algo value.
 
 2002-05-08  David Shaw  <dshaw@jabberwocky.com>
 
 	* pkclist.c (select_algo_from_prefs): There is an assumed
 	compression preference for uncompressed data.
 
 2002-05-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), getkey.c (finish_lookup), pkclist.c
 	(algo_available): --pgp7, identical to --pgp6 except that it
 	permits a few algorithms that PGP 7 added: AES128, AES192, AES256,
 	and TWOFISH.  Any more of these --pgpX flags, and it'll be time to
 	start looking at a generic --emulate-pgp X option.
 
 	* export.c (do_export_stream): Warn the user when exporting a
 	secret key if it or any of its secret subkeys are protected with
 	SHA1 while simple_sk_checksum is set.
 
 	* parse-packet.c (parse_key): Show when the SHA1 protection is
 	used in --list-packets.
 
 	* options.h, build-packet.c (do_comment), g10.c (main): Rename
 	--no-comment as --sk-comments/--no-sk-comments (--no-comment still
 	works) and make the default be --no-sk-comments.
 
 2002-05-07  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (get_parameter_algo): Never allow generation of the
 	deprecated RSA-E or RSA-S flavors of PGP RSA.
 	(ask_algo): Allow generation of RSA sign and encrypt in expert
 	mode.  Don't allow ElGamal S+E unless in expert mode.
 	* helptext.c: Added entry keygen.algo.rsa_se.
 
 2002-05-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (sign_uids): If --expert is set, allow re-signing a
 	uid to promote a v3 self-sig to a v4 one.  This essentially
 	deletes the old v3 self-sig and replaces it with a v4 one.
 
 	* packet.h, parse-packet.c (parse_key), getkey.c
 	(merge_keys_and_selfsig, merge_selfsigs_main): a v3 key with a v4
 	self-sig must never let the v4 self-sig express a key expiration
 	time that extends beyond the original v3 expiration time.
 
 2002-05-06  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (sign_uids): When making a self-signature via "sign"
 	don't ask about sig level or expiration, and include the usual
 	preferences and such for v4 self-sigs.  (menu_set_preferences):
 	Convert uids from UTF8 to native before printing.
 
 	* keyedit.c (sign_uids): Convert uids from UTF8 to native before
 	printing.  (menu_set_primary_uid): Show error if the user tries to
 	make a uid with a v3 self-sig primary.
 
 2002-05-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (import_one): When merging with a key we already have,
 	don't let a key conflict (same keyid but different key) stop the
 	import: just skip the bad key and continue.
 
 	* exec.c (make_tempdir): Under Win32, don't try environment
 	variables for temp directories - GetTempDir tries environment
 	variables internally, and it's better not to second-guess it in
 	case MS adds some sort of temp dir handling to Windows at some
 	point.
 
 2002-05-05  Timo Schulz  <ts@winpt.org>
 
 	* mainproc.c (proc_symkey_enc): Don't ask for a passphrase
         in the list only mode.
 	
 2002-05-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_refresh): --refresh-keys implies
 	--merge-only so as not to import keys with keyids that match the
 	ones being refreshed.  Noted by Florian Weimer.
 
 2002-05-04  Stefan Bellon  <sbellon@sbellon.de>
 
 	* free-packet.c (copy_public_key): Don't call m_alloc(0), therefore
 	added consistency check for revkey and numrefkeys.
 
 	* getkey.c (check_revocation_keys): Added consistency check for
 	revkey and numrefkeys.
 
 	* keyedit.c (show_key_with_all_names): Likewise.
 
 2002-05-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* photoid.c: Provide default image viewer for Win32.
 
 	* misc.c (pct_expando): %t means extension, not name ("jpg", not
 	"jpeg").
 
 	* keyserver.c (keyserver_spawn), photoid.c (show_photos), exec.h,
 	exec.c: Allow the caller to determine the temp file extension when
 	starting an exec_write and change all callers.
 
 	* keyedit.c (sign_uids): Nonrevocable key signatures cause an
 	automatic promotion to v4.
 
 	* exec.c: Provide stubs for exec_ functions when NO_EXEC is
 	defined.
 
 2002-05-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* photoid.h, photoid.c (parse_image_header, image_type_to_string):
 	Useful functions to return data about an image.
 
 	* packet.h, parse-packet.c (make_attribute_uidname,
 	parse_attribute_subpkts, parse_attribute), photoid.h, photoid.c
 	(show_photos): Handle multiple images in a single attribute
 	packet.
 
 	* main.h, misc.c (pct_expando), sign.c (mk_notation_and_policy),
 	photoid.c (show_photos): Simpler expando code that does not
 	require using compile-time string sizes.  Call
 	image_type_to_string to get image strings (i.e. "jpg",
 	"image/jpeg").  Change all callers.
 
 	* keyedit.c (menu_showphoto), keylist.c (list_keyblock_print):
 	Allow viewing multiple images within a single attribute packet.
 
 	* gpgv.c: Various stubs for link happiness.
 
 2002-05-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* build-packet.c (build_sig_subpkt), keyedit.c (sign_uids),
 	options.h, sign.c (mk_notation_and_policy), g10.c (main,
 	add_notation_data, add_policy_url (new), check_policy_url
 	(removed)): Allow multiple policy URLs on a given signature.
 	Split "--notation-data" into "--cert-notation" and
 	"--sig-notation" so the user can set different policies for key
 	and data signing.  For backwards compatibility, "--notation-data"
 	sets both, as before.
 
 2002-05-02  Werner Koch  <wk@gnupg.org>
 
 	* options.skel: Removed the comment on trusted-keys because this
 	option is now deprecated.
 
 2002-05-01  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_adduid): 2440bis04 says that multiple attribute
 	packets on a given key are legal.
 
 	* keyserver.c (keyserver_refresh): the fake v3 keyid hack applies
 	to "mailto" URLs as well since they are also served by pksd.
 
 2002-04-29  Werner Koch  <wk@gnupg.org>
 
 	Added a copyright year for files changed this year.
 
 2002-04-25  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: New options --display, --ttyname, --ttytype,
 	--lc-ctype, --lc-messages to be used with future versions of the
 	gpg-agent. 
 	* passphrase.c (agent_send_option,agent_send_all_options): New.
 	(agent_open): Send options to the agent.
 
 	* trustdb.c (update_ownertrust, clear_ownertrust): Do an explicit
 	do_sync because revalidation_mark does it only if when the
 	timestamp actually changes.
 
 2002-04-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, keygen.c (do_generate_keypair), keylist.c
 	(print_signature_stats, list_all, list_one, list_keyblock,
 	list_keyblock_print, list_keyblock_colon): After generating a new
 	key, show the key information (name, keyid, fingerprint, etc.)
 	Also do not print uncheckable signatures (missing key..) in
 	--check-sigs.  Print statistics (N missing keys, etc.) after
 	--check-sigs.
 
 	* keyedit.c (sign_uids): When signing a key with an expiration
 	date on it, the "Do you want your signature to expire at the same
 	time?" question should default to YES.
 
 2002-04-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* parse-packet.c (parse_plaintext), packet.h, plaintext.c
 	(handle_plaintext): Fix bug in handling literal packets with
 	zero-length data (no data was being confused with partial body
 	length).
 
 	* misc.c (pct_expando), options.skel: %t means extension ("jpg").
 	%T means MIME type ("image/jpeg").
 
 	* import.c (import_one): Only trigger trust update if the keyring
 	is actually changed.
 
 	* export.c (do_export_stream): Missing a m_free.
 
 2002-04-22  Stefan Bellon  <sbellon@sbellon.de>
 
 	* keyid.c (expirestr_from_sk, expirestr_from_sig): Added _() to
 	string constant.
 
 	* exec.c (make_tempdir) [__riscos__]: Better placement of
 	temporary file.
 
 2002-04-20  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (generate_subkeypair): 2440bis04 adds that creating
 	subkeys on v3 keys is a MUST NOT.
 
 	* getkey.c (finish_lookup): The --pgp6 "use the primary key"
 	behavior should only apply while data signing and not encryption.
 	Noted by Roger Sondermann.
 
 2002-04-19  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (keygen_set_std_prefs): Put back 3DES because the RFC
 	says it is good form to do so.
 
 2002-04-19  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_deluid): Only cause a trust update if we delete
 	a non-revoked user id.
 
 	* hkp.c (hkp_ask_import), keyserver.c (parse_keyserver_options,
 	keyserver_spawn), options.h: Remove fast-import keyserver option
 	(no longer meaningful).
 
 	* g10.c (main), keyedit.c (sign_uids), options.h: Change
 	--default-check-level to --default-cert-check-level as it makes
 	clear what it operates on.
 
 	* g10.c (main): --pgp6 also implies --no-ask-sig-expire.
 
 	* delkey.c (do_delete_key): Comment.
 
 	* keyedit.c (sign_uids, keyedit_menu, menu_deluid, menu_delsig,
 	menu_expire, menu_revsig, menu_revkey): Only force a trustdb check
 	if we did something that changes it.
 
 	* g10.c: add "--auto-check-trustdb" to override a
 	"--no-auto-check-trustdb"
 
 2002-04-19  Werner Koch  <wk@gnupg.org>
 
 	* tdbio.c (tdbio_write_nextcheck): Return a status whether the
 	stamp was actually changed.
 	* trustdb.c (revalidation_mark): Sync the changes.  Removed the
 	sync operation done by its callers.
 	(get_validity): Add logic for maintaining a pending_check flag.
 	(clear_ownertrust): New.
 	
 	* keyedit.c (sign_uids): Don't call revalidation_mark depending on
 	primary_pk.
 	(keyedit_menu): Call revalidation_mark after "trust".
 	(show_key_with_all_names): Print a warning on the wrong listed key
 	validity.
 
 	* delkey.c (do_delete_key): Clear the owenertrust information when
 	deleting a public key.
 	
 2002-04-18  Werner Koch  <wk@gnupg.org>
 
 	* seskey.c (encode_md_value): Print an error message if a wrong
 	digest algorithm is used with DSA.  Changed all callers to cope
 	with a NULL return.  Problem noted by Imad R. Faiad.
 
 2002-04-18  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (mark_usable_uid_certs): Properly handle nonrevocable
 	signatures that can expire.  In short, the only thing that can
 	override an unexpired nonrevocable signature is another unexpired
 	nonrevocable signature.
 
 	* getkey.c (finish_lookup): Always use primary signing key for
 	signatures when --pgp6 is on since pgp6 and 7 do not understand
 	signatures made by signing subkeys.
 
 2002-04-18  Werner Koch  <wk@gnupg.org>
 
 	* trustdb.c (validate_keys): Never schedule a nextcheck into the
 	past.
 	(validate_key_list): New arg curtime use it to set next_expire.
 	(validate_one_keyblock): Take the current time from the caller.
 	(clear_validity, reset_unconnected_keys): New.
 	(validate_keys): Reset all unconnected keys.
 
 	* getkey.c (premerge_public_with_secret): Fixed 0x12345678! syntax
 	for use with secret keys.
 	(lookup): Advance the searchmode after a search FIRST.
 
 	* seckey-cert.c (do_check): Always calculate the old checksum for
 	use after unprotection.
 
 	* g10.c, options.skel: New option --no-escape-from.  Made
 	--escape-from and --force-v3-sigs the default and removed them
 	from the options skeleton.
 
 2002-04-16  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (parse_key): Support a SHA1 checksum as per
 	draft-rfc2440-bis04.
 	* packet.h (PKT_secret_key): Add field sha1chk.
 	* seckey-cert.c (do_check): Check the SHA1 checksum
 	(protect_secret_key): And create it.
 	* build-packet.c (do_secret_key): Mark it as sha-1 protected.
 	* g10.c, options.h: New option --simple-sk-checksum.
 
 2002-04-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* parse-packet.c (parse_signature): Minor fix - signatures should
 	expire at their expiration time and not one second later.
 
 	* keygen.c (proc_parameter_file): Allow specifying preferences
 	string (i.e. "s5 s2 z1 z2", etc) in a batchmode key generation
 	file.
 
 	* keyedit.c (keyedit_menu): Print standard error message when
 	signing a revoked key (no new translation).
 
 	* getkey.c (merge_selfsigs): Get the default set of key prefs from
 	the real (not attribute) primary uid.
 
 2002-04-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* pkclist.c (build_pk_list): Fix bug that allowed a key to be
 	selected twice in batch mode if one instance was the default
 	recipient and the other was an encrypt-to.  Noted by Stefan
 	Bellon.
 
 	* parse-packet.c (dump_sig_subpkt): Show data in trust and regexp
 	sig subpackets.
 
 	* keyedit.c (keyedit_menu): Use new function real_uids_left to
 	prevent deleting the last real (i.e. non-attribute) uid.  Again,
 	according to the attribute draft. (menu_showphoto): Make another
 	string translatable.
 
 2002-04-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* build-packet.c (build_sig_subpkt): Delete subpackets from both
 	hashed and unhashed area on update.  (find_subpkt): No longer
 	needed.
 
 	* keyedit.c (sign_uids): With --pgp2 on, refuse to sign a v3 key
 	with a v4 signature.  As usual, --expert overrides.  Try to tweak
 	some strings to a closer match so they can all be translated in
 	one place.  Use different helptext keys to allow different help
 	text for different questions.
 
 	* keygen.c (keygen_upd_std_prefs): Remove preferences from both
 	hashed and unhashed areas if they are not going to be used.
 
 2002-04-10  David Shaw  <dshaw@jabberwocky.com>
 
 	* misc.c (pct_expando), options.skel: Use %t to indicate type of a
 	photo ID (in this version, it's always "jpeg").  Also tweak string
 	expansion loop to minimize reallocs.
 
 	* mainproc.c (do_check_sig): Variable type fix.
 
 	* keyedit.c (menu_set_primary_uid): Differentiate between true
 	user IDs and attribute user IDs when making one of them primary.
 	That is, if we are making a user ID primary, we alter user IDs.
 	If we are making an attribute packet primary, we alter attribute
 	packets.  This matches the language in the latest attribute packet
 	draft.
 
 	* keyedit.c (sign_uids): No need for the empty string hack.
 
 	* getkey.c (fixup_uidnode): Only accept preferences from the
 	hashed segment of the self-sig.
 
 2002-04-10  Werner Koch  <wk@gnupg.org>
 
 	* tdbio.c (migrate_from_v2): Fixed the offset to read the old
 	ownertrust value and only add entries to the table if we really
 	have a value.
 
 2002-04-08  David Shaw  <dshaw@jabberwocky.com>
 
 	* status.h, status.c (get_status_string): Add KEYEXPIRED, EXPSIG,
 	and EXPKEYSIG.  Add "deprecated-use-keyexpired-instead" to
 	SIGEXPIRED.
 
 	* sig-check.c (do_check): Start transition from SIGEXPIRED to
 	KEYEXPIRED, since the actual event is signature verification by an
 	expired key and not an expired signature. (do_signature_check,
 	packet.h): Rename as signature_check2, make public, and change all
 	callers.
 
 	* mainproc.c (check_sig_and_print, do_check_sig): Use status
 	EXPSIG for an expired, but good, signature.  Add the expiration
 	time (or 0) to the VALIDSIG status line.  Use status KEYEXPSIG for
 	a good signature from an expired key.
 
 	* g10.c (main): remove checks for no arguments now that argparse
 	does it.
 
 2002-04-06  Werner Koch  <wk@gnupg.org>
 
 	* keyring.c (keyring_get_keyblock): Disable the keylist mode here.
 
 	* encode.c (encode_simple, encode_crypt): Only test on compressed
 	files if a compress level was not explicity set.
 
 	* keygen.c (keygen_set_std_prefs): Removed Blowfish and Twofish
 	from the list of default preferences, swapped the preferences of
 	RMD160 and SHA1.  Don't include a preference to 3DES unless the
 	IDEA kludge gets used.
 
 	* free-packet.c (free_packet): call free_encrypted also for
 	PKT_ENCRYPTED_MDC.
 
 	* compress.c (release_context): New.
 	(handle_compressed): Allocate the context and setup a closure to
 	release the context.  This is required because there is no
 	guarabntee that the filter gets popped from the chain at the end
 	of the function.  Problem noted by Timo and probably also the
 	cause for a couple of other reports.
 	(compress_filter): Use the release function if set.
 
 	* tdbio.c [__CYGWIN32__]: Don't rename ftruncate.  Noted by
 	Disastry.
 
 	* parse-packet.c (parse_signature): Put parens around a bit test.
 
 	* exec.c (make_tempdir): Double backslash for TMP directory
 	creation under Windows.  Better strlen the DIRSEP_S constants for
 	allocation measurements.
 
 	* decrypt.c (decrypt_messages): Release the passphrase aquired
 	by get_last_passphrase.
 
 2002-04-02  Werner Koch  <wk@gnupg.org>
 
 	* Makefile.am (EXTRA_DIST): Removed OPTIONS an pubring.asc - they
 	are no longer of any use. 
 
 2002-04-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (parse_keyserver_options): fix auto-key-retrieve to
 	actually work as a keyserver-option (noted by Roger Sondermann).
 
 	* keylist.c (reorder_keyblock): do not reorder the primary
 	attribute packet - the first user ID must be a genuine one.
 
 2002-03-31  David Shaw  <dshaw@jabberwocky.com>
 
 	* keylist.c (list_keyblock_colon): Fix ownertrust display with
 	--with-colons.
 
 	* keygen.c (generate_user_id), photoid.c (generate_photo_id):
 	Properly initialize the user ID refcount.  A few more "y/n" ->
 	"y/N" in photoid.c.
 
 	* keyedit.c (ask_revoke_sig): Warn the user if they are about to
 	revoke an expired sig (not a problem, but they should know).  Also
 	tweak a few prompts to change "y/n" to "y/N", which is how most
 	other prompts are written.
 
 	* keyserver.c (keyserver_search_prompt): Control-d escapes the
 	keyserver search prompt.
 
 	* pkclist.c (show_revocation_reason & callers): If a subkey is
 	considered revoked solely because the parent key is revoked, print
 	the revocation reason from the parent key.
 
 	* trustdb.c (get_validity): Allow revocation/expiration to apply
 	to a uid/key with no entry in the trustdb.
 
 2002-03-29  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (printunquoted): unquote backslashes from keyserver
 	searches
 
 	* hkp.c (write_quoted): quote backslashes from keyserver searches
 
 2002-03-26  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (ask_keysize): Removed the warning for key sizes > 1536.
 
 2002-03-25  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (sign_uids): Use 2 strings and not a %s so that
 	translations can be done the right way.
 	* helptext.c: Fixed small typo.
 
 2002-03-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (append_uid, merge_sigs): it is okay to import
 	completely non-signed uids now (with --allow-non-selfsigned-uid).
 
 	* getkey.c (get_primary_uid, merge_selfsigs_main): do not choose
 	an attribute packet (i.e. photo) as primary uid.  This prevents
 	oddities like "Good signature from [image of size 2671]".  This is
 	still not perfect (one can still select an attribute packet as
 	primary in --edit), but is closer to the way the draft is going.
 
 	* g10.c (build_list): algorithms should include 110.
 
 	* g10.c (main): --pgp2 implies --no-ask-sig-expire and
 	--no-ask-cert-expire as those would cause a v4 sig/cert.
 
 	* armor.c (is_armor_header): be more lenient in what constitutes a
 	valid armor header (i.e. -----BEGIN blah blah-----) as some
 	Windows programs seem to add spaces at the end.  --openpgp makes
 	it strict again.
 
 2002-03-18  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_search_prompt): Properly handle a "no
 	keys found" case from the internal HKP code (external HKP is ok).
 	Also, make a COUNT -1 (i.e. streamed) keyserver response a little
 	more efficient.
 
 	* g10.c (main): Add --no-allow-non-selfsigned-uid
 
 2002-03-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): --openpgp implies --allow-non-selfsigned-uid.
 
 	* getkey.c (merge_selfsigs_main): If none of the uids are primary
 	(because none are valid) then pick the first to be primary (but
 	still invalid).  This is for cosmetics in case some display needs
 	to print a user ID from a non-selfsigned key.  Also use
 	--allow-non-selfsigned-uid to make such a key valid and not
 	--always-trust.  The key is *not* automatically trusted via
 	--allow-non-selfsigned-uid.
 
 	* mainproc.c (check_sig_and_print): Make sure non-selfsigned uids
 	print [uncertain] on verification even though one is primary now.
 
 	* getkey.c (merge_selfsigs): If the main key is not valid, then
 	neither are the subkeys.
 
 	* import.c (import_one): Allow --allow-non-selfsigned-uid to work
 	on completely unsigned keys.  Print the uids in UTF8.  Remove
 	mark_non_selfsigned_uids_valid().
 
 	* keyedit.c (show_key_with_all_names): Show revocation key as
 	UTF8.
 
 	* sign.c (clearsign_file): Allow --not-dash-escaped to work with
 	v3 keys.
 
 2002-03-14  Werner Koch  <wk@gnupg.org>
 
 	* main.h: Changed the default algorithms to CAST5 and SHA1.
 
 2002-03-13  David Shaw  <dshaw@jabberwocky.com>
 
 	* import.c (chk_self_sigs): Show which user ID a bad self-sig
 	(invald sig or unsupported public key algorithm) resides on.
 
 	* import.c (chk_self_sigs): any valid self-sig should mark a user
 	ID or subkey as valid - otherwise, an attacker could DoS the user
 	by inventing a bogus invalid self-signature.
 
 2002-03-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): make a few more strings translatable.
 
 	* options.h, options.skel, g10.c (main), gpgv.c, mainproc.c
 	(check_sig_and_print), keyserver.c (parse_keyserver_options):
 	--auto-key-retrieve should really be a keyserver-option variable.
 
 	* import.c (revocation_present): new function to print a warning
 	if a key is imported that has been revoked by designated revoker,
 	but the designated revoker is not present to verify the
 	revocation.  If keyserver-options auto-key-retrieve is set, try
 	and fetch the designated revoker from the keyserver.
 
 	* import.c (import_one): call revocation_present after importing a
 	new key.  Note that this applies to --import, --recv-keys, and
 	--search-keys.
 	
 	* keyserver-internal.h, keyserver.c (keyserver_import_fprint):
 	import via fingerprint (for revocation keys).
 
 	* keyserver.c (keyserver_import_keyid): much simpler
 	implementation now that we're using KEYDB_SEARCH_DESC internally.
 
 2002-03-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* revoke.c (gen_revoke): do not prompt for revocation reason for
 	v3 revocations (unless force-v4-certs is on) since they wouldn't
 	be used anyway.
 
 	* keyedit.c (menu_revsig): show the status of the sigs
 	(exportable? revocable?) to the user before prompting for which
 	sig to revoke.  Also, make sure that local signatures get local
 	revocations.
 
 	* keyedit.c (ask_revoke_sig): remind the user which sigs are
 	local.
 
 	* g10.c (main): Add "exec-path" variable to override PATH for
 	execing programs.
 
 	* export.c (do_export_stream): properly check return code from
 	classify_user_id to catch unclassifiable keys.
 
 2002-03-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* parse-packet.c (parse_signature): variable type tweak for RISC
 	OS (from Stefan)
 
 2002-02-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* getkey.c (check_revocation_keys): New function to check a
 	revocation against a list of potential revocation keys.  Note the
 	loop-breaking code here.  This is to prevent blowing up if A is
 	B's revocation key, while B is also A's.  Note also that this is
 	written so that a revoked revoker can still issue revocations:
 	i.e. If A revokes B, but A is revoked, B is still revoked.  I'm
 	not completely convinced this is the proper behavior, but it
 	matches how PGP does it.  It does at least have the advantage of
 	much simpler code - my first version of this had lots of loop
 	maintaining code so you could chain revokers many levels deep and
 	if D was revoked, C was not, which meant that B was, and so on.
 	It was sort of scary, actually.
 
 	* getkey.c (merge_selfsigs_main): Add any revocation keys onto the
 	pk.  This is particularly interesting since we normally only get
 	data from the most recent 1F signature, but you need multiple 1F
 	sigs to properly handle revocation keys (PGP does it this way, and
 	a revocation key could be marked "sensitive" and hence in a
 	different signature).  Also, if a pk has a revocation key set,
 	check for revocation sigs that were not made by us - if made by a
 	valid revocation key, mark the pk revoked.
 
 	* packet.h, getkey.c (cache_public_key): do not cache key if
 	"dont_cache" is set.  This allows the revocation key code to look
 	up a key and return information that may be inaccurate to prevent
 	loops without caching the fake data.
 
 	* packet.h, sig-check.c (do_signature_check): Record if a
 	signature was made by a revoked pk.
 
 	* packet.h, parse-packet.c (parse_one_sig_subpkt,
 	can_handle_critical, parse_signature): Get revocation key
 	information out of direct sigs.
 	
 	* keylist.c (list_keyblock_print): don't assume that the presence
 	of a 0x20 signature means the key is revoked.  With revocation
 	keys, this may not be true if the revocation key is not around to
 	verify it or if verification failed.  Also, 0x1F should get listed
 	as "sig", and not "unexpected signature class".
 
 	* keyedit.c (show_key_with_all_names): Add a flag for printing
 	revoker information and change all callers.
 
 	* import.c (merge_blocks): merge in any new direct key (0x1F)
 	sigs.
 
 	* import.c (import_revoke_cert): don't keep processing after a
 	revocation is rejected.
 	
 	* import.c (delete_inv_parts): Allow importing a revocation
 	signature even if it was not issued by the key.  This allows a
 	revocation key to issue it.  Of course, the sig still needs to be
 	checked before we trust it.
 
 	* free-packet.c (copy_public_key): Include a new copy of the
 	revocation keys when duping a pk.
 
 	* free-packet.c (free_seckey_enc, release_public_key_parts): Free
 	any revocation keys that are attached to a sig or pk.
 
 	* export.c (do_export_stream): Do not export signatures with
 	"sensitive" revocation keys in them.
 
 2002-02-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* export.c (do_export_stream): Do not include v3 keys in a
 	--export-secret-subkeys export.
 
 	* getkey.c (merge_selfsigs_main): If a key isn't valid (say,
 	because of no self-signature), allow --always-trust to force it
 	valid so it can be trusted.
 
 2002-02-25  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (hkp_ask_import), hkp.h, keyserver.c (all): treat key
 	lists internally as fingerprints when possible.  All this is via
 	KEYDB_SEARCH_DESC - no point in reinventing the wheel. This allows
 	the helper program to search the keyserver by fingerprint if
 	desired (and the keyserver supports it).  Note that automatic
 	fingerprint promotion during refresh only applies to v4 keys as a
 	v4 fingerprint can be easily changed into a long or short key id,
 	and a v3 cannot.
 
 	* pubkey-enc.c, getkey.c, misc.c, main.h: Take two copies of
 	hextobyte() from pubkey-enc.c and getkey.c and make them into one
 	copy in misc.c.
 
 2002-02-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_search_prompt): Detect a "no keys found"
 	case even if the helper program does not explicitly say how many
 	keys were found.
 
 	* hkp.c (parse_hkp_index): Bug fix - don't report non-revoked keys
 	as revoked in HKP key searches.
 
 2002-02-19  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (parse_trust): Made parsing more robust.
 
 2002-02-19  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index): Catch corruption in HKP index lines
 	(can be caused by broken or malicious keyservers).
 
 	* keyserver.c (keyserver_work): Add KEYSERVER_NOT_SUPPORTED for
 	unsupported actions (say, a keyserver that has no way to search,
 	or a readonly keyserver that has no way to add).  Also add a
 	USE_EXTERNAL_HKP define to disable the internal HKP keyserver
 	code.
 
 2002-02-14  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New option --no-use-agent. 
 
 	* pkclist.c (check_signatures_trust): Always print the warning for
 	unknown and undefined trust.  Removed the did_add cruft.  Reported
 	by Janusz A. Urbanowicz.
 
 2002-02-11  David Shaw  <dshaw@jabberwocky.com>
 
 	* hkp.c (parse_hkp_index): Bug fix - properly handle user IDs with
 	colons (":") in them while HKP searching.
 
 2002-02-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* misc.c (pct_expando): More comments.
 
 	* keydb.h, sign.c (mk_notation_and_policy): Clarify what is a sig
 	and what is a cert.  A sig has sigclass 0x00, 0x01, 0x02, or 0x40,
 	and everything else is a cert.
 
 	* g10.c (main), keyedit.c (keyedit_menu): Add a "nrlsign" for
 	nonrevocable and local key signatures.
 
 	* g10.c (main): Add a --no-force-mdc to undo --force-mdc.
 
 	* options.h, g10.c (main), cipher.c (write_header): Add a knob to
 	--disable-mdc/--no-disable-mdc.  Off by default, of course, but is
 	used in --pgp2 and --pgp6 modes.
 	
 	* pkclist.c (build_pk_list): Allow specifying multiple users in
 	the "Enter the user ID" loop.  Enter a blank line to stop.  Show
 	each key+id as it is added.
 
 	* keylist.c (show_policy_url), mainproc.c (print_notation_data):
 	It is not illegal (though possibly silly) to have multiple policy
 	URLs in a given signature, so print all that are present.
 	
 	* hkp.c (hkp_search): More efficient implementation of URL-ifying
 	code.
 
 2002-02-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* main.h, misc.c (pct_expando): New function to generalize
 	%-expando processing in any arbitrary string.
 
 	* photoid.c (show_photo): Call the new pct_expando function rather
 	than expand strings internally.
 	
 	* sign.c (mk_notation_and_policy): Show policy URLs and notations
 	when making a signature if show-policy/show-notation is on.
 	%-expand policy URLs during generation.  This lets the user have
 	policy URLs of the form "http://notary.jabberwocky.com/keysign/%K"
 	which will generate a per-signature policy URL.
 
 	* main.h, keylist.c (show_policy_url, show_notation): Add amount
 	to indent so the same function can be used in key listings as well
 	as during sig generation.  Change all callers.
 
 2002-02-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c, options.h (parse_keyserver_options, keyidlist):
 	Workaround for the pksd and OKS keyserver bug that calculates v4
 	RSA keyids as if they were v3.  The workaround/hack is to fetch
 	both the v4 (e.g. 99242560) and v3 (e.g. 68FDDBC7) keyids.  This
 	only happens for key refresh while using the HKP scheme and the
 	refresh-add-fake-v3-keyids keyserver option must be set.  This
 	should stay off by default.
 
 2002-02-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Bug fix - do not append keys to
 	each other when --sending more than one.
 
 2002-02-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c (main), keyedit.c (sign_uids), sign.c
 	(mk_notation_and_policy): Split "--set-policy-url" into
 	"--cert-policy-url" and "--sig-policy-url" so the user can set
 	different policies for key and data signing.  For backwards
 	compatibility, "--set-policy-url" sets both, as before.
 
 2002-01-30  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): --gen-random --armor does now output a base64
 	encoded string.
 
 2002-01-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main), options.h, pkclist.c (algo_available): --pgp6
 	flag.  This is not nearly as involved as --pgp2.  In short, it
 	turns off force_mdc, turns on no_comment, escape_from, and
 	force_v3_sigs, and sets compression to 1.  It also restricts the
 	user to IDEA (if present), 3DES, CAST5, MD5, SHA1, and RIPEMD160.
 	See the comments above algo_available() for lots of discussion on
 	why you would want to do this.
 
 2002-01-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (keygen_set_std_prefs): Comment
 
 	* keyedit.c (sign_uids): Bug fix - when signing with multiple
 	secret keys at the same time, make sure each key gets the sigclass
 	prompt.
 
 	* exec.c (exec_finish): Close the iobuf and FILE before trying to
 	waitpid, so the remote process will get a SIGPIPE and exit.  This
 	is only a factor when using a pipe to communicate.
 
 	* exec.c (exec_write): Disable cache-on-close of the fd iobuf (is
 	this right?  Why is a fd iobuf cached at all?)
 
 2002-01-26  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: New option --gpg-agent-info
 	* passphrase.c (agent_open): Let it override the environment info.
 	* seckey-cert.c (check_secret_key): Always try 3 times when the
 	agent is enabled.
 	* options.skel: Describe --use-agent.
 
 2002-01-24  David Shaw  <dshaw@jabberwocky.com>
 
 	* pubkey-enc.c (is_algo_in_prefs, get_it): Only check preferences
 	against keys with v4 self sigs - there is really little point in
 	warning for every single non-IDEA message encrypted to an old key.
 
 	* pkclist.c (select_algo_from_prefs): Only put in the fake IDEA
 	preference if --pgp2 is on.
 
 	* mainproc.c (check_sig_and_print): Print "Expired" for expired
 	but good signatures (this still prints "BAD" for expired but bad
 	signatures).
 
 2002-01-23  David Shaw  <dshaw@jabberwocky.com>
 
 	* keygen.c (ask_keysize): Cosmetic: don't present a RSA signing
 	key as a "keypair" which can be 768 bits long (as RSA minimum is
 	1024).
 
 	* pubkey-enc.c (is_algo_in_prefs): Allow IDEA as a fake preference
 	for v3 keys with v3 selfsigs.
 
 2002-01-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* packet.h, getkey.c (merge_selfsigs_main), pkclist.c
 	(select_algo_from_prefs): Implement the fake IDEA preference as
 	per RFC2440:12.1.  This doesn't mean that IDEA will be used (the
 	plugin may not be present), but it does mean that a v3 key with a
 	v3 selfsig has an implicit IDEA preference instead of 3DES.  v3
 	keys with v4 selfsigs use preferences as normal.
 
 	* encode.c (encode_crypt): if select_algo_from_prefs fails, this
 	means that we could not find a cipher that both keys like.  Since
 	all v4 keys have an implicit 3DES preference, this means there is
 	a v3 key with a v3 selfsig in the list.  Use 3DES in this case as
 	it is the safest option (we know the v4 key can handle it, and
 	we'll just hope the v3 key is being used in an implementation that
 	can handle it).  If --pgp2 is on, warn the user what we're doing
 	since it'll probably break PGP2 compatibility.
 
 	* g10.c (main): Do not force using IDEA for encrypted files in
 	--pgp2 mode - let the fake IDEA preference choose this for us for
 	better compatibility when encrypting to multiple keys, only some
 	of which are v3.
 
 	* keygen.c (keygen_set_std_prefs): Put 3DES on the end of the
 	default cipher pref list (RFC2440: "...it is good form to place it
 	there explicitly.").  If the user has the IDEA plugin installed,
 	put a preference for IDEA *after* 3DES to effectively disable its
 	use for everything except encrypting along with v3 keys.
 
 	* encode.c, g10.c, sign.c: Change the PGP2 warning line from
 	"... will not be usable ..." to "... may not be usable ..." as the
 	user could be using one of the enhanced PGP2 variations.
 
 	* helptext.c: Revise the sign_uid.class help text as suggested by
 	Stefan.
 	
 2002-01-20  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (passphrase_to_dek): Add tryagain_text arg to be
 	used with the agent.  Changed all callers.
 	(agent_get_passphrase): Likewise and send it to the agent
 	* seckey-cert.c (do_check): New arg tryagain_text.
 	(check_secret_key): Pass the string to do_check.
 	* keygen.c (ask_passphrase): Set the error text is required.
 	* keyedit.c (change_passphrase): Ditto.
 
 	* passphrase.c (agent_open): Disable opt.use_agent in case of a
 	problem with the agent. 
 	(agent_get_passphrase): Ditto.
 	(passphrase_clear_cache): Ditto.
 
 2002-01-19  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (agent_open): Add support for the new Assuan based
 	gpg-agent.  New arg to return the used protocol version.
 	(agent_get_passphrase): Implemented new protocol here.
 	(passphrase_clear_cache): Ditto.
 	(readline): New.
 	
 2002-01-15  Timo Schulz  <ts@winpt.org>
 
 	* encode.c (encode_crypt_files): Fail if --output is used.
 	
 	* g10.c: New command --decrypt-files.
 
 	* decrypt.c (decrypt_messages): New.
 	
 2002-01-09  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c, misc.c, gpgv.c: move idea_cipher_warn to misc.c so gpgv.c
 	doesn't need a stub for it any longer.
 
 	* g10.c (get_temp_dir), main.h: no longer used (it's in exec.c now)
 
 	* g10.c (main), delkey.c (delete_keys), main.h : Allow
 	--delete-key (now --delete-keys, though --delete-key still works,
 	of course) to delete multiple keys in one go.  This applies to
 	--delete-secret-key(s) and --delete-secret-and-public-key(s) as
 	well.
 
 2002-01-09  Timo Schulz  <ts@winpt.org>
 
 	* encode.c (encode_crypt_files): Now it behaves like verify_files.
 	
 	* g10.c (main): We don't need to check argc for encode_crypt_files
 	any longer.
 
 2002-01-09  Timo Schulz  <ts@winpt.org>
 
 	* exec.c: Include windows.h for dosish systems.
 
 2002-01-08  Timo Schulz  <ts@winpt.org>
 
 	* g10.c (main): New description for --encrypt-files.
 
 2002-01-08  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Must register the secring for encryption because
 	it is needed to figure out the default recipient.  Reported by
 	Roger Sondermann.
 
 2002-01-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (menu_adduid): Require --expert before adding a photo
 	ID to a v3 key, and before adding a second photo ID to any key.
 
 	* keyedit.c (keyedit_menu): Don't allow adding photo IDs in
 	rfc1991 or pgp2 mode.
 
 	* getkey.c (merge_selfsigs_subkey): Permit v3 subkeys.  Believe it
 	or not, this is allowed by rfc 2440, and both PGP 6 and PGP 7 work
 	fine with them.
 
 	* g10.c, options.h, keyedit.c, sign.c: Move the "ask for
 	expiration" switch off of --expert, which was getting quite
 	overloaded, and onto ask-sig-expire and ask-cert-expire.  Both
 	default to off.
 
 	* g10.c (main): Change the default compression algo to 1, to be
 	more OpenPGP compliant (PGP also uses this, so it'll help with
 	interoperability problems as well).
 
 	* encode.c (encode_crypt): Handle compression algo 2, since the
 	default is now 1.
 
 	* build-packet.c (build_attribute_subpkt): Fix off-by-one error.
 
 2002-01-05  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Do not register the secret keyrings for certain
 	commands.
 
 	* keydb.c (keydb_add_resource): Use access to test for keyring
 	existence.  This avoids cached opened files which are bad under
 	RISC OS.
 
 2002-01-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (sign_file, sign_symencrypt_file): always use one-pass
 	packets unless rfc1991 is enabled.  This allows a signature made
 	with a v3 key to work in PGP 6 and 7.  Signatures made with v4
 	keys are unchanged.
 
 	* g10.c (main): Disallow non-detached signatures in PGP2 mode.
 	Move the "you must use files and not pipes" PGP2 warning up so all
 	the PGP2 stuff is together.
 
 	* encode.c (encode_simple): Use the actual filesize instead of
 	partial length packets in the internal literal packet from a
 	symmetric message.  This breaks PGP5(?), but fixes PGP2, 6, and 7.
 	It's a decent tradeoff.  Note there was only an issue with
 	old-style RFC1991 symmetric messages.  2440-style messages in 6
 	and 7 work with or without partial length packets.
 
 2002-01-03  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Removed --no-default-check-level option, as it is
 	not consistent with other "default" options.  Plus, it is the same
 	as saying --default-check-level 0.
 
 	* exec.c (exec_read): Disallow caching tempfile from child
 	process, as this keeps the file handle open and can cause unlink
 	problems on some platforms.
 
 	* keyserver.c (keyserver_search_prompt): Minor tweak - don't
 	bother to transform keyids into textual form if they're just going
 	to be transformed back to numbers.
 
 2002-01-03  Timo Schulz <ts@winpt.org>
 
 	* g10.c: New command --encrypt-files.
     
 	* verify.c (print_file_status): Removed the static because
 	encode_crypt_files also uses this function.
 
 	* main.h (print_files_status): New.
 	(encode_crypt_files): New.
 
 	* encode.c (encode_crypt_files): New.
 
 2002-01-02  Stefan Bellon  <sbellon@sbellon.de>
 
 	* keyserver.c: Moved util.h include down in order to avoid
 	redefinition problems on RISC OS.
 
 	* keyring.c (keyring_lock): Only lock keyrings that are writable.
 
 	* keyring.c (keyring_update_keyblock): Close unused iobuf.
 
 	* hkp.c (parse_hkp_index, hkp_search) [__riscos__]: Changed
 	unsigned char* to char* because of compiler issues.
 
 	* exec.c (exec_finish) [__riscos__]: Invalidate close cache so
 	that file can be unlinked.
 
 2001-12-28  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (main): Use a different strlist to check extensions since
 	they need to be handled seperately now.
 
 	* misc.c,main.h (check_permissions): Properly handle permission
 	and ownership checks on files in the lib directory
 	(e.g. /usr/local/lib/gnupg), which are owned by root and are
 	world-readable, and change all callers to specify extension or
 	per-user file.
 
 	* photoid.c (show_photo), keyserver.c (keyserver_spawn): Bug fix -
 	don't call exec_finish if exec_write fails.
 
 	* keyserver.c (keyserver_spawn): Look for OPTIONS from the
 	keyserver helper - specifically, a "OUTOFBAND" option for the
 	email keyserver.
 
 	* mainproc.c (list_node), keylist.c (list_keyblock_colon),
 	import.c (delete_inv_parts), export.c (do_export_stream): Use
 	signature flags for exportability check rather than re-parsing the
 	subpacket.
 
 	* keyid.c, keydb.h (get_lsign_letter): No longer needed.
 
 2001-12-27  David Shaw  <dshaw@jabberwocky.com>
 
 	* exec.c (exec_finish): Show errors when temp files cannot be
 	deleted for whatever reason.
 
 	* exec.c (exec_read): Don't rely on WEXITSTATUS being present.
 
 	* exec.c (make_tempdir): Add temp file creator for win32.  Don't
 	create an incoming temp file if the exec is write-only.
 
 	* keyserver.c (keyserver_spawn): Clean up error handling, for when
 	the spawn fails.
 
 	* photoid.c (show_photo): Clean up error handling.
 
 	* misc.c (check_permissions): Neaten.
 
 2001-12-25  David Shaw  <dshaw@jabberwocky.com>
 
 	* mkdtemp.c (mkdtemp): Add copyleft info and tweak the 'X' counter
 	to be a bit simpler.
 
 	* keyserver.c, photoid.c: Remove unused headers left over from
 	when the exec functions lived there.
 
 2001-12-23  Timo Schulz <ts@winpt.org>
 
 	* misc.c (check_permissions): Do not use it for W32 systems.
 
 	* tdbio.c (migrate_from_v2): Define ftruncate as chsize() for W32.
 
 	* mkdtemp.c: W32 support.
 
 	* photoid.c: Ditto.
 
 	* exec.c: Ditto.
 
 2001-12-22  David Shaw  <dshaw@jabberwocky.com>
 
 	* exec.c (make_tempdir): avoid compiler warning with const
 
 	* mkdtemp.c (mkdtemp): catch the empty ("") string case in case
 	someone repurposes mkdtemp at some point.
 
 	* photoid.c (generate_photo_id, show_photo): some type changes
 	from Stefan Bellon.
 
 	* exec.c (make_tempdir): handle Win32 systems, suggested by Timo
 	Schulz.
 
 2001-12-22  Werner Koch  <wk@gnupg.org>
 
 	* encode.c (encode_simple, encode_crypt): i18n 2 strings.
 
 2001-12-22  Timo Schulz <ts@winpt.org>
 	
 	* encode.c (encode_simple, encode_crypt): Use is_file_compressed
 	to avoid to compress compressed files.
 
 2001-12-22  Werner Koch  <wk@gnupg.org>
 
 	* keyserver.c (keyserver_spawn): Removed some variables
 	declaration due to shadowing warnings.
 
 	* build-packet.c (build_attribute_subpkt): s/index/idx/ to avoid
 	compiler warnig due to index(3).
 
 	* getkey.c (get_ctx_handle): Use KEYDB_HANDLE as return value.
 	* keylist.c (list_one): Made resname const.
 
 	* keyedit.c (keyedit_menu): Allow "addphoto" only when --openpgp is
 	not used.
 
 	* options.skel: Changed one example photo viewer to qiv.
 
 2001-12-21  David Shaw  <dshaw@jabberwocky.com>
 
 	* Makefile.am: add exec.c, exec.h, photoid.c, and photoid.h
 
 	* build-packet.c (build_attribute_subpkt): new function to build
 	the raw attribute subpacket.  Note that attribute subpackets have
 	the same format as signature subpackets.
 
 	* exec.c: new file with generic exec-a-program functionality.
 	Used by both photo IDs and keyserver helpers.  This is pretty much
 	the same code that used to be keyserver specific, with some
 	changes to be usable generically.
 
 	* free-packet.c (free_attributes (new)): function to free an
 	attribute packet.
 	
 	* gpgv.c: added stub show_photo
 	
 	* keyedit.c (keyedit_menu, menu_adduid, menu_showphoto): can add a
 	photo (calls generate_photo_id), or display a photo (calls
 	show_photo) from the --edit menu.  New commands are "addphoto",
 	and "delphoto" (same as "deluid").
 
 	* keylist.c (list_keyblock_print): show photos during key list if
 	--show-photos enabled.
 	
 	* keyserver.c (keyserver_spawn): use the generic exec_xxx
 	functions to call keyserver helper.
 
 	* g10.c, options.h: three new options - --{no-}show-photos, and
 	--photo-viewer to give the command line to display a picture.
 
 	* options.skel: instructions for the photo viewer
 	
 	* parse-packet.c (parse_user_id, setup_user_id (new)): common code
 	for both user IDs and attribute IDs moved to setup_user_id.
 
 	* parse-packet.c (make_attribute_uidname (new)): constructs a fake
 	"name" for attribute packets (e.g. "[image of size ...]")
 
 	* parse-packet.c (parse_attribute (replaces parse_photo_id),
 	parse_attribute_subpkts): Builds an array of individual
 	attributes.  Currently only handles attribute image / type jpeg
 	subpackets.
 
 	* sign.c (hash_uid): Fix bug in signing attribute (formerly
 	photo_id) packets.
 
 	* packet.h, and callers: globally change "photo_id" to "attribute"
 	and add structures for attributes.  The packet format is generic
 	attributes, even though the only attribute type thus far defined
 	is jpeg.
 
 2001-12-21  David Shaw  <dshaw@jabberwocky.com>
 
 	* parse-packet.c (can_handle_critical): Can handle critical
 	revocation subpackets now.
 
 	* trustdb.c (mark_usable_uid_certs): Disregard revocations for
 	nonrevocable sigs.  Note that this allows a newer revocable
 	signature to override an older nonrevocable signature.
 
 	* sign.c (make_keysig_packet): add a duration field and change all
 	callers.  This makes make_keysig_packet closer to
 	write_signature_packets and removes some duplicated expiration
 	code.
 
 	* keyedit.c (keyedit_menu, menu_revsig, sign_uids,
 	sign_mk_attrib): Add nrsign command, don't allow revoking a
 	nonrevocable signature,
 
 	* g10.c (main): Add --nrsign option to nonrevocably sign a key
 	from the command line.
 
 	* build-packet.c (build_sig_subpkt_from_sig): Comment to explain
 	the use of CRITICAL.
 
 2001-12-21  Werner Koch  <wk@gnupg.org>
 
 	* g10.c. options.h : New option --show-keyring
 	* getkey.c (get_ctx_handle): New.
 	* keylist.c (list_one): Implement option here.  By David Champion. 
 
 2001-12-20  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (keyserver_spawn): Use mkdtemp() to make temp
 	directory.
 
 	* mkdtemp.c: replacement function for those platforms that don't
 	have mkdtemp (make a temp directory securely).
 
 2001-12-19  David Shaw  <dshaw@jabberwocky.com>
 
 	* misc.c (check_permissions): New function to stat() and ensure
 	the permissions of GNUPGHOME and the files have safe permissions.
 
 	* keydb.c (keydb_add_resource): Check keyring permissions.
 
 	* tdbio.c (tdbio_set_dbname): Check permissions of trustdb.gpg
 
 	* keyserver.c (keyserver_spawn): Disable keyserver schemes that
 	involve running external programs if the options file has unsafe
 	permissions or ownership.
 
 	* g10.c, options.h: New option --no-permission-warning to disable
 	the permission warning message(s).  This also permits use of the
 	keyserver if it had been disabled (see above).  Also check the
 	permissions/ownership of random_seed.
 	
 	* keyserver.c (keyserver_spawn): The new glibc prints a warning
 	when using mktemp() (the code was already secure, but the warning
 	was bound to cause confusion).  Use a different implementation
 	based on get_random_bits() instead.  Also try a few times to get
 	the temp dir before giving up.
 
 2001-12-19  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, passphrase.c [CYGWIN32]: Allow this as an alias for MINGW32.
 
 2001-12-18  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c (idea_cipher_warn): Add a flag to show the warning always
 	or once per session and change all callers (show always except for
 	the secret key protection and unknown cipher from an encrypted
 	message errors).  Also make the strings translatable.
 
 	* pubkey-enc.c (get_it): Add the IDEA cipher warning if the user
 	tries to decrypt an IDEA encrypted message without the IDEA
 	plugin.
 
 	* keyserver.c (parse_keyserver_uri): More strict checking of the
 	keyserver URI.  Specifically, fail if the ":port" section is
 	anything except a number between 1 and 65535.
 
 2001-12-17  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyserver.c (print_keyinfo): No need to check for
 	control/illegal characters, as utf8_to_native does this for us.
 
 	* mainproc.c (proc_encrypted): Use generic IDEA warning.
 
 	* gpgv.c: add stub for idea_cipher_warn
 
 	* g10.c, hkp.c, keyserver.c: Fix capitalization and plural issues.
 
 	* encode.c (encode_crypt), sign.c (sign_file, clearsign_file):
 	disable pgp2 mode after the message is no longer pgp2 compatible.
 
 	* g10.c (main): Tweak the PGP2.x IDEA warning to use the generic
 	warning, and not merely fail if the IDEA plugin isn't there.
 
 	* g10.c (main, idea_cipher_warn), keygen.c (set_one_pref),
 	seckey-cert.c (do_check): Add a generic IDEA warning for when the
 	IDEA plugin is not present.  This pops up when the user uses
 	"--cipher-algo idea", when setpref is used to set a "S1"
 	preference, and when a secret key protected with IDEA is used.
 
 2001-12-15  Werner Koch  <wk@gnupg.org>
 
 	* keyserver.c (keyserver_spawn): Assert that we have dropped privs.
 
 2001-12-13  Werner Koch  <wk@gnupg.org>
 
 	* pubkey-enc.c (get_session_key): Check that the public key
 	algorithm is indeed usable for en/decryption.  This avoid a
 	strange error message from pubkey_decrypt if for some reasons a
 	bad algorithm indentifier is passed.
 
 2001-12-12  David Shaw  <dshaw@jabberwocky.com>
 
 	* Fixed some types for portability.  Noted by Stefan Bellon.
 
 2001-12-11  Werner Koch  <wk@gnupg.org>
 
 	* hkp.c (hkp_export): Do not print possible control characters
 	from a keyserver response.
 	(parse_hkp_index): Made uid an unsigned char* because it is passed to
 	isspace().
 	(hkp_search): Ditto for the char* vars.
 
 	* g10.c (main): Print the IDEA warning also for -c and -se.
 	
 	* g10.c (get_temp_dir): Assert that we have dropped privs
 
 	* encode.c (encode_crypt): Include the first key into the --pgp2
 	check.
 
 2001-12-07  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c, options.h: New option --pgp2.  This is identical to
 	"--rfc1991 --cipher-algo idea --compress-algo 1 --digest-algo md5
 	--force_v3_sigs" with the addition of an warning to advise the
 	user not to use a pipe (which would break pgp2 compatibility).
 
 	* encode.c (encode_crypt): warn if the user tries to encrypt to
 	any key that is not RSA and <= 2048 bits when the --pgp2 option is
 	used.
 
 	* sign.c (sign_file, clearsign_file): When using --pgp2, make a v3
 	sig, and warn if the signature is made with a non-v3 key.
 
 2001-12-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* sign.c (sign_file, clearsign_file, sign_symencrypt_file): Prompt
 	for sig expiration if --expert is set and --force-v3-sigs is not
 	set (v3 sigs cannot expire).
 
 	* mainproc.c (check_sig_and_print): After checking a sig, print
 	expiration status.  This causes a error return if the sig is
 	expired.
 
 	* build-packet.c (build_sig_subpkt_from_sig): Include a critical
 	sig expiration subpacket if the sig is to expire.
 
 	* keyedit.c (sign_uids): Do not sign an expired key unless
 	--expert is set, in which case prompt.  Also, offer to expire a
 	signature when the key the user is signing expires.
 
 	* keygen.c (ask_expire_interval): Add a value to determine whether
 	to prompt for a key or sig expiration and change all callers.
 
 	* keyid.c: New functions: expirestr_from_sig and
 	colon_expirestr_from_sig.
 
 	* keylist.c (list_keyblock_colon): Show sig expiration date in the
 	--with-colons listing.
 
 	* sign.c (make_keysig_packet, write_signature_packets): Pass in an
 	optional timestamp for the signature packet, and change all
 	callers.
 
 	* keyedit.c (sign_mk_attrib): Include a critical expiration
 	subpacket in the signature if an expiration date is given.
 
 2001-12-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (sign_uids): If the user tries to sign a
 	locally-signed key, allow the cert to be promoted to a full
 	exportable signature.  This essentially deletes the old
 	non-exportable sig, and replaces it with a new exportable one.
 
 2001-12-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* keyedit.c (keyedit_menu): Do not allow signing a revoked key
 	unless --expert is set, and ask even then.
 
 	* keyedit.c (sign_uids): Do not allow signing a revoked UID unless
 	--expert is set, and ask even then.
 
 	* g10.c, options.h : New option --expert
 
 2001-11-16  David Shaw  <dshaw@jabberwocky.com>
 
 	* Allow the user to select no compression via "--compress-algo 0"
 	on the command line.
 
 	* keyedit.c (show_prefs): Show compression preferences in the
 	long-form "showpref" style.
 
 	* keygen.c (set_one_pref): Permit setting a no-compression ("Z0")
 	preference.
 
 	* getkey.c (fixup_uidnode): Fix compression preference corruption
 	bug.
 
 2001-12-02  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c: Add advisory --for-your-eyes-only option as per section
 	5.9 of 2440.
 
 2001-12-05  David Shaw  <dshaw@jabberwocky.com>
 
 	* Force a V4 sig if the user has a notation or policy URL set.
 
 2001-12-04  David Shaw  <dshaw@jabberwocky.com>
 
 	* g10.c: Add options --keyserver-options, --temp-directory, and
 	auto-key-retrieve (the opposite of no-auto-key-retrieve).
 
 	* hkp.c (hkp_search): New function to handle searching a HKP
 	keyserver for a key
 
 	* hkp.c (hkp_ask_import, hkp_export): Pretty large changes to make
 	them communicate via the generic functions in keyserver.c
 
 	* keyserver.c: new file with generic keyserver routines for
 	getting keys from a keyserver, sending keys to a keyserver, and
 	searching for keys on a keyserver.  Calls the internal HKP stuff
 	in hkp.c for HKP keyserver functions.  Other calls are handled by
 	an external program which is spawned and written to and read from
 	via pipes.  Platforms that don't have pipes use temp files.
 
 2001-11-20  David Shaw  <dshaw@jabberwocky.com>
 
 	* options.h, g10.c: New options show-notation, no-show-notation,
 	default-check-level, no-default-check-level, show-policy-url,
 	no-show-policy-url.
 
 	* packet.h, sign.c (make_keysig_packet), parse-packet.c
 	(parse_signature), free-packet.c (free_seckey_enc): Fill in
 	structures for notation, policy, sig class, exportability, etc.
 
 	* keyedit.c, keylist.c (print_and_check_one_sig,
 	list_keyblock_print): Show flags in signature display for cert
 	details (class, local, notation, policy, revocable).  If selected,
 	show the notation and policy url.
 
 	* keyedit.c (sign_uids): Prompt for and use different key sig
 	classes.
 
 	* helptext.c (helptexts): Add help text to explain different
 	key signature classes
 
 2001-11-26  David Shaw  <dshaw@jabberwocky.com>
 
 	* trustdb.c (mark_usable_uid_certs): Fix segfault from bad
 	initialization and fix reversed key signature expiration check.
 
 2001-11-09  Werner Koch  <wk@gnupg.org>
 
 	* export.c (do_export_stream): Put all given names into a search
 	description and change the loop so that all matching names are
 	returned.
 
 2001-11-08  Werner Koch  <wk@gnupg.org>
 
 	* pubkey-enc.c (get_it): To reduce the number of questions on the
 	MLs print the the name of cipher algorithm 1 with the error message.
 
 	* mainproc.c: Changed the way old rfc1991 encryption cipher is
 	selected. Based on a patch by W Lewis.
 
 	* pkclist.c (do_edit_ownertrust): Allow to skip over keys, the non
 	working "show info" is now assigned to "i" 
 	* trustdb.c (ask_ownertrust, validate_keys): Implement a real quit
 	here.  Both are by David Shaw.
 	
 	* trustdb.c (validate_keys): Make sure next_exipire is initialized.
 
 	* sign.c (make_keysig_packet): Use SHA-1 with v4 RSA keys.
 
 	* g10.c, options.h : New option --[no-]froce-v4-certs.
 	* sign.c (make_keysig_packet): Create v4 sigs on v4 keys even with
 	a v3 key.  Use that new option.  By David Shaw
 
 	* revoke.c (ask_revocation_reason): Allow to select "no reason".
 	By David Shaw.
 
 	* keyid.c (fingerprint_from_sk): Calculation of an v3 fpr was
 	plain wrong - nearly the same code in fingerprint_from_pk is correct.
 
 	* build-packet.c (do_secret_key): Added a few comments to the code.
 
 2001-11-07  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Print a warning when -r is used w/o encryption.
 	Suggested by Pascal Scheffers.
 
 2001-10-23  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (keyedit_menu): Changed helptext for showpref
 	command.  Suggested by Reinhard Wobst.
 
 	* keyring.c (keyring_search): When marking the offtbl ready, take
 	into account that we may have more than one keyring.
 
 2001-10-22  Werner Koch  <wk@gnupg.org>
 
 	* Makefile.am: Do not use OMIT_DEPENDENCIES
 
 	* build-packet.c (build_sig_subpkt): Default is now to put all
 	types of subpackets into the hashed area and only list those which
 	should go into the unhashed area.
 
 2001-10-18  Werner Koch  <wk@gnupg.org>
 
 	* keydb.c (keydb_add_resource): Rearranged the way we keep track
 	of the resource. There will now be an entry for each keyring here
 	and not in keyring.c itself.  Store a token to allow creation of a
 	keyring handle.  Changed all functions to utilize this new design.
 	(keydb_locate_writable): Make a real implementation.
 	* keyring.c (next_kr): Removed and changed all callers to set the
 	resource directly from the one given with the handle.
 	(keyring_is_writable): New. 
 	(keyring_rebuild_cache): Add an arg to pass the token from keydb.
 
 2001-10-17  Werner Koch  <wk@gnupg.org>
 
 	* keyring.c (keyring_search): Enabled word search mode but print a
 	warning that it is buggy.
 	
 2001-10-11  Werner Koch  <wk@gnupg.org>
 
 	* hkp.c (hkp_ask_import): No more need to set the port number for
 	the x-hkp scheme. 
 	(hkp_export): Ditto.
 
 2001-10-06  Stefan Bellon  <sbellon@sbellon.de>
 
 	* passphrase.c [__riscos__]: Disabled agent specific stuff.
 	* g10.c: New option --no-force-v3-sigs.
 
 2001-10-04  Werner Koch  <wk@gnupg.org>
 
 	* export.c (do_export_stream): Do not push the compress filter
 	here because the context would run out of scope due to the
 	iobuf_close done by the caller.
 	(do_export): Do it here instead. 
 
 2001-09-28  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (sign_uids): Always use the primary key to sign keys.
 	* getkey.c (finish_lookup): Hack to return only the primary key if
 	a certification key has been requested.
 
 	* trustdb.c (cmp_kid_for_make_key_array): Renamed to
 	(validate_one_keyblock): this and changed arg for direct calling.
 	(make_key_array): Renamed to
 	(validate_one_keyblock): this and changed args for direct calling.
 	(mark_usable_uid_certs, validate_one_keyblock)
 	(validate_key_list): Add next_expire arg to keep track of
 	expiration times.  
 	(validate_keys): Ditto for UTKs and write the stamp.
 
 	* tdbio.c (migrate_from_v2): Check return code of tbdio_sync.
 
 	* tdbdump.c (import_ownertrust): Do a tdbio_sync().
 
 	* keyring.c: Made the offtbl an global object.
 
 2001-09-27  Werner Koch  <wk@gnupg.org>
 
 	* pkclist.c (do_edit_ownertrust): Allow settin of ultimate trust.
 
 	* trustdb.c (mark_keyblock_seen): New.
 	(make_key_array): Use it to mark the subkeys too.
 	(validate_keys): Store validity for ultimatly trusted keys.
 
 2001-09-26  Werner Koch  <wk@gnupg.org>
 
 	* pkclist.c (check_signatures_trust, do_we_trust): Removed the
 	invocation of add_ownertrust. Minor changes to the wording.
 	(add_ownertrust, add_ownertrust_cb): Removed.
 
 	* trustdb.c (get_validity): Allow to lookup the validity using a
 	subkey.
 
 	* trustdb.c (new_key_hash_table): Increased the table size to 1024
 	and changed the masks accordingly.
 	(validate): Changed stats printing.
 	(mark_usable_uid_certs): New.
 	(cmp_kid_for_make_key_array): Does now check the signatures and
 	figures out a usable one.
 
 2001-09-25  Werner Koch  <wk@gnupg.org>
 
 	* keyring.c (new_offset_item,release_offset_items)
 	(new_offset_hash_table, lookup_offset_hash_table)
 	(update_offset_hash_table, update_offset_hash_table_from_kb): New.
 	(keyring_search): Use a offset table to optimize search for
 	unknown keys.
 	(keyring_update_keyblock, keyring_insert_keyblock): Insert new
 	offsets.
 	* getkey.c (MAX_UNK_CACHE_ENTRIES): Removed the unknown keys
 	caching code.
 
 	* g10.c, options.h, import.c: Removed the entire
 	allow-secret-key-import stuff because the validity is now
 	controlled by other means.
 
 	* g10.c: New command --rebuild-keydb-caches.
 	* keydb.c (keydb_rebuild_caches): New.
 	* keyring.c (do_copy): Moved some code to
 	(create_tmp_file, rename_tmp_file, write_keyblock): new functions.
 	(keyring_rebuild_cache): New.
 
 	* packet.h (PKT_ring_trust): Add sigcache field.
 	* parse-packet.c (parse_trust): Parse sigcache.
 	* keyring.c (do_copy): Always insert a sigcache packet.
 	(keyring_get_keyblock): Copy the sigcache packet to the signature.
 	* sig-check.c (cache_sig_result): Renamed from
 	cache_selfsig_result. Changed implementation to use the flag bits
 	and changed all callers.
 	(mdc_kludge_check): Removed this unused code.
 	(do_check): Do not set the sig flags here.
 
 	* import.c (read_block): Make sure that ring_trust packets are
 	never imported.
 	* export.c (do_export_stream): and never export them.
 
 	* trustdb.c (make_key_array): Skip revoked and expired keys.
 
 2001-09-24  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: New option --no-auto-check-trustdb.
 
 	* keygen.c (do_generate_keypair): Set newly created keys to
 	ultimately trusted.
 
 	* tdbio.h, tdbio.c: Removed all support for records DIR, KEY, UID,
 	PREF, SIG, SDIR and CACH. Changed migration function to work
 	direct on the file.
 	(tdbio_read_nextcheck): New.
 	(tdbio_write_nextcheck): New. 
 
 2001-09-21  Werner Koch  <wk@gnupg.org>
 
 	Revamped the entire key validation system.
 	* trustdb.c: Complete rewrite. No more validation on demand,
 	removed some functions, adjusted to all callers to use the new 
 	and much simpler interface. Does not use the LID anymore.
 	* tdbio.c, tdbio.h: Add new record types trust and valid. Wrote a
 	migration function to convert to the new trustdb layout.
 	* getkey.c (classify_user_id2): Do not allow the use of the "#"
 	prefix. 
 	* keydb.h: Removed the TDBIDX mode add a skipfnc to the
 	descriptor.
 	* keyring.c (keyring_search): Implemented skipfnc.
 
 	* passphrase.c (agent_open): Add missing bracket.  Include windows.h.
 
 2001-09-19  Werner Koch  <wk@gnupg.org>
 
 	* keylist.c (print_fingerprint): Renamed from fingerprint, made
 	global available. Added new arg to control the print style.
 	* mainproc.c (print_fingerprint): Removed. 
 	* pkclist.c (print_fpr, fpr_info): Removed and changed callers to
 	use print_fingerprint.
 	* keyedit.c (show_fingerprint): Ditto.
 
 	* passphrase.c (writen, readn)
 	(agent_open, agent_close)
 	(agent_get_passphrase)
 	(passphrase_clear_cache): Support for W32.  Contributed by Timo.
 
 	* import.c (import_one): Release keydb handles at 2 more places.
 
 	* keyring.c (keyring_release): Close the iobuf.
 	(keyring_get_keyblock): Init ret_kb to NULL and store error contidion.
 
 	* import.c (import_new_stats_handle): New. 
 	(import_release_stats_handle): New.
 	(import_print_stats): Renamed from static fnc print_stats.
 	(import_keys, import_keys_stream): Add an optional status handle
 	arg and changed all callers.
 	* hkp.c (hkp_ask_import): Add an stats_handle arg and changed all
 	callers.
 
 	* mainproc.c (print_pkenc_list): Use print_utf8_string2().
 
 2001-09-18  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New command --refresh-keys.
 	* hkp.c (hkp_refresh_keys): New. Contributed by Timo Schulz.
 
 	* parse-packet.c (parse): Stop on impossible packet lengths.
 
 2001-09-17  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (print_notation_data): Wrap notation data status lines
 	after 50 chars.
 	
 	* mainproc.c (proc_pubkey_enc): Make option try-all-secrets work.
 	By disastry@saiknes.lv.
 
 2001-09-14  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (dump_sig_subpkt): List key server preferences
 	and show the revocable flag correctly. Contributed by David Shaw.
 
 2001-09-09  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (keyedit_menu): No need to define another p.
 
 	* keylist.c (print_capabilities): s/used/use/ so that it
 	does not shadow a global.
 	* sign.c (sign_file): Renamed arg encrypt to encryptflag
 	* keygen.c: Replaced all "usage" by "use".
 	* misc.c (openpgp_pk_algo_usage): Ditto.
 
 	* pubkey-enc.c (get_it): Renamed arg k to enc so that the later
 	defined k does not shadow it.
 
 	* parse-packet.c (parse_gpg_control): No need to define another i.
 
 	* getkey.c (get_pubkey_byfprint): Must use the enum values and not
 	the fprint_len.
 	* keyring.c (keyring_search): Removed a non-sense break.  Both
 	bugs pointed out by Stefan.
 
 2001-09-07  Werner Koch  <wk@gnupg.org>
 
 	* status.c, status.h: Added NO_RECP and ALREADY_SIGNED.
 	* pkclist.c (build_pk_list): Issue NO_RECP.
 	* keyedit.c (sign_uids): Added experimental ALREADY_SIGNED
 
 	* hkp.c (hkp_import): Use log_error. Bug reported by Neal H
 	Walfield. 
 
 	* getkey.c (classify_user_id2): Change args to take the desc union
 	direct.  It was a stupid idea to pass the individual fields of an
 	union to this function. Changed all callers.
 	(classify_user_id): Ditto and allow to pass NULL as the description.
 
 2001-09-06  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (fixup_uidnode): Features flag is now a bit vector.
 	* keygen.c (add_feature_mdc): Ditto.
 
 	Revamped the entire key I/O code to be prepared for other ways of
 	key storages and to get rid of the existing shit.  GDBM support has
 	gone.
 	* keydb.c: New
 	* keyring.c, keyring.h: New.
 	* ringedit.c: Removed.  Moved some stuff to keyring.c
 	* getkey.c: Changed everything related to the key retrieving
 	functions which are now using the keydb_ functions.  
 	(prepare_search, word_match_chars, word_match)
 	(prepare_word_match, compare_name): Moved to keyring.c
 	(get_pubkey_byname): Removed ctx arg and add ret_kdbhd
 	arg.  Changed all callers.
 	(key_byname): Use get_pubkey_end to release the context and take
 	new ret_kbdhd arg.  Changed all callers.
 	(classify_user_id2): Fill the 16 byte fingerprint up with 4 null
 	bytes not with zero bytes of value 4, tsss.
 	* import.c (import_one): Updated to use the new keydb interface.
 	(import_secret_one): Ditto.
 	(import_revoke_cert): Ditto.
 	* delkey.c (do_delete_key): Ditto. 
 	* keyedit.c (keyedit_menu): Ditto.
 	(get_keyblock_byname): Removed.
 	* revoke.c (gen_revoke): Ditto. 
 	* export.c (do_export_stream): Ditto.
 	* trustdb.c (update_trustdb): Ditto.
 	* g10.c, gpgv.c (main): Renamed add_keyblock_resource to
 	keydb_add_resource. 
 	* Makefile.am:  Added and removed files.
 
 	* keydb.h: Moved KBNODE typedef and MAX_FINGERPRINT_LEN to
 	* global.h: this new header.
  	
 2001-09-03  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (agent_get_passphrase): Changed nread to size_t.
 	(passphrase_clear_cache): Ditto.
 
 	* keyid.c (mk_datestr): Avoid trigraphs.
 	(fingerprint_from_pk): Cache the keyid in the pk.
 
 	* options.h: Add opt.with_fingerprint so that we know whether the
 	corresponding options was used.
 	* g10.c (main): Set it here.
 	* pkclist.c (check_signatures_trust): Always print fingerprint
 	when this option is used.  Mixed a minor memory leak.
 
 	* status.c, status.h: New status INV_RECP.
 	* pkclist.c (build_pk_list): Issue this status.
 
 2001-08-31  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (parse_key,parse_pubkeyenc)
 	(parse_signature): Return error on reading bad MPIs.
 	
 	* mainproc.c (check_sig_and_print): Always print the user ID even
 	if it is not bound by a signature.  Use the primary UID in the
 	status messages and encode them in UTF-8
 	* status.c (write_status_text_and_buffer): New.
 
 2001-08-30  Werner Koch  <wk@gnupg.org>
 
 	* packet.h (sigsubpkttype_t): Add SIGSUBPKT_FEATURES.
 	(PKT_public_key, PKT_user_id): Add a flag for it.
 	* parse-packet.c, build-packet.c: Add support for them.
 	* getkey.c (fixup_uidnode, merge_selfsigs): Set the MDC flags.
 	* keygen.c (add_feature_mdc): New.
 	(keygen_upd_std_prefs): Always set the MDC feature.
 	* keyedit.c (show_prefs): List the MDC flag
 	* pkclist.c (select_mdc_from_pklist): New.
 	* encode.c (encode_crypt, encrypt_filter): Test whether MDC
 	should be used.
 	* cipher.c (write_header): Set MDC use depending on the above test.
 	Print more status info.
 
 	* delkey.c (do_delete_key): Kludge to delete a secret key with no
 	public key available.
 
 	* ringedit.c (find_secret_keyblock_direct): New.
 	* getkey.c (seckey_available): Simplified.
 
 	* ringedit.c (cmp_seckey): Now compares the secret key against the
 	public key while ignoring all secret parts.
 	(keyring_search): Use a public key packet as arg.  Allow to search
 	for subnkeys
 	(search): Likewise. Changed all callers.
 	(find_secret_keyblock_bypk): New.
 	(find_secret_keyblock_byname): First locate the pubkey and then
 	find the correponding secret key.
 	* parse-packet.c (parse): Renamed pkttype arg to onlykeypkts and
 	changed code accordingly.  Changed all callers.
 	(search_packet): Removed pkttype arg.
 	* keyedit.c (keyedit_menu): First locate the public key and then
 	try to locate a secret key.
 
 	* ringedit.c (locate_keyblock_by_fpr): Removed.
 	(locate_keyblock_by_keyid): Removed.
 	(find_keyblock_bysk): Removed.
 
 	* sig-check.c (check_key_signature2): Print the keyid along with
 	the wrong sig class errors.
 
 2001-08-24  Werner Koch  <wk@gnupg.org>
 
 	* sign.c (sign_file): Stripped the disabled comment packet code.
 	(sign_file, sign_symencrypt_file): Moved common code to ..
 	(write_onepass_sig_packets): .. this new function.
 	(sign_file, clearsign_file, sign_symencrypt_file): Moved common
 	code to 
 	(write_signature_packets): this new function.
 	(write_signature_packets, make_keysig_packet)
 	(update_keysig_packet): Moved common code to 
 	(hash_uid, hash_sigclass_to_magic): these new functions
 	(sign_file, sign_symencrypt_file): Moved common code to 
 	(write_plaintext_packet):  this new function.
 
 2001-08-21  Stefan Bellon  <sbellon@sbellon.de>
 
 	* trustdb.c (query_trust_info): Changed trustlevel to signed int.
 	* g10.c [__riscos__]: Fixed handling of --use-agent --lock-multiple.
 
 2001-08-20  Werner Koch  <wk@gnupg.org>
 
 	* encr-data.c (decrypt_data): Keep track on whether we already
 	printed information about the used algorithm.
 	* mainproc.c (proc_encrypted): Removed the non-working IDEA hack
 	and print a message about the assumed algorithm.
 	* passphrase.c (passphrase_to_dek): Use the same algorithm as above.
 	(proc_symkey_enc): Print the algorithm, so that the user knows it
 	before entering the passphrase.
 	(proc_pubkey_enc, proc_pubkey_enc): Zero the DEK out.
 	* encode.c (encode_crypt, encrypt_filter): Ditto.
 
 	* g10.c: Allow for --sign --symmetric.
 	* sign.c (sign_and_symencrypt): New.
 
 	Applied patches from Stefan Bellon <sbellon@sbellon.de> to support
 	RISC OS.  Nearly all of these patches are identified by the
 	__riscos__ macro.
 	* compress.c: Added a couple of casts.
 	* g10.c [__riscos__]: Some patches and new options foo-file similar
 	to all foo-fd options.
 	* gpgv.c, openfile.c, ringedit.c, tdbio.c: Minor fixes.  Mainly
 	replaced hardcoded path	separators with EXTSEP_S like macros.  
 	* passprase.c [__riscos__]: Disabled agent stuff
 	* trustdb.c (check_trust): Changed r_trustlevel to signed int to
 	avoid mismatch problems in pkclist.c
 	* pkclist.c (add_ownertrust): Ditto.
 	* plaintext.c (handle_plaintext) [__riscos__]: Print a note when
 	file can't be created.
 	* options.h [__riscos__]: Use an extern unless included from the
 	main module.
 	* signal.c (got_fatal_signal) [__riscos__]: Close all files.
 	
 2001-08-14  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (ask_algo): New arg r_usage.  Allow for RSA keys.
 	(gen_rsa): Enabled the code.
 	(do_create): Enabled RSA branch.
 	(parse_parameter_usage): New.
 	(proc_parameter_file): Handle usage parameter.
 	(read_parameter_file): Ditto.
 	(generate_keypair): Ditto.
 	(generate_subkeypair): Ditto.
 	(do_generate_keypair): Ditto.
 	(do_add_key_flags): New.
 	(keygen_add_std_prefs): Use the new function.
 	(keygen_add_key_flags_and_expire): New.
 	(write_selfsig, write_keybinding): Handle new usage arg.
 	* build-packet.c (build_sig_subpkt): Make sure that key flags go
 	into the hashed area.
 	
 	* keygen.c (write_uid): Initialize the reference cunter.
 
 	* keyedit.c (keyedit_menu): No more need to update the trustdb for
 	preferences.  Added calls to merge keblock.
 
 	* kbnode.c (dump_kbnode): Print some more flags.
 
 2001-08-10  Werner Koch  <wk@gnupg.org>
 
         Revamped the preference handling.
 
 	* packet.h (prefitem_t, preftype_t): New.
 	(PKT_public_key): Added a uid field.
 	(PKT_user_id): Added field to store preferences and a reference
 	counter.
 	* parse-packet.c (parse_user_id,parse_photo_id): Initialize them
 	* free-packet.c (free_user_id): Free them.
 	(copy_user_id): Removed.
 	(scopy_user_id): New. 
 	(cmp_user_ids): Optimized for identical pointers.
 	(release_public_key_parts): Release the uid.
 	(copy_public_key_with_new_namehash): Removed.
 	(copy_prefs): New.
 	* keyedit.c (menu_adduid): Use the new shallow copy user id.
 	(show_prefs): Adjusted implementation.
 	(keyedit_menu): No more need to update the trustdb after changing
 	preferences.
 	* getkey.c (fixup_uidnode): Store preferences.
 	(find_by_name): Return a user id packet and remove namehash stuff.
 	(lookup): Removed the unused namehash stuff.
 	(finish_lookup): Added foundu arg.
 	(pk_from_block): Removed the namehash arg and changed all callers.
 	(merge_selfsigs): Copy prefs to all keys.
 	* trustdb.c (get_pref_data): Removed.
  	(is_algo_in_prefs): Removed.
 	(make_pref_record): Deleted and removed all class.
 	* pkclist.c (select_algo_from_prefs): Adjusted for the new
 	preference implementation.
 	* pubkey-enc.c (is_algo_in_prefs): New.
 	(get_it): Use that new function. 
 
 2001-08-09  Werner Koch  <wk@gnupg.org>
 
 	* build-packet.c (build_sig_subpkt): Fixed calculation of
 	newarea->size.
 
 	* g10.c (main): New option "--preference-list"
 	* keyedit.c (keyedit_menu): New commands "setpref" and "updpref".
 	(menu_set_preferences): New.
 	* keygen.c (keygen_set_std_prefs): New.
 	(set_one_pref): New.
 	(check_zip_algo): New.
 	(keygen_get_std_prefs): New.
 	(keygen_upd_std_prefs): New
 	(keygen_add_std_prefs): Move the pref setting code into the above fnc.
 	* build-packet.c (build_sig_subpkt): Updated the list of allowed
 	to update subpackets.
 
 2001-08-08  Werner Koch  <wk@gnupg.org>
 
 	* packet.h (subpktarea_t): New.
 	(PKT_signature): Use that type for hashed_data and unhashed_data and
 	removed the _data prefix from those fields.  Changed all users.
 	* parse-packet.c (parse_signature): Changed allocation for that.
 	(parse_sig_subpkt): Changed declaration
 	(enum_sig_subpkt): Ditto and changed implementation accordingly.
 	* free-packet.c (cp_subpktarea): Renamed from cp_data_block and
 	adjusted implementation. Changed caller.
 	* sig-check.c (mdc_kludge_check): Adjusted the hashing.
 	(do_check): Ditto.
 	* sign.c (sign_file, clearsign_file, make_keysig_packet,
 	update_keysig_packet): Ditto.
 	* build-packet.c (build_sig_subpkt): Partial rewrite.
 	(find_subpkt): Adjusted and made static.
 	(delete_sig_subpkt): Adjusted.
 	(do_signature): Ditto.
 
 	* keygen.c (ask_keysize): Do not print the notes about suggested
 	key sizes if just a DSA key is generated.
 
 	* trustdb.c (add_ultimate_key): s/log_error/log_info/ for
 	duplicated inserted trusted keys.
 
 2001-08-07  Werner Koch  <wk@gnupg.org>
 
 	* sign.c (sleep): Redefine for W32.
 
 	* g10.c, options.h: Set new flag opt.no_homedir_creation when
 	--no-options is given.
 	* openfile.c (try_make_homedir): Don't create the homedir in that case.
 
 2001-08-03  Werner Koch  <wk@gnupg.org>
 
 	* armor.c (armor_filter): Removed the default comment string
 	because it could get us in trouble due to translations using non
 	ascii characters.
 
 2001-08-01  Werner Koch  <wk@gnupg.org>
 
 	* keylist.c (list_keyblock_print): Do not list revoked UIDs unless
 	in verbose mode and we do no signature listing.
 
 	* getkey.c (finish_lookup): Skip subkeys which are not yet valid.
 	* g10.c, options.h: New option --ignore-valid-from.
 
 	* sign.c (make_keysig_packet): Added new sigversion argument to
 	allow the caller to force generation of required signature
 	version. Changed all callers. Suggested by Thomas Roessler.
 
 	* keyedit.c (sign_uids): Force v4 signature generation for local
 	sigs.  Removed the check for local signature and pre-v4 keys.
 
 2001-07-27  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (sign_uids): Check that we are not trying to to a
 	lsign with a pre-v4 key.  Bug noticed by Thomas Roessler.
 
 2001-07-26  Werner Koch  <wk@gnupg.org>
 
 	* parse-packet.c (parse_photo_id): Reset all variables.
 	* getkey.c (merge_selfsigs_main): Removed checks on PHOTO_ID
 	because this is handled identically to a user ID.
 
 2001-07-06  Werner Koch  <wk@gnupg.org>
 
 	* cipher.c (write_header): Don't use MDC with --rfc1991.  Suggested
 	by disastry@saiknes.lv.
 
 2001-07-05  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: New option --preserve-permissions.
 	* ringedit.c (add_keyblock_resource): Use it here
 	(keyring_copy): and here.
 
 	* trustdb.c (verify_own_keys): Be more silent on --quiet.
 	Suggested by Thomas Roessler.
 	* sig-check.c (check_key_signature2): Ditto.
 	* mainproc.c (proc_encrypted, proc_tree): Ditto
 	* getkey.c (lookup): Ditto.
 
 2001-07-04  Werner Koch  <wk@gnupg.org>
 
 	* ringedit.c (add_keyblock_resource): Restore filename in case of error.
 
 2001-06-25  Werner Koch  <wk@gnupg.org>
 
 	* kbnode.c (dump_kbnode): Print the signature timestamp.
 
 	* keyedit.c (keyedit_menu): New menu point "primary".
 	(change_primary_uid_cb): New.
 	(menu_set_primary_uid): New.
 	* sign.c (update_keysig_packet): New.
 	* build-packet.c (build_sig_subpkt): Put the primary UID flag into
 	the hashed area. Allow update of some more packets.
 
 2001-06-15  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (merge_selfsigs): Exit gracefully when a secret key is
 	encountered.  May happen if a secret key is in public keyring.
 	Reported by Francesco Potorti.
 	
 2001-06-12  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (compare_name): Use ascii_memistr(), ascii_memcasecmp()
 	* keyedit.c (keyedit_menu): Use ascii_strcasecmp().
 	* armor.c (radix64_read): Use ascii_toupper().  
 	* ringedit.c (do_bm_search): Ditto.
 	* keygen.c (read_parameter_file): Ditto.
 	* openfile.c (CMP_FILENAME): Ditto.
 	* g10.c (i18n_init): We can now use just LC_ALL.
 
 2001-05-29  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (generate_subkeypair): Print a warning if a subkey is
 	created on a v3 key. Suggested by Brian M. Carlson.
 
 2001-05-27  Werner Koch  <wk@gnupg.org>
 
 	* keyid.c (get_lsign_letter): New.
 	* keylist.c (list_keyblock_colon): Use it here.
 	* mainproc.c (list_node): and here.
 
 	* getkey.c, packet.h, free-packet.c: Removed that useless key
 	created field; I dunno why I introducded this at all - the
 	creation time is always bound to the key packet and subject to
 	fingerprint calculation etc.
 
 	* getkey.c (fixup_uidnode): Add keycreated arg and use this
 	instead of the signature timestamp to calculate the
 	help_key_expire.  Bug reported by David R. Bergstein.
 	(merge_selfsigs_main): Correct key expiration time calculation.
 	(merge_selfsigs_subkey): Ditto.
 
 2001-05-25  Werner Koch  <wk@gnupg.org>
 
 	* revoke.c (gen_revoke): Add a cast to a tty_printf arg.
 	* delkey.c (do_delete_key): Ditto.
 	* keyedit.c (print_and_check_one_sig): Ditto.
 	(ask_revoke_sig): Ditto.
 	(menu_revsig): Ditto.
 	(check_all_keysigs): Removed unused arg.
 
 2001-05-23  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (opts): Typo fix by Robert C. Ames.
 
 2001-05-06  Werner Koch  <wk@gnupg.org>
 
 	* revoke.c: Small typo fix
 
 2001-05-04  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (passphrase_clear_cache): Shortcut if agent usage
 	is not enabled.
 
 2001-05-01  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (writen): Replaced ssize_t by int.  Thanks to 
 	to Robert Joop for reporting that SunOS 4.1.4 does not have it.
 
 2001-04-28  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (merge_public_with_secret): pkttype was not set to subkey.
 
 2001-04-27  Werner Koch  <wk@gnupg.org>
 
 	* skclist.c (build_sk_list): Changed one log_debug to log_info.
 
 2001-04-25  Werner Koch  <wk@gnupg.org>
 
 	* keyedit.c (show_prefs): Add a verbose mode.
 	(show_key_with_all_names): Pass verbose flag for special value of
 	with_pref.
 	(keyedit_menu): New command "showpref"
 	(show_key_with_all_names): Mark revoked uids and the primary key.
 
 2001-04-24  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (get_primary_uid): Return a different string in case of
 	error and made it translatable.
 
 	* build-packet.c (do_secret_key): Ugly, we wrote a zero
 	instead of the computed ndays.  Thanks to M Taylor for complaining
 	about a secret key import problem.
 
 2001-04-23  Werner Koch  <wk@gnupg.org>
 
 	* hkp.c (hkp_ask_import): Allow to specify a port number for the 
 	keyserver.  Add a kudge to set the no_shutdown flag.
 	(hkp_export): Ditto.
 	* options.skel: Document the changes 
 
 2001-04-20  Werner Koch  <wk@gnupg.org>
 
 	* options.skel: Add some more comments.
 
 2001-04-19  Werner Koch  <wk@gnupg.org>
 
 	* keyid.c (mk_datestr): New.  Handles negative times.  We must do
 	this because Windoze segvs on negative times passed to gmtime().
 	Changed all datestr_from function to use this one.
 
 	* keyid.c, keyid.h (colon_strtime): New. To implement the
 	fixed-list-mode.
 	(colon_datestr_from_pk): New.
 	(colon_datestr_from_sk): New.
 	(colon_datestr_from_sig): New.
 	* keylist.c (list_keyblock_colon): Use these functions here.
 	* mainproc.c (list_node): Ditto.
 
 2001-04-18  Werner Koch  <wk@gnupg.org>
 
 	* openfile.c (open_sigfile): Fixed the handling of ".sign".
 	* mainproc.c (proc_tree): Use iobuf_get_real_fname.
 	Both are by Vincent Broman.
 
 2001-04-14  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (fixup_uidnode): Removed check for !sig which is
 	pointless here.  Thanks to Jan Niehusmann.
 
 2001-04-10  Werner Koch  <wk@gnupg.org>
 
 	* sig-check.c (check_key_signature2): Use log_info instead of
 	log_error so that messed up keys do not let gpg return an error.
 	Suggested by Christian Kurz.
 
 	* getkey.c (merge_selfsigs_main): Do a fixup_uidnode only if we
 	have both, uid and sig.  Thanks to M Taylor.
 
 2001-04-05  Werner Koch  <wk@gnupg.org>
 
 	* armor.c (unarmor_pump_new,unarmor_pump_release): New.
 	(unarmor_pump): New. 
 	* pipemode.c (pipemode_filter): Use the unarmor_pump to handle
 	armored or non-armored detached signatures.  We can't use the
 	regular armor_filter becuase this does only chack for armored
 	signatures the very first time.  In pipemode we may have a mix of
 	armored and binary detached signatures.
 	* mainproc.c (proc_tree): Do not print the "old style" notice when
 	this is a pipemode processes detached signature.
 	(proc_plaintext): Special handling of pipemode detached sigs.
 
 	* packet.h (CTRLPKT_PLAINTEXT_MARK): New.
 	* parse-packet.c (create_gpg_control): New.
 	* kbnode.c (dump_kbnode): Support it here.
 	* mainproc.c (check_sig_and_print): Fixed the check for bad
 	sequences of multiple signatures.
 	(proc_plaintext): Add the marker packet.
 	(proc_tree): We can now check multiple detached signatures.
 
 2001-04-02  Werner Koch  <wk@gnupg.org>
 
 	The length of encrypted packets for blocksizes != 8 was not
 	correct encoded.  I think this is a minor problem, because we
 	usually use partial length packets.  Kudos to Kahil D. Jallad for
 	pointing this out.
 	* packet.h: Add extralen to PKT_encrypted.
 	* cipher.c (write_header): Set extralen.
 	* build-packet.c (do_encrypted): Use extralen instead of const 10.
 	(do_encrypted_mdc): Ditto.
 	* parse-packet.c (parse_encrypted): Set extralen to 0 because we
 	don't know it here.
 
 2001-03-30  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (premerge_public_with_secret): Changed wording an add
 	the keyID to the info message.
 
 2001-03-29  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (premerge_public_with_secret): Use log_info instead of
 	log_error when no secret key was found for a public one.
 	Fix the usage if the secret parts of a key are not available.
 
 	* openfile.c (ask_outfile_name): Trim spaces.
 	(open_outfile): Allow to enter an alternate filename.  Thanks to
 	Stefan Bellon.
 	* plaintext.c (handle_plaintext): Ditto.
 
 2001-03-28  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (do_check_sig): Allow direct key and subkey
 	revocation signature.
 	* sig-check.c (check_key_signature2): Check direct key signatures.
 	Print the signature class along with an error.
 
 2001-03-27  Werner Koch  <wk@gnupg.org>
 
 	* packet.h: Add a missing typedef to an enum.  Thanks to Stefan Bellon.
 
 	* g10.c: New option --no-sig-create-check.
 	* sign.c (do_sign): Implement it here.
 	* g10.c: New option --no-sig-cache.
 	* sig-check.c (check_key_signature2): Implement it here.
 	(cache_selfsig_result): and here.
 
 	* keylist.c (list_keyblock): Removed debugging stuff.
 
 	* getkey.c (cache_public_key): Made global.
 	* keygen.c (write_selfsig, write_keybinding): Cache the new key.
 
 	* getkey.c (key_byname): Add new arg secmode and changed all
 	callers to request explicitly the mode.  Deriving this information
 	from the other supplied parameters does not work if neither pk nor
 	sk are supplied.
 
 2001-03-25  Werner Koch  <wk@gnupg.org>
 
 	* packet.h (ctrlpkttype_t): New.
 	* mainproc.c (add_gpg_control,proc_plaintext,proc_tree): Use the
 	new enum values.
 	* pipemode.c (make_control): Ditto.
 	* armor.c (armor_filter): Ditto.
 
 2001-03-24  Werner Koch  <wk@gnupg.org>
 
 	* sign.c (do_sign): Verify the signature right after creation.
 
 2001-03-23  Werner Koch  <wk@gnupg.org>
 
 	* status.c, status.h (STATUS_UNEXPECTED): New.
 	* mainproc.c (do_proc_packets): And emit it here.
 
 2001-03-21  Werner Koch  <wk@gnupg.org>
 
 	* status.c: Add sys/types.h so that it runs on Ultrix.  Reported
 	by Georg Schwarz.x
 
 	* build-packet.c (build_sig_subpkt): Fixed generaton of packet
 	length header in case where 2 bytes headers are needed.  Thanks to
 	Piotr Krukowiecki.
 
 2001-03-19  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): the default keyring is no always used unless
 	--no-default-keyring is given.  
 
 	* ringedit.c (add_keyblock_resource): invalidate cache after file
 	creation.
 
 2001-03-15  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (ask_algo): Changed the warning of the ElGamal S+E Algo.
 
 	* keylist.c (print_capabilities): New.
 	(list_keyblock_colon): and use it here.
 
 2001-03-13  Werner Koch  <wk@gnupg.org>
 
 	* main.c, options.h: New option --fixed_list_mode.
 	* keylist.c (list_keyblock_colon): use it here.
 
 	* getkey.c (merge_keys_and_selfsig): Divert merging of public keys
 	to the function used in key selection..
 	* keylist.c (is_uid_valid): Removed.
 	(list_keyblock): Splitted into ..
 	(list_keyblock_print, list_keyblock_colon): .. these.
 	functions.  Changed them to use the flags set in the key lookup code.
 	(reorder_keyblock): New, so that primary user IDs are listed first.
 
 	* ringedit.c (keyring_copy): flush the new iobuf chaces before
 	rename or remove operations.  This is mainly needed for W32.
 
 	* hkp.c [HAVE_DOSISH_SYSTEM]: Removed the disabled code because we
 	have now W32 socket support in ../util/http.c
 
 	* skclist.c (key_present_in_sk_list): New.
 	(is_duplicated_entry): New.
 	(build_sk_list): Check for duplicates and do that before unlocking.
 
 2001-03-12  Werner Koch  <wk@gnupg.org>
 
 	* armor.c (parse_header_line): Removed double empty line check.
 	(parse_header_line): Replaced trim_trailing_ws with a counting
 	function so that we can adjust for the next read.
 
 	* options.skel: Fixed 3 typos. By Thomas Klausner. Replaced the
 	keyserver example by a better working server. 
 
 	* parse-packet.c (parse_symkeyenc): Return Invalid_Packet on error.
 	(parse_pubkeyenc): Ditto.
 	(parse_onepass_sig): Ditto.
 	(parse_plaintext): Ditto.
 	(parse_encrypted): Ditto.
 	(parse_signature): Return error at other places too.
 	(parse_key): Ditto.
 	* g10.c (main): Set opt.list_packets to another value when invoked
 	with the --list-packets command.
 	* mainproc.c (do_proc_packets): Don's stop processing when running
 	under --list-packets command.
 
 	* signal.c (do_sigaction): Removed.
 	(init_one_signal): New to replace the above.  Needed to support
 	systems without sigactions. Suggested by Dave Dykstra.
 	(got_fatal_signal,init_signals): Use the above here. 
 	(do_block): Use sigset() if sigprocmask() is not available.
 
 	* armor.c (parse_hash_header): Test on TIGER192, which is the
 	correct value as per rfc2440.  By Edwin Woudt.
 
 2001-03-08  Werner Koch  <wk@gnupg.org>
 
 	* misc.c: Include time.h. By James Troup.
 
 	* getkey.c: Re-enabled the unknown user Id and PK caches and
 	increased their sizes.
 
 	* getkey.c (merge_selfsigs_main): Set expire date and continue
 	processing even if we found a revoked key.
 	(merge_selfsigs_subkeys): Ditto.
 	
 	* packet.h: Add an is_revoked flag to the user_id packet.
 	* getkey.c (fixup_uidnode): Set that flag here.
 	(merge_selfsigs_main): Fix so that the latest signature is used to
 	find the self-signature for an UID.
 	* parse-packet.c (parse_user_id): Zero out all fields.
 	* mainproc.c (check_sig_and_print): Print the primary user ID
 	according the the node flag and then all other non-revoked user IDs.
 	(is_uid_revoked): Removed; it is now handled by the key selection code.
 	
 	Changed the year list of all copyright notices.
 	
 2001-03-07  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (finish_lookup): Print an info message only in verbose mode.
 
 2001-03-05  Werner Koch  <wk@gnupg.org>
 
 	* packet.h: Replaced sigsubpkt_t value 101 by PRIV_VERIFY_CACHE.
 	We have never used the old value, so we can do this without any harm.
 	* parse-packet.c (dump_sig_subpkt): Ditto.
 	(parse_one_sig_subpkt): Parse that new sub packet.
 	* build-packet.c (build_sig_subpkt): Removed the old one from the
 	hashed area.
 	(delete_sig_subpkt): New.
 	(build_sig_subpkt): Allow an update of that new subpkt.
 	* sig-check.c (check_key_signature2): Add verification caching
 	(cache_selfsig_result): New.
 	* export.c (do_export_stream): Delete that sig subpkt before exporting.
 	* import.c (remove_bad_stuff): New.
 	(import): Apply that function to all imported data 
 
 2001-03-03  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c: Introduced a new lookup context flag "exact" and used 
 	it in all place where we once used primary.
 	(classify_user_id2): Replaced the old function and add an extra
 	argument to return whether an exact keyID has been requested.
 	(key_byname): Removed the unused ctx.primary flag
 	(get_seckey_byname2): Ditto.
 	(finish_lookup): Changed debugging output.
 
 2001-03-02  Werner Koch  <wk@gnupg.org>
 
 	* keylist.c (list_one): Remove the merge key calls. 
 
 2001-03-01  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (finish_lookup): Don't use it if we no specific usage
 	has been requested.
 	(merge_selfsigs_main): fix UID only if we have an signature.
 	(lookup): Return UNU_PUBKEY etc. instead of NO_PUBKEY if we found
 	a key but the requested usage does not allow this key.
 	* import.c (import_one): Take UNU_PUBKEY into account.
 	* mainproc.c (list_node): Ditto.
 	* keylist.c (list_keyblock): Ditto.
 	* keyedit.c (print_and_check_one_sig): Ditto. 
 
 2001-02-09  Werner Koch  <wk@gnupg.org>
 
 	* delkey.c (delete_key): Removed that silly assert which rendered
 	the whole new stuff meaningless.
 
 2001-02-08  Werner Koch  <wk@gnupg.org>
 
 	* getkey.c (key_byname): It can happen that we have both, sk and pk
 	NULL, fix for that.
 
 	* parse-packet.c (parse_one_sig_subpkt): Add support for
 	primary_uid and key_flags.
 	(can_handle_critical): Ditto
 
 	* parse-packet.c (parse_encrypted): Fixed listing of pktlen for
 	MDC packets.
 
 	* getkey.c: Backported the version of this file from gpg 1.1. this
 	involved some changes in other files too.
 	* parse-packet.c (parse_key): Clear req_usage.
 	* skclist.c (build_sk_list): Use req_usage to pass the usage
 	information to the lookup function.
 	* pkclist.c (build_pk_list): Ditto.
 	* free-packet.c (copy_public_parts_to_secret_key): New.
 	* keydb.h: Add IS_* macros to check the sig_class.
 	* misc.c (openpgp_cipher_test_algo): New.
 	(openpgp_pk_test_algo): New.
 	(openpgp_pk_algo_usage): New.
 	(openpgp_md_test_algo): New.
 	* packet.h: Add a few fields to PKT_{public,secret}_key and
 	PKT_user_id.
 	* seckey-cert.c (do_check): Use the new main_keyid field.
 
 2001-02-04  Werner Koch  <wk@gnupg.org>
 
 	* encr-data.c (decrypt_data): Catch error when we had problems to
 	parse the encrypted packet. By Timo.
 
 2001-01-29  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): --batch does now set nogreeting.
 
 	* delkey.c (do_delete_key): Fixed delete-both functionality.
 
 2001-01-22  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New command --delete-secret-and-public-key.
 	* delkey.c (delete_key): Add new arg allow_both.
 	(do_delete_key): Move most stuff from above to this new function.
 
 2001-01-12  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c (passphrase_to_dek): Use MD5 when IDEA is installed
 	and we have no S2K.
 	* mainproc.c (proc_encrypted): Likewise
 
 2001-01-11  Werner Koch  <wk@gnupg.org>
 
 	* sig-check.c (do_check): Print the signature key expire message
 	only in verbose mode and added the keyID.
 
 2001-01-09  Werner Koch  <wk@gnupg.org>
 
 	* status.c, status.h: New status USERID_HINT. 
 	(write_status_text): Replace LF and CR int text by C-escape sequence.
 
 	* passphrase.c (passphrase_to_dek): Fixed the NEED_PASSPHRASE
 	output.  It does now always print 2 keyIDs.  Emit the new
 	USERID_HINT.
 
 2001-01-08  Werner Koch  <wk@gnupg.org>
 
 	* g10.c, options.h: New option --no-expensive-trust-checks.
 	* keylist.c (list_keyblock): Act on this option.
 
 2001-01-04  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Set homedir only in the pre-parsing phase and
 	replace backslashes in the W32 version.
 
 2001-01-03  Werner Koch  <wk@gnupg.org>
 
 	* status.c, status.h : New status KEY_CREATED
 	* keygen.c (do_generate_keypair,generate_subkeypair): Emit it.
 
 2000-12-28  Werner Koch  <wk@gnupg.org>
 
 	* signal.c (got_fatal_signal): Remove lockfiles here because the
 	atexit stuff does not work due to the use of raise. Suggested by
 	Peter Fales.
 	* gpgv.c (remove_lockfiles): New stub.
 	
 2000-12-19  Werner Koch  <wk@gnupg.org>
 
 	* status.c, status.h (cpr_get_no_help): New.
 	* keyedit.c (keyedit_menu): Use it here because we have our own
 	help list here.
 
 2000-12-18  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (print_failed_pkenc): Don't print the sometimes
 	confusing message about unavailabe secret key.  Renamed ...
 	(print_pkenc_list): ... to this and introduced failed arg.
 	(proc_encrypted): Print the failed encryption keys and then
 	the one to be used.
 	(proc_pubkey_enc): Store also the key we are going to use.
 
 	* mainproc.c (check_sig_and_print): Don't list revoked user IDs.
 	(is_uid_revoked): New.
 
 2000-12-08  Werner Koch  <wk@gnupg.org>
 
 	* pipemode.c: Made the command work.  Currently only for
 	non-armored detached signatures.
 	* mainproc.c (release_list): Reset the new pipemode vars.
 	(add_gpg_control): Handle the control packets for pipemode
 	* status.c, status.h: New stati {BEGIN,END}_STREAM.
 
 2000-12-07  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New option --allow-secret-key-import.
 	* import.c (import_keys,import_keys_stream): Honor this option.
 	(import): New arg allow_secret and pass that arg down to ...
 	(import_secret_one): to this and print a warning if secret key
 	importing is not allowed.
 
 2000-12-05  Werner Koch  <wk@gnupg.org>
 
 	* cipher.c (cipher_filter): Moved the end_encryption status ...
 	* encode.c (encode_simple,encode_crypt): to here
 	* sign.c (sign_file): and here.
 
 	* status.c (mywrite): Removed.
 	(get_status_string): Removed the LFs from the strings.
 	(set_status_fd,is_status_enabed,write_status_text,
 	write_status_buffer): Replaced all mywrite by stdio calls and use
 	fdopen to create a strem.  This is needed to make things smoother
 	in the W32 version.
 
 2000-12-04  Werner Koch  <wk@gnupg.org>
 
 	* import.c (merge_blocks): Increment n_sigs for revocations.
 
 2000-11-30  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): Use iobuf_translate_file_handle for all options
 	with filehandles as arguments.  This is function does some magic
 	for the W32 API.
 
 	* verify.c (verify_signatures): Add a comment rant about the
 	detached signature problem.
 	* mainproc.c (proc_tree): Issue an error if a detached signature
 	is assumed but a standard one was found.
 	* plaintext.c (hash_datafiles): Don't fall back to read signature
 	from stdin.
 	* openfile.c (open_sigfile): Print verbose message only if the
 	file could be accessed.
 
 2000-11-24  Werner Koch  <wk@gnupg.org>
 
 	* passphrase.c [HAVE_DOSISH_SYSTEM]: Disabled all the agent stuff.
 
 2000-11-16  Werner Koch  <wk@gnupg.org>
 
         * g10.c: New option --use-agent
         * passphrase.c (agent_open,agent_close): New.
         (agent_get_passphrase,agent_clear_passphrase): New.
 	(passphrase_clear_cache): New.
         (passphrase_to_dek): Use the agent here.
 	* seckey-cert.c (do_check): Clear cached passphrases.
 
 2000-11-15  Werner Koch  <wk@gnupg.org>
 
 	* status.c (write_status_text): Moved the big switch to ...
 	(get_status_string): ... new function.
 	(write_status_buffer): New.
 
 	* status.c (mywrite): New and replaced all write() by this.
 
 	* status.c, status.h: Add 3 status lcodes for notaions and policy.
 	* mainproc.c (print_notation_data): Do status output of notations.
 	
 2000-11-13  Werner Koch  <wk@gnupg.org>
 
 	* sign.c (clearsign_file): Use LF macro to print linefeed.
 	
 2000-11-11  Paul Eggert  <eggert@twinsun.com>
 
 	Clean up the places in the code that incorrectly use "long" or
         "unsigned long" for file offsets.  The correct type to use is
         "off_t".  The difference is important on large-file hosts,
         where "off_t" is longer than "long".
 
         * keydb.h (struct keyblock_pos_struct.offset):
         Use off_t, not ulong, for file offsets.
         * packet.h (dbg_search_packet, dbg_copy_some_packets,
         search_packet, copy_some_packets): Likewise.
         * parse-packet.c (parse, dbg_search_packet, search_packet,
         dbg_copy_some_packets, copy_some_packets): Likewise.
         * ringedit.c (keyring_search): Likewise.
 
         * parse-packet.c (parse): Do not use %lu to report file
         offsets in error diagnostics; it's not portable.
         * ringedit.c (keyring_search): Likewise.
 
 2000-11-09  Werner Koch  <wk@gnupg.org>
 
 	* g10.c (main): New option --enable-special-filenames.
 
 2000-11-07  Werner Koch  <wk@gnupg.org>
  
 	* g10.c (main): New command --pipemode.
 	* pipemode.c: New.
 
 2000-10-23  Werner Koch  <wk@gnupg.org>
 
 	* armor.c (armor_filter): Changed output of hdrlines, so that a CR
 	is emitted for DOS systems.
 
 	* keygen.c (read_parameter_file): Add a cast for isspace().
 
 	* status.c (myread): Use SIGINT instead of SIGHUP for DOS. 
 
 2000-10-19  Werner Koch  <wk@gnupg.org>
 
 	* g10.c: New option --ignore-crc-error
 	* armor.c (invalid_crc): New.
 	(radix64_read): Act on new option.
 
 	* openfile.c (try_make_homedir): Klaus Singvogel fixed a stupid
 	error introduced on Sep 6th. 
 
 2000-10-18  Werner Koch  <wk@gnupg.org>
 
 	* misc.c (print_cipher_algo_note): Don't print the note for AES.
 	Changed wording.
 
 2000-10-16  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (do_proc_packets): Hack to fix the problem that
 	signatures are not detected when there is a MDC packet but no
 	compression packet.
 	
 	* g10.c (print_hashline): New.
 	(print_mds): Use above func with --with-colons.
 
 	* mainproc.c (check_sig_and_print): Detect multiple signatures
 	and don't verify them.
 
 2000-10-14  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (add_onepass_sig): There is an easier solution to the
 	error fixed yesterday; just check that we only have onepass
 	packets.  However, the other solution provides an cleaner
 	interface and opens the path to get access to other information
 	from the armore headers.
 	(release_list): Reset some more variables.
 
 2000-10-13  Werner Koch  <wk@gnupg.org>
 
 	* mainproc.c (add_gpg_control): New.
 	(do_proc_packets): use it.
 	(proc_plaintext): Changed logic to detect clearsigns.
 	(proc_tree): Check the cleartext sig with some new code.
 
 	* packet.h: New packet PKT_GPG_CONTROL.
 	* parse-packet.c (parse_gpg_control): New.
 	* misc.c (get_session_marker): New.
 	* armor.c (armor_filter): Replaced the faked 1-pass packet by the
 	new control packet.
 
 	* keyedit.c (keyedit_menu): Allow batchmode with a command_fd. 
 	* status.c (my_read): New.
 	(do_get_from_fd): use it.
 
 2000-10-12  Werner Koch  <wk@gnupg.org>
 
 	* keygen.c (keygen_add_std_prefs): Add Rijndael to the prefs.
 
 2000-10-07  Werner Koch  <wk@gnupg.org>
 
 	* gpgv.c: Add more stubs for ununsed code to make the binary smaller.
 
 Wed Oct  4 15:50:18 CEST 2000  Werner Koch  <wk@openit.de>
 
         * sign.c (hash_for): New arg to take packet version in account, changed
         call callers.
 
         * gpgv.c: New.
         * Makefile.am: Rearranged source files so that gpgv can be build with
         at least files as possible.
 
 Mon Sep 18 12:13:52 CEST 2000  Werner Koch  <wk@openit.de>
 
         * hkp.c (not_implemented): Print a notice for W32
 
 Fri Sep 15 18:40:36 CEST 2000  Werner Koch  <wk@openit.de>
 
         * keygen.c (keygen_add_std_prefs): Changed order of preferences to
         twofish, cast5, blowfish.
 
         * pkclist.c (algo_available): Removed hack to disable Twofish.
 
 Thu Sep 14 17:45:11 CEST 2000  Werner Koch  <wk@openit.de>
 
         * parse-packet.c (dump_sig_subpkt): Dump key flags. Print special
         warning in case of faked ARRs.
 
         * getkey.c (finsih_lookup): Hack so that for v4 RSA keys the subkey
         is used for encryption.
 
 Thu Sep 14 14:20:38 CEST 2000  Werner Koch  <wk@openit.de>
 
         * g10.c (main): Default S2K algorithms are now SHA1 and CAST5 - this
         should solve a lot of compatibility problems with other OpenPGP
         apps because those algorithms are SHOULD and not optional.  The old
         way to force it was by using the --openpgp option whith the drawback 
         that this would disable a couple of workarounds for PGP.
 
         * g10.c (main): Don't set --quite along with --no-tty.  By Frank Tobin.
 
         * misc.c (disable_core_dump): Don't display a warning here but a return
         a status value and ...
         * g10.c (main): ...print warnining here. Suggested by Sam Roberts.
 
 Wed Sep 13 18:12:34 CEST 2000  Werner Koch  <wk@openit.de>
 
         * keyedit.c (keyedit_menu): Allow to use "debug" on the secret key.
 
         * ringedit.c (cmp_seckey): Fix for v4 RSA keys.
         * seckey-cert.c (do_check): Workaround for PGP 7 bug.
 
 Wed Sep  6 17:55:47 CEST 2000  Werner Koch  <wk@openit.de>
 
         * misc.c (print_pubkey_algo_note): Do not print the RSA notice.
         * sig-check.c (do_signature_check): Do not emit the RSA status message.
         * pubkey-enc.c (get_session_key): Ditto.
 
         * encode.c (encode_simple, encode_crypt): Fix for large files.
         * sign.c (sign_file): Ditto.
 
 Wed Sep  6 14:59:09 CEST 2000  Werner Koch  <wk@openit.de>
 
         * passphrase.c (hash_passphrase): Removed funny assert.  Reported by
         David Mathog.
 
         * openfile.c (try_make_homedir): Changes for non-Posix systems.
         * g10.c (main): Take the default homedir from macro.
 
         * g10.c: The --trusted-key option is back.
         * trustdb.c (verify_own_key): Handle this option.
         (add_ultimate_key): Moved stuff from verify_own_key to this new func.
         (register_trusted_key): New.
 
 Fri Aug 25 16:05:38 CEST 2000  Werner Koch  <wk@openit.de>
 
         * parse-packet.c (dump_sig_subpkt): Print info about the ARR.
 
         * openfile.c (overwrite_filep): Always return okay if the file is
         called /dev/null. 
         (make_outfile_name): Add ".sign" to the list of know extensions.
         (open_sigfile): Ditto.
 
 Wed Aug 23 19:52:51 CEST 2000  Werner Koch  <wk@openit.de>
 
         * g10.c: New option --allow-freeform-uid. By Jeroen C. van Gelderen.
         * keygen.c (ask_user_id): Implemented here.
 
 Fri Aug  4 14:23:05 CEST 2000  Werner Koch  <wk@openit.de>
 
   * status.c (do_get_from_fd): Ooops, we used fd instead of opt.command_fd.
   Thanks to Michael Tokarev.
 
 Tue Aug  1 20:06:23 CEST 2000  Werner Koch  <wk@openit.de>
 
   * g10.c: New opttion --try-all-secrets on suggestion from Matthias Urlichs.
   * pubkey-enc.c (get_session_key): Quite easy to implement here.
 
 Thu Jul 27 17:33:04 CEST 2000  Werner Koch  <wk@openit.de>
 
   * g10.c: New option --merge-only.  Suggested by Brendan O'Dea.
   * import.c (import_one): Implemented it here
   (import_secret_one): Ditto.
   (print_stats): and give some stats.
 
 Thu Jul 27 12:01:00 CEST 2000  Werner Koch  <wk@openit.de>
 
   * g10.c: New options --show-session-key and --override-session-key
   * pubkey-enc.c (hextobyte): New.
   (get_override_session_key): New.
   * mainproc.c (proc_pubkey_enc): Add session-key stuff.
   * status.h, status.c (STATUS_SESSION_KEY): New.
 
 Thu Jul 27 10:02:38 CEST 2000  Werner Koch  <wk@openit.de>
 
   * g10.c (main): Use setmode(O_BINARY) for MSDOS while generating random bytes
   (print_mds): Likewise for stdin.
   * plaintext.c (handle_plaintext): Likewise for stdout.
 
 Mon Jul 24 10:30:17 CEST 2000  Werner Koch  <wk@openit.de>
 
   * keyedit.c (menu_expire): expire date for primary key can be set again.
 
 Wed Jul 19 11:26:43 CEST 2000  Werner Koch  <wk@openit.de>
 
   * keylist.c (is_uid_valid): New.
   (list_keyblock): Print validity information for all user IDs.  Note, this
   has to be done at other places too; for now we have only minimal support.
 
 Wed Jul 12 13:32:06 CEST 2000  Werner Koch  <wk@openit.de>
 
   * helptext.c, pkclist.c: s/superseeded/superseded/
 
 Mon Jul 10 16:08:57 CEST 2000  Werner Koch  <wk@openit.de>
 
   * parse-packet.c (enum_sig_subpkt): Fixed testing on crtitical bit in case
   of a NULL buffer.  Reported by Peter Marschall.
 
 Wed Jul  5 13:28:45 CEST 2000  Werner Koch  <wk@openit.de>
 
   * keyedit.c, keyid.c: Add some _()
 
   * argparse.c:  Changed the flag to suppress --version handling to also
   suppress --help.
 
 Wed Jun 28 11:54:44 CEST 2000  Werner Koch  <wk@openit.de>
 
   * armor.c (armor_filter): Set sigclass to 0 in case of non-dash-escaped
   clearsig.  This makes this mode work again.
 
   * mainproc.c (proc_tree): Fixed handling of one-pass-sig packets in textmode.
   Disabled the ugly workaround for PGP 5 - let's see whether thi breaks less
   cases. Found by Ted Cabeen.
 
   * options.h (DBG_HASHING): New.  All commented md_start_debug are now
   controlled by this debug option.
 
   * sign.c (print_status_sig_created): New and called from 2 places.
 
   * keygen.c (gen_rsa): New, but commented.
   (ask_algo): Commented support for RSA.
 
   * seckey-cert.c (protect_secret_key): Started to fix the code for v4 RSA
   keys - it is not solved yet. However, we have time until, Sep 20th ;)
 
 Wed Jun 14 12:27:09 CEST 2000  Werner Koch  <wk@openit.de>
 
   * status.c (init_shm_coprocessing): Changed the sequence of the get,attach
   to cope with the changes in newer Linux kernels.  This bug has been found
   by <dmitri@advantrix.com> who also proposed this solution.  Hopefully
   this does not break gpg on to many systems.
 
   * cipher.c (write_header): Protect the IV with the MDC too.
   * encr-data.c (decrypt_data): Likewise.
 
 Fri Jun  9 10:09:52 CEST 2000  Werner Koch  <wk@openit.de>
 
   * g10.c: New options --no-auto-key-retrieve
   * options.h (auto_key_retrieve): New.
   * mainproc.c (check_sig_and_print): Implemented that.
 
 Wed Jun  7 19:19:09 CEST 2000  Werner Koch  <wk@openit.de>
 
   * sig-check.c (do_check): Use EMULATE_MDENCODE also on v4 packets.
 
 Wed Jun  7 17:25:38 CEST 2000  Werner Koch  <wk@openit.de>
 
   * cipher.c (write_header): Use plain CFB mode for MDC encrypted packets.
   * encr-data.c (decrypt_data): Ditto.
 
 Mon Jun  5 23:41:54 CEST 2000  Werner Koch  <wk@openit.de>
 
   * seskey.c (do_encode_md, encode_md_value): Add new arg v3compathack to work
   around a bug in old versions.
   * sig-check.c (do_check): use the aboved workaround when enabled.
   * g10.c: New option --emulate-md-decode-bug
 
 Mon Jun  5 12:37:43 CEST 2000  Werner Koch  <wk@openit.de>
 
   * build-packet.c (do_mdc): New.
   (do_encrypted_mdc): Changed for the new proposal.
   * parse-packet.c (parse_mdc): New.
   (parse_encrypted): Fixed for the new proposal.
   * packet.h (PKT_MDC): New.
   * cipher.c (cipher_filter): Build the MDC packet here.
   * g10.c (main): Enable --force-mdc.
   * encr-data.c (mdc_decode_filter): Fixed for new MDC method
 
   * options.h(rfc2440): New.
   * g10.c (main): Changed the selected values for --openpgp to not include
   optional algorithms.
 
 Thu May 18 11:38:54 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* keyedit.c (keyedit_menu): Add a keyword arg to the prompt.
 
 	* status.c, status.h: Added 3 new status tokens.
 	* status.c (do_get_from_fd): New.
 	(cpr_enabled,cpr_get,cpr_get_hidden,cpr_kill_prompt,
 	 cpr_get_answer_is_yes,cpr_get_answer_yes_no_quit): Modified to work
 	 with the new function.
 	* g10.c: Add new option --command-fd.
 
 	* status.c (progress_cb): New.
 	(set_status_fd): Register progress functions
 
 Fri May 12 14:01:20 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* delkey.c (delete_key): Add 2 new status messages
 	* status.c, status.h (STATUS_DELETE_PROBLEM): New.
 
 	Fixed years of copyright in all source files.
 
 Mon May  1 17:08:14 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* trustdb.c (propagate_validity): Fixed the bug that only one uid
 	gets fully trusted even when all are signed by an ultimate key.
 
 Mon May  1 15:38:04 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* getkey.c (key_byname): Always returned a defined context.  Fixed
 	a segv for invalid user id specifications. Reported by Walter Koch.
 
 	* getkey.c (get_user_id): I18ned "no user id" string. By Walter.
 
 	* pkclist.c (do_show_revocation_reason): Typo fixes.
 	* helptext.c: Ditto.
 
 	* armor.c (armor_filter): Fixed some CRLF issues.  By Mike McEwan.
 
 Fri Apr 14 19:37:08 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* pkclist.c (do_show_revocation_reason): New.
 	(show_revocation_reason): New and called at various places.
 
 	* g10.c (main): Fixed small typo.
 
 	* pkclist.c (do_we_trust): Act on always_trust but not for revoked
 	keys. Suggested by Chip Salzenberg.
 
 	* g10.c: New option --lock-never.
 
 	* ringedit.c (get_writable_keyblock_file): New.
 	* keygen.c (do_generate_keypair): Use this instead of the hardwired one.
 
 	* keygen.c (ask_user_id): Check that the email address is in the
 	correct field.	Suggested by Christian Kurz.
 
 Mon Apr 10 13:34:19 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* keyedit.c (show_key_with_all_names): s/sbb/ssb/
 
 Tue Mar 28 14:26:58 CEST 2000  Werner Koch  <wk@openit.de>
 
 	* trustdb.c (verify_own_keys): Do not print warning about unprotected
 	key when in quiet mode.
 
 Wed Mar 22 13:50:24 CET 2000  Werner Koch  <wk@openit.de>
 
 	* mainproc.c (print_userid): Do UTF8 conversion before printing.
 	* import.c (import_one): Ditto.
 	(import_secret_one): Ditto.
 	(delete_inv_parts): Ditto.
 
 Thu Mar 16 16:20:23 CET 2000  Werner Koch  <wk@openit.de>
 
 	* keylist.c (print_key_data): Handle a NULL pk gracefully.
 
 	* getkey.c (merge_one_pk_and_selfsig): Fixed silly code for
 	getting the primary keys keyID but kept using the one from the
 	subkey.
 	* pubkey-enc.c (get_it): Print a note for expired subkeys.
 
 	* getkey.c (has_expired): New.
 	(subkeys_expiretime): New.
 	(finish_lookup): Check for expired subkeys needed for encryption.
 	(merge_keys_and_selfsig): Fixed expiration date merging for subkeys.
 
 	* keylist.c (list_keyblock): Print expiration time for "sub".
 	(list_one): Add missing merging for public keys.
 	* mainproc.c (list_node): Ditto.
 
 2000-03-14 13:49:38  Werner Koch  (wk@habibti.openit.de)
 
 	* keygen.c (keyedit_menu): Do not allow to use certain commands
 	while the secret key is selected.
 
 2000-03-09 12:53:09  Werner Koch  (wk@habibti.openit.de)
 
 	* keygen.c (ask_expire_interval): Movede parsig to ...
 	(parse_expire_string): ... this new function. And some new control
 	commands.
 	(proc_parameter_file): Add expire date parsing.
 	(do_generate_keypair): Allow the use of specified output files.
 
 2000-03-08 10:38:38  Werner Koch  (wk@habibti.openit.de)
 
 	* keygen.c (ask_algo): Removed is_v4 return value and the commented
 	code to create Elg keys in a v3 packet. Removed the rounding
 	of key sizes here.
 	(do_create): Likewise removed arg v4_packet.
 	(gen_elg): Likewise removed arg version. Now rounding keysizes here.
 	(gen_dsa): Rounding keysize now here.
 	(release_parameter_list): New
 	(get_parameter*): New.
 	(proc_parameter_file): New.
 	(read_parameter_file): New.
 	(generate_keypair): Splitted. Now uses read_parameter_file when in
 	batch mode.  Additional argument to specify a parameter file.
 	(do_generate_keypair): Main bulk of above fucntion and uses the
 	parameter list.
 	(do_create): Don't print long notice in batch mode.
 	* g10.c (main): Allow batched key generation.
 
 Thu Mar  2 15:37:46 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* pubkey-enc.c (get_it): Print a note about unknown cipher algos.
 
 	* g10.c (opts): Add a note to the help listing about the man page
 	and removed some options from the help listing.
 
 	* keyedit.c (print_and_check_one_sig): Use a new function to truncate
 	the output of the user ID.  Suggested by Jan-Benedict Glaw.
 
 Wed Feb 23 10:07:57 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* helptext.c: typo fix.
 
 Thu Feb 17 13:39:32 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* revoke.c: Removed a bunch of commented code.
 
 	* packet.h (SIGSUBPKT_REVOC_REASON): New.
 	* build-packet.c (build_sig_subpkt): Support new sub packet.
 	* parse-packet.c (parse_one_sig_subpkt): Ditto.
 	(dump_sig_subpkt): Ditto.
 	* revoke.c (ask_revocation_reason): New.
 	(release_revocation_reason_info): New.
 	(revocation_reason_build_cb): New.
 	(gen_revoke): Ask for reason.
 	* main.h (struct revocation_reason_info): Add declaration.
 	* keyedit.c (menu_revsig): Add support for revocation reason.
 	(menu_revkey): Ditto.
 	(sign_uid_mk_attrib): Renamed to ...
 	(sign_mk_attrib): ... this, made static and add support for reasons.
 
 Tue Feb 15 08:48:13 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* build-packet.c (build_packet): Fixed fixing of old comment packets.
 
 	* import.c (import_keys): Fixed importing from stdin when called with
 	nnames set to zero as it normally happens.
 
 Mon Feb 14 14:30:20 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* sig-check.c (check_key_signature2): Add new arg r_expired.
 	(do_signature_check): New arg to pass it down to ...
 	(do_check): New arg r-expire which is set when the signature
 	has expired.
 	* trustdb.c (check_sig_record): Set SIGF_EXPIRED flag and set
 	the expiretime to zero so that thi signature will not be checked
 	anymore.
 
 Fri Feb 11 17:44:40 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* g10.c (g10_exit): Update the random seed_file.
 	(main): Set the random seed file.  New option --no-random-seed-file.
 
 Thu Feb 10 17:39:44 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* keyedit.c (menu_expire): Fixed segv due to unitialized sub_pk.
 	By R�mi.
 
 Thu Feb 10 11:39:41 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* keylist.c (list_keyblock): Don't print warnings in the middle of
 	regulat output lines.  By R�mi.
 
 	* sig-check.c: Include options.h
 
 Wed Feb  9 15:33:44 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* gpg.c: New option --ignore-time-conflict
 	* sig-check.c (do_check): Implemented this option.
 	* trustdb.c (check_trust): Ditto.
 	* sign.c (do_sign): Ditto.
 	* keygen.c (generate_subkeypair): Ditto.
 
 	* encode.c (encode_simple): use iobuf_cancel after open failure.
 	Reported by Huy Le.
 
 Fri Jan 14 18:32:01 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* packet.h (STRING2KEY): Changed mode from byte to int.
 	* parse-packet.c (parse_key): Add the special GNU protection stuff
 	* build-packet.c (so_secret_key): Ditto.
 	* seckey-cert.c (do_check): Ditto.
 	* keyedit.c (change_passphrase): Ditto.
 	* export.c (export_secsubkeys): New.
 	(do_export_stream): Hack to export the primary key using mode 1001.
 	* g10.c: New command --export-secret-subkeys
 
 Thu Jan 13 19:31:58 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* armor.c (is_armored): Check for 1-pass-sig packets. Reported by
 	David Hallinan <hallinan@rtd.com>.
 	(armor_filter): Replaced one LF by the LF macro.  Reported by
 	Wolfgang Redtenbacher.
 
 Wed Jan  5 11:51:17 CET 2000  Werner Koch  <wk@gnupg.de>
 
 	* g10.c (main): Reset new global flag opt.pgp2_workarounds
 	when --openpgp is used.
 	* mainproc.c (proc_plaintext): Do the PGP2,5 workarounds only
 	when the global flag is set.
 	(proc_tree): Ditto.
 	* textfilter.c (copy_clearsig_text): Ditto.
 	* armor.c (armor_filter): Ditto.
 
 	* g10.c: New option --list-only
 	* mainproc.c (proc_tree): Don't do it if opt.list_only is active.
 	(proc_pubkey_enc): Implement option.
 
 	* status.h, status.c ({BEGIN,END}_{EN,DE}CRYPTION): New.
 	* cipher.c (cipher_filter): New status outputs.
 	* mainproc.c (proc_encrypted): New status outputs.
 
 Fri Dec 31 14:08:15 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* armor.c (armor_filter): Made the "Comment:" header translatable.
 
 	* hkp.c (hkp_import): Make sure that the program does not return
 	success when there is a connection problem.  Reported by Phillip Jones.
 
 Sun Dec 19 15:22:26 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* armor.c (LF): Use this new macro at all places where a line LF
 	is needed.  This way DOSish textfiles should be created when the
 	input data is also in dos mode.
 	* sign.c (LF): Ditto.
 	* textfilter.c (LF): Ditto.
 	(copy_clearsig_text): Disabled the forcing of CR,LF sequences
 	for DOS systems.
 
 	* plaintext.c (handle_plaintext): Fixes for line endings on DOS.
 	and react on a LF in cleartext.
 	* armor.c (fake_packet): Restore the original line ending after
 	removing trailing spaces.
 
 	* signal.c (got_fatal_signal): DOS fix.
 
 Thu Dec 16 10:07:58 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* mainproc.c (print_failed_pkenc): Fix for unknown algorithm.
 	Found by fygrave@epr0.org.
 
 Thu Dec  9 10:31:05 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* hkp.c: i18n the strings.
 
 Sat Dec  4 15:32:20 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* trustdb.c (verify_key): Shortcut for ultimately trusted keys.
 
 Sat Dec  4 12:30:28 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* pkclist.c (build_pk_list): Validate the trust using the namehash
 	if this one has been set by the key lookup.
 
 	* g10.c: Add --delete-secret-key to the help page.
 
 	* openfile.c (copy_options_file): Made static.
 	(try_make_homedir): New.
 	* ringedit.c (add_keyblock_resource): Use the try_make_hoemdir logic.
 	* tdbio.c (tdbio_set_dbname): Likewise.
 
 	* keygen.c (generate_user_id): Use m_alloc_clear() here. We should
 	better use an allocation function specific to the user_id packet.
 
 	* keygen.c (keygen_add_std_prefs): Changed symmetric preferences
 	to include Blowfish again.  This is due to it's better speed compared
 	to CAST5.
 
 	* g10.c (strusage): Print the home directory.
 
 	* armor.c (armor_filter): Take action on the cancel control msg.
 	* filter.h (armor_filter_context_t): Add cancel flag.
 
 Mon Nov 29 21:52:11 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* g10.c: New option --fast-list-mode ..
 	* keylist.c (list_keyblock): .. and implemented.
 	* mainproc.c (list_node): Ditto.
 
 	* import.c (mark_non_selfsigned_uids_valid): Fixed the case that there
 	is a uid without any packet following.
 
 Mon Nov 22 11:14:53 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* mainproc.c (proc_plaintext): Never enable the hash processing
 	when skip_verify is active.
 
 	* armor.c (parse_header_line): Stop parsing on a WS line too.
 	Suggested by Aric Cyr.
 
 	* tdbdump.c (HEXTOBIN): Changed the name of the argument, so that
 	traditional cpp don't mess up the macros. Suggested by Jos Backus.
 
 	* mainproc.c (list_node): Print the PK algo in the --with-colon mode.
 	* keylist.c (list_keyblock): Ditto.
 
 	* signal.c (got_fatal_signal): Found the reason why exit(8) did not
 	work - it is better to set the disposition back to default before
 	raising the signal.  Print the notice on stderr always.
 
 Fri Nov 12 20:33:19 CET 1999  Werner Koch  <wk@gnupg.de>
 
 	* g10.c (make_username): Swapped the logic.
 	* keylist.c (public_key_list): Now takes a STRLIST as arg and moved
 	the creation ot this list to the caller, so that he can copy with
 	UTF-conversion of user IDs.  Changed all callers.
 	(secret_key_list): Likewise.
 
 	* getkey.c (get_user_id_string_native): New and ...
 	* encode.c (write_pubkey_enc_from_list): ... use it here.
 
 	* pubring.asc: Updated.
 
 	* packet.h (PKT_PHOTO_ID): New.
 	* parse-packet.c (parse_photo_id): New.
 	* build-packet.c (do_user_id: Handle photo IDs.
 	(build_packet): Change CTB for photo IDs
 	* free-packet.c (free_user_id): Release memory used for photo IDs
 	* sig-check.c (hash_uid_node): Handle photo IDs too.
 	* trustdb.c (print_uid_from_keyblock): Hash photo ID.
 	(make_uid_records): Ditto.
 	* getkey.c (find_by_name): Ditto.
 	* keyedit.c (show_prefs): Ditto.
 	* keylist.c (list_keyblock): Ditto.
 
 Thu Oct 28 16:08:20 CEST 1999  Werner Koch  <wk@gnupg.de>
 
 	* keygen.c (ask_expire_interval): Print a warning for systems
 	with a signed 32 time_t if the exiration time is beyoind 2038.
 
 Fri Oct  8 20:40:50 CEST 1999  Werner Koch  <wk@gnupg.de>
 
 	* ringedit.c (enum_keyblocks): The last fix way really stupid;
 	reverted and set rt to Unknown.
 
 Fri Oct  8 20:32:01 CEST 1999  Werner Koch  <wk@gnupg.de>
 
 	* ringedit.c (enum_keyblocks): Zero the entire kbpos out on open.
 
 	* g10.c (oEntropyDLL): Removed option.
 	(main): Made the warning on development versions more verbose.
 
 	* g10.c (oHonorHttpProxy): New option.
 	* hkp.c (hkp_ask_import,hkp_export): Implement this option.
 	* options.skel: Enable this option for new installations
 
 Mon Oct  4 21:23:04 CEST 1999  Werner Koch  <wk@gnupg.de>
 
 	* import.c (import_keys): Changed calling interface, adjusted caller.
 	(import): Moved printing of stats out ...
 	(print_stats): New. ... to here.
 	(import_keys_stream): Call stats print here.
 	(import_keys): Print stats as totals for all files.
 
 	* tdbio.h (DIRF_NEWKEYS): New
 	* tdbio.c (tdbio_dump_record): Print the new flag.
 	* trustdb.c (check_trust_record): New arg sigs_only.  Adapted all
 	callers.
 	(do_update_trust_record): Removed recheck arg and add a new sigs_only
 	do we can later improve on the performance.  Changed all callers too.
 	(check_trustdb): Evalutate the new flag and add a status output.
 	Do a check when the dir record has not been checked.
 	(build_cert_tree): Evaluate the new flag.
 	(check_trust): Ditto.  Do a trust_record check, when the dir record
 	is not marked as checked.
 	(mark_fresh_keys): New.
 	(clear_lid_table): New.
 	(sync_trustdb): New.
 	* import.c (import_keys): Call sync_trustdb() after processing.
 	(import_keys_stream): Ditto.
 	* tdbdump.c (import_ownertrust): Ditto.
 
 	* import.c (import_revoke_cert): Notify the trust DB.
 	(do_update_trust_record): Use |= to set the REVOKED bit and not &=;
 	shame on me for this bad copy+paste introduced bug.
 	(do_we_trust): Add trustmask to allow revoked key override to work.
 	Chnaged are to allow return of a mofified trustlevel. Adapted the
 	one caller.
 
 	* g10.c: New options --emulate-3des-s2k-bug
 	* passphrase.c (hash_passphrase): Implemented above.
 
 	* mainproc.c (proc_tree): Check for standalone signatures.
 	(do_check_sig): Print a notice for a standalone revocation
 	(check_sig_and_print): Do not print an error for unchecked standalone
 	revocations.
 
 Tue Sep 28 20:54:37 CEST 1999  Werner Koch  <wk@gnupg.de>
 
 	* encode.c (encode_simple): Use new CTB when we don't have the
 	length of the file.  This is somewhat strange as the comment above
 	indicates that this part is actually fixed for PGP 5 - maybe I simply
 	lost the source line, tsss.
 
 	* armor.c (armor_filter): Set a flag if no OpenPGP data has been found.
 	* verify.c (verify_signatures): Add an error helptext.
 
 Thu Sep 23 19:24:30 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* openfile.c (open_outfile): Fixed the 8dot3 handling.
 
 	* passphrase.c (passphrase_to_dek): Print uid using utf8 func.
 	* delkey.c (delete_key): Ditto.
 	* pkclist.c (show_paths,do_edit_ownertrust,do_we_trust): Ditto
 	(do_we_trust_pre): Ditto.
 	* trustdb.c (print_user_id,check_uidsigs): Ditto.
 	* revoke.c (gen_revoke,ask_revoke_sig): Ditto.
 
 Thu Sep 23 09:52:58 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* verify.c (print_file_status): New.
 	(verify_one_file): Moved status print to th new fnc. Add error status.
 	* status.c, status.h (STATUS_FILE_ERROR): New
 
 Wed Sep 22 10:14:17 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* openfile.c (make_outfile_name): Use case-insenstive compare for
 	DOS systems.  Add ".pgp" to the list of know extensions.
 	(open_outfile): For DOS systems try to replace the suffiy instead of
 	appending it.
 
 	* status.c, status.h: Add STATUS_FILE_{START,DONE}.
 	* verify.c (verify_one_file): Emit these new stati.
 
 	* sign.c (clearsign_file): Avoid duplicated Entries in the "Hash:"
 	line.  Those headers are now only _not_ printed when there are
 	only old-style keys _and_ all hashs are MD5.
 
 Mon Sep 20 12:24:41 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* verify.c (verify_files, ferify_one_file): New.
 	* g10.c:  New command --verify-files
 
 Fri Sep 17 12:56:42 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c: Add UK spelling as alias for armor options ;-)
 
 	* import.c (append_uid): Fixed a SEGV when there is no selfsig and
 	no subkey.
 	(merge_sigs): Ditto.  Removed the assertion.
 
 Wed Sep 15 16:22:17 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c: New option --entropy-dll-name
 
 Mon Sep 13 10:51:29 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* signal.c (got_fatal_signal): Print message using write(2) and
 	only for development versions.
 
 Mon Sep  6 19:59:08 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* tdbio.c (tdbio_set_dbname): Use mkdir macro
 	* ringedit.c (add_keyblock_resource): Ditto.
 
 Fri Sep  3 10:04:45 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (build_pk_list): Skip keys set with --encrypt-to also
 	when asking for a key.
 
 	* plaintext.c (handle_plaintext): Make sure that we don't read a
 	second EOF in the read loop for partial length packets.
 
 	* mainproc.c (check_sig_and_print): print user ID as utf-8.
 
 Thu Sep  2 16:40:55 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* import.c (merge_blocks): First add new subkeys, then merge subkey
 	certificates.
 	(merge_sigs): Don't merge subkey signatures here.
 
 Wed Sep  1 15:30:44 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keygen.c (ask_expire_interval): Fixed bug related to cpr_xx (tnx
 	Francis J. Lacoste).
 
 Tue Aug 31 17:20:44 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* plaintext.c (do_hash): Hash CR,LF for a single CR.
 	(ask_for_detached_datafile): Changed arguments to be closer to
 	those of hash_datafiles and cleanup the code a bit.
 	* mainproc.c (proc_tree): Workaround for pgp5 textmode detached
 	signatures.  Changed behavior of asking for data file to be the same
 	as with provided data files.
 
 	* keylist.c (list_keyblock): Use UTF8 print functions.
 
 Mon Aug 30 20:38:33 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* import.c (chk_self_sigs): some s/log_error/log_info/ so that gpg
 	does not return an error if a key has some invalid packets.
 
 	* helptext.c: Fixed some typos and changed the way the
 	translation works.  The english text is now the keyword for gettext
 	and not anymore the keyword supplied to the function.  Done after
 	some discussion with Walter who thinks this is much easier for the
 	translators.
 
 	* misc.c (disable_core_dumps): Don't do it for DOSish systems.
 
 	* signal.c (signal_name): Bounds check on signum.
 
 Wed Aug  4 10:34:18 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pubring.asc: Updated.
 
 	* pkclist.c (do_we_trust_pre,check_signatures_trust): Do not print
 	the warning about --always_trust when --quiet is used.
 
 	* pkclist.c (fpr_info): New and called at several places.
 
 	* parse-packet.c (dump_sig_subpkt): List revocation key contents.
 
 Mon Jul 26 09:34:46 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (build_pk_list): Fixed typo in format string.
 
 	* trustdb.c (create_shadow_dir): Don't translate the error string.
 
 	* g10.c (main): Fixed spelling of user-id.
 	* getkey.c (find_by_name_pk,find_by_name_sk,
 	find_by_keyid,find_by_keyid_sk): Ditto and translate it.
 	* import.c (mark_non_selfsigned_uids_valid,delete_inv_parts): Ditto.
 
 
 Mon Jul 26 01:01:39 CEST 1999  Michael Roth <mroth@nessie.de>
 
 	* g10.c, options.h: New options --no-literal and --set-filesize
 
 	* encode.c (encode_simple, encode_crypt): Support for the options
 	--no-literal and --set-filesize.
 
 	* sign.c (sign_file): ditto.
 
 Fri Jul 23 13:53:03 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* ringedit.c (enum_keyblocks): Removed annoying error message in cases
 	when we have no keyring at all to enum.
 
 	* getkey.c (classify_user_id): Rewrote to relax the recognition of
 	keyIDs and fingerprints (Michael).
 
 	* mainproc.c (check_sig_and_print): Print status NO_PUBKEY.
 	(print_failed_pkenc): Print status NO_SECKEY.
 
 	* import.c (mark_non_selfsigned_uids_valid): New.
 	* g10.c: New option --allow-non-selfsigned-uid.
 
 	* pkclist.c (print_fpr): New.
 	(do_we_trust_pre): Print the fpr before asking whether to use the key
 	anyway.
 	(do_edit_ownertrust): Likewise.
 
 Thu Jul 22 20:03:03 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* ringedit.c (enum_keyblocks): Removed annoying error message in cases
 	when we have no keyring at all to enum.
 
 	* getkey.c (classify_user_id): Rewrote to relax the recognition of
 	keyIDs and fingerprints (Michael).
 
 	* mainproc.c (check_sig_and_print): Print status NO_PUBKEY.
 	(print_failed_pkenc): Print status NO_SECKEY.
 
 	* import.c (mark_non_selfsigned_uids_valid): New.
 	* g10.c: New option --allow-non-selfsigned-uid.
 
 Thu Jul 15 10:15:35 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c: New options --disable-{cipher,pubkey}-algo.
 
 Wed Jul 14 19:42:08 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* status.h (STATUS_IMPORTED): New.
 	* import.c (import): Print some status information (Holger Schurig).
 
 	* g10.c (main): Make --no-greeting work again. Add a warning when
 	--force-mds is used.
 
 Tue Jul 13 17:39:25 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (do_edit_ownertrust): Changed the way help works.
 	(build_pk_list): Implemented default recipient stuff.
 	* g10.c: New options --default-recipient[-self]
 	(main): Suppress greeting in most cases, entering a passphrase or
 	a missing value is not considered to be interactive use.
 	Merged --print-md and --print-mds; the latter is now obsolete.
 	Changed the way --gen-random works and documented it.
 	Changed the way --gen-prime works and add a man entry.
 	* g10.c (MAINTAINER_OPTIONS): Removed.
 
 Mon Jul 12 18:45:57 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keyedit.c (keyedit_menu): Add arg sign_mode and changed callers
 	* g10.c (main): New command --lsign-key.
 
 Mon Jul 12 14:55:34 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* mainproc.c (kidlist_item): New.
 	(release_list): Release failed pk-enc-list.
 	(print_failed_pkenc): New
 	(proc_encrypted): Print info about failed PK enc.
 
 	* openfile.c (make_outfile_name): s/error/info/
 
 	* passphrase.c (passphrase_to_dek): Return an empty passphrase when
 	in batch mode and don't make the warning message fatal
 	* seckey-cert.c (check_secret_key): Try only once when in batch mode.
 
 	* g10.c (make_username): New.
 
 Thu Jul  8 16:21:27 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* packet.h (PKT_ring_trust): New
 	* parse-packet.c (parse_trust): Store trust value
 	* build-packet (build_packet): Ignore ring trust packets.
 	* mainproc.c (add_ring_trust): New.
 	(list_node): Print "rtv" records.
 	* g10.c: New option --with-fingerprint.
 
 	* trustdb.c (verify_own_keys): Don't insert if we are dry running
 	(check_trust): Ditto.
 
 Wed Jul  7 13:08:40 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* Makefile.am: Support for libtool.
 
 	* keygen.c (ask_expire_interval): Hack to allow for an expire date.
 
 	* trustdb.c (do_update_trust_record,update_trust_record): Splitted.
 	(check_trust_record): New.
 	(check_trust,build_cert_tree): Check the dir record as needed.
 	(upd_pref_record): Removed.
 	(make_pref_record): New.
 	(propagate_validity): Stop as soon as we have enough validity.
 
 	* tbdio.c (MAX_CACHE_ENTRIES_HARD): Increased the limit.
 
 
 Fri Jul  2 11:45:54 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (g10_exit): Dump random stats.
 
 	* sig-check.c (check_key_signature,check_key_signature2): Enhanced
 	version and wrapper for old function.
 	(do_signature_check,signature_check): Ditto.
 
 Thu Jul  1 12:47:31 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* keyedit.c (show_key_with_all_names): Print a notice for disabled keys.
 	(enable_disable_keys): Add functionality
 	* pkclist.c (edit_ownertrust): preserve disabled state.
 	(build_pk_list): Skip disabled keys.
 	* trustdb.c (upd_one_ownertrust): Ditto.
 	(build_cert_tree): Mask the ownertrust.
 	(trust_letter): Mask the value.
 	(do_check): Take disabled flag into account.
 
 	* passphrase.c (passphrase_to_dek): Add a pubkey_algo arg and changed
 	all callers.
 
 	* g10.c (utf8_strings): 2 new options.
 
 	* trustdb.c (insert_trust_record_by_pk): New, replaces the next one.
 	(insert_trust_record): Now takes a keyblock as arg.  Changed all
 	callers to use the appropritae function.
 
 	* openfile.c (ask_outfile_name): New.
 	* plaintext.c (handle_plaintext): Ask for filename if there is
 	no valid syntax. Don't use fname varbatim but filter it.
 
 Tue Jun 29 21:44:25 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* trustdb.h (TRUST_FLAG_DISABLED): New.
 
 	* status.c (USE_CAPABILITIES): Capabilities support (Remi).
 
 	* tdbio.c : Added new fields to the DIR record.
 	(tdbio_write_record): Fixed the update of the hash tables.
 	(tdbio_delete_record): Drop the record from the hash tables.
 	(drop_from_hashtbl): New.
 
 	* status.c (cpr_get): Special online help mode.
 	* helptext.c ("keyedit.cmd"): Removed.
 	* keyedit.c (keyedit_menu): Use only help system.
 	(enable_disable_key): New bit doies not yet work.
 
 Sat Jun 26 12:15:59 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* dearmor.c (enarmor_file): Fixed comment string.
 	* tdbdump.c (export_ownertrust): Text fix.
 	* tbio.c (tdbio_invalid): Ditto.
 
 	* parse-packet.c (parse_key): Made temp buffer larger.
 
 	* Makefile.am (install-data-local): Add missing backslashes
 
 Tue Jun 15 12:21:08 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (main): Made iterated+salted the default S2K method.
 
 	* Makefile.am (install-data-local): Use DESTDIR.
 
 	* passphrase.c (passphrase_to_dek): Emit missing-passphrase while in
 	batchmode.
 
 	* parse-packet.c (parse_pubkeyenc): Fixed a SEGV.
 
 Mon Jun 14 21:18:54 CEST 1999 Michael Roth <mroth@nessie.de>
 
 	* g10.c: New options --openpgp, --no-tty, --emit-version,
 	  --default-comment and --lock-multiple
 
 Thu Jun 10 14:18:23 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* free-packet.c (free_encrypted): Fixed EOF case (Remi).
 	(free_plaintext): Ditto.
 
 	* helptext.c (keyedit.delsig.unknown): New (Remi).
 	* keyedit.c (print_and_check_one_sig): Add arg print_without_key and
 	changed all callers to make use of it (Remi):
 
 Tue Jun  8 13:36:25 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keylist.c (print_key_data): New and called elsewhere.
 	* g10.c: New option --with-key-data
 
 Wed Jun  2 14:17:19 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* mainproc.c (proc_tree): Yet another bad hack to cope with
 	broken pgp2 created detached messages in textmode.
 
 Tue Jun  1 16:01:46 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* openfile.c (make_outfile_name): New.
 	* plaintext.c (handle_plaintext): Outputfile is now the inputfile
 	without the suffix.
 	* g10.c: New option --use-embedded-filename
 
 Mon May 31 19:41:10 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (main): Fix for SHM init (Michael).
 
 	* compress.c, encr-data.c, mdfilter.c,
 	  plaintext.c, free-packet.c: Speed patches (R�mi).
 
 Thu May 27 09:40:55 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* status.c (cpr_get_answer_yes_no_quit): New.
 	* keyedit.c (menu_delsig): New.
 	(check_all_keysigs): Splitted.
 	(print_and_check_one_sig): New.
 
 Wed May 26 14:36:29 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* build-packet.c (build_sig_subpkt): Support large packets.
 	* parse-packet.c (enum_sig_subpkt): Replaces parse_sig_subpkt.
 	* mainproc.c (print_notation_data): Print all notation packets.
 	* g10.c (add_notation_data): Add a way to specify the critical flag.
 	(main): Add option --set-policy-url.
 	(check_policy_url): Basic checks.
 	* sign.c (mk_notation_and_policy): Replaces mk_notation.
 
 	* parse-packet.c (can_handle_critical): Moved decision whether we can
 	handle critical subpacket to an extra function.
 
 Tue May 25 19:50:32 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* sign.c (sign_file): Always use compression algo 1 for signed
 	onyl file becuase we can� be sure the the verifier supports other
 	algorithms.
 
 	* build-packet.c (build_sig_subpkt): Support for notation data.
 	* sign.c (sign_file,clearsign_file,make_keysig_packet): Ditto.
 	(mk_notation): New.
 	* g10.c (add_notation_data): New and add option -N
 	* mainproc.c (print_notation_data): New.
 	(check_sig_and_print): Print any notation data of the signed text.
 
 Sun May 23 14:20:22 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (check_signatures_trust): Print a warning and return
 	immediateley if opt.always_trust is true.
 
 	* g10.c (main): Corrected handling of no-default-keyring
 
 	* pkclist.c (algo_available): Disable Twofish until we have settled
 	how to do the MDC.
 
 	* hkp.c: Disable everything for mingw32
 
 Sat May 22 22:47:26 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* mainproc.c (check_sig_and_print): Add sig creation time to the
 	VALIDSIG status output. Add more info to the ERRSIG output.
 	* sig-check.c (signature_check): Add sig time after epoch to SIG_ID.
 
 	* import.c (import_one): Merge duplicate user IDs.
 	(collapse_uids): New.
 	* kbnode.c (move_kbnode): New.
 	(remove_kbnode): New.
 	* keyedit.c (keyedit_menu): Call collapse_uids.
 
 	* g10.c: new option --logger-fd.
 
 	* import.c: s/log_*_f/log_*/
 
 Thu May 20 14:04:08 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* misc.c (pull_in_libs): do the volatile only for gcc
 
 	* sig-check (signature_check): Emit SIG_iD only for classes 0 and 1.
 
 	* armor.c (armor_filter): Add detection of PGP2 created clearsigs.
 	(fake_packet): A tab is not a WS for pgp2 - handle this.
 	* textfilter.c (len_without_trailing_chars): New.
 	(copy_clearsig_text): Add pgp2mode arg.
 	* sign.c (clearsign_file): pass old_style to the above fnc.
 
 
 Wed May 19 16:04:30 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c: New option --interactive.
 
 	* mainproc.c (proc_plaintext): Add workaround for pgp2 bug
 	(do_check_sig): Ditto.
 	(proc_tree): Ditto.
 	* plaintext.c (do_hash): Ditto.
 	(hash_datafiles): Ditto, add an arg, changed all callers.
 	* mdfilter.c (md_filter): Add support for the alternate hash context.
 
 Mon May 17 21:54:43 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* parse-packet.c (parse_encrypted): Support for PKT_ENCRYPTED_MDC.
 	* build-packet.c (do_encrypted_mdc): Ditto.
 	* cipher.c (write_header): Add mdc hashing.
 	(cipher_filter): write out the hash.
 	* mainproc.c (do_proc_packets): Add PKT_ENCRYPTED_MDC.
 	* encr-data.c (decrypt_data): Add mdc hashing.
 	(mdc_decode_filter): New.
 
 	* parse-packet.c (parse_sig_subpkt): Fixed stupid bug for subpkt
 	length calculation
 	(parse_signature): Fixed even more stupid bug.
 
 Sat May  8 19:28:08 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* build-packet.c (do_signature): Removed MDC hack.
 	* encode.c (encode_crypt_mdc): Removed.
 	* mainproc.c (do_check_sig): Removed MDC hack.
 	(check_sig_and_print): Ditto.
 	* parse-packet.c (parse_signature): Ditto.
 	* sig-check.c (mdc_kludge_check): Ditto.
 	* free-packte.c (copy_signature, free_seckey_enc): Ditto.
 
 	* parse-packet.c (parse_signature,parse_key): Store data of
 	unknown algorithms with mpi_set_opaque inseatd of the old
 	faked data stuff.
 	(read_rest): Removed.
 	(read_rest2): Renamed to read_rest
 	* build-packet.c (write_fake_data): Use mpi_get_opaque.
 	* free-packet.c (cp_fake_data): Removed and cahnged all callers
 	to use mpi_copy.
 	(free_pubkey_enc,free_seckey_enc,release_public_key_parts,
 	 release_secret_key_parts): Use mpi_free for opaque data.
 
 Thu May  6 14:18:17 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* trustdb.c (check_trust): Check for revoked subkeys.
 	* pkclist.c (do_we_trust): Handled revoked subkeys.
 	(do_we_trust_pre): Ditto.
 	(check_signatures_trust): Ditto.
 
 	* build-packet.c (hash_public_key): Fix for ancient g10 keys.
 
 	* mainproc.c (do_proc_packets): Return EOF if no data has been read.
 	* g10.c (main): Catch errors for default operation.
 
 Thu Apr 29 12:29:22 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* sign.c (sign_file): Fixed hashing in case of no subpackets.
 	(clearsign_file): Ditto.
 	(make_keysig_packet): Ditto.
 
 Wed Apr 28 13:03:03 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keyedit.c (keyedit_menu): Add new command revkey.
 	* (menu_revkey): New.
 
 
 Mon Apr 26 17:48:15 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* parse-packet.c (parse_signature): Add the MDC hack.
 	* build-packet.c (do_signature): Ditto.
 	* free-packet.c (free_seckey_enc,copy_signature,cmp_signatures): Ditto.
 	* mainproc.c (do_check_sig): Ditto.
 	* sig-check.c (mdc_kludge_check): New.
 	* encode.c (encrypt_mdc_file): New.
 
 	* keyedit.c (check_all_keysigs): List revocations.
 	* (menu_revsig): New.
 	* sign (make_keysig_packet): Support for class 0x30.
 
 Sun Apr 18 20:48:15 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (select_algo_from_prefs): Fixed the case that one key
 	has no preferences (Remi Guyomarch).
 
 	keylist.c (list_keyblock): ulti_hack to propagate trust to all uids.
 
 Sun Apr 18 10:11:28 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* seckey-cert.c (do_check): Use real IV instead of a 0 one, so that
 	it works even if the length of the IV doesn't match the blocksize.
 	Removed the save_iv stuff.
 	(protect_secret_key): Likewise.  Create the IV here.
 	* packet.h (PKT_secret_key): Increased size of IV field and add a
 	ivlen field.
 	* parse-packet.c (parse_key): Use the len protect.ivlen.
 	* build-packet.c (do_secret_key). Ditto.
 
 	* getkey.c (key_byname): Close keyblocks.
 
 	* Makefile.am (gpgm): Removed this
 	* g10.c: Merged gpg and gpgm
 
 	* import.c (import): Utilize option quiet.
 	* tdbio.c (tdbio_set_dbname): Ditto.
 	* ringedit.c (add_keyblock_resource,keyring_copy): Ditto.
 
 	* keyedit.c (sign_uids): Add some batch support.
 
 	* g10.c (main): add call to tty_batchmode.
 
 Fri Apr  9 12:26:25 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* status.c (write_status_text): Some more status codes.
 	* passphrase_to_dek (passphrase_to_dek): add a status code.
 	* seckey_cert.c (check_secret_key): Likewise.
 
 	* encr-data.c (decrypt_data): Reverse the last changes
 	* cipher.c (write_header): Ditto.
 
 	* parse-packet.c (parse_key): Dropped kludge for ancient blowfish mode.
 
 Thu Apr  8 09:35:53 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* mainproc.c (proc_encrypted): Add a new status output
 	* passphrase.c (passphrase_to_dek): Ditto.
 	* status.h status.c: Add new status tokens.
 
 Wed Apr  7 20:51:39 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* encr-data.c (decrypt_data): Fixes for 128 bit blocksize
 	* cipher.c (write_header): Ditto.
 	* seckey-cert.c (do_check): Ditto.
 	(protect_secret_key). Ditto.
 	* misc.c (print_cipher_algo_note): Twofish is now a standard algo.
 
 	* keygen.c (do_create): Fixed spelling (Ga�l Qu�ri)
 	(ask_keysize): Only allow keysizes up to 4096
 
 	* ringedit.c (add_keyblock_resource): chmod newly created secrings.
 
 	* import.c (delete_inv_parts): Fixed accidently deleted subkeys.
 
 Tue Apr  6 19:58:12 CEST 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c: Removed duped include (John Bley)
 	* mainproc.c: Ditto.
 
 	* build-packet.c (hash_public_key): Fixed hashing of the header.
 
 	* import.c (delete_inv_parts): Allow import of own non-exportable sigs.
 
 Sat Mar 20 13:59:47 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c (fake_packet): Fix for not not-dash-escaped
 
 Sat Mar 20 11:44:21 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (main): Added command --recv-keys
 	* hkp.c (hkp_import): New.
 
 Wed Mar 17 13:09:03 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* trustdb.c (check_trust): add new arg add_fnc and changed all callers.
 	(do_check): Ditto.
 	(verify_key): Ditto.
 	(propagate_validity): Use the new add_fnc arg.
 	(print_user_id): Add the FILE arg.
 	(propagate_ownertrust): New.
 	* pkclist.c (add_ownertrust_cb): New and changed the add_ownertrust
 	logic.
 
 	* getkey.c (get_keyblock_bylid): New.
 	* trustdb.c (print_uid_from_keyblock): New.
 	(dump_tn_tree_with_colons): New.
 	(list_trust_path): Add colon print mode.
 
 	* trustdb.c (insert_trust_record): Always use the primary key.
 
 	* encode.c (encode_simple): Added text_mode filter (R�mi Guyomarch)
 	(encode_crypt): Ditto.
 
 	* mainproc.c (proc_pubkey_enc): Added status ENC_TO.
 	* armor.c (armor_filter): Added status NODATA.
 	* passphrase.c (passphrase_to_dek): Always print NEED_PASSPHRASE
 	* seckey_cert.c (check_secret_key): Added BAD_PASS status.
 
 	* g10.c (main): Set g10_opt_homedir.
 
 Sun Mar 14 19:34:36 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keygen.c (do_create): Changed wording of the note (Hugh Daniel)
 
 Thu Mar 11 16:39:46 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* tdbdump.c: New
 
 	* trustdb.c (walk_sigrecs,do_list_sigs,list_sigs,
 	list_records,list_trustdb,export_ownertrust,import_ownertrust): Moved
 	to tdbdump.c
 	(init_trustdb): renamed to setup_trustdb.  Changed all callers.
 	(do_init_trustdb): renamed to init_trustdb().
 	* trustdb.c (die_invalid_db): replaced by tdbio_invalid.
 	* tdbio.c (tdbio_invalid): New.
 
 	* import.c (delete_inv_parts): Skip non exportable signatures.
 	* keyedit.c (sign_uid_mk_attrib): New.
 	(sign_uids): Add the local argument.
 	(keyedit_menu): New "lsign" command.
 	* trustdb.c (register_trusted_key): Removed this and all related stuff.
 	* g10.c (oTrustedKey): Removed option.
 
 	* tdbio.h (dir.valcheck): New trustdb field.
 	* tdbio.c: Add support for this field
 	(tdbio_read_modify_stamp): New.
 	(tdbio_write_modify_stamp): New.
 	* trustdb.c (do_check): Check against this field. Removed cache update.
 	(verify_key): Add cache update.
 	(upd_uid_record): Some functional changes.
 	(upd_cert_record): Ditto
 
 Wed Mar 10 11:26:18 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keylist.c (list_keyblock): Fixed segv in uid. Print 'u' as
 	validity of sks.
 
 Mon Mar  8 20:47:17 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* getkey.c (classify_user_id): Add new mode 12 (#<lid>).
 
 	* seckey-cert.c (check_secret_key): replaced error by info.
 
 	* trustdb.c (query_trust_info): Add another arg, changed all callers.
 	(check_trust): Ditto.
 	(do_check): Ditto.
 	(verify_key): Handle namehash.
 	* keylist.c (list_keyblock): print trust info for user ids.
 
 	* sig-check.c (signature_check): Add sig-created to status output.
 
 Tue Mar  2 16:44:57 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* textfilter.c (copy_clearsig_text): New.
 	(clearsign): Removed.
 	* sign.c (clearsign_file): does not use textfiler anymore.
 
 	* keygen.c (ask_user_id): print a note about the used charset.
 
 Tue Mar  2 10:38:42 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* sig-check.c (signature_check): sig-id now works for all algos.
 
 	* armor.c (armor_filter): Fixed armor bypassing.
 
 Sun Feb 28 19:11:00 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keygen.c (ask_user_id): Don't change the case of email addresses.
 	(has_invalid_email_chars): Adjusted.
 
 	* keylist.c (list_one): Really list serect keys (Remi Guyomarch)
 
 	* keyedit.c (menu_select_uid): Add some braces to make egcs happy.
 	(menu_select_key): Ditto.
 
 	* mainproc.c (do_proc_packets): List sym-enc packets (Remi Guyomarch)
 
 Fri Feb 26 17:55:41 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (build_pk_list): Return error if there are no recipients.
 
 	* sig-check.c (signature_check): New signature id feature.
 	* armor.c (make_radic64_string): New.
 
 	* mainproc.c (proc_pubkey_enc): early check for seckey availability.
 
 	* pkclist.c (do_we_trust_pre): print user id before asking.
 
 	* ringedit.c (add_keyblock_resource,get_keyblock_handle): Cleaner
 	handling of default resource.
 
 
 Thu Feb 25 18:47:39 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (algo_available): New.
 	(select_algo_from_prefs): Check whether algo is available.
 
 	* ringedit.c (keyring_copy): Take care of opt.dry_run.
 	(do_gdbm_store): Ditto.
 	* openfile.c (open_outfile). Ditto.
 	(copy_options_file): Ditto.
 	* trustdb.c (update_trustdb): Ditto.
 	(clear_trust_checked_flag): Ditto.
 	(update_trust_record): Ditto.
 	(insert_trust_record): Ditto.
 
 Wed Feb 24 11:07:27 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* keylist.c (secret_key_list): Now really list the secret key.
 
 	* trustdb.c (do_init_trustdb): New. Init is now deferred.
 
 Mon Feb 22 20:04:00 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* getkey.c (lookup_sk): Return G10ERR_NO_SECKEY and not x_PUBKEY.
 
 Fri Feb 19 15:49:15 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (select_algo_from_prefs): retrieve LID if not there.
 
 	* armor.c (fake_packet): Replaced ugly lineending handling.
 
 	* g10.c (oNoEncryptTo): New.
 	* pkclist.c (build_pk_list): Implemented this option.
 
 	* g10.c (main): Greeting is now printed to stderr and not to tty.
 	Use add_to_strlist() instead of direct coding.
 
 	* import.c (import): Use iobuf_push_filter2.
 
 	* mainproc.c (check_sig_and_print): Print all user ids
 	for good signatures.
 	* getkey.c (get_pubkeyblock): New.
 
 	* import.c (chk_self_sigs): Fixed SEGV for unbounded class 0x18 keys.
 	(delete_inv_parts): Delete special marked packets.
 
 Tue Feb 16 14:10:02 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (main): New option --encrypt-to
 
 	* pkclist.c (build_pk_list): Implemented encrypt-to.
 
 	* parse-packet.c (parse_user_id): Removed the hack to work with
 	utf-8 strings.
 
 	* g10.c (main): Install lockfile cleanup handler.
 	* tdbio.c (cleanup): Removed: this is now handled by dotlock.
 
 Sat Feb 13 14:13:04 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* tdbio.c (tdbio_set_dbname): Init lockhandle for a new trustdb
 
 Wed Feb 10 17:15:39 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c (main): check for development version now in configure
 
 	* tdbio.c (tdbio_write_record): Add uid.validity
 	(tdbio_read_record) : Ditto.
 	(tdbio_dump_record) : Ditto.
 
 	* keygen.c (keygen_add_std_prefs): Replaced Blowfish by Twofish,
 	removed MD5 and Tiger.
 	* pubkey-enc.c (get_it): Suppress warning about missing Blowfish
 	in preferences in certain cases.
 
 	* ringedit.c (lock_rentry,unlock_rentry): New.
 
 	* getkey.c (key_byname): Pass ret_kb down to lookup_xx.
 
 	* armor.c (armor_filter): No output of of empty comment lines.
 	Add option --no-version to suppress the output of the version string.
 
 	* getkey.c: Release the getkey context for auto context variables.
 
 Sun Jan 24 18:16:26 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* getkey.c: Changed the internal design to allow simultaneous
 	lookup of multible user ids
 	(get_pubkey_bynames): New.
 	(get_seckey_bynames): New.
 	(get_seckey_next): New.
 	(get_seckey_end): New.
 	* keylist.c (list_one): Use the new functions.
 
 	* keylist.c (list_keyblock): add a newline for normal listings.
 
 	* g10.c (--recipient): New option name to replace --remote-user
 
 
 Wed Jan 20 18:59:49 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* textfilter.c: Mostly rewritten
 	* plaintext.c (handle_plaintext): Use now text_filter semantics.
 
 Tue Jan 19 19:34:58 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* export.c (export_pubkeys_stream): New.
 	(do_export_stream): New.
 	* g10.c (aSendKeys): New command.
 	* hkp.c (hkp_export): New.
 
 	* compress.c (do_uncompress): Hack for algo 1 and 1.1.3
 
 Sun Jan 17 11:04:33 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* textfilter.c (text_filter): Now uses iobuf_read_line().
 	(read_line): Removed.
 
 	* armor.c (trim_trailing_spaces): Removed and replaced
 	by trim_trailing_ws from libutil
 
 Sat Jan 16 12:03:27 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* hkp.c (hkp_ask_import): Use only the short keyid
 
 Sat Jan 16 09:27:30 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* import.c (import_key_stream): New
 	(import): New, moved most of import_keys here.
 	* g10.c: New option --keyserver
 	* mainproc.c (check_sig_and_print): Hook to import a pubkey.
 
 	* pref.c pref.h : Removed
 
 	* hkp.c hkp.h: New
 
 Wed Jan 13 14:10:15 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c (radix64_read): Print an error if a bad armor was detected.
 
 Wed Jan 13 12:49:36 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c (radix64_read): Now handles malformed armors produced
 	by some buggy MUAs.
 
 Tue Jan 12 11:17:18 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* ringedit.c (find_keyblock_bysk): New.
 
 	* skc_list.c (is_insecure): New.
 	(build_sk_list): usage check for insecure keys.
 
 	* import.c (chk_self_sigs): Add handling for subkeys.
 	(delete_inv_parts): Skip unsigned subkeys
 
 	* sig-check.c (do_check): Print info if the signature is older
 	than the key.
 	* keygen.c (generate_subkeypair): Fail on time warp.
 	* sign.c (do_sign): Ditto.
 
 Sun Jan 10 15:10:02 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c (fake_packet): Fixed not-dash-escaped bug.
 
 Sat Jan  9 16:02:23 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* sig-check.c (do_check): Output time diff on error
 
 	* status.c (STATUS_VALIDSIG): New.
 	(is_status_enabled): New.
 	* mainproc.c (check_sig_and_print): Issue that status message.
 
 	* plaintext.c (special_md_putc): Removed
 
 	* armor.c (armor_filter): print error for truncated lines.
 
 	* free-packet.c (free_encrypted): Revomed call to set_block_mode.
 	(free_plaintext): Ditto.
 
 Thu Jan  7 18:00:58 CET 1999  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (add_ownertrust): Fixed return value.
 
 	* encr-data.c (decrypt_data): Disabled iobuf_set_limit and
 	iobuf_pop_filter stuff.
 	* compress.c (handle_compressed): Disabled iobuf_pop_filter.
 
 	* packet.h (PKT_secret_key): Add is_primary flag.
 	* parse-packet.c (parse_key): Set this flag.
 	* passphrase.c (passphrase_to_dek): Kludge to print the primary
 	keyid - changed the API: keyid must now hold 2 keyids.
 	* getkey.c (get_primary_seckey): New.
 	* seckey-cert.c (do_check): pass primary keyid to passphrase query
 
 	* tbdio.c (open_db): removed the atexit
 	(tdbio_set_dbname): and moved it to here.
 
 	* armor.c: Rewrote large parts.
 
 Tue Dec 29 19:55:38 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* revoke.c (gen_revoke): Removed compression.
 
 	* pkclist.c (do_we_trust_pre): special check for revoked keys
 
 	* trustdb.c (update_trust_record): Fixed revoke flag.
 
 Tue Dec 29 14:41:47 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* misc.c (disable_core_dumps): Check for EINVAL (Atari)
 
 	* getkey (merge_one_pk_and_selfsig): Fixed search of expiredate.
 	(merge_keys_and_selfsig): Ditto.
 
 	* free-packet.c (cmp_public_keys): cmp expire only for v3 packets
 	(cmp_secret_keys): Ditto.
 	(cmp_public_secret_key): Ditto.
 
 Wed Dec 23 17:12:24 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* armor.c (find_header): Reset not_dashed at every header
 
 Wed Dec 23 13:18:14 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pkclist.c (add_ownertrust): Refresh validity values.
 
 	* trustdb.c (enum_cert_paths_print): New arg refresh.
 
 	* ringedit.c: Fixed problems fix keyrings
 	* parse-packet.c (dbg_parse_packet): New debug functions.
 
 	* getkey.c (getkey_disable_caches): New.
 	* import.c (import_keys): Disable caches.
 
 Thu Dec 17 18:31:15 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* misc.c (trap_unaligned): Only for glibc 1
 
 	* sign.c (write_dash_escaped): Now escapes "From " lines
 	* g10.c: New option --escape-from-lines
 
 	* trustdb.c (sort_tsl_list): New
 	(list_trust_path): Now prints sorted list.
 	(enum_cert_paths): Likewise.
 	(enum_cert_paths_print): New.
 	(print_paths): New printing format.
 	* pkclist.c (add_ownertrust): New arg quit.
 	(edit_ownertrust): New quit selection and does not query
 	the recipients ownertrust anymore.
 	(add_ownertrust): Print the ceritficate path.
 
 
 Mon Dec 14 21:18:49 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* parse-packet.c (parse_signature): Now checks for critical bit
 	(parse_sig_subpkt): Splitted.
 	(parse_one_sig_subpkt): New.
 	* sig-check.c (do_check): handle critical bit.
 
 Sun Dec 13 14:10:56 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* pcklist.c (select_algo_from_prefs): Preferences should
 	now work (lost the != ? )
 
 Thu Dec 10 20:15:36 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* ringedit.c (gdbm_store): Fix for inserts
 
 	* g10.c (main): New option --export-all
 	* export.c (export_pubkeys): New arg.
 	(do_export): Now may skip old keys.
 
 	* status.c: Minor patches for Sun's cc
 
 	* keygen.c (ask_algo): Disabled v3 ElGamal choice, rearranged
 	 the numbers.  Add a warning question when a sign+encrypt key
 	 is selected.
 
 	* g10.c (do_not_use_RSA): Removed.
 	* misc.c (print_pubkey_algo_note): New as replacement for the
 	do_not_use_RSA() and chnaged all callers.
 	(print_cipher_algo_note): New.
 	(print_hash_algo_note): New.
 
 	* cipher.c (write_header): Add a call to print_cipher_algo_note.
 	* seckey-cert.c (protect_secret_key): Ditto
 	* sign.c (do_sign): Add a call to print_digest_algo_note.
 
 	* getkey.c (get_long_user_id_string): New.
 	* mainproc.c (check_sig_and_print): Changed the format of the
 	status output.
 
 	* encrypt.c (write_pubkey_enc_from_list): print used symmetric cipher.
 
 	* pkclist.c (do_we_trust): Changed a message.
 
 Wed Dec  9 13:41:06 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* misc.c (trap_unaligned) [ALPHA]: Only if UAC_SIGBUS is defined.
 
 	* sign.c (write_dash_escaped): Add the forgotten patch by Brian Moore.
 
 	* compress.c (do_uncompress): Fixed the inflating bug.
 
 
 Tue Dec  8 13:15:16 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* trustdb.c (upd_uid_record): Now uses the newest self-signature
 	(insert_trust_record): Now calls update with recheck set to true.
 	(register_trusted_key): New.
 	(verify_own_keys): Enhanced by list of trusted keys.
 
 	* g10.c (main): Print a warning when a devel version is used.
 	(main): New option --trusted-key
 
 	* import.c (merge_blocks): Fixed merging of new user ids and
 	added merging of subkeys.
 	(append_uid): Ditto.
 	(merge_keysig): New.
 	(append_key): New.
 	* getkey.c (merge_one_pk_and_selfsig): Get the expiration time
 	from the newest self-signature.
 	(merge_keys_and_selfsig): Ditto.
 
 	* free-packet.c (cmp_secret_key): New.
 
 
 Fri Nov 27 21:37:41 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	* g10.c: New option --lock-once
 	* tdbio.c (open_db): Add an atexit
 	(cleanup): New.
 	(tdbio_sync): Add locking.
 	(tdbio_end_transaction): Ditto.
 	(put_record_into_cache): Ditto.
 	* ringedit.c (keyring_copy): Ditto.
 	(cleanup): New.
 	(add_keyblock_resource): Add an atexit.
 
 Fri Nov 27 15:30:24 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 	 * armor.c (find_header): Another fix for clearsigs.
 
 Fri Nov 27 12:39:29 CET 1998  Werner Koch  <wk@isil.d.shuttle.de>
 
 
 	* status.c (display_help): Removed.
 	* helptext.c: New and removed the N_() from all cpr_gets.
 
 
 Fri Nov 20 16:54:52 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): New option --not-dash-escaped
 	* sign.c (write_dashed_escaped): Ditto.
 	* armor.c (find_header): Support for NotDashEscaped header.
 
 	* getkey.c: print "disabled cache.." only if verbose is used.
 
 Thu Nov 19 07:17:31 1998  Werner Koch  <werner.koch@guug.de>
 
 	* parse-packet.c (dump_sig_subpkt): Fixed expire listing
 	* getkey.c (merge_keys_and_selfsig): Fixed expire calculation.
 	(merge_one_pk_and_selfsig): Ditto.
 	* keyedit.c (menu_expire). Ditto.
 	* keygen.c (keygen_add_key_expire): Ditto.
 	(ask_expire_interval): New and changed all local function to use
 	this instead.
 	(keygen_add_key_expire): Opaque should now be a public key;
 	changed all callers.
 
 	* parse.packet.c (parse): use skip_rest to skip packets.
 
 	* keyedit.c (keyedit_menu): New arg for cmdline cmds.
 
 Wed Nov 18 20:33:50 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (check_trustdb): Now rechecks all gived userids.
 	(collect_paths): Some fixes.
 	(upd_pref_records): Skips empty items, evaluate all items.
 
 	* parse-packet.c (dump_sig_subpkt): Better listing of prefs.
 	(skip_packet): Now knows about marker packet
 
 	* g10.c: removed cmd "--edit-sig".
 
 	* pubring.asc: Updated.
 
 Sat Nov 14 14:01:29 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Changed syntax of --list-trust-path
 	* trustdb.c (list_trust_path): Replaced max_depth by
 	opt.max_cert_depth
 
 Fri Nov 13 07:39:58 1998  Werner Koch  <werner.koch@guug.de>
 
 	* trustdb.c (collect_paths): Removed a warning message.
 	(enum_trust_web): Removed.
 	(enum_cert_paths): New.
 	* pkclist.c (add_ownertrust): Changed to use enum_cert_paths.
 	(edit_ownertrust): Now list ceritficates on request.
 	(show_paths): New.
 
 Wed Nov 11 18:05:44 1998  Werner Koch  <werner.koch@guug.de>
 
 	* g10.c (main): New option --max-cert-depth
 	* tdbio.h: add new fields to ver and dir record.
 	* tdbio.c: read/write/dump of these fields.
 	(tdbio_db_matches_options): New.
 	* trustdb.c: replaced MAC_CERT_DEPTH by opt.max_cert_depth.
 	(do_check): cache validity and changed other functions
 	to reset the cached value.
 
 	* keylist.c (list_one): Now lists the ownertrust.
 	* mainproc.c (list_node): Ditto.
 
 Tue Nov 10 10:08:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (g10_exit): Now looks at the new g10_errors_seen.
 	* mainproc.c (check_sig_and_print): Sets g10_errors_seen.
 
 	* *.c : i18n many more strings.
 
 	* ringedit.c (locate_keyblock_by_keyid): Add HAVE_LIBGDBM
 	(locate_keyblock_by_fpr): Ditto.
 
 	* g10.c (main): removed unsused "int errors".
 	(main): Add new option --charset.
 
 	* g10.c (main): special message for the unix newbie.
 
 Mon Nov  9 07:17:42 1998  Werner Koch  <werner.koch@guug.de>
 
 	* getkey.c (finish_lookup): Kludge to prefere algo 16.
 
 	* trustdb.c (new_lid_table): Clear cached item.
 
 	* status.c (cpr_get_utf8): New.
 	* pkclist.c (build_pk_list): Uses this.
 
 Sun Nov  8 17:20:39 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c (check_sig_and_print): Why did I use strlen()-1
 	in the printf? - This truncated the TZ.
 
 Sat Nov  7 15:57:28 1998  me,,,  (wk@tobold)
 
 	* getkey.c (lookup): Changes to support a read_next.
 	(get_pubkey): Fixed a memory leak.
 
 	* keylist.c (list_one): Now lists all matching user IDs.
 
 Tue Nov  3 16:19:21 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (ask_user_id): Now converted to UTF-8
 
 	* g10.c (main): Kludge for pgp clearsigs and textmode.
 
 Fri Oct 30 16:40:39 1998  me,,,  (wk@tobold)
 
 	* signal.c (block_all_signals): New.
 	(unblock_all_signals): New
 	* tdbio.c (tdbio_end_transaction): Now blocks all signals.
 
 	* trustdb.c (new_lid_table): Changed the representation of the
 	former local_lid_info stuff.
 
 	* trustdb.c (update_trust_record): Reorganized the whole thing.
 	* sig-check.c (check_key_signature): Now handles class 0x28
 
 
 Wed Oct 28 18:56:33 1998  me,,,  (wk@tobold)
 
 	* export.c (do_export): Takes care of the exportable sig flag.
 
 Tue Oct 27 14:53:04 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (update_trust_record): New "fast" parameter.
 
 Sun Oct 25 19:32:05 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* openfile.c (copy_options_File): New.
 	* ringedit.c (add_keyblock_resource): Creates options file
 	* tdbio.c (tdbio_set_dbname): Ditto.
 
 Sat Oct 24 14:10:53 1998  brian moore <bem@cmc.net>
 
 	* mainproc.c (proc_pubkey_enc): Don't release the DEK
 	(do_proc_packets): Ditto.
 
 Fri Oct 23 06:49:38 1998  me,,,  (wk@tobold)
 
 	* keyedit.c (keyedit_menu): Comments are now allowed
 
 	* trustdb.c: Rewrote large parts.
 
 
 Thu Oct 22 15:56:45 1998  Michael Roth	(mroth@nessie.de)
 
 	* encode.c: (encode_simple): Only the plain filename without
 	a given directory is stored in generated packets.
 	(encode_crypt): Ditto.
 
 	* sign.c: (sign_file) Ditto.
 
 
 Thu Oct 22 10:53:41 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (update_trust_record): Add new optional arg.
 
 	* import.c (import_keys): Add statistics output
 	* trustdb.c (update_trustdb): Ditto.
 	(insert_trustdb): Ditto.
 
 	* tdbio.c (tdbio_begin_transaction): New.
 	(tdbio_end_transaction): New.
 	(tdbio_cancel_transaction): New.
 
 	* g10.c (main): New option --quit.
 
 	* trustdb.c (check_hint_sig): No tests for user-id w/o sig.
 	This caused an assert while checking the sigs.
 
 	* trustdb.c (upd_sig_record): Splitted into several functions.
 
 	* import.c (import_keys): New arg "fast".
 	* g10.c (main): New command --fast-import.
 
 Wed Oct 21 18:19:36 1998  Michael Roth <mroth@nessie.de>
 
 	* ringedit.c (add_keyblock_resource): Directory is now created.
 	* tdbio.c (tdbio_set_dbname): New info message.
 
 Wed Oct 21 11:52:04 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (update_trustdb): released keyblock in loop.
 
 	* keylist.c (list_block): New.
 	(list_all): Changed to use list_block.
 
 	* trustdb.c: Completed support for GDBM
 
 	* sign.c (only_old_style): Changed the way force_v3 is handled
 	(sign_file): Ditto.
 	(clearsign_file): Ditto.
 
 	* keygen.c (has_invalid_email_chars): Splitted into mailbox and
 	host part.
 
 	* keylist.c (list_one): Add a merge_keys_and_selfsig.
 	* mainproc.c (proc_tree): Ditto.
 
 Sun Oct 18 11:49:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sign.c (only_old_style): Add option force_v3_sigs
 	(sign_file): Fixed a bug in sig->version
 	(clearsign_file): Ditto.
 
 	* parse-packet.c (dump_sig_subpkt): New
 
 	* keyedit.c (menu_expire): New.
 	* free-packet.c (cmp_signatures): New
 
 
 Sat Oct 17 10:22:39 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c: changed output line length from 72 to 64.
 
 	* keyedit.c (fix_keyblock): New.
 
 Fri Oct 16 10:24:47 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c: Rewrote most.
 	* tdbio.c: Add cache and generalized hash tables.
 
 	* options.h (ENABLE_COMMENT_PACKETS): New but undef'ed.
 	* encode.c, sign.c, keygen.c: Disabled comment packets.
 	* export.c (do_export): Comment packets are never exported,
 	except for those in the secret keyring.
 
 	* g10.c (main): Removed option do-no-export-rsa; should be
 	be replaced by a secpial tool.
 	* export.c (do_export): Removed the code for the above option.
 
 	* armor.c (find_header): Support for new only_keyblocks.
 	* import.c (import_keys): Only looks for keyblock armors.
 
 	* packet.h: replaced valid_days by expiredate and changed all users.
 	* build-packet.c (do_public_key): calculates valid-days
 	(do_secret_key): Ditto.
 	* parse-packet.c (parse_key): expiredate is calucated from the
 	valid_period in v3 packets.
 	* keyid.c (do_fingerprint_md): calculates valid_dates.
 
 	* keygen.c (add_key_expire): fixed key expiration time for v4 packets.
 
 	* armor.c (find_header): A LF in the first 28 bytes
 	was skipped for non-armored data.
 
 Thu Oct  8 11:35:51 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (is_armored): Add test on old comment packets.
 
 	* tdbio.c (tdbio_search_dir_bypk): fixed memory leak.
 
 	* getkey.c: Changed the caching algorithms.
 
 Wed Oct  7 19:33:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* kbnodes.c (unused_nodes): New.
 
 Wed Oct  7 11:15:36 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keyedit.c (sign_uids): Fixed a problem with SK which could caused
 	a save of an unprotected key.
 	(menu_adduid): Ditto.
 
 	* keyedit.c (keyedit_menu): Prefs are now correctly listed for
 	new user ids.
 
 	* trustdb.c (update_trust_record): New.
 	(insert_trust_record): Now makes use of update_trust_record.
 
 Tue Oct  6 16:18:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (read_record): replaces most of the tdbio_read_records.
 	(write_record): Ditto.
 
 Sat Oct  3 11:01:21 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (ask_alogo): enable ElGamal enc-only only for addmode.
 
 Wed Sep 30 10:15:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* import.c (import_one): Fixed update of wrong keyblock.
 
 Tue Sep 29 08:32:08 1998  me,,,  (wk@tobold)
 
 	* mainproc.c (proc_plaintext): Display note for special filename.
 	* plaintext.c (handle_plaintext): Suppress output of special file.
 
 Mon Sep 28 12:57:12 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (verify_own_keys): Add warning if a key is not protected.
 
 	* passphrase (hash_passphrase): Fixed iterated+salted mode and
 	setup for keysizes > hashsize.
 
 	* g10.c (main): New options: --s2k-{cipher,digest,mode}.
 
 Fri Sep 25 09:34:23 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c: Chnaged some help texts.
 
 Tue Sep 22 19:34:39 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* passphrase.c (read_passphrase_from_fd): fixed bug for long
 	passphrases.
 
 Mon Sep 21 11:28:05 1998  Werner Koch  (wk@(none))
 
 	* getkey.c (lookup): Add code to use the sub key if the primary one
 	does not match the usage.
 
 	* armor.c (armor_filter): New error message: no valid data found.
 	(radix64_read): Changes to support multiple messages.
 	(i18n.h): New.
 	* mainproc.c (add_onepass_sig): bug fix.
 
 Mon Sep 21 08:03:16 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* pkclist.c (do_we_trust): Add keyid to most messages.
 
 	* passphrase.c (read_passphrase_from_fd): New.
 	(have_static_passphrase): New
 	(get_passphrase_fd): Removed.
 	(set_passphrase_fd): Removed.
 	* g10.c (main): passphrase is now read here.
 
 	* keyedit.c (keyedit_menu): "help" texts should now translate fine.
 
 Mon Sep 21 06:40:02 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* encode.c (encode_simple): Now disables compression
 	when --rfc1991 is used.
 	(encode_crypt): Ditto.
 
 Fri Sep 18 16:50:32 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (merge_key_and_selfsig): New.
 
 Fri Sep 18 10:20:11 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* pkclist.c (select_algo_from_prefs): Removed 3DES kludge.
 
 	* seskey.c (make_session_key): Fixed SERIOUS bug introduced
 	by adding the weak key detection code.
 
 	* sign.c (sign_file): Changed aremor header in certain cases.
 
 Tue Sep 15 17:52:55 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c (check_sig_and_print): Replaced ascime by asctimestamp.
 
 Mon Sep 14 11:40:52 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seskey.c (make_session_key): Now detects weak keys.
 
 	* trustdb (clear_trust_checked_flag): New.
 
 	* plaintext.c (handle_plaintext): Does no anymore suppress CR from
 	cleartext signed messages.
 
 Sun Sep 13 12:54:29 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (insert_trust_record): Fixed a stupid bug in the free
 	liunked list loops.
 
 Sat Sep 12 15:49:16 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* status.c (remove_shmid): New.
 	(init_shm_comprocess): Now sets permission to the real uid.
 
 Wed Sep  9 11:15:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h (PKT_pubkey_enc): New flah throw_keyid, and add logic to
 	implement it.
 	* g10.c (main): New Option --throw-keyid
 
 	* getkey.c (enum_secret_keys): Add new ar and changed all callers.
 
 Tue Sep  8 20:04:09 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* delkey.c (delete_key): Moved from keyedit.c.
 
 Mon Sep  7 16:37:52 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (calc_length_header): New arg new_ctb to correctly
 	calculate the length of new style packets.
 
 	* armor.c (is_armored): Checks for symkey_enc packets.
 
 	* pkclist.c (select_algo_from_prefs): 3DEs substitute is now CAST5.
 
 Tue Aug 11 17:54:50 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (do_secret_key): Fixed handling of old keys.
 
 	* getkey.c (compare_name): Fixed exact and email matching
 
 	* openfile.c (open_outfile): Changed arguments and all callers.
 
 Tue Aug 11 09:14:35 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* encode.c (encode_simple): Applied option set-filename and comment.
 	(encode_crypt): Ditto.
 	* sign.c (sign_file): Ditto.
 	* armor.c (armor_filter): Applied option comment.
 
 	* encode.c (encode_crypt): Moved init_packet to the begin.
 	(encode_simple): add an init_packet().
 
 	* comment (write_comment): Now enforces a hash sign as the 1st byte.
 
 	* import.c (import_one): Add explanation for "no user ids".
 
 	* compress.c (do_uncompress): Applied Brian Warner's patch to support
 	zlib 1.1.3 etc.
 
 	* trustdb.c (check_trust): Fixed a problem after inserting new keys.
 
 	* getkey (lookup): do not return the primary key if usage is given
 	(lookup_sk): Ditto and take usage into account.
 
 	* status.c (cpr_get_answer_is_yes): add display_help.
 
 Mon Aug 10 10:11:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (lookup_sk): Now always returns the primary if arg
 	primary is true.
 	(lookup): Likewise.
 	(get_pubkey_byname): Now returns the primary key
 	(get_seckey_byname): Ditto.
 
 
 Mon Aug 10 08:34:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keyid.c (pubkey_letter): ELG_E is now a small g.
 
 Sat Aug  8 17:26:12 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* openfile (overwrite_filep): Changed semantics and all callers.
 
 Sat Aug  8 12:17:07 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* status.c (display_help): New.
 
 Thu Aug  6 16:30:41 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* seskey.c (encode_session_key): Now uses get_random_bits().
 
 Thu Aug  6 07:34:56 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* ringedit.c (keyring_copy): No more backupfiles for
 	secret keyrings and add additional warning in case of
 	a failed secret keyring operation.
 
 Wed Aug  5 11:54:37 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (check_opts): Moved to main.  Changed def_cipher_algo
 	semantics and chnaged all users.
 
 	* pubkey-enc.c (get_sssion_key): New informational output
 	about preferences.
 
 	* parse-packet.c (parse_symkeyenc): Fixed salted+iterated S2K
 	(parse_key): Ditto.
 	* build-packet.c (do_secret_key): Ditto.
 	(do_symkey_enc): Ditto.
 
 Tue Aug  4 08:59:10 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (enum_secret_keys): Now returns only primary keys.
 
 	* getkey (lookup): Now sets the new namehash field.
 
 	* parse-packet.c (parse_sig_subpkt2): New.
 
 	* sign.c (sign_file): one-pass sigs are now emiited reverse.
 	Preference data is considered when selecting the compress algo.
 
 Wed Jul 29 12:53:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* free-packet.c (copy_signature): New.
 
 	* keygen.c (generate_subkeypair): rewritten
 	* g10.c (aKeyadd): Removed option --add-key
 
 Mon Jul 27 10:37:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seckey-cert.c (do_check): Additional check on cipher blocksize.
 	(protect_secret_key): Ditto.
 	* encr-data.c: Support for other blocksizes.
 	* cipher.c (write_header): Ditto.
 
 Fri Jul 24 16:47:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* kbnode.c (insert_kbnode): Changed semantics and all callers.
 	* keyedit.c : More or less a complete rewrite
 
 Wed Jul 22 17:10:04 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (write_sign_packet_header): New.
 
 Tue Jul 21 14:37:09 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* import.c (import_one): Now creates a trustdb record.
 
 	* g10.c (main): New command --check-trustdb
 
 Mon Jul 20 11:15:07 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* genkey.c (generate_keypair): Default key is now DSA with
 	encryption only ElGamal subkey.
 
 Thu Jul 16 10:58:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keyid.c (keyid_from_fingerprint): New.
 	* getkey.c (get_pubkey_byfprint): New.
 
 Tue Jul 14 18:09:51 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keyid.c (fingerprint_from_pk): Add argument and changed all callers.
 	(fingerprint_from_sk): Ditto.
 
 Tue Jul 14 10:10:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* plaintext.c (handle_plaintext): Now returns create error if
 	the file could not be created or the user responded not to overwrite
 	the file.
 	* mainproc.c (proc_plaintext): Tries again if the file could not
 	be created to check the signature without output.
 
 	* misc.c (disable_core_dumps): New.
 	* g10.c (main): disable coredumps for gpg
 
 	* g10.c (MAINTAINER_OPTIONS): New to disable some options
 
 Mon Jul 13 16:47:54 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* plaintext.c (hash_datafiles): New arg for better support of
 	detached sigs. Changed all callers.
 	* mainproc.c (proc_signature_packets): Ditto.
 
 	* g10.c (main): New option "compress-sigs"
 	* sig.c (sign_file): detached signatures are not anymore compressed
 	unless the option --compress-sigs is used.
 
 Thu Jul  9 19:54:54 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c: Fixes to allow zero length cleartext signatures
 
 Thu Jul  9 14:52:47 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (build_list): Now drops setuid.
 	(main): Changed the way keyrings  and algorithms are registered .
 
 Wed Jul  8 14:17:30 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h (PKT_public_key): Add field keyid.
 	* parse-packet.c (parse_key): Reset the above field.
 	* keyid.c (keyid_from_pk): Use above field as cache.
 
 	* tdbio.c, tdbio.h: New
 	* trustdb.c: Moved some functions to tdbio.c.
 	(print_keyid): New.
 
 	* pkclist.c (check_signatures_trust): New.
 
 Wed Jul  8 10:45:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* plaintext.c (special_md_putc): New.
 	(handle_plaintext): add clearsig argument
 	* mainproc.c (proc_plaintext): detection of clearsig
 	* sign.c (write_dased_escaped): Changed clearsig format
 
 Tue Jul  7 18:56:19 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (find_header): Now makes sure that there is only one
 	empty line for clearsigs, as this is what OP now says.
 
 Mon Jul  6 13:09:07 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): New option default-secret-key
 	* getkey.c (get_seckey_byname): support for this option.
 
 Mon Jul  6 09:03:49 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (add_keyring): Keyrings are now added to end of the
 	list of keyrings.  The first added keyringwill be created.
 	(add_secret_keyring): Likewise.
 
 	* ringedit.c (add_keyblock_resource): Files are created here.
 
 	* g10.c (aNOP): Removed
 
 	* getkey.c (lookup): Add checking of usage for name lookups
 	* packet.h (pubkey_usage): Add a field which may be used to store
 	usage capabilities.
 	* pkclist.c (build_pk_list): getkey now called with usage arg.
 	* skclist.c (build_sk_list): Ditto.
 
 	* sign.c (clearsign_file): Fixed "Hash:" headers
 
 Sat Jul  4 13:33:31 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (list_ownertrust): New.
 	* g10.c (aListOwnerTrust): New.
 
 	* g10.c (def_pubkey_algo): Removed.
 
 	* trustdb.c (verify_private_data): Removed and also the call to it.
 	(sign_private_data): Removed.
 
 Fri Jul  3 13:26:10 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (aEditKey): was aEditSig. Changed usage msg.
 
 	* keyedit.c: Done some i18n stuff.
 
 	* g10.c (do_not_use_RSA): New.
 	* sign.c (do_sign): Add call to above function.
 	* encode.c (write_pubkey_enc_from_list): Ditto.
 
 Thu Jul  2 21:01:25 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c: Now is able sto store data of unknown
 	algorithms.
 	* free-packet.c: Support for this.
 	* build-packet.c: Can write data of packet with unknown algos.
 
 Thu Jul  2 11:46:36 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (parse): fixed 4 byte length header
 
 Wed Jul  1 12:36:55 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h (new_ctb): New field for some packets
 	* build-packet.c (build_packet): Support for new_ctb
 	* parse-packet.c (parse): Ditto.
 
 Mon Jun 29 12:54:45 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h: changed all "_cert" to "_key", "subcert" to "subkey".
 
 	* free-packet.c (free_packet): Removed memory leak for subkeys.
 
 Sun Jun 28 18:32:27 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* import.c (import_keys): Renamed from import_pubkeys.
 	(import_secret_one): New.
 
 	* g10.c (aExportSecret): New.
 
 	* export.c (export_seckeys): New.
 
 	* parse-packet.c (parse_certificate): Cleaned up.
 	(parse_packet): Trust packets are now considered as unknown.
 	(parse_pubkey_warning): New.
 
 Fri Jun 26 10:37:35 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (has_invalid_email_chars): New.
 
 Wed Jun 24 16:40:22 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (armor_filter): Now creates valid onepass_sig packets
 	with all detected hash algorithms.
 	* mainproc.c (proc_plaintext): Now uses the hash algos as specified
 	in the onepass_sig packets (if there are any)
 
 Mon Jun 22 11:54:08 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* plaintext.c (handle_plaintext): add arg to disable outout
 	* mainproc.c (proc_plaintext): disable output when in sigs_only mode.
 
 Thu Jun 18 13:17:27 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c: Removed all rsa packet stuff, chnaged defaults
 	for key generation.
 
 Sun Jun 14 21:28:31 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* misc.c (checksum_u16): Fixed a stupid bug which caused a
 	wrong checksum calculation for the secret key protection and
 	add a backward compatibility option.
 	* g10.c (main): Add option --emulate-checksum-bug.
 
 Thu Jun 11 13:26:44 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h: Major changes to the structure of public key material
 	which is now stored in an array and not anaymore in a union of
 	algorithm specific structures.	These is needed to make the system
 	more extendable and makes a lot of stuff much simpler. Changed
 	all over the system.
 
 	* dsa.c, rsa.c, elg.c: Removed.
 
 Wed Jun 10 07:22:02 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* g10.c ("load-extension"): New option.
 
 Mon Jun  8 22:23:37 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seckey-cert.c (do_check): Removed cipher constants
 	(protect_secret_key): Ditto.
 
 Fri May 29 10:00:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (query_trust_info): New.
 	* keylist.c (list_one): Add output of trust info
 	* mainproc (list_node): ditto.
 	* g10.c (main): full trustdb init if -with-colons and any of the
 	key list modes.
 
 Thu May 28 10:34:42 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* status.c (STATUS_RSA_OR_IDEA): New.
 	* sig-check.c (check_signature): Output special status message.
 	* pubkey-enc.c (get_session_key): Ditto.
 
 	* mainproc.c (check_sig_and_print): Changed format of output.
 	* passpharse.c (passphrase_to_dek): Likewise.
 
 Wed May 27 13:46:48 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (aListSecretKeys): New option --list-secret-keys
 	* keylist.c (std_key_list): Renamed to public_key_list.
 	(secret_key_list): New
 	(list_one, list_all): Add support for secret keys.
 	* getkey.c (get_secret_keyring): New.
 	* mainproc.c (list_node): Add option --with-colons for secret keys
 
 	* sig-check.c (check_key_signature): detection of selfsigs
 	* mainproc.c (list_node): fixed listing.
 
 	* g10.c (aListSecretKeys): New option --always-trust
 	* pkclist.c (do_we_trust): Override per option added
 
 	* status.c (write_status_text): Add a prefix to every output line.
 
 Wed May 27 07:49:21 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10 (--compress-keys): New.
 	* options.h (compress_keys): New.
 	* export.c (export_pubkeys): Only compresses with the new option.
 
 Tue May 26 11:24:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* passphrase.c (get_last_passphrase): New
 	(set_next_passphrase): New.
 	(passphrase_to_dek): add support for the above functions.
 	* keyedit.c (make_keysig_packet): Add sigclass 0x18,
 	changed all callers due to a new argument.
 	* keygen.c (write_keybinding): New
 	(generate_subkeypair): Add functionality
 	(ask_algo, ask_keysize, ask_valid_days): Broke out of generate_keypair
 	(ask_user_id, ask_passphrase): Ditto.
 
 Thu May 21 11:26:13 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c,gpgd.c (main): Does now return an int, so that egcs does
 	not complain.
 
 	* armor.c (fake_packet): Removed erro message and add a noticed
 	that this part should be fixed.
 
 	* sign.c (sign_file): Compression now comes in front of encryption.
 	* encode.c (encode_simple): Ditto.
 	(encode_crypt): Ditto.
 
 Tue May 19 16:18:19 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (fake_packet): Changed assertion to log_error
 
 Sat May 16 16:02:06 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (build_packet): Add SUBKEY packets.
 
 Fri May 15 17:57:23 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sign.c (hash_for): New and used in all places here.
 	* main.h (DEFAULT_): new macros.
 	* g10.c  (opt.def_digest_algo): Now set to 0
 
 	* compress.c (init_compress): Add support for algo 1
 	* options.h (def_compress_algo): New
 	* g10.c (main): New option --compress-algo
 
 Fri May 15 13:23:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (print_mds): New feature to print only one hash,
 	chnaged formatting.
 
 Thu May 14 15:36:24 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* misc.c (trap_unaligned) [__alpha__]: New
 	* g10.c (trap_unaligned): Add call to this to track down SIGBUS
 	on Alphas (to avoid the slow emulation code).
 
 Wed May 13 11:48:27 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (do_signature): Support for v4 pakets.
 	* keyedit.c (make_keysig_packet): Ditto.
 	* build-packet.c (build_sig_subpkt_from_sig): New.
 	(build_sig_subpkt): New.
 
 	* elg.c (g10_elg_sign): removed keyid_from_skc.
 	* dsa.c (g10_dsa_sign): Ditto.
 	* rsa.c (g10_rsa_sign): Ditto.
 	* keyedit.c (make_keysig_packet): Add call to keyid_from_skc
 
 	* sign.c (clearsign_file): Support for v4 signatures.
 	(sign_file): Ditto.
 
 Wed May  6 09:31:24 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (do_parse): add support for 5 byte length leader.
 	(parse_subpkt): Ditto.
 	* build-packet.c (write_new_header): Ditto.
 
 	* packet.h (SIGSUBPKT_): New constants.
 	* parse-packet.c (parse_sig_subpkt): Changed name, made global,
 	and arg to return packet length, chnaged all callers
 
 
 Tue May  5 22:11:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (gen_dsa): New.
 	* build_packet.c (do_secret_cert): Support for DSA
 
 Mon May  4 19:01:25 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* compress.c: doubled buffer sizes
 	* parse-packet.c (do_plaintext): now uses iobuf_read/write.
 
 Mon May  4 09:35:53 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seskey.c (encode_md_value): Add optional argument hash_algo,
 	changed all callers.
 
 	* passphrase.c (make_dek_from_passphrase): Removed
 	* (get_passhrase_hash): Changed name to passphrase_to_dek, add arg,
 	changed all callers.
 
 	* all: Introduced the new ELG identifier and added support for the
 	encryption only one (which is okay to use by GNUPG for signatures).
 
 Sun May  3 17:50:26 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h (PKT_OLD_COMMENT): New name for type 16.
 	* parse-packet.c (parse_comment): Now uses type 61
 
 Fri May  1 12:44:39 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* packet.h (count): Chnaged s2k count from byte to u32.
 	* seckey-cert.c (do_check): Changed s2k algo 3 to 4, changed
 	reading of count.
 	* build-packet.c (do_secret_cert): ditto.
 	* parse-packet.c (parse_certificate): ditto.
 
 	* parse-packet.c (parse_symkeyenc): New.
 	* build-packet.c (do_symkey_enc): New.
 
 Thu Apr 30 16:33:34 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sign.c (clearsign_file): Fixed "Hash: " armor line.
 
 Tue Apr 28 14:27:42 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (parse_subpkt): Some new types.
 
 Mon Apr 27 12:53:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Add option --skip-verify.
 	* mainproc.c (check_sig_and_print): Ditto.
 
 	* g10.c (print_mds): Add output for Tiger.
 
 	* sign.c (sign_file): Now uses partial length headers if used
 	in canonical textmode (kludge to fix a bug).
 
 	* parse-packet.c (parse_certificate): Changed BLOWFISH id.
 	* pubkey-enc.c (get_session_key): Ditto.
 	* seskey.c (make_session_key): Ditto.
 	* seckey-cert.c (protect_secret_key,do_check): Add BLOWFISH160.
 
 Fri Apr 24 17:38:48 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* sig-check.c (check_key_signature): Add sig-class 0x14..0x17
 	* keyedit.c (sign-key): Some changes to start with support of
 	the above new sig-classes.
 
 Wed Apr 22 09:01:57 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* getkey.c (compare_name): add email matching
 
 Tue Apr 21 16:17:12 1998  Werner Koch,mobil,,,	(wk@tobold)
 
 	* armor.c (armor_filter): fixed missing last LF before CSUM.
 
 Thu Apr  9 11:35:22 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seckey-cert.c (do_check): New; combines all the check functions
 	into one.
 
 	* sign.c: removed all key management functions
 	* keyedit.c: New.
 
 Thu Apr  9 09:49:36 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* import.c (chk_self_sigs): Changed an error message.
 
 Wed Apr  8 16:19:39 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* packet.h: packet structs now uses structs from the pubkey,
 	removed all copy operations from packet to pubkey structs.
 
 Wed Apr  8 13:40:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (verify_own_certs): Fixed "public key not found".
 
 	* getkey.c (key_byname): New, combines public and secret key search.
 
 	* pkclist.c (build_pkc_list): Add new arg usage, changed all callers.
 	* skclist.c (build_skc_list): Likewise.
 
 	* ringedit.c (find_keyblock, keyring_search2): Removed.
 
 Wed Apr  8 09:47:21 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sig-check.c (do_check): Applied small fix from Ulf M�ller.
 
 Tue Apr  7 19:28:07 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* cipher.c, encr-data.c, seckey-cert.c: Now uses cipher_xxxx
 	functions instead of blowfish_xxx or cast_xxx
 
 Tue Apr  7 11:04:02 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* Makefile.am (g10maint.o): Changed the way it is created.
 
 Mon Apr  6 11:17:08 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* misc.c: New.
 	* keygen.c (checksum,checksum_u16,checksum_mpi): Moved to misc.c
 	* seckey-cert.c: Kludge for wrong ELG checksum implementation.
 
 Sat Apr  4 20:07:01 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* cipher.c (cipher_filter): Support for CAST5
 	* encr-data.c (decode_filter): Ditto.
 	(decrypt_data): Ditto.
 	* seskey.c (make_session_key): Ditto.
 	* seckey-cert.c (check_elg, check_dsa): Ditto,
 	(protect_secret_key): Ditto.
 	* pubkey-enc.c (get_session_key): Ditto.
 	* passphrase.c (hash_passphrase): Ditto.
 
 Thu Apr  2 20:22:35 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* gpgd.c: New
 
 Thu Apr  2 10:38:16 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (generate_keypair): Add valid_days stuff.
 	* trustdb.c (check_trust): Add check for valid_days.
 
 Wed Apr  1 16:15:58 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (generate_keypair): Addional question whether the
 	selected large keysize is really needed.
 
 Wed Apr  1 15:56:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* seckey-cert.c (protect_secret_key): merged protect_xxx to here.
 
 Wed Apr  1 10:34:46 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* Makefile.am (g10maint.c): Changed creation rule, so that it works
 	on FreeBSD (missing CFLAGS).
 
 	* parse-packet.c (parse_subkey): Removed.
 
 Thu Mar 19 15:22:36 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* ringedit.c (keyring_enum): Fixed problem with reading too
 	many packets. Add support to read secret keyrings.
 
 	* getkey.c (scan_keyring): Removed
 	(lookup): New to replace scan_keyring.
 	(scan_secret_keyring): Removed.
 	(lookup_skc): New.
 
 Wed Mar 18 11:47:34 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* ringedit.c (enum_keyblocks): New read mode 11.
 
 	* keyid.c (elg_fingerprint_md): New and changed all other functions
 	to call this if the packet version is 4 or above.
 
 Tue Mar 17 20:46:16 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (parse_certificate): Add listing support for subkeys.
 
 Tue Mar 17 20:32:22 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (is_armored): Allow marker packet.
 
 Thu Mar 12 13:36:49 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (check_trust): Checks timestamp of pubkey.
 	* sig-check. (do_check): Compares timestamps.
 
 Tue Mar 10 17:01:56 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Add call to init_signals.
 	* signal.c: New.
 
 Mon Mar  9 12:43:42 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* dsa.c: New
 	* packet.h, free-packet.c, parse-packet.c : Add support for DSA
 	* sig-check.c, getkey.c, keyid.c, ringedit.c: Ditto.
 	* seckey-cert.c: Ditto.
 
 	* packet.h : Moved .digest_algo of signature packets to outer
 	structure. Changed all references
 
 Sun Mar  8 13:06:42 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* openfile.c : Support for stdout filename "-".
 
 	* mainproc.c (check_sig_and_print): Enhanced status output:
 	* status.c (write_status_text): New.
 
 Fri Mar  6 16:10:54 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* kbnode.c (clone_kbnode): Fixed private_flag.
 
 	* mainproc.c (list_node): Output of string "Revoked" as user-id.
 
 Fri Mar  6 14:26:39 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Add userids to "-kv" and cleaned up this stuff.
 
 Fri Mar  6 12:45:58 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Changed semantics of the list-... commands
 	and added a new one. Removed option "-d"
 
 	* decrypt.c: New.
 
 	* trustdb.c (init_trustdb): Autocreate directory only if it ends
 	in "/.gnupg".
 
 Thu Mar  5 12:12:11 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c (do_proc_packets): New. Common part of proc_packet.
 	(proc_signature_packets): special version to handle signature data.
 	* verify.c: New.
 	* g10.c (aVerify): New.
 	* plaintext.c (hash_datafiles): New.
 	* compress.c (handle_compressed): Add callback arg, changed caller.
 
 Thu Mar  5 10:20:06 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c: Is nom the common source for gpg and gpgm
 	* g10maint.c: Removed
 	* Makefile.am: Add rule to build g10maint.c
 
 Thu Mar  5 08:43:59 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Changed the way clear text sigs are faked.
 
 Wed Mar  4 19:47:37 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10maint.c (aMuttKeyList): New
 	* keylist.c: New.
 
 Wed Mar  4 17:20:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (get_pubkey_byname): Kludge to allow 0x prefix.
 
 Tue Mar  3 13:46:55 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10maint.c (main): New option --gen-random.
 
 Tue Mar  3 09:50:08 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (aDeleteSecretKey): New.
 	(aEditSig): Add option "--edit-key" as synonym for "--edit-sig".
 	(aDeleteSecretKey): New.
 	* getkey.c (seckey_available): New.
 	* sign.c (delete_key): Enhanced to delete secret keys, changed all
 	callers.
 
 Mon Mar  2 21:23:48 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* pkc_list.c (build_pkc_list): Add interactive input of user ID.
 
 Mon Mar  2 20:54:05 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* pkclist.c (do_we_trust_pre): New.
 	(add_ownertrust): Add message.
 	* trustdb.c (enum_trust_web): Quick fix.
 
 Mon Mar  2 13:50:53 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): New action aDeleteKey
 	* sign.c (delete_key): New.
 
 Sun Mar  1 16:38:58 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (do_check): No returns TRUST_UNDEFINED instead of
 	eof error.
 
 Fri Feb 27 18:14:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (find_header): Removed trailing CR on headers.
 
 Fri Feb 27 18:02:48 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* ringedit.c (keyring_search) [MINGW32]: Open and close file here
 	because rename does not work on open files. Chnaged callers.
 
 Fri Feb 27 16:43:11 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sig-check.c (do_check): Add an md_enable.
 	* mainproc.c (do_check_sig): Use md_open in case of detached sig
 	(proc_tree): Take detached sigs into account.
 
 Fri Feb 27 15:22:46 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): Make use of GNUPGHOME envvar.
 	* g10main.c (main): Ditto.
 
 Wed Feb 25 11:40:04 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* plaintext.c (ask_for_detached_datafile): add opt.verbose to
 	info output.
 
 	* openfile.c (open_sigfile): Try also name ending in ".asc"
 
 Wed Feb 25 08:41:00 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* keygen.c (generate_keypair): Fixed memory overflow.
 
 Tue Feb 24 15:51:55 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (parse_certificate): Support for S2K.
 	* build-packet.c (do_secret_cert): Ditto.
 	* keygen.c (gen_elg): Ditto.
 	* seckey-cert.c (check_elg): Ditto
 	(protect_elg): Ditto.
 	* sign.c (chnage_passphrase): Ditto.
 	* passphrase.c (get_passphrase_hash): Support for a salt and
 	changed all callers.
 	(make_dek_from_passphrase): Ditto.
 
 Tue Feb 24 12:30:56 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* build-packet.c (hash_public_cert): Disabled debug output.
 
 Fri Feb 20 17:22:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (init_trustdb) [MINGW32]: Removed 2nd mkdir arg.
 	(keyring_copy) [MINGW32]: Add a remove prior to the renames.
 
 Wed Feb 18 18:39:02 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* Makefile.am (OMIT_DEPENDENCIES): New.
 
 	* rsa.c: Replaced log_bug by BUG.
 
 Wed Feb 18 13:35:58 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c (do_check_sig): Now uses hash_public_cert.
 	* parse-packet.c (parse_certificate): Removed hashing.
 	* packet.h (public_cert): Removed hash variable.
 	* free-packet.c (copy_public_cert, free_public_cert): Likewise.
 
 	* sig-check.c (check_key_signatures): Changed semantics.
 
 Wed Feb 18 12:11:28 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* trustdb.c (do_check): Add handling for revocation certificates.
 	(build_sigrecs): Ditto.
 	(check_sigs): Ditto.
 
 Wed Feb 18 09:31:04 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (armor_filter): Add afx->hdrlines.
 	* revoke.c (gen_revoke): Add comment line.
 	* dearmor.c (enarmor_file): Ditto.
 
 	* sig-check.c (check_key_signature): Add handling for class 0x20.
 	* mainproc.c : Ditto.
 
 Tue Feb 17 21:24:17 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c : Add header lines "...ARMORED FILE .."
 	* dearmor.c (enarmor_file): New.
 	* g10maint.c (main): New option "--enarmor"
 
 Tue Feb 17 19:03:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c : Changed a lot, because the packets are now stored
 	a simple linlked list and not anymore in a complicatd tree structure.
 
 Tue Feb 17 10:14:48 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* free_packet.c (cmp_public_certs): New.
 	(cmp_user_ids): New.
 
 	* kbnode.c (clone_kbnode): New.
 	(release_kbnode): Add clone support.
 
 	* ringedit.c (find_keyblock_bypkc): New.
 
 	* sign.c (remove_keysigs): Self signatures are now skipped,
 	changed arguments and all callers.
 
 	* import.c : Add functionality.
 
 Tue Feb 17 09:31:40 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* options.h (homedir): New option.
 	* g10.c, g10maint.c, getkey.c, keygen.c, trustdb.c (opt.homedir): New.
 
 	* trustdb.c (init_trustdb): mkdir for hoem directory
 	(sign_private_data): Renamed "sig" to "g10.sig"
 
 Mon Feb 16 20:02:03 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* kbnode.c (commit_kbnode): New.
 	(delete_kbnode): removed unused first arg. Changed all Callers.
 
 	* ringedit.c (keyblock_resource_name): New.
 	(get_keyblock_handle): NULL for filename returns default resource.
 
 Mon Feb 16 19:38:48 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* sig-check.s (check_key_signature): Now uses the supplied
 	public key to check the signature and not any more the one
 	from the getkey.c
 	(do_check): New.
 	(check_signature): Most work moved to do_check.
 
 Mon Feb 16 14:48:57 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (find_header): Fixed another bug.
 
 Mon Feb 16 12:18:34 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* getkey.c (scan_keyring): Add handling of compressed keyrings.
 
 Mon Feb 16 10:44:51 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c, g10maint.c (strusage): Rewrote.
 	(build_list): New
 
 Mon Feb 16 08:58:41 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (use_armor): New.
 
 Sat Feb 14 14:30:57 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* mainproc.c (proc_tree): Sigclass fix.
 
 Sat Feb 14 14:16:33 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* armor.c (armor_filter): Changed version and comment string.
 	* encode.c, sign.c, keygen.c: Changed all comment packet strings.
 
 Sat Feb 14 12:39:24 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (aGenRevoke): New command.
 	* revoke.c: New.
 	* sign.c (make_keysig_packet): Add support for sigclass 0x20.
 
 Fri Feb 13 20:18:14 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* ringedit.c (enum_keyblocks, keyring_enum): New.
 
 Fri Feb 13 19:33:40 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* export.c: Add functionality.
 
 	* keygen.c (generate_keypair): Moved the leading comment behind the
 	key packet.
 	* kbnode.c (walk_kbnode): Fixed.
 
 	* g10.c (main): listing armored keys now work.
 
 Fri Feb 13 16:17:43 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* parse-packet.c (parse_publickey, parse_signature): Fixed calls
 	to mpi_read used for ELG b.
 
 Fri Feb 13 15:13:23 1998  Werner Koch  (wk@isil.d.shuttle.de)
 
 	* g10.c (main): changed formatting of help output.
 
 Thu Feb 12 22:24:42 1998  Werner Koch  (wk@frodo)
 
 	* pubkey-enc.c (get_session_key): rewritten
 
 
  Copyright 1998,1999,2000,2001,2002,2003 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
  modifications, as long as this notice is preserved.
 
  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.
diff --git a/g10/comment.c b/g10/comment.c
index ab5d2941e..b52104cd7 100644
--- a/g10/comment.c
+++ b/g10/comment.c
@@ -1,107 +1,112 @@
 /* comment.c - write comment stuff
  *	Copyright (C) 1998, 2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
 
 #include "options.h"
 #include "packet.h"
 #include "errors.h"
 #include "iobuf.h"
 #include "memory.h"
 #include "util.h"
 #include "main.h"
 #include "keydb.h"
 
 
 
 int
 write_comment( iobuf_t out, const char *s )
 {
     PACKET pkt;
     size_t n = strlen(s);
     int rc=0;
 
     pkt.pkttype = PKT_COMMENT;
     if( *s != '#' ) {
        pkt.pkt.comment = xmalloc ( sizeof *pkt.pkt.comment + n );
        pkt.pkt.comment->len = n+1;
        *pkt.pkt.comment->data = '#';
        strcpy(pkt.pkt.comment->data+1, s);
     }
     else {
        pkt.pkt.comment = xmalloc ( sizeof *pkt.pkt.comment + n - 1 );
        pkt.pkt.comment->len = n;
        strcpy(pkt.pkt.comment->data, s);
     }
     if( (rc = build_packet( out, &pkt )) )
 	log_error("build_packet(comment) failed: %s\n", gpg_strerror (rc) );
     free_packet( &pkt );
     return rc;
 }
 
 
 KBNODE
-make_comment_node( const char *s )
+make_comment_node_from_buffer (const char *s, size_t n)
 {
     PACKET *pkt;
-    size_t n = strlen(s);
 
-    pkt = xcalloc (1, sizeof *pkt );
+    pkt = gcry_xcalloc( 1, sizeof *pkt );
     pkt->pkttype = PKT_COMMENT;
-    pkt->pkt.comment = xmalloc ( sizeof *pkt->pkt.comment + n - 1 );
+    pkt->pkt.comment = gcry_xmalloc( sizeof *pkt->pkt.comment + n - 1 );
     pkt->pkt.comment->len = n;
     strcpy(pkt->pkt.comment->data, s);
     return new_kbnode( pkt );
 }
 
+KBNODE
+make_comment_node( const char *s )
+{
+  return make_comment_node_from_buffer (s, strlen (s));
+}
+
 
 KBNODE
 make_mpi_comment_node( const char *s, gcry_mpi_t a )
 {
     PACKET *pkt;
     byte *buf, *pp;
     size_t n1, nb1;
     size_t n = strlen(s);
 
     nb1 = mpi_get_nbits( a );
     if (gcry_mpi_print (GCRYMPI_FMT_PGP, NULL, 0, &n1, a))
       BUG ();
     /* fixme: allocate it on the stack */
     buf = xmalloc (n1);
     if (gcry_mpi_print (GCRYMPI_FMT_PGP, buf, n1, &n1, a))
       BUG ();
 
     pkt = xcalloc (1, sizeof *pkt );
     pkt->pkttype = PKT_COMMENT;
     pkt->pkt.comment = xmalloc ( sizeof *pkt->pkt.comment + n + 2 + n1 );
     pkt->pkt.comment->len = n+1+2+n1;
     pp = pkt->pkt.comment->data;
     memcpy(pp, s, n+1);
     memcpy(pp+n+1, buf, n1 );
     xfree (buf);
     return new_kbnode( pkt );
 }
 
 
diff --git a/g10/g10.c b/g10/g10.c
index 2f0a78cd0..f89556184 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -1,3255 +1,3247 @@
 /* g10.c - The GnuPG utility (main for gpg)
  * Copyright (C) 1998,1999,2000,2001,2002,2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <errno.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <unistd.h>
 #include <assert.h>
 #ifdef HAVE_DOSISH_SYSTEM
 #include <fcntl.h> /* for setmode() */
 #endif
 #ifdef HAVE_STAT
 #include <sys/stat.h> /* for stat() */
 #endif
+#include <assuan.h>
 
 #define INCLUDED_BY_MAIN_MODULE 1
 #include "gpg.h"
 #include "packet.h"
 #include "iobuf.h"
 #include "memory.h"
 #include "util.h"
 #include "main.h"
 #include "options.h"
 #include "keydb.h"
 #include "trustdb.h"
 #include "mpi.h"
 #include "cipher.h"
 #include "filter.h"
 #include "ttyio.h"
 #include "i18n.h"
 #include "status.h"
 #include "keyserver-internal.h"
 #include "exec.h"
 
 enum cmd_and_opt_values { aNull = 0,
     oArmor	  = 'a',
     aDetachedSign = 'b',
     aSym	  = 'c',
     aDecrypt	  = 'd',
     aEncr	  = 'e',
     aEncrFiles,
     oInteractive  = 'i',
     oKOption	  = 'k',
     oDryRun	  = 'n',
     oOutput	  = 'o',
     oQuiet	  = 'q',
     oRecipient	  = 'r',
     oHiddenRecipient = 'R',
     aSign	  = 's',
     oTextmodeShort= 't',
     oUser	  = 'u',
     oVerbose	  = 'v',
     oCompress	  = 'z',
     oNotation	  = 'N',
     oBatch	  = 500,
     oSigNotation,
     oCertNotation,
     oShowNotation,
     oNoShowNotation,
     aDecryptFiles,                          
     aClearsign,
     aStore,
     aKeygen,
     aSignEncr,
     aSignSym,
     aSignKey,
     aLSignKey,
     aNRSignKey,
     aNRLSignKey,
     aListPackets,
     aEditKey,
     aDeleteKeys,
     aDeleteSecretKeys,
     aDeleteSecretAndPublicKeys,
     aKMode,
     aKModeC,
     aImport,
     aFastImport,
     aVerify,
     aVerifyFiles,
     aListKeys,
     aListSigs,
     aListSecretKeys,
     aSendKeys,
     aRecvKeys,
     aSearchKeys,
     aExport,
     aExportAll,
     aExportSecret,
     aExportSecretSub,
     aCheckKeys,
     aGenRevoke,
     aDesigRevoke,
     aPrimegen,
     aPrintMD,
     aPrintMDs,
     aCheckTrustDB,
     aUpdateTrustDB,
     aFixTrustDB,
     aListTrustDB,
     aListTrustPath,
     aExportOwnerTrust,
     aListOwnerTrust,
     aImportOwnerTrust,
     aDeArmor,
     aEnArmor,
     aGenRandom,
     aPipeMode,
     aRebuildKeydbCaches,
     aRefreshKeys,
     aCardStatus,
     aChangePIN,
 
     oTextmode,
     oNoTextmode,
     oExpert,
     oNoExpert,
     oAskSigExpire,
     oNoAskSigExpire,
     oAskCertExpire,
     oNoAskCertExpire,
     oFingerprint,
     oWithFingerprint,
     oAnswerYes,
     oAnswerNo,
     oDefCertCheckLevel,
     oKeyring,
     oPrimaryKeyring,
     oSecretKeyring,
     oShowKeyring,
     oDefaultKey,
     oDefRecipient,
     oDefRecipientSelf,
     oNoDefRecipient,
     oOptions,
     oDebug,
     oDebugAll,
     oStatusFD,
 #ifdef __riscos__
     oStatusFile,
 #endif /* __riscos__ */
     oAttributeFD,
 #ifdef __riscos__
     oAttributeFile,
 #endif /* __riscos__ */
     oSKComments,
     oNoSKComments,
     oEmitVersion,
     oNoEmitVersion,
     oCompletesNeeded,
     oMarginalsNeeded,
     oMaxCertDepth,
     oLoadExtension,
     oGnuPG,
     oRFC1991,
     oOpenPGP,
     oPGP2,
     oPGP6,
     oPGP7,
     oPGP8,
     oCipherAlgo,
     oDigestAlgo,
     oCertDigestAlgo,
     oCompressAlgo,
     oPasswdFD,
 #ifdef __riscos__
     oPasswdFile,
 #endif /* __riscos__ */
     oCommandFD,
 #ifdef __riscos__
     oCommandFile,
 #endif /* __riscos__ */
     oQuickRandom,
     oNoVerbose,
     oTrustDBName,
     oNoSecmemWarn,
     oNoPermissionWarn,
     oNoMDCWarn,
     oNoArmor,
     oNoDefKeyring,
     oNoGreeting,
     oNoTTY,
     oNoOptions,
     oNoBatch,
     oHomedir,
     oWithColons,
     oWithKeyData,
     oSkipVerify,
     oCompressKeys,
     oCompressSigs,
     oAlwaysTrust,
     oTrustModel,
     oForceOwnertrust,
     oEmuChecksumBug,
     oRunAsShmCP,
     oSetFilename,
     oForYourEyesOnly,
     oNoForYourEyesOnly,
     oSetPolicyURL,
     oSigPolicyURL,
     oCertPolicyURL,
     oShowPolicyURL,
     oNoShowPolicyURL,
     oUseEmbeddedFilename,
     oComment,
     oDefaultComment,
     oThrowKeyid,
     oNoThrowKeyid,
     oShowPhotos,
     oNoShowPhotos,
     oPhotoViewer,
     oForceV3Sigs,
     oNoForceV3Sigs,
     oForceV4Certs,
     oNoForceV4Certs,
     oForceMDC,
     oNoForceMDC,
     oDisableMDC,
     oNoDisableMDC,
     oS2KMode,
     oS2KDigest,
     oS2KCipher,
     oSimpleSKChecksum,                          
     oCharset,
     oNotDashEscaped,
     oEscapeFrom,
     oNoEscapeFrom,
     oLockOnce,
     oLockMultiple,
     oLockNever,
     oKeyServer,
     oKeyServerOptions,
     oImportOptions,
     oExportOptions,
     oListOptions,
     oVerifyOptions,
     oTempDir,
     oExecPath,
     oEncryptTo,
     oHiddenEncryptTo,
     oNoEncryptTo,
     oLoggerFD,
 #ifdef __riscos__
     oLoggerFile,
 #endif /* __riscos__ */
     oUtf8Strings,
     oNoUtf8Strings,
     oDisableCipherAlgo,
     oDisablePubkeyAlgo,
     oAllowNonSelfsignedUID,
     oNoAllowNonSelfsignedUID,
     oAllowFreeformUID,
     oNoAllowFreeformUID,
     oAllowSecretKeyImport,                      
     oEnableSpecialFilenames,
     oNoLiteral,
     oSetFilesize,
     oHonorHttpProxy,
     oFastListMode,
     oListOnly,
     oIgnoreTimeConflict,
     oIgnoreValidFrom,
     oIgnoreCrcError,
     oIgnoreMDCError,
     oShowSessionKey,
     oOverrideSessionKey,
     oNoRandomSeedFile,
     oAutoKeyRetrieve,
     oNoAutoKeyRetrieve,
     oUseAgent,
     oNoUseAgent,
     oGpgAgentInfo,
     oMergeOnly,
     oTryAllSecrets,
     oTrustedKey,
     oNoExpensiveTrustChecks,
     oFixedListMode,
     oNoSigCache,
     oNoSigCreateCheck,
     oAutoCheckTrustDB,
     oNoAutoCheckTrustDB,
     oPreservePermissions,
     oDefaultPreferenceList,
     oPersonalCipherPreferences,
     oPersonalDigestPreferences,
     oPersonalCompressPreferences,
     oEmuMDEncodeBug,
     oAgentProgram,
     oDisplay,
     oTTYname,
     oTTYtype,
     oLCctype,
     oLCmessages,
     oGroup,
     oStrict,
     oNoStrict,
     oMangleDosFilenames,
     oNoMangleDosFilenames,
     oEnableProgressFilter,                          
 aTest };
 
 
 static ARGPARSE_OPTS opts[] = {
 
     { 300, NULL, 0, N_("@Commands:\n ") },
 
     { aSign, "sign",      256, N_("|[file]|make a signature")},
     { aClearsign, "clearsign", 256, N_("|[file]|make a clear text signature") },
     { aDetachedSign, "detach-sign", 256, N_("make a detached signature")},
     { aEncr, "encrypt",   256, N_("encrypt data")},
     { aEncrFiles, "encrypt-files", 256, N_("|[files]|encrypt files")},
     { aSym, "symmetric", 256, N_("encryption only with symmetric cipher")},
     { aStore, "store",     256, N_("store only")},
     { aDecrypt, "decrypt",   256, N_("decrypt data (default)")},
     { aDecryptFiles, "decrypt-files", 256, N_("|[files]|decrypt files")},
     { aVerify, "verify"   , 256, N_("verify a signature")},
     { aVerifyFiles, "verify-files" , 256, "@" },
     { aListKeys, "list-keys", 256, N_("list keys")},
     { aListKeys, "list-public-keys", 256, "@" },
     { aListSigs, "list-sigs", 256, N_("list keys and signatures")},
     { aCheckKeys, "check-sigs",256, N_("check key signatures")},
     { oFingerprint, "fingerprint", 256, N_("list keys and fingerprints")},
     { aListSecretKeys, "list-secret-keys", 256, N_("list secret keys")},
     { aKeygen,	   "gen-key",  256, N_("generate a new key pair")},
     { aDeleteKeys,"delete-keys",256,N_("remove keys from the public keyring")},
     { aDeleteSecretKeys, "delete-secret-keys",256,
 				    N_("remove keys from the secret keyring")},
     { aSignKey,  "sign-key"   ,256, N_("sign a key")},
     { aLSignKey, "lsign-key"  ,256, N_("sign a key locally")},
     { aNRSignKey, "nrsign-key"  ,256, N_("sign a key non-revocably")},
     { aNRLSignKey, "nrlsign-key"  ,256, N_("sign a key locally and non-revocably")},
     { aEditKey,  "edit-key"   ,256, N_("sign or edit a key")},
     { aGenRevoke, "gen-revoke",256, N_("generate a revocation certificate")},
     { aDesigRevoke, "desig-revoke",256, "@" },
     { aExport, "export"           , 256, N_("export keys") },
     { aSendKeys, "send-keys"     , 256, N_("export keys to a key server") },
     { aRecvKeys, "recv-keys"     , 256, N_("import keys from a key server") },
     { aSearchKeys, "search-keys" , 256,
                                     N_("search for keys on a key server") },
     { aRefreshKeys, "refresh-keys", 256,
                                     N_("update all keys from a keyserver")},
     { aExportAll, "export-all"    , 256, "@" },
     { aExportSecret, "export-secret-keys" , 256, "@" },
     { aExportSecretSub, "export-secret-subkeys" , 256, "@" },
     { aImport, "import",      256     , N_("import/merge keys")},
     { aFastImport, "fast-import",  256 , "@"},
     { aCardStatus,  "card-status", 256, N_("print the card status")},
     { aChangePIN,  "change-pin", 256, N_("change a card's PIN")},
 
     { aListPackets, "list-packets",256,N_("list only the sequence of packets")},
     { aExportOwnerTrust,
 	      "export-ownertrust", 256, N_("export the ownertrust values")},
     { aImportOwnerTrust,
 	      "import-ownertrust", 256, N_("import ownertrust values")},
     { aUpdateTrustDB,
 	      "update-trustdb",0 , N_("update the trust database")},
     { aCheckTrustDB,
 	      "check-trustdb",0 , N_("unattended trust database update")},
     { aFixTrustDB, "fix-trustdb",0 , N_("fix a corrupted trust database")},
     { aDeArmor, "dearmor", 256, N_("De-Armor a file or stdin") },
     { aDeArmor, "dearmour", 256, "@" },
     { aEnArmor, "enarmor", 256, N_("En-Armor a file or stdin") },
     { aEnArmor, "enarmour", 256, "@" },
     { aPrintMD,  "print-md" , 256, N_("|algo [files]|print message digests")},
     { aPrimegen, "gen-prime" , 256, "@" },
     { aGenRandom, "gen-random" , 256, "@" },
 
     { 301, NULL, 0, N_("@\nOptions:\n ") },
 
     { oArmor, "armor",     0, N_("create ascii armored output")},
     { oArmor, "armour",     0, "@" },
     { oRecipient, "recipient", 2, N_("|NAME|encrypt for NAME")},
     { oHiddenRecipient, "hidden-recipient", 2, "@" },
     { oRecipient, "remote-user", 2, "@"},  /* old option name */
     { oDefRecipient, "default-recipient" ,2,
 				  N_("|NAME|use NAME as default recipient")},
     { oDefRecipientSelf, "default-recipient-self" ,0,
 				N_("use the default key as default recipient")},
     { oNoDefRecipient, "no-default-recipient", 0, "@" },
     { oTempDir, "temp-directory", 2, "@" },
     { oExecPath, "exec-path", 2, "@" },
     { oEncryptTo, "encrypt-to", 2, "@" },
     { oHiddenEncryptTo, "hidden-encrypt-to", 2, "@" },
     { oNoEncryptTo, "no-encrypt-to", 0, "@" },
     { oUser, "local-user",2, N_("use this user-id to sign or decrypt")},
     { oCompress, NULL,	      1, N_("|N|set compress level N (0 disables)") },
     { oTextmodeShort, NULL,   0, "@"},
     { oTextmode, "textmode",  0, N_("use canonical text mode")},
     { oNoTextmode, "no-textmode",  0, "@"},
     { oExpert, "expert",   0, "@"},
     { oNoExpert, "no-expert",   0, "@"},
     { oAskSigExpire, "ask-sig-expire",   0, "@"},
     { oNoAskSigExpire, "no-ask-sig-expire",   0, "@"},
     { oAskCertExpire, "ask-cert-expire",   0, "@"},
     { oNoAskCertExpire, "no-ask-cert-expire",   0, "@"},
     { oOutput, "output",    2, N_("use as output file")},
     { oVerbose, "verbose",   0, N_("verbose") },
     { oQuiet,	"quiet",   0, N_("be somewhat more quiet") },
     { oNoTTY, "no-tty", 0, N_("don't use the terminal at all") },
     { oForceV3Sigs, "force-v3-sigs", 0, N_("force v3 signatures") },
     { oNoForceV3Sigs, "no-force-v3-sigs", 0, N_("do not force v3 signatures") },
     { oForceV4Certs, "force-v4-certs", 0, N_("force v4 key signatures") },
     { oNoForceV4Certs, "no-force-v4-certs", 0, N_("do not force v4 key signatures") },
     { oForceMDC, "force-mdc", 0, N_("always use a MDC for encryption") },
     { oNoForceMDC, "no-force-mdc", 0, "@" },
     { oDisableMDC, "disable-mdc", 0, N_("never use a MDC for encryption") },
     { oNoDisableMDC, "no-disable-mdc", 0, "@" },
     { oDryRun, "dry-run",   0, N_("do not make any changes") },
     { oInteractive, "interactive", 0, N_("prompt before overwriting") },
     { oUseAgent, "use-agent",0, N_("use the gpg-agent")},
     { oNoUseAgent, "no-use-agent",0, "@"},
     { oGpgAgentInfo, "gpg-agent-info",2, "@"},
     { oBatch, "batch",     0, N_("batch mode: never ask")},
     { oAnswerYes, "yes",       0, N_("assume yes on most questions")},
     { oAnswerNo,  "no",        0, N_("assume no on most questions")},
     { oKeyring, "keyring"   ,2, N_("add this keyring to the list of keyrings")},
     { oPrimaryKeyring, "primary-keyring",2, "@" },
     { oSecretKeyring, "secret-keyring" ,2, N_("add this secret keyring to the list")},
     { oShowKeyring, "show-keyring", 0, N_("show which keyring a listed key is on")},
     { oDefaultKey, "default-key" ,2, N_("|NAME|use NAME as default secret key")},
     { oKeyServer, "keyserver",2, N_("|HOST|use this keyserver to lookup keys")},
     { oKeyServerOptions, "keyserver-options",2,"@"},
     { oImportOptions, "import-options",2,"@"},
     { oExportOptions, "export-options",2,"@"},
     { oListOptions, "list-options",2,"@"},
     { oCharset, "charset"   , 2, N_("|NAME|set terminal charset to NAME") },
     { oOptions, "options"   , 2, N_("read options from file")},
 
     { oDebug, "debug"     ,4|16, "@"},
     { oDebugAll, "debug-all" ,0, "@"},
     { oStatusFD, "status-fd" ,1, N_("|FD|write status info to this FD") },
 #ifdef __riscos__
     { oStatusFile, "status-file" ,2, N_("|[file]|write status info to file") },
 #endif /* __riscos__ */
     { oAttributeFD, "attribute-fd" ,1, "@" },
 #ifdef __riscos__
     { oAttributeFile, "attribute-file" ,2, "@" },
 #endif /* __riscos__ */
     { oNoSKComments, "no-comment", 0,   "@"},
     { oNoSKComments, "no-sk-comments", 0,   "@"},
     { oSKComments, "sk-comments", 0,   "@"},
     { oCompletesNeeded, "completes-needed", 1, "@"},
     { oMarginalsNeeded, "marginals-needed", 1, "@"},
     { oMaxCertDepth,	"max-cert-depth", 1, "@" },
     { oTrustedKey, "trusted-key", 2, N_("|KEYID|ultimately trust this key")},
     { oLoadExtension, "load-extension" ,2, N_("|FILE|load extension module FILE")},
     { oGnuPG, "gnupg",   0, "@"},
     { oGnuPG, "no-pgp2", 0, "@"},
     { oGnuPG, "no-pgp6", 0, "@"},
     { oGnuPG, "no-pgp7", 0, "@"},
     { oGnuPG, "no-pgp8", 0, "@"},
     { oRFC1991, "rfc1991",   0, N_("emulate the mode described in RFC1991")},
     { oOpenPGP, "openpgp", 0, N_("set all packet, cipher and digest options to OpenPGP behavior")},
     { oPGP2, "pgp2", 0, N_("set all packet, cipher and digest options to PGP 2.x behavior")},
     { oPGP6, "pgp6", 0, "@"},
     { oPGP7, "pgp7", 0, "@"},
     { oPGP8, "pgp8", 0, "@"},
     { oS2KMode, "s2k-mode",  1, N_("|N|use passphrase mode N")},
     { oS2KDigest, "s2k-digest-algo",2,
 		N_("|NAME|use message digest algorithm NAME for passphrases")},
     { oS2KCipher, "s2k-cipher-algo",2,
 		N_("|NAME|use cipher algorithm NAME for passphrases")},
     { oSimpleSKChecksum, "simple-sk-checksum", 0, "@"},
     { oCipherAlgo, "cipher-algo", 2 , N_("|NAME|use cipher algorithm NAME")},
     { oDigestAlgo, "digest-algo", 2 , N_("|NAME|use message digest algorithm NAME")},
     { oCertDigestAlgo, "cert-digest-algo", 2 , "@" },
     { oCompressAlgo,"compress-algo",2,N_("|NAME|use compression algorithm NAME")},
     { oThrowKeyid, "throw-keyid", 0, N_("throw keyid field of encrypted packets")},
     { oNoThrowKeyid, "no-throw-keyid", 0, "@" },
     { oShowPhotos,   "show-photos", 0, "@" },
     { oNoShowPhotos, "no-show-photos", 0, "@" },
     { oPhotoViewer,  "photo-viewer", 2, "@" },
     { oNotation,   "notation-data", 2, "@" },
     { oSigNotation,   "sig-notation", 2, "@" },
     { oCertNotation,  "cert-notation", 2, "@" },
 
     { 302, NULL, 0, N_(
   "@\n(See the man page for a complete listing of all commands and options)\n"
 		      )},
 
     { 303, NULL, 0, N_("@\nExamples:\n\n"
     " -se -r Bob [file]          sign and encrypt for user Bob\n"
     " --clearsign [file]         make a clear text signature\n"
     " --detach-sign [file]       make a detached signature\n"
     " --list-keys [names]        show keys\n"
     " --fingerprint [names]      show fingerprints\n"  ) },
 
   /* hidden options */
     { aListOwnerTrust, "list-ownertrust", 256, "@"}, /* deprecated */
     { oCompressAlgo, "compression-algo", 1, "@"}, /* alias */
     { aPrintMDs, "print-mds" , 256, "@"}, /* old */
     { aListTrustDB, "list-trustdb",0 , "@"},
     /* Not yet used */
     /* { aListTrustPath, "list-trust-path",0, "@"}, */
     { aPipeMode,  "pipemode", 0, "@" },
     { oKOption, NULL,	 0, "@"},
     { oPasswdFD, "passphrase-fd",1, "@" },
 #ifdef __riscos__
     { oPasswdFile, "passphrase-file",2, "@" },
 #endif /* __riscos__ */
     { oCommandFD, "command-fd",1, "@" },
 #ifdef __riscos__
     { oCommandFile, "command-file",2, "@" },
 #endif /* __riscos__ */
     { oQuickRandom, "quick-random", 0, "@"},
     { oNoVerbose, "no-verbose", 0, "@"},
     { oTrustDBName, "trustdb-name", 2, "@" },
     { oNoSecmemWarn, "no-secmem-warning", 0, "@" }, /* used only by regression tests */
     { oNoPermissionWarn, "no-permission-warning", 0, "@" },
     { oNoMDCWarn, "no-mdc-warning", 0, "@" },
     { oNoArmor, "no-armor",   0, "@"},
     { oNoArmor, "no-armour",   0, "@"},
     { oNoDefKeyring, "no-default-keyring", 0, "@" },
     { oNoGreeting, "no-greeting", 0, "@" },
     { oNoOptions, "no-options", 0, "@" }, /* shortcut for --options /dev/null */
     { oHomedir, "homedir", 2, "@" },   /* defaults to "~/.gnupg" */
     { oNoBatch, "no-batch", 0, "@" },
     { oWithColons, "with-colons", 0, "@"},
     { oWithKeyData,"with-key-data", 0, "@"},
     { aListKeys, "list-key", 0, "@" }, /* alias */
     { aListSigs, "list-sig", 0, "@" }, /* alias */
     { aCheckKeys, "check-sig",0, "@" }, /* alias */
     { oSkipVerify, "skip-verify",0, "@" },
     { oCompressKeys, "compress-keys",0, "@"},
     { oCompressSigs, "compress-sigs",0, "@"},
     { oDefCertCheckLevel, "default-cert-check-level", 1, "@"},
     { oAlwaysTrust, "always-trust", 0, "@"},
     { oTrustModel, "trust-model", 2, "@"},
     { oForceOwnertrust, "force-ownertrust", 2, "@"},
     { oEmuChecksumBug, "emulate-checksum-bug", 0, "@"},
     { oRunAsShmCP, "run-as-shm-coprocess", 4, "@" },
     { oSetFilename, "set-filename", 2, "@" },
     { oForYourEyesOnly, "for-your-eyes-only", 0, "@" },
     { oNoForYourEyesOnly, "no-for-your-eyes-only", 0, "@" },
     { oSetPolicyURL, "set-policy-url", 2, "@" },
     { oSigPolicyURL, "sig-policy-url", 2, "@" },
     { oCertPolicyURL, "cert-policy-url", 2, "@" },
     { oShowPolicyURL, "show-policy-url", 0, "@" },
     { oNoShowPolicyURL, "no-show-policy-url", 0, "@" },
     { oShowNotation, "show-notation", 0, "@" },
     { oNoShowNotation, "no-show-notation", 0, "@" },
     { oComment, "comment", 2, "@" },
     { oDefaultComment, "default-comment", 0, "@" },
     { oEmitVersion, "emit-version", 0, "@"},
     { oNoEmitVersion, "no-emit-version", 0, "@"},
     { oNoEmitVersion, "no-version", 0, "@"}, /* alias */
     { oNotDashEscaped, "not-dash-escaped", 0, "@" },
     { oEscapeFrom, "escape-from-lines", 0, "@" },
     { oNoEscapeFrom, "no-escape-from-lines", 0, "@" },
     { oLockOnce, "lock-once", 0, "@" },
     { oLockMultiple, "lock-multiple", 0, "@" },
     { oLockNever, "lock-never", 0, "@" },
     { oLoggerFD, "logger-fd",1, "@" },
 #ifdef __riscos__
     { oLoggerFile, "logger-file",2, "@" },
 #endif /* __riscos__ */
     { oUseEmbeddedFilename, "use-embedded-filename", 0, "@" },
     { oUtf8Strings, "utf8-strings", 0, "@" },
     { oNoUtf8Strings, "no-utf8-strings", 0, "@" },
     { oWithFingerprint, "with-fingerprint", 0, "@" },
     { oDisableCipherAlgo,  "disable-cipher-algo", 2, "@" },
     { oDisablePubkeyAlgo,  "disable-pubkey-algo", 2, "@" },
     { oAllowNonSelfsignedUID, "allow-non-selfsigned-uid", 0, "@" },
     { oNoAllowNonSelfsignedUID, "no-allow-non-selfsigned-uid", 0, "@" },
     { oAllowFreeformUID, "allow-freeform-uid", 0, "@" },
     { oNoAllowFreeformUID, "no-allow-freeform-uid", 0, "@" },
     { oNoLiteral, "no-literal", 0, "@" },
     { oSetFilesize, "set-filesize", 20, "@" },
     { oHonorHttpProxy,"honor-http-proxy", 0, "@" },
     { oFastListMode,"fast-list-mode", 0, "@" },
     { oFixedListMode,"fixed-list-mode", 0, "@" },
     { oListOnly, "list-only", 0, "@"},
     { oIgnoreTimeConflict, "ignore-time-conflict", 0, "@" },
     { oIgnoreValidFrom,    "ignore-valid-from",    0, "@" },
     { oIgnoreCrcError, "ignore-crc-error", 0,"@" },
     { oIgnoreMDCError, "ignore-mdc-error", 0,"@" },
     { oShowSessionKey, "show-session-key", 0, "@" },
     { oOverrideSessionKey, "override-session-key", 2, "@" },
     { oNoRandomSeedFile,  "no-random-seed-file", 0, "@" },
     { oAutoKeyRetrieve, "auto-key-retrieve", 0, "@" },
     { oNoAutoKeyRetrieve, "no-auto-key-retrieve", 0, "@" },
     { oNoSigCache,         "no-sig-cache", 0, "@" },
     { oNoSigCreateCheck,   "no-sig-create-check", 0, "@" },
     { oAutoCheckTrustDB, "auto-check-trustdb", 0, "@"},
     { oNoAutoCheckTrustDB, "no-auto-check-trustdb", 0, "@"},
     { oMergeOnly,	  "merge-only", 0, "@" },
     { oAllowSecretKeyImport, "allow-secret-key-import", 0, "@" },
     { oTryAllSecrets,  "try-all-secrets", 0, "@" },
     { oEnableSpecialFilenames, "enable-special-filenames", 0, "@" },
     { oNoExpensiveTrustChecks, "no-expensive-trust-checks", 0, "@" },
     { aDeleteSecretAndPublicKeys, "delete-secret-and-public-keys",256, "@" },
     { aRebuildKeydbCaches, "rebuild-keydb-caches", 256, "@"},
     { oPreservePermissions, "preserve-permissions", 0, "@"},
     { oDefaultPreferenceList,  "default-preference-list", 2, "@"},
     { oPersonalCipherPreferences,  "personal-cipher-preferences", 2, "@"},
     { oPersonalDigestPreferences,  "personal-digest-preferences", 2, "@"},
     { oPersonalCompressPreferences,  "personal-compress-preferences", 2, "@"},
     { oEmuMDEncodeBug,	"emulate-md-encode-bug", 0, "@"},
     { oAgentProgram, "agent-program", 2 , "@" },
     { oDisplay,    "display",     2, "@" },
     { oTTYname,    "ttyname",     2, "@" },
     { oTTYtype,    "ttytype",     2, "@" },
     { oLCctype,    "lc-ctype",    2, "@" },
     { oLCmessages, "lc-messages", 2, "@" },
     { oGroup,      "group",       2, "@" },
     { oStrict,     "strict",      0, "@" },
     { oNoStrict,   "no-strict",   0, "@" },
     { oMangleDosFilenames, "mangle-dos-filenames", 0, "@" },
     { oNoMangleDosFilenames, "no-mangle-dos-filenames", 0, "@" },
     { oEnableProgressFilter, "enable-progress-filter", 0, "@" },
 {0} };
 
 
 
 int g10_errors_seen = 0;
 
 static int utf8_strings = 0;
 static int maybe_setuid = 1;
 
 static char *build_list( const char *text, char letter,
 			 const char *(*mapf)(int), int (*chkf)(int) );
 static void set_cmd( enum cmd_and_opt_values *ret_cmd,
 			enum cmd_and_opt_values new_cmd );
 static void print_mds( const char *fname, int algo );
 static void add_notation_data( const char *string, int which );
 static void add_policy_url( const char *string, int which );
 static void emergency_cleanup (void);
 
 #ifdef __riscos__
 RISCOS_GLOBAL_STATICS("GnuPG Heap")
 #endif /* __riscos__ */
 
 static int
 pk_test_algo (int algo)
 {
   return openpgp_pk_test_algo (algo, 0);
 }
 
 
 static const char *
 my_strusage( int level )
 {
   static char *digests, *pubkeys, *ciphers, *zips;
     const char *p;
     switch( level ) {
       case 11: p = "gpg (GnuPG)";
 	break;
       case 13: p = VERSION; break;
       case 17: p = PRINTABLE_OS_NAME; break;
       case 19: p =
 	    _("Please report bugs to <gnupg-bugs@gnu.org>.\n");
 	break;
       case 1:
       case 40:	p =
 	    _("Usage: gpg [options] [files] (-h for help)");
 	break;
       case 41:	p =
 	    _("Syntax: gpg [options] [files]\n"
 	      "sign, check, encrypt or decrypt\n"
 	      "default operation depends on the input data\n");
 	break;
 
       case 31: p = "\nHome: "; break;
 #ifndef __riscos__
       case 32: p = opt.homedir; break;
 #else /* __riscos__ */
       case 32: p = make_filename(opt.homedir, NULL); break;
 #endif /* __riscos__ */
       case 33: p = _("\nSupported algorithms:\n"); break;
       case 34:
 	if( !pubkeys )
 	    pubkeys = build_list(_("Pubkey: "), 0, gcry_pk_algo_name,
                                  pk_test_algo );
 	p = pubkeys;
 	break;
       case 35:
 	if( !ciphers )
 	    ciphers = build_list(_("Cipher: "), 'S', gcry_cipher_algo_name,
                                  openpgp_cipher_test_algo );
 	p = ciphers;
 	break;
       case 36:
 	if( !digests )
 	    digests = build_list(_("Hash: "), 'H', gcry_md_algo_name,
 					openpgp_md_test_algo );
 	p = digests;
 	break;
       case 37:
 	if( !zips )
 	    zips = build_list(_("Compression: "),'Z',compress_algo_to_string,
 			                                check_compress_algo);
 	p = zips;
 	break;
 
       default:	p = NULL;
     }
     return p;
 }
 
 
 static char *
 build_list( const char *text, char letter,
 	    const char * (*mapf)(int), int (*chkf)(int) )
 {
     int i;
     const char *s;
     size_t n=strlen(text)+2;
     char *list, *p, *line=NULL;
 
     if( maybe_setuid )
         gcry_control (GCRYCTL_INIT_SECMEM, 0, 0);  /* drop setuid */
 
     for(i=0; i <= 110; i++ )
 	if( !chkf(i) && (s=mapf(i)) )
 	    n += strlen(s) + 7 + 2;
     list = xmalloc ( 21 + n ); *list = 0;
     for(p=NULL, i=0; i <= 110; i++ ) {
 	if( !chkf(i) && (s=mapf(i)) ) {
 	    if( !p ) {
 		p = stpcpy( list, text );
 		line=p;
 	    }
 	    else
 		p = stpcpy( p, ", ");
 
 	    if(strlen(line)>60) {
 	      int spaces=strlen(text);
 
 	      list = xrealloc(list,n+spaces+1);
 	      /* realloc could move the block, so find the end again */
 	      p=list;
 	      while(*p)
 		p++;
 
 	      p=stpcpy(p, "\n");
 	      line=p;
 	      for(;spaces;spaces--)
 		p=stpcpy(p, " ");
 	    }
 
 	    p = stpcpy(p, s );
 	    if(opt.verbose && letter)
 	      {
 		char num[8];
 		sprintf(num," (%c%d)",letter,i);
 		p = stpcpy(p,num);
 	      }
 	}
     }
     if( p )
 	p = stpcpy(p, "\n" );
     return list;
 }
 
 
 static void
 i18n_init(void)
 {
 #ifdef USE_SIMPLE_GETTEXT
     set_gettext_file( PACKAGE );
 #else
 #ifdef ENABLE_NLS
     setlocale( LC_ALL, "" );
     bindtextdomain( PACKAGE, LOCALEDIR );
     textdomain( PACKAGE );
 #endif
 #endif
 }
 
 static void
 wrong_args( const char *text)
 {
     fputs(_("usage: gpg [options] "),stderr);
     fputs(text,stderr);
     putc('\n',stderr);
     g10_exit(2);
 }
 
 
 static void
 log_set_strict (int yesno)
 {
   /* FIXME-XXX*/
 }
 
 static char *
 make_username( const char *string )
 {
     char *p;
     if( utf8_strings )
 	p = xstrdup (string);
     else
 	p = native_to_utf8( string );
     return p;
 }
 
 
 /*
  * same as add_to_strlist() but if is_utf8 is *not* set a conversion
  * to UTF8 is done  
  */
 static STRLIST
 add_to_strlist2 ( STRLIST *list, const char *string, int is_utf8)
 {
   STRLIST sl;
   
   if (is_utf8)
     sl = add_to_strlist( list, string );
   else 
     {
       char *p = native_to_utf8( string );
       sl = add_to_strlist( list, p );
       xfree( p );
     }
   return sl;
 }
 
 
 static void
 set_debug(void)
 {
   if (opt.debug & DBG_MEMORY_VALUE )
     memory_debug_mode = 1;
   if (opt.debug & DBG_MEMSTAT_VALUE )
     memory_stat_debug_mode = 1;
   if (opt.debug & DBG_MPI_VALUE)
     gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 2);
   if (opt.debug & DBG_CIPHER_VALUE )
     gcry_control (GCRYCTL_SET_DEBUG_FLAGS, 1);
   if (opt.debug & DBG_IOBUF_VALUE )
     iobuf_debug_mode = 1;
 }
 
 
 /* We need the home directory also in some other directories, so make
    sure that both variables are always in sync. */
 static void
 set_homedir (char *dir)
 {
   if (!dir)
     dir = "";
   g10_opt_homedir = opt.homedir = dir;
 }
 
 
 static void
 set_cmd( enum cmd_and_opt_values *ret_cmd, enum cmd_and_opt_values new_cmd )
 {
     enum cmd_and_opt_values cmd = *ret_cmd;
 
     if( !cmd || cmd == new_cmd )
 	cmd = new_cmd;
     else if( cmd == aSign && new_cmd == aEncr )
 	cmd = aSignEncr;
     else if( cmd == aEncr && new_cmd == aSign )
 	cmd = aSignEncr;
     else if( cmd == aSign && new_cmd == aSym )
 	cmd = aSignSym;
     else if( cmd == aSym && new_cmd == aSign )
 	cmd = aSignSym;
     else if( cmd == aKMode && new_cmd == aSym )
 	cmd = aKModeC;
     else if(	( cmd == aSign	   && new_cmd == aClearsign )
 	     || ( cmd == aClearsign && new_cmd == aSign )  )
 	cmd = aClearsign;
     else {
 	log_error(_("conflicting commands\n"));
 	g10_exit(2);
     }
 
     *ret_cmd = cmd;
 }
 
 
 static void add_group(char *string)
 {
   char *name,*value;
   struct groupitem *item;
   STRLIST values=NULL;
 
   /* Break off the group name */
   name=strsep(&string,"=");
   if(string==NULL)
     {
       log_error(_("no = sign found in group definition \"%s\"\n"),name);
       return;
     }
 
   trim_trailing_ws(name,strlen(name));
 
   /* Break apart the values */
   while ((value= strsep(&string," \t")))
     {
       if (*value)
         add_to_strlist2 (&values,value,utf8_strings);
     }
 
   item=xmalloc (sizeof(struct groupitem));
   item->name=name;
   item->values=values;
   item->next=opt.grouplist;
 
   opt.grouplist=item;
 }
 
 /* We need to check three things.
 
    0) The homedir.  It must be x00, a directory, and owned by the
    user.
 
    1) The options file.  Okay unless it or its containing directory is
    group or other writable or not owned by us.  disable exec in this
    case.
 
    2) Extensions.  Same as #2.
 
    Returns true if the item is unsafe. */
 static int
 check_permissions(const char *path,int item)
 {
 #if defined(HAVE_STAT) && !defined(HAVE_DOSISH_SYSTEM)
   static int homedir_cache=-1;
   char *tmppath,*dir;
   struct stat statbuf,dirbuf;
   int homedir=0,ret=0,checkonly=0;
   int perm=0,own=0,enc_dir_perm=0,enc_dir_own=0;
 
   if(opt.no_perm_warn)
     return 0;
 
   assert(item==0 || item==1 || item==2);
 
   /* extensions may attach a path */
   if(item==2 && path[0]!=DIRSEP_C)
     {
       if(strchr(path,DIRSEP_C))
 	tmppath=make_filename(path,NULL);
       else
 	tmppath=make_filename(GNUPG_LIBDIR,path,NULL);
     }
   else
     tmppath=xstrdup (path);
 
   /* If the item is located in the homedir, but isn't the homedir,
      don't continue if we already checked the homedir itself.  This is
      to avoid user confusion with an extra options file warning which
      could be rectified if the homedir itself had proper
      permissions. */
   if(item!=0 && homedir_cache>-1
      && ascii_strncasecmp(opt.homedir,tmppath,strlen(opt.homedir))==0)
     {
       ret=homedir_cache;
       goto end;
     }
 
   /* It's okay if the file or directory doesn't exist */
   if(stat(tmppath,&statbuf)!=0)
     {
       ret=0;
       goto end;
     }
 
   /* Now check the enclosing directory.  Theoretically, we could walk
      this test up to the root directory /, but for the sake of sanity,
      I'm stopping at one level down. */
   dir=make_dirname(tmppath);
 
   if(stat(dir,&dirbuf)!=0 || !S_ISDIR(dirbuf.st_mode))
     {
       /* Weird error */
       ret=1;
       goto end;
     }
 
   xfree (dir);
 
   /* Assume failure */
   ret=1;
 
   if(item==0)
     {
       /* The homedir must be x00, a directory, and owned by the user. */
 
       if(S_ISDIR(statbuf.st_mode))
 	{
 	  if(statbuf.st_uid==getuid())
 	    {
 	      if((statbuf.st_mode & (S_IRWXG|S_IRWXO))==0)
 		ret=0;
 	      else
 		perm=1;
 	    }
 	  else
 	    own=1;
 
 	  homedir_cache=ret;
 	}
     }
   else if(item==1 || item==2)
     {
       /* The options or extension file.  Okay unless it or its
 	 containing directory is group or other writable or not owned
 	 by us or root. */
 
       if(S_ISREG(statbuf.st_mode))
 	{
 	  if(statbuf.st_uid==getuid() || statbuf.st_uid==0)
 	    {
 	      if((statbuf.st_mode & (S_IWGRP|S_IWOTH))==0)
 		{
 		  /* it's not writable, so make sure the enclosing
                      directory is also not writable */
 		  if(dirbuf.st_uid==getuid() || dirbuf.st_uid==0)
 		    {
 		      if((dirbuf.st_mode & (S_IWGRP|S_IWOTH))==0)
 			ret=0;
 		      else
 			enc_dir_perm=1;
 		    }
 		  else
 		    enc_dir_own=1;
 		}
 	      else
 		{
 		  /* it's writable, so the enclosing directory had
                      better not let people get to it. */
 		  if(dirbuf.st_uid==getuid() || dirbuf.st_uid==0)
 		    {
 		      if((dirbuf.st_mode & (S_IRWXG|S_IRWXO))==0)
 			ret=0;
 		      else
 			perm=enc_dir_perm=1; /* unclear which one to fix! */
 		    }
 		  else
 		    enc_dir_own=1;
 		}
 	    }
 	  else
 	    own=1;
 	}
     }
   else
     BUG();
 
   if(!checkonly)
     {
       if(own)
 	{
 	  if(item==0)
 	    log_info(_("WARNING: unsafe ownership on "
 		       "homedir \"%s\"\n"),tmppath);
 	  else if(item==1)
 	    log_info(_("WARNING: unsafe ownership on "
 		       "configuration file \"%s\"\n"),tmppath);
 	  else
 	    log_info(_("WARNING: unsafe ownership on "
 		       "extension \"%s\"\n"),tmppath);
 	}
       if(perm)
 	{
 	  if(item==0)
 	    log_info(_("WARNING: unsafe permissions on "
 		       "homedir \"%s\"\n"),tmppath);
 	  else if(item==1)
 	    log_info(_("WARNING: unsafe permissions on "
 		       "configuration file \"%s\"\n"),tmppath);
 	  else
 	    log_info(_("WARNING: unsafe permissions on "
 		       "extension \"%s\"\n"),tmppath);
 	}
       if(enc_dir_own)
 	{
 	  if(item==0)
 	    log_info(_("WARNING: unsafe enclosing directory ownership on "
 		       "homedir \"%s\"\n"),tmppath);
 	  else if(item==1)
 	    log_info(_("WARNING: unsafe enclosing directory ownership on "
 		       "configuration file \"%s\"\n"),tmppath);
 	  else
 	    log_info(_("WARNING: unsafe enclosing directory ownership on "
 		       "extension \"%s\"\n"),tmppath);
 	}
       if(enc_dir_perm)
 	{
 	  if(item==0)
 	    log_info(_("WARNING: unsafe enclosing directory permissions on "
 		       "homedir \"%s\"\n"),tmppath);
 	  else if(item==1)
 	    log_info(_("WARNING: unsafe enclosing directory permissions on "
 		       "configuration file \"%s\"\n"),tmppath);
 	  else
 	    log_info(_("WARNING: unsafe enclosing directory permissions on "
 		       "extension \"%s\"\n"),tmppath);
 	}
     }
 
  end:
   xfree (tmppath);
 
   if(homedir)
     homedir_cache=ret;
 
   return ret;
 
 #endif /* HAVE_STAT && !HAVE_DOSISH_SYSTEM */
 
   return 0;
 }
 
 int
 main( int argc, char **argv )
 {
     ARGPARSE_ARGS pargs;
     iobuf_t a;
     int rc=0;
     int orig_argc;
     char **orig_argv;
     const char *fname;
     char *username;
     int may_coredump;
     STRLIST sl, remusr= NULL, locusr=NULL;
     STRLIST nrings=NULL, sec_nrings=NULL;
     armor_filter_context_t afx;
     int detached_sig = 0;
     FILE *configfp = NULL;
     char *configname = NULL;
     unsigned configlineno;
     int parse_debug = 0;
     int default_config = 1;
     int default_keyring = 1;
     int greeting = 0;
     int nogreeting = 0;
     int use_random_seed = 1;
     enum cmd_and_opt_values cmd = 0;
     const char *trustdb_name = NULL;
     char *def_cipher_string = NULL;
     char *def_digest_string = NULL;
     char *def_compress_string = NULL;
     char *cert_digest_string = NULL;
     char *s2k_cipher_string = NULL;
     char *s2k_digest_string = NULL;
     char *pers_cipher_list = NULL;
     char *pers_digest_list = NULL;
     char *pers_compress_list = NULL;
     int eyes_only=0;
     int pwfd = -1;
     int with_fpr = 0; /* make an option out of --fingerprint */
     int any_explicit_recipient = 0;
 #ifdef USE_SHM_COPROCESSING
     ulong requested_shm_size=0;
 #endif
 
 #ifdef __riscos__
     riscos_global_defaults();
     opt.lock_once = 1;
 #endif /* __riscos__ */
 
     trap_unaligned();
     set_strusage (my_strusage);
     gcry_control (GCRYCTL_SUSPEND_SECMEM_WARN);
     /* We don't need any locking in libgcrypt unless we use any kind of
        threading. */
     gcry_control (GCRYCTL_DISABLE_INTERNAL_LOCKING);
     /* Please note that we may running SUID(ROOT), so be very CAREFUL
      * when adding any stuff between here and the call to
      * secmem_init()  somewhere after the option parsing
      */
     log_set_prefix ("gpg", 1);
     /* check that the libraries are suitable.  Do it here because the
        option parse may need services of the library */
     if (!gcry_check_version (NEED_LIBGCRYPT_VERSION) )
       {
         log_fatal( _("libgcrypt is too old (need %s, have %s)\n"),
                    NEED_LIBGCRYPT_VERSION, gcry_check_version (NULL) );
       }
 
     gcry_control (GCRYCTL_USE_SECURE_RNDPOOL);
 
     may_coredump = disable_core_dumps();
     gnupg_init_signals (0, emergency_cleanup);
     create_dotlock (NULL); /* register locking cleanup */
     i18n_init();
 
     opt.command_fd = -1; /* no command fd */
     opt.compress = -1; /* defaults to standard compress level */
     /* note: if you change these lines, look at oOpenPGP */
     opt.def_cipher_algo = 0;
     opt.def_digest_algo = 0;
     opt.cert_digest_algo = 0;
     opt.def_compress_algo = -1;
     opt.s2k_mode = 3; /* iterated+salted */
     opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
 #ifdef USE_CAST5
     opt.s2k_cipher_algo = CIPHER_ALGO_CAST5;
 #else
     opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
 #endif
     opt.completes_needed = 1;
     opt.marginals_needed = 3;
     opt.max_cert_depth = 5;
     opt.pgp2_workarounds = 1;
     opt.force_v3_sigs = 1;
     opt.escape_from = 1;
     opt.import_options=IMPORT_SK2PK;
     opt.export_options=
       EXPORT_INCLUDE_NON_RFC|EXPORT_INCLUDE_ATTRIBUTES;
     opt.keyserver_options.import_options=IMPORT_REPAIR_PKS_SUBKEY_BUG;
     opt.keyserver_options.export_options=
       EXPORT_INCLUDE_NON_RFC|EXPORT_INCLUDE_ATTRIBUTES;
     opt.keyserver_options.include_subkeys=1;
     opt.keyserver_options.include_revoked=1;
     opt.keyserver_options.try_dns_srv=1;
     opt.verify_options=VERIFY_SHOW_POLICY|VERIFY_SHOW_NOTATION;
     opt.trust_model=TM_AUTO;
     opt.mangle_dos_filenames = 1;
     opt.use_agent = 1;
 
 #if defined (__MINGW32__)
     set_homedir ( read_w32_registry_string( NULL,
                                     "Software\\GNU\\GnuPG", "HomeDir" ));
 #else
     set_homedir ( getenv("GNUPGHOME") );
 #endif
     if( !*opt.homedir )
 	set_homedir ( GNUPG_HOMEDIR );
 
     /* check whether we have a config file on the commandline */
     orig_argc = argc;
     orig_argv = argv;
     pargs.argc = &argc;
     pargs.argv = &argv;
     pargs.flags= 1|(1<<6);  /* do not remove the args, ignore version */
     while( arg_parse( &pargs, opts) ) {
 	if( pargs.r_opt == oDebug || pargs.r_opt == oDebugAll )
 	    parse_debug++;
 	else if( pargs.r_opt == oOptions ) {
 	    /* yes there is one, so we do not try the default one, but
 	     * read the option file when it is encountered at the commandline
 	     */
 	    default_config = 0;
 	}
 	else if( pargs.r_opt == oNoOptions )
 	    default_config = 0; /* --no-options */
 	else if( pargs.r_opt == oHomedir )
 	    set_homedir ( pargs.r.ret_str );
 	else if( pargs.r_opt == oNoPermissionWarn )
 	    opt.no_perm_warn=1;
 	else if (pargs.r_opt == oStrict )
 	  {
 	    opt.strict=1;
 	    log_set_strict(1);
 	  }
 	else if (pargs.r_opt == oNoStrict )
 	  {
 	    opt.strict=0;
 	    log_set_strict(0);
 	  }
 #ifdef USE_SHM_COPROCESSING
 	else if( pargs.r_opt == oRunAsShmCP ) {
 	    /* does not make sense in a options file, we do it here,
 	     * so that we are the able to drop setuid as soon as possible */
 	    opt.shm_coprocess = 1;
 	    requested_shm_size = pargs.r.ret_ulong;
 	}
 	else if ( pargs.r_opt == oStatusFD ) {
 	    /* this is needed to ensure that the status-fd filedescriptor is
 	     * initialized when init_shm_coprocessing() is called */
 	    set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
 	}
 #endif
     }
 
 #ifdef HAVE_DOSISH_SYSTEM
     if ( strchr (opt.homedir,'\\') ) {
         char *d, *buf = xmalloc (strlen (opt.homedir)+1);
         const char *s = opt.homedir;
         for (d=buf,s=opt.homedir; *s; s++)
             *d++ = *s == '\\'? '/': *s;
         *d = 0;
         set_homedir (buf);
     }
 #endif
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess ) {
 	init_shm_coprocessing(requested_shm_size, 1 );
     }
 #endif
     /* Initialize the secure memory. */
     gcry_control (GCRYCTL_INIT_SECMEM, 32768, 0);
     maybe_setuid = 0;
     /* Okay, we are now working under our real uid */
 
     /* malloc hooks go here ... */
     assuan_set_malloc_hooks (gcry_malloc, gcry_realloc, gcry_free);
 
     set_native_charset (NULL); /* Try to auto set the character set */
 
     if( default_config )
       {
        /* Try for a version specific config file first */
 	configname = make_filename(opt.homedir,
 				   "gpg" EXTSEP_S "conf-" SAFE_VERSION, NULL );
 	if(access(configname,R_OK))
 	  {
 	    xfree (configname);
 	    configname = make_filename(opt.homedir,
 				       "gpg" EXTSEP_S "conf", NULL );
 	  }
         if (!access (configname, R_OK))
           { /* Print a warning when both config files are present. */
             char *p = make_filename(opt.homedir, "options", NULL );
             if (!access (p, R_OK))
               log_info (_("NOTE: old default options file `%s' ignored\n"), p);
             xfree (p);
           }
         else
           { /* Keep on using the old default one. */
             xfree (configname);
             configname = make_filename(opt.homedir, "options", NULL );
           }
       }
     argc = orig_argc;
     argv = orig_argv;
     pargs.argc = &argc;
     pargs.argv = &argv;
     pargs.flags=  1;  /* do not remove the args */
 
     /* By this point we have a homedir, and cannot change it. */
     check_permissions(opt.homedir,0);
 
   next_pass:
     if( configname ) {
       if(check_permissions(configname,1))
 	{
 	  /* If any options file is unsafe, then disable any external
 	     programs for keyserver calls or photo IDs.  Since the
 	     external program to call is set in the options file, a
 	     unsafe options file can lead to an arbitrary program
 	     being run. */
 
 	  opt.exec_disable=1;
 	}
 
 	configlineno = 0;
 	configfp = fopen( configname, "r" );
 	if( !configfp ) {
 	    if( default_config ) {
 		if( parse_debug )
 		    log_info(_("NOTE: no default option file `%s'\n"),
 							    configname );
 	    }
 	    else {
 		log_error(_("option file `%s': %s\n"),
 				    configname, strerror(errno) );
 		g10_exit(2);
 	    }
 	    xfree (configname); configname = NULL;
 	}
 	if( parse_debug && configname )
 	    log_info(_("reading options from `%s'\n"), configname );
 	default_config = 0;
     }
 
     while( optfile_parse( configfp, configname, &configlineno,
 						&pargs, opts) ) {
 	switch( pargs.r_opt ) {
 	  case aCheckKeys: set_cmd( &cmd, aCheckKeys); break;
 	  case aListPackets: set_cmd( &cmd, aListPackets); break;
 	  case aImport: set_cmd( &cmd, aImport); break;
 	  case aFastImport: set_cmd( &cmd, aFastImport); break;
 	  case aSendKeys: set_cmd( &cmd, aSendKeys); break;
 	  case aRecvKeys: set_cmd( &cmd, aRecvKeys); break;
 	  case aSearchKeys: set_cmd( &cmd, aSearchKeys); break;
 	  case aRefreshKeys: set_cmd( &cmd, aRefreshKeys); break;
 	  case aExport: set_cmd( &cmd, aExport); break;
 	  case aExportAll: set_cmd( &cmd, aExportAll); break;
 	  case aListKeys: set_cmd( &cmd, aListKeys); break;
 	  case aListSigs: set_cmd( &cmd, aListSigs); break;
 	  case aExportSecret: set_cmd( &cmd, aExportSecret); break;
 	  case aExportSecretSub: set_cmd( &cmd, aExportSecretSub); break;
 	  case aDeleteSecretKeys: set_cmd( &cmd, aDeleteSecretKeys);
 							greeting=1; break;
 	  case aDeleteSecretAndPublicKeys:
             set_cmd( &cmd, aDeleteSecretAndPublicKeys);
             greeting=1; 
             break;
 	  case aDeleteKeys: set_cmd( &cmd, aDeleteKeys); greeting=1; break;
 
 	  case aDetachedSign: detached_sig = 1; set_cmd( &cmd, aSign ); break;
 	  case aSym: set_cmd( &cmd, aSym); break;
 
 	  case aDecrypt: set_cmd( &cmd, aDecrypt); break;
           case aDecryptFiles: set_cmd( &cmd, aDecryptFiles); break;
 
 	  case aEncr: set_cmd( &cmd, aEncr); break;
 	  case aEncrFiles: set_cmd( &cmd, aEncrFiles ); break;
 	  case aSign: set_cmd( &cmd, aSign );  break;
 	  case aKeygen: set_cmd( &cmd, aKeygen); greeting=1; break;
 	  case aSignKey: set_cmd( &cmd, aSignKey); break;
 	  case aLSignKey: set_cmd( &cmd, aLSignKey); break;
 	  case aNRSignKey: set_cmd( &cmd, aNRSignKey); break;
 	  case aNRLSignKey: set_cmd( &cmd, aNRLSignKey); break;
 	  case aStore: set_cmd( &cmd, aStore); break;
 	  case aEditKey: set_cmd( &cmd, aEditKey); greeting=1; break;
 	  case aClearsign: set_cmd( &cmd, aClearsign); break;
 	  case aGenRevoke: set_cmd( &cmd, aGenRevoke); break;
 	  case aDesigRevoke: set_cmd( &cmd, aDesigRevoke); break;
 	  case aVerify: set_cmd( &cmd, aVerify); break;
 	  case aVerifyFiles: set_cmd( &cmd, aVerifyFiles); break;
 	  case aPrimegen: set_cmd( &cmd, aPrimegen); break;
 	  case aGenRandom: set_cmd( &cmd, aGenRandom); break;
 	  case aPrintMD: set_cmd( &cmd, aPrintMD); break;
 	  case aPrintMDs: set_cmd( &cmd, aPrintMDs); break;
 	  case aListTrustDB: set_cmd( &cmd, aListTrustDB); break;
 	  case aCheckTrustDB: set_cmd( &cmd, aCheckTrustDB); break;
 	  case aUpdateTrustDB: set_cmd( &cmd, aUpdateTrustDB); break;
 	  case aFixTrustDB: set_cmd( &cmd, aFixTrustDB); break;
 	  case aListTrustPath: set_cmd( &cmd, aListTrustPath); break;
 	  case aDeArmor: set_cmd( &cmd, aDeArmor); break;
 	  case aEnArmor: set_cmd( &cmd, aEnArmor); break;
 	  case aListOwnerTrust:
 	    deprecated_warning(configname,configlineno,
 			       "--list-ownertrust","--export-ownertrust","");
 	  case aExportOwnerTrust: set_cmd( &cmd, aExportOwnerTrust); break;
 	  case aImportOwnerTrust: set_cmd( &cmd, aImportOwnerTrust); break;
           case aPipeMode: set_cmd( &cmd, aPipeMode); break;
           case aRebuildKeydbCaches: set_cmd( &cmd, aRebuildKeydbCaches); break;
 
           case aCardStatus: set_cmd (&cmd, aCardStatus); break;
           case aChangePIN: set_cmd (&cmd, aChangePIN); break;
 
 	  case oArmor: opt.armor = 1; opt.no_armor=0; break;
 	  case oOutput: opt.outfile = pargs.r.ret_str; break;
 	  case oQuiet: opt.quiet = 1; break;
 	  case oNoTTY: tty_no_terminal(1); break;
 	  case oDryRun: opt.dry_run = 1; break;
 	  case oInteractive: opt.interactive = 1; break;
 	  case oVerbose: g10_opt_verbose++;
 		    opt.verbose++; opt.list_sigs=1; break;
 	  case oKOption: set_cmd( &cmd, aKMode ); break;
 
 	  case oBatch: opt.batch = 1; nogreeting = 1; break;
           case oUseAgent:
 #ifndef __riscos__
             opt.use_agent = 1;
 #else /* __riscos__ */
             opt.use_agent = 0;
             riscos_not_implemented("use-agent");
 #endif /* __riscos__ */
             break;
           case oNoUseAgent: opt.use_agent = 0; break;
 	  case oGpgAgentInfo: opt.gpg_agent_info = pargs.r.ret_str; break;
 	  case oAnswerYes: opt.answer_yes = 1; break;
 	  case oAnswerNo: opt.answer_no = 1; break;
 	  case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
 	  case oPrimaryKeyring:
 	    sl=append_to_strlist( &nrings, pargs.r.ret_str);
 	    sl->flags=2;
 	    break;
 	  case oShowKeyring: opt.list_options|=LIST_SHOW_KEYRING; break;
 	  case oDebug: opt.debug |= pargs.r.ret_ulong; break;
 	  case oDebugAll: opt.debug = ~0; break;
 	  case oStatusFD:
             set_status_fd( iobuf_translate_file_handle (pargs.r.ret_int, 1) );
             break;
 #ifdef __riscos__
 	  case oStatusFile:
             set_status_fd( iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
             break;
 #endif /* __riscos__ */
 	  case oAttributeFD:
             set_attrib_fd(iobuf_translate_file_handle (pargs.r.ret_int, 1));
             break;
 #ifdef __riscos__
 	  case oAttributeFile:
             set_attrib_fd(iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
             break;
 #endif /* __riscos__ */
 	  case oLoggerFD:
             log_set_fd (iobuf_translate_file_handle (pargs.r.ret_int, 1));
             break;
 #ifdef __riscos__
 	  case oLoggerFile:
             log_set_logfile( NULL,
                              iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 1), 1) );
             break;
 #endif /* __riscos__ */
 	  case oWithFingerprint:
             opt.with_fingerprint = 1;
             with_fpr=1; /*fall thru*/
 	  case oFingerprint: opt.fingerprint++; break;
 	  case oSecretKeyring: append_to_strlist( &sec_nrings, pargs.r.ret_str); break;
 	  case oOptions:
 	    /* config files may not be nested (silently ignore them) */
 	    if( !configfp ) {
 		xfree (configname);
 		configname = xstrdup (pargs.r.ret_str);
 		goto next_pass;
 	    }
 	    break;
 	  case oNoArmor: opt.no_armor=1; opt.armor=0; break;
 	  case oNoDefKeyring: default_keyring = 0; break;
           case oDefCertCheckLevel: opt.def_cert_check_level=pargs.r.ret_int; break;
 	  case oNoGreeting: nogreeting = 1; break;
 	  case oNoVerbose: g10_opt_verbose = 0;
 			   opt.verbose = 0; opt.list_sigs=0; break;
       /* disabled for now: 
           case oQuickRandom: quick_random_gen(1); break; */
 	  case oSKComments: opt.sk_comments=1; break;
 	  case oNoSKComments: opt.sk_comments=0; break;
 	  case oEmitVersion: opt.no_version=0; break;
 	  case oNoEmitVersion: opt.no_version=1; break;
 	  case oCompletesNeeded: opt.completes_needed = pargs.r.ret_int; break;
 	  case oMarginalsNeeded: opt.marginals_needed = pargs.r.ret_int; break;
 	  case oMaxCertDepth: opt.max_cert_depth = pargs.r.ret_int; break;
 	  case oTrustDBName: trustdb_name = pargs.r.ret_str; break;
 	  case oDefaultKey: opt.def_secret_key = pargs.r.ret_str; break;
 	  case oDefRecipient:
 		    if( *pargs.r.ret_str )
 			opt.def_recipient = make_username(pargs.r.ret_str);
 		    break;
 	  case oDefRecipientSelf:
 		    xfree (opt.def_recipient); opt.def_recipient = NULL;
 		    opt.def_recipient_self = 1;
 		    break;
 	  case oNoDefRecipient:
 		    xfree (opt.def_recipient); opt.def_recipient = NULL;
 		    opt.def_recipient_self = 0;
 		    break;
 	  case oNoOptions: opt.no_homedir_creation = 1; break; /* no-options */
 	  case oHomedir: break;
 	  case oNoBatch: opt.batch = 0; break;
 	  case oWithKeyData: opt.with_key_data=1; /* fall thru */
 	  case oWithColons: opt.with_colons=':'; break;
 
 	  case oSkipVerify: opt.skip_verify=1; break;
 	  case oCompressKeys: opt.compress_keys = 1; break;
 	  case aListSecretKeys: set_cmd( &cmd, aListSecretKeys); break;
 	    /* There are many programs (like mutt) that call gpg with
 	       --always-trust so keep this option around for a long
 	       time. */
 	  case oAlwaysTrust: opt.trust_model=TM_ALWAYS; break;
 	  case oTrustModel:
 	    if(ascii_strcasecmp(pargs.r.ret_str,"pgp")==0)
 	      opt.trust_model=TM_PGP;
 	    else if(ascii_strcasecmp(pargs.r.ret_str,"classic")==0)
 	      opt.trust_model=TM_CLASSIC;
 	    else if(ascii_strcasecmp(pargs.r.ret_str,"always")==0)
 	      opt.trust_model=TM_ALWAYS;
 	    else if(ascii_strcasecmp(pargs.r.ret_str,"auto")==0)
 	      opt.trust_model=TM_AUTO;
 	    else
 	      log_error("unknown trust model \"%s\"\n",pargs.r.ret_str);
 	    break;
 	  case oForceOwnertrust:
 	    log_info(_("NOTE: %s is not for normal use!\n"),
 		     "--force-ownertrust");
 	    opt.force_ownertrust=string_to_trust_value(pargs.r.ret_str);
 	    if(opt.force_ownertrust==-1)
 	      {
 		log_error("invalid ownertrust \"%s\"\n",pargs.r.ret_str);
 		opt.force_ownertrust=0;
 	      }
 	    break;
 	  case oLoadExtension:
 #ifndef __riscos__
 #if defined(USE_DYNAMIC_LINKING) || defined(__MINGW32__)
 	    if(check_permissions(pargs.r.ret_str,2))
 	      log_info(_("cipher extension \"%s\" not loaded due to "
 			 "unsafe permissions\n"),pargs.r.ret_str);
 	    else
 	      register_cipher_extension(orig_argc? *orig_argv:NULL,
 					pargs.r.ret_str);
 #endif
 #else /* __riscos__ */
             riscos_not_implemented("load-extension");
 #endif /* __riscos__ */
 	    break;
 	  case oRFC1991:
 	    opt.compliance = CO_RFC1991;
 	    opt.force_v4_certs = 0;
 	    opt.disable_mdc = 1;
 	    opt.escape_from = 1;
 	    break;
 	  case oOpenPGP:
 	    /* TODO: When 2440bis becomes a RFC, these may need
                changing. */
 	    opt.compliance = CO_RFC2440;
 	    opt.disable_mdc = 1;
 	    opt.allow_non_selfsigned_uid = 1;
 	    opt.allow_freeform_uid = 1;
 	    opt.pgp2_workarounds = 0;
 	    opt.escape_from = 0;
 	    opt.force_v3_sigs = 0;
 	    opt.compress_keys = 0;	    /* not mandated  but we do it */
 	    opt.compress_sigs = 0;	    /* ditto. */
 	    opt.not_dash_escaped = 0;
 	    opt.def_cipher_algo = 0;
 	    opt.def_digest_algo = 0;
 	    opt.cert_digest_algo = 0;
 	    opt.def_compress_algo = -1;
             opt.s2k_mode = 3; /* iterated+salted */
 	    opt.s2k_digest_algo = DIGEST_ALGO_SHA1;
 	    opt.s2k_cipher_algo = CIPHER_ALGO_3DES;
 	    break;
 	  case oPGP2:  opt.compliance = CO_PGP2;  break;
 	  case oPGP6:  opt.compliance = CO_PGP6;  break;
 	  case oPGP7:  opt.compliance = CO_PGP7;  break;
 	  case oPGP8:  opt.compliance = CO_PGP8;  break;
 	  case oGnuPG: opt.compliance = CO_GNUPG; break;
 	  case oEmuMDEncodeBug: opt.emulate_bugs |= EMUBUG_MDENCODE; break;
 	  case oCompressSigs: opt.compress_sigs = 1; break;
 	  case oRunAsShmCP:
 #ifndef __riscos__
 # ifndef USE_SHM_COPROCESSING
 	    /* not possible in the option file,
 	     * but we print the warning here anyway */
 	    log_error("shared memory coprocessing is not available\n");
 # endif
 #else /* __riscos__ */
             riscos_not_implemented("run-as-shm-coprocess");
 #endif /* __riscos__ */
 	    break;
 	  case oSetFilename: opt.set_filename = pargs.r.ret_str; break;
 	  case oForYourEyesOnly: eyes_only = 1; break;
 	  case oNoForYourEyesOnly: eyes_only = 0; break;
 	  case oSetPolicyURL:
 	    add_policy_url(pargs.r.ret_str,0);
 	    add_policy_url(pargs.r.ret_str,1);
 	    break;
 	  case oSigPolicyURL: add_policy_url(pargs.r.ret_str,0); break;
 	  case oCertPolicyURL: add_policy_url(pargs.r.ret_str,1); break;
           case oShowPolicyURL:
 	    opt.list_options|=LIST_SHOW_POLICY;
 	    opt.verify_options|=VERIFY_SHOW_POLICY;
 	    break;
 	  case oNoShowPolicyURL:
 	    opt.list_options&=~LIST_SHOW_POLICY;
 	    opt.verify_options&=~VERIFY_SHOW_POLICY;
 	    break;
 	  case oUseEmbeddedFilename: opt.use_embedded_filename = 1; break;
 	  case oComment: opt.comment_string = pargs.r.ret_str; break;
 	  case oDefaultComment: opt.comment_string = NULL; break;
 	  case oThrowKeyid: opt.throw_keyid = 1; break;
 	  case oNoThrowKeyid: opt.throw_keyid = 0; break;
 	  case oShowPhotos: 
 	    opt.list_options|=LIST_SHOW_PHOTOS;
 	    opt.verify_options|=VERIFY_SHOW_PHOTOS;
 	    break;
 	  case oNoShowPhotos:
 	    opt.list_options&=~LIST_SHOW_PHOTOS;
 	    opt.verify_options&=~VERIFY_SHOW_PHOTOS;
 	    break;
 	  case oPhotoViewer: opt.photo_viewer = pargs.r.ret_str; break;
 	  case oForceV3Sigs: opt.force_v3_sigs = 1; break;
 	  case oNoForceV3Sigs: opt.force_v3_sigs = 0; break;
           case oForceV4Certs: opt.force_v4_certs = 1; break;
           case oNoForceV4Certs: opt.force_v4_certs = 0; break;
 	  case oForceMDC: opt.force_mdc = 1; break;
 	  case oNoForceMDC: opt.force_mdc = 0; break;
 	  case oDisableMDC: opt.disable_mdc = 1; break;
 	  case oNoDisableMDC: opt.disable_mdc = 0; break;
 	  case oS2KMode:   opt.s2k_mode = pargs.r.ret_int; break;
 	  case oS2KDigest: s2k_digest_string = xstrdup (pargs.r.ret_str); break;
 	  case oS2KCipher: s2k_cipher_string = xstrdup (pargs.r.ret_str); break;
           case oSimpleSKChecksum: opt.simple_sk_checksum = 1; break;
 	  case oNoEncryptTo: opt.no_encrypt_to = 1; break;
 	  case oEncryptTo: /* store the recipient in the second list */
 	    sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
 	    sl->flags = 1;
 	    break;
 	  case oHiddenEncryptTo: /* store the recipient in the second list */
 	    sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
 	    sl->flags = 1|2;
 	    break;
 	  case oRecipient: /* store the recipient */
 	    add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
             any_explicit_recipient = 1;
 	    break;
 	  case oHiddenRecipient: /* store the recipient with a flag */
 	    sl = add_to_strlist2( &remusr, pargs.r.ret_str, utf8_strings );
 	    sl->flags = 2;
             any_explicit_recipient = 1;
 	    break;
 	  case oTextmodeShort: opt.textmode = 2; break;
 	  case oTextmode: opt.textmode=1;  break;
 	  case oNoTextmode: opt.textmode=0;  break;
 	  case oExpert: opt.expert = 1; break;
 	  case oNoExpert: opt.expert = 0; break;
 	  case oAskSigExpire: opt.ask_sig_expire = 1; break;
 	  case oNoAskSigExpire: opt.ask_sig_expire = 0; break;
 	  case oAskCertExpire: opt.ask_cert_expire = 1; break;
 	  case oNoAskCertExpire: opt.ask_cert_expire = 0; break;
 	  case oUser: /* store the local users */
 	    add_to_strlist2( &locusr, pargs.r.ret_str, utf8_strings );
 	    break;
 	  case oCompress: opt.compress = pargs.r.ret_int; break;
 	  case oPasswdFD:
             pwfd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
             break;
 #ifdef __riscos__
 	  case oPasswdFile:
             pwfd = iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 0), 0);
             break;
 #endif /* __riscos__ */
 	  case oCommandFD:
             opt.command_fd = iobuf_translate_file_handle (pargs.r.ret_int, 0);
             break;
 #ifdef __riscos__
 	  case oCommandFile:
             opt.command_fd = iobuf_translate_file_handle ( riscos_fdopenfile (pargs.r.ret_str, 0), 0);
             break;
 #endif /* __riscos__ */
 	  case oCipherAlgo: def_cipher_string = xstrdup (pargs.r.ret_str); break;
 	  case oDigestAlgo: def_digest_string = xstrdup (pargs.r.ret_str); break;
 	  case oCompressAlgo:
 	    /* If it is all digits, stick a Z in front of it for
 	       later.  This is for backwards compatibility with
 	       versions that took the compress algorithm number. */
 	    {
 	      char *pt=pargs.r.ret_str;
 	      while(*pt)
 		{
 		  if(!isdigit(*pt))
 		    break;
 
 		  pt++;
 		}
 
 	      if(*pt=='\0')
 		{
 		  def_compress_string=xmalloc (strlen(pargs.r.ret_str)+2);
 		  strcpy(def_compress_string,"Z");
 		  strcat(def_compress_string,pargs.r.ret_str);
 		}
 	      else
 		def_compress_string = xstrdup (pargs.r.ret_str);
 	    }
 	    break;
 	  case oCertDigestAlgo: cert_digest_string = xstrdup (pargs.r.ret_str); break;
 	  case oNoSecmemWarn:
-#warning add secmem_get_flags
-/*              secmem_set_flags( secmem_get_flags() | 1 ); */
+            gcry_control (GCRYCTL_DISABLE_SECMEM_WARN); 
             break;
 	  case oNoPermissionWarn: opt.no_perm_warn=1; break;
 	  case oNoMDCWarn: opt.no_mdc_warn=1; break;
           case oCharset:
 	    if( set_native_charset( pargs.r.ret_str ) )
 		log_error(_("%s is not a valid character set\n"),
 						    pargs.r.ret_str);
 	    break;
 	  case oNotDashEscaped: opt.not_dash_escaped = 1; break;
 	  case oEscapeFrom: opt.escape_from = 1; break;
 	  case oNoEscapeFrom: opt.escape_from = 0; break;
 	  case oLockOnce: opt.lock_once = 1; break;
 	  case oLockNever: disable_dotlock(); break;
 	  case oLockMultiple:
 #ifndef __riscos__
 	    opt.lock_once = 0;
 #else /* __riscos__ */
             riscos_not_implemented("lock-multiple");
 #endif /* __riscos__ */
             break;
 	  case oKeyServer:
 	    opt.keyserver_uri=xstrdup (pargs.r.ret_str);
 	    if(parse_keyserver_uri(pargs.r.ret_str,configname,configlineno))
 	      log_error(_("could not parse keyserver URI\n"));
 	    break;
 	  case oKeyServerOptions:
 	    parse_keyserver_options(pargs.r.ret_str);
 	    break;
 	  case oImportOptions:
 	    if(!parse_import_options(pargs.r.ret_str,&opt.import_options))
 	      {
 		if(configname)
 		  log_error(_("%s:%d: invalid import options\n"),
 			    configname,configlineno);
 		else
 		  log_error(_("invalid import options\n"));
 	      }
 	    break;
 	  case oExportOptions:
 	    if(!parse_export_options(pargs.r.ret_str,&opt.export_options))
 	      {
 		if(configname)
 		  log_error(_("%s:%d: invalid export options\n"),
 			    configname,configlineno);
 		else
 		  log_error(_("invalid export options\n"));
 	      }
 	    break;
 	  case oListOptions:
 	    {
 	      struct parse_options lopts[]=
 		{
 		  {"show-photos",LIST_SHOW_PHOTOS},
 		  {"show-policy-url",LIST_SHOW_POLICY},
 		  {"show-notation",LIST_SHOW_NOTATION},
 		  {"show-keyring",LIST_SHOW_KEYRING},
 		  {"show-validity",LIST_SHOW_VALIDITY},
 		  {"show-long-keyid",LIST_SHOW_LONG_KEYID},
 		  {NULL,0}
 		};
 
 	      if(!parse_options(pargs.r.ret_str,&opt.list_options,lopts))
 		{
 		  if(configname)
 		    log_error(_("%s:%d: invalid list options\n"),
 			      configname,configlineno);
 		  else
 		    log_error(_("invalid list options\n"));
 		}
 	    }
 	    break;
 	  case oVerifyOptions:
 	    {
 	      struct parse_options vopts[]=
 		{
 		  {"show-photos",VERIFY_SHOW_PHOTOS},
 		  {"show-policy-url",VERIFY_SHOW_POLICY},
 		  {"show-notation",VERIFY_SHOW_NOTATION},
 		  {NULL,0}
 		};
 
 	      if(!parse_options(pargs.r.ret_str,&opt.verify_options,vopts))
 		{
 		  if(configname)
 		    log_error(_("%s:%d: invalid verify options\n"),
 			      configname,configlineno);
 		  else
 		    log_error(_("invalid verify options\n"));
 		}
 	    }
 	    break;
 	  case oTempDir: opt.temp_dir=pargs.r.ret_str; break;
 	  case oExecPath:
 	    if(set_exec_path(pargs.r.ret_str,0))
 	      log_error(_("unable to set exec-path to %s\n"),pargs.r.ret_str);
 	    else
 	      opt.exec_path_set=1;
 	    break;
 	  case oNotation:
 	    add_notation_data( pargs.r.ret_str, 0 );
 	    add_notation_data( pargs.r.ret_str, 1 );
 	    break;
 	  case oSigNotation: add_notation_data( pargs.r.ret_str, 0 ); break;
 	  case oCertNotation: add_notation_data( pargs.r.ret_str, 1 ); break;
 	  case oShowNotation:
 	    opt.list_options|=LIST_SHOW_NOTATION;
 	    opt.verify_options|=VERIFY_SHOW_NOTATION;
 	    break;
 	  case oNoShowNotation:
 	    opt.list_options&=~LIST_SHOW_NOTATION;
 	    opt.verify_options&=~VERIFY_SHOW_NOTATION;
 	    break;
 	  case oUtf8Strings: utf8_strings = 1; break;
 	  case oNoUtf8Strings: utf8_strings = 0; break;
 	  case oDisableCipherAlgo:
             {
               int algo = gcry_cipher_map_name (pargs.r.ret_str);
               gcry_cipher_ctl (NULL, GCRYCTL_DISABLE_ALGO,
                                &algo, sizeof algo);
             }
             break;
 	  case oDisablePubkeyAlgo:
             {
               int algo = gcry_pk_map_name (pargs.r.ret_str);
               gcry_pk_ctl (GCRYCTL_DISABLE_ALGO,
                            &algo, sizeof algo );
             }
             break;
           case oNoSigCache: opt.no_sig_cache = 1; break;
           case oNoSigCreateCheck: opt.no_sig_create_check = 1; break;
 	  case oAllowNonSelfsignedUID: opt.allow_non_selfsigned_uid = 1; break;
 	  case oNoAllowNonSelfsignedUID: opt.allow_non_selfsigned_uid=0; break;
 	  case oAllowFreeformUID: opt.allow_freeform_uid = 1; break;
 	  case oNoAllowFreeformUID: opt.allow_freeform_uid = 0; break;
 	  case oNoLiteral: opt.no_literal = 1; break;
 	  case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break;
 	  case oHonorHttpProxy:
                 opt.keyserver_options.honor_http_proxy = 1;
 		deprecated_warning(configname,configlineno,
 				   "--honor-http-proxy",
 				   "--keyserver-options ",
 				   "honor-http-proxy");
 		break;
 	  case oFastListMode: opt.fast_list_mode = 1; break;
 	  case oFixedListMode: opt.fixed_list_mode = 1; break;
 	  case oListOnly: opt.list_only=1; break;
 	  case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
 	  case oIgnoreValidFrom: opt.ignore_valid_from = 1; break;
 	  case oIgnoreCrcError: opt.ignore_crc_error = 1; break;
 	  case oIgnoreMDCError: opt.ignore_mdc_error = 1; break;
 	  case oNoRandomSeedFile: use_random_seed = 0; break;
 	  case oAutoKeyRetrieve:
 	  case oNoAutoKeyRetrieve:
 	        opt.keyserver_options.auto_key_retrieve=
 	                                     (pargs.r_opt==oAutoKeyRetrieve);
 		deprecated_warning(configname,configlineno,
 			   pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve":
 			       "--no-auto-key-retrieve","--keyserver-options ",
 			   pargs.r_opt==oAutoKeyRetrieve?"auto-key-retrieve":
 			       "no-auto-key-retrieve");
 		break;
 	  case oShowSessionKey: opt.show_session_key = 1; break;
 	  case oOverrideSessionKey:
 		opt.override_session_key = pargs.r.ret_str;
 		break;
 	  case oMergeOnly: opt.merge_only = 1; break;
           case oAllowSecretKeyImport: /* obsolete */ break;
 	  case oTryAllSecrets: opt.try_all_secrets = 1; break;
           case oTrustedKey: register_trusted_key( pargs.r.ret_str ); break;
           case oEnableSpecialFilenames:
             iobuf_enable_special_filenames (1);
             break;
           case oNoExpensiveTrustChecks: opt.no_expensive_trust_checks=1; break;
           case oAutoCheckTrustDB: opt.no_auto_check_trustdb=0; break;
           case oNoAutoCheckTrustDB: opt.no_auto_check_trustdb=1; break;
           case oPreservePermissions: opt.preserve_permissions=1; break;
           case oDefaultPreferenceList:
 	    opt.def_preference_list = pargs.r.ret_str;
 	    break;
           case oPersonalCipherPreferences:
 	    pers_cipher_list=pargs.r.ret_str;
 	    break;
           case oPersonalDigestPreferences:
 	    pers_digest_list=pargs.r.ret_str;
 	    break;
           case oPersonalCompressPreferences:
 	    pers_compress_list=pargs.r.ret_str;
 	    break;
           case oAgentProgram: opt.agent_program = pargs.r.ret_str;  break;
           case oDisplay: opt.display = pargs.r.ret_str; break;
           case oTTYname: opt.ttyname = pargs.r.ret_str; break;
           case oTTYtype: opt.ttytype = pargs.r.ret_str; break;
           case oLCctype: opt.lc_ctype = pargs.r.ret_str; break;
           case oLCmessages: opt.lc_messages = pargs.r.ret_str; break;
 	  case oGroup: add_group(pargs.r.ret_str); break;
 	  case oStrict: opt.strict=1; log_set_strict(1); break;
 	  case oNoStrict: opt.strict=0; log_set_strict(0); break;
 
           case oMangleDosFilenames: opt.mangle_dos_filenames = 1; break;
           case oNoMangleDosFilenames: opt.mangle_dos_filenames = 0; break;
 
           case oEnableProgressFilter: opt.enable_progress_filter = 1; break;
 
 	  default : pargs.err = configfp? 1:2; break;
 	}
     }
 
     if( configfp ) {
 	fclose( configfp );
 	configfp = NULL;
 	xfree (configname); configname = NULL;
 	goto next_pass;
     }
     xfree ( configname ); configname = NULL;
     if( log_get_errorcount(0) )
 	g10_exit(2);
     if( nogreeting )
 	greeting = 0;
 
     if( greeting ) {
 	fprintf(stderr, "%s %s; %s\n",
 			strusage(11), strusage(13), strusage(14) );
 	fprintf(stderr, "%s\n", strusage(15) );
     }
 #ifdef IS_DEVELOPMENT_VERSION
     if( !opt.batch ) {
 	log_info("NOTE: THIS IS A DEVELOPMENT VERSION!\n");
 	log_info("It is only intended for test purposes and should NOT be\n");
 	log_info("used in a production environment or with production keys!\n");
     }
 #endif
 
-#warning locking does not work - disabled
-    disable_dotlock ();
-
     if (opt.verbose > 2)
         log_info ("using character set `%s'\n", get_native_charset ());
 
     if( may_coredump && !opt.quiet )
 	log_info(_("WARNING: program may create a core file!\n"));
 
     if (eyes_only) {
       if (opt.set_filename)
 	  log_info(_("WARNING: %s overrides %s\n"),
 		   "--for-your-eyes-only","--set-filename");
 
       opt.set_filename="_CONSOLE";
     }
 
     if (opt.no_literal) {
 	log_info(_("NOTE: %s is not for normal use!\n"), "--no-literal");
 	if (opt.textmode)
 	    log_error(_("%s not allowed with %s!\n"),
 		       "--textmode", "--no-literal" );
 	if (opt.set_filename)
 	    log_error(_("%s makes no sense with %s!\n"),
 			eyes_only?"--for-your-eyes-only":"--set-filename",
 		        "--no-literal" );
     }
 
     if (opt.set_filesize)
 	log_info(_("NOTE: %s is not for normal use!\n"), "--set-filesize");
     if( opt.batch )
 	tty_batchmode( 1 );
 
-#warning fix that
-#if 0
-    secmem_set_flags( secmem_get_flags() & ~2 ); /* resume warnings */
-#endif
+    gcry_control (GCRYCTL_RESUME_SECMEM_WARN);
     set_debug();
 
     /* Do these after the switch(), so they can override settings. */
     if(PGP2)
       {
 	int unusable=0;
 
 	if(cmd==aSign && !detached_sig)
 	  {
 	    log_info(_("you can only make detached or clear signatures "
 		       "while in --pgp2 mode\n"));
 	    unusable=1;
 	  }
 	else if(cmd==aSignEncr || cmd==aSignSym)
 	  {
 	    log_info(_("you can't sign and encrypt at the "
 		       "same time while in --pgp2 mode\n"));
 	    unusable=1;
 	  }
 	else if(argc==0 && (cmd==aSign || cmd==aEncr || cmd==aSym))
 	  {
 	    log_info(_("you must use files (and not a pipe) when "
 		       "working with --pgp2 enabled.\n"));
 	    unusable=1;
 	  }
 	else if(cmd==aEncr || cmd==aSym)
 	  {
 	    /* Everything else should work without IDEA (except using
 	       a secret key encrypted with IDEA and setting an IDEA
 	       preference, but those have their own error
 	       messages). */
 
 	    if(openpgp_cipher_test_algo (CIPHER_ALGO_IDEA))
 	      {
 		log_info(_("encrypting a message in --pgp2 mode requires "
 			   "the IDEA cipher\n"));
 		idea_cipher_warn(1);
 		unusable=1;
 	      }
 	    else if(cmd==aSym)
 	      {
 		/* This only sets IDEA for symmetric encryption
 		   since it is set via select_algo_from_prefs for
 		   pk encryption. */
 		xfree (def_cipher_string);
 		def_cipher_string = xstrdup ("idea");
 	      }
 
 	    /* PGP2 can't handle the output from the textmode
 	       filter, so we disable it for anything that could
 	       create a literal packet (only encryption and
 	       symmetric encryption, since we disable signing
 	       above). */
 	    if(!unusable)
 	      opt.textmode=0;
 	  }
 
 	if(unusable)
 	  compliance_failure();
 	else
 	  {
 	    opt.force_mdc = 0;
 	    opt.disable_mdc = 1;
 	    opt.force_v4_certs = 0;
 	    opt.sk_comments = 0;
 	    opt.escape_from = 1;
 	    opt.force_v3_sigs = 1;
 	    opt.pgp2_workarounds = 1;
 	    opt.ask_sig_expire = 0;
 	    opt.ask_cert_expire = 0;
 	    xfree (def_digest_string);
 	    def_digest_string = xstrdup ("md5");
 	    opt.def_compress_algo = 1;
 	  }
       }
     else if(PGP6)
       {
 	opt.sk_comments=0;
 	opt.escape_from=1;
 	opt.force_v3_sigs=1;
 	opt.ask_sig_expire=0;
 	opt.force_mdc=0;
 	opt.disable_mdc=1;
       }
     else if(PGP7)
       {
 	opt.sk_comments=0;
 	opt.escape_from=1;
 	opt.force_v3_sigs=1;
 	opt.ask_sig_expire=0;
       }
     else if(PGP8)
       {
 	opt.escape_from=1;
       }
 
     /* must do this after dropping setuid, because string_to...
      * may try to load an module */
     if( def_cipher_string ) {
 	opt.def_cipher_algo = gcry_cipher_map_name (def_cipher_string);
 	if(opt.def_cipher_algo==0 &&
 	   (ascii_strcasecmp(def_cipher_string,"idea")==0
 	    || ascii_strcasecmp(def_cipher_string,"s1")==0))
 	  idea_cipher_warn(1);
 	xfree (def_cipher_string); def_cipher_string = NULL;
 	if( openpgp_cipher_test_algo (opt.def_cipher_algo) )
 	    log_error(_("selected cipher algorithm is invalid\n"));
     }
     if( def_digest_string ) {
 	opt.def_digest_algo = gcry_md_map_name (def_digest_string);
 	xfree (def_digest_string); def_digest_string = NULL;
 	if( openpgp_md_test_algo (opt.def_digest_algo) )
 	    log_error(_("selected digest algorithm is invalid\n"));
     }
     if( def_compress_string ) {
 	opt.def_compress_algo = string_to_compress_algo(def_compress_string);
 	xfree (def_compress_string); def_compress_string = NULL;
 	if( check_compress_algo(opt.def_compress_algo) )
 	    log_error(_("selected compression algorithm is invalid\n"));
     }
     if( cert_digest_string ) {
 	opt.cert_digest_algo = gcry_md_map_name (cert_digest_string);
 	xfree (cert_digest_string); cert_digest_string = NULL;
 	if( openpgp_md_test_algo(opt.cert_digest_algo) )
 	    log_error(_("selected certification digest algorithm is invalid\n"));
     }
     if( s2k_cipher_string ) {
 	opt.s2k_cipher_algo = gcry_cipher_map_name (s2k_cipher_string);
 	xfree (s2k_cipher_string); s2k_cipher_string = NULL;
 	if( openpgp_cipher_test_algo (opt.s2k_cipher_algo) )
 	    log_error(_("selected cipher algorithm is invalid\n"));
     }
     if( s2k_digest_string ) {
 	opt.s2k_digest_algo = gcry_md_map_name (s2k_digest_string);
 	xfree (s2k_digest_string); s2k_digest_string = NULL;
 	if( openpgp_md_test_algo (opt.s2k_digest_algo) )
 	    log_error(_("selected digest algorithm is invalid\n"));
     }
     if( opt.completes_needed < 1 )
 	log_error(_("completes-needed must be greater than 0\n"));
     if( opt.marginals_needed < 2 )
 	log_error(_("marginals-needed must be greater than 1\n"));
     if( opt.max_cert_depth < 1 || opt.max_cert_depth > 255 )
 	log_error(_("max-cert-depth must be in range 1 to 255\n"));
     switch( opt.s2k_mode ) {
       case 0:
 	log_info(_("NOTE: simple S2K mode (0) is strongly discouraged\n"));
 	break;
       case 1: case 3: break;
       default:
 	log_error(_("invalid S2K mode; must be 0, 1 or 3\n"));
     }
 
     if(opt.def_cert_check_level<0 || opt.def_cert_check_level>3)
       log_error(_("invalid default-check-level; must be 0, 1, 2, or 3\n"));
 
     /* This isn't actually needed, but does serve to error out if the
        string is invalid. */
     if(opt.def_preference_list &&
 	keygen_set_std_prefs(opt.def_preference_list,0))
       log_error(_("invalid default preferences\n"));
 
     /* We provide defaults for the personal digest list */
     if(!pers_digest_list)
       pers_digest_list="h2";
 
     if(pers_cipher_list &&
        keygen_set_std_prefs(pers_cipher_list,PREFTYPE_SYM))
       log_error(_("invalid personal cipher preferences\n"));
 
     if(pers_digest_list &&
        keygen_set_std_prefs(pers_digest_list,PREFTYPE_HASH))
       log_error(_("invalid personal digest preferences\n"));
 
     if(pers_compress_list &&
        keygen_set_std_prefs(pers_compress_list,PREFTYPE_ZIP))
       log_error(_("invalid personal compress preferences\n"));
 
     if( log_get_errorcount(0) )
 	g10_exit(2);
 
     /* Check our chosen algorithms against the list of legal
        algorithms. */
 
     if(!GNUPG)
       {
 	const char *badalg=NULL;
 	preftype_t badtype=PREFTYPE_NONE;
 
 	if (opt.def_cipher_algo
             && !algo_available (PREFTYPE_SYM,opt.def_cipher_algo,NULL))
 	  {
 	    badalg = gcry_cipher_algo_name (opt.def_cipher_algo);
 	    badtype = PREFTYPE_SYM;
 	  }
 	else if (opt.def_digest_algo
 		&& !algo_available (PREFTYPE_HASH,opt.def_digest_algo,NULL))
 	  {
 	    badalg = gcry_md_algo_name (opt.def_digest_algo);
 	    badtype = PREFTYPE_HASH;
 	  }
 	else if (opt.cert_digest_algo
 		 && !algo_available (PREFTYPE_HASH,opt.cert_digest_algo,NULL))
 	  {
 	    badalg = gcry_md_algo_name (opt.cert_digest_algo);
 	    badtype = PREFTYPE_HASH;
 	  }
 	else if (opt.def_compress_algo!=-1
                  && !algo_available (PREFTYPE_ZIP,opt.def_compress_algo,NULL))
 	  {
 	    badalg = compress_algo_to_string (opt.def_compress_algo);
 	    badtype = PREFTYPE_ZIP;
 	  }
 
 	if (badalg)
 	  {
 	    switch(badtype)
 	      {
 	      case PREFTYPE_SYM:
 		log_info(_("you may not use cipher algorithm \"%s\" "
 			   "while in %s mode\n"),
 			 badalg,compliance_option_string());
 		break;
 	      case PREFTYPE_HASH:
 		log_info(_("you may not use digest algorithm \"%s\" "
 			   "while in %s mode\n"),
 			 badalg,compliance_option_string());
 		break;
 	      case PREFTYPE_ZIP:
 		log_info(_("you may not use compression algorithm \"%s\" "
 			   "while in %s mode\n"),
 			 badalg,compliance_option_string());
 		break;
 	      default:
 		BUG();
 	      }
 
 	    compliance_failure();
 	  }
       }
 
     /* set the random seed file */
     if( use_random_seed ) {
 	char *p = make_filename(opt.homedir, "random_seed", NULL );
-#warning No random seed file yet
-#if 0
-	set_random_seed_file(p);
-#endif
+	gcry_control (GCRYCTL_SET_RANDOM_SEED_FILE, p);
 	xfree (p);
     }
 
     if( !cmd && opt.fingerprint && !with_fpr ) {
 	set_cmd( &cmd, aListKeys);
     }
 
     if( cmd == aKMode || cmd == aKModeC ) { /* kludge to be compatible to pgp */
 	if( cmd == aKModeC ) {
 	    opt.fingerprint = 1;
 	    cmd = aKMode;
 	}
 	opt.list_sigs = 0;
 	if( opt.verbose > 2 )
 	    opt.check_sigs++;
 	if( opt.verbose > 1 )
 	    opt.list_sigs++;
 
 	opt.verbose = opt.verbose > 1;
 	g10_opt_verbose = opt.verbose;
     }
 
     /* Compression algorithm 0 means no compression at all */
     if( opt.def_compress_algo == 0)
         opt.compress = 0;
 
     /* kludge to let -sat generate a clear text signature */
     if( opt.textmode == 2 && !detached_sig && opt.armor && cmd == aSign )
 	cmd = aClearsign;
 
     if( opt.verbose > 1 )
 	set_packet_list_mode(1);
 
     /* Add the keyrings, but not for some special commands and not in
        case of "-kvv userid keyring".  Also avoid adding the secret
        keyring for a couple of commands to avoid unneeded access in
        case the secrings are stored on a floppy */
     if( cmd != aDeArmor && cmd != aEnArmor
 	&& !(cmd == aKMode && argc == 2 ) ) 
       {
         if (cmd != aCheckKeys && cmd != aListSigs && cmd != aListKeys
             && cmd != aVerify && cmd != aVerifyFiles
             && cmd != aSym)
           {
             if (!sec_nrings || default_keyring) /* add default secret rings */
               keydb_add_resource ("secring" EXTSEP_S "gpg", 0, 1);
             for (sl = sec_nrings; sl; sl = sl->next)
               keydb_add_resource ( sl->d, 0, 1 );
           }
 	if( !nrings || default_keyring )  /* add default ring */
 	    keydb_add_resource ("pubring" EXTSEP_S "gpg", 0, 0);
 	for(sl = nrings; sl; sl = sl->next )
 	    keydb_add_resource ( sl->d, sl->flags, 0 );
       }
     FREE_STRLIST(nrings);
     FREE_STRLIST(sec_nrings);
 
 
     if( pwfd != -1 )  /* read the passphrase now. */
 	read_passphrase_from_fd( pwfd );
 
     fname = argc? *argv : NULL;
 
     switch( cmd ) {
       case aPrimegen:
       case aPrintMD:
       case aPrintMDs:
       case aGenRandom:
       case aDeArmor:
       case aEnArmor:
       case aFixTrustDB:
       case aCardStatus:
       case aChangePIN:
 	break;
       case aExportOwnerTrust: rc = setup_trustdb( 0, trustdb_name ); break;
       case aListTrustDB: rc = setup_trustdb( argc? 1:0, trustdb_name ); break;
       default: rc = setup_trustdb(1, trustdb_name ); break;
     }
     if( rc )
 	log_error(_("failed to initialize the TrustDB: %s\n"), gpg_strerror (rc));
 
 
     switch (cmd) {
       case aStore: 
       case aSym:  
       case aSign: 
       case aSignSym: 
       case aClearsign: 
         if (!opt.quiet && any_explicit_recipient)
           log_info (_("WARNING: recipients (-r) given "
                       "without using public key encryption\n"));
 	break;
       default:
         break;
     }
 
     switch( cmd ) {
       case aStore: /* only store the file */
 	if( argc > 1 )
 	    wrong_args(_("--store [filename]"));
 	if( (rc = encode_store(fname)) )
 	    log_error ("\b%s: store failed: %s\n",
                        print_fname_stdin(fname), gpg_strerror (rc) );
 	break;
       case aSym: /* encrypt the given file only with the symmetric cipher */
 	if( argc > 1 )
 	    wrong_args(_("--symmetric [filename]"));
 	if( (rc = encode_symmetric(fname)) )
 	    log_error ("\b%s: symmetric encryption failed: %s\n",
                        print_fname_stdin(fname), gpg_strerror (rc) );
 	break;
 
       case aEncr: /* encrypt the given file */
 	if( argc > 1 )
 	    wrong_args(_("--encrypt [filename]"));
 	if( (rc = encode_crypt(fname,remusr)) )
 	    log_error("%s: encryption failed: %s\n",
                       print_fname_stdin(fname), gpg_strerror (rc) );
 	break;
 
       case aEncrFiles: /* encrypt the given files */
         encode_crypt_files(argc, argv, remusr);
     	break;
           
       case aSign: /* sign the given file */
 	sl = NULL;
 	if( detached_sig ) { /* sign all files */
 	    for( ; argc; argc--, argv++ )
 		add_to_strlist( &sl, *argv );
 	}
 	else {
 	    if( argc > 1 )
 		wrong_args(_("--sign [filename]"));
 	    if( argc ) {
 		sl = xcalloc (1, sizeof *sl + strlen(fname));
 		strcpy(sl->d, fname);
 	    }
 	}
 	if( (rc = sign_file( sl, detached_sig, locusr, 0, NULL, NULL)) )
 	    log_error("signing failed: %s\n", gpg_strerror (rc) );
 	free_strlist(sl);
 	break;
 
       case aSignEncr: /* sign and encrypt the given file */
 	if( argc > 1 )
 	    wrong_args(_("--sign --encrypt [filename]"));
 	if( argc ) {
 	    sl = xcalloc (1, sizeof *sl + strlen(fname));
 	    strcpy(sl->d, fname);
 	}
 	else
 	    sl = NULL;
 	if( (rc = sign_file(sl, detached_sig, locusr, 1, remusr, NULL)) )
 	    log_error("%s: sign+encrypt failed: %s\n", print_fname_stdin(fname), gpg_strerror (rc) );
 	free_strlist(sl);
 	break;
 
       case aSignSym: /* sign and conventionally encrypt the given file */
 	if (argc > 1)
 	    wrong_args(_("--sign --symmetric [filename]"));
 	rc = sign_symencrypt_file (fname, locusr);
         if (rc)
 	    log_error("%s: sign+symmetric failed: %s\n",
                       print_fname_stdin(fname), gpg_strerror (rc) );
 	break;
 
       case aClearsign: /* make a clearsig */
 	if( argc > 1 )
 	    wrong_args(_("--clearsign [filename]"));
 	if( (rc = clearsign_file(fname, locusr, NULL)) )
 	    log_error("%s: clearsign failed: %s\n",
                       print_fname_stdin(fname), gpg_strerror (rc) );
 	break;
 
       case aVerify:
 	if( (rc = verify_signatures( argc, argv ) ))
 	    log_error("verify signatures failed: %s\n", gpg_strerror (rc) );
 	break;
 
       case aVerifyFiles:
 	if( (rc = verify_files( argc, argv ) ))
 	    log_error("verify files failed: %s\n", gpg_strerror (rc) );
 	break;
 
       case aDecrypt:
 	if( argc > 1 )
 	    wrong_args(_("--decrypt [filename]"));
 	if( (rc = decrypt_message( fname ) ))
 	    log_error("decrypt_message failed: %s\n", gpg_strerror (rc) );
 	break;
 
       case aDecryptFiles:
         decrypt_messages(argc, argv);
         break;
             
       case aSignKey: /* sign the key given as argument */
 	if( argc != 1 )
 	    wrong_args(_("--sign-key user-id"));
 	username = make_username( fname );
 	keyedit_menu(fname, locusr, NULL, 1 );
 	xfree (username);
 	break;
 
       case aLSignKey:
 	if( argc != 1 )
 	    wrong_args(_("--lsign-key user-id"));
 	username = make_username( fname );
 	keyedit_menu(fname, locusr, NULL, 2 );
 	xfree (username);
 	break;
 
       case aNRSignKey:
 	if( argc != 1 )
 	    wrong_args(_("--nrsign-key user-id"));
 	username = make_username( fname );
 	keyedit_menu(fname, locusr, NULL, 3 );
         xfree (username);
         break;
 
       case aNRLSignKey:
 	if( argc != 1 )
 	    wrong_args(_("--nrlsign-key user-id"));
 	username = make_username( fname );
 	keyedit_menu(fname, locusr, NULL, 4 );
         xfree (username);
         break;
 
       case aEditKey: /* Edit a key signature */
 	if( !argc )
 	    wrong_args(_("--edit-key user-id [commands]"));
 	username = make_username( fname );
 	if( argc > 1 ) {
 	    sl = NULL;
 	    for( argc--, argv++ ; argc; argc--, argv++ )
 		append_to_strlist( &sl, *argv );
 	    keyedit_menu( username, locusr, sl, 0 );
 	    free_strlist(sl);
 	}
 	else
 	    keyedit_menu(username, locusr, NULL, 0 );
 	xfree (username);
 	break;
 
       case aDeleteKeys:
       case aDeleteSecretKeys:
       case aDeleteSecretAndPublicKeys:
 	sl = NULL;
 	/* I'm adding these in reverse order as add_to_strlist2
            reverses them again, and it's easier to understand in the
            proper order :) */
 	for( ; argc; argc-- )
 	  add_to_strlist2( &sl, argv[argc-1], utf8_strings );
 	delete_keys(sl,cmd==aDeleteSecretKeys,cmd==aDeleteSecretAndPublicKeys);
 	free_strlist(sl);
 	break;
 
       case aCheckKeys:
 	opt.check_sigs = 1;
       case aListSigs:
 	opt.list_sigs = 1;
       case aListKeys:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	public_key_list( sl );
 	free_strlist(sl);
 	break;
       case aListSecretKeys:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	secret_key_list( sl );
 	free_strlist(sl);
 	break;
 
       case aKMode: /* list keyring -- NOTE: This will be removed soon */
 	if( argc < 2 ) { /* -kv [userid] */
 	    sl = NULL;
 	    if (argc && **argv)
 		add_to_strlist2( &sl, *argv, utf8_strings );
 	    public_key_list( sl );
 	    free_strlist(sl);
 	}
 	else if( argc == 2 ) { /* -kv userid keyring */
 	    if( access( argv[1], R_OK ) ) {
 		log_error(_("can't open %s: %s\n"),
 			       print_fname_stdin(argv[1]), strerror(errno));
 	    }
 	    else {
 		/* add keyring (default keyrings are not registered in this
 		 * special case */
 		keydb_add_resource( argv[1], 0, 0 );
 		sl = NULL;
 		if (**argv)
 		    add_to_strlist2( &sl, *argv, utf8_strings );
 		public_key_list( sl );
 		free_strlist(sl);
 	    }
 	}
 	else
 	    wrong_args(_("-k[v][v][v][c] [user-id] [keyring]") );
 	break;
 
       case aKeygen: /* generate a key */
 	if( opt.batch ) {
 	    if( argc > 1 )
 		wrong_args("--gen-key [parameterfile]");
 	    generate_keypair( argc? *argv : NULL );
 	}
 	else {
 	    if( argc )
 		wrong_args("--gen-key");
 	    generate_keypair(NULL);
 	}
 	break;
 
       case aFastImport:
         opt.import_options |= IMPORT_FAST_IMPORT;
       case aImport:
 	import_keys( argc? argv:NULL, argc, NULL, opt.import_options );
 	break;
 
       case aExport:
       case aExportAll:
       case aSendKeys:
       case aRecvKeys:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	if( cmd == aSendKeys )
 	    rc=keyserver_export( sl );
 	else if( cmd == aRecvKeys )
 	    rc=keyserver_import( sl );
 	else
 	    rc=export_pubkeys( sl, opt.export_options );
 	if(rc)
 	  {
 	    if(cmd==aSendKeys)
 	      log_error(_("keyserver send failed: %s\n"),gpg_strerror (rc));
 	    else if(cmd==aRecvKeys)
 	      log_error(_("keyserver receive failed: %s\n"),gpg_strerror (rc));
 	    else
 	      log_error(_("key export failed: %s\n"),gpg_strerror (rc));
 	  }
 	free_strlist(sl);
 	break;
 
      case aSearchKeys:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
           {
             if (utf8_strings)
               sl = append_to_strlist ( &sl, *argv );
             else
               {
                 char *p = native_to_utf8 ( *argv );
                 sl = append_to_strlist( &sl, p );
                 xfree( p );
               }
           }
 
 	rc=keyserver_search( sl );
 	if(rc)
 	  log_error(_("keyserver search failed: %s\n"),gpg_strerror (rc));
 	free_strlist(sl);
 	break;
 
       case aRefreshKeys:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	rc=keyserver_refresh(sl);
 	if(rc)
 	  log_error(_("keyserver refresh failed: %s\n"),gpg_strerror (rc));
 	free_strlist(sl);
 	break;
 
       case aExportSecret:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	export_seckeys( sl );
 	free_strlist(sl);
 	break;
 
       case aExportSecretSub:
 	sl = NULL;
 	for( ; argc; argc--, argv++ )
 	    add_to_strlist2( &sl, *argv, utf8_strings );
 	export_secsubkeys( sl );
 	free_strlist(sl);
 	break;
 
       case aGenRevoke:
 	if( argc != 1 )
 	    wrong_args("--gen-revoke user-id");
 	username =  make_username(*argv);
 	gen_revoke( username );
 	xfree ( username );
 	break;
 
       case aDesigRevoke:
 	if( argc != 1 )
 	    wrong_args("--desig-revoke user-id");
 	username =  make_username(*argv);
 	gen_desig_revoke( username );
 	xfree ( username );
 	break;
 
       case aDeArmor:
 	if( argc > 1 )
 	    wrong_args("--dearmor [file]");
 	rc = dearmor_file( argc? *argv: NULL );
 	if( rc )
 	    log_error(_("dearmoring failed: %s\n"), gpg_strerror (rc));
 	break;
 
       case aEnArmor:
 	if( argc > 1 )
 	    wrong_args("--enarmor [file]");
 	rc = enarmor_file( argc? *argv: NULL );
 	if( rc )
 	    log_error(_("enarmoring failed: %s\n"), gpg_strerror (rc));
 	break;
 
 
       case aPrimegen:
 #if 0 /*FIXME-XXX*/
 	{   int mode = argc < 2 ? 0 : atoi(*argv);
 
 	    if( mode == 1 && argc == 2 ) {
 		mpi_print( stdout, generate_public_prime( atoi(argv[1]) ), 1);
 	    }
 	    else if( mode == 2 && argc == 3 ) {
 		mpi_print( stdout, generate_elg_prime(
 					     0, atoi(argv[1]),
 					     atoi(argv[2]), NULL,NULL ), 1);
 	    }
 	    else if( mode == 3 && argc == 3 ) {
 		gcry_mpi_t *factors;
 		mpi_print( stdout, generate_elg_prime(
 					     1, atoi(argv[1]),
 					     atoi(argv[2]), NULL,&factors ), 1);
 		putchar('\n');
 		mpi_print( stdout, factors[0], 1 ); /* print q */
 	    }
 	    else if( mode == 4 && argc == 3 ) {
 		gcry_mpi_t g = mpi_alloc(1);
 		mpi_print( stdout, generate_elg_prime(
 						 0, atoi(argv[1]),
 						 atoi(argv[2]), g, NULL ), 1);
 		putchar('\n');
 		mpi_print( stdout, g, 1 );
 		mpi_free(g);
 	    }
 	    else
 		wrong_args("--gen-prime mode bits [qbits] ");
 	    putchar('\n');
 	}
 #endif
 	break;
 
       case aGenRandom:
 	{
 	    int level = argc ? atoi(*argv):0;
 	    int count = argc > 1 ? atoi(argv[1]): 0;
 	    int endless = !count;
 
 	    if( argc < 1 || argc > 2 || level < 0 || level > 2 || count < 0 )
 		wrong_args("--gen-random 0|1|2 [count]");
 
 	    while( endless || count ) {
 		byte *p;
                 /* Wee need a multiple of 3, so that in case of
                    armored output we get a correct string.  No
                    linefolding is done, as it is best to levae this to
                    other tools */
 		size_t n = !endless && count < 99? count : 99;
 
 		p = gcry_random_bytes (n, level);
 #ifdef HAVE_DOSISH_SYSTEM
 		setmode ( fileno(stdout), O_BINARY );
 #endif
                 if (opt.armor) {
                     char *tmp = make_radix64_string (p, n);
                     fputs (tmp, stdout);
                     xfree (tmp);
                     if (n%3 == 1)
                       putchar ('=');
                     if (n%3)
                       putchar ('=');
                 } else {
                     fwrite( p, n, 1, stdout );
                 }
 		xfree (p);
 		if( !endless )
 		    count -= n;
 	    }
             if (opt.armor)
                 putchar ('\n');
 	}
 	break;
 
       case aPrintMD:
 	if( argc < 1)
 	    wrong_args("--print-md algo [files]");
 	{
 	    int all_algos = (**argv=='*' && !(*argv)[1]);
 	    int algo = all_algos? 0 : gcry_md_map_name (*argv);
 
 	    if( !algo && !all_algos )
 		log_error(_("invalid hash algorithm `%s'\n"), *argv );
 	    else {
 		argc--; argv++;
 		if( !argc )
 		    print_mds(NULL, algo);
 		else {
 		    for(; argc; argc--, argv++ )
 			print_mds(*argv, algo);
 		}
 	    }
 	}
 	break;
 
       case aPrintMDs: /* old option */
 	if( !argc )
 	    print_mds(NULL,0);
 	else {
 	    for(; argc; argc--, argv++ )
 		print_mds(*argv,0);
 	}
 	break;
 
       case aListTrustDB:
 	if( !argc )
 	    list_trustdb(NULL);
 	else {
 	    for( ; argc; argc--, argv++ )
 		list_trustdb( *argv );
 	}
 	break;
 
       case aUpdateTrustDB:
 	if( argc )
 	    wrong_args("--update-trustdb");
 	update_trustdb();
 	break;
 
       case aCheckTrustDB:
         /* Old versions allowed for arguments - ignore them */
         check_trustdb();
 	break;
 
       case aFixTrustDB:
 	log_error("this command is not yet implemented.\n");
 	log_error("A workaround is to use \"--export-ownertrust\", remove\n");
 	log_error("the trustdb file and do an \"--import-ownertrust\".\n" );
 	break;
 
       case aListTrustPath:
 	if( !argc )
 	    wrong_args("--list-trust-path <user-ids>");
 	for( ; argc; argc--, argv++ ) {
 	    username = make_username( *argv );
 	    list_trust_path( username );
 	    xfree (username);
 	}
 	break;
 
       case aExportOwnerTrust:
 	if( argc )
 	    wrong_args("--export-ownertrust");
 	export_ownertrust();
 	break;
 
       case aImportOwnerTrust:
 	if( argc > 1 )
 	    wrong_args("--import-ownertrust [file]");
 	import_ownertrust( argc? *argv:NULL );
 	break;
       
       case aPipeMode:
         if ( argc )
             wrong_args ("--pipemode");
         run_in_pipemode ();
         break;
 
       case aRebuildKeydbCaches:
         if (argc)
             wrong_args ("--rebuild-keydb-caches");
         keydb_rebuild_caches ();
         break;
 
     case aCardStatus:
       if (argc)
         wrong_args ("--card-status");
       card_status (stdout);
       break;
 
     case aChangePIN:
       if (!argc)
         change_pin (0);
       else if (argc == 1)
         change_pin ( atoi (*argv));
       else
         wrong_args ("--change-pin [no]");
       break;
 
       case aListPackets:
 	opt.list_packets=2;
       default:
 	if( argc > 1 )
 	    wrong_args(_("[filename]"));
 	/* Issue some output for the unix newbie */
 	if( !fname && !opt.outfile && isatty( fileno(stdin) )
 		&& isatty( fileno(stdout) ) && isatty( fileno(stderr) ) )
 	    log_info(_("Go ahead and type your message ...\n"));
 
 	if( !(a = iobuf_open(fname)) )
 	    log_error(_("can't open `%s'\n"), print_fname_stdin(fname));
 	else {
 
 	    if( !opt.no_armor ) {
 		if( use_armor_filter( a ) ) {
 		    memset( &afx, 0, sizeof afx);
 		    iobuf_push_filter( a, armor_filter, &afx );
 		}
 	    }
 	    if( cmd == aListPackets ) {
 		set_packet_list_mode(1);
 		opt.list_packets=1;
 	    }
 	    rc = proc_packets(NULL, a );
 	    if( rc )
 		log_error("processing message failed: %s\n", gpg_strerror (rc) );
 	    iobuf_close(a);
 	}
 	break;
     }
 
     /* cleanup */
     FREE_STRLIST(remusr);
     FREE_STRLIST(locusr);
     g10_exit(0);
     return 8; /*NEVER REACHED*/
 }
 
 /* Note: This function is used by signal handlers!. */
 static void
 emergency_cleanup (void)
 {
   gcry_control (GCRYCTL_TERM_SECMEM );
 }
 
 
 void
 g10_exit( int rc )
 {
-  /* FIXME-XX update_random_seed_file(); */
-/*      if( opt.debug & DBG_MEMSTAT_VALUE ) { */
-/*          m_print_stats("on exit"); */
-/*  	random_dump_stats(); */
-/*      } */
-/*      if( opt.debug ) */
-/*  	secmem_dump_stats(); */
-    gcry_control (GCRYCTL_TERM_SECMEM );
-    rc = rc? rc : log_get_errorcount(0)? 2 :
-			g10_errors_seen? 1 : 0;
-    exit(rc );
+  gcry_control (GCRYCTL_UPDATE_RANDOM_SEED_FILE);
+  if (opt.debug & DBG_MEMSTAT_VALUE)
+    {
+      gcry_control( GCRYCTL_DUMP_MEMORY_STATS );
+      gcry_control( GCRYCTL_DUMP_RANDOM_STATS );
+    }
+  if (opt.debug)
+    gcry_control (GCRYCTL_DUMP_SECMEM_STATS );
+  emergency_cleanup ();
+  rc = rc? rc : log_get_errorcount(0)? 2 :
+       g10_errors_seen? 1 : 0;
+  exit (rc );
 }
 
 
 /* Pretty-print hex hashes.  This assumes at least an 80-character
    display, but there are a few other similar assumptions in the
    display code. */
 static void
 print_hex( MD_HANDLE md, int algo, const char *fname )
 {
   int i,n,count,indent=0;
   const byte *p;
 
   if(fname)
     indent=printf("%s: ",fname);
 
   if(indent>40)
     {
       printf("\n");
       indent=0;
     }
 
   if(algo==DIGEST_ALGO_RMD160)
     indent+=printf("RMD160 = ");
   else if(algo==DIGEST_ALGO_TIGER)
     indent+=printf(" TIGER = ");
   else if(algo>0)
     indent+=printf("%6s = ", gcry_md_algo_name (algo));
   else
     algo=abs(algo);
 
   count=indent;
 
   p = gcry_md_read (md, algo);
   n = gcry_md_get_algo_dlen (algo);
 
   count+=printf("%02X",*p++);
 
   for(i=1;i<n;i++,p++)
     {
       if(n==16)
 	{
 	  if(count+2>79)
 	    {
 	      printf("\n%*s",indent," ");
 	      count=indent;
 	    }
 	  else
 	    count+=printf(" ");
 
 	  if(!(i%8))
 	    count+=printf(" ");
 	}
       else if (n==20)
 	{
 	  if(!(i%2))
 	    {
 	      if(count+4>79)
 		{
 		  printf("\n%*s",indent," ");
 		  count=indent;
 		}
 	      else
 		count+=printf(" ");
 	    }
 
 	  if(!(i%10))
 	    count+=printf(" ");
 	}
       else
 	{
 	  if(!(i%4))
 	    {
 	      if(count+8>79)
 		{
 		  printf("\n%*s",indent," ");
 		  count=indent;
 		}
 	      else
 		count+=printf(" ");
 	    }
 	}
 
       count+=printf("%02X",*p);
     }
 
   printf("\n");
 }
 
 static void
 print_hashline( MD_HANDLE md, int algo, const char *fname )
 {
     int i, n;
     const byte *p;
     
     if ( fname ) {
         for (p = fname; *p; p++ ) {
             if ( *p <= 32 || *p > 127 || *p == ':' || *p == '%' )
                 printf("%%%02X", *p );
             else 
                 putchar( *p );
         }
     }
     putchar(':');
     printf("%d:", algo );
     p = gcry_md_read (md, algo );
     n = gcry_md_get_algo_dlen (algo);
     for(i=0; i < n ; i++, p++ ) 
         printf("%02X", *p );
     putchar(':');
     putchar('\n');
 }
 
 static void
 print_mds( const char *fname, int algo )
 {
     FILE *fp;
     char buf[1024];
     size_t n;
     MD_HANDLE md;
 
     if( !fname ) {
 	fp = stdin;
 #ifdef HAVE_DOSISH_SYSTEM
 	setmode ( fileno(fp) , O_BINARY );
 #endif
     }
     else {
 	fp = fopen( fname, "rb" );
     }
     if( !fp ) {
 	log_error("%s: %s\n", fname?fname:"[stdin]", strerror(errno) );
 	return;
     }
 
     gcry_md_open (&md, 0, 0 );
     if( algo )
 	gcry_md_enable ( md, algo );
     else {
 	gcry_md_enable (md, GCRY_MD_MD5 );
 	gcry_md_enable (md, GCRY_MD_SHA1 );
 	gcry_md_enable (md, GCRY_MD_RMD160 );
 #ifdef USE_TIGER192
 	gcry_md_enable (md, GCRY_MD_TIGER );
 #endif
 #ifdef USE_SHA256
 	gcry_md_enable (md, GCRY_MD_SHA256 );
 #endif
 #ifdef USE_SHA512
 	gcry_md_enable (md, GCRY_MD_SHA384 );
 	gcry_md_enable (md, GCRY_MD_SHA512 );
 #endif
     }
 
     while( (n=fread( buf, 1, DIM(buf), fp )) )
 	gcry_md_write (md, buf, n);
     if( ferror(fp) )
 	log_error("%s: %s\n", fname?fname:"[stdin]", strerror(errno) );
     else {
 	gcry_md_final (md);
         if ( opt.with_colons ) {
             if ( algo ) 
                 print_hashline( md, algo, fname );
             else {
                 print_hashline( md, GCRY_MD_MD5, fname );
                 print_hashline( md, GCRY_MD_SHA1, fname );
                 print_hashline( md, GCRY_MD_RMD160, fname );
 #ifdef USE_TIGER192
 		print_hashline( md, GCRY_MD_TIGER, fname );
 #endif
 #ifdef USE_SHA256
                 print_hashline( md, GCRY_MD_SHA256, fname );
 #endif
 #ifdef USE_SHA512
 		print_hashline( md, GCRY_MD_SHA384, fname );
 		print_hashline( md, GCRY_MD_SHA512, fname );
 #endif
             }
         }
         else {
             if( algo )
 	       print_hex(md,-algo,fname);
             else {
                 print_hex( md, GCRY_MD_MD5, fname );
                 print_hex( md, GCRY_MD_SHA1, fname );
                 print_hex( md, GCRY_MD_RMD160, fname );
 #ifdef USE_TIGER192
 		print_hex( md, GCRY_MD_TIGER, fname );
 #endif
 #ifdef USE_SHA256
                 print_hex( md, GCRY_MD_SHA256, fname );
 #endif
 #ifdef USE_SHA512
 		print_hex( md, GCRY_MD_SHA384, fname );
 		print_hex( md, GCRY_MD_SHA512, fname );
 #endif
             }
         }
     }
     gcry_md_close (md);
 
     if( fp != stdin )
 	fclose(fp);
 }
 
 
 /****************
  * Check the supplied name,value string and add it to the notation
  * data to be used for signatures.  which==0 for sig notations, and 1
  * for cert notations.
 */
 static void
 add_notation_data( const char *string, int which )
 {
     const char *s;
     STRLIST sl,*notation_data;
     int critical=0;
     int highbit=0;
     int saw_at=0;
 
     if(which)
       notation_data=&opt.cert_notation_data;
     else
       notation_data=&opt.sig_notation_data;
 
     if( *string == '!' ) {
 	critical = 1;
 	string++;
     }
 
     /* If and when the IETF assigns some official name tags, we'll
        have to add them here. */
 
     for( s=string ; *s != '='; s++ )
       {
 	if( *s=='@')
 	  saw_at=1;
 
 	if( !*s || (*s & 0x80) || (!isgraph(*s) && !isspace(*s)) )
 	  {
 	    log_error(_("a notation name must have only printable characters "
 			"or spaces, and end with an '='\n") );
 	    return;
 	  }
       }
 
     if(!saw_at && !opt.expert)
       {
 	log_error(
 	        _("a user notation name must contain the '@' character\n"));
 	return;
       }
 
     /* we only support printable text - therefore we enforce the use
      * of only printable characters (an empty value is valid) */
     for( s++; *s ; s++ ) {
 	if( iscntrl(*s) ) {
 	    log_error(_("a notation value must not use "
 			"any control characters\n") );
 	    return;
 	}
 	else if( *s & 0x80 )
 	    highbit = 1;
     }
 
     if( highbit )   /* must use UTF8 encoding */
 	sl = add_to_strlist2( notation_data, string, utf8_strings );
     else
 	sl = add_to_strlist( notation_data, string );
 
     if( critical )
 	sl->flags |= 1;
 }
 
 
 static void
 add_policy_url( const char *string, int which )
 {
   int i,critical=0;
   STRLIST sl;
 
   if(*string=='!')
     {
       string++;
       critical=1;
     }
 
   for(i=0;i<strlen(string);i++)
     if(string[i]&0x80 || iscntrl(string[i]))
       break;
 
   if(i==0 || i<strlen(string))
     {
       if(which)
 	log_error(_("the given certification policy URL is invalid\n"));
       else
 	log_error(_("the given signature policy URL is invalid\n"));
     }
 
   if(which)
     sl=add_to_strlist( &opt.cert_policy_url, string );
   else
     sl=add_to_strlist( &opt.sig_policy_url, string );
 
   if(critical)
     sl->flags |= 1;    
 }
diff --git a/g10/keygen.c b/g10/keygen.c
index 515d4867a..210bbc897 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -1,3002 +1,3242 @@
 /* keygen.c - generate a key pair
  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003
  *                                               Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <ctype.h>
 #include <errno.h>
 #include <assert.h>
 
 #include "gpg.h"
 #include "util.h"
 #include "main.h"
 #include "packet.h"
 #include "cipher.h"
 #include "ttyio.h"
 #include "options.h"
 #include "keydb.h"
 #include "trustdb.h"
 #include "status.h"
 #include "i18n.h"
 #include "call-agent.h"
 
 
 #define MAX_PREFS 30 
 
 enum para_name {
   pKEYTYPE,
   pKEYLENGTH,
   pKEYUSAGE,
   pSUBKEYTYPE,
   pSUBKEYLENGTH,
   pSUBKEYUSAGE,
   pAUTHKEYTYPE,
   pNAMEREAL,
   pNAMEEMAIL,
   pNAMECOMMENT,
   pPREFERENCES,
   pREVOKER,
   pUSERID,
   pEXPIREDATE,
   pKEYEXPIRE, /* in n seconds */
   pSUBKEYEXPIRE, /* in n seconds */
   pPASSPHRASE,
   pPASSPHRASE_DEK,
   pPASSPHRASE_S2K,
   pSERIALNO
 };
 
 struct para_data_s {
     struct para_data_s *next;
     int lnr;
     enum para_name key;
     union {
         DEK *dek;
         STRING2KEY *s2k;
         u32 expire;
         unsigned int usage;
         struct revocation_key revkey;
         char value[1];
     } u;
 };
 
 struct output_control_s {
     int lnr;
     int dryrun;
     int use_files;
     struct {
 	char  *fname;
 	char  *newfname;
 	iobuf_t stream;
 	armor_filter_context_t afx;
     } pub;
     struct {
 	char  *fname;
 	char  *newfname;
 	iobuf_t stream;
 	armor_filter_context_t afx;
     } sec;
 };
 
 
 struct opaque_data_usage_and_pk {
     unsigned int usage;
     PKT_public_key *pk;
 };
 
 
 static int prefs_initialized = 0;
 static byte sym_prefs[MAX_PREFS];
 static int nsym_prefs;
 static byte hash_prefs[MAX_PREFS];
 static int nhash_prefs;
 static byte zip_prefs[MAX_PREFS];
 static int nzip_prefs;
 static int mdc_available,ks_modify;
 
 static void do_generate_keypair( struct para_data_s *para,
 				 struct output_control_s *outctrl, int card);
 static int write_keyblock( iobuf_t out, KBNODE node );
 static int check_smartcard (char **);
 static int gen_card_key (int algo, int keyno, KBNODE pub_root, KBNODE sec_root,
                          u32 expireval, struct para_data_s *para);
 
 
 
 static void
 write_uid( KBNODE root, const char *s )
 {
     PACKET *pkt = xcalloc (1,sizeof *pkt );
     size_t n = strlen(s);
 
     pkt->pkttype = PKT_USER_ID;
     pkt->pkt.user_id = xcalloc (1, sizeof *pkt->pkt.user_id + n - 1 );
     pkt->pkt.user_id->len = n;
     pkt->pkt.user_id->ref = 1;
     strcpy(pkt->pkt.user_id->name, s);
     add_kbnode( root, new_kbnode( pkt ) );
 }
 
 static void
 do_add_key_flags (PKT_signature *sig, unsigned int use)
 {
     byte buf[1];
 
     if (!use) 
         return;
 
     buf[0] = 0;
     if (use & PUBKEY_USAGE_SIG)
         buf[0] |= 0x01 | 0x02;
     if (use & PUBKEY_USAGE_ENC)
         buf[0] |= 0x04 | 0x08;
     build_sig_subpkt (sig, SIGSUBPKT_KEY_FLAGS, buf, 1);
 }
 
 
 int
 keygen_add_key_expire( PKT_signature *sig, void *opaque )
 {
     PKT_public_key *pk = opaque;
     byte buf[8];
     u32  u;
 
     if( pk->expiredate ) {
         if(pk->expiredate > pk->timestamp)
 	  u= pk->expiredate - pk->timestamp;
 	else
 	  u= 0;
 
 	buf[0] = (u >> 24) & 0xff;
 	buf[1] = (u >> 16) & 0xff;
 	buf[2] = (u >>	8) & 0xff;
 	buf[3] = u & 0xff;
 	build_sig_subpkt( sig, SIGSUBPKT_KEY_EXPIRE, buf, 4 );
     }
     else
       {
 	/* Make sure we don't leave a key expiration subpacket lying
 	   around */
 	delete_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE);
       }
 
     return 0;
 }
 
 static int
 keygen_add_key_flags_and_expire (PKT_signature *sig, void *opaque)
 {
     struct opaque_data_usage_and_pk *oduap = opaque;
 
     do_add_key_flags (sig, oduap->usage);
     return keygen_add_key_expire (sig, oduap->pk);
 }
 
 static int
 set_one_pref (int val, int type, const char *item, byte *buf, int *nbuf)
 {
     int i;
 
     for (i=0; i < *nbuf; i++ )
       if (buf[i] == val)
 	{
 	  log_info (_("preference `%s' duplicated\n"), item);
 	  return -1;
         }
 
     if (*nbuf >= MAX_PREFS)
       {
 	if(type==1)
 	  log_info(_("too many cipher preferences\n"));
 	else if(type==2)
 	  log_info(_("too many digest preferences\n"));
 	else if(type==3)
 	  log_info(_("too many compression preferences\n"));
 	else
 	  BUG();
 
         return -1;
       }
 
     buf[(*nbuf)++] = val;
     return 0;
 }
 
 #ifdef USE_AES
 #define AES "S9 S8 S7 "
 #else
 #define AES ""
 #endif
 
 #ifdef USE_CAST5
 #define CAST5 "S3 "
 #else
 #define CAST5 ""
 #endif
 
 /*
  * Parse the supplied string and use it to set the standard
  * preferences.  The string may be in a form like the one printed by
  * "pref" (something like: "S10 S3 H3 H2 Z2 Z1") or the actual
  * cipher/hash/compress names.  Use NULL to set the default
  * preferences.  Returns: 0 = okay
  */
 int
 keygen_set_std_prefs (const char *string,int personal)
 {
     byte sym[MAX_PREFS], hash[MAX_PREFS], zip[MAX_PREFS];
     int nsym=0, nhash=0, nzip=0, val, rc=0;
     int mdc=1, modify=0; /* mdc defaults on, modify defaults off. */
 
     if (!string || !ascii_strcasecmp (string, "default")) {
       if (opt.def_preference_list)
 	string=opt.def_preference_list;
       else if ( !openpgp_cipher_test_algo(CIPHER_ALGO_IDEA) )
         string = AES CAST5 "S2 S1 H2 H3 Z2 Z1";
       else
         string = AES CAST5 "S2 H2 H3 Z2 Z1";
 
       /* If we have it, IDEA goes *after* 3DES so it won't be used
          unless we're encrypting along with a V3 key.  Ideally, we
          would only put the S1 preference in if the key was RSA and
          <=2048 bits, as that is what won't break PGP2, but that is
          difficult with the current code, and not really worth
          checking as a non-RSA <=2048 bit key wouldn't be usable by
          PGP2 anyway. -dms */
     }
     else if (!ascii_strcasecmp (string, "none"))
         string = "";
 
     if(strlen(string))
       {
 	char *tok,*prefstring;
 
 	prefstring=xstrdup (string); /* need a writable string! */
 
 	while((tok=strsep(&prefstring," ,")))
 	  {
 	    if((val=openpgp_cipher_map_name(tok)))
 	      {
 		if(set_one_pref(val,1,tok,sym,&nsym))
 		  rc=-1;
 	      }
 	    else if((val=openpgp_md_map_name(tok)))
 	      {
 		if(set_one_pref(val,2,tok,hash,&nhash))
 		  rc=-1;
 	      }
 	    else if((val=string_to_compress_algo(tok))>-1)
 	      {
 		if(set_one_pref(val,3,tok,zip,&nzip))
 		  rc=-1;
 	      }
 	    else if (ascii_strcasecmp(tok,"mdc")==0)
 	      mdc=1;
 	    else if (ascii_strcasecmp(tok,"no-mdc")==0)
 	      mdc=0;
 	    else if (ascii_strcasecmp(tok,"ks-modify")==0)
 	      modify=1;
 	    else if (ascii_strcasecmp(tok,"no-ks-modify")==0)
 	      modify=0;
 	    else
 	      {
 		log_info (_("invalid item `%s' in preference string\n"),tok);
 
 		/* Complain if IDEA is not available. */
 		if(ascii_strcasecmp(tok,"s1")==0
 		   || ascii_strcasecmp(tok,"idea")==0)
 		  idea_cipher_warn(1);
 
 		rc=-1;
 	      }
 	  }
 
 	xfree (prefstring);
       }
 
     if(!rc)
       {
 	if(personal)
 	  {
 	    if(personal==PREFTYPE_SYM)
 	      {
 		xfree (opt.personal_cipher_prefs);
 
 		if(nsym==0)
 		  opt.personal_cipher_prefs=NULL;
 		else
 		  {
 		    int i;
 
 		    opt.personal_cipher_prefs=
 		      xmalloc (sizeof(prefitem_t *)*(nsym+1));
 
 		    for (i=0; i<nsym; i++)
 		      {
 			opt.personal_cipher_prefs[i].type = PREFTYPE_SYM;
 			opt.personal_cipher_prefs[i].value = sym[i];
 		      }
 
 		    opt.personal_cipher_prefs[i].type = PREFTYPE_NONE;
 		    opt.personal_cipher_prefs[i].value = 0;
 		  }
 	      }
 	    else if(personal==PREFTYPE_HASH)
 	      {
 		xfree (opt.personal_digest_prefs);
 
 		if(nhash==0)
 		  opt.personal_digest_prefs=NULL;
 		else
 		  {
 		    int i;
 
 		    opt.personal_digest_prefs=
 		      xmalloc (sizeof(prefitem_t *)*(nhash+1));
 
 		    for (i=0; i<nhash; i++)
 		      {
 			opt.personal_digest_prefs[i].type = PREFTYPE_HASH;
 			opt.personal_digest_prefs[i].value = hash[i];
 		      }
 
 		    opt.personal_digest_prefs[i].type = PREFTYPE_NONE;
 		    opt.personal_digest_prefs[i].value = 0;
 		  }
 	      }
 	    else if(personal==PREFTYPE_ZIP)
 	      {
 		xfree (opt.personal_compress_prefs);
 
 		if(nzip==0)
 		  opt.personal_compress_prefs=NULL;
 		else
 		  {
 		    int i;
 
 		    opt.personal_compress_prefs=
 		      xmalloc (sizeof(prefitem_t *)*(nzip+1));
 
 		    for (i=0; i<nzip; i++)
 		      {
 			opt.personal_compress_prefs[i].type = PREFTYPE_ZIP;
 			opt.personal_compress_prefs[i].value = zip[i];
 		      }
 
 		    opt.personal_compress_prefs[i].type = PREFTYPE_NONE;
 		    opt.personal_compress_prefs[i].value = 0;
 		  }
 	      }
 	  }
 	else
 	  {
 	    memcpy (sym_prefs,  sym,  (nsym_prefs=nsym));
 	    memcpy (hash_prefs, hash, (nhash_prefs=nhash));
 	    memcpy (zip_prefs,  zip,  (nzip_prefs=nzip));
 	    mdc_available = mdc;
 	    ks_modify = modify;
 	    prefs_initialized = 1;
 	  }
       }
 
     return rc;
 }
 
 #undef CAST5
 #undef AES
 
 /* Return a fake user ID containing the preferences.  Caller must
    free. */
 PKT_user_id *keygen_get_std_prefs(void)
 {
   int i,j=0;
   PKT_user_id *uid=xcalloc (1,sizeof(PKT_user_id));
 
   if(!prefs_initialized)
     keygen_set_std_prefs(NULL,0);
 
   uid->prefs=xmalloc ((sizeof(prefitem_t *)*
 		      (nsym_prefs+nhash_prefs+nzip_prefs+1)));
 
   for(i=0;i<nsym_prefs;i++,j++)
     {
       uid->prefs[j].type=PREFTYPE_SYM;
       uid->prefs[j].value=sym_prefs[i];
     }
 
   for(i=0;i<nhash_prefs;i++,j++)
     {
       uid->prefs[j].type=PREFTYPE_HASH;
       uid->prefs[j].value=hash_prefs[i];
     }
 
   for(i=0;i<nzip_prefs;i++,j++)
     {
       uid->prefs[j].type=PREFTYPE_ZIP;
       uid->prefs[j].value=zip_prefs[i];
     }
 
   uid->prefs[j].type=PREFTYPE_NONE;
   uid->prefs[j].value=0;
 
   uid->mdc_feature=mdc_available;
   uid->ks_modify=ks_modify;
 
   return uid;
 }
 
 static void
 add_feature_mdc (PKT_signature *sig,int enabled)
 {
     const byte *s;
     size_t n;
     int i;
     char *buf;
 
     s = parse_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES, &n );
     /* Already set or cleared */
     if (s && n &&
 	((enabled && (s[0] & 0x01)) || (!enabled && !(s[0] & 0x01))))
       return;
 
     if (!s || !n) { /* create a new one */
         n = 1;
         buf = xcalloc (1,n);
     }
     else {
         buf = xmalloc (n);
         memcpy (buf, s, n);
     }
 
     if(enabled)
       buf[0] |= 0x01; /* MDC feature */
     else
       buf[0] &= ~0x01;
 
     /* Are there any bits set? */
     for(i=0;i<n;i++)
       if(buf[i]!=0)
 	break;
 
     if(i==n)
       delete_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES);
     else
       build_sig_subpkt (sig, SIGSUBPKT_FEATURES, buf, n);
 
     xfree (buf);
 }
 
 static void
 add_keyserver_modify (PKT_signature *sig,int enabled)
 {
   const byte *s;
   size_t n;
   int i;
   char *buf;
 
   /* The keyserver modify flag is a negative flag (i.e. no-modify) */
   enabled=!enabled;
 
   s = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KS_FLAGS, &n );
   /* Already set or cleared */
   if (s && n &&
       ((enabled && (s[0] & 0x80)) || (!enabled && !(s[0] & 0x80))))
     return;
 
   if (!s || !n) { /* create a new one */
     n = 1;
     buf = xcalloc (1,n);
   }
   else {
     buf = xmalloc (n);
     memcpy (buf, s, n);
   }
 
   if(enabled)
     buf[0] |= 0x80; /* no-modify flag */
   else
     buf[0] &= ~0x80;
 
   /* Are there any bits set? */
   for(i=0;i<n;i++)
     if(buf[i]!=0)
       break;
 
   if(i==n)
     delete_sig_subpkt (sig->hashed, SIGSUBPKT_KS_FLAGS);
   else
     build_sig_subpkt (sig, SIGSUBPKT_KS_FLAGS, buf, n);
 
   xfree (buf);
 }
 
 int
 keygen_upd_std_prefs( PKT_signature *sig, void *opaque )
 {
     if (!prefs_initialized)
         keygen_set_std_prefs (NULL, 0);
 
     if (nsym_prefs) 
         build_sig_subpkt (sig, SIGSUBPKT_PREF_SYM, sym_prefs, nsym_prefs);
     else
       {
         delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_SYM);
         delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_SYM);
       }
 
     if (nhash_prefs)
         build_sig_subpkt (sig, SIGSUBPKT_PREF_HASH, hash_prefs, nhash_prefs);
     else
       {
 	delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_HASH);
 	delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_HASH);
       }
 
     if (nzip_prefs)
         build_sig_subpkt (sig, SIGSUBPKT_PREF_COMPR, zip_prefs, nzip_prefs);
     else
       {
         delete_sig_subpkt (sig->hashed, SIGSUBPKT_PREF_COMPR);
         delete_sig_subpkt (sig->unhashed, SIGSUBPKT_PREF_COMPR);
       }
 
     /* Make sure that the MDC feature flag is set if needed */
     add_feature_mdc (sig,mdc_available);
     add_keyserver_modify (sig,ks_modify);
 
     return 0;
 }
 
 
 /****************
  * Add preference to the self signature packet.
  * This is only called for packets with version > 3.
 
  */
 int
 keygen_add_std_prefs( PKT_signature *sig, void *opaque )
 {
     PKT_public_key *pk = opaque;
 
     do_add_key_flags (sig, pk->pubkey_usage);
     keygen_add_key_expire( sig, opaque );
     keygen_upd_std_prefs (sig, opaque);
 
     return 0;
 }
 
 int
 keygen_add_revkey(PKT_signature *sig, void *opaque)
 {
   struct revocation_key *revkey=opaque;
   byte buf[2+MAX_FINGERPRINT_LEN];
 
   buf[0]=revkey->class;
   buf[1]=revkey->algid;
   memcpy(&buf[2],revkey->fpr,MAX_FINGERPRINT_LEN);
 
   build_sig_subpkt(sig,SIGSUBPKT_REV_KEY,buf,2+MAX_FINGERPRINT_LEN);
 
   /* All sigs with revocation keys set are nonrevocable */
   sig->flags.revocable=0;
   buf[0] = 0;
   build_sig_subpkt( sig, SIGSUBPKT_REVOCABLE, buf, 1 );
 
   parse_revkeys(sig);
 
   return 0;
 }
 
 static int
 write_direct_sig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
 		  struct revocation_key *revkey )
 {
     PACKET *pkt;
     PKT_signature *sig;
     int rc=0;
     KBNODE node;
     PKT_public_key *pk;
 
     if( opt.verbose )
 	log_info(_("writing direct signature\n"));
 
     /* get the pk packet from the pub_tree */
     node = find_kbnode( pub_root, PKT_PUBLIC_KEY );
     if( !node )
 	BUG();
     pk = node->pkt->pkt.public_key;
 
     /* we have to cache the key, so that the verification of the signature
      * creation is able to retrieve the public key */
     cache_public_key (pk);
 
     /* and make the signature */
     rc = make_keysig_packet(&sig,pk,NULL,NULL,sk,0x1F,0,0,0,0,
 			    keygen_add_revkey,revkey);
     if( rc ) {
 	log_error("make_keysig_packet failed: %s\n", gpg_strerror (rc) );
 	return rc;
     }
 
     pkt = xcalloc (1, sizeof *pkt );
     pkt->pkttype = PKT_SIGNATURE;
     pkt->pkt.signature = sig;
     add_kbnode( root, new_kbnode( pkt ) );
     return rc;
 }
 
 static int
 write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
                unsigned int use )
 {
     PACKET *pkt;
     PKT_signature *sig;
     PKT_user_id *uid;
     int rc=0;
     KBNODE node;
     PKT_public_key *pk;
 
     if( opt.verbose )
 	log_info(_("writing self signature\n"));
 
     /* get the uid packet from the list */
     node = find_kbnode( root, PKT_USER_ID );
     if( !node )
 	BUG(); /* no user id packet in tree */
     uid = node->pkt->pkt.user_id;
     /* get the pk packet from the pub_tree */
     node = find_kbnode( pub_root, PKT_PUBLIC_KEY );
     if( !node )
 	BUG();
     pk = node->pkt->pkt.public_key;
     pk->pubkey_usage = use;
     /* we have to cache the key, so that the verification of the signature
      * creation is able to retrieve the public key */
     cache_public_key (pk);
 
     /* and make the signature */
     rc = make_keysig_packet( &sig, pk, uid, NULL, sk, 0x13, 0, 0, 0, 0,
         		     keygen_add_std_prefs, pk );
     if( rc ) {
 	log_error("make_keysig_packet failed: %s\n", gpg_strerror (rc) );
 	return rc;
     }
 
     pkt = xcalloc (1, sizeof *pkt );
     pkt->pkttype = PKT_SIGNATURE;
     pkt->pkt.signature = sig;
     add_kbnode( root, new_kbnode( pkt ) );
     return rc;
 }
 
 static int
 write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
                   unsigned int use )
 {
     PACKET *pkt;
     PKT_signature *sig;
     int rc=0;
     KBNODE node;
     PKT_public_key *pk, *subpk;
     struct opaque_data_usage_and_pk oduap;
 
     if( opt.verbose )
 	log_info(_("writing key binding signature\n"));
 
     /* get the pk packet from the pub_tree */
     node = find_kbnode( pub_root, PKT_PUBLIC_KEY );
     if( !node )
 	BUG();
     pk = node->pkt->pkt.public_key;
     /* we have to cache the key, so that the verification of the signature
      * creation is able to retrieve the public key */
     cache_public_key (pk);
  
     /* find the last subkey */
     subpk = NULL;
     for(node=pub_root; node; node = node->next ) {
 	if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
 	    subpk = node->pkt->pkt.public_key;
     }
     if( !subpk )
 	BUG();
 
     /* and make the signature */
     oduap.usage = use;
     oduap.pk = subpk;
     rc = make_keysig_packet( &sig, pk, NULL, subpk, sk, 0x18, 0, 0, 0, 0,
         		     keygen_add_key_flags_and_expire, &oduap );
     if( rc ) {
 	log_error("make_keysig_packet failed: %s\n", gpg_strerror (rc) );
 	return rc;
     }
 
     pkt = xcalloc (1, sizeof *pkt );
     pkt->pkttype = PKT_SIGNATURE;
     pkt->pkt.signature = sig;
     add_kbnode( root, new_kbnode( pkt ) );
     return rc;
 }
 
 
 static int
-gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
-	STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval )
+key_from_sexp (gcry_mpi_t *array, gcry_sexp_t sexp,
+               const char *topname, const char *elems)
 {
-    int rc;
-    int i;
-    PACKET *pkt;
-    PKT_secret_key *sk;
-    PKT_public_key *pk;
-    gcry_mpi_t skey[4];
-    gcry_mpi_t *factors;
+  gcry_sexp_t list, l2;
+  const char *s;
+  int i, idx;
+  int rc = 0;
+
+  list = gcry_sexp_find_token (sexp, topname, 0);
+  if (!list)
+    return gpg_error (GPG_ERR_INV_OBJ);
+  l2 = gcry_sexp_cadr (list);
+  gcry_sexp_release (list);
+  list = l2;
+  if (!list)
+    return gpg_error (GPG_ERR_NO_OBJ);
+
+  for (idx=0,s=elems; *s; s++, idx++)
+    {
+      l2 = gcry_sexp_find_token (list, s, 1);
+      if (!l2)
+        {
+          rc = gpg_error (GPG_ERR_NO_OBJ); /* required parameter not found */
+          goto leave;
+        }
+      array[idx] = gcry_sexp_nth_mpi (l2, 1, GCRYMPI_FMT_USG);
+      gcry_sexp_release (l2);
+      if (!array[idx]) 
+        {
+          rc = gpg_error (GPG_ERR_INV_OBJ); /* required parameter invalid */
+          goto leave;
+        }
+    }
+  gcry_sexp_release (list);
+
+ leave:
+  if (rc)
+    {
+      for (i=0; i<idx; i++)
+        {
+          xfree (array[i]);
+          array[i] = NULL;
+        }
+      gcry_sexp_release (list);
+    }
+  return rc;
+}
 
-    assert( is_ELGAMAL(algo) );
 
-    if( nbits < 512 ) {
-	nbits = 1024;
-	log_info(_("keysize invalid; using %u bits\n"), nbits );
+static int
+genhelp_protect (DEK *dek, STRING2KEY *s2k, PKT_secret_key *sk)
+{
+  int rc = 0;
+
+  if (dek)
+    {
+      sk->protect.algo = dek->algo;
+      sk->protect.s2k = *s2k;
+      rc = protect_secret_key (sk, dek);
+      if (rc)
+        log_error ("protect_secret_key failed: %s\n", gpg_strerror (rc) );
     }
 
-    if( (nbits % 32) ) {
-	nbits = ((nbits + 31) / 32) * 32;
-	log_info(_("keysize rounded up to %u bits\n"), nbits );
+  return rc;
+}
+
+static void
+genhelp_factors (gcry_sexp_t misc_key_info, KBNODE sec_root)
+{
+  size_t n;
+  char *buf;
+  
+  if (misc_key_info)
+    {
+      /* DSA: don't know whether it makes sense to have the factors, so for now
+         we store them in the secret keyring (but they are not secret)
+         p = 2 * q * f1 * f2 * ... * fn
+         We store only f1 to f_n-1;  fn can be calculated because p and q
+         are known. */
+      n = gcry_sexp_sprint (misc_key_info, 0, NULL, 0);
+      buf = xmalloc (n+4);
+      strcpy (buf, "#::");
+      n = gcry_sexp_sprint (misc_key_info, 0, buf+3, n);
+      if (n)
+        {
+          n += 3;
+          add_kbnode (sec_root, make_comment_node_from_buffer (buf, n));
+        }
+      xfree (buf);
+      gcry_sexp_release (misc_key_info);
     }
+}
 
-#warning need to implement this
-    rc = -1 /*pubkey_generate( algo, nbits, skey, &factors )*/;
-    if( rc ) {
-	log_error("pubkey_generate failed: %s\n", gpg_strerror (rc) );
-	return rc;
+
+static int
+gen_elg(int algo, unsigned int nbits,
+        KBNODE pub_root, KBNODE sec_root, DEK *dek,
+	STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval )
+{
+  int rc;
+  PACKET *pkt;
+  PKT_secret_key *sk;
+  PKT_public_key *pk;
+  gcry_sexp_t s_parms, s_key;
+  gcry_sexp_t misc_key_info;
+  
+  assert (is_ELGAMAL(algo));
+
+  if (nbits < 512)
+    {
+      nbits = 1024;
+      log_info (_("keysize invalid; using %u bits\n"), nbits);
     }
 
-    sk = xcalloc (1, sizeof *sk );
-    pk = xcalloc (1, sizeof *pk );
-    sk->timestamp = pk->timestamp = make_timestamp();
-    sk->version = pk->version = 4;
-    if( expireval ) {
-	sk->expiredate = pk->expiredate = sk->timestamp + expireval;
-    }
-    sk->pubkey_algo = pk->pubkey_algo = algo;
-		       pk->pkey[0] = mpi_copy( skey[0] );
-		       pk->pkey[1] = mpi_copy( skey[1] );
-		       pk->pkey[2] = mpi_copy( skey[2] );
-    sk->skey[0] = skey[0];
-    sk->skey[1] = skey[1];
-    sk->skey[2] = skey[2];
-    sk->skey[3] = skey[3];
-    sk->is_protected = 0;
-    sk->protect.algo = 0;
-
-    sk->csum = checksum_mpi( sk->skey[3] );
-    if( ret_sk ) /* not a subkey: return an unprotected version of the sk */
-	*ret_sk = copy_secret_key( NULL, sk );
-
-    if( dek ) {
-	sk->protect.algo = dek->algo;
-	sk->protect.s2k = *s2k;
-	rc = protect_secret_key( sk, dek );
-	if( rc ) {
-	    log_error("protect_secret_key failed: %s\n", gpg_strerror (rc) );
-	    free_public_key(pk);
-	    free_secret_key(sk);
-	    return rc;
-	}
+  if ((nbits % 32))
+    {
+      nbits = ((nbits + 31) / 32) * 32;
+      log_info (_("keysize rounded up to %u bits\n"), nbits);
+    }
+
+  rc = gcry_sexp_build ( &s_parms, NULL,
+                         "(genkey(%s(nbits %d)))",
+                         algo == GCRY_PK_ELG_E ? "openpgp-elg" :
+                         algo == GCRY_PK_ELG	 ? "elg" : "x-oops" ,
+                         (int)nbits);
+  if (rc)
+    log_bug ("gcry_sexp_build failed: %s\n", gpg_strerror (rc));
+  
+  rc = gcry_pk_genkey (&s_key, s_parms);
+  gcry_sexp_release (s_parms);
+  if (rc)
+    {
+      log_error ("gcry_pk_genkey failed: %s\n", gpg_strerror (rc) );
+      return rc;
     }
 
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
-    pkt->pkt.public_key = pk;
-    add_kbnode(pub_root, new_kbnode( pkt ));
+  sk = xcalloc (1, sizeof *sk);
+  pk = xcalloc (1, sizeof *pk);
+  sk->timestamp = pk->timestamp = make_timestamp();
+  sk->version = pk->version = 4;
+  if (expireval)
+    sk->expiredate = pk->expiredate = sk->timestamp + expireval;
+  sk->pubkey_algo = pk->pubkey_algo = algo;
 
-    /* don't know whether it makes sense to have the factors, so for now
-     * we store them in the secret keyring (but they are not secret) */
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
-    pkt->pkt.secret_key = sk;
-    add_kbnode(sec_root, new_kbnode( pkt ));
-    for(i=0; factors[i]; i++ )
-	add_kbnode( sec_root,
-		    make_mpi_comment_node("#:ELG_factor:", factors[i] ));
+  rc = key_from_sexp (pk->pkey, s_key, "public-key", "pgy");
+  if (rc) 
+    {
+      log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc) );
+      gcry_sexp_release (s_key);
+      return rc;
+    }
+  rc = key_from_sexp (sk->skey, s_key, "private-key", "pgyx");
+  if (rc)
+    {
+      log_error("key_from_sexp failed: %s\n", gpg_strerror (rc) );
+      gcry_sexp_release (s_key);
+      return rc;
+    }
+  misc_key_info = gcry_sexp_find_token (s_key, "misc-key-info", 0);
+  gcry_sexp_release (s_key);
 
-    return 0;
+  sk->is_protected = 0;
+  sk->protect.algo = 0;
+
+  sk->csum = checksum_mpi (sk->skey[3]);
+  if (ret_sk) /* not a subkey: return an unprotected version of the sk */
+    *ret_sk = copy_secret_key (NULL, sk);
+
+  rc = genhelp_protect (dek, s2k, sk);
+  if (rc)
+    {
+      free_public_key (pk);
+      free_secret_key (sk);
+      gcry_sexp_release (misc_key_info);
+      return rc;
+    }
+
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
+  pkt->pkt.public_key = pk;
+  add_kbnode(pub_root, new_kbnode( pkt ));
+  
+  /* don't know whether it makes sense to have the factors, so for now
+   * we store them in the secret keyring (but they are not secret) */
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
+  pkt->pkt.secret_key = sk;
+  add_kbnode(sec_root, new_kbnode( pkt ));
+  
+  genhelp_factors (misc_key_info, sec_root);
+  
+  return 0;
 }
 
 
 /****************
  * Generate a DSA key
  */
 static int
-gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
-	    STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval )
+gen_dsa (unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
+         STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval )
 {
-    int rc;
-    int i;
-    PACKET *pkt;
-    PKT_secret_key *sk;
-    PKT_public_key *pk;
-    gcry_mpi_t skey[5];
-    gcry_mpi_t *factors;
+  int rc;
+  PACKET *pkt;
+  PKT_secret_key *sk;
+  PKT_public_key *pk;
+  gcry_sexp_t s_parms, s_key;
+  gcry_sexp_t misc_key_info;
 
-    if( nbits > 1024 || nbits < 512 ) {
-	nbits = 1024;
-	log_info(_("keysize invalid; using %u bits\n"), nbits );
+  if (nbits > 1024 || nbits < 512)
+    {
+      nbits = 1024;
+      log_info(_("keysize invalid; using %u bits\n"), nbits);
     }
 
-    if( (nbits % 64) ) {
-	nbits = ((nbits + 63) / 64) * 64;
-	log_info(_("keysize rounded up to %u bits\n"), nbits );
+  if ((nbits % 64))
+    {
+      nbits = ((nbits + 63) / 64) * 64;
+      log_info (_("keysize rounded up to %u bits\n"), nbits);
     }
 
-#warning need to implement this
-    rc = -1 /*pubkey_generate( PUBKEY_ALGO_DSA, nbits, skey, &factors )*/;
-    if( rc ) {
-	log_error("pubkey_generate failed: %s\n", gpg_strerror (rc) );
-	return rc;
+  rc = gcry_sexp_build (&s_parms, NULL,
+                        "(genkey(dsa(nbits %d)))",
+                        (int)nbits);
+  if (rc)
+    log_bug ("gcry_sexp_build failed: %s\n", gpg_strerror (rc));
+  
+  rc = gcry_pk_genkey (&s_key, s_parms);
+  gcry_sexp_release (s_parms);
+  if (rc)
+    {
+      log_error ("gcry_pk_genkey failed: %s\n", gpg_strerror (rc) );
+      return rc;
     }
 
-    sk = xcalloc (1, sizeof *sk );
-    pk = xcalloc (1, sizeof *pk );
-    sk->timestamp = pk->timestamp = make_timestamp();
-    sk->version = pk->version = 4;
-    if( expireval ) {
-	sk->expiredate = pk->expiredate = sk->timestamp + expireval;
-    }
-    sk->pubkey_algo = pk->pubkey_algo = PUBKEY_ALGO_DSA;
-		       pk->pkey[0] = mpi_copy( skey[0] );
-		       pk->pkey[1] = mpi_copy( skey[1] );
-		       pk->pkey[2] = mpi_copy( skey[2] );
-		       pk->pkey[3] = mpi_copy( skey[3] );
-    sk->skey[0] = skey[0];
-    sk->skey[1] = skey[1];
-    sk->skey[2] = skey[2];
-    sk->skey[3] = skey[3];
-    sk->skey[4] = skey[4];
-    sk->is_protected = 0;
-    sk->protect.algo = 0;
-
-    sk->csum = checksum_mpi ( sk->skey[4] );
-    if( ret_sk ) /* not a subkey: return an unprotected version of the sk */
-	*ret_sk = copy_secret_key( NULL, sk );
-
-    if( dek ) {
-	sk->protect.algo = dek->algo;
-	sk->protect.s2k = *s2k;
-	rc = protect_secret_key( sk, dek );
-	if( rc ) {
-	    log_error("protect_secret_key failed: %s\n", gpg_strerror (rc) );
-	    free_public_key(pk);
-	    free_secret_key(sk);
-	    return rc;
-	}
+  sk = xcalloc (1, sizeof *sk );
+  pk = xcalloc (1, sizeof *pk );
+  sk->timestamp = pk->timestamp = make_timestamp();
+  sk->version = pk->version = 4;
+  if (expireval) 
+    sk->expiredate = pk->expiredate = sk->timestamp + expireval;
+  sk->pubkey_algo = pk->pubkey_algo = PUBKEY_ALGO_DSA;
+
+  rc = key_from_sexp (pk->pkey, s_key, "public-key", "pqgy");
+  if (rc) 
+    {
+      log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc));
+      gcry_sexp_release (s_key);
+      return rc;
     }
+  rc = key_from_sexp (sk->skey, s_key, "private-key", "pqgyx");
+  if (rc) 
+    {
+      log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc) );
+      gcry_sexp_release (s_key);
+      return rc;
+    }
+  misc_key_info = gcry_sexp_find_token (s_key, "misc-key-info", 0);
+  gcry_sexp_release (s_key);
 
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
-    pkt->pkt.public_key = pk;
-    add_kbnode(pub_root, new_kbnode( pkt ));
-
-    /* don't know whether it makes sense to have the factors, so for now
-     * we store them in the secret keyring (but they are not secret)
-     * p = 2 * q * f1 * f2 * ... * fn
-     * We store only f1 to f_n-1;  fn can be calculated because p and q
-     * are known.
-     */
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
-    pkt->pkt.secret_key = sk;
-    add_kbnode(sec_root, new_kbnode( pkt ));
-    for(i=1; factors[i]; i++ )	/* the first one is q */
-	add_kbnode( sec_root,
-		    make_mpi_comment_node("#:DSA_factor:", factors[i] ));
+  sk->is_protected = 0;
+  sk->protect.algo = 0;
 
-    return 0;
+  sk->csum = checksum_mpi ( sk->skey[4] );
+  if (ret_sk) /* not a subkey: return an unprotected version of the sk */
+    *ret_sk = copy_secret_key( NULL, sk );
+
+  rc = genhelp_protect (dek, s2k, sk);
+  if (rc)
+    {
+      free_public_key (pk);
+      free_secret_key (sk);
+      gcry_sexp_release (misc_key_info);
+      return rc;
+    }
+
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
+  pkt->pkt.public_key = pk;
+  add_kbnode(pub_root, new_kbnode( pkt ));
+
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
+  pkt->pkt.secret_key = sk;
+  add_kbnode(sec_root, new_kbnode( pkt ));
+
+  genhelp_factors (misc_key_info, sec_root);
+
+  return 0;
 }
 
 
 /* 
  * Generate an RSA key.
  */
 static int
 gen_rsa(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
 	STRING2KEY *s2k, PKT_secret_key **ret_sk, u32 expireval )
 {
-    int rc;
-    PACKET *pkt;
-    PKT_secret_key *sk;
-    PKT_public_key *pk;
-    gcry_mpi_t skey[6];
-    gcry_mpi_t *factors;
+  int rc;
+  PACKET *pkt;
+  PKT_secret_key *sk;
+  PKT_public_key *pk;
+  gcry_sexp_t s_parms, s_key;
 
-    assert( is_RSA(algo) );
+  assert (is_RSA(algo));
 
-    if( nbits < 1024 ) {
-	nbits = 1024;
-	log_info(_("keysize invalid; using %u bits\n"), nbits );
+  if (nbits < 1024)
+    {
+      nbits = 1024;
+      log_info(_("keysize invalid; using %u bits\n"), nbits);
     }
 
-    if( (nbits % 32) ) {
-	nbits = ((nbits + 31) / 32) * 32;
-	log_info(_("keysize rounded up to %u bits\n"), nbits );
+  if ((nbits % 32))
+    {
+      nbits = ((nbits + 31) / 32) * 32;
+      log_info (_("keysize rounded up to %u bits\n"), nbits);
     }
 
-#warning need to implement this
-    rc = -1 /*pubkey_generate( algo, nbits, skey, &factors )*/;
-    if( rc ) {
-	log_error("pubkey_generate failed: %s\n", gpg_strerror (rc) );
-	return rc;
+  rc = gcry_sexp_build (&s_parms, NULL,
+                        "(genkey(rsa(nbits %d)))",
+                        (int)nbits);
+  if (rc)
+    log_bug ("gcry_sexp_build failed: %s\n", gpg_strerror (rc));
+  
+  rc = gcry_pk_genkey (&s_key, s_parms);
+  gcry_sexp_release (s_parms);
+  if (rc)
+    {
+      log_error ("gcry_pk_genkey failed: %s\n", gpg_strerror (rc) );
+      return rc;
     }
 
-    sk = xcalloc (1, sizeof *sk );
-    pk = xcalloc (1, sizeof *pk );
-    sk->timestamp = pk->timestamp = make_timestamp();
-    sk->version = pk->version = 4;
-    if( expireval ) {
-	sk->expiredate = pk->expiredate = sk->timestamp + expireval;
-    }
-    sk->pubkey_algo = pk->pubkey_algo = algo;
-		       pk->pkey[0] = mpi_copy( skey[0] );
-		       pk->pkey[1] = mpi_copy( skey[1] );
-    sk->skey[0] = skey[0];
-    sk->skey[1] = skey[1];
-    sk->skey[2] = skey[2];
-    sk->skey[3] = skey[3];
-    sk->skey[4] = skey[4];
-    sk->skey[5] = skey[5];
-    sk->is_protected = 0;
-    sk->protect.algo = 0;
-
-    sk->csum  = checksum_mpi (sk->skey[2] );
-    sk->csum += checksum_mpi (sk->skey[3] );
-    sk->csum += checksum_mpi (sk->skey[4] );
-    sk->csum += checksum_mpi (sk->skey[5] );
-    if( ret_sk ) /* not a subkey: return an unprotected version of the sk */
-	*ret_sk = copy_secret_key( NULL, sk );
-
-    if( dek ) {
-	sk->protect.algo = dek->algo;
-	sk->protect.s2k = *s2k;
-	rc = protect_secret_key( sk, dek );
-	if( rc ) {
-	    log_error("protect_secret_key failed: %s\n", gpg_strerror (rc) );
-	    free_public_key(pk);
-	    free_secret_key(sk);
-	    return rc;
-	}
+  sk = xcalloc (1, sizeof *sk );
+  pk = xcalloc (1, sizeof *pk );
+  sk->timestamp = pk->timestamp = make_timestamp();
+  sk->version = pk->version = 4;
+  if (expireval) 
+    sk->expiredate = pk->expiredate = sk->timestamp + expireval;
+  sk->pubkey_algo = pk->pubkey_algo = algo;
+
+  rc = key_from_sexp (pk->pkey, s_key, "public-key", "ne");
+  if (rc) 
+    {
+      log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc));
+      gcry_sexp_release (s_key);
+      return rc;
+    }
+  rc = key_from_sexp (sk->skey, s_key, "private-key", "nedpqu");
+  if (rc) 
+    {
+      log_error ("key_from_sexp failed: %s\n", gpg_strerror (rc) );
+      gcry_sexp_release (s_key);
+      return rc;
     }
+  gcry_sexp_release (s_key);
 
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
-    pkt->pkt.public_key = pk;
-    add_kbnode(pub_root, new_kbnode( pkt ));
+  sk->is_protected = 0;
+  sk->protect.algo = 0;
 
-    pkt = xcalloc (1,sizeof *pkt);
-    pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
-    pkt->pkt.secret_key = sk;
-    add_kbnode(sec_root, new_kbnode( pkt ));
+  sk->csum  = checksum_mpi (sk->skey[2] );
+  sk->csum += checksum_mpi (sk->skey[3] );
+  sk->csum += checksum_mpi (sk->skey[4] );
+  sk->csum += checksum_mpi (sk->skey[5] );
+  if (ret_sk) /* not a subkey: return an unprotected version of the sk */
+    *ret_sk = copy_secret_key (NULL, sk);
 
-    return 0;
+  rc = genhelp_protect (dek, s2k, sk);
+  if (rc)
+    {
+      free_public_key (pk);
+      free_secret_key (sk);
+      return rc;
+    }
+
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
+  pkt->pkt.public_key = pk;
+  add_kbnode (pub_root, new_kbnode( pkt ));
+
+  pkt = xcalloc (1,sizeof *pkt);
+  pkt->pkttype = ret_sk ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
+  pkt->pkt.secret_key = sk;
+  add_kbnode(sec_root, new_kbnode( pkt ));
+
+  return 0;
 }
 
 
 /****************
  * check valid days:
  * return 0 on error or the multiplier
  */
 static int
 check_valid_days( const char *s )
 {
     if( !isdigit(*s) )
 	return 0;
     for( s++; *s; s++)
 	if( !isdigit(*s) )
 	    break;
     if( !*s )
 	return 1;
     if( s[1] )
 	return 0; /* e.g. "2323wc" */
     if( *s == 'd' || *s == 'D' )
 	return 1;
     if( *s == 'w' || *s == 'W' )
 	return 7;
     if( *s == 'm' || *s == 'M' )
 	return 30;
     if( *s == 'y' || *s == 'Y' )
 	return 365;
     return 0;
 }
 
 
 /****************
  * Returns: 0 to create both a DSA and a ElGamal key.
  *          and only if key flags are to be written the desired usage.
  */
 static int
 ask_algo (int addmode, unsigned int *r_usage)
 {
     char *answer;
     int algo;
 
     *r_usage = 0;
     tty_printf(_("Please select what kind of key you want:\n"));
     if( !addmode )
 	tty_printf(_("   (%d) DSA and ElGamal (default)\n"), 1 );
     tty_printf(    _("   (%d) DSA (sign only)\n"), 2 );
     if( addmode )
 	tty_printf(    _("   (%d) ElGamal (encrypt only)\n"), 3 );
     if (opt.expert)
         tty_printf(    _("   (%d) ElGamal (sign and encrypt)\n"), 4 );
     tty_printf(    _("   (%d) RSA (sign only)\n"), 5 );
     if (addmode)
         tty_printf(    _("   (%d) RSA (encrypt only)\n"), 6 );
     if (opt.expert)
       tty_printf(    _("   (%d) RSA (sign and encrypt)\n"), 7 );
 
     for(;;) {
 	answer = cpr_get("keygen.algo",_("Your selection? "));
 	cpr_kill_prompt();
 	algo = *answer? atoi(answer): 1;
 	xfree (answer);
 	if( algo == 1 && !addmode ) {
 	    algo = 0;	/* create both keys */
 	    break;
 	}
 	else if( algo == 7 && opt.expert ) {
 	    algo = PUBKEY_ALGO_RSA;
 	    *r_usage = PUBKEY_USAGE_ENC | PUBKEY_USAGE_SIG;
 	    break;
 	}
 	else if( algo == 6 && addmode ) {
 	    algo = PUBKEY_ALGO_RSA;
             *r_usage = PUBKEY_USAGE_ENC;
 	    break;
 	}
 	else if( algo == 5 ) {
 	    algo = PUBKEY_ALGO_RSA;
             *r_usage = PUBKEY_USAGE_SIG;
 	    break;
 	}
 	else if( algo == 4 && opt.expert)
 	  {
 	    tty_printf(_(
 "The use of this algorithm is only supported by GnuPG.  You will not be\n"
 "able to use this key to communicate with PGP users.  This algorithm is also\n"
 "very slow, and may not be as secure as the other choices.\n"));
 
 	    if( cpr_get_answer_is_yes("keygen.algo.elg_se",
 				      _("Create anyway? ")))
 	      {
 		algo = PUBKEY_ALGO_ELGAMAL;
 		break;
 	      }
 	}
 	else if( algo == 3 && addmode ) {
 	    algo = PUBKEY_ALGO_ELGAMAL_E;
 	    break;
 	}
 	else if( algo == 2 ) {
 	    algo = PUBKEY_ALGO_DSA;
 	    break;
 	}
 	else
 	    tty_printf(_("Invalid selection.\n"));
     }
     return algo;
 }
 
 
 static unsigned
 ask_keysize( int algo )
 {
     char *answer;
     unsigned nbits;
 
     if (algo != PUBKEY_ALGO_DSA && algo != PUBKEY_ALGO_RSA) {
         tty_printf (_("About to generate a new %s keypair.\n"
                       "              minimum keysize is  768 bits\n"
                       "              default keysize is 1024 bits\n"
                       "    highest suggested keysize is 2048 bits\n"),
                     gcry_pk_algo_name (algo) );
     }
 
     for(;;) {
 	answer = cpr_get("keygen.size",
 			  _("What keysize do you want? (1024) "));
 	cpr_kill_prompt();
 	nbits = *answer? atoi(answer): 1024;
 	xfree (answer);
 	if( algo == PUBKEY_ALGO_DSA && (nbits < 512 || nbits > 1024) )
 	    tty_printf(_("DSA only allows keysizes from 512 to 1024\n"));
 	else if( algo == PUBKEY_ALGO_RSA && nbits < 1024 )
 	    tty_printf(_("keysize too small;"
 			 " 1024 is smallest value allowed for RSA.\n"));
 	else if( nbits < 768 )
 	    tty_printf(_("keysize too small;"
 			 " 768 is smallest value allowed.\n"));
 	else if( nbits > 4096 ) {
 	    /* It is ridiculous and an annoyance to use larger key sizes!
 	     * GnuPG can handle much larger sizes; but it takes an eternity
 	     * to create such a key (but less than the time the Sirius
 	     * Computer Corporation needs to process one of the usual
 	     * complaints) and {de,en}cryption although needs some time.
 	     * So, before you complain about this limitation, I suggest that
 	     * you start a discussion with Marvin about this theme and then
 	     * do whatever you want. */
 	    tty_printf(_("keysize too large; %d is largest value allowed.\n"),
 									 4096);
 	}
 	else if( nbits > 2048 && !cpr_enabled() ) {
 	    tty_printf(
 		_("Keysizes larger than 2048 are not suggested because\n"
 		  "computations take REALLY long!\n"));
 	    if( cpr_get_answer_is_yes("keygen.size.huge.okay",_(
 			"Are you sure that you want this keysize? ")) ) {
 		tty_printf(_("Okay, but keep in mind that your monitor "
 			     "and keyboard radiation is also very vulnerable "
 			     "to attacks!\n"));
 		break;
 	    }
 	}
 	else
 	    break;
     }
     tty_printf(_("Requested keysize is %u bits\n"), nbits );
     if( algo == PUBKEY_ALGO_DSA && (nbits % 64) ) {
 	nbits = ((nbits + 63) / 64) * 64;
 	tty_printf(_("rounded up to %u bits\n"), nbits );
     }
     else if( (nbits % 32) ) {
 	nbits = ((nbits + 31) / 32) * 32;
 	tty_printf(_("rounded up to %u bits\n"), nbits );
     }
     return nbits;
 }
 
 
 /****************
  * Parse an expire string and return it's value in days.
  * Returns -1 on error.
  */
 static int
 parse_expire_string( const char *string )
 {
     int mult;
     u32 abs_date=0;
     u32 curtime = make_timestamp();
     int valid_days;
 
     if( !*string )
 	valid_days = 0;
     else if( (abs_date = scan_isodatestr(string)) && abs_date > curtime ) {
 	/* This calculation is not perfectly okay because we
 	 * are later going to simply multiply by 86400 and don't
 	 * correct for leapseconds.  A solution would be to change
 	 * the whole implemenation to work with dates and not intervals
 	 * which are required for v3 keys.
 	 */
 	valid_days = abs_date/86400-curtime/86400+1;
     }
     else if( (mult=check_valid_days(string)) ) {
 	valid_days = atoi(string) * mult;
 	if( valid_days < 0 || valid_days > 39447 )
 	    valid_days = 0;
     }
     else {
 	valid_days = -1;
     }
     return valid_days;
 }
 
 /* object == 0 for a key, and 1 for a sig */
 u32
 ask_expire_interval(int object)
 {
     char *answer;
     int valid_days=0;
     u32 interval = 0;
 
     switch(object)
       {
       case 0:
 	tty_printf(_("Please specify how long the key should be valid.\n"
 		     "         0 = key does not expire\n"
 		     "      <n>  = key expires in n days\n"
 		     "      <n>w = key expires in n weeks\n"
 		     "      <n>m = key expires in n months\n"
 		     "      <n>y = key expires in n years\n"));
 	break;
 
       case 1:
 	tty_printf(_("Please specify how long the signature should be valid.\n"
 		     "         0 = signature does not expire\n"
 		     "      <n>  = signature expires in n days\n"
 		     "      <n>w = signature expires in n weeks\n"
 		     "      <n>m = signature expires in n months\n"
 		     "      <n>y = signature expires in n years\n"));
 	break;
 
       default:
 	BUG();
       }
 
     /* Note: The elgamal subkey for DSA has no expiration date because
      * it must be signed with the DSA key and this one has the expiration
      * date */
 
     answer = NULL;
     for(;;) {
 	u32 curtime=make_timestamp();
 
 	xfree (answer);
 	if(object==0)
 	  answer = cpr_get("keygen.valid",_("Key is valid for? (0) "));
 	else
 	  answer = cpr_get("siggen.valid",_("Signature is valid for? (0) "));
 	cpr_kill_prompt();
 	trim_spaces(answer);
 	valid_days = parse_expire_string( answer );
 	if( valid_days < 0 ) {
 	    tty_printf(_("invalid value\n"));
 	    continue;
 	}
 
 	if( !valid_days ) {
 	    tty_printf(_("%s does not expire at all\n"),
 		       object==0?"Key":"Signature");
 	    interval = 0;
 	}
 	else {
 	    interval = valid_days * 86400L;
 	    /* print the date when the key expires */
 	    tty_printf(_("%s expires at %s\n"),
 		        object==0?"Key":"Signature",
 			asctimestamp((ulong)(curtime + interval) ) );
-            /* FIXME: This check yields warning on alhas:
-               write a configure check and to this check here only for 32 bit machines */
+            /* FIXME: This check yields warning some machines: write a
+               configure check and do this check here only for 32 bit
+               machines */
 	    if( (time_t)((ulong)(curtime+interval)) < 0 )
 		tty_printf(_("Your system can't display dates beyond 2038.\n"
 		    "However, it will be correctly handled up to 2106.\n"));
 	}
 
 	if( cpr_enabled() || cpr_get_answer_is_yes("keygen.valid.okay",
 					    _("Is this correct (y/n)? ")) )
 	    break;
     }
     xfree (answer);
     return interval;
 }
 
 u32
 ask_expiredate()
 {
     u32 x = ask_expire_interval(0);
     return x? make_timestamp() + x : 0;
 }
 
 
 static int
 count_chr( const char *string, int c )
 {
   int count;
 
   for (count=0; *string; string++ )
     if ( *string == c )
       count++;
   return count;
 }
 
 
 static int
 has_invalid_email_chars( const char *s )
 {
     int at_seen=0;
     static char valid_chars[] = "01234567890_-."
 				"abcdefghijklmnopqrstuvwxyz"
 				"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
     for( ; *s; s++ ) {
 	if( *s & 0x80 )
 	    return 1;
 	if( *s == '@' )
 	    at_seen=1;
 	else if( !at_seen && !( !!strchr( valid_chars, *s ) || *s == '+' ) )
 	    return 1;
 	else if( at_seen && !strchr( valid_chars, *s ) )
 	    return 1;
     }
     return 0;
 }
 
 
 static char *
 ask_user_id( int mode )
 {
     char *answer;
     char *aname, *acomment, *amail, *uid;
 
     if( !mode )
 	tty_printf( _("\n"
 "You need a User-ID to identify your key; the software constructs the user id\n"
 "from Real Name, Comment and Email Address in this form:\n"
 "    \"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>\"\n\n") );
     uid = aname = acomment = amail = NULL;
     for(;;) {
 	char *p;
 	int fail=0;
 
 	if( !aname ) {
 	    for(;;) {
 		xfree (aname);
 		aname = cpr_get("keygen.name",_("Real name: "));
 		trim_spaces(aname);
 		cpr_kill_prompt();
 
 		if( opt.allow_freeform_uid )
 		    break;
 
 		if( strpbrk( aname, "<>" ) )
 		    tty_printf(_("Invalid character in name\n"));
 		else if( isdigit(*aname) )
 		    tty_printf(_("Name may not start with a digit\n"));
 		else if( strlen(aname) < 5 )
 		    tty_printf(_("Name must be at least 5 characters long\n"));
 		else
 		    break;
 	    }
 	}
 	if( !amail ) {
 	    for(;;) {
 		xfree (amail);
 		amail = cpr_get("keygen.email",_("Email address: "));
 		trim_spaces(amail);
 		cpr_kill_prompt();
 		if( !*amail )
 		    break;   /* no email address is okay */
 		else if( has_invalid_email_chars(amail)
 			 || count_chr(amail,'@') != 1
 			 || *amail == '@'
 			 || amail[strlen(amail)-1] == '@'
 			 || amail[strlen(amail)-1] == '.'
 			 || strstr(amail, "..") )
 		    tty_printf(_("Not a valid email address\n"));
 		else
 		    break;
 	    }
 	}
 	if( !acomment ) {
 	    for(;;) {
 		xfree (acomment);
 		acomment = cpr_get("keygen.comment",_("Comment: "));
 		trim_spaces(acomment);
 		cpr_kill_prompt();
 		if( !*acomment )
 		    break;   /* no comment is okay */
 		else if( strpbrk( acomment, "()" ) )
 		    tty_printf(_("Invalid character in comment\n"));
 		else
 		    break;
 	    }
 	}
 
 
 	xfree (uid);
 	uid = p = xmalloc (strlen(aname)+strlen(amail)+strlen(acomment)+12+10);
 	p = stpcpy(p, aname );
 	if( *acomment )
 	    p = stpcpy(stpcpy(stpcpy(p," ("), acomment),")");
 	if( *amail )
 	    p = stpcpy(stpcpy(stpcpy(p," <"), amail),">");
 
 	/* print a note in case that UTF8 mapping has to be done */
 	for(p=uid; *p; p++ ) {
 	    if( *p & 0x80 ) {
 		tty_printf(_("You are using the `%s' character set.\n"),
 			   get_native_charset() );
 		break;
 	    }
 	}
 
 	tty_printf(_("You selected this USER-ID:\n    \"%s\"\n\n"), uid);
 	/* fixme: add a warning if this user-id already exists */
 	if( !*amail && (strchr( aname, '@' ) || strchr( acomment, '@'))) {
 	    fail = 1;
 	    tty_printf(_("Please don't put the email address "
 			  "into the real name or the comment\n") );
 	}
 
 	for(;;) {
 	    const char *ansstr = _("NnCcEeOoQq");
 
 	    if( strlen(ansstr) != 10 )
 		BUG();
 	    if( cpr_enabled() ) {
 		answer = xstrdup (ansstr+6);
 		answer[1] = 0;
 	    }
 	    else {
 		answer = cpr_get("keygen.userid.cmd", fail?
 		  _("Change (N)ame, (C)omment, (E)mail or (Q)uit? ") :
 		  _("Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? "));
 		cpr_kill_prompt();
 	    }
 	    if( strlen(answer) > 1 )
 		;
 	    else if( *answer == ansstr[0] || *answer == ansstr[1] ) {
 		xfree (aname); aname = NULL;
 		break;
 	    }
 	    else if( *answer == ansstr[2] || *answer == ansstr[3] ) {
 		xfree (acomment); acomment = NULL;
 		break;
 	    }
 	    else if( *answer == ansstr[4] || *answer == ansstr[5] ) {
 		xfree (amail); amail = NULL;
 		break;
 	    }
 	    else if( *answer == ansstr[6] || *answer == ansstr[7] ) {
 		if( fail ) {
 		    tty_printf(_("Please correct the error first\n"));
 		}
 		else {
 		    xfree (aname); aname = NULL;
 		    xfree (acomment); acomment = NULL;
 		    xfree (amail); amail = NULL;
 		    break;
 		}
 	    }
 	    else if( *answer == ansstr[8] || *answer == ansstr[9] ) {
 		xfree (aname); aname = NULL;
 		xfree (acomment); acomment = NULL;
 		xfree (amail); amail = NULL;
 		xfree (uid); uid = NULL;
 		break;
 	    }
 	    xfree (answer);
 	}
 	xfree (answer);
 	if( !amail && !acomment && !amail )
 	    break;
 	xfree (uid); uid = NULL;
     }
     if( uid ) {
 	char *p = native_to_utf8( uid );
 	xfree ( uid );
 	uid = p;
     }
     return uid;
 }
 
 
 static DEK *
 ask_passphrase( STRING2KEY **ret_s2k )
 {
     DEK *dek = NULL;
     STRING2KEY *s2k;
     const char *errtext = NULL;
 
     tty_printf(_("You need a Passphrase to protect your secret key.\n\n") );
 
     s2k = xmalloc_secure ( sizeof *s2k );
     for(;;) {
 	s2k->mode = opt.s2k_mode;
 	s2k->hash_algo = opt.s2k_digest_algo;
 	dek = passphrase_to_dek( NULL, 0, opt.s2k_cipher_algo, s2k,2,
                                  errtext, NULL);
 	if( !dek ) {
 	    errtext = N_("passphrase not correctly repeated; try again");
 	    tty_printf(_("%s.\n"), _(errtext));
 	}
 	else if( !dek->keylen ) {
 	    xfree (dek); dek = NULL;
 	    xfree (s2k); s2k = NULL;
 	    tty_printf(_(
 	    "You don't want a passphrase - this is probably a *bad* idea!\n"
 	    "I will do it anyway.  You can change your passphrase at any time,\n"
 	    "using this program with the option \"--edit-key\".\n\n"));
 	    break;
 	}
 	else
 	    break; /* okay */
     }
     *ret_s2k = s2k;
     return dek;
 }
 
 
 static int
 do_create( int algo, unsigned int nbits, KBNODE pub_root, KBNODE sec_root,
 	   DEK *dek, STRING2KEY *s2k, PKT_secret_key **sk, u32 expiredate )
 {
     int rc=0;
 
     if( !opt.batch )
 	tty_printf(_(
 "We need to generate a lot of random bytes. It is a good idea to perform\n"
 "some other action (type on the keyboard, move the mouse, utilize the\n"
 "disks) during the prime generation; this gives the random number\n"
 "generator a better chance to gain enough entropy.\n") );
 
     if( algo == PUBKEY_ALGO_ELGAMAL || algo == PUBKEY_ALGO_ELGAMAL_E )
 	rc = gen_elg(algo, nbits, pub_root, sec_root, dek, s2k, sk, expiredate);
     else if( algo == PUBKEY_ALGO_DSA )
 	rc = gen_dsa(nbits, pub_root, sec_root, dek, s2k, sk, expiredate);
     else if( algo == PUBKEY_ALGO_RSA )
 	rc = gen_rsa(algo, nbits, pub_root, sec_root, dek, s2k, sk, expiredate);
     else
 	BUG();
 
 #ifdef ENABLE_COMMENT_PACKETS
     if( !rc ) {
 	add_kbnode( pub_root,
 		make_comment_node("#created by GNUPG v" VERSION " ("
 					    PRINTABLE_OS_NAME ")"));
 	add_kbnode( sec_root,
 		make_comment_node("#created by GNUPG v" VERSION " ("
 					    PRINTABLE_OS_NAME ")"));
     }
 #endif
     return rc;
 }
 
 
 /****************
  * Generate a new user id packet, or return NULL if canceled
  */
 PKT_user_id *
 generate_user_id()
 {
     PKT_user_id *uid;
     char *p;
     size_t n;
 
     p = ask_user_id( 1 );
     if( !p )
 	return NULL;
     n = strlen(p);
     uid = xcalloc (1, sizeof *uid + n - 1 );
     uid->len = n;
     strcpy(uid->name, p);
     uid->ref = 1;
     return uid;
 }
 
 
 static void
 release_parameter_list( struct para_data_s *r )
 {
     struct para_data_s *r2;
 
     for( ; r ; r = r2 ) {
 	r2 = r->next;
 	if( r->key == pPASSPHRASE_DEK )
 	    xfree ( r->u.dek );
 	else if( r->key == pPASSPHRASE_S2K )
 	    xfree ( r->u.s2k );
 
 	xfree (r);
     }
 }
 
 static struct para_data_s *
 get_parameter( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r;
 
     for( r = para; r && r->key != key; r = r->next )
 	;
     return r;
 }
 
 static const char *
 get_parameter_value( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r = get_parameter( para, key );
     return (r && *r->u.value)? r->u.value : NULL;
 }
 
 static int
 get_parameter_algo( struct para_data_s *para, enum para_name key )
 {
     int i;
     struct para_data_s *r = get_parameter( para, key );
     if( !r )
 	return -1;
     if( isdigit( *r->u.value ) )
 	i = atoi( r->u.value );
     else
         i = openpgp_pk_map_name ( r->u.value );
     if (i == PUBKEY_ALGO_RSA_E || i == PUBKEY_ALGO_RSA_S)
       i = 0; /* we don't want to allow generation of these algorithms */
     return i;
 }
 
 /* 
  * parse the usage parameter and set the keyflags.  Return true on error.
  */
 static int
 parse_parameter_usage (const char *fname,
                        struct para_data_s *para, enum para_name key)
 {
     struct para_data_s *r = get_parameter( para, key );
     char *p, *pn;
     unsigned int use;
 
     if( !r )
 	return 0; /* none (this is an optional parameter)*/
     
     use = 0;
     pn = r->u.value;
     while ( (p = strsep (&pn, " \t,")) ) {
         if ( !*p)
             ;
         else if ( !ascii_strcasecmp (p, "sign") )
             use |= PUBKEY_USAGE_SIG;
         else if ( !ascii_strcasecmp (p, "encrypt") )
             use |= PUBKEY_USAGE_ENC;
         else {
             log_error("%s:%d: invalid usage list\n", fname, r->lnr );
             return -1; /* error */
         }
     }
     r->u.usage = use;
     return 0;
 }
 
 static int
 parse_revocation_key (const char *fname,
 		      struct para_data_s *para, enum para_name key)
 {
   struct para_data_s *r = get_parameter( para, key );
   struct revocation_key revkey;
   char *pn;
   int i;
 
   if( !r )
     return 0; /* none (this is an optional parameter) */
 
   pn = r->u.value;
 
   revkey.class=0x80;
   revkey.algid=atoi(pn);
   if(!revkey.algid)
     goto fail;
 
   /* Skip to the fpr */
   while(*pn && *pn!=':')
     pn++;
 
   if(*pn!=':')
     goto fail;
 
   pn++;
 
   for(i=0;i<MAX_FINGERPRINT_LEN && *pn;i++,pn+=2)
     {
       int c=hextobyte(pn);
       if(c==-1)
 	goto fail;
 
       revkey.fpr[i]=c;
     }
 
   /* skip to the tag */
   while(*pn && *pn!='s' && *pn!='S')
     pn++;
 
   if(ascii_strcasecmp(pn,"sensitive")==0)
     revkey.class|=0x40;
 
   memcpy(&r->u.revkey,&revkey,sizeof(struct revocation_key));
 
   return 0;
 
   fail:
   log_error("%s:%d: invalid revocation key\n", fname, r->lnr );
   return -1; /* error */
 }
 
 
 static u32
 get_parameter_u32( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r = get_parameter( para, key );
 
     if( !r )
 	return 0;
     if( r->key == pKEYEXPIRE || r->key == pSUBKEYEXPIRE )
 	return r->u.expire;
     if( r->key == pKEYUSAGE || r->key == pSUBKEYUSAGE )
 	return r->u.usage;
 
     return (unsigned int)strtoul( r->u.value, NULL, 10 );
 }
 
 static unsigned int
 get_parameter_uint( struct para_data_s *para, enum para_name key )
 {
     return get_parameter_u32( para, key );
 }
 
 static DEK *
 get_parameter_dek( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r = get_parameter( para, key );
     return r? r->u.dek : NULL;
 }
 
 static STRING2KEY *
 get_parameter_s2k( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r = get_parameter( para, key );
     return r? r->u.s2k : NULL;
 }
 
 static struct revocation_key *
 get_parameter_revkey( struct para_data_s *para, enum para_name key )
 {
     struct para_data_s *r = get_parameter( para, key );
     return r? &r->u.revkey : NULL;
 }
 
 static int
 proc_parameter_file( struct para_data_s *para, const char *fname,
                      struct output_control_s *outctrl, int card )
 {
     struct para_data_s *r;
     const char *s1, *s2, *s3;
     size_t n;
     char *p;
     int i;
 
     /* check that we have all required parameters */
     assert( get_parameter( para, pKEYTYPE ) );
     i = get_parameter_algo( para, pKEYTYPE );
     if( i < 1 || openpgp_pk_test_algo ( i, PUBKEY_USAGE_SIG ) ) {
 	r = get_parameter( para, pKEYTYPE );
 	log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
 	return -1;
     }
 
     if (parse_parameter_usage (fname, para, pKEYUSAGE))
         return -1;
 
     i = get_parameter_algo( para, pSUBKEYTYPE );
     if( i > 0 && openpgp_pk_test_algo ( i, 0 ) ) {
 	r = get_parameter( para, pSUBKEYTYPE );
 	log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
 	return -1;
     }
     if (i > 0 && parse_parameter_usage (fname, para, pSUBKEYUSAGE))
         return -1;
 
 
     if( !get_parameter_value( para, pUSERID ) ) {
 	/* create the formatted user ID */
 	s1 = get_parameter_value( para, pNAMEREAL );
 	s2 = get_parameter_value( para, pNAMECOMMENT );
 	s3 = get_parameter_value( para, pNAMEEMAIL );
 	if( s1 || s2 || s3 ) {
 	    n = (s1?strlen(s1):0) + (s2?strlen(s2):0) + (s3?strlen(s3):0);
 	    r = xcalloc (1, sizeof *r + n + 20 );
 	    r->key = pUSERID;
 	    p = r->u.value;
 	    if( s1 )
 		p = stpcpy(p, s1 );
 	    if( s2 )
 		p = stpcpy(stpcpy(stpcpy(p," ("), s2 ),")");
 	    if( s3 )
 		p = stpcpy(stpcpy(stpcpy(p," <"), s3 ),">");
 	    r->next = para;
 	    para = r;
 	}
     }
 
     /* Set preferences, if any. */
     keygen_set_std_prefs(get_parameter_value( para, pPREFERENCES ), 0);
 
     /* Set revoker, if any. */
     if (parse_revocation_key (fname, para, pREVOKER))
       return -1;
 
     /* make DEK and S2K from the Passphrase */
     r = get_parameter( para, pPASSPHRASE );
     if( r && *r->u.value ) {
 	/* we have a plain text passphrase - create a DEK from it.
 	 * It is a little bit ridiculous to keep it in secure memory
 	 * but because we do this always, why not here. */
 	STRING2KEY *s2k;
 	DEK *dek;
 
 	s2k = xmalloc_secure ( sizeof *s2k );
 	s2k->mode = opt.s2k_mode;
 	s2k->hash_algo = opt.s2k_digest_algo;
 	set_next_passphrase( r->u.value );
 	dek = passphrase_to_dek( NULL, 0, opt.s2k_cipher_algo, s2k, 2,
                                  NULL, NULL);
 	set_next_passphrase( NULL );
 	assert( dek );
 	memset( r->u.value, 0, strlen(r->u.value) );
 
 	r = xcalloc (1, sizeof *r );
 	r->key = pPASSPHRASE_S2K;
 	r->u.s2k = s2k;
 	r->next = para;
 	para = r;
 	r = xcalloc (1, sizeof *r );
 	r->key = pPASSPHRASE_DEK;
 	r->u.dek = dek;
 	r->next = para;
 	para = r;
     }
 
     /* make KEYEXPIRE from Expire-Date */
     r = get_parameter( para, pEXPIREDATE );
     if( r && *r->u.value ) {
 	i = parse_expire_string( r->u.value );
 	if( i < 0 ) {
 	    log_error("%s:%d: invalid expire date\n", fname, r->lnr );
 	    return -1;
 	}
 	r->u.expire = i * 86400L;
 	r->key = pKEYEXPIRE;  /* change hat entry */
 	/* also set it for the subkey */
 	r = xcalloc (1, sizeof *r + 20 );
 	r->key = pSUBKEYEXPIRE;
 	r->u.expire = i * 86400L;
 	r->next = para;
 	para = r;
     }
 
     if( !!outctrl->pub.newfname ^ !!outctrl->sec.newfname ) {
 	log_error("%s:%d: only one ring name is set\n", fname, outctrl->lnr );
 	return -1;
     }
 
     do_generate_keypair( para, outctrl, card);
     return 0;
 }
 
 
 /****************
  * Kludge to allow non interactive key generation controlled
  * by a parameter file (which currently is only stdin)
  * Note, that string parameters are expected to be in UTF-8
  */
 static void
 read_parameter_file( const char *fname )
 {
     static struct { const char *name;
 		    enum para_name key;
     } keywords[] = {
 	{ "Key-Type",       pKEYTYPE},
 	{ "Key-Length",     pKEYLENGTH },
 	{ "Key-Usage",      pKEYUSAGE },
 	{ "Subkey-Type",    pSUBKEYTYPE },
 	{ "Subkey-Length",  pSUBKEYLENGTH },
 	{ "Subkey-Usage",   pSUBKEYUSAGE },
 	{ "Name-Real",      pNAMEREAL },
 	{ "Name-Email",     pNAMEEMAIL },
 	{ "Name-Comment",   pNAMECOMMENT },
 	{ "Expire-Date",    pEXPIREDATE },
 	{ "Passphrase",     pPASSPHRASE },
 	{ "Preferences",    pPREFERENCES },
 	{ "Revoker",        pREVOKER },
 	{ NULL, 0 }
     };
     FILE *fp;
     char line[1024], *p;
     int lnr;
     const char *err = NULL;
     struct para_data_s *para, *r;
     int i;
     struct output_control_s outctrl;
 
     memset( &outctrl, 0, sizeof( outctrl ) );
 
     if( !fname || !*fname || !strcmp(fname,"-") ) {
 	fp = stdin;
 	fname = "-";
     }
     else {
 	fp = fopen( fname, "r" );
 	if( !fp ) {
 	    log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
 	    return;
 	}
     }
 
     lnr = 0;
     err = NULL;
     para = NULL;
     while( fgets( line, DIM(line)-1, fp ) ) {
 	char *keyword, *value;
 
 	lnr++;
 	if( *line && line[strlen(line)-1] != '\n' ) {
 	    err = "line too long";
 	    break;
 	}
 	for( p = line; isspace(*(byte*)p); p++ )
 	    ;
 	if( !*p || *p == '#' )
 	    continue;
 	keyword = p;
 	if( *keyword == '%' ) {
 	    for( ; !isspace(*(byte*)p); p++ )
 		;
 	    if( *p )
 		*p++ = 0;
 	    for( ; isspace(*(byte*)p); p++ )
 		;
 	    value = p;
 	    trim_trailing_ws( value, strlen(value) );
 	    if( !ascii_strcasecmp( keyword, "%echo" ) )
 		log_info("%s\n", value );
 	    else if( !ascii_strcasecmp( keyword, "%dry-run" ) )
 		outctrl.dryrun = 1;
 	    else if( !ascii_strcasecmp( keyword, "%commit" ) ) {
 		outctrl.lnr = lnr;
 		proc_parameter_file( para, fname, &outctrl, 0 );
 		release_parameter_list( para );
 		para = NULL;
 	    }
 	    else if( !ascii_strcasecmp( keyword, "%pubring" ) ) {
 		if( outctrl.pub.fname && !strcmp( outctrl.pub.fname, value ) )
 		    ; /* still the same file - ignore it */
 		else {
 		    xfree ( outctrl.pub.newfname );
 		    outctrl.pub.newfname = xstrdup ( value );
 		    outctrl.use_files = 1;
 		}
 	    }
 	    else if( !ascii_strcasecmp( keyword, "%secring" ) ) {
 		if( outctrl.sec.fname && !strcmp( outctrl.sec.fname, value ) )
 		    ; /* still the same file - ignore it */
 		else {
 		   xfree ( outctrl.sec.newfname );
 		   outctrl.sec.newfname = xstrdup ( value );
 		   outctrl.use_files = 1;
 		}
 	    }
 	    else
 		log_info("skipping control `%s' (%s)\n", keyword, value );
 
 
 	    continue;
 	}
 
 
 	if( !(p = strchr( p, ':' )) || p == keyword ) {
 	    err = "missing colon";
 	    break;
 	}
 	if( *p )
 	    *p++ = 0;
 	for( ; isspace(*(byte*)p); p++ )
 	    ;
 	if( !*p ) {
 	    err = "missing argument";
 	    break;
 	}
 	value = p;
 	trim_trailing_ws( value, strlen(value) );
 
 	for(i=0; keywords[i].name; i++ ) {
 	    if( !ascii_strcasecmp( keywords[i].name, keyword ) )
 		break;
 	}
 	if( !keywords[i].name ) {
 	    err = "unknown keyword";
 	    break;
 	}
 	if( keywords[i].key != pKEYTYPE && !para ) {
 	    err = "parameter block does not start with \"Key-Type\"";
 	    break;
 	}
 
 	if( keywords[i].key == pKEYTYPE && para ) {
 	    outctrl.lnr = lnr;
 	    proc_parameter_file( para, fname, &outctrl, 0 );
 	    release_parameter_list( para );
 	    para = NULL;
 	}
 	else {
 	    for( r = para; r; r = r->next ) {
 		if( r->key == keywords[i].key )
 		    break;
 	    }
 	    if( r ) {
 		err = "duplicate keyword";
 		break;
 	    }
 	}
 	r = xcalloc (1, sizeof *r + strlen( value ) );
 	r->lnr = lnr;
 	r->key = keywords[i].key;
 	strcpy( r->u.value, value );
 	r->next = para;
 	para = r;
     }
     if( err )
 	log_error("%s:%d: %s\n", fname, lnr, err );
     else if( ferror(fp) ) {
 	log_error("%s:%d: read error: %s\n", fname, lnr, strerror(errno) );
     }
     else if( para ) {
 	outctrl.lnr = lnr;
 	proc_parameter_file( para, fname, &outctrl, 0 );
     }
 
     if( outctrl.use_files ) { /* close open streams */
 	iobuf_close( outctrl.pub.stream );
 	iobuf_close( outctrl.sec.stream );
 	xfree ( outctrl.pub.fname );
 	xfree ( outctrl.pub.newfname );
 	xfree ( outctrl.sec.fname );
 	xfree ( outctrl.sec.newfname );
     }
 
     release_parameter_list( para );
     if( strcmp( fname, "-" ) )
 	fclose(fp);
 }
 
 
 /****************
  * Generate a keypair
  * (fname is only used in batch mode)
  */
 void
 generate_keypair( const char *fname )
 {
   unsigned int nbits;
   char *uid = NULL;
   DEK *dek;
   STRING2KEY *s2k;
   int algo;
   unsigned int use;
   int both = 0;
   int card = 0;
   u32 expire;
   struct para_data_s *para = NULL;
   struct para_data_s *r;
   struct output_control_s outctrl;
   char *serialno = NULL;
 
   memset (&outctrl, 0, sizeof (outctrl));
 
   if (opt.batch)
     {
       read_parameter_file( fname );
       return;
     }
 
   do
     {
       xfree (serialno); serialno = NULL;
       card = check_smartcard (&serialno);
       if (card < 0)
         return;
     }
   while (card > 1);
 
   if (serialno)
     {
       r = xcalloc (1, sizeof *r + strlen (serialno) );
       r->key = pSERIALNO;
       strcpy( r->u.value, serialno);
       r->next = para;
       para = r;
       xfree (serialno); serialno = NULL;
     }
 
   if (card)
     {
       algo = PUBKEY_ALGO_RSA;
 
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pKEYTYPE;
       sprintf( r->u.value, "%d", algo );
       r->next = para;
       para = r;
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pKEYUSAGE;
       strcpy (r->u.value, "sign");
       r->next = para;
       para = r;
 
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pSUBKEYTYPE;
       sprintf( r->u.value, "%d", algo );
       r->next = para;
       para = r;
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pSUBKEYUSAGE;
       strcpy (r->u.value, "encrypt");
       r->next = para;
       para = r;
 
       r = xcalloc (1, sizeof *r + 20 );
       r->key = pAUTHKEYTYPE;
       sprintf( r->u.value, "%d", algo );
       r->next = para;
       para = r;
     }
   else
     {
       algo = ask_algo (0, &use);
       
       if (!algo)
         { /* default: DSA with ElG subkey of the specified size */
           both = 1;
           r = xcalloc (1, sizeof *r + 20 );
           r->key = pKEYTYPE;
           sprintf( r->u.value, "%d", PUBKEY_ALGO_DSA );
           r->next = para;
           para = r;
           tty_printf(_("DSA keypair will have 1024 bits.\n"));
           r = xcalloc (1, sizeof *r + 20 );
           r->key = pKEYLENGTH;
           strcpy( r->u.value, "1024" );
           r->next = para;
           para = r;
           
           algo = PUBKEY_ALGO_ELGAMAL_E;
           r = xcalloc (1, sizeof *r + 20 );
           r->key = pSUBKEYTYPE;
           sprintf( r->u.value, "%d", algo );
           r->next = para;
           para = r;
         }
       else 
         {
           r = xcalloc (1, sizeof *r + 20 );
           r->key = pKEYTYPE;
           sprintf( r->u.value, "%d", algo );
           r->next = para;
           para = r;
           
           if (use)
             {
               r = xcalloc (1, sizeof *r + 20 );
               r->key = pKEYUSAGE;
               sprintf( r->u.value, "%s%s",
                        (use & PUBKEY_USAGE_SIG)? "sign ":"",
                        (use & PUBKEY_USAGE_ENC)? "encrypt ":"" );
               r->next = para;
               para = r;
             }
         }
 
       nbits = ask_keysize( algo );
       r = xcalloc (1, sizeof *r + 20 );
       r->key = both? pSUBKEYLENGTH : pKEYLENGTH;
       sprintf( r->u.value, "%u", nbits);
       r->next = para;
       para = r;
     }
 
   expire = ask_expire_interval(0);
   r = xcalloc (1, sizeof *r + 20 );
   r->key = pKEYEXPIRE;
   r->u.expire = expire;
   r->next = para;
   para = r;
   r = xcalloc (1, sizeof *r + 20 );
   r->key = pSUBKEYEXPIRE;
   r->u.expire = expire;
   r->next = para;
   para = r;
   
   uid = ask_user_id(0);
   if (!uid)
     {
       log_error(_("Key generation canceled.\n"));
       release_parameter_list( para );
       return;
     }
   r = xcalloc (1, sizeof *r + strlen(uid) );
   r->key = pUSERID;
   strcpy( r->u.value, uid );
   r->next = para;
   para = r;
 
   dek = card? NULL : ask_passphrase( &s2k );
   if (dek)
     {
       r = xcalloc (1, sizeof *r );
       r->key = pPASSPHRASE_DEK;
       r->u.dek = dek;
       r->next = para;
       para = r;
       r = xcalloc (1, sizeof *r );
       r->key = pPASSPHRASE_S2K;
       r->u.s2k = s2k;
       r->next = para;
       para = r;
     }
   
   proc_parameter_file (para, "[internal]", &outctrl, card);
   release_parameter_list (para);
 }
 
 
 static void
 print_status_key_created (int letter, PKT_public_key *pk)
 {
   byte array[MAX_FINGERPRINT_LEN], *s;
   char buf[MAX_FINGERPRINT_LEN*2+30], *p;
   size_t i, n;
   
   p = buf;
   *p++ = letter;
   *p++ = ' ';
   fingerprint_from_pk (pk, array, &n);
   s = array;
   for (i=0; i < n ; i++, s++, p += 2)
     sprintf (p, "%02X", *s);
   *p = 0;
   write_status_text (STATUS_KEY_CREATED, buf);
 }
 
 
 
 static void
 do_generate_keypair (struct para_data_s *para,
 		     struct output_control_s *outctrl, int card)
 {
   KBNODE pub_root = NULL;
   KBNODE sec_root = NULL;
   PKT_secret_key *sk = NULL;
   const char *s;
   struct revocation_key *revkey;
   int rc;
   int did_sub = 0;
 
   if (outctrl->dryrun)
     {
       log_info ("dry-run mode - key generation skipped\n");
       return;
     }
 
 
   if (outctrl->use_files)
     {
       if (outctrl->pub.newfname)
 	{
 	  iobuf_close (outctrl->pub.stream);
 	  outctrl->pub.stream = NULL;
 	  xfree (outctrl->pub.fname);
 	  outctrl->pub.fname = outctrl->pub.newfname;
 	  outctrl->pub.newfname = NULL;
 
 	  outctrl->pub.stream = iobuf_create (outctrl->pub.fname);
 	  if (!outctrl->pub.stream)
 	    {
 	      log_error ("can't create `%s': %s\n", outctrl->pub.newfname,
 			 strerror (errno));
 	      return;
 	    }
 	  if (opt.armor)
 	    {
 	      outctrl->pub.afx.what = 1;
 	      iobuf_push_filter (outctrl->pub.stream, armor_filter,
 				 &outctrl->pub.afx);
 	    }
 	}
       if (outctrl->sec.newfname)
 	{
 	  iobuf_close (outctrl->sec.stream);
 	  outctrl->sec.stream = NULL;
 	  xfree (outctrl->sec.fname);
 	  outctrl->sec.fname = outctrl->sec.newfname;
 	  outctrl->sec.newfname = NULL;
 
 	  outctrl->sec.stream = iobuf_create (outctrl->sec.fname);
 	  if (!outctrl->sec.stream)
 	    {
 	      log_error ("can't create `%s': %s\n", outctrl->sec.newfname,
 			 strerror (errno));
 	      return;
 	    }
 	  if (opt.armor)
 	    {
 	      outctrl->sec.afx.what = 5;
 	      iobuf_push_filter (outctrl->sec.stream, armor_filter,
 				 &outctrl->sec.afx);
 	    }
 	}
       assert (outctrl->pub.stream);
       assert (outctrl->sec.stream);
       if (opt.verbose)
 	{
 	  log_info (_("writing public key to `%s'\n"), outctrl->pub.fname);
           if (card)
             log_info (_("writing secret key stub to `%s'\n"),
                       outctrl->sec.fname);
           else
             log_info (_("writing secret key to `%s'\n"), outctrl->sec.fname);
 	}
     }
 
 
   /* We create the packets as a tree of kbnodes. Because the structure
    * we create is known in advance we simply generate a linked list.
    * The first packet is a dummy comment packet which we flag
    * as deleted.  The very first packet must always be a KEY packet.
    */
   pub_root = make_comment_node ("#");
   delete_kbnode (pub_root);
   sec_root = make_comment_node ("#");
   delete_kbnode (sec_root);
   if (!card)
     {
       rc = do_create (get_parameter_algo (para, pKEYTYPE),
                       get_parameter_uint (para, pKEYLENGTH),
                       pub_root, sec_root,
                       get_parameter_dek (para, pPASSPHRASE_DEK),
                       get_parameter_s2k (para, pPASSPHRASE_S2K),
                       &sk, get_parameter_u32 (para, pKEYEXPIRE));
     }
   else
     {
       rc = gen_card_key (PUBKEY_ALGO_RSA, 1, pub_root, sec_root,
                          get_parameter_u32 (para, pKEYEXPIRE), para);
       if (!rc)
         {
           sk = sec_root->next->pkt->pkt.secret_key;
           assert (sk);
         }
       
     }
 
   if (!rc && (revkey = get_parameter_revkey (para, pREVOKER)))
     {
       rc = write_direct_sig (pub_root, pub_root, sk, revkey);
       if (!rc)
 	write_direct_sig (sec_root, pub_root, sk, revkey);
     }
 
   if (!rc && (s = get_parameter_value (para, pUSERID)))
     {
       write_uid (pub_root, s);
       if (!rc)
 	write_uid (sec_root, s);
       if (!rc)
 	rc = write_selfsig (pub_root, pub_root, sk,
 			    get_parameter_uint (para, pKEYUSAGE));
       if (!rc)
 	rc = write_selfsig (sec_root, pub_root, sk,
 			    get_parameter_uint (para, pKEYUSAGE));
     }
 
   if (get_parameter (para, pSUBKEYTYPE))
     {
       if (!card)
         {
           rc = do_create (get_parameter_algo (para, pSUBKEYTYPE),
                           get_parameter_uint (para, pSUBKEYLENGTH),
                           pub_root, sec_root,
                           get_parameter_dek (para, pPASSPHRASE_DEK),
                           get_parameter_s2k (para, pPASSPHRASE_S2K),
                           NULL, get_parameter_u32 (para, pSUBKEYEXPIRE));
         }
       else
         {
           rc = gen_card_key (PUBKEY_ALGO_RSA, 2, pub_root, sec_root,
                              get_parameter_u32 (para, pKEYEXPIRE), para);
         }
 
       if (!rc)
 	rc = write_keybinding (pub_root, pub_root, sk,
 			       get_parameter_uint (para, pSUBKEYUSAGE));
       if (!rc)
 	rc = write_keybinding (sec_root, pub_root, sk,
 			       get_parameter_uint (para, pSUBKEYUSAGE));
       did_sub = 1;
     }
 
   if (card && get_parameter (para, pAUTHKEYTYPE))
     {
       rc = gen_card_key (PUBKEY_ALGO_RSA, 3, pub_root, sec_root,
                          get_parameter_u32 (para, pKEYEXPIRE), para);
 
       /* FIXME: Change the usage to AUTH. */
       if (!rc)
 	rc = write_keybinding (pub_root, pub_root, sk, PUBKEY_USAGE_SIG);
       if (!rc)
 	rc = write_keybinding (sec_root, pub_root, sk, PUBKEY_USAGE_SIG);
     }
 
 
   if (!rc && outctrl->use_files)
     {				/* direct write to specified files */
       rc = write_keyblock (outctrl->pub.stream, pub_root);
       if (rc)
 	log_error ("can't write public key: %s\n", gpg_strerror (rc));
       if (!rc)
 	{
 	  rc = write_keyblock (outctrl->sec.stream, sec_root);
 	  if (rc)
 	    log_error ("can't write secret key: %s\n", gpg_strerror (rc));
 	}
 
     }
   else if (!rc)
     {				/* write to the standard keyrings */
       KEYDB_HANDLE pub_hd = keydb_new (0);
       KEYDB_HANDLE sec_hd = keydb_new (1);
 
       /* FIXME: we may have to create the keyring first */
       rc = keydb_locate_writable (pub_hd, NULL);
       if (rc)
 	log_error (_("no writable public keyring found: %s\n"),
 		   gpg_strerror (rc));
 
       if (!rc)
 	{
 	  rc = keydb_locate_writable (sec_hd, NULL);
 	  if (rc)
 	    log_error (_("no writable secret keyring found: %s\n"),
 		       gpg_strerror (rc));
 	}
 
       if (!rc && opt.verbose)
 	{
 	  log_info (_("writing public key to `%s'\n"),
 		    keydb_get_resource_name (pub_hd));
           if (card)
             log_info (_("writing secret key stub to `%s'\n"),
                       keydb_get_resource_name (sec_hd));
           else
             log_info (_("writing secret key to `%s'\n"),
                       keydb_get_resource_name (sec_hd));
 	}
 
       if (!rc)
 	{
 	  rc = keydb_insert_keyblock (pub_hd, pub_root);
 	  if (rc)
 	    log_error (_("error writing public keyring `%s': %s\n"),
 		       keydb_get_resource_name (pub_hd), gpg_strerror (rc));
 	}
 
       if (!rc)
 	{
 	  rc = keydb_insert_keyblock (sec_hd, sec_root);
 	  if (rc)
 	    log_error (_("error writing secret keyring `%s': %s\n"),
 		       keydb_get_resource_name (pub_hd), gpg_strerror (rc));
 	}
 
       keydb_release (pub_hd);
       keydb_release (sec_hd);
 
       if (!rc)
 	{
 	  int no_enc_rsa =
 	    get_parameter_algo (para, pKEYTYPE) == PUBKEY_ALGO_RSA
 	    && get_parameter_uint (para, pKEYUSAGE)
 	    && !(get_parameter_uint (para, pKEYUSAGE) & PUBKEY_USAGE_ENC);
 	  PKT_public_key *pk = find_kbnode (pub_root,
 					    PKT_PUBLIC_KEY)->pkt->pkt.
 	    public_key;
 
 	  update_ownertrust (pk,
 			     ((get_ownertrust (pk) & ~TRUST_MASK)
 			      | TRUST_ULTIMATE));
 
 	  if (!opt.batch)
 	    {
 	      tty_printf (_("public and secret key created and signed.\n"));
 	      tty_printf (_("key marked as ultimately trusted.\n"));
 	      tty_printf ("\n");
 	      list_keyblock (pub_root, 0, 1, NULL);
 	    }
 
 
 	  if (!opt.batch
 	      && (get_parameter_algo (para, pKEYTYPE) == PUBKEY_ALGO_DSA
 		  || no_enc_rsa) && !get_parameter (para, pSUBKEYTYPE))
 	    {
 	      tty_printf (_("Note that this key cannot be used for "
 			    "encryption.  You may want to use\n"
 			    "the command \"--edit-key\" to generate a "
 			    "secondary key for this purpose.\n"));
 	    }
 	}
     }
 
   if (rc)
     {
       if (opt.batch)
 	log_error ("key generation failed: %s\n", gpg_strerror (rc));
       else
 	tty_printf (_("Key generation failed: %s\n"), gpg_strerror (rc));
     }
   else
     {
       PKT_public_key *pk = find_kbnode (pub_root,
 					PKT_PUBLIC_KEY)->pkt->pkt.public_key;
       print_status_key_created (did_sub ? 'B' : 'P', pk);
     }
 
   release_kbnode (pub_root);
   release_kbnode (sec_root);
   if (sk && !card)         /* The unprotected secret key unless we have */
     free_secret_key (sk);  /* shallow copy in card mode. */
 }
 
 
 /****************
  * add a new subkey to an existing key.
  * Returns true if a new key has been generated and put into the keyblocks.
  */
 int
 generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
 {
     int okay=0, rc=0;
     KBNODE node;
     PKT_secret_key *sk = NULL; /* this is the primary sk */
     int algo;
     unsigned int use;
     u32 expire;
     unsigned nbits;
     char *passphrase = NULL;
     DEK *dek = NULL;
     STRING2KEY *s2k = NULL;
     u32 cur_time;
 
     /* break out the primary secret key */
     node = find_kbnode( sec_keyblock, PKT_SECRET_KEY );
     if( !node ) {
 	log_error("Oops; secret key not found anymore!\n");
 	goto leave;
     }
 
     /* make a copy of the sk to keep the protected one in the keyblock */
     sk = copy_secret_key( NULL, node->pkt->pkt.secret_key );
 
     cur_time = make_timestamp();
     if( sk->timestamp > cur_time ) {
 	ulong d = sk->timestamp - cur_time;
 	log_info( d==1 ? _("key has been created %lu second "
 			   "in future (time warp or clock problem)\n")
 		       : _("key has been created %lu seconds "
 			   "in future (time warp or clock problem)\n"), d );
 	if( !opt.ignore_time_conflict ) {
 	    rc = GPG_ERR_TIME_CONFLICT;
 	    goto leave;
 	}
     }
 
     if (sk->version < 4) {
         log_info (_("NOTE: creating subkeys for v3 keys "
                     "is not OpenPGP compliant\n"));
 	goto leave;
     }
 
     /* unprotect to get the passphrase */
     switch( is_secret_key_protected( sk ) ) {
       case -1:
 	rc = GPG_ERR_PUBKEY_ALGO;
 	break;
       case 0:
 	tty_printf("This key is not protected.\n");
 	break;
       default:
 	tty_printf("Key is protected.\n");
 	rc = check_secret_key( sk, 0 );
 	if( !rc )
 	    passphrase = get_last_passphrase();
 	break;
     }
     if( rc )
 	goto leave;
 
 
     algo = ask_algo( 1, &use );
     assert(algo);
     nbits = ask_keysize( algo );
     expire = ask_expire_interval(0);
     if( !cpr_enabled() && !cpr_get_answer_is_yes("keygen.sub.okay",
 						  _("Really create? ") ) )
 	goto leave;
 
     if( passphrase ) {
 	s2k = xmalloc_secure ( sizeof *s2k );
 	s2k->mode = opt.s2k_mode;
 	s2k->hash_algo = opt.s2k_digest_algo;
 	set_next_passphrase( passphrase );
 	dek = passphrase_to_dek( NULL, 0, opt.s2k_cipher_algo, s2k, 2,
                                  NULL, NULL );
     }
 
     rc = do_create( algo, nbits, pub_keyblock, sec_keyblock,
 				      dek, s2k, NULL, expire );
     if( !rc )
 	rc = write_keybinding(pub_keyblock, pub_keyblock, sk, use);
     if( !rc )
 	rc = write_keybinding(sec_keyblock, pub_keyblock, sk, use);
     if( !rc ) {
 	okay = 1;
         write_status_text (STATUS_KEY_CREATED, "S");
     }
 
   leave:
     if( rc )
 	log_error(_("Key generation failed: %s\n"), gpg_strerror (rc) );
     xfree ( passphrase );
     xfree ( dek );
     xfree ( s2k );
     if( sk ) /* release the copy of the (now unprotected) secret key */
 	free_secret_key(sk);
     set_next_passphrase( NULL );
     return okay;
 }
 
 /****************
  * Write a keyblock to an output stream
  */
 static int
 write_keyblock( iobuf_t out, KBNODE node )
 {
     for( ; node ; node = node->next ) {
 	int rc = build_packet( out, node->pkt );
 	if( rc ) {
 	    log_error("build_packet(%d) failed: %s\n",
 			node->pkt->pkttype, gpg_strerror (rc) );
 	    return rc;
 	}
     }
     return 0;
 }
 
 
 static void
 show_sha1_fpr (const unsigned char *fpr)
 {
   int i;
 
   if (fpr)
     {
       for (i=0; i < 20 ; i+=2, fpr += 2 )
         {
           if (i == 10 )
             tty_printf (" ");
           tty_printf (" %02X%02X", *fpr, fpr[1]);
         }
     }
   else
     tty_printf (" [none]");
   tty_printf ("\n");
 }
 
 static void
 show_smartcard (struct agent_card_info_s *info)
 {
   PKT_public_key *pk = xcalloc (1, sizeof *pk);
 
   /* FIXME: Sanitize what we show. */
   tty_printf ("Name of cardholder: %s\n",
               info->disp_name && *info->disp_name? info->disp_name 
                                                  : "[not set]");
   tty_printf ("URL of public key : %s\n",
               info->pubkey_url && *info->pubkey_url? info->pubkey_url 
                                                  : "[not set]");
   tty_printf ("Signature key ....:");
   show_sha1_fpr (info->fpr1valid? info->fpr1:NULL);
   tty_printf ("Encryption key....:");
   show_sha1_fpr (info->fpr2valid? info->fpr2:NULL);
   tty_printf ("Authentication key:");
   show_sha1_fpr (info->fpr3valid? info->fpr3:NULL);
 
   if (info->fpr1valid && !get_pubkey_byfprint (pk, info->fpr1, 20))
     print_pubkey_info (NULL, pk);
 
   free_public_key( pk );
 }
 
 
 static char *
 smartcard_get_one_name (const char *prompt1, const char *prompt2)
 {
   char *name;
   int i;
 
   for (;;)
     {
       name = cpr_get (prompt1, prompt2);
       if (!name)
         return NULL;
       trim_spaces (name);
       cpr_kill_prompt ();
       for (i=0; name[i] && name[i] >= ' ' && name[i] <= 126; i++)
         ;
 
       /* The name must be in Latin-1 and not UTF-8 - lacking the code
          to ensure this we restrict it to ASCII. */
       if (name[i])
         tty_printf (_("Error: Only plain ASCII is currently allowed.\n"));
       else if (strchr (name, '<'))
         tty_printf (_("Error: The \"<\" character may not be used.\n"));
       else if (strstr (name, "  "))
         tty_printf (_("Error: Double spaces are not allowed.\n"));    
       else
         return name;
       xfree (name);
     }
 }
 
 static int
 smartcard_change_name (const char *current_name)
 {
   char *surname = NULL, *givenname = NULL;
   char *isoname, *p;
   int rc;
 
   surname = smartcard_get_one_name ("keygen.smartcard.surname",
                                     _("Cardholder's surname: "));
   givenname = smartcard_get_one_name ("keygen.smartcard.givenname",
                                        _("Cardholder's given name: "));
   if (!surname || !givenname || (!*surname && !*givenname))
     {
       xfree (surname);
       xfree (givenname);
       return -1; /*canceled*/
     }
 
   isoname = xmalloc ( strlen (surname) + 2 + strlen (givenname) + 1);
   strcpy (stpcpy (stpcpy (isoname, surname), "<<"), givenname);
   xfree (surname);
   xfree (givenname);
   for (p=isoname; *p; p++)
     if (*p == ' ')
       *p = '<';
 
   log_debug ("setting Name to `%s'\n", isoname);
   rc = agent_scd_setattr ("DISP-NAME", isoname, strlen (isoname) );
   if (rc)
     log_error ("error setting Name: %s\n", gpg_strerror (rc));
 
   xfree (isoname);
   return rc;
 }
 
 
 static int
 smartcard_change_url (const char *current_url)
 {
   char *url;
   int rc;
 
   url = cpr_get ("keygen.smartcard.url", _("URL to retrieve public key: "));
   if (!url)
     return -1;
   trim_spaces (url);
   cpr_kill_prompt ();
 
   rc = agent_scd_setattr ("PUBKEY-URL", url, strlen (url) );
   if (rc)
     log_error ("error setting URL: %s\n", gpg_strerror (rc));
   xfree (url);
   return rc;
 }
 
+static int
+smartcard_change_login_data (void)
+{
+  char *data;
+  int rc;
+
+  data = cpr_get ("keygen.smartcard.login_data",
+                  _("Login data (account name): "));
+  if (!data)
+    return -1;
+  trim_spaces (data);
+  cpr_kill_prompt ();
+
+  rc = agent_scd_setattr ("LOGIN-DATA", data, strlen (data) );
+  if (rc)
+    log_error ("error setting login data: %s\n", gpg_strerror (rc));
+  xfree (data);
+  return rc;
+}
+
+static int
+smartcard_change_lang (void)
+{
+  char *data, *p;
+  int rc;
+
+  data = cpr_get ("keygen.smartcard.lang",
+                  _("Language preferences: "));
+  if (!data)
+    return -1;
+  trim_spaces (data);
+  cpr_kill_prompt ();
+
+  if (strlen (data) > 8 || (strlen (data) & 1))
+    {
+      tty_printf (_("Error: invalid length of preference string.\n"));
+      xfree (data);
+      return -1;
+    }
+
+  for (p=data; *p && *p >= 'a' && *p <= 'z'; p++)
+    ;
+  if (*p)
+    {
+      tty_printf (_("Error: invalid characters in preference string.\n"));
+      xfree (data);
+      return -1;
+    }
+
+  rc = agent_scd_setattr ("DISP-LANG", data, strlen (data) );
+  if (rc)
+    log_error ("error setting lang: %s\n", gpg_strerror (rc));
+  xfree (data);
+  return rc;
+}
+
+
+static int
+smartcard_change_sex (void)
+{
+  char *data;
+  const char *str;
+  int rc;
+
+  data = cpr_get ("keygen.smartcard.sex",
+                  _("Sex ((M)ale, (F)emale or space): "));
+  if (!data)
+    return -1;
+  trim_spaces (data);
+  cpr_kill_prompt ();
+
+  if (!*data)
+    str = "9";
+  else if ((*data == 'M' || *data == 'm') && !data[1])
+    str = "1";
+  else if ((*data == 'F' || *data == 'f') && !data[1])
+    str = "2";
+  else 
+    {
+      tty_printf (_("Error: invalid response.\n"));
+      xfree (data);
+      return -1;
+    }
+     
+  rc = agent_scd_setattr ("DISP-SEX", str, 1 );
+  if (rc)
+    log_error ("error setting sex: %s\n", gpg_strerror (rc));
+  xfree (data);
+  return rc;
+}
+
 
 /* Return true if the SHA1 fingerprint FPR consists only of zeroes. */
 static int
 fpr_is_zero (const char *fpr)
 {
   int i;
 
   for (i=0; i < 20 && !fpr[i]; i++)
     ;
   return (i == 20);
 }
 
 /* Check whether a smartcatrd is available and alow to select it as
    the target for key generation. 
    
    Return values: -1 = Quit generation
                    0 = No smartcard
                    1 = Generate keypair
 */
 static int
 check_smartcard (char **r_serialno)
 {
   struct agent_card_info_s info;
   int rc;
 
   rc = agent_learn (&info);
   if (rc)
     {
       tty_printf (_("OpenPGP card not available: %s\n"),
                   gpg_strerror (rc));
       return 0;
     }
   
   tty_printf (_("OpenPGP card no. %s detected\n"),
               info.serialno? info.serialno : "[none]");
 
 
   for (;;)
     {
       char *answer;
       int reread = 0;
 
       tty_printf ("\n");
       show_smartcard (&info);
 
       tty_printf ("\n"
                   "N - change cardholder name\n"
                   "U - change public key URL\n"
+                  "D - change login data\n"
+                  "L - change language preferences\n"
+                  "S - change sex\n"
                   "K - generate all keys\n"
                   "Q - quit\n"
                   "\n");
 
       answer = cpr_get("keygen.smartcard.menu",_("Your selection? "));
       cpr_kill_prompt();
       if (strlen (answer) != 1)
         continue;
 
       rc = 0;
       if ( *answer == 'N' || *answer == 'n')
         {
           if (!smartcard_change_name (info.disp_name))
             reread = 1;
         }
       else if ( *answer == 'U' || *answer == 'u')
         {
           if (!smartcard_change_url (info.pubkey_url))
             reread = 1;
         }
+      else if ( *answer == 'D' || *answer == 'd')
+        {
+          if (!smartcard_change_login_data ())
+            reread = 1;
+        }
+      else if ( *answer == 'L' || *answer == 'l')
+        {
+          if (!smartcard_change_lang ())
+            reread = 1;
+        }
+      else if ( *answer == 'S' || *answer == 's')
+        {
+          if (!smartcard_change_sex ())
+            reread = 1; 
+        }
       else if ( *answer == 'K' || *answer == 'k')
         {
           if ( (info.fpr1valid && !fpr_is_zero (info.fpr1))
                || (info.fpr2valid && !fpr_is_zero (info.fpr2))
                || (info.fpr3valid && !fpr_is_zero (info.fpr3)))
             {
               tty_printf ("\n");
               log_error ("WARNING: key does already exists!\n");
               tty_printf ("\n");
               if ( cpr_get_answer_is_yes( "keygen.card.replace_key",
                                           _("Replace existing key? ")))
                 {
                   rc = 1;
                   break;
                 }
             }
           else
             {
               rc = 1;
               break;
             }
         }
       else if ( *answer == 'q' || *answer == 'Q')
         {
           rc = -1;
           break;
         }
 
       if (reread)
         {
           agent_release_card_info (&info);
           rc = agent_learn (&info);
           if (rc)
             {
               tty_printf (_("OpenPGP card not anymore available: %s\n"),
                           gpg_strerror (rc));
               g10_exit (1);
             }
           reread = 0;
         }
     }
 
   if (r_serialno && rc > 0)
     {
       *r_serialno = info.serialno;
       info.serialno = NULL;
     }
   agent_release_card_info (&info);
 
   return rc;
 }
 
 
 
 static int
 gen_card_key (int algo, int keyno, KBNODE pub_root, KBNODE sec_root,
               u32 expireval, struct para_data_s *para)
 {
   int rc;
   const char *s;
   struct agent_card_genkey_s info;
   PACKET *pkt;
   PKT_secret_key *sk;
   PKT_public_key *pk;
 
   assert (algo == PUBKEY_ALGO_RSA);
 
   rc = agent_scd_genkey (&info, keyno, 1);
 /*    if (gpg_err_code (rc) == GPG_ERR_EEXIST) */
 /*      { */
 /*        tty_printf ("\n"); */
 /*        log_error ("WARNING: key does already exists!\n"); */
 /*        tty_printf ("\n"); */
 /*        if ( cpr_get_answer_is_yes( "keygen.card.replace_key", */
 /*                                    _("Replace existing key? "))) */
 /*          rc = agent_scd_genkey (&info, keyno, 1); */
 /*      } */
 
   if (rc)
     {
       log_error ("key generation failed: %s\n", gpg_strerror (rc));
       return rc;
     }
   if ( !info.n || !info.e )
     {
       log_error ("communication error with SCD\n");
       gcry_mpi_release (info.n);
       gcry_mpi_release (info.e);
       return gpg_error (GPG_ERR_GENERAL);
     }
   
 
   pk = xcalloc (1, sizeof *pk );
   sk = xcalloc (1, sizeof *sk );
   sk->timestamp = pk->timestamp = info.created_at;
   sk->version = pk->version = 4;
   if (expireval)
       sk->expiredate = pk->expiredate = pk->timestamp + expireval;
   sk->pubkey_algo = pk->pubkey_algo = algo;
   pk->pkey[0] = info.n;
   pk->pkey[1] = info.e; 
-  sk->skey[0] = mpi_copy (pk->pkey[0]);
-  sk->skey[1] = mpi_copy (pk->pkey[1]);
-  sk->skey[2] = mpi_set_opaque (NULL, xstrdup ("dummydata"), 10);
+  sk->skey[0] = gcry_mpi_copy (pk->pkey[0]);
+  sk->skey[1] = gcry_mpi_copy (pk->pkey[1]);
+  sk->skey[2] = gcry_mpi_set_opaque (NULL, xstrdup ("dummydata"), 10*8);
   sk->is_protected = 1;
   sk->protect.s2k.mode = 1002;
   s = get_parameter_value (para, pSERIALNO);
   if (s)
     {
       for (sk->protect.ivlen=0; sk->protect.ivlen < 16 && *s && s[1];
            sk->protect.ivlen++, s += 2)
         sk->protect.iv[sk->protect.ivlen] = xtoi_2 (s);
     }
 
   pkt = xcalloc (1,sizeof *pkt);
   pkt->pkttype = keyno == 1 ? PKT_PUBLIC_KEY : PKT_PUBLIC_SUBKEY;
   pkt->pkt.public_key = pk;
   add_kbnode(pub_root, new_kbnode( pkt ));
 
   pkt = xcalloc (1,sizeof *pkt);
   pkt->pkttype = keyno == 1 ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
   pkt->pkt.secret_key = sk;
   add_kbnode(sec_root, new_kbnode( pkt ));
 
   return 0;
 }
 
 
 
diff --git a/g10/main.h b/g10/main.h
index cb81192d3..2e1377ea4 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -1,268 +1,269 @@
 /* main.h
  * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG 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
  */
 #ifndef G10_MAIN_H
 #define G10_MAIN_H
 #include "types.h"
 #include "gpg.h"
 #include "../common/iobuf.h"
 #include "mpi.h"
 #include "cipher.h"
 #include "keydb.h"
 
 /* It could be argued that the default cipher should be 3DES rather
    than CAST5, and the default compression should be 0
    (i.e. uncompressed) rather than 1 (zip). */
 #define DEFAULT_CIPHER_ALGO   CIPHER_ALGO_CAST5
 #define DEFAULT_DIGEST_ALGO   DIGEST_ALGO_SHA1
 #define DEFAULT_COMPRESS_ALGO 1
 
 typedef struct {
     int header_okay;
     PK_LIST pk_list;
     cipher_filter_context_t cfx;
 } encrypt_filter_context_t;
 
 struct groupitem
 {
   char *name;
   STRLIST values;
   struct groupitem *next;
 };
 
 /*-- g10.c --*/
 extern int g10_errors_seen;
 
 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )
   void g10_exit(int rc) __attribute__ ((noreturn));
 #else
   void g10_exit(int rc);
 #endif
 void print_pubkey_algo_note( int algo );
 void print_cipher_algo_note( int algo );
 void print_digest_algo_note( int algo );
 
 /*-- armor.c --*/
 char *make_radix64_string( const byte *data, size_t len );
 
 /*-- misc.c --*/
 void trap_unaligned(void);
 int disable_core_dumps(void);
 u16 checksum_u16( unsigned n );
 u16 checksum( byte *p, unsigned n );
 u16 checksum_mpi( gcry_mpi_t a );
 u32 buffer_to_u32( const byte *buffer );
 const byte *get_session_marker( size_t *rlen );
 int openpgp_cipher_test_algo( int algo );
 int openpgp_pk_test_algo( int algo, unsigned int usage_flags );
 int openpgp_pk_algo_usage ( int algo );
 int openpgp_md_test_algo( int algo );
 int openpgp_md_map_name (const char *string);
 int openpgp_cipher_map_name (const char *string);
 int openpgp_pk_map_name (const char *string);
 
 #ifdef USE_IDEA
 void idea_cipher_warn( int show );
 #else
 #define idea_cipher_warn(a)
 #endif
 
 struct expando_args
 {
   PKT_public_key *pk;
   PKT_secret_key *sk;
   byte imagetype;
 };
 
 char *pct_expando(const char *string,struct expando_args *args);
 int hextobyte( const char *s );
 void deprecated_warning(const char *configname,unsigned int configlineno,
 			const char *option,const char *repl1,const char *repl2);
 const char *compress_algo_to_string(int algo);
 int string_to_compress_algo(const char *string);
 int check_compress_algo(int algo);
 int default_cipher_algo(void);
 int default_compress_algo(void);
 const char *compliance_option_string(void);
 void compliance_failure(void);
 
 struct parse_options
 {
   char *name;
   unsigned int bit;
 };
 
 int parse_options(char *str,unsigned int *options,struct parse_options *opts);
 
 
 /* Temporary helpers. */
 int pubkey_get_npkey( int algo );
 int pubkey_get_nskey( int algo );
 int pubkey_get_nsig( int algo );
 int pubkey_get_nenc( int algo );
 unsigned int pubkey_nbits( int algo, gcry_mpi_t *pkey );
 
 /* MPI helpers. */
 int mpi_write( iobuf_t out, gcry_mpi_t a );
 int mpi_write_opaque( iobuf_t out, gcry_mpi_t a );
 gcry_mpi_t mpi_read(iobuf_t inp, unsigned int *ret_nread, int secure );
 gcry_mpi_t mpi_read_opaque(iobuf_t inp, unsigned int *ret_nread );
 int mpi_print( FILE *fp, gcry_mpi_t a, int mode );
 
 
 
 
 /*-- helptext.c --*/
 void display_online_help( const char *keyword );
 
 /*-- encode.c --*/
 int encode_symmetric( const char *filename );
 int encode_store( const char *filename );
 int encode_crypt( const char *filename, STRLIST remusr );
 void encode_crypt_files(int nfiles, char **files, STRLIST remusr);
 int encrypt_filter( void *opaque, int control,
 		    iobuf_t a, byte *buf, size_t *ret_len);
 
 
 /*-- sign.c --*/
 int complete_sig( PKT_signature *sig, PKT_secret_key *sk, MD_HANDLE md );
 int sign_file( STRLIST filenames, int detached, STRLIST locusr,
 	       int do_encrypt, STRLIST remusr, const char *outfile );
 int clearsign_file( const char *fname, STRLIST locusr, const char *outfile );
 int sign_symencrypt_file (const char *fname, STRLIST locusr);
 
 /*-- sig-check.c --*/
 int check_revocation_keys (PKT_public_key *pk, PKT_signature *sig);
 int check_key_signature( KBNODE root, KBNODE node, int *is_selfsig );
 int check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk,
 			  int *is_selfsig, u32 *r_expiredate, int *r_expired );
 
 /*-- delkey.c --*/
 int delete_keys( STRLIST names, int secret, int allow_both );
 
 /*-- keyedit.c --*/
 void keyedit_menu( const char *username, STRLIST locusr, STRLIST cmds,
 							    int sign_mode );
 void show_basic_key_info (KBNODE keyblock);
 
 /*-- keygen.c --*/
 u32 ask_expire_interval(int object);
 u32 ask_expiredate(void);
 void generate_keypair( const char *fname );
 int keygen_set_std_prefs (const char *string,int personal);
 PKT_user_id *keygen_get_std_prefs (void);
 int keygen_add_key_expire( PKT_signature *sig, void *opaque );
 int keygen_add_std_prefs( PKT_signature *sig, void *opaque );
 int keygen_upd_std_prefs( PKT_signature *sig, void *opaque );
 int keygen_add_revkey(PKT_signature *sig, void *opaque);
 int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock );
 
 /*-- openfile.c --*/
 int overwrite_filep( const char *fname );
 char *make_outfile_name( const char *iname );
 char *ask_outfile_name( const char *name, size_t namelen );
 int   open_outfile( const char *iname, int mode, iobuf_t *a );
 iobuf_t open_sigfile( const char *iname, progress_filter_context_t *pfx );
 void try_make_homedir( const char *fname );
 
 /*-- seskey.c --*/
 void make_session_key( DEK *dek );
 gcry_mpi_t encode_session_key( DEK *dek, unsigned int nbits);
 gcry_mpi_t encode_md_value( int pubkey_algo,  MD_HANDLE md,
 		     int hash_algo, unsigned nbits, int v3compathack );
 
 /*-- comment.c --*/
+KBNODE make_comment_node_from_buffer (const char *s, size_t n);
 KBNODE make_comment_node( const char *s );
 KBNODE make_mpi_comment_node( const char *s, gcry_mpi_t a );
 
 /*-- import.c --*/
 int parse_import_options(char *str,unsigned int *options);
 void import_keys( char **fnames, int nnames,
 		  void *stats_hd, unsigned int options );
 int import_keys_stream( iobuf_t inp,
 			void *stats_hd, unsigned int options );
 void *import_new_stats_handle (void);
 void import_release_stats_handle (void *p);
 void import_print_stats (void *hd);
 
 int collapse_uids( KBNODE *keyblock );
 
 /*-- export.c --*/
 int parse_export_options(char *str,unsigned int *options);
 int export_pubkeys( STRLIST users, unsigned int options );
 int export_pubkeys_stream( iobuf_t out, STRLIST users,
 			   KBNODE *keyblock_out, unsigned int options );
 int export_seckeys( STRLIST users );
 int export_secsubkeys( STRLIST users );
 
 /* dearmor.c --*/
 int dearmor_file( const char *fname );
 int enarmor_file( const char *fname );
 
 /*-- revoke.c --*/
 struct revocation_reason_info;
 int gen_revoke( const char *uname );
 int gen_desig_revoke( const char *uname );
 int revocation_reason_build_cb( PKT_signature *sig, void *opaque );
 struct revocation_reason_info *
 		ask_revocation_reason( int key_rev, int cert_rev, int hint );
 void release_revocation_reason_info( struct revocation_reason_info *reason );
 
 /*-- keylist.c --*/
 void public_key_list( STRLIST list );
 void secret_key_list( STRLIST list );
 void reorder_keyblock (KBNODE keyblock);
 void list_keyblock( KBNODE keyblock, int secret, int fpr, void *opaque );
 void print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode);
 void show_policy_url(PKT_signature *sig,int indent,int mode);
 void show_notation(PKT_signature *sig,int indent,int mode);
 void dump_attribs(const PKT_user_id *uid,
 		  PKT_public_key *pk,PKT_secret_key *sk);
 void set_attrib_fd(int fd);
 void print_seckey_info (PKT_secret_key *sk);
 void print_pubkey_info (FILE *fp, PKT_public_key *pk);
 
 /*-- verify.c --*/
 void print_file_status( int status, const char *name, int what );
 int verify_signatures( int nfiles, char **files );
 int verify_files( int nfiles, char **files );
 
 /*-- decrypt.c --*/
 int decrypt_message( const char *filename );
 void decrypt_messages(int nfiles, char **files);
 
 /*-- plaintext.c --*/
 int hash_datafiles( MD_HANDLE md, MD_HANDLE md2,
 		    STRLIST files, const char *sigfilename, int textmode );
 
 /*-- pipemode.c --*/
 void run_in_pipemode (void);
 
 /*-- card-util.c --*/
 void change_pin (int no);
 void card_status (FILE *fp);
 
 
 /*-- signal.c --*/
 void init_signals(void);
 void pause_on_sigusr( int which );
 void block_all_signals(void);
 void unblock_all_signals(void);
 
 #endif /*G10_MAIN_H*/
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 57a6d3d7b..f70cc3f69 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1,2303 +1,2305 @@
 /* parse-packet.c  - read packets
  * Copyright (C) 1998, 1999, 2000, 2001, 2002,
  *               2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 #include "packet.h"
 #include "iobuf.h"
 #include "mpi.h"
 #include "util.h"
 #include "cipher.h"
 #include "memory.h"
 #include "filter.h"
 #include "photoid.h"
 #include "options.h"
 #include "main.h"
 #include "i18n.h"
 
 static int mpi_print_mode = 0;
 static int list_mode = 0;
 
 static int  parse( iobuf_t inp, PACKET *pkt, int onlykeypkts,
                   off_t *retpos, int *skip, iobuf_t out, int do_skip
 #ifdef DEBUG_PARSE_PACKET
 		   ,const char *dbg_w, const char *dbg_f, int dbg_l
 #endif
 		 );
 static int  copy_packet( iobuf_t inp, iobuf_t out, int pkttype,
 					       unsigned long pktlen );
 static void skip_packet( iobuf_t inp, int pkttype, unsigned long pktlen );
 static void skip_rest( iobuf_t inp, unsigned long pktlen );
 static void *read_rest( iobuf_t inp, size_t pktlen );
 static int  parse_symkeyenc( iobuf_t inp, int pkttype, unsigned long pktlen,
 							     PACKET *packet );
 static int  parse_pubkeyenc( iobuf_t inp, int pkttype, unsigned long pktlen,
 							     PACKET *packet );
 static int  parse_signature( iobuf_t inp, int pkttype, unsigned long pktlen,
 							 PKT_signature *sig );
 static int  parse_onepass_sig( iobuf_t inp, int pkttype, unsigned long pktlen,
 							PKT_onepass_sig *ops );
 static int  parse_key( iobuf_t inp, int pkttype, unsigned long pktlen,
 				      byte *hdr, int hdrlen, PACKET *packet );
 static int  parse_user_id( iobuf_t inp, int pkttype, unsigned long pktlen,
 							   PACKET *packet );
 static int  parse_attribute( iobuf_t inp, int pkttype, unsigned long pktlen,
 							   PACKET *packet );
 static int  parse_comment( iobuf_t inp, int pkttype, unsigned long pktlen,
 							   PACKET *packet );
 static void parse_trust( iobuf_t inp, int pkttype, unsigned long pktlen,
 							   PACKET *packet );
 static int  parse_plaintext( iobuf_t inp, int pkttype, unsigned long pktlen,
 					       PACKET *packet, int new_ctb);
 static int  parse_compressed( iobuf_t inp, int pkttype, unsigned long pktlen,
 					       PACKET *packet, int new_ctb );
 static int  parse_encrypted( iobuf_t inp, int pkttype, unsigned long pktlen,
 					       PACKET *packet, int new_ctb);
 static int  parse_mdc( iobuf_t inp, int pkttype, unsigned long pktlen,
 					       PACKET *packet, int new_ctb);
 static int  parse_gpg_control( iobuf_t inp, int pkttype, unsigned long pktlen,
                                PACKET *packet );
 
 static unsigned short
 read_16(iobuf_t inp)
 {
     unsigned short a;
     a = iobuf_get_noeof(inp) << 8;
     a |= iobuf_get_noeof(inp);
     return a;
 }
 
 static unsigned long
 read_32(iobuf_t inp)
 {
     unsigned long a;
     a =  iobuf_get_noeof(inp) << 24;
     a |= iobuf_get_noeof(inp) << 16;
     a |= iobuf_get_noeof(inp) << 8;
     a |= iobuf_get_noeof(inp);
     return a;
 }
 
 
 int
 set_packet_list_mode( int mode )
 {
     int old = list_mode;
     list_mode = mode;
     /* FIXME(gcrypt) mpi_print_mode = DBG_MPI; */
     return old;
 }
 
 static void
 unknown_pubkey_warning( int algo )
 {
     static byte unknown_pubkey_algos[256];
 
     algo &= 0xff;
     if( !unknown_pubkey_algos[algo] ) {
 	if( opt.verbose )
 	    log_info(_("can't handle public key algorithm %d\n"), algo );
 	unknown_pubkey_algos[algo] = 1;
     }
 }
 
 /****************
  * Parse a Packet and return it in packet
  * Returns: 0 := valid packet in pkt
  *	   -1 := no more packets
  *	   >0 := error
  * Note: The function may return an error and a partly valid packet;
  * caller must free this packet.
  */
 #ifdef DEBUG_PARSE_PACKET
 int
 dbg_parse_packet( iobuf_t inp, PACKET *pkt, const char *dbg_f, int dbg_l )
 {
     int skip, rc;
 
     do {
 	rc = parse( inp, pkt, 0, NULL, &skip, NULL, 0, "parse", dbg_f, dbg_l );
     } while( skip );
     return rc;
 }
 #else
 int
 parse_packet( iobuf_t inp, PACKET *pkt )
 {
     int skip, rc;
 
     do {
 	rc = parse( inp, pkt, 0, NULL, &skip, NULL, 0 );
     } while( skip );
     return rc;
 }
 #endif
 
 /****************
  * Like parse packet, but only return secret or public (sub)key packets.
  */
 #ifdef DEBUG_PARSE_PACKET
 int
 dbg_search_packet( iobuf_t inp, PACKET *pkt, off_t *retpos, int with_uid,
 		   const char *dbg_f, int dbg_l )
 {
     int skip, rc;
 
     do {
 	rc = parse( inp, pkt, with_uid?2:1, retpos, &skip, NULL, 0, "search", dbg_f, dbg_l );
     } while( skip );
     return rc;
 }
 #else
 int
 search_packet( iobuf_t inp, PACKET *pkt, off_t *retpos, int with_uid )
 {
     int skip, rc;
 
     do {
 	rc = parse( inp, pkt, with_uid?2:1, retpos, &skip, NULL, 0 );
     } while( skip );
     return rc;
 }
 #endif
 
 /****************
  * Copy all packets from INP to OUT, thereby removing unused spaces.
  */
 #ifdef DEBUG_PARSE_PACKET
 int
 dbg_copy_all_packets( iobuf_t inp, iobuf_t out,
 		   const char *dbg_f, int dbg_l )
 {
     PACKET pkt;
     int skip, rc=0;
     do {
 	init_packet(&pkt);
     } while( !(rc = parse( inp, &pkt, 0, NULL, &skip, out, 0, "copy", dbg_f, dbg_l )));
     return rc;
 }
 #else
 int
 copy_all_packets( iobuf_t inp, iobuf_t out )
 {
     PACKET pkt;
     int skip, rc=0;
     do {
 	init_packet(&pkt);
     } while( !(rc = parse( inp, &pkt, 0, NULL, &skip, out, 0 )));
     return rc;
 }
 #endif
 
 /****************
  * Copy some packets from INP to OUT, thereby removing unused spaces.
  * Stop at offset STOPoff (i.e. don't copy packets at this or later offsets)
  */
 #ifdef DEBUG_PARSE_PACKET
 int
 dbg_copy_some_packets( iobuf_t inp, iobuf_t out, off_t stopoff,
 		   const char *dbg_f, int dbg_l )
 {
     PACKET pkt;
     int skip, rc=0;
     do {
 	if( iobuf_tell(inp) >= stopoff )
 	    return 0;
 	init_packet(&pkt);
     } while( !(rc = parse( inp, &pkt, 0, NULL, &skip, out, 0,
 				     "some", dbg_f, dbg_l )) );
     return rc;
 }
 #else
 int
 copy_some_packets( iobuf_t inp, iobuf_t out, off_t stopoff )
 {
     PACKET pkt;
     int skip, rc=0;
     do {
 	if( iobuf_tell(inp) >= stopoff )
 	    return 0;
 	init_packet(&pkt);
     } while( !(rc = parse( inp, &pkt, 0, NULL, &skip, out, 0 )) );
     return rc;
 }
 #endif
 
 /****************
  * Skip over N packets
  */
 #ifdef DEBUG_PARSE_PACKET
 int
 dbg_skip_some_packets( iobuf_t inp, unsigned n,
 		   const char *dbg_f, int dbg_l )
 {
     int skip, rc=0;
     PACKET pkt;
 
     for( ;n && !rc; n--) {
 	init_packet(&pkt);
 	rc = parse( inp, &pkt, 0, NULL, &skip, NULL, 1, "skip", dbg_f, dbg_l );
     }
     return rc;
 }
 #else
 int
 skip_some_packets( iobuf_t inp, unsigned n )
 {
     int skip, rc=0;
     PACKET pkt;
 
     for( ;n && !rc; n--) {
 	init_packet(&pkt);
 	rc = parse( inp, &pkt, 0, NULL, &skip, NULL, 1 );
     }
     return rc;
 }
 #endif
 
 
 /****************
  * Parse packet. Set the variable skip points to 1 if the packet
  * should be skipped; this is the case if either ONLYKEYPKTS is set
  * and the parsed packet isn't one or the
  * packet-type is 0, indicating deleted stuff.
  * if OUT is not NULL, a special copymode is used.
  */
 static int
 parse( iobuf_t inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
        int *skip, iobuf_t out, int do_skip
 #ifdef DEBUG_PARSE_PACKET
        ,const char *dbg_w, const char *dbg_f, int dbg_l
 #endif
      )
 {
     int rc=0, c, ctb, pkttype, lenbytes;
     unsigned long pktlen;
     byte hdr[8];
     int hdrlen;
     int new_ctb = 0;
     int with_uid = (onlykeypkts == 2);
 
     *skip = 0;
     assert( !pkt->pkt.generic );
     if( retpos )
 	*retpos = iobuf_tell(inp);
 
     if( (ctb = iobuf_get(inp)) == -1 ) {
 	rc = -1;
 	goto leave;
     }
     hdrlen=0;
     hdr[hdrlen++] = ctb;
     if( !(ctb & 0x80) ) {
         log_error("%s: invalid packet (ctb=%02x)\n", iobuf_where(inp), ctb );
 	rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     pktlen = 0;
     new_ctb = !!(ctb & 0x40);
     if( new_ctb ) {
         pkttype = ctb & 0x3f;
 	if( (c = iobuf_get(inp)) == -1 ) {
 	    log_error("%s: 1st length byte missing\n", iobuf_where(inp) );
 	    rc = GPG_ERR_INV_PACKET;
 	    goto leave;
 	}
         if (pkttype == PKT_COMPRESSED) {
              iobuf_set_partial_block_mode(inp, c & 0xff);
              pktlen = 0;/* to indicate partial length */
         }
         else {
              hdr[hdrlen++] = c;
              if( c < 192 )
                   pktlen = c;
              else if( c < 224 ) {
                   pktlen = (c - 192) * 256;
                   if( (c = iobuf_get(inp)) == -1 ) {
                        log_error("%s: 2nd length byte missing\n",
                                  iobuf_where(inp) );
                        rc = GPG_ERR_INV_PACKET;
                        goto leave;
                   }
                   hdr[hdrlen++] = c;
                   pktlen += c + 192;
              }
              else if( c == 255 ) {
                   pktlen  = (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 24;
                   pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 16;
                   pktlen |= (hdr[hdrlen++] = iobuf_get_noeof(inp)) << 8;
                   if( (c = iobuf_get(inp)) == -1 ) {
                        log_error("%s: 4 byte length invalid\n",
                                  iobuf_where(inp) );
                        rc = GPG_ERR_INV_PACKET;
                        goto leave;
                   }
                   pktlen |= (hdr[hdrlen++] = c );
              }
              else { /* partial body length */
                   iobuf_set_partial_block_mode(inp, c & 0xff);
                   pktlen = 0;/* to indicate partial length */
              }
 	}
     }
     else {
 	pkttype = (ctb>>2)&0xf;
 	lenbytes = ((ctb&3)==3)? 0 : (1<<(ctb & 3));
 	if( !lenbytes ) {
 	    pktlen = 0; /* don't know the value */
 	    if( pkttype != PKT_COMPRESSED )
 		iobuf_set_block_mode(inp, 1);
 	}
 	else {
 	    for( ; lenbytes; lenbytes-- ) {
 		pktlen <<= 8;
 		pktlen |= hdr[hdrlen++] = iobuf_get_noeof(inp);
 	    }
 	}
     }
 
     if (pktlen == 0xffffffff) {
         /* with a some probability this is caused by a problem in the
          * the uncompressing layer - in some error cases it just loops
          * and spits out 0xff bytes. */
         log_error ("%s: garbled packet detected\n", iobuf_where(inp) );
 	g10_exit (2);
     }
 
     if( out && pkttype	) {
         rc = iobuf_write( out, hdr, hdrlen );
 	if (!rc)
 	    rc = copy_packet(inp, out, pkttype, pktlen );
 	goto leave;
     }
 
     if (with_uid && pkttype == PKT_USER_ID)
         ;
     else if( do_skip 
         || !pkttype
         || (onlykeypkts && pkttype != PKT_PUBLIC_SUBKEY
                         && pkttype != PKT_PUBLIC_KEY
                         && pkttype != PKT_SECRET_SUBKEY
                         && pkttype != PKT_SECRET_KEY  ) ) {
 	skip_rest(inp, pktlen);
 	*skip = 1;
 	rc = 0;
 	goto leave;
     }
 
     if( DBG_PACKET ) {
 #ifdef DEBUG_PARSE_PACKET
 	log_debug("parse_packet(iob=%d): type=%d length=%lu%s (%s.%s.%d)\n",
 		   iobuf_id(inp), pkttype, pktlen, new_ctb?" (new_ctb)":"",
 		    dbg_w, dbg_f, dbg_l );
 #else
 	log_debug("parse_packet(iob=%d): type=%d length=%lu%s\n",
 		   iobuf_id(inp), pkttype, pktlen, new_ctb?" (new_ctb)":"" );
 #endif
     }
     pkt->pkttype = pkttype;
     rc = GPG_ERR_UNKNOWN_PACKET; /* default error */
     switch( pkttype ) {
       case PKT_PUBLIC_KEY:
       case PKT_PUBLIC_SUBKEY:
 	pkt->pkt.public_key = xcalloc (1,sizeof *pkt->pkt.public_key );
 	rc = parse_key(inp, pkttype, pktlen, hdr, hdrlen, pkt );
 	break;
       case PKT_SECRET_KEY:
       case PKT_SECRET_SUBKEY:
 	pkt->pkt.secret_key = xcalloc (1,sizeof *pkt->pkt.secret_key );
 	rc = parse_key(inp, pkttype, pktlen, hdr, hdrlen, pkt );
 	break;
       case PKT_SYMKEY_ENC:
 	rc = parse_symkeyenc( inp, pkttype, pktlen, pkt );
 	break;
       case PKT_PUBKEY_ENC:
 	rc = parse_pubkeyenc(inp, pkttype, pktlen, pkt );
 	break;
       case PKT_SIGNATURE:
 	pkt->pkt.signature = xcalloc (1,sizeof *pkt->pkt.signature );
 	rc = parse_signature(inp, pkttype, pktlen, pkt->pkt.signature );
 	break;
       case PKT_ONEPASS_SIG:
 	pkt->pkt.onepass_sig = xcalloc (1,sizeof *pkt->pkt.onepass_sig );
 	rc = parse_onepass_sig(inp, pkttype, pktlen, pkt->pkt.onepass_sig );
 	break;
       case PKT_USER_ID:
 	rc = parse_user_id(inp, pkttype, pktlen, pkt );
 	break;
       case PKT_ATTRIBUTE:
 	pkt->pkttype = pkttype = PKT_USER_ID;  /* we store it in the userID */
 	rc = parse_attribute(inp, pkttype, pktlen, pkt);
 	break;
       case PKT_OLD_COMMENT:
       case PKT_COMMENT:
 	rc = parse_comment(inp, pkttype, pktlen, pkt);
 	break;
       case PKT_RING_TRUST:
 	parse_trust(inp, pkttype, pktlen, pkt);
 	rc = 0;
 	break;
       case PKT_PLAINTEXT:
 	rc = parse_plaintext(inp, pkttype, pktlen, pkt, new_ctb );
 	break;
       case PKT_COMPRESSED:
 	rc = parse_compressed(inp, pkttype, pktlen, pkt, new_ctb );
 	break;
       case PKT_ENCRYPTED:
       case PKT_ENCRYPTED_MDC:
 	rc = parse_encrypted(inp, pkttype, pktlen, pkt, new_ctb );
 	break;
       case PKT_MDC:
 	rc = parse_mdc(inp, pkttype, pktlen, pkt, new_ctb );
 	break;
       case PKT_GPG_CONTROL:
         rc = parse_gpg_control(inp, pkttype, pktlen, pkt );
         break;
       default:
 	skip_packet(inp, pkttype, pktlen);
 	break;
     }
 
   leave:
     if( !rc && iobuf_error(inp) )
 	rc = GPG_ERR_INV_KEYRING;
     return rc;
 }
 
 static void
 dump_hex_line( int c, int *i )
 {
     if( *i && !(*i%8) ) {
 	if( *i && !(*i%24) )
 	    printf("\n%4d:", *i );
 	else
 	    putchar(' ');
     }
     if( c == -1 )
 	printf(" EOF" );
     else
 	printf(" %02x", c );
     ++*i;
 }
 
 
 static int
 copy_packet( iobuf_t inp, iobuf_t out, int pkttype, unsigned long pktlen )
 {
     int rc, n;
     char buf[100];
 
     if( iobuf_in_block_mode(inp) ) {
 	while( (n = iobuf_read( inp, buf, 100 )) != -1 )
 	    if( (rc = iobuf_write(out, buf, n )) )
 		return rc; /* write error */
     }
     else if( !pktlen && pkttype == PKT_COMPRESSED ) {
 	log_debug("copy_packet: compressed!\n");
 	/* compressed packet, copy till EOF */
 	while( (n = iobuf_read( inp, buf, 100 )) != -1 )
 	    if( (rc = iobuf_write(out, buf, n )) )
 		return rc; /* write error */
     }
     else {
 	for( ; pktlen; pktlen -= n ) {
 	    n = pktlen > 100 ? 100 : pktlen;
 	    n = iobuf_read( inp, buf, n );
 	    if( n == -1 )
               return GPG_ERR_GENERAL; /* FIXME(gcrypt): read error*/;
 	    if( (rc = iobuf_write(out, buf, n )) )
 		return rc; /* write error */
 	}
     }
     return 0;
 }
 
 
 static void
 skip_packet( iobuf_t inp, int pkttype, unsigned long pktlen )
 {
     if( list_mode ) {
 	if( pkttype == PKT_MARKER )
 	    fputs(":marker packet:\n", stdout );
 	else
 	    printf(":unknown packet: type %2d, length %lu\n", pkttype, pktlen);
 	if( pkttype ) {
 	    int c, i=0 ;
 	    if( pkttype != PKT_MARKER )
 		fputs("dump:", stdout );
 	    if( iobuf_in_block_mode(inp) ) {
 		while( (c=iobuf_get(inp)) != -1 )
 		    dump_hex_line(c, &i);
 	    }
 	    else {
 		for( ; pktlen; pktlen-- )
 		    dump_hex_line(iobuf_get(inp), &i);
 	    }
 	    putchar('\n');
 	    return;
 	}
     }
     skip_rest(inp,pktlen);
 }
 
 static void
 skip_rest( iobuf_t inp, unsigned long pktlen )
 {
     if( iobuf_in_block_mode(inp) ) {
 	while( iobuf_get(inp) != -1 )
 		;
     }
     else {
 	for( ; pktlen; pktlen-- )
 	    if( iobuf_get(inp) == -1 )
 		break;
     }
 }
 
 
 static void *
 read_rest( iobuf_t inp, size_t pktlen )
 {
     byte *p;
     int i;
 
     if( iobuf_in_block_mode(inp) ) {
 	log_error("read_rest: can't store stream data\n");
 	p = NULL;
     }
     else {
 	p = xmalloc ( pktlen );
 	for(i=0; pktlen; pktlen--, i++ )
 	    p[i] = iobuf_get(inp);
     }
     return p;
 }
 
 
 
 static int
 parse_symkeyenc( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *packet )
 {
     PKT_symkey_enc *k;
     int rc = 0;
     int i, version, s2kmode, cipher_algo, hash_algo, seskeylen, minlen;
 
     if( pktlen < 4 ) {
 	log_error("packet(%d) too short\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     version = iobuf_get_noeof(inp); pktlen--;
     if( version != 4 ) {
 	log_error("packet(%d) with unknown version %d\n", pkttype, version);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     if( pktlen > 200 ) { /* (we encode the seskeylen in a byte) */
 	log_error("packet(%d) too large\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     cipher_algo = iobuf_get_noeof(inp); pktlen--;
     s2kmode = iobuf_get_noeof(inp); pktlen--;
     hash_algo = iobuf_get_noeof(inp); pktlen--;
     switch( s2kmode ) {
       case 0:  /* simple s2k */
 	minlen = 0;
 	break;
       case 1:  /* salted s2k */
 	minlen = 8;
 	break;
       case 3:  /* iterated+salted s2k */
 	minlen = 9;
 	break;
       default:
 	log_error("unknown S2K %d\n", s2kmode );
 	goto leave;
     }
     if( minlen > pktlen ) {
 	log_error("packet with S2K %d too short\n", s2kmode );
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     seskeylen = pktlen - minlen;
     k = packet->pkt.symkey_enc = xcalloc (1, sizeof *packet->pkt.symkey_enc
 						+ seskeylen - 1 );
     k->version = version;
     k->cipher_algo = cipher_algo;
     k->s2k.mode = s2kmode;
     k->s2k.hash_algo = hash_algo;
     if( s2kmode == 1 || s2kmode == 3 ) {
 	for(i=0; i < 8 && pktlen; i++, pktlen-- )
 	    k->s2k.salt[i] = iobuf_get_noeof(inp);
     }
     if( s2kmode == 3 ) {
 	k->s2k.count = iobuf_get(inp); pktlen--;
     }
     k->seskeylen = seskeylen;
     for(i=0; i < seskeylen && pktlen; i++, pktlen-- )
 	k->seskey[i] = iobuf_get_noeof(inp);
     assert( !pktlen );
 
     if( list_mode ) {
 	printf(":symkey enc packet: version %d, cipher %d, s2k %d, hash %d\n",
 			    version, cipher_algo, s2kmode, hash_algo);
 	if( s2kmode == 1 || s2kmode == 3 ) {
 	    printf("\tsalt ");
 	    for(i=0; i < 8; i++ )
 		printf("%02x", k->s2k.salt[i]);
 	    if( s2kmode == 3 )
 		printf(", count %lu\n", (ulong)k->s2k.count );
 	    printf("\n");
 	}
     }
 
   leave:
     skip_rest(inp, pktlen);
     return rc;
 }
 
 static int
 parse_pubkeyenc( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *packet )
 {
     unsigned int n;
     int rc = 0;
     int i, ndata;
     PKT_pubkey_enc *k;
 
     k = packet->pkt.pubkey_enc = xcalloc (1,sizeof *packet->pkt.pubkey_enc);
     if( pktlen < 12 ) {
 	log_error("packet(%d) too short\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     k->version = iobuf_get_noeof(inp); pktlen--;
     if( k->version != 2 && k->version != 3 ) {
 	log_error("packet(%d) with unknown version %d\n", pkttype, k->version);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     k->keyid[0] = read_32(inp); pktlen -= 4;
     k->keyid[1] = read_32(inp); pktlen -= 4;
     k->pubkey_algo = iobuf_get_noeof(inp); pktlen--;
     k->throw_keyid = 0; /* only used as flag for build_packet */
     if( list_mode )
 	printf(":pubkey enc packet: version %d, algo %d, keyid %08lX%08lX\n",
 	  k->version, k->pubkey_algo, (ulong)k->keyid[0], (ulong)k->keyid[1]);
 
     ndata = pubkey_get_nenc(k->pubkey_algo);
     if( !ndata ) {
 	if( list_mode )
 	    printf("\tunsupported algorithm %d\n", k->pubkey_algo );
 	unknown_pubkey_warning( k->pubkey_algo );
 	k->data[0] = NULL;  /* no need to store the encrypted data */
     }
     else {
 	for( i=0; i < ndata; i++ ) {
 	    n = pktlen;
 	    k->data[i] = mpi_read(inp, &n, 0); pktlen -=n;
 	    if( list_mode ) {
 		printf("\tdata: ");
 		mpi_print(stdout, k->data[i], mpi_print_mode );
 		putchar('\n');
 	    }
             if (!k->data[i])
                 rc = GPG_ERR_INV_PACKET;
 	}
     }
 
   leave:
     skip_rest(inp, pktlen);
     return rc;
 }
 
 
 static void
 dump_sig_subpkt( int hashed, int type, int critical,
 		 const byte *buffer, size_t buflen, size_t length )
 {
     const char *p=NULL;
     int i;
 
     /* The CERT has warning out with explains how to use GNUPG to
      * detect the ARRs - we print our old message here when it is a faked
      * ARR and add an additional notice */
     if ( type == SIGSUBPKT_ARR && !hashed ) {
         printf("\tsubpkt %d len %u (additional recipient request)\n"
                "WARNING: PGP versions > 5.0 and < 6.5.8 will automagically "
                "encrypt to this key and thereby reveal the plaintext to "
                "the owner of this ARR key. Detailed info follows:\n",
                type, (unsigned)length );
     }
     
     buffer++;
     length--;
    
     printf("\t%s%ssubpkt %d len %u (", /*)*/
 	      critical ? "critical ":"",
 	      hashed ? "hashed ":"", type, (unsigned)length );
     if( length > buflen ) {
 	printf("too short: buffer is only %u)\n", (unsigned)buflen );
 	return;
     }
     switch( type ) {
       case SIGSUBPKT_SIG_CREATED:
 	if( length >= 4 )
 	    printf("sig created %s", strtimestamp( buffer_to_u32(buffer) ) );
 	break;
       case SIGSUBPKT_SIG_EXPIRE:
 	if( length >= 4 )
 	    printf("sig expires after %s",
 				     strtimevalue( buffer_to_u32(buffer) ) );
 	break;
       case SIGSUBPKT_EXPORTABLE:
 	if( length )
 	    printf("%sexportable", *buffer? "":"not ");
 	break;
       case SIGSUBPKT_TRUST:
 	if(length!=2)
 	  p="[invalid trust subpacket]";
 	else
 	  printf("trust signature of depth %d, value %d",buffer[0],buffer[1]);
 	break;
       case SIGSUBPKT_REGEXP:
 	if(!length)
 	  p="[invalid regexp subpacket]";
 	else
 	  printf("regular expression: \"%s\"",buffer);
 	break;
       case SIGSUBPKT_REVOCABLE:
 	if( length )
 	    printf("%srevocable", *buffer? "":"not ");
 	break;
       case SIGSUBPKT_KEY_EXPIRE:
 	if( length >= 4 )
 	    printf("key expires after %s",
 				    strtimevalue( buffer_to_u32(buffer) ) );
 	break;
       case SIGSUBPKT_PREF_SYM:
 	fputs("pref-sym-algos:", stdout );
 	for( i=0; i < length; i++ )
 	    printf(" %d", buffer[i] );
 	break;
       case SIGSUBPKT_REV_KEY:
 	fputs("revocation key: ", stdout );
 	if( length < 22 )
 	    p = "[too short]";
 	else {
 	    printf("c=%02x a=%d f=", buffer[0], buffer[1] );
 	    for( i=2; i < length; i++ )
 		printf("%02X", buffer[i] );
 	}
 	break;
       case SIGSUBPKT_ISSUER:
 	if( length >= 8 )
 	    printf("issuer key ID %08lX%08lX",
 		      (ulong)buffer_to_u32(buffer),
 		      (ulong)buffer_to_u32(buffer+4) );
 	break;
       case SIGSUBPKT_NOTATION:
 	{
 	    fputs("notation: ", stdout );
 	    if( length < 8 )
 		p = "[too short]";
 	    else {
 		const byte *s = buffer;
 		size_t n1, n2;
 
 		n1 = (s[4] << 8) | s[5];
 		n2 = (s[6] << 8) | s[7];
 		s += 8;
 		if( 8+n1+n2 != length )
 		    p = "[error]";
 		else {
 		    print_string( stdout, s, n1, ')' );
 		    putc( '=', stdout );
 
 		    if( *buffer & 0x80 )
 		      print_string( stdout, s+n1, n2, ')' );
 		    else
 		      p = "[not human readable]";
 		}
 	    }
 	}
 	break;
       case SIGSUBPKT_PREF_HASH:
 	fputs("pref-hash-algos:", stdout );
 	for( i=0; i < length; i++ )
 	    printf(" %d", buffer[i] );
 	break;
       case SIGSUBPKT_PREF_COMPR:
 	fputs("pref-zip-algos:", stdout );
 	for( i=0; i < length; i++ )
 	    printf(" %d", buffer[i] );
 	break;
       case SIGSUBPKT_KS_FLAGS:
 	fputs("key server preferences:",stdout);
 	for(i=0;i<length;i++)
 	  printf(" %02X", buffer[i]);
 	break;
       case SIGSUBPKT_PREF_KS:
 	p = "preferred key server";
 	break;
       case SIGSUBPKT_PRIMARY_UID:
 	p = "primary user ID";
 	break;
       case SIGSUBPKT_POLICY:
 	fputs("policy: ", stdout );
 	print_string( stdout, buffer, length, ')' );
 	break;
       case SIGSUBPKT_KEY_FLAGS:
         fputs ( "key flags:", stdout );
         for( i=0; i < length; i++ )
             printf(" %02X", buffer[i] );
 	break;
       case SIGSUBPKT_SIGNERS_UID:
 	p = "signer's user ID";
 	break;
       case SIGSUBPKT_REVOC_REASON:
         if( length ) {
 	    printf("revocation reason 0x%02x (", *buffer );
 	    print_string( stdout, buffer+1, length-1, ')' );
 	    p = ")";
 	}
 	break;
       case SIGSUBPKT_ARR:
         fputs("Big Brother's key (ignored): ", stdout );
 	if( length < 22 )
 	    p = "[too short]";
 	else {
 	    printf("c=%02x a=%d f=", buffer[0], buffer[1] );
 	    for( i=2; i < length; i++ )
 		printf("%02X", buffer[i] );
 	}
         break;
       case SIGSUBPKT_FEATURES:
         fputs ( "features:", stdout );
         for( i=0; i < length; i++ )
             printf(" %02x", buffer[i] );
 	break;
       default:
 	if(type>=100 && type<=110)
 	  p="experimental / private subpacket";
 	else
 	  p = "?";
 	break;
     }
 
     printf("%s)\n", p? p: "");
 }
 
 /****************
  * Returns: >= 0 offset into buffer
  *	    -1 unknown type
  *	    -2 unsupported type
  *	    -3 subpacket too short
  */
 int
 parse_one_sig_subpkt( const byte *buffer, size_t n, int type )
 {
     switch( type ) {
       case SIGSUBPKT_REV_KEY:
 	if(n < 22)
 	  break;
 	return 0;
       case SIGSUBPKT_SIG_CREATED:
       case SIGSUBPKT_SIG_EXPIRE:
       case SIGSUBPKT_KEY_EXPIRE:
 	if( n < 4 )
 	    break;
 	return 0;
       case SIGSUBPKT_KEY_FLAGS:
       case SIGSUBPKT_KS_FLAGS:
       case SIGSUBPKT_PREF_SYM:
       case SIGSUBPKT_PREF_HASH:
       case SIGSUBPKT_PREF_COMPR:
       case SIGSUBPKT_POLICY:
       case SIGSUBPKT_FEATURES:
       case SIGSUBPKT_REGEXP:
 	return 0;
       case SIGSUBPKT_EXPORTABLE:
       case SIGSUBPKT_REVOCABLE:
 	if( !n )
 	    break;
 	return 0;
       case SIGSUBPKT_ISSUER: /* issuer key ID */
 	if( n < 8 )
 	    break;
 	return 0;
       case SIGSUBPKT_NOTATION:
 	if( n < 8 ) /* minimum length needed */
 	    break;
 	return 0;
       case SIGSUBPKT_REVOC_REASON:
 	if( !n	)
 	    break;
 	return 0;
       case SIGSUBPKT_PRIMARY_UID:
           if ( n != 1 )
               break;
           return 0;   
       case SIGSUBPKT_TRUST:
 	  if ( n != 2 )
 	      break;
 	  return 0;
       default: return -1;
     }
     return -3;
 }
 
 
 static int
 can_handle_critical( const byte *buffer, size_t n, int type )
 {
     switch( type ) {
       case SIGSUBPKT_NOTATION:
 	if( n >= 8 && (*buffer & 0x80) )
 	    return 1; /* human readable is handled */
 	return 0;
 
       case SIGSUBPKT_SIG_CREATED:
       case SIGSUBPKT_SIG_EXPIRE:
       case SIGSUBPKT_KEY_EXPIRE:
       case SIGSUBPKT_EXPORTABLE:
       case SIGSUBPKT_REVOCABLE:
       case SIGSUBPKT_REV_KEY:
       case SIGSUBPKT_ISSUER:/* issuer key ID */
       case SIGSUBPKT_PREF_SYM:
       case SIGSUBPKT_PREF_HASH:
       case SIGSUBPKT_PREF_COMPR:
       case SIGSUBPKT_KEY_FLAGS:
       case SIGSUBPKT_PRIMARY_UID:
       case SIGSUBPKT_FEATURES:
       case SIGSUBPKT_POLICY: /* Is it enough to show the policy? */
       case SIGSUBPKT_TRUST:
       case SIGSUBPKT_REGEXP:
 	return 1;
 
       default:
 	return 0;
     }
 }
 
 
 const byte *
 enum_sig_subpkt( const subpktarea_t *pktbuf, sigsubpkttype_t reqtype,
 		 size_t *ret_n, int *start, int *critical )
 {
     const byte *buffer;
     int buflen;
     int type;
     int critical_dummy;
     int offset;
     size_t n;
     int seq = 0;
     int reqseq = start? *start: 0;
 
     if(!critical)
       critical=&critical_dummy;
 
     if( !pktbuf || reqseq == -1 ) {
 	/* return some value different from NULL to indicate that
 	 * there is no critical bit we do not understand.  The caller
 	 * will never use the value.  Yes I know, it is an ugly hack */
 	return reqtype == SIGSUBPKT_TEST_CRITICAL? (const byte*)&pktbuf : NULL;
     }
     buffer = pktbuf->data;
     buflen = pktbuf->len;
     while( buflen ) {
 	n = *buffer++; buflen--;
 	if( n == 255 ) { /* 4 byte length header */
 	    if( buflen < 4 )
 		goto too_short;
 	    n = (buffer[0] << 24) | (buffer[1] << 16)
                 | (buffer[2] << 8) | buffer[3];
 	    buffer += 4;
 	    buflen -= 4;
 	}
 	else if( n >= 192 ) { /* 2 byte special encoded length header */
 	    if( buflen < 2 )
 		goto too_short;
 	    n = (( n - 192 ) << 8) + *buffer + 192;
 	    buffer++;
 	    buflen--;
 	}
 	if( buflen < n )
 	    goto too_short;
 	type = *buffer;
 	if( type & 0x80 ) {
 	    type &= 0x7f;
 	    *critical = 1;
 	}
 	else
 	    *critical = 0;
 	if( !(++seq > reqseq) )
 	    ;
 	else if( reqtype == SIGSUBPKT_TEST_CRITICAL ) {
 	    if( *critical ) {
 		if( n-1 > buflen+1 )
 		    goto too_short;
 		if( !can_handle_critical(buffer+1, n-1, type ) )
 		  {
 		    if(opt.verbose)
 		      log_info(_("subpacket of type %d has "
 				 "critical bit set\n"),type);
 		    if( start )
 		      *start = seq;
 		    return NULL; /* this is an error */
 		  }
 	    }
 	}
 	else if( reqtype < 0 ) /* list packets */
 	    dump_sig_subpkt( reqtype == SIGSUBPKT_LIST_HASHED,
 				    type, *critical, buffer, buflen, n );
 	else if( type == reqtype ) { /* found */
 	    buffer++;
 	    n--;
 	    if( n > buflen )
 		goto too_short;
 	    if( ret_n )
 		*ret_n = n;
 	    offset = parse_one_sig_subpkt(buffer, n, type );
 	    switch( offset ) {
 	      case -3:
 		log_error("subpacket of type %d too short\n", type);
 		return NULL;
 	      case -2:
 		return NULL;
 	      case -1:
 		BUG(); /* not yet needed */
 	      default:
 		break;
 	    }
 	    if( start )
 		*start = seq;
 	    return buffer+offset;
 	}
 	buffer += n; buflen -=n;
     }
     if( reqtype == SIGSUBPKT_TEST_CRITICAL )
 	return buffer; /* as value true to indicate that there is no */
 		       /* critical bit we don't understand */
     if( start )
 	*start = -1;
     return NULL; /* end of packets; not found */
 
   too_short:
     log_error("buffer shorter than subpacket\n");
     if( start )
 	*start = -1;
     return NULL;
 }
 
 
 const byte *
 parse_sig_subpkt (const subpktarea_t *buffer, sigsubpkttype_t reqtype,
                   size_t *ret_n)
 {
     return enum_sig_subpkt( buffer, reqtype, ret_n, NULL, NULL );
 }
 
 const byte *
 parse_sig_subpkt2 (PKT_signature *sig, sigsubpkttype_t reqtype,
                    size_t *ret_n )
 {
     const byte *p;
 
     p = parse_sig_subpkt (sig->hashed, reqtype, ret_n );
     if( !p )
 	p = parse_sig_subpkt (sig->unhashed, reqtype, ret_n );
     return p;
 }
 
 /* Find all revocation keys. Look in hashed area only. */
 void parse_revkeys(PKT_signature *sig)
 {
   struct revocation_key *revkey;
   int seq=0;
   size_t len;
 
   if(sig->sig_class!=0x1F)
     return;
 
   while((revkey=
 	 (struct revocation_key *)enum_sig_subpkt(sig->hashed,
 						  SIGSUBPKT_REV_KEY,
 						  &len,&seq,NULL)))
     {
       if(len==sizeof(struct revocation_key) &&
 	 (revkey->class&0x80)) /* 0x80 bit must be set */
 	{
 	  sig->revkey=xrealloc(sig->revkey,
 			  sizeof(struct revocation_key *)*(sig->numrevkeys+1));
 	  sig->revkey[sig->numrevkeys]=revkey;
 	  sig->numrevkeys++;
 	}
     }
 }
 
 static int
 parse_signature( iobuf_t inp, int pkttype, unsigned long pktlen,
 					  PKT_signature *sig )
 {
     int md5_len=0;
     unsigned n;
     int is_v4=0;
     int rc=0;
     int i, ndata;
 
     if( pktlen < 16 ) {
 	log_error("packet(%d) too short\n", pkttype);
 	goto leave;
     }
     sig->version = iobuf_get_noeof(inp); pktlen--;
     if( sig->version == 4 )
 	is_v4=1;
     else if( sig->version != 2 && sig->version != 3 ) {
 	log_error("packet(%d) with unknown version %d\n", pkttype, sig->version);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
 
     if( !is_v4 ) {
 	md5_len = iobuf_get_noeof(inp); pktlen--;
     }
     sig->sig_class = iobuf_get_noeof(inp); pktlen--;
     if( !is_v4 ) {
 	sig->timestamp = read_32(inp); pktlen -= 4;
 	sig->keyid[0] = read_32(inp); pktlen -= 4;
 	sig->keyid[1] = read_32(inp); pktlen -= 4;
     }
     sig->pubkey_algo = iobuf_get_noeof(inp); pktlen--;
     sig->digest_algo = iobuf_get_noeof(inp); pktlen--;
     sig->flags.exportable=1;
     sig->flags.revocable=1;
     if( is_v4 ) { /* read subpackets */
 	n = read_16(inp); pktlen -= 2; /* length of hashed data */
 	if( n > 10000 ) {
 	    log_error("signature packet: hashed data too long\n");
 	    rc = GPG_ERR_INV_PACKET;
 	    goto leave;
 	}
 	if( n ) {
 	    sig->hashed = xmalloc (sizeof (*sig->hashed) + n - 1 );
             sig->hashed->size = n;
 	    sig->hashed->len = n;
 	    if( iobuf_read (inp, sig->hashed->data, n ) != n ) {
 		log_error ("premature eof while reading "
                            "hashed signature data\n");
 		rc = -1;
 		goto leave;
 	    }
 	    pktlen -= n;
 	}
 	n = read_16(inp); pktlen -= 2; /* length of unhashed data */
 	if( n > 10000 ) {
 	    log_error("signature packet: unhashed data too long\n");
 	    rc = GPG_ERR_INV_PACKET;
 	    goto leave;
 	}
 	if( n ) {
             /* we add 8 extra bytes so that we have space for the signature
              * status cache.  Well we are wasting this if there is a cache
              * packet already, but in the other case it avoids an realloc */
 	    sig->unhashed = xmalloc (sizeof(*sig->unhashed) + n + 8 - 1 );
             sig->unhashed->size = n + 8;
 	    sig->unhashed->len = n;
 	    if( iobuf_read(inp, sig->unhashed->data, n ) != n ) {
 		log_error("premature eof while reading "
                           "unhashed signature data\n");
 		rc = -1;
 		goto leave;
 	    }
 	    pktlen -= n;
 	}
     }
 
     if( pktlen < 5 ) { /* sanity check */
 	log_error("packet(%d) too short\n", pkttype);
 	rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
 
     sig->digest_start[0] = iobuf_get_noeof(inp); pktlen--;
     sig->digest_start[1] = iobuf_get_noeof(inp); pktlen--;
 
     if( is_v4 && sig->pubkey_algo ) { /*extract required information */
 	const byte *p;
 	size_t len;
 
 	/* set sig->flags.unknown_critical if there is a
 	 * critical bit set for packets which we do not understand */
 	if( !parse_sig_subpkt (sig->hashed, SIGSUBPKT_TEST_CRITICAL, NULL)
 	   || !parse_sig_subpkt (sig->unhashed, SIGSUBPKT_TEST_CRITICAL,
 									NULL) )
 	{
 	    sig->flags.unknown_critical = 1;
 	}
 
 	p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_SIG_CREATED, NULL );
 	if( !p )
 	    log_error("signature packet without timestamp\n");
 	else
 	    sig->timestamp = buffer_to_u32(p);
 	p = parse_sig_subpkt2( sig, SIGSUBPKT_ISSUER, NULL );
 	if( !p )
 	    log_error("signature packet without keyid\n");
 	else {
 	    sig->keyid[0] = buffer_to_u32(p);
 	    sig->keyid[1] = buffer_to_u32(p+4);
 	}
 
 	p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_SIG_EXPIRE,NULL);
 	if(p)
 	  sig->expiredate=sig->timestamp+buffer_to_u32(p);
 	if(sig->expiredate && sig->expiredate<=make_timestamp())
  	    sig->flags.expired=1;
 
 	p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_POLICY,NULL);
 	if(p)
 	  sig->flags.policy_url=1;
 
 	p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_NOTATION,NULL);
 	if(p)
 	  sig->flags.notation=1;
 
 	p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_REVOCABLE,NULL);
 	if(p && *p==0)
 	  sig->flags.revocable=0;
 
 	p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_TRUST,&len);
 	if(p && len==2)
 	  {
 	    sig->trust_depth=p[0];
 	    sig->trust_value=p[1];
 
 	    /* Only look for a regexp if there is also a trust
 	       subpacket. */
 	    sig->trust_regexp=
 	      parse_sig_subpkt(sig->hashed,SIGSUBPKT_REGEXP,&len);
 
 	    /* If the regular expression is of 0 length, there is no
 	       regular expression. */
 	    if(len==0)
 	      sig->trust_regexp=NULL;
 	  }
 
 	/* We accept the exportable subpacket from either the hashed
 	   or unhashed areas as older versions of gpg put it in the
 	   unhashed area.  In theory, anyway, we should never see this
 	   packet off of a local keyring. */
 
 	p=parse_sig_subpkt2(sig,SIGSUBPKT_EXPORTABLE,NULL);
 	if(p && *p==0)
 	  sig->flags.exportable=0;
 
 	/* Find all revocation keys. */
 	if(sig->sig_class==0x1F)
 	  parse_revkeys(sig);
     }
 
     if( list_mode ) {
 	printf(":signature packet: algo %d, keyid %08lX%08lX\n"
 	       "\tversion %d, created %lu, md5len %d, sigclass %02x\n"
 	       "\tdigest algo %d, begin of digest %02x %02x\n",
 		sig->pubkey_algo,
 		(ulong)sig->keyid[0], (ulong)sig->keyid[1],
 		sig->version, (ulong)sig->timestamp, md5_len, sig->sig_class,
 		sig->digest_algo,
 		sig->digest_start[0], sig->digest_start[1] );
 	if( is_v4 ) {
 	    parse_sig_subpkt (sig->hashed,   SIGSUBPKT_LIST_HASHED, NULL );
 	    parse_sig_subpkt (sig->unhashed, SIGSUBPKT_LIST_UNHASHED, NULL);
 	}
     }
 
     ndata = pubkey_get_nsig(sig->pubkey_algo);
     if( !ndata ) {
 	if( list_mode )
 	    printf("\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
 	 * to write it back with build_packet() */
-	sig->data[0] = mpi_set_opaque(NULL, read_rest(inp, pktlen), pktlen );
+	sig->data[0] = gcry_mpi_set_opaque(NULL, read_rest(inp, pktlen),
+                                           pktlen*8 );
 	pktlen = 0;
     }
     else {
 	for( i=0; i < ndata; i++ ) {
 	    n = pktlen;
 	    sig->data[i] = mpi_read(inp, &n, 0 );
 	    pktlen -=n;
 	    if( list_mode ) {
 		printf("\tdata: ");
 		mpi_print(stdout, sig->data[i], mpi_print_mode );
 		putchar('\n');
 	    }
             if (!sig->data[i])
                 rc = GPG_ERR_INV_PACKET;
 	}
     }
 
   leave:
     skip_rest(inp, pktlen);
     return rc;
 }
 
 
 static int
 parse_onepass_sig( iobuf_t inp, int pkttype, unsigned long pktlen,
 					     PKT_onepass_sig *ops )
 {
     int version;
     int rc = 0;
 
     if( pktlen < 13 ) {
 	log_error("packet(%d) too short\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     version = iobuf_get_noeof(inp); pktlen--;
     if( version != 3 ) {
 	log_error("onepass_sig with unknown version %d\n", version);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     ops->sig_class = iobuf_get_noeof(inp); pktlen--;
     ops->digest_algo = iobuf_get_noeof(inp); pktlen--;
     ops->pubkey_algo = iobuf_get_noeof(inp); pktlen--;
     ops->keyid[0] = read_32(inp); pktlen -= 4;
     ops->keyid[1] = read_32(inp); pktlen -= 4;
     ops->last = iobuf_get_noeof(inp); pktlen--;
     if( list_mode )
 	printf(":onepass_sig packet: keyid %08lX%08lX\n"
 	       "\tversion %d, sigclass %02x, digest %d, pubkey %d, last=%d\n",
 		(ulong)ops->keyid[0], (ulong)ops->keyid[1],
 		version, ops->sig_class,
 		ops->digest_algo, ops->pubkey_algo, ops->last );
 
 
   leave:
     skip_rest(inp, pktlen);
     return rc;
 }
 
 
 static gcry_mpi_t
 read_protected_v3_mpi (iobuf_t inp, unsigned long *length)
 {
   int c;
   unsigned int nbits, nbytes;
   unsigned char *buf, *p;
   gcry_mpi_t val;
 
   if (*length < 2)
     {
       log_error ("mpi too small\n");
       return NULL;
     }
 
   if ((c=iobuf_get (inp)) == -1)
     return NULL;
   --*length;
   nbits = c << 8;
   if ((c=iobuf_get(inp)) == -1)
     return NULL;
   --*length;
   nbits |= c;
 
   if (nbits > 16384)
     {
       log_error ("mpi too large (%u bits)\n", nbits);
       return NULL;
     }
   nbytes = (nbits+7) / 8;
   buf = p = xmalloc (2 + nbytes);
   *p++ = nbits >> 8;
   *p++ = nbits;
   for (; nbytes && length; nbytes--, --*length)
     *p++ = iobuf_get (inp);
   if (nbytes)
     {
       log_error ("packet shorter tham mpi\n");
       xfree (buf);
       return NULL;
     }
 
   /* convert buffer into an opaque gcry_mpi_t */
-  val = mpi_set_opaque (NULL, buf, p-buf); 
+  val = gcry_mpi_set_opaque (NULL, buf, (p-buf)*8); 
   return val;
 }
 
 
 static int
 parse_key( iobuf_t inp, int pkttype, unsigned long pktlen,
 			      byte *hdr, int hdrlen, PACKET *pkt )
 {
     int i, version, algorithm;
     unsigned n;
     unsigned long timestamp, expiredate, max_expiredate;
     int npkey, nskey;
     int is_v4=0;
     int rc=0;
 
     version = iobuf_get_noeof(inp); pktlen--;
     if( pkttype == PKT_PUBLIC_SUBKEY && version == '#' ) {
 	/* early versions of G10 use old PGP comments packets;
 	 * luckily all those comments are started by a hash */
 	if( list_mode ) {
 	    printf(":rfc1991 comment packet: \"" );
 	    for( ; pktlen; pktlen-- ) {
 		int c;
 		c = iobuf_get_noeof(inp);
 		if( c >= ' ' && c <= 'z' )
 		    putchar(c);
 		else
 		    printf("\\x%02x", c );
 	    }
 	    printf("\"\n");
 	}
 	skip_rest(inp, pktlen);
 	return 0;
     }
     else if( version == 4 )
 	is_v4=1;
     else if( version != 2 && version != 3 ) {
 	log_error("packet(%d) with unknown version %d\n", pkttype, version);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
 
     if( pktlen < 11 ) {
 	log_error("packet(%d) too short\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
 
     timestamp = read_32(inp); pktlen -= 4;
     if( is_v4 ) {
 	expiredate = 0; /* have to get it from the selfsignature */
 	max_expiredate = 0;
     }
     else {
 	unsigned short ndays;
 	ndays = read_16(inp); pktlen -= 2;
 	if( ndays )
 	    expiredate = timestamp + ndays * 86400L;
 	else
 	    expiredate = 0;
 
 	max_expiredate=expiredate;
     }
     algorithm = iobuf_get_noeof(inp); pktlen--;
     if( list_mode )
 	printf(":%s key packet:\n"
 	       "\tversion %d, algo %d, created %lu, expires %lu\n",
 		pkttype == PKT_PUBLIC_KEY? "public" :
 		pkttype == PKT_SECRET_KEY? "secret" :
 		pkttype == PKT_PUBLIC_SUBKEY? "public sub" :
 		pkttype == PKT_SECRET_SUBKEY? "secret sub" : "??",
 		version, algorithm, timestamp, expiredate );
 
     if( pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY )  {
 	PKT_secret_key *sk = pkt->pkt.secret_key;
 
 	sk->timestamp = timestamp;
 	sk->expiredate = expiredate;
 	sk->max_expiredate = max_expiredate;
 	sk->hdrbytes = hdrlen;
 	sk->version = version;
 	sk->is_primary = pkttype == PKT_SECRET_KEY;
 	sk->pubkey_algo = algorithm;
 	sk->req_usage = 0; 
 	sk->pubkey_usage = 0; /* not yet used */
     }
     else {
 	PKT_public_key *pk = pkt->pkt.public_key;
 
 	pk->timestamp = timestamp;
 	pk->expiredate = expiredate;
 	pk->max_expiredate = max_expiredate;
 	pk->hdrbytes	= hdrlen;
 	pk->version	= version;
 	pk->is_primary = pkttype == PKT_PUBLIC_KEY;
 	pk->pubkey_algo = algorithm;
 	pk->req_usage = 0; 
 	pk->pubkey_usage = 0; /* not yet used */
         pk->is_revoked = 0;
 	pk->is_disabled = 0;
 	pk->keyid[0] = 0;
 	pk->keyid[1] = 0;
     }
     nskey = pubkey_get_nskey( algorithm );
     npkey = pubkey_get_npkey( algorithm );
     if( !npkey ) {
 	if( list_mode )
 	    printf("\tunknown algorithm %d\n", algorithm );
 	unknown_pubkey_warning( algorithm );
     }
 
 
     if( pkttype == PKT_SECRET_KEY || pkttype == PKT_SECRET_SUBKEY ) {
 	PKT_secret_key *sk = pkt->pkt.secret_key;
 	byte temp[16];
         size_t snlen = 0;
 
 	if( !npkey ) {
-	    sk->skey[0] = mpi_set_opaque( NULL,
-					  read_rest(inp, pktlen), pktlen );
+	    sk->skey[0] = gcry_mpi_set_opaque( NULL, read_rest(inp, pktlen),
+                                               pktlen*8 );
 	    pktlen = 0;
 	    goto leave;
 	}
 
 	for(i=0; i < npkey; i++ ) {
 	    n = pktlen; sk->skey[i] = mpi_read(inp, &n, 0 ); pktlen -=n;
 	    if( list_mode ) {
 		printf(  "\tskey[%d]: ", i);
 		mpi_print(stdout, sk->skey[i], mpi_print_mode  );
 		putchar('\n');
 	    }
             if (!sk->skey[i])
                 rc = GPG_ERR_INV_PACKET;
 	}
         if (rc) /* one of the MPIs were bad */
             goto leave;
 	sk->protect.algo = iobuf_get_noeof(inp); pktlen--;
         sk->protect.sha1chk = 0;
 	if( sk->protect.algo ) {
 	    sk->is_protected = 1;
 	    sk->protect.s2k.count = 0;
 	    if( sk->protect.algo == 254 || sk->protect.algo == 255 ) {
 		if( pktlen < 3 ) {
 		    rc = GPG_ERR_INV_PACKET;
 		    goto leave;
 		}
                 sk->protect.sha1chk = (sk->protect.algo == 254);
 		sk->protect.algo = iobuf_get_noeof(inp); pktlen--;
 		/* Note that a sk->protect.algo > 110 is illegal, but
 		   I'm not erroring on it here as otherwise there
 		   would be no way to delete such a key. */
 		sk->protect.s2k.mode  = iobuf_get_noeof(inp); pktlen--;
 		sk->protect.s2k.hash_algo = iobuf_get_noeof(inp); pktlen--;
 		/* check for the special GNU extension */
 		if( is_v4 && sk->protect.s2k.mode == 101 ) {
 		    for(i=0; i < 4 && pktlen; i++, pktlen-- )
 			temp[i] = iobuf_get_noeof(inp);
 		    if( i < 4 || memcmp( temp, "GNU", 3 ) ) {
 			if( list_mode )
 			    printf(  "\tunknown S2K %d\n",
 						sk->protect.s2k.mode );
 			rc = GPG_ERR_INV_PACKET;
 			goto leave;
 		    }
 		    /* here we know that it is a gnu extension
 		     * What follows is the GNU protection mode:
 		     * All values have special meanings
 		     * and they are mapped in the mode with a base of 1000.
 		     */
 		    sk->protect.s2k.mode = 1000 + temp[3];
 		}
 		switch( sk->protect.s2k.mode ) {
 		  case 1:
 		  case 3:
 		    for(i=0; i < 8 && pktlen; i++, pktlen-- )
 			temp[i] = iobuf_get_noeof(inp);
 		    memcpy(sk->protect.s2k.salt, temp, 8 );
 		    break;
 		}
 		switch( sk->protect.s2k.mode ) {
 		  case 0: if( list_mode ) printf(  "\tsimple S2K" );
 		    break;
 		  case 1: if( list_mode ) printf(  "\tsalted S2K" );
 		    break;
 		  case 3: if( list_mode ) printf(  "\titer+salt S2K" );
 		    break;
 		  case 1001: if( list_mode ) printf(  "\tgnu-dummy S2K" );
 		    break;
 		  case 1002: if (list_mode) printf("\tgnu-divert-to-card S2K");
 		    break;
 		  default:
 		    if( list_mode )
 			printf(  "\tunknown %sS2K %d\n",
 				 sk->protect.s2k.mode < 1000? "":"GNU ",
 						   sk->protect.s2k.mode );
 		    rc = GPG_ERR_INV_PACKET;
 		    goto leave;
 		}
 
 		if( list_mode ) {
 		    printf(", algo: %d,%s hash: %d",
 				     sk->protect.algo,
                                      sk->protect.sha1chk?" SHA1 protection,"
                                                         :" simple checksum,",
 				     sk->protect.s2k.hash_algo );
 		    if( sk->protect.s2k.mode == 1
 			|| sk->protect.s2k.mode == 3 ) {
 			printf(", salt: ");
 			for(i=0; i < 8; i++ )
 			    printf("%02x", sk->protect.s2k.salt[i]);
 		    }
 		    putchar('\n');
 		}
 
 		if( sk->protect.s2k.mode == 3 ) {
 		    if( pktlen < 1 ) {
 			rc = GPG_ERR_INV_PACKET;
 			goto leave;
 		    }
 		    sk->protect.s2k.count = iobuf_get(inp);
 		    pktlen--;
 		    if( list_mode )
 			printf("\tprotect count: %lu\n",
 					    (ulong)sk->protect.s2k.count);
 		}
 		else if( sk->protect.s2k.mode == 1002 ) {
                     /* Read the serial number. */
                     if (pktlen < 1) {
 			rc = GPG_ERR_INV_PACKET;
 			goto leave;
 		    }
 		    snlen = iobuf_get (inp);
 		    pktlen--;
                     if (pktlen < snlen || snlen == -1) {
 			rc = GPG_ERR_INV_PACKET;
 			goto leave;
                     }
 		}
 	    }
 	    /* Note that a sk->protect.algo > 110 is illegal, but I'm
 	       not erroring on it here as otherwise there would be no
 	       way to delete such a key. */
 	    else { /* old version; no S2K, so we set mode to 0, hash MD5 */
 		sk->protect.s2k.mode = 0;
 		sk->protect.s2k.hash_algo = DIGEST_ALGO_MD5;
 		if( list_mode )
 		    printf(  "\tprotect algo: %d  (hash algo: %d)\n",
 			 sk->protect.algo, sk->protect.s2k.hash_algo );
 	    }
 	    /* It is really ugly that we don't know the size
 	     * of the IV here in cases we are not aware of the algorithm.
 	     * so a
 	     *	 sk->protect.ivlen = cipher_get_blocksize(sk->protect.algo);
 	     * won't work.  The only solution I see is to hardwire it here.
 	     * NOTE: if you change the ivlen above 16, don't forget to
 	     * enlarge temp.
 	     */
 	    switch( sk->protect.algo ) {
 	      case 7: case 8: case 9: /* reserved for AES */
 	      case 10: /* Twofish */
 		sk->protect.ivlen = 16;
 		break;
 	      default:
 		sk->protect.ivlen = 8;
 	    }
 	    if( sk->protect.s2k.mode == 1001 )
 		sk->protect.ivlen = 0;
 	    else if( sk->protect.s2k.mode == 1002 ) {
                 if (snlen > 16)
                     log_info ("WARNING: serial number of card truncated\n");
 		sk->protect.ivlen = snlen < 16? snlen : 16;
 
             }
 	    if( pktlen < sk->protect.ivlen ) {
 		rc = GPG_ERR_INV_PACKET;
 		goto leave;
 	    }
 	    for(i=0; i < sk->protect.ivlen && pktlen; i++, pktlen-- )
 		temp[i] = iobuf_get_noeof(inp);
 	    if( list_mode ) {
 		printf( sk->protect.s2k.mode == 1002? "\tserial-number: "
                                                     : "\tprotect IV: ");
 		for(i=0; i < sk->protect.ivlen; i++ )
 		    printf(" %02x", temp[i] );
 		putchar('\n');
 	    }
 	    memcpy(sk->protect.iv, temp, sk->protect.ivlen );
 	}
 	else
 	    sk->is_protected = 0;
 	/* It does not make sense to read it into secure memory.
 	 * If the user is so careless, not to protect his secret key,
 	 * we can assume, that he operates an open system :=(.
 	 * So we put the key into secure memory when we unprotect it. */
 	if( sk->protect.s2k.mode == 1001
             || sk->protect.s2k.mode == 1002 ) {
 	    /* better set some dummy stuff here */
-	    sk->skey[npkey] = mpi_set_opaque(NULL, xstrdup ("dummydata"), 10);
+	    sk->skey[npkey] = gcry_mpi_set_opaque(NULL, xstrdup ("dummydata"),
+                                                  10*8);
 	    pktlen = 0;
 	}
 	else if( is_v4 && sk->is_protected ) {
 	    /* ugly; the length is encrypted too, so we read all
 	     * stuff up to the end of the packet into the first
 	     * skey element */
-	    sk->skey[npkey] = mpi_set_opaque(NULL,
-					     read_rest(inp, pktlen), pktlen );
+	    sk->skey[npkey] = gcry_mpi_set_opaque(NULL, read_rest(inp, pktlen),
+                                                  pktlen*8 );
 	    pktlen = 0;
 	    if( list_mode ) {
 		printf("\tencrypted stuff follows\n");
 	    }
 	}
 	else { /* v3 method: the mpi length is not encrypted */
 	    for(i=npkey; i < nskey; i++ ) {
                 if ( sk->is_protected ) {
                     sk->skey[i] = read_protected_v3_mpi (inp, &pktlen);
                     if( list_mode ) 
                         printf(  "\tskey[%d]: [encrypted]\n", i);
                 }
                 else {
                     n = pktlen;
                     sk->skey[i] = mpi_read(inp, &n, 0 );
                     pktlen -=n;
                     if( list_mode ) {
                         printf(  "\tskey[%d]: ", i);
                         mpi_print(stdout, sk->skey[i], mpi_print_mode  );
                         putchar('\n');
                     }
                 }
 
                 if (!sk->skey[i])
                     rc = GPG_ERR_INV_PACKET;
 	    }
             if (rc)
                 goto leave;
 
 	    sk->csum = read_16(inp); pktlen -= 2;
 	    if( list_mode ) {
 		printf("\tchecksum: %04hx\n", sk->csum);
 	    }
 	}
     }
     else {
 	PKT_public_key *pk = pkt->pkt.public_key;
 
 	if( !npkey ) {
-	    pk->pkey[0] = mpi_set_opaque( NULL,
-					  read_rest(inp, pktlen), pktlen );
+	    pk->pkey[0] = gcry_mpi_set_opaque( NULL, read_rest(inp, pktlen),
+                                               pktlen*8 );
 	    pktlen = 0;
 	    goto leave;
 	}
 
 	for(i=0; i < npkey; i++ ) {
 	    n = pktlen; pk->pkey[i] = mpi_read(inp, &n, 0 ); pktlen -=n;
 	    if( list_mode ) {
 		printf(  "\tpkey[%d]: ", i);
 		mpi_print(stdout, pk->pkey[i], mpi_print_mode  );
 		putchar('\n');
 	    }
             if (!pk->pkey[i])
                 rc = GPG_ERR_INV_PACKET;
 	}
         if (rc)
             goto leave;
     }
 
   leave:
     skip_rest(inp, pktlen);
     return rc;
 }
 
 /* Attribute subpackets have the same format as v4 signature
    subpackets.  This is not part of OpenPGP, but is done in several
    versions of PGP nevertheless. */
 int
 parse_attribute_subpkts(PKT_user_id *uid)
 {
   size_t n;
   int count=0;
   struct user_attribute *attribs=NULL;
   const byte *buffer=uid->attrib_data;
   int buflen=uid->attrib_len;
   byte type;
 
   xfree (uid->attribs);
 
   while(buflen)
     {
       n = *buffer++; buflen--;
       if( n == 255 ) { /* 4 byte length header */
 	if( buflen < 4 )
 	  goto too_short;
 	n = (buffer[0] << 24) | (buffer[1] << 16)
 	  | (buffer[2] << 8) | buffer[3];
 	buffer += 4;
 	buflen -= 4;
       }
       else if( n >= 192 ) { /* 2 byte special encoded length header */
 	if( buflen < 2 )
 	  goto too_short;
 	n = (( n - 192 ) << 8) + *buffer + 192;
 	buffer++;
 	buflen--;
       }
       if( buflen < n )
 	goto too_short;
 
       attribs=xrealloc(attribs,(count+1)*sizeof(struct user_attribute));
       memset(&attribs[count],0,sizeof(struct user_attribute));
 
       type=*buffer;
       buffer++;
       buflen--;
       n--;
 
       attribs[count].type=type;
       attribs[count].data=buffer;
       attribs[count].len=n;
       buffer+=n;
       buflen-=n;
       count++;
     }
 
   uid->attribs=attribs;
   uid->numattribs=count;
   return count;
 
  too_short:
   log_error("buffer shorter than attribute subpacket\n");
   uid->attribs=attribs;
   uid->numattribs=count;
   return count;
 }
 
 static void setup_user_id(PACKET *packet)
 {
   packet->pkt.user_id->ref = 1;
   packet->pkt.user_id->attribs = NULL;
   packet->pkt.user_id->attrib_data = NULL;
   packet->pkt.user_id->attrib_len = 0;
   packet->pkt.user_id->is_primary = 0;
   packet->pkt.user_id->is_revoked = 0;
   packet->pkt.user_id->is_expired = 0;
   packet->pkt.user_id->expiredate = 0;
   packet->pkt.user_id->created = 0;
   packet->pkt.user_id->help_key_usage = 0;
   packet->pkt.user_id->help_key_expire = 0;
   packet->pkt.user_id->prefs = NULL;
   packet->pkt.user_id->namehash = NULL;
 }
 
 static int
 parse_user_id( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *packet )
 {
     byte *p;
 
     packet->pkt.user_id = xmalloc (sizeof *packet->pkt.user_id  + pktlen);
     packet->pkt.user_id->len = pktlen;
 
     setup_user_id(packet);
 
     p = packet->pkt.user_id->name;
     for( ; pktlen; pktlen--, p++ )
 	*p = iobuf_get_noeof(inp);
     *p = 0;
 
     if( list_mode ) {
 	int n = packet->pkt.user_id->len;
 	printf(":user ID packet: \"");
 	/* fixme: Hey why don't we replace this with print_string?? */
 	for(p=packet->pkt.user_id->name; n; p++, n-- ) {
 	    if( *p >= ' ' && *p <= 'z' )
 		putchar(*p);
 	    else
 		printf("\\x%02x", *p );
 	}
 	printf("\"\n");
     }
     return 0;
 }
 
 
 void
 make_attribute_uidname(PKT_user_id *uid, size_t max_namelen)
 {
   assert ( max_namelen > 70 );
   if(uid->numattribs<=0)
     sprintf(uid->name,"[bad attribute packet of size %lu]",uid->attrib_len);
   else if(uid->numattribs>1)
     sprintf(uid->name,"[%d attributes of size %lu]",
 	    uid->numattribs,uid->attrib_len);
   else
     {
       /* Only one attribute, so list it as the "user id" */
 
       if(uid->attribs->type==ATTRIB_IMAGE)
 	{
 	  u32 len;
 	  byte type;
 
 	  if(parse_image_header(uid->attribs,&type,&len))
 	    sprintf(uid->name,"[%.20s image of size %lu]",
 		    image_type_to_string(type,1),(ulong)len);
 	  else
 	    sprintf(uid->name,"[invalid image]");
 	}
       else
 	sprintf(uid->name,"[unknown attribute of size %lu]",
 		(ulong)uid->attribs->len);
     }
 
   uid->len = strlen(uid->name);
 }
 
 static int
 parse_attribute( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *packet )
 {
     byte *p;
 
 #define EXTRA_UID_NAME_SPACE 71
     packet->pkt.user_id = xmalloc (sizeof *packet->pkt.user_id
                                   + EXTRA_UID_NAME_SPACE);
 
     setup_user_id(packet);
 
     packet->pkt.user_id->attrib_data = xmalloc (pktlen);
     packet->pkt.user_id->attrib_len = pktlen;
     p = packet->pkt.user_id->attrib_data;
     for( ; pktlen; pktlen--, p++ )
 	*p = iobuf_get_noeof(inp);
 
     /* Now parse out the individual attribute subpackets.  This is
        somewhat pointless since there is only one currently defined
        attribute type (jpeg), but it is correct by the spec. */
     parse_attribute_subpkts(packet->pkt.user_id);
 
     make_attribute_uidname(packet->pkt.user_id, EXTRA_UID_NAME_SPACE);
 
     if( list_mode ) {
 	printf(":attribute packet: %s\n", packet->pkt.user_id->name );
     }
     return 0;
 }
 
 
 static int
 parse_comment( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *packet )
 {
     byte *p;
 
     packet->pkt.comment = xmalloc (sizeof *packet->pkt.comment + pktlen - 1);
     packet->pkt.comment->len = pktlen;
     p = packet->pkt.comment->data;
     for( ; pktlen; pktlen--, p++ )
 	*p = iobuf_get_noeof(inp);
 
     if( list_mode ) {
 	int n = packet->pkt.comment->len;
 	printf(":%scomment packet: \"", pkttype == PKT_OLD_COMMENT?
 					 "OpenPGP draft " : "" );
 	for(p=packet->pkt.comment->data; n; p++, n-- ) {
 	    if( *p >= ' ' && *p <= 'z' )
 		putchar(*p);
 	    else
 		printf("\\x%02x", *p );
 	}
 	printf("\"\n");
     }
     return 0;
 }
 
 
 static void
 parse_trust( iobuf_t inp, int pkttype, unsigned long pktlen, PACKET *pkt )
 {
   int c;
 
   if (pktlen)
     {
       c = iobuf_get_noeof(inp);
       pktlen--;
       pkt->pkt.ring_trust = xmalloc ( sizeof *pkt->pkt.ring_trust );
       pkt->pkt.ring_trust->trustval = c;
       pkt->pkt.ring_trust->sigcache = 0;
       if (!c && pktlen==1)
         {
           c = iobuf_get_noeof (inp);
           pktlen--;
           /* we require that bit 7 of the sigcache is 0 (easier eof handling)*/
           if ( !(c & 0x80) )
             pkt->pkt.ring_trust->sigcache = c;
         }
       if( list_mode )
 	printf(":trust packet: flag=%02x sigcache=%02x\n",
                pkt->pkt.ring_trust->trustval,
                pkt->pkt.ring_trust->sigcache);
     }
   else
     {
       if( list_mode )
 	printf(":trust packet: empty\n");
     }
   skip_rest (inp, pktlen);
 }
 
 
 static int
 parse_plaintext( iobuf_t inp, int pkttype, unsigned long pktlen,
 					PACKET *pkt, int new_ctb )
 {
     int rc = 0;
     int mode, namelen, partial=0;
     PKT_plaintext *pt;
     byte *p;
     int c, i;
 
     if( pktlen && pktlen < 6 ) {
 	log_error("packet(%d) too short (%lu)\n", pkttype, (ulong)pktlen);
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     /* A packet length of zero indicates partial body length.  A zero
        data length isn't a zero length packet due to the header (mode,
        name, etc), so this is accurate. */
     if(pktlen==0)
       partial=1;
     mode = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
     namelen = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
     pt = pkt->pkt.plaintext = xmalloc (sizeof *pkt->pkt.plaintext + namelen -1);
     pt->new_ctb = new_ctb;
     pt->mode = mode;
     pt->namelen = namelen;
     pt->is_partial = partial;
     if( pktlen ) {
 	for( i=0; pktlen > 4 && i < namelen; pktlen--, i++ )
 	    pt->name[i] = iobuf_get_noeof(inp);
     }
     else {
 	for( i=0; i < namelen; i++ )
 	    if( (c=iobuf_get(inp)) == -1 )
 		break;
 	    else
 		pt->name[i] = c;
     }
     pt->timestamp = read_32(inp); if( pktlen) pktlen -= 4;
     pt->len = pktlen;
     pt->buf = inp;
     pktlen = 0;
 
     if( list_mode ) {
 	printf(":literal data packet:\n"
 	       "\tmode %c, created %lu, name=\"",
 		    mode >= ' ' && mode <'z'? mode : '?',
 		    (ulong)pt->timestamp );
 	for(p=pt->name,i=0; i < namelen; p++, i++ ) {
 	    if( *p >= ' ' && *p <= 'z' )
 		putchar(*p);
 	    else
 		printf("\\x%02x", *p );
 	}
 	printf("\",\n\traw data: %lu bytes\n", (ulong)pt->len );
     }
 
   leave:
     return rc;
 }
 
 
 static int
 parse_compressed( iobuf_t inp, int pkttype, unsigned long pktlen,
 		  PACKET *pkt, int new_ctb )
 {
     PKT_compressed *zd;
 
     /* pktlen is here 0, but data follows
      * (this should be the last object in a file or
      *	the compress algorithm should know the length)
      */
     zd = pkt->pkt.compressed =	xmalloc (sizeof *pkt->pkt.compressed );
     zd->algorithm = iobuf_get_noeof(inp);
     zd->len = 0; /* not used */ 
     zd->new_ctb = new_ctb;
     zd->buf = inp;
     if( list_mode )
 	printf(":compressed packet: algo=%d\n", zd->algorithm);
     return 0;
 }
 
 
 static int
 parse_encrypted( iobuf_t inp, int pkttype, unsigned long pktlen,
 				       PACKET *pkt, int new_ctb )
 {
     int rc = 0;
     PKT_encrypted *ed;
     unsigned long orig_pktlen = pktlen;
 
     ed = pkt->pkt.encrypted =  xmalloc (sizeof *pkt->pkt.encrypted );
     ed->len = pktlen;
     /* we don't know the extralen which is (cipher_blocksize+2)
        because the algorithm ist not specified in this packet.
        However, it is only important to know this for some sanity
        checks on the packet length - it doesn't matter that we can't
        do it */
     ed->extralen = 0;
     ed->buf = NULL;
     ed->new_ctb = new_ctb;
     ed->mdc_method = 0;
     if( pkttype == PKT_ENCRYPTED_MDC ) {
 	/* fixme: add some pktlen sanity checks */
 	int version;
 
 	version = iobuf_get_noeof(inp); 
         if (orig_pktlen)
             pktlen--;
 	if( version != 1 ) {
 	    log_error("encrypted_mdc packet with unknown version %d\n",
 								version);
             /*skip_rest(inp, pktlen); should we really do this? */
             rc = GPG_ERR_INV_PACKET;
 	    goto leave;
 	}
 	ed->mdc_method = DIGEST_ALGO_SHA1;
     }
     if( orig_pktlen && pktlen < 10 ) { /* actually this is blocksize+2 */
 	log_error("packet(%d) too short\n", pkttype);
         rc = GPG_ERR_INV_PACKET;
 	skip_rest(inp, pktlen);
 	goto leave;
     }
     if( list_mode ) {
 	if( orig_pktlen )
 	    printf(":encrypted data packet:\n\tlength: %lu\n", orig_pktlen);
 	else
 	    printf(":encrypted data packet:\n\tlength: unknown\n");
 	if( ed->mdc_method )
 	    printf("\tmdc_method: %d\n", ed->mdc_method );
     }
 
     ed->buf = inp;
     pktlen = 0;
 
   leave:
     return rc;
 }
 
 
 static int
 parse_mdc( iobuf_t inp, int pkttype, unsigned long pktlen,
 				   PACKET *pkt, int new_ctb )
 {
     int rc = 0;
     PKT_mdc *mdc;
     byte *p;
 
     mdc = pkt->pkt.mdc=  xmalloc (sizeof *pkt->pkt.mdc );
     if( list_mode )
 	printf(":mdc packet: length=%lu\n", pktlen);
     if( !new_ctb || pktlen != 20 ) {
 	log_error("mdc_packet with invalid encoding\n");
         rc = GPG_ERR_INV_PACKET;
 	goto leave;
     }
     p = mdc->hash;
     for( ; pktlen; pktlen--, p++ )
 	*p = iobuf_get_noeof(inp);
 
   leave:
     return rc;
 }
 
 
 /*
  * This packet is internally generated by PGG (by armor.c) to
  * transfer some information to the lower layer.  To make sure that
  * this packet is really a GPG faked one and not one comming from outside,
  * we first check that tehre is a unique tag in it.
  * The format of such a control packet is:
  *   n byte  session marker
  *   1 byte  control type CTRLPKT_xxxxx
  *   m byte  control data
  */
 
 static int
 parse_gpg_control( iobuf_t inp,
                    int pkttype, unsigned long pktlen, PACKET *packet )
 {
     byte *p;
     const byte *sesmark;
     size_t sesmarklen;
     int i;
 
     if ( list_mode )
         printf(":packet 63: length %lu ",  pktlen);
 
     sesmark = get_session_marker ( &sesmarklen );
     if ( pktlen < sesmarklen+1 ) /* 1 is for the control bytes */
         goto skipit;
     for( i=0; i < sesmarklen; i++, pktlen-- ) {
 	if ( sesmark[i] != iobuf_get_noeof(inp) )
             goto skipit;
     }
     if ( list_mode )
         puts ("- gpg control packet");
 
     packet->pkt.gpg_control = xmalloc (sizeof *packet->pkt.gpg_control
                                       + pktlen - 1);
     packet->pkt.gpg_control->control = iobuf_get_noeof(inp); pktlen--;
     packet->pkt.gpg_control->datalen = pktlen;
     p = packet->pkt.gpg_control->data;
     for( ; pktlen; pktlen--, p++ )
 	*p = iobuf_get_noeof(inp);
 
     return 0;
 
  skipit:
     if ( list_mode ) {
         int c;
 
         i=0;
         printf("- private (rest length %lu)\n",  pktlen);
         if( iobuf_in_block_mode(inp) ) {
             while( (c=iobuf_get(inp)) != -1 )
                 dump_hex_line(c, &i);
         }
         else {
             for( ; pktlen; pktlen-- )
                 dump_hex_line(iobuf_get(inp), &i);
         }
         putchar('\n');
     }
     skip_rest(inp,pktlen);
     return GPG_ERR_INV_PACKET;
 }
 
 /* create a gpg control packet to be used internally as a placeholder */
 PACKET *
 create_gpg_control( ctrlpkttype_t type, const byte *data, size_t datalen )
 {
     PACKET *packet;
     byte *p;
 
     packet = xmalloc ( sizeof *packet );
     init_packet(packet);
     packet->pkttype = PKT_GPG_CONTROL;
     packet->pkt.gpg_control = xmalloc (sizeof *packet->pkt.gpg_control
                                       + datalen - 1);
     packet->pkt.gpg_control->control = type;
     packet->pkt.gpg_control->datalen = datalen;
     p = packet->pkt.gpg_control->data;
     for( ; datalen; datalen--, p++ )
 	*p = *data++;
 
     return packet;
 }
diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c
index c9bddd2ff..5a7db4c97 100644
--- a/g10/seckey-cert.c
+++ b/g10/seckey-cert.c
@@ -1,454 +1,454 @@
 /* seckey-cert.c -  secret key certificate packet handling
  * Copyright (C) 1998, 1999, 2000, 2001, 2002,
  *               2003 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
 #include "gpg.h"
 #include "util.h"
 #include "memory.h"
 #include "packet.h"
 #include "mpi.h"
 #include "keydb.h"
 #include "cipher.h"
 #include "main.h"
 #include "options.h"
 #include "i18n.h"
 #include "status.h"
 #include "pkglue.h"
 
 static int
 do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
           int *canceled )
 {
     byte *buffer;
     u16 csum=0;
     int i, res;
     unsigned nbytes;
     gpg_error_t rc;
 
     if( sk->is_protected ) { /* remove the protection */
 	DEK *dek = NULL;
 	u32 keyid[4]; /* 4! because we need two of them */
 	CIPHER_HANDLE cipher_hd=NULL;
 	PKT_secret_key *save_sk;
 
 	if( sk->protect.s2k.mode == 1001 ) {
 	    log_info(_("secret key parts are not available\n"));
 	    return GPG_ERR_GENERAL;
 	}
 	if( sk->protect.algo == CIPHER_ALGO_NONE )
 	    BUG();
 	if( openpgp_cipher_test_algo( sk->protect.algo ) ) {
 	    log_info(_("protection algorithm %d%s is not supported\n"),
 			sk->protect.algo,sk->protect.algo==1?" (IDEA)":"" );
 	    if (sk->protect.algo==CIPHER_ALGO_IDEA)
               {
                 write_status (STATUS_RSA_OR_IDEA);
                 idea_cipher_warn (0);
               }
 	    return GPG_ERR_CIPHER_ALGO;
 	}
 	keyid_from_sk( sk, keyid );
 	keyid[2] = keyid[3] = 0;
 	if( !sk->is_primary ) {
             keyid[2] = sk->main_keyid[0];
             keyid[3] = sk->main_keyid[1];
 	}
 	dek = passphrase_to_dek( keyid, sk->pubkey_algo, sk->protect.algo,
 				 &sk->protect.s2k, mode,
                                  tryagain_text, canceled );
         if (!dek && canceled && *canceled)
 	    return GPG_ERR_GENERAL;
 
 	rc = gcry_cipher_open (&cipher_hd, sk->protect.algo,
                                GCRY_CIPHER_MODE_CFB,
                                GCRY_CIPHER_SECURE
                                | (sk->protect.algo >= 100 ?
                                   0 : GCRY_CIPHER_ENABLE_SYNC));
         if (rc)
           log_fatal ("cipher open failed: %s\n", gpg_strerror (rc) );
 
 	rc = gcry_cipher_setkey (cipher_hd, dek->key, dek->keylen);
         if (rc)
           log_fatal ("set key failed: %s\n", gpg_strerror (rc) );
 
 	xfree (dek);
 	save_sk = copy_secret_key( NULL, sk );
 	gcry_cipher_setiv (cipher_hd, sk->protect.iv, sk->protect.ivlen);
 	csum = 0;
 	if( sk->version >= 4 ) {
 	    int ndata;
             unsigned int ndatabits;
 	    byte *p, *data;
             u16 csumc = 0;
 
 	    i = pubkey_get_npkey(sk->pubkey_algo);
             assert( gcry_mpi_get_flag (sk->skey[i], GCRYMPI_FLAG_OPAQUE ));
             p = gcry_mpi_get_opaque( sk->skey[i], &ndatabits );
             ndata = (ndatabits+7)/8;
             if ( ndata > 1 )
                 csumc = p[ndata-2] << 8 | p[ndata-1];
 	    data = gcry_xmalloc_secure ( ndata );
 	    gcry_cipher_decrypt( cipher_hd, data, ndata, p, ndata );
 	    gcry_mpi_release ( sk->skey[i] ); sk->skey[i] = NULL ;
 	    p = data;
             if (sk->protect.sha1chk) {
                 /* This is the new SHA1 checksum method to detect
                    tampering with the key as used by the Klima/Rosa
                    attack */
                 sk->csum = 0;
                 csum = 1;
                 if( ndata < 20 ) 
                     log_error("not enough bytes for SHA-1 checksum\n");
                 else {
                     gcry_md_hd_t h;
 
                     if ( gcry_md_open (&h, DIGEST_ALGO_SHA1, 1))
                         BUG(); /* algo not available */
                     gcry_md_write (h, data, ndata - 20);
                     gcry_md_final (h);
                     if (!memcmp (gcry_md_read (h, DIGEST_ALGO_SHA1),
                                  data + ndata - 20, 20) ) {
                         /* digest does match.  We have to keep the old
                            style checksum in sk->csum, so that the
                            test used for unprotected keys does work.
                            This test gets used when we are adding new
                            keys. */
                         sk->csum = csum = checksum (data, ndata-20);
                     }
                     gcry_md_close (h);
                 }
             }
             else {
                 if( ndata < 2 ) {
                     log_error("not enough bytes for checksum\n");
                     sk->csum = 0;
                     csum = 1;
                 }
                 else {
                     csum = checksum( data, ndata-2);
                     sk->csum = data[ndata-2] << 8 | data[ndata-1];
                     if ( sk->csum != csum ) {
                         /* This is a PGP 7.0.0 workaround */
                         sk->csum = csumc; /* take the encrypted one */
                     }
                 }
             }
                 
             /* must check it here otherwise the mpi_read_xx would fail
                because the length may have an arbitrary value */
             if( sk->csum == csum ) {
                 for( ; i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
 		    assert( gcry_is_secure( p ) );
 		    res = gcry_mpi_scan( &sk->skey[i], GCRYMPI_FMT_PGP,
                                          p, ndata, &nbytes);
 		    if( res )
 			log_bug ("gcry_mpi_scan failed in do_check: %s\n",
                                  gpg_strerror (res));
                     ndata -= nbytes;
                     p += nbytes;
                 }
                 /* Note: at this point ndata should be 2 for a simple
                    checksum or 20 for the sha1 digest */
             }
 	    xfree (data);
 	}
 	else {
 	    for(i=pubkey_get_npkey(sk->pubkey_algo);
 		    i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
                 byte *p;
                 int ndata;
                 unsigned int ndatabits;
 
                 assert( gcry_mpi_get_flag (sk->skey[i], GCRYMPI_FLAG_OPAQUE));
                 p = gcry_mpi_get_opaque( sk->skey[i], &ndatabits );
                 ndata = (ndatabits+7)/8;
                 assert (ndata >= 2);
                 assert (ndata == ((p[0] << 8 | p[1]) + 7)/8 + 2);
                 buffer = gcry_xmalloc_secure (ndata);
 		gcry_cipher_sync (cipher_hd);
                 buffer[0] = p[0];
                 buffer[1] = p[1];
                 gcry_cipher_decrypt (cipher_hd, buffer+2, ndata-2,
                                      p+2, ndata-2);
                 csum += checksum (buffer, ndata);
                 gcry_mpi_release (sk->skey[i]);
 		res = gcry_mpi_scan( &sk->skey[i], GCRYMPI_FMT_USG,
 				     buffer, ndata, &ndata );
 		if( res )
 		    log_bug ("gcry_mpi_scan failed in do_check: %s\n", 
                              gpg_strerror (res));
 
                 assert (sk->skey[i]);
 		xfree (buffer);
 /*  		csum += checksum_mpi (sk->skey[i]); */
 	    }
 	}
 	gcry_cipher_close (cipher_hd);
 	/* now let's see whether we have used the right passphrase */
 	if( csum != sk->csum ) {
 	    copy_secret_key( sk, save_sk );
             passphrase_clear_cache ( keyid, sk->pubkey_algo );
 	    free_secret_key( save_sk );
 	    return gpg_error (GPG_ERR_BAD_PASSPHRASE);
 	}
 	/* the checksum may fail, so we also check the key itself */
 #warning fixme - we need to reenable this
 /*  	res = pubkey_check_secret_key( sk->pubkey_algo, sk->skey ); */
 /*  	if( res ) { */
 /*  	    copy_secret_key( sk, save_sk ); */
 /*              passphrase_clear_cache ( keyid, sk->pubkey_algo ); */
 /*  	    free_secret_key( save_sk ); */
 /*  	    return gpg_error (GPG_ERR_BAD_PASSPHRASE); */
 /*  	} */
 	free_secret_key( save_sk );
 	sk->is_protected = 0;
     }
     else { /* not protected, assume it is okay if the checksum is okay */
 	csum = 0;
 	for(i=pubkey_get_npkey(sk->pubkey_algo);
 		i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
 	    csum += checksum_mpi( sk->skey[i] );
 	}
 	if( csum != sk->csum )
 	    return GPG_ERR_CHECKSUM;
     }
 
     return 0;
 }
 
 
 
 /****************
  * Check the secret key
  * Ask up to 3 (or n) times for a correct passphrase
  * If n is negative, disable the key info prompt and make n=abs(n)
  */
 int
 check_secret_key( PKT_secret_key *sk, int n )
 {
     int rc = gpg_error (GPG_ERR_BAD_PASSPHRASE);
     int i,mode;
 
     if (sk && sk->is_protected && sk->protect.s2k.mode == 1002)
       return 0; /* Let the scdaemon handle it. */
 
     if(n<0)
       {
 	n=abs(n);
 	mode=1;
       }
     else
       mode=0;
 
     if( n < 1 )
 	n = (opt.batch && !opt.use_agent)? 1 : 3; /* use the default value */
 
     for(i=0; i < n && gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE; i++ ) {
         int canceled = 0;
         const char *tryagain = NULL;
 	if (i) {
             tryagain = N_("Invalid passphrase; please try again");
             log_info (_("%s ...\n"), _(tryagain));
         }
 	rc = do_check( sk, tryagain, mode, &canceled );
 	if( gpg_err_code (rc) == GPG_ERR_BAD_PASSPHRASE
             && is_status_enabled() ) {
 	    u32 kid[2];
 	    char buf[50];
 
 	    keyid_from_sk( sk, kid );
 	    sprintf(buf, "%08lX%08lX", (ulong)kid[0], (ulong)kid[1]);
 	    write_status_text( STATUS_BAD_PASSPHRASE, buf );
 	}
 	if( have_static_passphrase() || canceled)
 	    break;
     }
 
     if( !rc )
 	write_status( STATUS_GOOD_PASSPHRASE );
 
     return rc;
 }
 
 /****************
  * check whether the secret key is protected.
  * Returns: 0 not protected, -1 on error or the protection algorithm
  *                           -2 indicates a card stub.
  */
 int
 is_secret_key_protected( PKT_secret_key *sk )
 {
     return sk->is_protected?
                sk->protect.s2k.mode == 1002? -2
                                            : sk->protect.algo : 0;
 }
 
 
 
 /****************
  * Protect the secret key with the passphrase from DEK
  */
 int
 protect_secret_key( PKT_secret_key *sk, DEK *dek )
 {
     int i,j, rc = 0;
     byte *buffer;
     unsigned nbytes;
     u16 csum;
 
     if( !dek )
 	return 0;
 
     if( !sk->is_protected ) { /* okay, apply the protection */
-	CIPHER_HANDLE cipher_hd=NULL;
+	gcry_cipher_hd_t cipher_hd=NULL;
 
 	if( openpgp_cipher_test_algo( sk->protect.algo ) )
           {
 	    rc = gpg_error (GPG_ERR_CIPHER_ALGO); /* unsupport
                                                      protection
                                                      algorithm */
           }
 	else {
 	    print_cipher_algo_note( sk->protect.algo );
 	    rc = gcry_cipher_open (&cipher_hd, sk->protect.algo,
                                    GCRY_CIPHER_MODE_CFB,
                                    GCRY_CIPHER_SECURE
                                    | (sk->protect.algo >= 100 ?
                                       0 : GCRY_CIPHER_ENABLE_SYNC) );
             if (rc)
               BUG();
 	    if( gcry_cipher_setkey( cipher_hd, dek->key, dek->keylen ) )
 		log_info(_("WARNING: Weak key detected"
 			   " - please change passphrase again.\n"));
 	    sk->protect.ivlen = gcry_cipher_get_algo_blklen(sk->protect.algo);
 	    assert( sk->protect.ivlen <= DIM(sk->protect.iv) );
 	    if( sk->protect.ivlen != 8 && sk->protect.ivlen != 16 )
 		BUG(); /* yes, we are very careful */
 	    gcry_randomize (sk->protect.iv, sk->protect.ivlen,
                             GCRY_STRONG_RANDOM);
 	    gcry_cipher_setiv( cipher_hd, sk->protect.iv, sk->protect.ivlen );
 	    if( sk->version >= 4 ) {
                 unsigned char *bufarr[PUBKEY_MAX_NSKEY];
 		unsigned narr[PUBKEY_MAX_NSKEY];
 		unsigned nbits[PUBKEY_MAX_NSKEY];
 		int ndata=0;
 		byte *p, *data;
 
 		for(j=0, i = pubkey_get_npkey(sk->pubkey_algo);
 			i < pubkey_get_nskey(sk->pubkey_algo); i++, j++ ) {
 		    assert( !gcry_mpi_get_flag( sk->skey[i],
                                                 GCRYMPI_FLAG_OPAQUE ));
 
 		    if( gcry_mpi_aprint( GCRYMPI_FMT_USG, bufarr+j,
                                          narr+j, sk->skey[i]))
 			BUG();
 
 		    nbits[j]  = gcry_mpi_get_nbits( sk->skey[i] );
 		    ndata += narr[j] + 2;
 		}
 		for( ; j < PUBKEY_MAX_NSKEY; j++ )
 		    bufarr[j] = NULL;
 		ndata += opt.simple_sk_checksum? 2 : 20; /* for checksum */
 
 		data = xmalloc_secure ( ndata );
 		p = data;
 		for(j=0; j < PUBKEY_MAX_NSKEY && bufarr[j]; j++ ) {
 		    p[0] = nbits[j] >> 8 ;
 		    p[1] = nbits[j];
 		    p += 2;
 		    memcpy(p, bufarr[j], narr[j] );
 		    p += narr[j];
 		    xfree (bufarr[j]);
 		}
                 
                 if (opt.simple_sk_checksum) {
                     log_info (_("generating the deprecated 16-bit checksum"
                               " for secret key protection\n")); 
                     csum = checksum( data, ndata-2);
                     sk->csum = csum;
                     *p++ =	csum >> 8;
                     *p++ =	csum;
                     sk->protect.sha1chk = 0;
                 }
                 else {
                     gcry_md_hd_t h;
 
                     if (gcry_md_open (&h, GCRY_MD_SHA1, 1))
                         BUG(); /* algo not available */
                     gcry_md_write (h, data, ndata - 20);
                     gcry_md_final (h);
                     memcpy (p, gcry_md_read (h, GCRY_MD_SHA1), 20);
                     p += 20;
                     gcry_md_close (h);
                     sk->csum = csum = 0;
                     sk->protect.sha1chk = 1;
                 }
                 assert( p == data+ndata );
 
 		gcry_cipher_encrypt( cipher_hd, data, ndata, NULL, 0 );
 		for(i = pubkey_get_npkey(sk->pubkey_algo);
 			i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
 		    gcry_mpi_release ( sk->skey[i] );
 		    sk->skey[i] = NULL;
 		}
 		i = pubkey_get_npkey(sk->pubkey_algo);
 		sk->skey[i] = gcry_mpi_set_opaque(NULL, data, ndata*8);
 	    }
 	    else {
 		csum = 0;
 		for(i=pubkey_get_npkey(sk->pubkey_algo);
 			i < pubkey_get_nskey(sk->pubkey_algo); i++ ) {
                     byte *data;
 		    unsigned int nbits;
 
 		    csum += checksum_mpi (sk->skey[i]);
 		    if( gcry_mpi_aprint( GCRYMPI_FMT_USG, &buffer,
                                          &nbytes, sk->skey[i] ) )
 			BUG();
 		    gcry_cipher_sync (cipher_hd);
 		    assert (!gcry_mpi_get_flag( sk->skey[i],
                                                 GCRYMPI_FLAG_OPAQUE ));
                     data = xmalloc (nbytes+2);
                     nbits  = gcry_mpi_get_nbits (sk->skey[i]);
                     assert (nbytes == (nbits + 7)/8);
                     data[0] = nbits >> 8;
                     data[1] = nbits;
 		    gcry_cipher_encrypt (cipher_hd, data+2, nbytes,
                                          buffer, nbytes);
 		    xfree ( buffer );
                     
                     gcry_mpi_release (sk->skey[i]);
                     sk->skey[i] = gcry_mpi_set_opaque (NULL, data,
                                                        (nbytes+2)*8);
 		}
 		sk->csum = csum;
 	    }
 	    sk->is_protected = 1;
 	    gcry_cipher_close( cipher_hd );
 	}
     }
     return rc;
 }
diff --git a/g10/status.c b/g10/status.c
index 32e59eef5..432ec575c 100644
--- a/g10/status.c
+++ b/g10/status.c
@@ -1,698 +1,693 @@
 /* status.c
  * Copyright (C) 1998, 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
  *
  * This file is part of GnuPG.
  *
  * GnuPG 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.
  *
  * GnuPG is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  */
 
 #include <config.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
 #include <signal.h>
 #ifdef USE_SHM_COPROCESSING
 #ifdef USE_CAPABILITIES
 #include <sys/capability.h>
 #endif
 #ifdef HAVE_SYS_IPC_H
 #include <sys/types.h>
 #include <sys/ipc.h>
 #endif
 #ifdef HAVE_SYS_SHM_H
 #include <sys/shm.h>
 #endif
 #if defined(HAVE_MLOCK)
 #include <sys/mman.h>
 #endif
 #endif
 
 #include "gpg.h"
 #include "util.h"
 #include "status.h"
 #include "ttyio.h"
 #include "options.h"
 #include "main.h"
 #include "i18n.h"
 #include "cipher.h" /* for progress functions */
 
 #define CONTROL_D ('D' - 'A' + 1)
 
 
 
 static FILE *statusfp;
 
 #ifdef USE_SHM_COPROCESSING
   static int shm_id = -1;
   static volatile char *shm_area;
   static size_t shm_size;
   static int shm_is_locked;
 #endif /*USE_SHM_COPROCESSING*/
 
 
 static void
-progress_cb ( void *ctx, int c )
+progress_cb (void *ctx, const char *what, int printchar, int current, int total)
 {
-    char buf[50];
-
-    if ( c == '\n' )
-	sprintf ( buf, "%.20s X 100 100", (char*)ctx );
-    else
-	sprintf ( buf, "%.20s %c 0 0", (char*)ctx, c );
-    write_status_text ( STATUS_PROGRESS, buf );
+  char buf[150];
+  
+  if (printchar == '\n')
+    printchar = 'X';
+  
+  sprintf (buf, "%.20s %c %d %d", what, printchar, current, total);
+  write_status_text (STATUS_PROGRESS, buf);
 }
 
 static const char *
 get_status_string ( int no ) 
 {
     const char *s;
 
     switch( no ) {
       case STATUS_ENTER  : s = "ENTER"; break;
       case STATUS_LEAVE  : s = "LEAVE"; break;
       case STATUS_ABORT  : s = "ABORT"; break;
       case STATUS_GOODSIG: s = "GOODSIG"; break;
       case STATUS_KEYEXPIRED: s = "KEYEXPIRED"; break;
       case STATUS_KEYREVOKED: s = "KEYREVOKED"; break;
       case STATUS_BADSIG : s = "BADSIG"; break;
       case STATUS_ERRSIG : s = "ERRSIG"; break;
       case STATUS_BADARMOR : s = "BADARMOR"; break;
       case STATUS_RSA_OR_IDEA : s= "RSA_OR_IDEA"; break;
       case STATUS_TRUST_UNDEFINED: s = "TRUST_UNDEFINED"; break;
       case STATUS_TRUST_NEVER	 : s = "TRUST_NEVER"; break;
       case STATUS_TRUST_MARGINAL : s = "TRUST_MARGINAL"; break;
       case STATUS_TRUST_FULLY	 : s = "TRUST_FULLY"; break;
       case STATUS_TRUST_ULTIMATE : s = "TRUST_ULTIMATE"; break;
       case STATUS_GET_BOOL	 : s = "GET_BOOL"; break;
       case STATUS_GET_LINE	 : s = "GET_LINE"; break;
       case STATUS_GET_HIDDEN	 : s = "GET_HIDDEN"; break;
       case STATUS_GOT_IT	 : s = "GOT_IT"; break;
       case STATUS_SHM_INFO	 : s = "SHM_INFO"; break;
       case STATUS_SHM_GET	 : s = "SHM_GET"; break;
       case STATUS_SHM_GET_BOOL	 : s = "SHM_GET_BOOL"; break;
       case STATUS_SHM_GET_HIDDEN : s = "SHM_GET_HIDDEN"; break;
       case STATUS_NEED_PASSPHRASE: s = "NEED_PASSPHRASE"; break;
       case STATUS_VALIDSIG	 : s = "VALIDSIG"; break;
       case STATUS_SIG_ID	 : s = "SIG_ID"; break;
       case STATUS_ENC_TO	 : s = "ENC_TO"; break;
       case STATUS_NODATA	 : s = "NODATA"; break;
       case STATUS_BAD_PASSPHRASE : s = "BAD_PASSPHRASE"; break;
       case STATUS_NO_PUBKEY	 : s = "NO_PUBKEY"; break;
       case STATUS_NO_SECKEY	 : s = "NO_SECKEY"; break;
       case STATUS_NEED_PASSPHRASE_SYM: s = "NEED_PASSPHRASE_SYM"; break;
       case STATUS_DECRYPTION_FAILED: s = "DECRYPTION_FAILED"; break;
       case STATUS_DECRYPTION_OKAY: s = "DECRYPTION_OKAY"; break;
       case STATUS_MISSING_PASSPHRASE: s = "MISSING_PASSPHRASE"; break;
       case STATUS_GOOD_PASSPHRASE : s = "GOOD_PASSPHRASE"; break;
       case STATUS_GOODMDC	 : s = "GOODMDC"; break;
       case STATUS_BADMDC	 : s = "BADMDC"; break;
       case STATUS_ERRMDC	 : s = "ERRMDC"; break;
       case STATUS_IMPORTED	 : s = "IMPORTED"; break;
       case STATUS_IMPORT_OK	 : s = "IMPORT_OK"; break;
       case STATUS_IMPORT_CHECK   : s = "IMPORT_CHECK"; break;
       case STATUS_IMPORT_RES	 : s = "IMPORT_RES"; break;
       case STATUS_FILE_START	 : s = "FILE_START"; break;
       case STATUS_FILE_DONE	 : s = "FILE_DONE"; break;
       case STATUS_FILE_ERROR	 : s = "FILE_ERROR"; break;
       case STATUS_BEGIN_DECRYPTION:s = "BEGIN_DECRYPTION"; break;
       case STATUS_END_DECRYPTION : s = "END_DECRYPTION"; break;
       case STATUS_BEGIN_ENCRYPTION:s = "BEGIN_ENCRYPTION"; break;
       case STATUS_END_ENCRYPTION : s = "END_ENCRYPTION"; break;
       case STATUS_DELETE_PROBLEM : s = "DELETE_PROBLEM"; break;
       case STATUS_PROGRESS	 : s = "PROGRESS"; break;
       case STATUS_SIG_CREATED	 : s = "SIG_CREATED"; break;
       case STATUS_SESSION_KEY	 : s = "SESSION_KEY"; break;
       case STATUS_NOTATION_NAME  : s = "NOTATION_NAME" ; break;
       case STATUS_NOTATION_DATA  : s = "NOTATION_DATA" ; break;
       case STATUS_POLICY_URL     : s = "POLICY_URL" ; break;
       case STATUS_BEGIN_STREAM   : s = "BEGIN_STREAM"; break;
       case STATUS_END_STREAM     : s = "END_STREAM"; break;
       case STATUS_KEY_CREATED    : s = "KEY_CREATED"; break;
       case STATUS_USERID_HINT    : s = "USERID_HINT"; break;
       case STATUS_UNEXPECTED     : s = "UNEXPECTED"; break;
       case STATUS_INV_RECP       : s = "INV_RECP"; break;
       case STATUS_NO_RECP        : s = "NO_RECP"; break;
       case STATUS_ALREADY_SIGNED : s = "ALREADY_SIGNED"; break;
       case STATUS_SIGEXPIRED     : s = "SIGEXPIRED deprecated-use-keyexpired-instead"; break;
       case STATUS_EXPSIG         : s = "EXPSIG"; break;
       case STATUS_EXPKEYSIG      : s = "EXPKEYSIG"; break;
       case STATUS_ATTRIBUTE      : s = "ATTRIBUTE"; break;
       default: s = "?"; break;
     }
     return s;
 }
 
 void
 set_status_fd ( int fd )
 {
     static int last_fd = -1;
 
     if ( fd != -1 && last_fd == fd )
         return;
 
     if ( statusfp && statusfp != stdout && statusfp != stderr )
         fclose (statusfp);
     statusfp = NULL;
     if ( fd == -1 ) 
         return;
 
     if( fd == 1 )
 	statusfp = stdout;
     else if( fd == 2 )
 	statusfp = stderr;
     else
 	statusfp = fdopen( fd, "w" );
     if( !statusfp ) {
 	log_fatal("can't open fd %d for status output: %s\n",
                   fd, strerror(errno));
     }
     last_fd = fd;
-#warning fixme: register progress CBs
-#if 0
-    register_primegen_progress ( progress_cb, "primegen" );
-    register_pk_dsa_progress ( progress_cb, "pk_dsa" );
-    register_pk_elg_progress ( progress_cb, "pk_elg" );
-#endif
+    gcry_set_progress_handler (progress_cb, NULL);
 }
 
 int
 is_status_enabled()
 {
     return !!statusfp;
 }
 
 void
 write_status ( int no )
 {
     write_status_text( no, NULL );
 }
 
 void
 write_status_text ( int no, const char *text)
 {
     if( !statusfp )
 	return;  /* not enabled */
 
     fputs ( "[GNUPG:] ", statusfp );
     fputs ( get_status_string (no), statusfp );
     if( text ) {
         putc ( ' ', statusfp );
         for (; *text; text++) {
             if (*text == '\n')
                 fputs ( "\\n", statusfp );
             else if (*text == '\r')
                 fputs ( "\\r", statusfp );
             else 
                 putc ( *(const byte *)text,  statusfp );
         }
     }
     putc ('\n',statusfp);
     fflush (statusfp);
 }
 
 
 /*
  * Write a status line with a buffer using %XX escapes.  If WRAP is >
  * 0 wrap the line after this length.  If STRING is not NULL it will
  * be prepended to the buffer, no escaping is done for string.
  * A wrap of -1 forces spaces not to be encoded as %20.
  */
 void
 write_status_text_and_buffer ( int no, const char *string,
                                const char *buffer, size_t len, int wrap )
 {
     const char *s, *text;
     int esc, first;
     int lower_limit = ' ';
     size_t n, count, dowrap;
 
     if( !statusfp )
 	return;  /* not enabled */
     
     if (wrap == -1) {
         lower_limit--;
         wrap = 0;
     }
 
     text = get_status_string (no);
     count = dowrap = first = 1;
     do {
         if (dowrap) {
             fprintf (statusfp, "[GNUPG:] %s ", text );
             count = dowrap = 0;
             if (first && string) {
                 fputs (string, statusfp);
                 count += strlen (string);
             }
             first = 0;
         }
         for (esc=0, s=buffer, n=len; n && !esc; s++, n-- ) {
             if ( *s == '%' || *(const byte*)s <= lower_limit 
                            || *(const byte*)s == 127 ) 
                 esc = 1;
             if ( wrap && ++count > wrap ) {
                 dowrap=1;
                 break;
             }
         }
         if (esc) {
             s--; n++;
         }
         if (s != buffer) 
             fwrite (buffer, s-buffer, 1, statusfp );
         if ( esc ) {
             fprintf (statusfp, "%%%02X", *(const byte*)s );
             s++; n--;
         }
         buffer = s;
         len = n;
         if ( dowrap && len )
             putc ( '\n', statusfp );
     } while ( len );
 
     putc ('\n',statusfp);
     fflush (statusfp);
 }
 
 void
 write_status_buffer ( int no, const char *buffer, size_t len, int wrap )
 {
     write_status_text_and_buffer (no, NULL, buffer, len, wrap);
 }
 
 
 
 #ifdef USE_SHM_COPROCESSING
 
 #ifndef IPC_RMID_DEFERRED_RELEASE
 static void
 remove_shmid( void )
 {
     if( shm_id != -1 ) {
 	shmctl ( shm_id, IPC_RMID, 0);
 	shm_id = -1;
     }
 }
 #endif
 
 void
 init_shm_coprocessing ( ulong requested_shm_size, int lock_mem )
 {
     char buf[100];
     struct shmid_ds shmds;
 
 #ifndef IPC_RMID_DEFERRED_RELEASE
     atexit( remove_shmid );
 #endif
     requested_shm_size = (requested_shm_size + 4095) & ~4095;
     if ( requested_shm_size > 2 * 4096 )
 	log_fatal("too much shared memory requested; only 8k are allowed\n");
     shm_size = 4096 /* one page for us */ + requested_shm_size;
 
     shm_id = shmget( IPC_PRIVATE, shm_size, IPC_CREAT | 0700 );
     if ( shm_id == -1 )
 	log_fatal("can't get %uk of shared memory: %s\n",
 				(unsigned)shm_size/1024, strerror(errno));
 
 #if !defined(IPC_HAVE_SHM_LOCK) \
       && defined(HAVE_MLOCK) && !defined(HAVE_BROKEN_MLOCK)
     /* part of the old code which uses mlock */
     shm_area = shmat( shm_id, 0, 0 );
     if ( shm_area == (char*)-1 )
 	log_fatal("can't attach %uk shared memory: %s\n",
 				(unsigned)shm_size/1024, strerror(errno));
     log_debug("mapped %uk shared memory at %p, id=%d\n",
 			    (unsigned)shm_size/1024, shm_area, shm_id );
     if( lock_mem ) {
 #ifdef USE_CAPABILITIES
 	cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
 #endif
 	/* (need the cast for Solaris with Sun's workshop compilers) */
 	if ( mlock ( (char*)shm_area, shm_size) )
 	    log_info("locking shared memory %d failed: %s\n",
 				shm_id, strerror(errno));
 	else
 	    shm_is_locked = 1;
 #ifdef USE_CAPABILITIES
 	cap_set_proc( cap_from_text("cap_ipc_lock+p") );
 #endif
     }
 
 #ifdef IPC_RMID_DEFERRED_RELEASE
     if( shmctl( shm_id, IPC_RMID, 0) )
 	log_fatal("shmctl IPC_RMDID of %d failed: %s\n",
 					    shm_id, strerror(errno));
 #endif
 
     if( shmctl( shm_id, IPC_STAT, &shmds ) )
 	log_fatal("shmctl IPC_STAT of %d failed: %s\n",
 					    shm_id, strerror(errno));
     if( shmds.shm_perm.uid != getuid() ) {
 	shmds.shm_perm.uid = getuid();
 	if( shmctl( shm_id, IPC_SET, &shmds ) )
 	    log_fatal("shmctl IPC_SET of %d failed: %s\n",
 						shm_id, strerror(errno));
     }
 
 #else /* this is the new code which handles the changes in the SHM
        * semantics introduced with Linux 2.4.  The changes is that we
        * now change the permissions and then attach to the memory.
        */
 
     if( lock_mem ) {
 #ifdef USE_CAPABILITIES
 	cap_set_proc( cap_from_text("cap_ipc_lock+ep") );
 #endif
 #ifdef IPC_HAVE_SHM_LOCK
 	if ( shmctl (shm_id, SHM_LOCK, 0) )
 	    log_info("locking shared memory %d failed: %s\n",
 				shm_id, strerror(errno));
 	else
 	    shm_is_locked = 1;
 #else
 	log_info("Locking shared memory %d failed: No way to do it\n", shm_id );
 #endif
 #ifdef USE_CAPABILITIES
 	cap_set_proc( cap_from_text("cap_ipc_lock+p") );
 #endif
     }
 
     if( shmctl( shm_id, IPC_STAT, &shmds ) )
 	log_fatal("shmctl IPC_STAT of %d failed: %s\n",
 					    shm_id, strerror(errno));
     if( shmds.shm_perm.uid != getuid() ) {
 	shmds.shm_perm.uid = getuid();
 	if( shmctl( shm_id, IPC_SET, &shmds ) )
 	    log_fatal("shmctl IPC_SET of %d failed: %s\n",
 						shm_id, strerror(errno));
     }
 
     shm_area = shmat( shm_id, 0, 0 );
     if ( shm_area == (char*)-1 )
 	log_fatal("can't attach %uk shared memory: %s\n",
 				(unsigned)shm_size/1024, strerror(errno));
     log_debug("mapped %uk shared memory at %p, id=%d\n",
 			    (unsigned)shm_size/1024, shm_area, shm_id );
 
 #ifdef IPC_RMID_DEFERRED_RELEASE
     if( shmctl( shm_id, IPC_RMID, 0) )
 	log_fatal("shmctl IPC_RMDID of %d failed: %s\n",
 					    shm_id, strerror(errno));
 #endif
 
 #endif
     /* write info; Protocol version, id, size, locked size */
     sprintf( buf, "pv=1 pid=%d shmid=%d sz=%u lz=%u", (int)getpid(),
 	    shm_id, (unsigned)shm_size, shm_is_locked? (unsigned)shm_size:0 );
     write_status_text( STATUS_SHM_INFO, buf );
 }
 
 /****************
  * Request a string from client
  * If bool, returns static string on true (do not free) or NULL for false
  */
 static char *
 do_shm_get( const char *keyword, int hidden, int bool )
 {
     size_t n;
     byte *p;
     char *string;
 
     if( !shm_area )
 	BUG();
 
     shm_area[0] = 0;  /* msb of length of control block */
     shm_area[1] = 32; /* and lsb */
     shm_area[2] = 1;  /* indicate that we are waiting on a reply */
     shm_area[3] = 0;  /* clear data available flag */
 
     write_status_text( bool? STATUS_SHM_GET_BOOL :
 		       hidden? STATUS_SHM_GET_HIDDEN : STATUS_SHM_GET, keyword );
 
     do {
 	pause_on_sigusr(1);
 	if( shm_area[0] || shm_area[1] != 32 || shm_area[2] != 1 )
 	    log_fatal("client modified shm control block - abort\n");
     } while( !shm_area[3] );
     shm_area[2] = 0; /* reset request flag */
     p = (byte*)shm_area+32;
     n = p[0] << 8 | p[1];
     p += 2;
     if( n+32+2+1 > 4095 )
 	log_fatal("client returns too large data (%u bytes)\n", (unsigned)n );
 
     if( bool )
 	return p[0]? "" : NULL;
 
     string = hidden? xmalloc_secure ( n+1 ) : xmalloc ( n+1 );
     memcpy(string, p, n );
     string[n] = 0; /* make sure it is a string */
     if( hidden ) /* invalidate the memory */
 	memset( p, 0, n );
 
     return string;
 }
 
 #endif /* USE_SHM_COPROCESSING */
 
 static int
 myread(int fd, void *buf, size_t count)
 {
     int rc;
     do {
         rc = read( fd, buf, count );
     } while ( rc == -1 && errno == EINTR );
     if ( !rc && count ) {
         static int eof_emmited=0;
         if ( eof_emmited < 3 ) {
             *(char*)buf = CONTROL_D;
             rc = 1;
             eof_emmited++;
         }
         else { /* Ctrl-D not caught - do something reasonable */
 #ifdef HAVE_DOSISH_SYSTEM
             raise (SIGINT);  /* nothing to hangup under DOS */
 #else
             raise (SIGHUP); /* no more input data */
 #endif
         }
     }    
     return rc;
 }
 
 
 
 /****************
  * Request a string from the client over the command-fd
  * If bool, returns static string on true (do not free) or NULL for false
  */
 static char *
 do_get_from_fd( const char *keyword, int hidden, int bool )
 {
     int i, len;
     char *string;
 
     write_status_text( bool? STATUS_GET_BOOL :
 		       hidden? STATUS_GET_HIDDEN : STATUS_GET_LINE, keyword );
 
     for( string = NULL, i = len = 200; ; i++ ) {
 	if( i >= len-1 ) {
 	    char *save = string;
 	    len += 100;
 	    string = hidden? xmalloc_secure ( len ) : xmalloc ( len );
 	    if( save )
 		memcpy(string, save, i );
 	    else
 		i=0;
 	}
 	/* Hmmm: why not use our read_line function here */
 	if( myread( opt.command_fd, string+i, 1) != 1 || string[i] == '\n'  )
             break;
         else if ( string[i] == CONTROL_D ) {
             /* found ETX - cancel the line and return a sole ETX */
             string[0] = CONTROL_D;
             i=1;
             break;
         }
     }
     string[i] = 0;
 
     write_status( STATUS_GOT_IT );
 
     if( bool )	 /* Fixme: is this correct??? */
 	return (string[0] == 'Y' || string[0] == 'y') ? "" : NULL;
 
     return string;
 }
 
 
 
 int
 cpr_enabled()
 {
     if( opt.command_fd != -1 )
 	return 1;
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return 1;
 #endif
     return 0;
 }
 
 char *
 cpr_get_no_help( const char *keyword, const char *prompt )
 {
     char *p;
 
     if( opt.command_fd != -1 )
 	return do_get_from_fd ( keyword, 0, 0 );
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return do_shm_get( keyword, 0, 0 );
 #endif
     for(;;) {
 	p = tty_get( prompt );
         return p;
     }
 }
 
 char *
 cpr_get( const char *keyword, const char *prompt )
 {
     char *p;
 
     if( opt.command_fd != -1 )
 	return do_get_from_fd ( keyword, 0, 0 );
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return do_shm_get( keyword, 0, 0 );
 #endif
     for(;;) {
 	p = tty_get( prompt );
 	if( *p=='?' && !p[1] && !(keyword && !*keyword)) {
 	    xfree (p);
 	    display_online_help( keyword );
 	}
 	else
 	    return p;
     }
 }
 
 
 char *
 cpr_get_utf8( const char *keyword, const char *prompt )
 {
     char *p;
     p = cpr_get( keyword, prompt );
     if( p ) {
 	char *utf8 = native_to_utf8( p );
 	xfree ( p );
 	p = utf8;
     }
     return p;
 }
 
 char *
 cpr_get_hidden( const char *keyword, const char *prompt )
 {
     char *p;
 
     if( opt.command_fd != -1 )
 	return do_get_from_fd ( keyword, 1, 0 );
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return do_shm_get( keyword, 1, 0 );
 #endif
     for(;;) {
 	p = tty_get_hidden( prompt );
 	if( *p == '?' && !p[1] ) {
 	    xfree (p);
 	    display_online_help( keyword );
 	}
 	else
 	    return p;
     }
 }
 
 void
 cpr_kill_prompt(void)
 {
     if( opt.command_fd != -1 )
 	return;
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return;
 #endif
     tty_kill_prompt();
     return;
 }
 
 int
 cpr_get_answer_is_yes( const char *keyword, const char *prompt )
 {
     int yes;
     char *p;
 
     if( opt.command_fd != -1 )
 	return !!do_get_from_fd ( keyword, 0, 1 );
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return !!do_shm_get( keyword, 0, 1 );
 #endif
     for(;;) {
 	p = tty_get( prompt );
 	trim_spaces(p); /* it is okay to do this here */
 	if( *p == '?' && !p[1] ) {
 	    xfree (p);
 	    display_online_help( keyword );
 	}
 	else {
 	    tty_kill_prompt();
 	    yes = answer_is_yes(p);
 	    xfree (p);
 	    return yes;
 	}
     }
 }
 
 int
 cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt )
 {
     int yes;
     char *p;
 
     if( opt.command_fd != -1 )
 	return !!do_get_from_fd ( keyword, 0, 1 );
 #ifdef USE_SHM_COPROCESSING
     if( opt.shm_coprocess )
 	return !!do_shm_get( keyword, 0, 1 );
 #endif
     for(;;) {
 	p = tty_get( prompt );
 	trim_spaces(p); /* it is okay to do this here */
 	if( *p == '?' && !p[1] ) {
 	    xfree (p);
 	    display_online_help( keyword );
 	}
 	else {
 	    tty_kill_prompt();
 	    yes = answer_is_yes_no_quit(p);
 	    xfree (p);
 	    return yes;
 	}
     }
 }