Page MenuHome GnuPG

No OneTemporary

This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 7df590369..edc6af54a 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,11880 +1,11898 @@
+2005-08-05 Werner Koch <wk@g10code.com>
+
+ * gpgv.c (keyserver_import_fprint): New stub.
+
+ * keygen.c (ask_user_id): Moved email checking code out to ..
+ * misc.c (is_valid_mailbox): .. new.
+ * mainproc.c (get_pka_address): Use it here.
+ * getkey.c (get_pubkey_byname): Add falback to auto-retrieve a key
+ via the PKA mechanism.
+
+ * options.h (KEYSERVER_AUTO_PKA_RETRIEVE): New.
+ * keyserver.c (keyserver_opts): Ditto.
+ * mainproc.c (check_sig_and_print): Use it here to retrieve keys
+ from a PKA DNS record.
+
+ * pkclist.c (build_pk_list): Add comments to this function;
+ re-indented it.
+
2005-08-04 David Shaw <dshaw@jabberwocky.com>
* keygen.c (proc_parameter_file): Sanity check items in keygen
batch file. Noted by Michael Schierl.
* pkclist.c (do_edit_ownertrust): Don't allow ownertrust level 0.
Noted by Michael Schierl.
* keygen.c (write_keyblock): Don't try and build deleted kbnodes
since we start our tree with one.
2005-08-04 Werner Koch <wk@g10code.com>
* export.c (do_export_stream): Skip on-card keys when only subkeys
are to be exported. It does not make sense to replace the on-card
key stub by a no-key stub.
* revoke.c (gen_revoke): Check for non-online keys.
* seckey-cert.c (is_secret_key_protected): Return -3 for
non-online key stubs. The old code assumes that a protection
algorithm is still set but in some cases this one is 0 and thus it
won't be possible to decide whether it is unprotected or
protected.
2005-07-28 Werner Koch <wk@g10code.com>
* Makefile.am (other_libs): Add SRVLIBS.
* parse-packet.c (can_handle_critical_notation): We know about
pka-address@gnupg.org.
* packet.h (PKT_signature): New fields PKA_INFO and PKA_TRIED.
(pka_info_t): New.
* free-packet.c (cp_pka_info): New.
(free_seckey_enc, copy_signature): Support new fields.
* mainproc.c (get_pka_address, pka_uri_from_sig): New.
(check_sig_and_print): Try to get the keyserver from the PKA
record.
* pkclist.c (check_signatures_trust): Adjust the trust based on
the PKA.
* gpgv.c (parse_keyserver_uri): New stub.
* keygen.c (has_invalid_email_chars): Moved to ..
* misc.c (has_invalid_email_chars): .. here and made global.
2005-07-27 Werner Koch <wk@g10code.com>
* export.c (do_export_stream): Make two strings translatable.
2005-07-26 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_typemap): Special-case LDAP since curl
will report that it can handle it, and we don't want it to.
2005-07-26 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Make sure to release the
saved codeset.
(agent_open): Add arg ORIG_CODESET and switch back to it in case
of error. Changed all callers.
2005-07-22 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (sign_uids): Don't prompt for setting signature expiry
to match key expiry unless --ask-cert-expire is set. Suggested by
Peter Palfrader.
2005-07-22 Werner Koch <wk@g10code.com>
* g10.c, options.h: New option --exit-on-status-write-error.
* status.c (write_status_text): Make use of this option.
2005-07-22 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main): Removed option --no-interactive-selection.
* keyedit.c (keyedit_menu): Use --interactive to enable the uid
walking when signing a key with no uids specified to sign.
* keylist.c (list_keyblock_print): Fix silly typo. Noted by Greg
Sabino Mullane.
2005-07-20 Werner Koch <wk@g10code.com>
* openfile.c (open_outfile): Disable FD caching for created files.
* encode.c (encode_simple, encode_crypt): Disable FD caching for
input files.
* verify.c (verify_one_file): Ditto.
* decrypt.c (decrypt_messages): Ditto. This is bug #479.
* misc.c (get_libexecdir) [W32]: Changed to return the value of
program used to create the process.
* keyserver.c (keyserver_spawn) [DISABLE_KEYSERVER_PATH]: Don't
change the exec-path at all.
2005-07-20 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (curl_can_handle): New. Do a runtime check against
libcurl to see if it can handle a particular protocol.
(keyserver_typemap): Call it here.
* Makefile.am: Pull in libcurl for curl_version_info() if used.
2005-07-19 Werner Koch <wk@g10code.com>
* g10.c, options.h: New option --limit-card-insert-tries.
* cardglue.c (open_card): Use it.
* export.c (parse_export_options): New option
export-reset-subkey-passwd.
(do_export_stream): Implement it.
* misc.c (get_libexecdir): New.
* keyserver.c (keyserver_spawn): Use it
2005-07-18 Werner Koch <wk@g10code.com>
* tdbio.c (open_db): Check for EROFS. Suggested by Bryce Nichols.
2005-07-08 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (clean_uids_from_key): Don't keep a valid selfsig
around when compacting a uid. There is no reason to make an
attacker's job easier - this way they only have a revocation which
is useless in bringing the uid back.
* keydb.h, kbnode.c (undelete_kbnode): Removed. No longer needed.
* import.c (chk_self_sigs): Allow a uid revocation to be enough to
allow importing a particular uid (no self sig needed). This
allows importing compacted uids.
2005-06-20 David Shaw <dshaw@jabberwocky.com>
* keygen.c (save_unprotected_key_to_card): Better fix for gcc4
warning.
2005-06-20 Werner Koch <wk@g10code.com>
* g10.c, options.h: New option --no-interactive-selection.
* keyedit.c (keyedit_menu): Use it.
2005-06-18 Werner Koch <wk@g10code.com>
* parse-packet.c (parse_signature): Use log_info for messages
about missing timestamp or keyid. In case we don't use that key
there won't be no further error and thus gpg does not need to
return with an error.
2005-06-13 David Shaw <dshaw@jabberwocky.com>
* keygen.c (save_unprotected_key_to_card): Fix gcc4 warning.
* options.h, import.c (parse_import_options, import_one): Add
import-clean-uids option to automatically compact unusable uids
when importing. Like import-clean-sigs, this may nodify the local
keyring.
* trustdb.c (clean_uids_from_key): Only allow selfsigs to be a
candidate for re-inclusion.
2005-06-12 David Shaw <dshaw@jabberwocky.com>
* options.h, import.c (parse_import_options,
clean_sigs_from_all_uids, import_one): Add import-clean-sigs
option to automatically clean a key when importing. Note that
when importing a key that is already on the local keyring, the
clean applies to the merged key - i.e. existing superceded or
invalid signatures are removed.
* getkey.c (merge_selfsigs_main, merge_selfsigs_subkey): Make sure
that even after keys may be merged together, we only have one
chosen selfsig.
2005-06-09 David Shaw <dshaw@jabberwocky.com>
* options.h, import.c (parse_import_options, delete_inv_parts):
import-unusable-sigs is now a noop.
* options.h, export.c (do_export_stream), keyedit.c (keyedit_menu,
menu_clean_subkeys_from_key), trustdb.h, trustdb.c
(clean_subkeys_from_key): Remove subkey cleaning function. It is
of very limited usefulness since it cannot be used on any subkey
that can sign, and can only affect multiple selfsigs on
encryption-only subkeys.
* keydb.h, kbnode.c (undelete_kbnode): New function to undelete a
kbnode.
* trustdb.c (clean_uids_from_key): Further tweak the algorithm so
that the last good selfsig is kept when the chosen selfsig is a
revocation.
2005-06-08 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (clean_uids_from_key), keyedit.c
(menu_clean_uids_from_key): Tweak algorithm to preserve the last
selfsig which helps prevent uid resurrections.
* getkey.c (fixup_uidnode, merge_selfsigs_main): Handle both
expired and revoked uids in fixup_uidnode(). No need to special
case in merge_selfsigs_main(). This also means that an expired
uid will have its selfsig tagged with chosen_selfsig.
2005-06-07 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), export.c (parse_export_options,
do_export_stream): Add export-options export-clean-sigs,
export-clean-uids, export-clean-subkeys, and export-clean which is
all of the above. Export-minimal is the same except it also
removes all non-selfsigs. export-unusable-sigs is now a noop.
2005-06-06 Werner Koch <wk@g10code.com>
* cardglue.c (open_card): Emit new CARDCTRL status 5 for no reader
available.
2005-06-02 Werner Koch <wk@g10code.com>
* app-openpgp.c (do_writekey): Typo fix.
* status.c, status.h: Removed STATUS_BAD_PASSPHRASE_PIN.
2005-06-01 David Shaw <dshaw@jabberwocky.com>
* signal.c [HAVE_DOSISH_SYSTEM]: Fix unused function warnings on
mingw32. Noted by Joe Vender.
* passphrase.c [_WIN32]: Remove unused variables.
2005-05-31 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (menu_clean_uids_from_key,
menu_clean_subkeys_from_key), trustdb.c (clean_uids_from_key,
clean_subkeys_from_key): Fix mingw32 build warnings. Noted by Joe
Vender.
2005-05-31 Werner Koch <wk@g10code.com>
* keydb.h [!ENABLE_AGENT_SUPPORT]: Define dummy types.
* cardglue.c (assuan_strerror, assuan_transact): Dummy functions
if not build with agent support.
* armor.c (check_input): Don't bail out on invalid header lines
unless in struict rfc2440 mode. Suggested by Richard Patterson.
2005-05-30 Werner Koch <wk@g10code.com>
* tlv.c: Add hack to compile without gpg-error.h.
2005-05-30 David Shaw <dshaw@jabberwocky.com>
* trustdb.h, trustdb.c (clean_subkeys_from_key): New. Walk
through the subkeys on a key, and mark any that aren't usable for
deletion. Note that a signing subkey is never marked for deletion
since these keys are still useful after expiration or revocation.
* keyedit.c (menu_clean_subkeys_from_key): New function to call
clean_subkeys_from_key() on a key. Note that the strings here are
not marked for translation yet. The UI is still in flux, and
there is no point in annoying the translators twice.
(keyedit_menu): Call it here as part of the "clean" command.
2005-05-29 David Shaw <dshaw@jabberwocky.com>
* trustdb.h, trustdb.c (clean_uids_from_key): New. Walk through
the user IDs on a key, and mark any that aren't valid for
deletion.
* keyedit.c (menu_clean_uids_from_key): New function to call
clean_uids_from_key() on a key.
(keyedit_menu): Call it from here as part of the "clean" command.
2005-05-26 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Default {export|import}-unusable-sigs to off until
the "clean" UI can be finished.
2005-05-24 Werner Koch <wk@g10code.com>
* passphrase.c (ask_passphrase): Unescape the description string.
* cardglue.c (unescape_status_string): Removed. Changed all
caller to use ...
* misc.c (unescape_percent_string): New.
* g10.c (add_notation_data): Check number of at-signs.
2005-05-23 Werner Koch <wk@g10code.com>
* app-openpgp.c, app-common.h: Again updated from gnupg 1.9 CVS.
* cardglue.c (open_card): Check USE_AGENT.
(agent_scd_checkpin): Implemented Assuan part.
(agent_scd_change_pin): Ditto.
* g10.c (main): Option --debug-ccid-driver may now be given
several times increase the debug level.
* ccid-driver.c (parse_ccid_descriptor): Mark SCR335 FW version
5.14 as good.
(do_close_reader): Never do a reset. The caller should instead
make sure that the reader has been closed properly. The new retry
code in ccid_slot_status will make sure that the readersatrts up
fine even if the last process didn't closed the USB connection
properly.
(ccid_get_atr): For certain readers try switching to ISO mode.
Thanks to Ludovic Rousseau for this hint and the magic numbers.
(print_command_failed): New.
(bulk_in): Use it here. Add new arg NO_DEBUG.
(ccid_slot_status): Disabled debugging.
2005-05-21 Werner Koch <wk@g10code.com>
* cardglue.c (send_status_info): Make CTRL optional.
(agent_scd_writekey, inq_writekey_parms): New.
(agent_openpgp_storekey): Removed.
* cardglue.h: Add a few more error code mappings.
* keygen.c (copy_mpi): Removed.
(save_unprotected_key_to_card): Changed to use agent_scd_writekey.
* app-common.h, app-openpgp.c, tlv.c, tlv.h: Updated from newer
version in gnupg 1.9 CVS.
2005-05-20 Werner Koch <wk@g10code.com>
* ccid-driver.c (ccid_transceive): Arghhh. The seqno is another
bit in the R-block than in the I block, this was wrong at one
place. Fixes bug #419 and hopefully several others.
2005-05-19 Werner Koch <wk@g10code.com>
* app-common.h, app-openpgp.c, tlv.c, tlv.h: Updated from newer
version in gnupg 1.9 CVS.
2005-05-18 Werner Koch <wk@g10code.com>
* passphrase.c (agent_open): Made global and add arg TRY.
(agent_close): Made global.
* app-common.h (app_t): Add a field to store the Assuan context.
2005-05-13 David Shaw <dshaw@jabberwocky.com>
* build-packet.c (do_comment): Removed.
(build_packet): Ignore comment packets.
* export.c (do_export_stream): Don't export comment packets any
longer.
* options.h, g10.c (main): Remove --sk-comments and
--no-sk-comments options, and replace with no-op.
2005-05-11 David Shaw <dshaw@jabberwocky.com>
* keygen.c (write_selfsigs): Rename from write_selfsig. Write the
same selfsig into both the pk and sk, so that someone importing
their sk (which will get an autoconvert to the pk) won't end up
with two selfsigs.
(do_generate_keypair): Call it from here.
* parse-packet.c (can_handle_critical_notation): New. Check for
particular notation tags that we will accept when critical.
Currently, that's only preferred-email-encoding@pgp.com, since we
know how to handle it (pass it through to a mail program).
(can_handle_critical): Call it from here.
(parse_one_sig_subpkt): Sanity check that notations are
well-formed in that the internal lengths add up to the size of the
subpacket.
2005-05-07 Werner Koch <wk@g10code.com>
* ccid-driver.c (do_close_reader): Don't do a reset before close.
Some folks reported that it makes the SCR335 hang less often.
Look at the source on how to re-enable it.
2005-05-06 David Shaw <dshaw@jabberwocky.com>
* main.h, keygen.c (parse_expire_string, ask_expire_interval),
sign.c (sign_file, clearsign_file, sign_symencrypt_file), g10.c
(main), keyedit.c (sign_uids): Use seconds rather than days
internally to calculate expiration. We no longer need the
day-based code as we don't generate v3 keys.
* sign.c (sign_file, clearsign_file, sign_symencrypt_file): Use
the default sig expire value when signing in batchmode.
2005-05-05 David Shaw <dshaw@jabberwocky.com>
* Makefile.am, packet.h, main.h, comment.c: Remove comment.c. We
don't use any of these functions any longer.
* keygen.c (start_tree): New function to "prime" a KBNODE list.
(do_generate_keypair): Use it here rather than creating and
deleting a comment packet.
* keygen.c (gen_elg, gen_dsa): Do not put public factors in secret
key as a comment.
* options.h, encode.c (encode_simple, encode_crypt), keygen.c
(do_create): Remove disabled comment packet code.
* keygen.c (keygen_set_std_prefs): Add SHA256 and BZip2 to default
preferences.
* options.h, g10.c (main): Add new --default-sig-expire and
--default-cert-expire options. Suggested by Florian Weimer.
* main.h, keygen.c (parse_expire_string, ask_expire_interval): Use
defaults passed in, or "0" to control what default expiration is.
* keyedit.c (sign_uids), sign.c (sign_file, clearsign_file,
sign_symencrypt_file): Call them here, so that default expiration
is used when --ask-xxxxx-expire is off.
2005-05-03 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Add new arg CACHEID.
Changed all callers.
(ask_passphrase): Add new arg CACHEID and use it in agent mode.
Changed all callers.
(passphrase_clear_cache): New arg CACHEID. Changed all callers.
* cardglue.c (format_cacheid): New.
(pin_cb): Compute a cache ID.
(agent_scd_pksign, agent_scd_pkdecrypt): Use it.
(agent_clear_pin_cache): New.
* card-util.c (change_pin): Clear the PIN cache.
(check_pin_for_key_operation): Ditto.
2005-04-24 David Shaw <dshaw@jabberwocky.com>
* trustdb.h, trustdb.c (mark_usable_uid_certs): Add flags for the
no-pubkey and chosen revocation cases.
(clean_uid): New function to clean a user ID of unusable (as
defined by mark_usable_uid_certs) certs.
* keyedit.c (keyedit_menu, menu_clean_uids): Call it here for new
"clean" command that removes unusable sigs from a key.
* trustdb.h, keyedit.c (keyedit_menu, menu_select_uid_namehash):
Allow specifying user ID via the namehash from --with-colons
--fixed-list-mode --list-keys. Suggested by Peter Palfrader.
2005-04-21 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (sign_uids, keyedit_menu): When the user requests to
sign a key without specifying which user IDs to sign, and declines
to sign all user IDs, walk through the set of user IDs and prompt
for which to sign.
* mainproc.c (symkey_decrypt_seskey): There is no need to have an
extra check for a bad passphrase and/or unknown cipher algorithm
here. We'll fail quite happily later, and usually with a better
error message to boot.
2005-04-20 Werner Koch <wk@g10code.com>
* sign.c (sign_file, sign_symencrypt_file): Allow for hash
debugging.
2005-04-16 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_spawn): Free some memory.
* sign.c (hash_for): Comments.
2005-04-11 Werner Koch <wk@g10code.com>
* g10.c (main, add_notation_data, add_policy_url)
(add_keyserver_url): Use isascii() to protect the isfoo macros and
to replace direct tests. Possible problems noted by Christian
Biere.
* keyserver.c (parse_keyserver_uri): Ditto.
2005-04-07 Werner Koch <wk@g10code.com>
* g10.c (main): Declare --pipemode deprecated.
* misc.c (deprecated_command): New.
* ccid-driver.c (ccid_slot_status): Fixed debug messages.
* card-util.c (card_edit): Add command "verify". Enhanced admin
command to allow optional arguments "on", "off" and "verify".
(card_status): Print private DOs in colon mode.
* app-openpgp.c (do_check_pin): Add hack to allow verification of
CHV3.
2005-04-01 Werner Koch <wk@g10code.com>
* keygen.c (keygen_set_std_prefs): Explain the chosen order of
AES key sizes.
2005-04-01 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (proc_plaintext): Properly handle SIG+LITERAL
(old-style PGP) signatures that use hashes other than SHA-1,
RIPEMD160, or MD5.
2005-03-31 David Shaw <dshaw@jabberwocky.com>
* exec.h, exec.c (set_exec_path): Remove some dead code and change
all callers. We no longer need to append to $PATH.
2005-03-31 Werner Koch <wk@g10code.com>
* passphrase.c (agent_open): Dropped support for W32 - is was
never actually used. Removed support for the old non-assuan
protocol; there has never been a matured implementation and
gpg-agent is now arround for quite some time. Rewritten to make
use of the Assuan code from ../util.
(gpga_protocol_codes): Removed.
(readn): Removed.
(agent_close): Simplified for use with Assuan.
(agent_get_passphrase, passphrase_clear_cache): Removed support
for old protocol. Use only with ENABLE_CARD_SUPPORT defined.
(agent_send_all_options): Take assuan context instead of a file
descriptor.
(agent_send_option): Likewise. Use assuan_transact.
* passphrase.c (writen, readaline): Removed.
* g10.c (main): Print a warning if --use-agent has been used but
it has not been build with support for it.
* keydb.c (keydb_add_resource): Clarify meaning of flags. Add new
flag 4. Use log_info for errors registering the default secret key.
* g10.c (main): Flag the default keyrings.
2005-03-30 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_spawn): Don't mess about with the $PATH.
Rather, call keyserver helpers with the full path. This fixes
some PATH-inspired DLL problems on W32. Noted by Carlo Luciano
Bianco.
2005-03-30 Werner Koch <wk@g10code.com>
* cardglue.c (pin_cb): Print a warning if the info string hack is
not there. This may happen due to typos in the translation.
2005-03-22 Werner Koch <wk@g10code.com>
* misc.c (w32_shgetfolderpath) [W32]: Changed declaration of
function ptr. Noted by Tim Costello.
* apdu.c [W32]: Changed declaration of dlopened function pointers.
2005-03-21 David Shaw <dshaw@jabberwocky.com>
* gpgv.c: Stubs for tty_enable_completion() &
tty_disable_completion().
* openfile.c (ask_outfile_name): Enable readline completion when
prompting for an output filename.
* plaintext.c (ask_for_detached_datafile): Enable readline
completion when prompting for a detached sig datafile.
2005-03-21 Werner Koch <wk@g10code.com>
* keyedit.c (command_generator, keyedit_completion): Changed
indentation.
* card-util.c (command_generator, card_edit_completion): Ditto.
2005-03-19 David Shaw <dshaw@jabberwocky.com>
* card-util.c (command_generator, card_edit_completion)
[GNUPG_MAJOR_VERSION==1 && HAVE_LIBREADLINE]: New functions to
enable command completion in the --card-edit menu.
(card_edit): Call them here.
2005-03-18 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (command_generator, keyedit_completion)
[HAVE_LIBREADLINE]: New functions to enable command completion in
the --edit-key menu.
(keyedit_menu): Call them here.
2005-03-17 David Shaw <dshaw@jabberwocky.com>
* getkey.c (get_seckey_byname2): If no explicit default key is
set, don't pick a disabled default. Noted by David Crick.
* Makefile.am: Calculate GNUPG_LIBEXECDIR directly. Do not
redefine $libexecdir.
* options.h, keyserver.c (parse_keyserver_options)
(keyserver_spawn): Don't treat 'verbose' and 'include-disabled' as
special. Just pass them through silently to the keyserver helper.
2005-03-16 Werner Koch <wk@g10code.com>
* ccid-driver.c (parse_ccid_descriptor): Make SCM workaround
reader type specific.
(scan_or_find_devices): Do not check the interface subclass in the
SPR532 kludge, as this depends on the firmware version.
(ccid_get_atr): Get the Slot status first. This solves the
problem with readers hanging on recent Linux 2.6.x.
(bulk_in): Add argument TIMEOUT and changed all callers to pass an
appropriate one. Change the standard timeout from 10 to 5 seconds.
(ccid_slot_status): Add a retry code with an initial short timeout.
(do_close_reader): Do an usb_reset before closing the reader.
2005-03-14 Werner Koch <wk@g10code.com>
* card-util.c (card_status): Use isotimestamp and not the
localized asctimestamp to match the timezone used in the key
information.
* cardglue.c (pin_cb): Disable debug output.
2005-03-11 Werner Koch <wk@g10code.com>
* keygen.c (gen_card_key_with_backup): Write status line with the
backup filename.
* status.h, status.h (STATUS_BACKUP_KEY_CREATED): New.
2005-03-10 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (parse_keyserver_options): Accept honor-http-proxy
as an alias for http-proxy.
* delkey.c (do_delete_key, delete_keys): Fix problem with --expert
preventing --delete-secret-and-public-keys from deleting secret
keys.
2005-03-10 Werner Koch <wk@g10code.com>
* keyedit.c (keyedit_menu) [W32]: Run the trustdb stale check
earlier.
2005-03-07 Werner Koch <wk@g10code.com>
* cardglue.c (agent_scd_pkdecrypt, agent_scd_pksign)
(agent_scd_genkey, agent_scd_setattr, agent_scd_change_pin)
(agent_scd_checkpin, agent_openpgp_storekey): Make sure to send a
SC_OP_FAILURE after card operations which might change data.
* card-util.c (change_pin): Send a SC_OP_SUCCESS after a PIN has
been changed.
(change_name): Removed a debug output.
* status.h, status.c: New codes BAD_PASSPHRASE_PIN, SC_OP_FAILURE
and SC_OP_SUCCESS.
2005-02-24 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Only print the key signing hint when
signing from a place where it is useful (i.e. --edit-key and not
--sign-key).
2005-02-16 Werner Koch <wk@g10code.com>
* card-util.c (fetch_url): Fetch the key from the default
keyserver if no URL is available.
2005-02-15 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Don't call free_public_key
if PK is NULL.
(passphrase_clear_cache): Ditto. Removed debug output.
(passphrase_to_dek): Ditto.
2005-02-13 Werner Koch <wk@g10code.com>
* keyedit.c (cmds): Limit code to 80 columns. Add command
BKUPTOCARD.
2005-02-09 David Shaw <dshaw@jabberwocky.com>
* encr-data.c (decrypt_data): Use it here to turn off the "quick
check" bytes for PK decryptions. This is in regards to the Mister
and Zuccherato attack on OpenPGP CFB mode.
* mainproc.c (proc_symkey_enc): Set a flag to indicate that a
particular session key came from a passphrase and not a PK.
2005-02-08 Werner Koch <wk@g10code.com>
* misc.c (w32_shgetfolderpath): New.
(default_homedir): Use it to avoid problems under Windows95.
2005-02-06 David Shaw <dshaw@jabberwocky.com>
* trustdb.h, trustdb.c (trustdb_check_or_update): New. If the
trustdb is dirty and --interactive is set, do an --update-trustdb.
If not interactive, do a --check_trustdb unless
--no-auto-check-trustdb is set.
* import.c (import_keys_internal): Moved from here.
* keyserver.c (keyserver_refresh): Call it here after all
refreshing has happened so that we don't rebuild after each
preferred keyserver set of imports, but do one big rebuild at the
end. This is Debian bug #293816, noted by Kurt Roeckx.
2005-02-04 David Shaw <dshaw@jabberwocky.com>
* getkey.c (merge_selfsigs_subkey): Merged away definition from
the backsigs code.
2005-01-31 David Shaw <dshaw@jabberwocky.com>
* keygen.c (do_generate_keypair): Write the auth key to the card
before the encryption key. This is a partial workaround for a PGP
bug (as of this writing, all versions including 8.1), that causes
it to try and encrypt to the most recent subkey regardless of
whether that subkey is actually an encryption type. In this case,
the auth key is an RSA key so it succeeds.
2005-01-27 David Shaw <dshaw@jabberwocky.com>
* keyid.c (keyid_from_sk, keyid_from_pk): Use 0xFFFFFFFFFFFFFFFF
instead of 0x0000000000000000 for the invalid key ID since
all-zeroes is reserved for the anonymous recipient.
* keyedit.c (change_passphrase), keygen.c (generate_subkeypair):
Fix a string ;)
2005-01-27 Werner Koch <wk@g10code.com>
* parse-packet.c (listfp): New.
(set_packet_list_mode): Intialize it to stdout or stderr depending
on a global option. Made all printing in list mode use LISTFP.
* keygen.c (generate_subkeypair): Detect primary key on-card and
ask for the passphrase. Return an error if the primary key is a
plain stub.
* keyedit.c (change_passphrase): Don't ever change any stub key.
Print a note if a key consists of only stub keys. Reported by
Dany Nativel. These are bugs #401 and #402.
2005-01-26 Werner Koch <wk@g10code.com>
* ccid-driver.c (parse_ccid_descriptor): Need the CSM workaround
also for newer firmware versions. Need to get a list of fixed
firmware versions and use that.
2005-01-26 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (parse_keyserver_uri): Allow RFC-2732 IPv6 [literal
address] syntax in keyserver URLs.
(keyserver_typemap): Map ftps if we are supporting it.
2005-01-25 Werner Koch <wk@g10code.com>
* keygen.c (do_generate_keypair): Don't continue after an error;
fixed at two places. Why at all didn't I used a goto to cleanup,
tsss?
* app-openpgp.c (get_cached_data): New arg GET_IMMEDIATE to bypass
the cache. Changed all callers.
(get_one_do): Bypass the cache if the value would have been read
directly for v1.1 cards. It makes things a bit slower but only for
1.0 cards and there are not that many cards out in the wild. This
is required to fix a caching bug when generating new keys; as a
side effect of the retrieval of the the C4 DO from the 6E DO the
chaced fingerprint will get updated to the old value and later
when signing the generated key the checking of the fingerprint
fails becuase it won't match the new one. Thanks to Moritz for
analyzing this problem.
(verify_chv3): Removed the CHV status reread logic because we
won't cache the C4 DO anymore.
2005-01-21 David Shaw <dshaw@grover.jabberwocky.com>
* keyserver.c (free_keyserver_spec): Fix small leak.
(keyserver_typemap): Map https if we are supporting it.
2005-01-20 Werner Koch <wk@g10code.com>
* cardglue.c (open_card): Issue new CARDCTRL(4) status.
* gpgv.c (tty_fprintf): New stub.
* card-util.c (card_status): Create a secret key stub on the fly
and print more information about a card key.
* import.c (pub_to_sec_keyblock, auto_create_card_key_stub): New.
* getkey.c (get_seckeyblock_byfprint): New.
* keylist.c (print_card_key_info): New.
* g10.c (i18n_init) [W32]: Pass registry key to gettext
initialization.
* gpgv.c (i18n_init) [W32]: Ditto.
2005-01-18 Werner Koch <wk@g10code.com>
* misc.c (default_homedir): New. Taken from gnupg 1.9.15.
* g10.c (main): Use it.
* gpgv.c (main): Ditto.
* keylist.c (public_key_list): Do a trustdb staleness check before
opening the keyring.
(secret_key_list): Ditto.
2005-01-10 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Move command strings outside the
function to get ready for the readline completion code.
* passphrase.c (readline, agent_send_option, agent_open,
agent_get_passphrase, passphrase_clear_cache): Rename readline()
to readaline() to keep readline library namespace clear.
2005-01-06 David Shaw <dshaw@jabberwocky.com>
* filter.h, armor.c (armor_filter): Use the eol string from the
armor filter context instead of hardcoding '\n' or '\r\n'. If no
eol string is provided, default to '\n' or '\r\n' as appropriate.
(is_armor_header): Trim tabs in armor header lines as well.
* keyserver.c (keyserver_spawn): Use it here to force '\n' line
endings since the keyserver output file gets a LF->CRLF expansion
on win32.
2005-01-05 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Typo.
* armor.c (is_armor_header): Allow CR and LF (not just actual
spaces) in an armor header line (-----BEGIN etc). This is needed
due to CRLF issues on win32. As before, --openpgp makes it
strict.
2005-01-03 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: Use @LIBUSB@ instead of @LIBUSB_LIBS@
* import.c (delete_inv_parts): Comments on import-unusable-sigs.
2005-01-01 David Shaw <dshaw@jabberwocky.com>
* options.h, import.c (parse_import_options, delete_inv_parts):
Add import-unusable-sigs flag to enable importing unusable
(currently: expired) sigs.
* options.h, export.c (parse_export_options, do_export_stream):
Add export-unusable-sigs flag to enable exporting unusable
(currently: expired) sigs.
2004-12-29 David Shaw <dshaw@jabberwocky.com>
* packet.h, getkey.c (merge_selfsigs_main, sig_to_revoke_info),
keyid.c (revokestr_from_pk), keyedit.c (show_key_with_all_names):
Show who revoked a key (either the same key or a designated
revoker) and when.
2004-12-28 Werner Koch <wk@g10code.com>
* ccid-driver.c (find_endpoint): New.
(scan_or_find_devices): Add new args to return endpoint info and
interface number.
(ccid_open_reader, ccid_shutdown_reader): Take care of these new
args.
(bulk_in, bulk_out): Use the correct endpoints.
(ccid_transceive_apdu_level): New.
(ccid_transceive): Divert to above.
(parse_ccid_descriptor): Allow APDU level exchange mode.
(do_close_reader): Pass the interface number to usb_release_interface.
2004-12-24 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_typemap): Only map HTTP and FTP if
libcurl has specifically been selected to handle them.
2004-12-22 David Shaw <dshaw@jabberwocky.com>
* options.h, keyserver.c (parse_keyserver_uri): Properly parse
auth data from URLs and pass to keyserver helpers.
* keyserver.c (keyserver_typemap): New. Map certain keyserver
types to a common type (e.g. ldaps -> ldap). If we are building
with curl, map both http and ftp to curl.
* build-packet.c (build_sig_subpkt): Only allow one preferred
keyserver subpacket at a time.
2004-12-21 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (menu_set_keyserver_url): Make sure we only operate on
the chosen selfsig so we don't accidentally promote an older
selfsig to chosen. Discovered by Simon Josefsson and 'Todd'.
* keygen.c (ask_expire_interval): Fix typo.
2004-12-20 David Shaw <dshaw@jabberwocky.com>
* keylist.c (list_keyblock_print): Secret key listings should
always show everything (expired UIDs, revoked subkeys, etc, etc).
* keyedit.c (keyedit_menu): Add additional help for the "sign"
flags.
2004-12-20 Werner Koch <wk@g10code.com>
* keygen.c (ask_expire_interval): For better translations chnage 2
strings.
* seckey-cert.c (do_check): Handle case when checksum was okay but
passphrase still wrong. Roman Pavlik found such a case.
2004-12-20 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Invisible alias "passwd" as
"password".
* passphrase.c: Don't check for __CYGWIN__, so it is treated as a
unix-like system.
* options.h, g10.c (main), textfilter.c (standard): Use new option
--rfc2440-text to determine whether to filter "<space>\t\r\n" or
just "\r\n" before canonicalizing text line endings. Default to
"<space>\t\r\n".
2004-12-19 David Shaw <dshaw@jabberwocky.com>
* keygen.c (keygen_get_std_prefs): Set reference count when
creating the temporary user ID.
* keyedit.c (keyedit_menu): Merge updpref and setpref. Keep
updpref as an invisible alias. Add invisible alias for revphoto.
Fix small memory leak when using "setpref" (not all of the uid was
freed).
(menu_revkey): Trigger a trust rebuild after revoking a key.
Don't allow revoking an already-revoked whole key.
(menu_revsubkey): Don't allow revoking an already-revoked subkey.
2004-12-18 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (menu_revkey): Rename to menu_revsubkey.
(menu_revkey): New. Revoke a whole key.
(keyedit_menu): Call it here for when 'revkey' is used without any
subkeys selected. This is to be consistent with the other
functions which are "selected part if selected, whole key if not".
* signal.c: Use only HAVE_LIBREADLINE to detect readline
availability.
* Makefile.am: Link with readline where necessary.
2004-12-17 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Define NREAD locally as
size_t or int.
* keylist.c (list_keyblock_print): Make field width an int.
* keyedit.c (show_key_with_all_names): Ditto.
2004-12-16 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Add --require-secmem/--no-require-secmem to cause
gpg to exit if it cannot lock memory. Also remove --nrsign-key
and --nrlsign-key since this can better be done via --edit-key.
2004-12-15 David Shaw <dshaw@jabberwocky.com>
* apdu.c (apdu_send_le, apdu_send_direct), keylist.c
(status_one_subpacket, print_one_subpacket): Fix some compiler
warnings.
* g10.c (main): Fix --compression-algo to take a string argument
like --compress-algo.
* trustdb.c (uid_trust_string_fixed): For safety, check for a pk.
2004-12-14 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Re-remove the N_() markers.
* trustdb.c (uid_trust_string_fixed): Show uids as revoked if the
key is revoked.
* keyedit.c (show_key_with_all_names): Don't show validity for
secret key UIDs.
* keyedit.c (parse_sign_type): New. Figure out the flags (local,
nonrevoke, trust) for a signature.
(keyedit_menu): Call it here so we can mix and match flags, and
don't need "nrltsign", "ltsign", "tnrsign", etc, etc, etc.
2004-12-14 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Removed debug output
* keyserver.c (keyserver_work, keyserver_spawn): Map ldaps to ldap.
* keyedit.c (keyedit_menu): Removed the N_() markers from the
command names.
* card-util.c (card_edit): Ditto.
2004-12-13 Werner Koch <wk@g10code.com>
* passphrase.c (read_passphrase_from_fd): Fixed memory leak.
Noted by Andrei Darashenka.
2004-12-11 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (parse_preferred_keyserver): Force preferred
keyserver subpackets to have a URI scheme specified.
2004-12-10 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), textfilter.c (standard): Use --rfc2440
or --openpgp directly to determine the end of line hashing rule.
* trustdb.c (uid_trust_string_fixed): Show uids as expired if the
key is expired.
2004-12-10 Werner Koch <wk@g10code.com>
* app-openpgp.c (send_fprtime_if_not_null): New.
(do_getattr): Add KEY_TIME.
(do_learn_status): Print KEY_TIME.
* cardglue.c (learn_status_cb): Parse KEY-TIME.
* card-util.c (card_status): Print creation time if available.
2004-12-09 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), textfilter.c (len_without_trailing_ws):
Removed (not used).
(standard): 2440 says that textmode hashes should canonicalize
line endings to CRLF and remove spaces and tabs. 2440bis-12 says
to just canonicalize to CRLF. So, we default to the 2440bis-12
behavior, but revert to the strict 2440 behavior if the user
specifies --rfc2440. In practical terms this makes no difference
to any signatures in the real world except for a textmode detached
signature.
2004-12-09 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): New args CUSTOM_PROMPT and
CUSTOM_DESCRIPTION. Changed all callers.
* app-openpgp.c (do_getattr, do_learn_status, do_setattr): Support
the new private DOs.
(do_change_pin): Add a "N" prefix to the strings so that the
callback can act accordingly for a new PIN. Unfortunately this
breaks existing translations but I see no wother way to overvome
this.
* cardglue.c (learn_status_cb): Ditto.
(agent_release_card_info): Ditto.
(struct pin_cb_info_s): Removed and changed all users.
(pin_cb): Reworked.
* card-util.c (card_status): Print them
(card_edit): New command PRIVATEDO.
(change_private_do): New.
2004-12-09 David Shaw <dshaw@jabberwocky.com>
* keygen.c (ask_algo): Add a choose-your-own-capabilities option
for DSA.
2004-12-07 David Shaw <dshaw@jabberwocky.com>
* keygen.c (ask_keysize): Change strings to always use %u instead
of hardcoding key sizes. Bump default to 2048. Bump minimum down
to 512, where possible, but require --expert to get there. DSA is
always 1024 unless --expert is given.
2004-11-29 David Shaw <dshaw@jabberwocky.com>
* getkey.c (parse_key_usage): New function to parse out key usage
flags. Set PUBKEY_USAGE_UNKNOWN to handle flags that we don't
understand.
(fixup_uidnode, merge_selfsigs_main, merge_selfsigs_subkey): Call
it from here to remove duplicate code.
2004-11-26 David Shaw <dshaw@jabberwocky.com>
* export.c (do_export_stream): Allow export-minimal to work with
secret keys, even though a non-selfsig secret key signature is
rare.
* options.h, export.c (parse_export_options, do_export_stream),
import.c (parse_import_options, import_keys_internal): Make the
import-options and export-options distinct since they can be mixed
together as part of keyserver-options.
2004-11-24 David Shaw <dshaw@jabberwocky.com>
* options.h, export.c (parse_export_options, do_export_stream):
Add "export-minimal" option to disregard any sigs except selfsigs.
* trustdb.c (uid_trust_string_fixed): Use a string that can be
atoi-ed, but also has a comment for the translator.
* trustdb.h, trustdb.c (uid_trust_string_fixed): New. Return a
fixed-size translatable string similar to trust_value_to_string.
This allows for easier lining up of displays.
* keyedit.c (show_key_with_all_names), keylist.c
(list_keyblock_print): Use it here to print validity strings.
* gpgv.c: Stub.
2004-11-18 Werner Koch <wk@g10code.com>
* g10.c (S_IRGRP) [HAVE_DOSISH_SYSTEM]: Define to 0.
2004-11-17 Werner Koch <wk@g10code.com>
* g10.c (open_info_file): New.
(main): Unconditionally implement --status-file, --logger-file,
--attribute-file, --passphrase-file, --command-file. This is not
generally useful but easy to support and might make scripting
under Windows easier.
2004-11-11 Werner Koch <wk@g10code.com>
* passphrase.c (readn): Fixed test against EINTR.
2004-11-05 Werner Koch <wk@g10code.com>
* app-openpgp.c: Made more strings translatable.
(verify_chv3, do_change_pin): Add a special prefix to the prompt
of the Admin PIN prompts.
* passphrase.c (ask_passphrase): Add arg TRYAGAIN_TEXT. Changed
call callers.
* cardglue.c (pin_cb): Make use of the OPAQUE arg to pass
arguments to the PIN callback. Use this to implement a way to
check for correct PIN repetition. Changed all callers to pass an
opaque argument. Improved detection of Admin PIN prompts.
2004-11-04 David Shaw <dshaw@jabberwocky.com>
* plaintext.c (handle_plaintext): Don't try and create a
zero-length filename when using --use-embedded-filename with input
that has no filename (clearsigned or message generated from a
pipe).
* encode.c (encode_simple, encode_crypt), progress.c
(handle_progress), sign.c (write_plaintext_packet): Fix a few
inconsistent calls (NULL filename means a pipe here, so don't
bother to check it twice).
2004-11-03 David Shaw <dshaw@jabberwocky.com>
* misc.c (print_digest_algo_note): The latest 2440bis drafts
deprecates MD5, so give a warning.
(print_pubkey_algo_note, print_cipher_algo_note,
print_digest_algo_note): Give the algorithm name in the
experimental algo warning.
2004-11-03 Timo Schulz <twoaday@g10code.com>
* passphrase.c (readn, writen): Use w32_strerror instead
of just showing the error number.
* misc.c [_WIN32]: Fix warning about missing prototypes.
2004-10-28 David Shaw <dshaw@jabberwocky.com>
* skclist.c (build_sk_list): Don't need to warn about
PGP-generated Elgamal signing keys since we no longer support any
Elgamal signing keys.
* sign.c (sign_file, clearsign_file): Use "writing to" instead of
"writing to file" to match other strings.
* pkclist.c (check_signatures_trust): Fix typo. Noted by Moray
Allan. This is Debian bug #278708.
* passphrase.c (ask_passphrase, passphrase_to_dek): "password" ->
"passphrase".
* keyedit.c (show_key_with_all_names): Show designated revoker as
part of translatable string.
2004-10-28 Werner Koch <wk@g10code.com>
* Makefile.am (other_libs): New. Also include LIBICONV. Noted by
Tim Mooney.
2004-10-28 Werner Koch <wk@g10code.com>
* apdu.c (open_pcsc_reader): Removed bad free in error handler.
2004-10-27 David Shaw <dshaw@jabberwocky.com>
* card-util.c, delkey.c, keygen.c, plaintext.c, keyedit.c,
passphrase.c, revoke.c: Collapse the two different "can't do that
in batch mode" strings into one.
* keylist.c (status_one_subpacket): New. Send the subpacket data
to the --status interface.
* card-util.c (card_edit): Show when admin is enabled or not.
* status.h, status.c: New STATUS_SIG_SUBPACKET type.
* build-packet.c (build_sig_subpkt): Multiple keyserver URLs are
allowed.
* keyring.c: Make some strings translatable.
* exec.c, sign.c: Change "can't open file" to "can't open" and
"can't create file" to "can't create" to be consistent with other
strings so we don't have to translate both.
* delkey.c, export.c, keyedit.c, pkclist.c, revoke.c, skclist.c:
Fix a few missed possible \"username\" quotes.
2004-10-26 Werner Koch <wk@g10code.com>
* app-openpgp.c (verify_chv3): The minimum length for CHV3 is
8. Changed string to match the other ones.
* passphrase.c (agent_send_all_options): Try to deduce the ttyname
from stdin.
2004-10-22 Werner Koch <wk@g10code.com>
* card-util.c (fetch_url): Disable for gnupg 1.9
(card_generate_subkey): Ditto.
(card_store_subkey): Ditto.
2004-10-21 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), mainproc.c (check_sig_and_print):
Rename verify-option show-validity to show-uid-validity to match
the similar list-option.
* app-openpgp.c (verify_chv3): Fix typo.
2004-10-21 Werner Koch <wk@g10code.com>
* app-common.h (app_openpgp_storekey): Add prototype.
* app-openpgp.c (do_sign): Replace asprintf by direct allocation.
This avoids problems with missing vasprintf implementations.
* card-util.c (generate_card_keys): Add a #warning for gnupg 1.9
and use the same string there.
2004-10-20 David Shaw <dshaw@jabberwocky.com>
* g10.c (parse_list_options): Fix non-constant initializer so we
can build with C89.
2004-10-17 David Shaw <dshaw@jabberwocky.com>
* keylist.c (print_one_subpacket): The flags field should be hex.
2004-10-17 Werner Koch <wk@g10code.com>
* passphrase.c (agent_get_passphrase): Cast UIDLEN to int. Noted
by Christian Cornelssen.
2004-10-16 David Shaw <dshaw@jabberwocky.com>
* parse-packet.c (parse_one_sig_subpkt, enum_sig_subpkt): Don't
BUG() on unknown subpackets. Rather, just return them silently.
2004-10-15 Werner Koch <wk@g10code.com>
* status.h (STATUS_NEED_PASSPHRASE_PIN): New.
* status.c (get_status_string): Added.
* passphrase.c (ask_passphrase): Moved status printing to ..
* cardglue.c (pin_cb): .. here and issue new status message.
* keyedit.c (sign_uids): Don't include the leading LF in the
translatable string but print them separately.
* apdu.c (apdu_open_remote_reader) [_WIN32]: We don't have ENOSYS.
* app-openpgp.c (parse_login_data): New.
(app_select_openpgp): Call it.
(do_setattr): Reparse it after change.
* pkclist.c (do_edit_ownertrust): Add a note to translators.
* keygen.c (ask_user_id): Ditto.
* helptext.c: Typo fix.
2004-10-14 David Shaw <dshaw@jabberwocky.com>
* keylist.c (list_keyblock_print): Show the fingerprint after the
key, not after the first user ID.
* keyedit.c (show_key_with_all_names): Don't show validity if
we're just printing user IDs for signing.
* armor.c (fake_packet): Properly handle the case where the line
is dash-space (i.e. a blank line that was quoted). Give a warning
for bad dash escaping.
2004-10-14 Werner Koch <wk@g10code.com>
* export.c (do_export_stream) [ENABLE_SELINUX_HACKS]: Don't allow
secret key export.
* import.c (import_secret_one) [ENABLE_SELINUX_HACKS]: Likewise
* misc.c (is_secured_filename): New.
* keydb.c (maybe_create_keyring)
* tdbio.c (tdbio_set_dbname)
* plaintext.c (handle_plaintext)
* openfile.c (copy_options_file, open_outfile)
* exec.c (exec_write)
* keygen.c (do_generate_keypair, gen_card_key_with_backup)
* sign.c (sign_file, clearsign_file)
* keyring.c (create_tmp_file, do_copy): Check for secured files
before creating them.
* keygen.c (print_status_key_created, read_parameter_file):
s/unsigned char/byte/ due to a strange typedef for RISC OS. Noted
by Stefan.
2004-10-13 David Shaw <dshaw@jabberwocky.com>
* armor.c (fake_packet): Allow arbitrary dash-escaped lines as per
2440bis-10. This is bug #158.
* keyserver.c (keyserver_work): Handle keyserver timeouts.
* pkclist.c (do_edit_ownertrust): Different prompt when we're
using direct trust since the meaning is different.
* keyedit.c (trustsig_prompt): Change the strings to match the
ones in pkclist.c:do_edit_ownertrust to make translation easier.
* trustdb.c (trust_model_string, get_validity): Add direct trust
model which applies to the key as a whole and not per-uid.
* options.h, g10.c (parse_trust_model): New.
(main): Call it from here to do string-to-trust-model.
2004-10-13 Werner Koch <wk@g10code.com>
* tdbdump.c (import_ownertrust): Removed all log_error_f and
reworded the messages.
* dermor.c: Include i18n.h. Made 2 strings translatable.
* misc.c (register_secured_file, is_secured_file)
(unregister_secured_file): New.
* keyring.c (do_copy, rename_tmp_file): Implement the SELinux hacks.
(keyring_register_filename): Ditto.
* tdbio.c (open_db): Ditto.
* openfile.c (copy_options_file, open_sigfile): Ditto.
* verify.c (verify_signatures, verify_one_file): Ditto.
* photoid.c (generate_photo_id): Ditto.
* keygen.c (read_parameter_file): Ditto.
* import.c (import_keys_internal): Ditto.
* decrypt.c (decrypt_message, decrypt_messages): Ditto.
* dearmor.c (dearmor_file, enarmor_file): Ditto.
* g10.c (main, print_mds): Ditto.
* exec.c (exec_write, exec_read): Ditto.
* card-util.c (change_login): Ditto.
* encode.c (encode_simple, encode_crypt): Ditto.
* openfile.c (overwrite_filep, make_outfile_name, open_outfile)
(open_sigfile): Use iobuf_is_pipe_filename to check for pipes so
that special filesnames are taken into account. This is bug 327.
* tdbdump.c (import_ownertrust): Ditto.
* sign.c (write_plaintext_packet): Ditto.
(sign_file, clearsign_file, sign_symencrypt_file):
* progress.c (handle_progress): Ditto.
* plaintext.c (handle_plaintext): Ditto.
(ask_for_detached_datafile, hash_datafiles):
* encode.c (encode_simple, encode_crypt): Ditto.
2004-10-12 Werner Koch <wk@g10code.com>
* keygen.c (read_parameter_file): Changed to use iobuf based file
reading to allow the special file name feature to work.
* keygen.c (read_parameter_file): New keyword "Handle". This is
bug 287.
(print_status_key_not_created): New.
(print_status_key_created): Add new arg HANDLE.
(do_generate_keypair): Print not created status.
* status.c, tatus.h (STATUS_KEY_NOT_CREATED): New.
2004-10-11 David Shaw <dshaw@jabberwocky.com>
* pkclist.c (do_edit_ownertrust): Use the same translated string
for showing the user ID as mainproc.c:print_pkenc_list.
* mainproc.c (print_pkenc_list): Allow translating the quotes
around the user ID.
* card-util.c, g10.c, photoid.c, trustdb.c: The last of the \"%s\"
-> `%s' quoting for things that aren't user IDs.
* keyserver.c (keyserver_spawn): If there is no keyserver host,
print the whole URI since it is self-contained.
2004-10-11 Werner Koch <wk@g10code.com>
* keyserver.c (keyserver_spawn): Print an empty string in log_info
if the host is not set (e.g. finger).
2004-10-10 David Shaw <dshaw@jabberwocky.com>
* card-util.c, keyedit.c, openfile.c, pkclist.c, delkey.c,
keygen.c, photoid.c, revoke.c: Some yes-or-no prompts end in
"(y/n)". Some don't. Consistently use y/n everywhere.
* keygen.c (ask_key_flags): New.
(ask_algo): Call it here in --expert mode so we don't need to
specify each possible variation of RSA capabilities.
* keygen.c (do_add_key_flags): The spec says that all primary keys
MUST be able to certify. Force the certify flag on for primaries
(and off for subkeys).
* keygen.c (generate_keypair): Fix generating keys with the auth
flag.
2004-10-08 David Shaw <dshaw@jabberwocky.com>
* encr-data.c (decrypt_data): Give a warning with a weak key, but
still allow to decrypt the message.
2004-10-07 David Shaw <dshaw@jabberwocky.com>
* pkclist.c (build_pk_list): Keystrify.
* mainproc.c (check_sig_and_print), pkclist.c
(do_edit_ownertrust): Improve translatability of user ID prompts.
2004-10-06 David Shaw <dshaw@jabberwocky.com>
* helptext.c, pkclist.c (do_we_trust): It is not possible to get
here with a revoked or expired key, so BUG() that case. Remove
question about overriding revoked/expired. Also
--keyid-format-ify.
(do_we_trust_pre): Use print_pubkey_info() instead of printing the
info ourselves.
* passphrase.c (passphrase_to_dek): Improve translatability of
user ID prompts.
* keylist.c (print_pubkey_info): Use the user ID the pk was
selected by, if any.
* keyedit.c (sign_uids, ask_revoke_sig): Improve translatability
of user ID prompts.
(ask_revoke_sig, menu_revsig): Try and use common strings for
these two functions so they don't need to be translated twice.
* keyedit.c, keylist.c, keyserver.c, mainproc.c: The
revoked/expired/expires string change of 2004-09-29 was too
simple. Use two styles for each tag.
2004-10-06 Werner Koch <wk@g10code.com>
* ccid-driver.c (ccid_open_reader): Store the vendor ID.
(ccid_transceive_secure): New.
(parse_ccid_descriptor): Workaround for an SCM reader problem.
(send_escape_cmd): New.
2004-10-05 David Shaw <dshaw@jabberwocky.com>
* passphrase.c (agent_get_passphrase): Use keystrs for agent
strings, and fix sprintf warnings.
* keyserver.c (keyserver_spawn): Fix BUG() with certain sets of
mixed regular and preferred keyserver refreshes. Noted by
Sebastian Wiesinger.
* keyedit.c (show_key_with_all_names): Show uid validity in menu.
2004-10-03 Timo Schulz <twoaday@g10code.de>
* apdu.c (apdu_open_remote_reader) [_WIN32]: Do not set ENOSYS.
2004-10-03 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (print_and_check_one_sig_colon): Fix bad keyids in
colon delsig output. Noted by Peter Palfrader.
(show_prefs): Do not reference missing selfsig. Noted by Alex
Moroz.
2004-10-01 Werner Koch <wk@g10code.com>
* gpgv.c (i18n_init): Always use LC_ALL.
2004-09-30 Werner Koch <wk@g10code.com>
* app-openpgp.c (verify_chv3) [GNUPG_MAJOR_VERSION!=1]: Typo fix.
2004-09-30 David Shaw <dshaw@jabberwocky.com>
* gpgv.c, keydb.c (keydb_add_resource): Factored keyring creation
out to ..
(maybe_create_keyring): .. new. Make sure that we do the checks
in a locked state. Problem reported by Stefan Haller. Try to
create the home directory before acquiring a lock for the keyring.
From Werner on stable branch.
* g10.c (main): Blow up if we didn't lose setuid. From Werner on
stable branch.
2004-09-29 David Shaw <dshaw@jabberwocky.com>
* keyedit.c, keylist.c, keyserver.c, mainproc.c: Reduce the many
variations of "revoked" ("revoked", "[revoked]", " [revoked]",
"[revoked] ") "and" expired down to two to simplify translation.
2004-09-28 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (print_and_check_one_sig): Account for the extra space
that show-sig-expire takes up so we do not wrap lines.
(show_key_with_all_names): No need to show subkey revocations as a
seperate line since we now show revocation date in the main subkey
line.
* signal.c (got_fatal_signal): HAVE_DECL_SYS_SIGLIST is defined,
but zero if not found. Noted by John Clizbe.
* keyserver.c (parse_keyrec): Fix problem with non-expiring keys
appearing expired in --search-keys results.
2004-09-27 Werner Koch <wk@g10code.com>
* card-util.c (card_edit): Take admin only status from the table.
* app-openpgp.c: Made all strings translatable.
(verify_chv3) [GNUPG_MAJOR_VERSION]: Make opt.allow_admin
available for use in gnupg 2.
(verify_chv3): Reimplemented countdown showing to use only
functions from this module. Flush the CVH status cache on a
successful read.
(get_one_do): Hack to bypass the cache for cards versions > 1.0.
(store_fpr): Store the creation date for card version > 1.0.
2004-09-25 David Shaw <dshaw@jabberwocky.com>
* main.h, g10.c (main), card-util.c (change_pin): If "admin" has
not been issued, skip right to the CHV1/CHV2 PIN change. No need
to show the unblock or admin PIN change option.
(card_edit): Add "admin" command to add admin commands to the
menu. Do not allow admin commands until "admin" is given.
* app-openpgp.c (verify_chv3): Show a countdown of how many wrong
admin PINs can be entered before the card is locked.
* options.h, g10.c (main), app-openpgp.c (verify_chv3): Remove
--allow-admin.
2004-09-24 David Shaw <dshaw@jabberwocky.com>
* main.h: Create S2K_DIGEST_ALGO macro so we do not need to always
set opt.s2k_digest_algo. This helps fix a problem with PGP 2.x
encrypted symmetric messages. Change all callers (encode.c,
g10.c, keyedit.c, keygen.c, passphrase.c, sign.c).
* armor.c, cardglue.c, getkey.c, import.c, keygen.c: Be consistent
in some more quoted strings. Always use 'user ID', not 'user id',
"quotes" for user IDs, etc.
* keyedit.c (keyedit_menu), gpgv.c (agent_scd_getattr (stub)),
keygen.c (copy_mpi, generate_raw_key): Fix a compile problem and a
few warnings when building without card support.
2004-09-23 Werner Koch <wk@g10code.com>
* card_util.c (generate_card_keys): ask whether backup should be
created.
(card_store_subkey): Factored some code out to ..
* keygen.c (save_unprotected_key_to_card): .. new function.
(gen_card_key_with_backup): New.
(generate_raw_key): New.
(generate_keypair): New arg BACKUP_ENCRYPTION_DIR. Changed all
callers.
(do_generate_keypair): Divert to gen_card_key_with_backup when
desired.
* apdu.c (open_pcsc_reader): Do not print empty reader string.
* keygen.c (ask_algo): Allow creation of AUTH keys.
* keyid.c (usagestr_from_pk): New.
* app-openpgp.c (app_openpgp_storekey): Call flush_cache.
(get_cached_data): Move local data initialization to ..
(app_select_openpgp): .. here. Read some flags for later use.
(do_getattr): New read-only attribute EXTCAP.
* keyedit.c (keyedit_menu): New command "keytocard"
(keyedit_menu): Bad hack for the not_with_sk element.
(show_key_with_all_names): Print the usage.
(find_pk_from_sknode): New.
* card-util.c (card_store_subkey): New.
(copy_mpi): New.
* cardglue.c (agent_openpgp_storekey): New.
2004-09-22 Werner Koch <wk@g10code.com>
* card-util.c (card_generate_subkey, generate_card_keys): Factored
common code out to ...
(get_info_for_key_operation, check_pin_for_key_operation)
(restore_forced_chv1, replace_existing_key_p)
(show_card_key_info): ... new functions.
2004-09-21 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (check_sig_and_print), keyedit.c (show_prefs,
menu_set_keyserver_url): Make sure that keyserver URLs with
control characters inside are printed properly. In fact, handle
them as UTF8.
* keyedit.c (keyedit_menu): Don't show "addcardkey" in the menu if
we do not have card support.
* keydb.h, keyserver.c (print_keyrec, keyserver_spawn): fpr is an
array of unsigned bytes.
2004-09-20 Werner Koch <wk@g10code.com>
* g10.c: Make -K an alias for --list-secret-keys.
* keylist.c (print_card_serialno): New. Taken from gnupg 1.9.11.
(list_keyblock_print): Make use of it.
* keyedit.c (show_key_with_all_names): Print the card S/N.
* keyedit.c (keyedit_menu): New command ADDCARDKEY.
* card-util.c (card_generate_subkey): New.
* keygen.c (generate_card_subkeypair): New.
(gen_card_key): New arg IS_PRIMARY; changed all callers.
* cardglue.c (open_card): Use shutdown code if possible.
(check_card_serialno): Ditto.
* ccid-driver.c (do_close_reader): Factored some code out from ...
(ccid_close_reader): ..here.
(ccid_shutdown_reader): New.
* apdu.c (apdu_shutdown_reader): New.
(shutdown_ccid_reader): New.
2004-09-17 Werner Koch <wk@g10code.com>
* g10.c (list_config): New config option ccid-reader-id.
(gpgconf_list): Add "reader-port".
* apdu.c (open_ccid_reader): New arg PORTSTR. Pass it to
ccid_open_reader.
(apdu_open_reader): Pass portstr to open_ccid_reader.
(apdu_open_reader): No fallback if a full CCID reader id has been
given.
* ccid-driver.c (ccid_get_reader_list): New.
(ccid_open_reader): Changed API to take a string for the reader.
Removed al the cruft for the libusb development vesion which seems
not to be maintained anymore and there are no packages anyway.
The stable library works just fine.
(struct ccid_reader_id_s): Deleted and replaced everywhere by a
simple string.
(usb_get_string_simple): Removed.
(bulk_in): Do valgrind hack here and not just everywhere.
2004-09-16 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names, show_prefs): Show preferred
keyserver(s) in "showpref" output.
* keygen.c (keygen_add_keyserver_url), keyedit.c
(menu_set_keyserver_url): Allow setting a keyserver URL of "none"
to remove an existing keyserver URL.
* keyedit.c (menu_set_keyserver_url): Confirm replacement of a
keyserver URL before overwriting the old one.
2004-09-15 David Shaw <dshaw@jabberwocky.com>
* gpgv.c (agent_scd_getattr): Stub.
* misc.c (get_signature_count): New. Get the signature count from
a smartcard.
(pct_expando): Call it here so the %c expando becomes the number
of signatures issued. This allows for notations or the like with
an automatic signature count.
* ccid-driver.c (usb_get_string_simple): Replacement function to
work with older libusb.
2004-09-15 Werner Koch <wk@g10code.com>
* g10.c [HAVE_LIBUSB]: New option --debug-ccid-driver.
* ccid-driver.c (read_device_info): Removed.
(make_reader_id, scan_or_find_devices): New.
(ccid_open_reader): Simplified by make use of the new functions.
(ccid_set_debug_level): New. Changed the macros to make use of
it. It has turned out that it is often useful to enable debugging
at runtime so I added this option.
2004-09-13 David Shaw <dshaw@jabberwocky.com>
* getkey.c (premerge_public_with_secret): Fix subkey<->binding sig
mismatch when some secret subkeys are missing. Discovered by
Michael Roth.
* main.h, keylist.c (print_subpackets_colon): Make a public
function.
* keyedit.c (print_and_check_one_sig_colon): New. Print a
with-colons version of the sig record.
(menu_delsig): Call it here for a with-colons delsig.
2004-09-12 David Shaw <dshaw@jabberwocky.com>
* options.h, keylist.c (print_one_subpacket,
print_subpackets_colon): Print a spk record for each request
subpacket.
(list_keyblock_colon): Call them here.
* g10.c (parse_subpacket_list, parse_list_options): New. Make the
list of subpackets we are going to print.
(main): Call them here.
2004-09-11 David Shaw <dshaw@jabberwocky.com>
* card-util.c (fetch_url, card_edit): Use the pubkey URL stored on
the card to fetch an updated copy. Works with either straight
URLs or HKP or LDAP keyservers.
* keyserver-internal.h, keyserver.c (keyserver_import_fprint),
import.c (revocation_present): Use a keyserver_spec so the caller
can pass in whatever keyserver they like.
2004-09-10 David Shaw <dshaw@jabberwocky.com>
* app-openpgp.c (get_cached_data): Avoid mallocing zero since it
breaks us when using --enable-m-guard.
* ccid-driver.c (read_device_info): Fix segfault when usb device
is not accessible.
(ccid_open_reader): Allow working with an even older version of
libusb (usb_busses global instead of usb_get_busses()).
2004-09-09 Werner Koch <wk@g10code.com>
* cardglue.h: Add members for CA fingerprints.
* cardglue.c (agent_release_card_info): Invalid them.
(learn_status_cb): Store them.
* app-common.h, app-openpgp.c, iso7816.c, iso7816.h
* apdu.c, apdu.h, ccid-driver.c, ccid-driver.h
* card-util.c: Updated from current gnupg-1.9.
Changes are:
* ccid-driver.h (CCID_DRIVER_ERR_ABORTED): New.
* ccid-driver.c (ccid_open_reader): Support the stable 0.1 version
of libusb.
(ccid_get_atr): Handle short messages.
* apdu.c (my_rapdu_get_status): Implemented.
* apdu.c: Include <signal.h>.
* apdu.c (reader_table_s): Add function pointers for the backends.
(apdu_close_reader, apdu_get_status, apdu_activate)
(send_apdu): Make use of them.
(new_reader_slot): Intialize them to NULL.
(dump_ccid_reader_status, ct_dump_reader_status): New.
(dump_pcsc_reader_status): New.
(open_ct_reader, open_pcsc_reader, open_ccid_reader)
(open_osc_reader, open_rapdu_reader): Intialize function pointers.
(ct_activate_card, ct_send_apdu, pcsc_send_apdu, osc_send_apdu)
(error_string): Removed. Replaced by apdu_strerror.
(get_ccid_error_string): Removed.
(ct_activate_card): Remove the unused loop.
(reset_ct_reader): Implemented.
(ct_send_apdu): Activate the card if not yet done.
(pcsc_send_apdu): Ditto.
* ccid-driver.h: Add error codes.
* ccid-driver.c: Implement more or less proper error codes all
over the place.
* apdu.c (apdu_send_direct): New.
(get_ccid_error_string): Add some error code mappings.
(send_apdu): Pass error codes along for drivers already supporting
them.
(host_sw_string): New.
(get_ccid_error_string): Use above.
(send_apdu_ccid): Reset the reader if it has not yet been done.
(open_ccid_reader): Don't care if the ATR can't be read.
(apdu_activate_card): New.
(apdu_strerror): New.
(dump_reader_status): Only enable it with opt.VERBOSE.
* iso7816.c (map_sw): Add mappings for the new error codes.
* apdu.c (open_ct_reader, open_pcsc_reader, open_ccid_reader)
(reset_ccid_reader, open_osc_reader): Call dump_reader_status only
in verbose mode.
* app-openpgp.c (do_getattr): Fix for sending CA-FPR.
* app-openpgp.c (app_openpgp_readkey): Fixed check for valid
exponent.
* app-openpgp.c (do_setattr): Sync FORCE_CHV1.
* card-util.c (change_login): Kludge to allow reading data from a
file.
(card_edit): Pass ARG_STRING to change_login.
(card_status): Print CA fingerprints.
(change_cafpr): New.
(card_edit): New command CAFPR.
2004-04-30 Werner Koch <wk@gnupg.org>
* g10.c (main) <gpgconf>: Use gpg.conf and not /dev/null as
default filename.
2004-04-28 Werner Koch <wk@gnupg.org>
* card-util.c (card_edit): Remove PIN verification.
(generate_card_keys): New arg SERIALNO. Do PIN verification here
after resetting forced_chv1.
2004-09-09 Werner Koch <wk@g10code.com>
* signal.c (got_fatal_signal): Do readline cleanup. Print signal
number if we can't print the name. Use new autoconf macro
HAVE_DECL_SYS_SIGLIST.
(get_signal_name): Removed.
* photoid.c: Include ttyio.h.
* parse-packet.c (skip_rest): Removed. Changed all callers to use
the new iobuf_skip_reset. Orginal patch by Florian Weimer.
2004-09-07 Werner Koch <wk@g10code.de>
* photoid.c (generate_photo_id): Use tty_printf and not just
printf. Put _() around one string.
2004-09-03 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (parse_keyrec): Force the 'e'xpired flag on as soon
as we know the key is definitely expired. Some translatable
string cleanup.
2004-08-27 David Shaw <dshaw@jabberwocky.com>
* encode.c, exec.c, g10.c, sign.c: Some translatable string
cleanup. Change some "this" to `this'.
2004-08-23 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_spawn): Show log line for what keyserver
action we are taking.
* keyid.c (keystr): If printing a keyid that lacks the high 4
bytes, print the low 4 alone.
(keystr_from_desc): Handle short keyids and warn on v3
fingerprints.
* keydb.h, getkey.c (get_user_id_printable,
get_user_id_string_printable): Rename to get_user_id_native and
get_user_id_string_native and remove the printable stuff since
we're print-ifying valid utf8 characters. Change all callers in
import.c, sign.c, keylist.c, and encode.c.
* keyserver.c (keyserver_search_prompt): Make sure the search
string is converted from UTF-8 before display.
2004-08-19 Werner Koch <wk@g10code.de>
* seskey.c (encode_session_key): Changed the zero random byte
substituting code to actually do clever things. Thanks to
Matthias Urlichs for noting the implementation problem.
2004-08-18 Marcus Brinkmann <marcus@g10code.de>
* passphrase.c (agent_get_passphrase): Fix detection of gpg-agent
cancellation.
2004-08-08 David Shaw <dshaw@jabberwocky.com>
* plaintext.c (handle_plaintext): Bigger buffer for extra safety.
* g10.c (main): New alias --throw-keyid for --throw-keyids, so
that it continues to work in old configuration files. Noted by
Jens Adam.
* pkclist.c (algo_available): --pgp8 now allows blowfish, zlib,
and bzip2.
* status.c (do_get_from_fd): Flush stdout if status isn't flushing
it for us. This guarantees that any menus that were displayed
before the prompt don't get stuck in a buffer. Noted by Peter
Palfrader. This is Debian bug #254072.
* sign.c (update_keysig_packet): Revert change of 2004-05-18. It
is not appropriate to strip policy and notations when remaking a
sig. That should only happen when specifically requested by the
user.
2004-08-05 David Shaw <dshaw@jabberwocky.com>
* armor.c (radix64_read): No armor CRC is legal according to the
spec (the CRC is a MAY).
2004-07-28 David Shaw <dshaw@jabberwocky.com>
* misc.c (argsplit): Properly split quoted args from the keyword
and trim whitespace afterwards.
2004-07-27 David Shaw <dshaw@jabberwocky.com>
* misc.c (optsep): Add the ability to understand keyword="quoted
arg with spaces" type options.
2004-07-16 David Shaw <dshaw@jabberwocky.com>
* keylist.c (list_keyblock_print): Always use the new listing
format where uids are always on a line for themselves. Mark
expired secret keys as expired.
* options.h, g10.c (main): Rename list show-validity to
show-uid-validity as it only shows for uids.
* armor.c (armor_filter): Do not use padding to get us to 8 bytes
of header. Rather, use 2+4 as two different chunks. This avoids
a fake filename of "is".
2004-07-15 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (sign_uids): Properly handle remaking a self-sig on
revoked or expired user IDs. Also, once we've established that a
given uid cannot or will not be signed, don't continue to ask
about each sig.
* mainproc.c (proc_symkey_enc), seckey-cert.c (do_check): Check
the S2K hash algorithm before we try to generate a passphrase
using it. This prevents hitting BUG() when generating a
passphrase using a hash that we don't have.
* sign.c (sign_symencrypt_file): Allow using --force-mdc in --sign
--symmetric messages.
* g10.c (main): Alias --charset as --display-charset to help avoid
the continuing confusion and make room for possible changes in
devel.
* parse-packet.c (parse_plaintext): Show the hex value for the
literal packet mode since it may not be printable.
* keygen.c (make_backsig): Make sure that the backsig was built
successfully before we try and use it.
* status.h, status.c (get_status_string), plaintext.c
(handle_plaintext): New status tags PLAINTEXT and
PLAINTEXT_LENGTH.
2004-06-16 Werner Koch <wk@gnupg.org>
* free-packet.c (copy_secret_key): Get last fix right.
2004-06-16 Werner Koch <wk@gnupg.org>
* free-packet.c (copy_secret_key): Fixed memory leak when D is not
NULL.
* passphrase.c (passphrase_to_dek): Added a few comments to the
code.
2004-05-26 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_refresh): Keep track of keys already
fetched so we don't do a regular keyserver fetch if the preferred
keyserver fetch has exhausted the list.
2004-05-23 David Shaw <dshaw@jabberwocky.com>
* verify.c (verify_signatures): Verify multiple files in the same
order in which we hashed them when issuing the signature. Noted
by Nicholas Cole.
* pkclist.c (do_edit_ownertrust): Fix a kbnode leak and do another
keyid-format conversion.
2004-05-22 Werner Koch <wk@gnupg.org>
* trustdb.c (check_regexp): s/EXP/EXPR/.
* keyedit.c (trustsig_prompt): Remoev useless range check.
* options.h: Renamed ctrl to glo_ctrl. Changed all users.
* ccid-driver.c (ccid_open_reader): Print a warning when CCID
can't be used.
2004-05-21 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (check_sig_and_print): If we're honoring preferred
keyservers, and auto-key-retrieve is set, try and get a missing
key from the preferred keyserver subpacket when we verify the sig.
* gpgv.c (parse_preferred_keyserver, free_keyserver_spec): Stubs.
* keyserver.c (keyidlist): Use new parse_preferred_keyserver
function.
(keyserver_work): Use the passed-in keyserver spec rather than the
options global one.
* keyserver-internal.h, keyserver.c (parse_preferred_keyserver):
New function to take a sig and return a split out keyserver_spec.
(keyserver_import_keyid): Now takes a keyserver_spec.
* keyserver.c (keyidlist): Go back to the old fast keyid lister.
Only merge selfsigs if we have to for honor-keyserver-url.
(keyserver_refresh): Keyserver URL handler moved here.
(calculate_keyid_fpr): Removed.
* keydb.h, keyid.c (keystr_from_desc): Calculate a key string from
a KEYDB_SEARCH_DESC.
* keyserver.c (keyserver_spawn): Fix keyserver options on tempfile
only platforms. Noted by Roger Sondermann.
2004-05-20 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_work): Allow --refresh-keys with a
preferred keyserver to happen even if there is no global keyserver
set.
* sig-check.c (do_check_messages): No need to check for Elgamal
signatures any longer.
(do_check_messages, do_check, check_key_signature2):
--keyid-format conversion.
* pkclist.c (show_paths, edit_ownertrust): Remove some unused
code.
* options.h (ctrl): New for member IN_AUTO_KEY_RETRIEVE.
* mainproc.c (check_sig_and_print): track whether we are
retrieving a key.
* status.c (status_currently_allowed): New.
(write_status_text, write_status_text_and_buffer): Use it here.
* g10.c: New command --gpgconf-list.
(gpgconf_list): New. From Werner on stable branch.
2004-05-19 David Shaw <dshaw@jabberwocky.com>
* pubkey-enc.c (get_session_key, get_it), keyedit.c
(show_key_with_all_names, show_basic_key_info): --keyid-format
conversion.
2004-05-18 David Shaw <dshaw@jabberwocky.com>
* sign.c (update_keysig_packet): Policies and notations should be
stripped out when remaking a self-signature. Noted by Atom
Smasher.
* keyserver.c (parse_keyserver_uri): Fix compiler warnings.
2004-05-11 David Shaw <dshaw@jabberwocky.com>
* options.h, keyserver-internal.h, keyserver.c
(parse_keyserver_uri): Improved URI parser that keeps track of the
path information and doesn't modify the input string.
(keyserver_spawn): Tell keyserver plugins about the path.
2004-05-11 Werner Koch <wk@gnupg.org>
* keylist.c (show_policy_url, show_keyserver_url, show_notation)
(list_one): Use const char* for i18n string helpers.
* keygen.c (do_generate_keypair, read_parameter_file): Really
close the files.
(do_generate_keypair): Create the secret key file using safe
permissions. Noted by Atom Smasher.
2004-05-10 David Shaw <dshaw@jabberwocky.com>
* options.h, mainproc.c (symkey_decrypt_seskey), keyserver.c
(struct keyrec, parse_keyrec, keyserver_search_prompt), keyedit.c
(keyedit_menu), g10.c (add_keyserver_url, add_policy_url): Fix
some compiler warnings.
2004-05-08 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu, menu_set_keyserver_url): Allow passing
preferred keyserver on "keyserver" command line. Sanity check
keyserver URL before accepting it.
* keyserver-internal.h, g10.c (main), keyserver.c
(parse_keyserver_uri): Add an option to require the scheme:// and
change all callers.
(free_keyserver_spec): Make public.
2004-05-07 Werner Koch <wk@gnupg.org>
* sign.c (write_plaintext_packet): Fixed the detection of too
large files in the same way as in encode.c.
2004-05-04 David Shaw <dshaw@jabberwocky.com>
* keylist.c (show_notation): Use bits to select which sort of
notation to show. Don't allow a not-shown notation to prevent us
from issuing the proper --status-fd message.
* options.h, g10.c (main): Add show-std/standard-notations and
show-user-notations. show-notations is both. Default is to show
standard notations only during verify. Change all callers.
2004-04-28 David Shaw <dshaw@jabberwocky.com>
* main.h, keylist.c (show_notation): Add argument to show only
user notations, only standard notations, or both. Change all
callers.
* keyserver.c (keyserver_spawn): We still need EXEC_TEMPFILE_ONLY.
2004-04-28 Werner Koch <wk@gnupg.org>
* card-util.c (card_edit): Require PIN only for generate.
* app-openpgp.c (do_setattr): Sync FORCE_CHV1.
2004-04-27 Werner Koch <wk@gnupg.org>
* keyserver.c (keyserver_spawn) [EXEC_TEMPFILE_ONLY]: Removed
setting use_temp_file because this option has been removed.
* g10.c: New commands --allow-admin and --deny-admin.
* options.h (opt): Add member ALLOW_ADMIN.
* tlv.h, tlv.c: New. Copied from gnupg-1.9.
* cardglue.c (open_card): The serialno is now set internally by
app_select_openpgp; changed invocation.
* cardglue.h (app_t, ctrl_t): New.
(GPG_ERR_EBUSY, GPG_ERR_ENOENT, GPG_ERR_NOT_FOUND, GPG_ERR_BUG)
(GPG_ERR_NOT_IMPLEMENTED, GPG_ERR_EACCESS): New.
(gpg_err_code_from_errno): New.
* app-common.h, app-openpgp.c, iso7816.c, iso7816.h
* apdu.c, apdu.h, ccid-driver.c, ccid-driver.h
* card-util.c: Updated from current gnupg-1.9.
Changes are:
* app-common.h: New members FNC.DEINIT and APP_LOCAL.
* app-openpgp.c (do_deinit): New.
(get_cached_data, flush_cache_item, flush_cache_after_error)
(flush_cache): New.
(get_one_do): Replaced arg SLOT by APP. Make used of cached data.
(verify_chv2, verify_chv3): Flush some cache item after error.
(do_change_pin): Ditto.
(do_sign): Ditto.
(do_setattr): Flush cache item.
(do_genkey): Flush the entire cache.
(compare_fingerprint): Use cached data.
* apdu.c (apdu_send_le): Reinitialize RESULTLEN. Handle
SW_EOF_REACHED like SW_SUCCESS.
* ccid-driver.c (parse_ccid_descriptor): Store some of the reader
features away. New arg HANDLE
(read_device_info): New arg HANDLE. Changed caller.
(bulk_in): Handle time extension requests.
(ccid_get_atr): Setup parameters and the IFSD.
(compute_edc): New. Factored out code.
(ccid_transceive): Use default NADs when required.
* apdu.h: New pseudo stati SW_HOST_NOT_SUPPORTED,
SW_HOST_LOCKING_FAILED and SW_HOST_BUSY.
* iso7816.c (map_sw): Map it.
* ccid-driver.c (ccid_slot_status): Add arg STATUSBITS.
* apdu.c (apdu_get_status): New.
(ct_get_status, pcsc_get_status, ocsc_get_status): New stubs.
(get_status_ccid): New.
(apdu_reset): New.
(reset_ct_reader, reset_pcsc_reader, reset_osc_reader): New stubs.
(reset_ccid_reader): New.
(apdu_enum_reader): New.
* apdu.c (lock_slot, trylock_slot, unlock_slot): New helpers.
(new_reader_slot) [USE_GNU_PTH]: Init mutex.
(apdu_reset, apdu_get_status, apdu_send_le): Run functions
in locked mode.
2004-04-25 David Shaw <dshaw@jabberwocky.com>
* getkey.c (get_seckey_byname2): Significantly simplify this
function by using key_byname to do the heavy lifting. Note that
this also fixes an old problem when the first key on the secret
keyring has an unusable stub primary, but is still chosen.
* getkey.c (key_byname): If namelist is NULL, return the first key
in the keyring.
2004-04-22 David Shaw <dshaw@jabberwocky.com>
* keygen.c (make_backsig): If DO_BACKSIGS is not defined, do not
create backsigs.
* getkey.c (merge_selfsigs_subkey): Find 0x19 backsigs on subkey
selfsigs and verify they are valid. If DO_BACKSIGS is not
defined, fake this as always valid.
* packet.h, parse-packet.c (parse_signature): Make parse_signature
non-static so we can parse 0x19s in self-sigs.
* main.h, sig-check.c (check_backsig): Check a 0x19 signature.
(signature_check2): Give a backsig warning if there is no or a bad
0x19 with signatures from a subkey.
2004-04-21 David Shaw <dshaw@jabberwocky.com>
* parse-packet.c (dump_sig_subpkt, parse_one_sig_subpkt,
can_handle_critical): Parse and display 0x19 signatures.
2004-04-20 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (parse_keyserver_uri): Do not accept "http" as an
alias for "hkp". They are not the same thing.
2004-04-19 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main): Add keyserver-option
honor-keyserver-url. parse_keyserver_options now returns a
success code.
* keyserver.c (parse_keyserver_options): Return error on failure
to parse. Currently there is no way to fail as any unrecognized
options get saved to be sent to the keyserver plugins later.
Check length of keyserver option tokens since with =arguments we
must only match the prefix.
(free_keyserver_spec): Moved code from parse_keyserver_url.
(keyserver_work, keyserver_spawn): Pass in a struct keyserver_spec
rather than using the global keyserver option.
(calculate_keyid_fpr): New. Fills in a KEYDB_SEARCH_DESC for a
key.
(keyidlist): New implementation using get_pubkey_bynames rather
than searching the keydb directly. If honor-keyserver-url is set,
make up a keyserver_spec and try and fetch that key directly. Do
not include it in the returned keyidlist in that case.
2004-04-16 David Shaw <dshaw@jabberwocky.com>
* plaintext.c (handle_plaintext): Accept 'u' as a plaintext mode
that requires end of line conversion. This is being considered
for a UTF8 text packet. If this doesn't take place, no major harm
done. If it does take place, we'll get a jump on starting the
changeover.
* g10.c (main): --no-use-embedded-filename.
* build-packet.c (calc_plaintext, do_plaintext): Do not create
illegal (packet header indicates a size larger than the actual
packet) encrypted data packets when not compressing and using a
filename longer than 255 characters.
* keyedit.c (no_primary_warning): Cleanup. (menu_expire): Don't
give primary warning for subkey expiration changes. These cannot
reorder primaries.
* keygen.c (gen_elg, gen_dsa, gen_rsa, do_create,
do_generate_keypair, generate_subkeypair): New is_subkey argument
to set whether a generated key is a subkey. Do not overload the
ret_sk. This is some early cleanup to do backsigs for signing
subkeys.
* keygen.c (write_keybinding, do_generate_keypair,
generate_subkeypair): Keep track of the unprotected subkey secret
key so we can make a backsig with it.
* keygen.c (make_backsig): New function to add a backsig to a
binding sig of signing subkeys. Currently disabled.
(write_keybinding): Call it here, for signing subkeys only.
* sign.c (make_keysig_packet): Allow generating 0x19 signatures
(same as 0x18 or 0x28, but used for backsigs).
* packet.h, build-packet.c (build_sig_subpkt): Add new
SIGSUBPKT_SIGNATURE type for embedded signatures.
* main.h, misc.c (optsep, argsplit, optlen, parse_options):
Simplify code and properly handle a partial match against an
option with an argument.
* keyserver-internal.h, keyserver.c (parse_keyserver_options): Use
new optsep and argsplit functions.
2004-04-15 David Shaw <dshaw@jabberwocky.com>
* main.h, misc.c (argsplit): Refactor argsep into argsplit and
argsep so they can be called separately.
* options.h, keyserver.c (parse_keyserver_options): Remove
duplicate code from parse_keyserver_options by calling the generic
parse_options.
* keyserver.c (keyserver_spawn, keyserver_refresh), g10.c (main),
gpgv.c (main), mainproc.c (check_sig_and_print), import.c
(revocation_present): Change all callers.
2004-04-14 David Shaw <dshaw@jabberwocky.com>
* packet.h, getkey.c (fixup_uidnode, merge_selfsigs_subkey): Keep
track of which self-sig we actually chose.
* keyedit.c (menu_expire, menu_set_primary_uid,
menu_set_preferences): Use it here to avoid updating non-used
self-sigs and possibly promoting an old self-sig into
consideration again.
* options.h, import.c, keyserver-internal.h, g10.c, mainproc.c,
keyserver.c (parse_keyserver_uri): Parse keyserver URI into a
structure. Cleanup for new "guess my keyserver" functionality, as
well as refreshing via a preferred keyserver subpacket.
* options.h: Encapsulate keyserver details. Change all callers.
2004-04-05 Werner Koch <wk@gnupg.org>
* status.h (STATUS_NEWSIG): New.
* status.c (get_status_string): Add it.
2004-03-27 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Request a trustdb update when adding a
new user ID so the new ID gets validity set. Reported by Owen
Taylor.
2004-03-25 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), compress-bz2.c (init_uncompress):
Rename --bzip2-compress-lowmem to --bzip2-decompress-lowmem since
it applies to decompression, not compression.
2004-03-24 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (sign_uids, show_key_and_fingerprint, ask_revoke_sig,
menu_revsig, menu_showphoto): --keyid-format conversion.
(menu_addrevoker): Use print_pubkey_info() rather than duplicating
code.
2004-03-19 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (update_min_ownertrust, validate_keys): Do not use
keystr functions in log_debug.
* import.c (import_one): Try and collapse user IDs when importing
a key for the first time.
* keyedit.c (menu_addrevoker): Allow appointing a subkey as a
designated revoker if the user forces it via keyid!, so long as
the subkey can certify. Also use the proper date string when
prompting for confirmation.
* g10.c (main): Maintain ordering of multiple Comment lines.
Requested by Peter Hyman.
2004-03-17 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (proc_pubkey_enc, print_pkenc_list, list_node):
--keyid-format conversion.
2004-03-16 David Shaw <dshaw@jabberwocky.com>
* getkey.c (skip_unusable, merge_selfsigs_main,
premerge_public_with_secret, lookup, get_user_id_string):
--keyid-format conversion.
2004-03-15 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (add_utk, verify_own_keys, update_min_ownertrust,
get_validity, ask_ownertrust, validate_keys): --keyid-format
conversion.
* import.c (check_prefs_warning, check_prefs): --keyid-format
conversion and a little better text.
(import_one, import_secret_one, import_revoke_cert, chk_self_sigs,
delete_inv_parts, merge_blocks): Still more --keyid-format
conversions.
2004-03-06 David Shaw <dshaw@jabberwocky.com>
* keylist.c (print_seckey_info, print_pubkey_info): --keyid-format
conversion.
(list_keyblock_print): 0xshort should not push us into the new
list format since it is not much longer than regular 8-character
short keyids.
* keydb.h, keyid.c (keystr_from_pk, keystr_from_sk): New functions
to pull a key string from a key in one step. This isn't faster
than before, but makes for neater code.
* keylist.c (list_keyblock_print): Use keystr_from_xx here.
(print_key_data): No need to pass a keyid in.
2004-03-05 David Shaw <dshaw@jabberwocky.com>
* keyid.c (keyid_from_sk): Minor performance boost by caching
secret key keyids so we don't have to calculate them each time.
* getkey.c (merge_selfsigs_subkey): Do not mark subkeys valid if
we do not support their pk algorithm. This allows for early
(during get_*) rejection of a subkey, and selection of another.
* passphrase.c (passphrase_to_dek): Give a little more information
when we have room to do so.
2004-03-04 David Shaw <dshaw@jabberwocky.com>
* revoke.c (export_minimal_pk), export.c (do_export_stream),
passphrase.c (passphrase_to_dek), keyserver.c (print_keyrec): A
few more places to use --keyid-format.
* options.h, g10.c (main), export.c (parse_export_options,
do_export_stream): Remove --export-all and the "include-non-rfc"
export-option as they are no longer meaningful with the removal of
v3 Elgamal keys.
* armor.c (fake_packet, armor_filter): Use the 2440 partial length
encoding for the faked plaintext packet.
2004-03-03 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), mainproc.c (check_sig_and_print):
Remove verify-option show-long-keyids and replace with
the more general keyid-format.
* build-packet.c (write_header2): Remove call to start old gpg
partial length mode and change all callers.
(do_plaintext): Turn off partial length encoding now that we're
done writing the packet.
(do_comment, do_user_id): Try for a headerlen of 2 since that's
the smallest and most likely encoding for these packets.
* parse-packet.c (parse): Remove call to start old gpg partial
length mode.
2004-03-02 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main): Add a more flexible --keyid-format
option to replace the list-option (and eventually verify-option)
show-long-keyids. The format can be short, long, 0xshort, and
0xlong.
* keydb.h, keyid.c (keystr, keystrlen): New functions to generate
a printable keyid.
* keyedit.c (print_and_check_one_sig, show_key_with_all_names),
keylist.c (list_keyblock_print): Use new keystr() function here to
print keyids.
* packet.h, free-packet.c (free_encrypted, free_plaintext),
parse-packet.c (copy_packet, skip_packet, skip_rest, read_rest,
parse_plaintext, parse_encrypted, parse_gpg_control): Use a flag
to indicate partial or indeterminate encoding. This is the first
step in some minor surgery to remove the old gpg partial length
encoding.
2004-03-01 David Shaw <dshaw@jabberwocky.com>
* parse-packet.c (parse): Only data-type packets are allowed to
use OpenPGP partial length encoding.
2004-02-25 David Shaw <dshaw@jabberwocky.com>
* delkey.c (do_delete_key): Allow deleting a public key with a
secret present if --expert is set.
* plaintext.c (handle_plaintext): Make bytecount static so it
works with multiple literal packets inside a message.
* encode.c, helptext.c (keygen.algo, keygen.algo.elg_se), keygen.c
(ask_algo), sig-check.c (do_check_messages), skclist.c
(build_sk_list): Rename "ElGamal" to "Elgamal" as that is the
proper spelling nowadays. Suggested by Jon Callas.
2004-02-24 David Shaw <dshaw@jabberwocky.com>
* plaintext.c: Copyright.
* encode.c (encode_simple): Show cipher with --verbose.
* options.h, g10.c (main), keyedit.c (sign_keys): Add
--ask-cert-level option to enable cert level prompts during
sigs. Defaults to on. Simplify --default-cert-check-level to
--default-cert-level. If ask-cert-level is off, or batch is on,
use the default-cert-level as the cert level.
* options.h, g10.c (main), trustdb.c (mark_usable_uid_certs):
Simplify --min-cert-check-level to --min-cert-level.
2004-02-22 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), trustdb.c (mark_usable_uid_certs): Add
--min-cert-check-level option to specify minimum cert check level.
Defaults to 2 (so 0x11 sigs are ignored). 0x10 sigs cannot be
ignored.
2004-02-21 David Shaw <dshaw@jabberwocky.com>
* plaintext.c (handle_plaintext): Properly handle a --max-output
of zero (do not limit output at all).
* keyserver.c (keyserver_spawn): Use the full 64-bit keyid in the
INFO header lines, and include "sig:" records for the benefit of
people who store their keys in LDAP servers. It makes it easy to
do queries for things like "all keys signed by Isabella".
* main.h, misc.c (hextobyte): Removed. It's in libutil.a now.
2004-02-20 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (keyserver_export): Disallow user strings that
aren't key IDs.
(keyserver_import): Clarify error message.
(keyserver_spawn): Properly handle 8 bit characters in user IDs in
the info lines during SEND.
* mkdtemp.c: Removed.
* Makefile.am: We get mkdtemp.c from libutil.a now, so don't link
with @LIBOBJS@.
* keyserver.c (keyserver_spawn): Pass the scheme to the keyserver
helper.
2004-02-18 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), plaintext.c (handle_plaintext): Add
--max-output option to help people deal with decompression bombs.
2004-02-15 David Shaw <dshaw@jabberwocky.com>
* build-packet.c (do_user_id): Do not force a header for attribute
packets as they require a new CTB, and we don't support forced
headers for new CTBs yet.
2004-02-14 David Shaw <dshaw@jabberwocky.com>
* build-packet.c (write_header2): If a suggested header length is
provided along with a zero length, interpret this as an actual
zero length packet and not as an indeterminate length packet.
(do_comment, do_user_id): Use it here as these packets might be
naturally zero length.
* parse-packet.c (parse): Show packet type when failing due to an
indeterminate length packet.
* misc.c (parse_options): Only provide args for the true (i.e. not
"no-xxx") form of options.
2004-02-13 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (argsep): Move to misc.c.
* main.h, misc.c (parse_options), export.c (parse_export_options),
import.c (parse_import_options), g10.c (main): Use it here to
allow for options with optional arguments. Change all callers.
* import.c (check_prefs): Some language fixes.
(sec_to_pub_keyblock, import_secret_one): Without knowing the
number of MPIs there are, we cannot try and sk-to-pk-ize a key.
2004-02-12 David Shaw <dshaw@jabberwocky.com>
* import.c (check_prefs): New function to check preferences on a
public key to ensure that it does not advertise any that we cannot
fulfill. Use the keyedit command list function to optionally
rewrite the prefs.
(import_one, import_secret_one): Use it here when importing a
public key that we have the secret half of, or when importing a
secret key that we have the public half of.
* main.h, keyedit.c (keyedit_menu): Remove sign_mode and enhance
the more general command list functionality to replace it.
* g10.c (main): Use the general command functionality to implement
--sign-key, --lsign-key, --nrsign-key, and --nrlsign-key.
* import.c (import_one): Do the revocation check even in the case
when a key, a revocation key set in a direct key signature, and a
revocation from that revocation key, all arrive piecemeal.
Needless to say, this is pretty obscure.
2004-02-11 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), keylist.c (list_keyblock_print): Add
"show-unusable-subkeys" list-option to show revoked and/or expired
subkeys.
2004-02-10 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (keyedit_menu): Prompt for subkey removal for both
secret and public subkeys.
* keylist.c (list_keyblock_print), keyedit.c
(show_key_with_all_names): Show the revocation date of a
key/subkey, and general formatting work.
* packet.h, getkey.c (merge_selfsigs_main, merge_selfsigs_subkey,
merge_selfsigs): Keep track of the revocation date of a key.
* keydb.h, keyid.c (revokestr_from_pk): New function to print the
revocation date of a key.
* keygen.c (keygen_set_std_prefs): Build the default preferences
list at runtime as it properly handles algorithms disabled at
build or run time.
* getkey.c (merge_selfsigs_main): Properly handle expired user IDs
when the expired self-sig is not the only self-sig.
* misc.c (compress_algo_to_string): Return NULL on failure like
all of the other xxxx_algo_to_string() functions.
* mainproc.c (list_node): Minor spacing tweak to match --list-keys
output.
* keylist.c (list_keyblock_print), mainproc.c (list_node): Mark
revoked subkeys as revoked. Requested by Matthew Wilcox. Revoked
overrides expiration when both apply.
* keyedit.c (show_prefs): Use compress algo constants.
(show_basic_key_info): Make revoked and expired tags translatable.
* g10.c (rm_group): Properly ungroup from a list of groups.
2004-01-30 David Shaw <dshaw@jabberwocky.com>
* g10.c (main, rm_group): Add --ungroup command to remove a
particular group.
(add_group): When adding a group with the same name as an already
existing group, merge the two groups.
(list_config): Show an error message when listing a config item
that doesn't exist.
(main): Replace -z0 trick for no compression.
* packet.h, keyedit.c (show_key_with_all_names_colon), keylist.c
(list_keyblock_colon), mainproc.c (list_node, proc_tree): Minor
cleanup to remove local_id, which is no longer used.
2004-01-27 David Shaw <dshaw@jabberwocky.com>
* getkey.c: Set MAX_PK_CACHE_ENTRIES and MAX_UID_CACHE_ENTRIES to
PK_UID_CACHE_SIZE (set in ./configure).
* getkey.c (get_pubkey): When reading key data into the cache,
properly handle keys that are partially (pk, no UIDs) cached
already. This is Debian bug #176425 and #229549.
* compress.c (init_compress, push_compress_filter2): Do the right
thing (i.e. nothing) with compress algo 0.
* main.h, decrypt.c (decrypt_messages): Accept filenames to
decrypt on stdin. This is bug #253.
2004-01-23 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (list_node): Show sigs with --verbose.
* options.h, g10.c (set_screen_dimensions): New function to look
at COLUMNS and LINES.
* keyserver.c (parse_keyrec, keyserver_search_prompt), keyedit.c
(print_and_check_one_sig): Use new screen dimension variables.
2004-01-21 David Shaw <dshaw@jabberwocky.com>
* g10.c (list_config): New function to dump config options to
stdout. Currently requires --with-colons.
(collapse_args): New function to turn argc/argv into a single
string.
(main): Use it here to pass list_config() more than one argument
as a single string.
(print_algo_numbers): Helper to print algorithm number for
--list-config "pubkey", "cipher", "hash"/"digest", and "compress"
config options.
* packet.h, getkey.c (merge_selfsigs, merge_selfsigs_main),
pkclist.c (check_signatures_trust): Indicate who has revoked a key
(the owner or a designated revoker). If a key was revoked by
both, prefer the owner. If a subkey is already revoked by the
owner, don't allow a designated revokation of the whole key to
override this. We're still revoked either way, of course.
* keyedit.c (print_and_check_one_sig, keyedit_menu): Use the
COLUMNS environment variable (if any) to hint how wide the
terminal is. Disabled on _WIN32. Suggested by Janusz
A. Urbanowicz.
2004-01-20 David Shaw <dshaw@jabberwocky.com>
* keylist.c (set_attrib_fd): Open attribute fd in binary
mode. This isn't meaningful on POSIX systems, but the Mingw builds
aren't exactly POSIX.
* trustdb.c (reset_trust_records): New, faster, implementation
that doesn't involve a keyring scan.
(clear_validity): Removed.
* g10.c (main), keydb.h, keydb.c (keydb_rebuild_caches),
keyring.h, keyring.c (keyring_rebuild_cache): Add "noisy" flag so
cache rebuilds can remain noisy when called for itself, and quiet
when called as part of the trustdb rebuild.
* trustdb.c (validate_keys): Rebuild the sig caches before
building the trustdb. Note that this is going to require some
architectual re-thinking, as it is agonizingly slow.
2004-01-19 David Shaw <dshaw@jabberwocky.com>
* sig-check.c (check_key_signature2): Comments.
* keyring.c (keyring_rebuild_cache): Clear sig cache for any
signatures that we can no longer process (say, if the user removed
support for a necessary pubkey or digest algorithm).
2004-01-16 David Shaw <dshaw@jabberwocky.com>
* misc.c (print_cipher_algo_note): May as well call Rijndael AES
at this point.
* keygen.c (do_create), misc.c (openpgp_pk_algo_usage): Remove the
last bits of Elgamal type 20 support.
2004-01-03 Stefan Bellon <sbellon@sbellon.de>
* compress.c [__riscos__]: Only use RISC OS' own ZLib module if
configured to use it.
2003-12-30 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), import.c (parse_import_options,
import_one, import_secret_one), keyserver.c (keyserver_refresh):
Change --merge-only to --import-option merge-only. Deprecate
--merge-only.
2003-12-29 David Shaw <dshaw@jabberwocky.com>
* misc.c (pull_in_libs): Dead code. Removed.
* sig-check.c (check_revocation_keys): Comments.
* getkey.c (merge_selfsigs_main): Don't bother to check designated
revoker sigs if the key is already revoked.
* packet.h, getkey.c (merge_selfsigs_main): New "maybe_revoked"
flag on PKs. It is set when there is a revocation signature from
a valid revocation key, but the revocation key is not present to
verify the signature.
* pkclist.c (check_signatures_trust): Use it here to give a
warning when showing key trust.
* compress-bz2.c: Include stdio.h. Solaris 9 has a very old bzip2
library and we can at least guarantee that it won't fail because
of the lack of stdio.h.
* tdbio.c: Fixed format string bugs related to the use of DB_NAME.
Reported by Florian Weimer.
2003-12-28 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), keyserver.c (keyserver_opts,
parse_keyserver_uri): honor-http-proxy is no longer an option
since we can do the same thing with http-proxy with no arguments.
Also remove broken-http-proxy since it can be better handled in
the HTTP helper.
* keyserver.c (argsep): New variation on strsep that knows about
optional arguments.
(parse_keyserver_options): Use it here for optional arguments.
2003-12-28 Stefan Bellon <sbellon@sbellon.de>
* plaintext.c (handle_plaintext) [__riscos__]: Don't mangle
filename if the user specified it.
* g10.c, gpgv.c [__riscos__]: Removal of unnecessary #ifdef
__riscos__ sections.
2003-12-27 David Shaw <dshaw@jabberwocky.com>
* keyserver.c (strip_leading_space, get_arg): New.
(parse_keyserver_options): Use them here to allow arguments to
keyserver-options. Since none of our options need arguments yet,
just pass them through whole to the keyserver helper.
* main.h, misc.c (parse_options): Add a "noisy" flag to enable and
disable the messages about which option didn't match or matched
ambiguously. Change all callers (g10.c, keyserver.c).
* main.h, import.c (import_options), export.c (export_options):
Pass the noisy flag through.
2003-12-17 David Shaw <dshaw@jabberwocky.com>
* build-packet.c (write_fake_data, do_secret_key), seckey-cert.c
(do_check): Use an unsigned length for mpi_get_opaque.
* options.h: It's impolite to assign -1 to an unsigned
opt.force_ownertrust.
* sig-check.c (cmp_help, do_check), sign.c (do_sign): Remove old
unused code.
* keyid.c (keyid_from_sk): Make sure lowbits is initialized.
2003-12-12 David Shaw <dshaw@jabberwocky.com>
* sig-check.c (do_check): Move the signing algo and hash checks
from here...
(signature_check2): ... to here.
(check_key_signature2): ... and here. This is a minor
optimization to avoid fetching a key (which can be expensive,
especially if it is not self-signed, and there are many key
signatures on it which need to be checked for ultimate trust) if
the signature would have failed anyway because of algorithm or
hash problems.
2003-12-10 David Shaw <dshaw@jabberwocky.com>
* packet.h, build-packet.c (hash_public_key): Remove function ...
* keydb.h, keyid.c (hash_public_key, do_fingerprint_md): ... and
make a new one here that shares code with the fingerprint
calculations. This removes some duplicated functionality, and is
also around 14% faster. (Every bit helps).
* import.c (import_one): No longer need the Elgamal import
warning.
* getkey.c (get_pubkey_fast): This one is sort of obscure.
get_pubkey_fast returns the primary key when requesting a subkey,
so if a user has a key signed by a subkey (we don't do this, but
used to), AND that key is not self-signed, AND the algorithm of
the subkey in question is not present in GnuPG, AND the algorithm
of the primary key that owns the subkey in question is present in
GnuPG, then we will try and verify the subkey signature using the
primary key algorithm and hit a BUG(). The fix is to not return a
hit if the keyid is not the primary. All other users of
get_pubkey_fast already expect a primary only.
2003-12-09 David Shaw <dshaw@jabberwocky.com>
* keyid.c (do_fingerprint_md): Remove the rules to hash the old v3
Elgamal keys. They are no longer needed.
* keyid.c (keyid_from_sk, keyid_from_pk, fingerprint_from_pk,
fingerprint_from_sk): Enforce the v3-is-only-RSA rule. Anything
that isn't RSA gets a zero keyid and fingerprint.
* keyid.c (do_fingerprint_md): Properly handle hashing of keys
that we don't know the structure of by using the opaque MPI.
(do_fingerprint_md_sk): We cannot calculate the fingerprint from a
secret key unless we know the structure (since we can't leave off
the secret key parts), so fail early.....
(keyid_from_sk, fingerprint_from_sk): .... and return all zeroes.
2003-12-03 David Shaw <dshaw@jabberwocky.com>
* g10.c (strusage, main): Show development version warning in
--version output.
(main): Set --bzip2-compress-level to the default value at
startup. Remove --emulate-checksum-bug noop.
* options.h, g10.c (main), main.h, seskey.c (do_encode_md,
encode_md_value), sig-check.c (do_check), sign.c (do_sign): Remove
--emulate-md-encode-bug as it only applied to Elgamal signatures,
which are going away.
2003-11-30 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (proc_symkey_enc, proc_encrypted): Add ability to use
--override-session-key on --symmetric messages (new-style or
old-style).
(proc_pubkey_enc): Move code to show session key from here to
proc_encrypted() so it can work with any type of message.
Suggested by Michael Young.
2003-11-29 David Shaw <dshaw@jabberwocky.com>
* trustdb.c (validate_keys): Reset the trustdb before checking if
we have any ultimately trusted keys. This ensures that if we lose
all our ultimately trusted keys, we don't leave behind the old
validity calculations. Noted by Peter Palfrader.
* revoke.c (gen_desig_revoke): Specify in the comment when a
designated revocation is generated.
* getkey.c (merge_selfsigs_main, merge_selfsigs_subkey,
get_seckey_byname2): Remove Elgamal check since we are removing
type 20 keys altogether.
2003-11-27 David Shaw <dshaw@jabberwocky.com>
* pkclist.c (build_pk_list): Do not allow an empty PK list in
interactive mode.
* keygen.c (ask_algo): Remove ability to generate Elgamal
sign+encrypt keys.
* getkey.c (merge_selfsigs_main, merge_selfsigs_subkey,
get_seckey_byname2): Disallow use of sign+encrypt Elgamal keys.
2003-11-20 David Shaw <dshaw@jabberwocky.com>
* seskey.c (do_encode_md): Comment about earlier (pre-PGP 2.3)
encodings.
* misc.c (compress_algo_to_string): Translate "Uncompressed".
Requested by Tommi Vainikainen.
(string_to_compress_algo): Include multi-string for
"uncompressed|none".
2003-11-17 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), compress-bz2.c (init_uncompress): Add
--bz2-compress-lowmem to set bzlib "small" flag for low memory
(but slow) decompression.
2003-11-15 David Shaw <dshaw@jabberwocky.com>
* compress.c (init_compress): Remove compress level 10 trick,
since it is no longer needed.
* g10.c: Fix typoed option name.
* compress-bz2.c (init_compress): Compression level 0 is not
meaningful for bzip2.
* options.h, g10.c (main), compress.c (init_compress),
compress-bz2.c (init_compress): Add --compress-level and
--bzip2-compress-level. -z sets them both. Change various
callers.
* encode.c (encode_simple), sign.c (sign_symencrypt_file):
Properly use default_compress_algo (--compress-algo, followed by
the highest --personal-compress-preference, followed by ZIP) to
get the algorithm.
2003-11-14 David Shaw <dshaw@jabberwocky.com>
* options.h, trustdb.c (trust_model_string, init_trustdb): Add
support for "external" trust model, where the user can provide a
pregenerated trustdb.
* keyedit.c (keyedit_menu): Do not allow editing ownertrust with
an external trust model trustdb.
2003-11-13 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c, keyedit.c, keylist.c, mainproc.c: Clarify the
plurarility (or not) of various list and verify options.
2003-11-12 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Add --symmetric --sign --encrypt.
* main.h, encode.c (setup_symkey): New. Prompt for a passphrase
and create a DEK for symmetric encryption.
(write_symkey_enc): New. Write out symmetrically encrypted
session keys.
(encode_crypt, encrypt_filter): Use them here here when creating a
message that can be decrypted with a passphrase or a pk.
* sign.c (sign_file): Call setup_symkey if we are doing a
--symmetric --sign --encrypt.
2003-11-09 David Shaw <dshaw@jabberwocky.com>
* mainproc.c (proc_symkey_enc): Don't show algorithm information
when --quiet is set. Suggested by Duncan Harris. Also don't fail
with BUG() when processing a --symmetric message with a cipher we
don't have.
* g10.c: Alias --personal-xxx-prefs to --personal-xxx-preferences.
* pkclist.c (build_pk_list): When adding recipients interactively,
allow the user to stop at any point.
2003-10-31 David Shaw <dshaw@jabberwocky.com>
* trustdb.h, trustdb.c (register_trusted_keyid): New. Adds a
keyid to the list of ultimately trusted keys.
* keygen.c (do_generate_keypair): Use it here so that the ultimate
ownertrust happens before the trustdb (might be) rebuilt. Also
fix an error where the newly generated pk is thought to be a
subkey by the trustdb.
* g10.c (main): Fix --export-all do actually do something
different than --export.
* pkclist.c (build_pk_list): Show all recipients rather than
showing each recipient as they are added.
* mainproc.c (proc_symkey_enc, proc_encrypted): Keep a count of
the number of passphrases that can decrypt a symmetric or mixed
symmetric/pk message and include it in the list of keys shown to
the user.
2003-10-30 David Shaw <dshaw@jabberwocky.com>
* misc.c (compress_algo_to_string, string_to_compress_algo,
check_compress_algo): Add bzip2.
* compress.c (compress_filter): Make static to help force the use
of push_compress_filter. Remove default algorithm setting since
that is done in push_compress_filter now.
* main.h: Use named algorithm.
* filter.h, compress.c (push_compress_filter,
push_compress_filter2): New. Figure out which is the appropriate
compression filter to use, and push it into place.
* compress.c (handle_compressed), encode.c (encode_simple,
encode_crypt), sign.c (sign_file, sign_symencrypt_file), import.c
(read_block), export.c (do_export): Use push_compress_filter
instead of pushing the compression filter ourselves.
* compress-bz2.c: New. Bzlib versions of the compression filter
routines.
* Makefile.am: Include compress-bz2.c if bz2lib is available.
2003-10-30 Werner Koch <wk@gnupg.org>
* apdu.c (close_ct_reader, close_pcsc_reader): Implemented.
(get_ccid_error_string): New. Not very useful messages, though.
2003-10-29 Werner Koch <wk@gnupg.org>
* cardglue.c (open_card): Ask for card insertion.
(check_card_serialno): New.
(agent_scd_pksign, agent_scd_pkdecrypt): Use it here.
* cardglue.c (open_card): Issue insertion status message.
* status.h, status.c (STATUS_CARDCTRL): New.
* status.c (cpr_get_answer_okay_cancel): New.
2003-10-28 Werner Koch <wk@gnupg.org>
* keylist.c (list_keyblock_print): Denote secrets keys stored on a
card with an '>'. Print the '#' also for subkeys.
(list_keyblock_colon): Introduce new field 15 for sec/ssb to print
the serial number.
2003-10-26 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Enhance the version-specific config file code to
try for more specific matches before giving up (e.g. 1.3.3-cvs,
1.3.3, 1.3, 1).
2003-10-25 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Add --symmetric --encrypt command. This generates
a message that can be decrypted via a passphrase or public key
system.
* main.h, encode.c (encode_seskey): Allow passing in an
already-created session key dek.
(encode_simple): Use the actual symmetric cipher when encrypting a
session key for a symmetric message.
(encode_crypt): Add a flag to trigger a hybrid mode that can be
decrypted via a passphrase or a pk. Change all callers.
* mainproc.c (symkey_decrypt_sesskey): There is no way to tell the
difference here between a bad passphrase and a cipher algorithm
that we don't have, so use a error message that makes that clear.
Use the actual list of ciphers when checking whether a cipher is
invalid. Return error if the decrypted cipher algorithm is
invalid.
(proc_symkey_enc): In a mixed passphrase/pk message, if a valid
dek already exists from decrypting via pk, do not try to process
the passphrase.
(proc_symkey_enc): Indicate when we're decrypting a session key as
opposed to decrypting data. If a passphrase is invalid, discard
the dek so we'll keep trying.
2003-10-25 Werner Koch <wk@gnupg.org>
* ccid-driver.c (ccid_open_reader): Return an error if no USB
devices are found.
* Makefile.am: Replaced INTLLIBS by LIBINTL.
* g10.c (main) [ENABLE_CARD_SUPPORT]: Add a default for
--pcsc-driver.
* cardglue.c (learn_status_cb): Fixed faulty use of !space.
2003-10-24 Werner Koch <wk@gnupg.org>
* apdu.c (apdu_open_reader): Hacks for PC/SC under Windows.
2003-10-21 Werner Koch <wk@gnupg.org>
* passphrase.c (ask_passphrase): Add optional promptid arg.
Changed all callers.
* cardglue.c (pin_cb): Use it here, so the machine interface can
tell whether the Admin PIN is requested.
* cardglue.c (agent_scd_checkpin): New.
* misc.c (openpgp_pk_algo_usage): Added AUTH usage.
* app-openpgp.c (check_against_given_fingerprint): New. Factored
out that code elsewhere.
(do_check_pin): New.
* card-util.c (card_edit): New command "passwd". Add logic to
check the PIN in advance.
(card_status): Add new args to return the serial number. Changed
all callers.
2003-10-14 David Shaw <dshaw@jabberwocky.com>
* import.c (import_one): Show the keyid when giving the Elgamal
slow import warning.
* g10.c (main): Older versions used --comment "" to indicate no
comment. Don't add an empty comment.
2003-10-13 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names): Ownertrust is only
meaningful for the PGP or classic trust models. Both validity and
ownertrust are not meaningful for the always trust model.
2003-10-11 Werner Koch <wk@gnupg.org>
* keygen.c: Always enable the gen_card_key prototype.
2003-10-10 Werner Koch <wk@gnupg.org>
* cardglue.c (card_close): New.
(agent_scd_change_pin): Implemented.
* ccid-driver.c (ccid_close_reader): New.
* apdu.c (close_ccid_reader, close_ct_reader, close_csc_reader)
(close_osc_reader, apdu_close_reader): New. Not all are properly
implemented yet.
* g10.c (g10_exit): Use close_card.
2003-10-09 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Give a deprecated option warning for
--show-keyring, --show-photos, --show-policy-url, --show-notation,
and their respective no- forms.
* options.skel: Remove show-photos and replace with
list/verify-options show-photos. Remove no-mangle-dos-filenames.
* misc.c (parse_options): Allow for incomplete (but unambiguous)
options.
2003-10-09 Werner Koch <wk@gnupg.org>
* ccid-driver.c (ccid_transceive): Add T=1 chaining for sending.
* sign.c (do_sign) [!ENABLE_CARD_SUPPORT]: Return an error for
card keys.
* cardglue.c (agent_scd_pkdecrypt): Implemented.
* pubkey-enc.c (get_it) [ENABLE_CARD_SUPPORT]: Divert decryption
to card
2003-10-08 Werner Koch <wk@gnupg.org>
* cardglue.c (pin_cb): Detect whether an admin or regular PIN is
requested.
(genkey_status_cb): New.
(agent_scd_genkey): Implemented.
* keygen.c (generate_keypair): New arg CARD_SERIALNO and prepare
parameters for on card key generation. Changed all callers.
(do_generate_keypair): Add new arg card and merged casrd specific
changes from 1.9.
(proc_parameter_file): New arg card, apss it down to
do_generate_keypair and changed all callers.
(gen_card_key): New.
* g10.c: Include cardclue.h.
(main): s/app_set_default_reader_port/card_set_reader_port/.
* cardglue.c (card_set_reader_port): New to address include file
issues.
2003-10-02 Werner Koch <wk@gnupg.org>
* cardglue.c (learn_status_cb): Release values before assignment
so that it can be used by getattr to update the structure.
(agent_scd_getattr): New.
* keylist.c (print_pubkey_info): Add FP arg for optional printing
to a stream. Changed all callers.
2003-10-01 Werner Koch <wk@gnupg.org>
* app-common.h, app-openpgp.c, iso7816.c, iso7816.h, apdu.c
* apdu.h, ccid-driver.c, ccid-driver.h, card-util.c: Updated
from current GnuPG 1.9. Changes over there are:
* card-util.c: Tweaked to use this source also under 1.3.
(card_edit): New command "forcesig".
* card-util.c (print_name, print_isoname): Use 0 and not LF fro
the max_n arg of tty_print_utf8_string2.
* card-util.c (change_pin): Simplified. We now have only a PIN
and an Admin PIN.
* ccid-driver.c: Detect GnuPG 1.3 and include appropriate files.
* apdu.c: Ditto.
* app-openpgp.c: Ditto.
* iso7816.c: Ditto.
(generate_keypair): Renamed to ..
(do_generate_keypair): .. this.
* app-common.h [GNUPG_MAJOR_VERSION]: New.
* iso7816.h [GNUPG_MAJOR_VERSION]: Include cardglue.h
* app-openpgp.c (do_change_pin): Make sure CVH1 and CHV2 are
always synced.
(verify_chv2, verify_chv3): New. Factored out common code.
(do_setattr, do_sign, do_auth, do_decipher): Change the names of
the prompts to match that we have only 2 different PINs.
(app_select_openpgp): Check whether the card enforced CHV1.
(convert_sig_counter_value): New. Factor out code from
get_sig_counter.
* Makefile.am (card_support_source): Depend on new AM conditional
to get the ifdef ENABLE_CARD_SUPPORT off the way from source
copied files.
(update-source-from-gnupg-2): Maintainer helper.
2003-10-01 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Add --no-groups to zero --group list.
* encode.c (encode_simple): Allow for 32 bytes (256 bits) of
symmetrically encrypted session key. Use --s2k-cipher-algo to
choose cipher, rather than the default cipher.
* parse-packet.c (parse_subkeyenc): Give a warning if an
symmetrically encrypted session key is seen without salt. Show in
--list-packets if a symetrically encrypted session key is present.
* pubkey-enc.c (get_it): Always show cipher-not-in-prefs warning
unless --quiet is set. Use text name of cipher in warning.
2003-09-30 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), mainproc.c (check_sig_and_print): Add
--verify-option show-unusable-uids.
* gpgv.c (check_trustdb_stale): Stub.
* trustdb.c (get_validity): Move the up-to-date check to
check_trustdb_stale (new), so that it can be called before
validity is checked.
* keylist.c (list_keyblock_print): Disable the overall key
validity display until it can be thought about more. Use
check_trustdb_stale here to avoid putting the check warning in the
middle of a listed key.
* trustdb.c (init_trustdb): Only verify_own_keys() for those trust
models that it applies to (i.e. classic and OpenPGP).
2003-09-29 Werner Koch <wk@gnupg.org>
* keygen.c (do_add_key_flags, parse_parameter_usage): Add support
the proposed AUTH key flag.
* getkey.c (fixup_uidnode, merge_selfsigs_main)
(merge_selfsigs_subkey, premerge_public_with_secret): Ditto.
* keylist.c (print_capabilities): Ditto.
* parse-packet.c (parse_key): Allow to parse the divert-to-card
S2K mode.
* build-packet.c (do_secret_key): Handle divert-to-card S2K
* seckey-cert.c (is_secret_key_protected): Ditto.
(check_secret_key): Ditto.
* keygen.c (do_ask_passphrase): Renamed from ask_passphrase.
* passphrase.c (ask_passphrase): New.
2003-09-28 Werner Koch <wk@gnupg.org>
* g10.c (main): New commands --card-edit, --card-status and
--change-pin. New options --ctapi-driver, --pcsc-driver and
--disable-ccid
* options.h (DBG_CARD_IO): New.
* cardglue.c, cardclue.h: Enhanced.
* card-util.c: New. Taken from current the gnupg 1.9 branch.
* app-common.h, app-openpgp.c, iso7816.c, iso7816.h, apdu.c
* apdu.h, ccid-driver.c, ccid-driver.h: New. Takem from the current
gnupg 1.9 branch withy minor changes to include directives.
* Makefile.am: Added these files.
2003-09-27 Werner Koch <wk@gnupg.org>
* sign.c (do_sign) [ENABLE_CARD_SUPPORT]: Divert to card.
* cardglue.c, cardglue.h: New.
* Makefile.am (gpg_LDADD): Added.
(card_support_sources): New.
2003-09-25 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), keylist.c (list_keyblock_print): Add
"show-unusable-uids" list-option to show revoked and/or expired
user IDs.
2003-09-24 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names): Show names a little neater
by putting the [revoked] or [expired] in the space used for the
[validity]. There is also no point in showing "[unknown]
[revoked]".
2003-09-23 David Shaw <dshaw@jabberwocky.com>
* sign.c (mk_notation_policy_etc): Capitalize "URL".
* trustdb.c (validate_keys): Give a little more information while
rebuilding trustdb.
* pkclist.c (do_edit_ownertrust): Clarify "don't know".
* g10.c (main): Default to --no-mangle-dos-filenames.
* keydb.h, keyring.c (keyring_search), trustdb.c (search_skipfnc):
Expand the skipfnc to include a pointer to the user ID that
matched.
* getkey.c (skip_disabled): Rename to skip_unusable, and add
checks for expired or revoked user IDs.
2003-09-22 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Deprecate --default-comment in favor of
--no-comments.
* options.h, g10.c (main), armor.c (armor_filter): Allow using
--comment multiple times to get multiple Comment: header lines.
--no-comments resets list.
2003-09-11 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Trim --help to commonly used options. Remove -f.
2003-09-08 David Shaw <dshaw@jabberwocky.com>
* g10.c (main): Error out if --multifile is used with the commands
that don't support it yet (--sign, --clearsign, --detach-sign,
--symmetric, and --store).
* g10.c (main): Add --multifile as an alias to turn --encrypt into
--encrypt-files (plus --verify-files, --decrypt-files).
* encode.c (use_mdc), g10.c (main): Use RFC1991 and RFC2440
directly to check for MDC usability. Do not set the force_mdc or
disable_mdc flags since there is no point any longer.
2003-09-04 David Shaw <dshaw@jabberwocky.com>
* armor.c (parse_hash_header, armor_filter), g10.c (print_hex,
print_mds), pkclist.c (algo_available): Drop TIGER/192 support.
2003-09-03 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names): Fix assertion failure when
using toggle to see a secret key. Reported by Maxim Britov.
2003-08-31 David Shaw <dshaw@jabberwocky.com>
* g10.c (add_keyserver_url), keyedit.c (keyedit_menu), sign.c
(mk_notation_policy_etc): Clarify a few strings. It's a
"preferred keyserver URL".
* g10.c (main): Use "keyserver-url" instead of
"preferred-keyserver" for the sake of short and simple commands.
2003-08-30 David Shaw <dshaw@jabberwocky.com>
* main.h, keygen.c (keygen_add_keyserver_url): Signature callback
for adding a keyserver URL.
* keyedit.c (keyedit_menu, menu_set_keyserver_url): New command to
set preferred keyserver to specified (or all) user IDs.
* build-packet.c (build_sig_subpkt): Set preferred keyserver flag
while building a preferred keyserver subpacket.
* keylist.c (show_policy_url, show_keyserver_url): URLs might be
UTF8.
* keyedit.c (menu_addrevoker): Fix leaking a few bytes.
2003-08-29 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names): Use list-option
show-long-keyid in main --edit-key display.
* keyedit.c (print_and_check_one_sig): Use list-option
show-long-keyid in --edit-key "check" function.
2003-08-28 David Shaw <dshaw@jabberwocky.com>
* passphrase.c (agent_send_all_options): Make use of $GPG_TTY.
* g10.c (main): Disable use-agent if passphrase-fd is given
later. Suggested by Kurt Garloff.
* exec.c, g10.c, gpgv.c, passphrase.c, photoid.c:
s/__MINGW32__/_WIN32/ to help building on native Windows
compilers. Requested by Brian Gladman. From Werner on stable
branch.
2003-08-25 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main): Add list-option
list-preferred-keyserver.
* keyedit.c (change_passphrase): When responding 'no' to the blank
passphrase question, re-prompt for a new passphrase. This is bug
#202.
* mainproc.c (check_sig_and_print): Use two different preferred
keyserver displays - one if the key is not present (to tell the
user where to get the key), the other if it is present (to tell
the user where the key can be refreshed).
* packet.h, parse-packet.c (parse_signature): Set flag if a
preferred keyserver is present.
* keylist.c (list_keyblock_print): Show keyserver url in listings
with list-option show-keyserver-url.
2003-08-24 David Shaw <dshaw@jabberwocky.com>
* Makefile.am: Use NETLIBS instead of EGDLIBS.
* mainproc.c (check_sig_and_print): Get the uid validity before
printing any sig results to avoid munging the output with trustdb
warnings.
* g10.c (main): Don't include --show-keyring in --help as it is
deprecated.
2003-08-21 David Shaw <dshaw@jabberwocky.com>
* gpgv.c: Remove extra semicolon (typo).
* options.skel: Note that keyserver.pgp.com isn't synchronized,
and explain the roundrobin a bit better.
* sig-check.c (check_key_signature2), import.c (import_one,
import_revoke_cert, chk_self_sigs, delete_inv_parts,
collapse_uids, merge_blocks): Make much quieter during import of
slightly munged, but recoverable, keys. Use log_error for
unrecoverable import failures.
* keyring.c (keyring_rebuild_cache): Comment.
* sign.c (mk_notation_and_policy): Making a v3 signature with
notations or policy urls is an error, not an info (i.e. increment
the errorcount). Don't print the notation or policy url to stdout
since it can be mixed into the output stream when piping and munge
the stream.
2003-08-12 David Shaw <dshaw@jabberwocky.com>
* packet.h, sig-check.c (signature_check2, do_check,
do_check_messages): Provide a signing-key-is-revoked flag. Change
all callers.
* status.h, status.c (get_status_string): New REVKEYSIG status tag
for a good signature from a revoked key.
* mainproc.c (do_check_sig, check_sig_and_print): Use it here.
* import.c (import_revoke_cert, merge_blocks, merge_sigs): Compare
actual signatures on import rather than using keyid or class
matching. This does not change actual behavior with a key, but
does mean that all sigs are imported whether they will be used or
not.
* parse-packet.c (parse_signature): Don't give "signature packet
without xxxx" warnings for experimental pk algorithms. An
experimental algorithm may not have a notion of (for example) a
keyid (i.e. PGP's x.509 stuff).
2003-08-02 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), keylist.c (list_keyblock_print),
keyedit.c (print_and_check_one_sig): New "show-sig-expire"
list-option to show signature expiration dates (if any).
2003-07-24 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main, add_keyserver_url): Add
--sig-preferred-keyserver to implant a "where to get my key"
subpacket into a signature.
* sign.c (mk_notation_and_policy): Rename to
mk_notation_policy_etc and add preferred keyserver support for
signatures.
2003-07-21 David Shaw <dshaw@jabberwocky.com>
* keygen.c (do_add_key_flags): Don't set the certify flag for
subkeys.
(ask_algo): Provide key flags for DSA, Elgamal_e, and Elgamal
subkeys.
(generate_keypair): Provide key flags for the default DSA/Elgamal
keys.
* sig-check.c (signature_check, signature_check2,
check_key_signature, check_key_signature2): Allow passing NULLs
for unused parameters in the x2 form of each function to avoid the
need for dummy variables. getkey.c, mainproc.c: Change all
callers.
* trustdb.h, trustdb.c (read_trust_options): New. Returns items
from the trustdb version record.
* keylist.c (public_key_list): Use it here for the new "tru"
record.
* gpgv.c (read_trust_options): Stub.
2003-07-20 David Shaw <dshaw@jabberwocky.com>
* keyedit.c (show_key_with_all_names): Use list-option
show-validity in --edit-key interface as well.
2003-07-19 David Shaw <dshaw@jabberwocky.com>
* options.h, g10.c (main), mainproc.c (check_sig_and_print): Add
verify-options "show-validity" and "show-long-keyid" to show
trustdb validity and long keyids during (file) signature
verification.
* packet.h, main.h, sig-check.c (signature_check2,
check_key_signature2, do_check): If ret_pk is set, fill in the pk
used to verify the signature. Change all callers in getkey.c,
mainproc.c, and sig-check.c.
* keylist.c (list_keyblock_colon): Use the ret_pk from above to
put the fingerprint of the signing key in "sig" records during a
--with-colons --check-sigs. This requires --no-sig-cache as well
since we don't cache fingerprints.
2003-07-10 David Shaw <dshaw@jabberwocky.com>
* parse-packet.c (parse_signature): No need to reserve 8 bytes for
the unhashed signature cache any longer.
* misc.c (pct_expando): Add two new expandos - signer's
fingerprint (%g), and signer's primary fingerprint (%p).
* Makefile.am: Include W32LIBS where appropriate.
* g10.c (main): Add --rfc2440 alias for --openpgp since in a few
months, they won't be the same thing.
* keyserver.c (parse_keyserver_uri): Accept "http" as an alias for
"hkp", since it is occasionally written that way.
(keyserver_spawn): Use ascii_isspace to avoid locale issues.
* keygen.c (ask_user_id): Make --allow-freeform-uid apply to the
email field as well as the name field, and allow mixing fields
when it is set.
* options.skel: Use subkeys.pgp.net as the default keyserver.
* trustdb.c (validate_one_keyblock): Certifications on revoked or
expired uids do not count in the web of trust.
* signal.c (init_one_signal, pause_on_sigusr, do_block): Only use
sigprocmask() if we have sigset_t, and only use sigaction() if we
have struct sigaction. This is for Forte c89 on Solaris which
seems to define only the function call half of the two pairs by
default.
(pause_on_sigusr): Typo.
(do_block): If we can't use sigprocmask() and sigset_t, try to get
the number of signals from NSIG as well as MAXSIG, and if we
can't, fail with an explanation.
* signal.c, tdbio.c: Comment out the transaction code. It was not
used in this version, and was causing some build problems on
quasi-posix platforms (Solaris and Forte c89).
* keylist.c (list_keyblock_colon): Don't include validity values
when listing secret keys since they can be incorrect and/or
misleading. This is a temporary kludge, and will be handled
properly in 1.9/2.0.
* mainproc.c (check_sig_and_print): Only show the "key available
from" preferred keyserver line if the key is not currently
present.
* keyedit.c (sign_uids): Do not sign expired uids without --expert
(same behavior as revoked uids). Do not allow signing a user ID
without a self-signature. --expert overrides. Add additional
prompt to the signature level question.
(menu_expire): When changing expiration dates, don't replace
selfsigs on revoked uids since this would effectively unrevoke
them. There is also no point in replacing expired selfsigs. This
is bug #181
2003-07-10 David Shaw <dshaw@jabberwocky.com> (from Werner on stable branch)
* g10.c (add_notation_data): Make sure that only ascii is passed
to iscntrl. Noted by Christian Biere.
* getkey.c (classify_user_id2): Replaced isspace by spacep
* keygen.c (ask_user_id): Ditto.
(get_parameter_algo): Ditto.
* keyedit.c (keyedit_menu): Ditto.
* tdbdump.c (import_ownertrust): Ditto. s/isxdigit/hexdigitp/.
* revoke.c (ask_revocation_reason):
* keyserver.c (keyserver_spawn): Dito.
2003-06-10 Werner Koch <wk@gnupg.org>
* parse-packet.c (parse): Disallow old style partial length for
all key material packets to avoid possible corruption of keyrings.
2003-06-08 Werner Koch <wk@gnupg.org>
* import.c (import_keys_internal): Invalidate the cache so that
the file descriptor gets closed. Fixes bug reported by Juan
F. Codagnone.
2003-06-04 David Shaw <dshaw@jabberwocky.com>
* options.skel: Use new hkp://subkeys.pgp.net as sample keyserver
since they at least handle subkeys correctly.
* options.h, g10.c (main), main.h, keylist.c (show_keyserver_url),
mainproc.c (check_sig_and_print), parse-packet.c (dump_sig_subpkt,
parse_one_sig_subpkt, can_handle_critical): Add read-only support
for preferred keyserver subpackets. They're basically policy URLs
with a different name. Add a verify-option
"show-preferred-keyserver" to turn them on and off (on by default,
as per stable branch).
* g10.c (main): Add "--set-notation" as alias to "--notation-data"
this is to make things consistent with --set-policy-url meaning
both sigs and certs.
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,
2004, 2005 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/getkey.c b/g10/getkey.c
index 7991b81af..59f18f6a5 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -1,2778 +1,2814 @@
/* getkey.c - Get a key from the database
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <ctype.h>
#include "util.h"
#include "packet.h"
#include "memory.h"
#include "iobuf.h"
#include "keydb.h"
#include "options.h"
#include "main.h"
#include "trustdb.h"
#include "i18n.h"
+#include "keyserver-internal.h"
#define MAX_PK_CACHE_ENTRIES PK_UID_CACHE_SIZE
#define MAX_UID_CACHE_ENTRIES PK_UID_CACHE_SIZE
#if MAX_PK_CACHE_ENTRIES < 2
#error We need the cache for key creation
#endif
struct getkey_ctx_s {
int exact;
KBNODE keyblock;
KBPOS kbpos;
KBNODE found_key; /* pointer into some keyblock */
int last_rc;
int req_usage;
int req_algo;
KEYDB_HANDLE kr_handle;
int not_allocated;
int nitems;
KEYDB_SEARCH_DESC items[1];
};
#if 0
static struct {
int any;
int okay_count;
int nokey_count;
int error_count;
} lkup_stats[21];
#endif
typedef struct keyid_list {
struct keyid_list *next;
u32 keyid[2];
} *keyid_list_t;
#if MAX_PK_CACHE_ENTRIES
typedef struct pk_cache_entry {
struct pk_cache_entry *next;
u32 keyid[2];
PKT_public_key *pk;
} *pk_cache_entry_t;
static pk_cache_entry_t pk_cache;
static int pk_cache_entries; /* number of entries in pk cache */
static int pk_cache_disabled;
#endif
#if MAX_UID_CACHE_ENTRIES < 5
#error we really need the userid cache
#endif
typedef struct user_id_db {
struct user_id_db *next;
keyid_list_t keyids;
int len;
char name[1];
} *user_id_db_t;
static user_id_db_t user_id_db;
static int uid_cache_entries; /* number of entries in uid cache */
static void merge_selfsigs( KBNODE keyblock );
static int lookup( GETKEY_CTX ctx, KBNODE *ret_keyblock, int secmode );
#if 0
static void
print_stats()
{
int i;
for(i=0; i < DIM(lkup_stats); i++ ) {
if( lkup_stats[i].any )
fprintf(stderr,
"lookup stats: mode=%-2d ok=%-6d nokey=%-6d err=%-6d\n",
i,
lkup_stats[i].okay_count,
lkup_stats[i].nokey_count,
lkup_stats[i].error_count );
}
}
#endif
void
cache_public_key( PKT_public_key *pk )
{
#if MAX_PK_CACHE_ENTRIES
pk_cache_entry_t ce;
u32 keyid[2];
if( pk_cache_disabled )
return;
if( pk->dont_cache )
return;
if( is_ELGAMAL(pk->pubkey_algo)
|| pk->pubkey_algo == PUBKEY_ALGO_DSA
|| is_RSA(pk->pubkey_algo) ) {
keyid_from_pk( pk, keyid );
}
else
return; /* don't know how to get the keyid */
for( ce = pk_cache; ce; ce = ce->next )
if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] ) {
if( DBG_CACHE )
log_debug("cache_public_key: already in cache\n");
return;
}
if( pk_cache_entries >= MAX_PK_CACHE_ENTRIES ) {
/* fixme: use another algorithm to free some cache slots */
pk_cache_disabled=1;
if( opt.verbose > 1 )
log_info(_("too many entries in pk cache - disabled\n"));
return;
}
pk_cache_entries++;
ce = xmalloc( sizeof *ce );
ce->next = pk_cache;
pk_cache = ce;
ce->pk = copy_public_key( NULL, pk );
ce->keyid[0] = keyid[0];
ce->keyid[1] = keyid[1];
#endif
}
/*
* Return the user ID from the given keyblock.
* We use the primary uid flag which has been set by the merge_selfsigs
* function. The returned value is only valid as long as then given
* keyblock is not changed
*/
static const char *
get_primary_uid ( KBNODE keyblock, size_t *uidlen )
{
KBNODE k;
const char *s;
for (k=keyblock; k; k=k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID
&& !k->pkt->pkt.user_id->attrib_data
&& k->pkt->pkt.user_id->is_primary ) {
*uidlen = k->pkt->pkt.user_id->len;
return k->pkt->pkt.user_id->name;
}
}
/* fixme: returning translatable constants instead of a user ID is
* not good because they are probably not utf-8 encoded. */
s = _("[User ID not found]");
*uidlen = strlen (s);
return s;
}
static void
release_keyid_list ( keyid_list_t k )
{
while ( k ) {
keyid_list_t k2 = k->next;
xfree (k);
k = k2;
}
}
/****************
* Store the association of keyid and userid
* Feed only public keys to this function.
*/
static void
cache_user_id( KBNODE keyblock )
{
user_id_db_t r;
const char *uid;
size_t uidlen;
keyid_list_t keyids = NULL;
KBNODE k;
for (k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
keyid_list_t a = xmalloc_clear ( sizeof *a );
/* Hmmm: For a long list of keyids it might be an advantage
* to append the keys */
keyid_from_pk( k->pkt->pkt.public_key, a->keyid );
/* first check for duplicates */
for(r=user_id_db; r; r = r->next ) {
keyid_list_t b = r->keyids;
for ( b = r->keyids; b; b = b->next ) {
if( b->keyid[0] == a->keyid[0]
&& b->keyid[1] == a->keyid[1] ) {
if( DBG_CACHE )
log_debug("cache_user_id: already in cache\n");
release_keyid_list ( keyids );
xfree ( a );
return;
}
}
}
/* now put it into the cache */
a->next = keyids;
keyids = a;
}
}
if ( !keyids )
BUG (); /* No key no fun */
uid = get_primary_uid ( keyblock, &uidlen );
if( uid_cache_entries >= MAX_UID_CACHE_ENTRIES ) {
/* fixme: use another algorithm to free some cache slots */
r = user_id_db;
user_id_db = r->next;
release_keyid_list ( r->keyids );
xfree(r);
uid_cache_entries--;
}
r = xmalloc( sizeof *r + uidlen-1 );
r->keyids = keyids;
r->len = uidlen;
memcpy(r->name, uid, r->len);
r->next = user_id_db;
user_id_db = r;
uid_cache_entries++;
}
void
getkey_disable_caches()
{
#if MAX_PK_CACHE_ENTRIES
{
pk_cache_entry_t ce, ce2;
for( ce = pk_cache; ce; ce = ce2 ) {
ce2 = ce->next;
free_public_key( ce->pk );
xfree( ce );
}
pk_cache_disabled=1;
pk_cache_entries = 0;
pk_cache = NULL;
}
#endif
/* fixme: disable user id cache ? */
}
static void
pk_from_block ( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE keyblock )
{
KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
assert ( a->pkt->pkttype == PKT_PUBLIC_KEY
|| a->pkt->pkttype == PKT_PUBLIC_SUBKEY );
copy_public_key ( pk, a->pkt->pkt.public_key );
}
static void
sk_from_block ( GETKEY_CTX ctx,
PKT_secret_key *sk, KBNODE keyblock )
{
KBNODE a = ctx->found_key ? ctx->found_key : keyblock;
assert ( a->pkt->pkttype == PKT_SECRET_KEY
|| a->pkt->pkttype == PKT_SECRET_SUBKEY );
copy_secret_key( sk, a->pkt->pkt.secret_key);
}
/****************
* Get a public key and store it into the allocated pk
* can be called with PK set to NULL to just read it into some
* internal structures.
*/
int
get_pubkey( PKT_public_key *pk, u32 *keyid )
{
int internal = 0;
int rc = 0;
#if MAX_PK_CACHE_ENTRIES
if(pk)
{
/* Try to get it from the cache. We don't do this when pk is
NULL as it does not guarantee that the user IDs are
cached. */
pk_cache_entry_t ce;
for( ce = pk_cache; ce; ce = ce->next )
{
if( ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1] )
{
copy_public_key( pk, ce->pk );
return 0;
}
}
}
#endif
/* more init stuff */
if( !pk ) {
pk = xmalloc_clear( sizeof *pk );
internal++;
}
/* do a lookup */
{ struct getkey_ctx_s ctx;
KBNODE kb = NULL;
memset( &ctx, 0, sizeof ctx );
ctx.exact = 1; /* use the key ID exactly as given */
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
ctx.items[0].u.kid[0] = keyid[0];
ctx.items[0].u.kid[1] = keyid[1];
ctx.req_algo = pk->req_algo;
ctx.req_usage = pk->req_usage;
rc = lookup( &ctx, &kb, 0 );
if ( !rc ) {
pk_from_block ( &ctx, pk, kb );
}
get_pubkey_end( &ctx );
release_kbnode ( kb );
}
if( !rc )
goto leave;
rc = G10ERR_NO_PUBKEY;
leave:
if( !rc )
cache_public_key( pk );
if( internal )
free_public_key(pk);
return rc;
}
/* Get a public key and store it into the allocated pk. This function
differs from get_pubkey() in that it does not do a check of the key
to avoid recursion. It should be used only in very certain cases.
It will only retrieve primary keys. */
int
get_pubkey_fast (PKT_public_key *pk, u32 *keyid)
{
int rc = 0;
KEYDB_HANDLE hd;
KBNODE keyblock;
u32 pkid[2];
assert (pk);
#if MAX_PK_CACHE_ENTRIES
{ /* Try to get it from the cache */
pk_cache_entry_t ce;
for (ce = pk_cache; ce; ce = ce->next)
{
if (ce->keyid[0] == keyid[0] && ce->keyid[1] == keyid[1])
{
if (pk)
copy_public_key (pk, ce->pk);
return 0;
}
}
}
#endif
hd = keydb_new (0);
rc = keydb_search_kid (hd, keyid);
if (rc == -1)
{
keydb_release (hd);
return G10ERR_NO_PUBKEY;
}
rc = keydb_get_keyblock (hd, &keyblock);
keydb_release (hd);
if (rc)
{
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
return G10ERR_NO_PUBKEY;
}
assert ( keyblock->pkt->pkttype == PKT_PUBLIC_KEY
|| keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY );
keyid_from_pk(keyblock->pkt->pkt.public_key,pkid);
if(keyid[0]==pkid[0] && keyid[1]==pkid[1])
copy_public_key (pk, keyblock->pkt->pkt.public_key );
else
rc=G10ERR_NO_PUBKEY;
release_kbnode (keyblock);
/* Not caching key here since it won't have all of the fields
properly set. */
return rc;
}
KBNODE
get_pubkeyblock( u32 *keyid )
{
struct getkey_ctx_s ctx;
int rc = 0;
KBNODE keyblock = NULL;
memset( &ctx, 0, sizeof ctx );
/* no need to set exact here because we want the entire block */
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
ctx.items[0].u.kid[0] = keyid[0];
ctx.items[0].u.kid[1] = keyid[1];
rc = lookup( &ctx, &keyblock, 0 );
get_pubkey_end( &ctx );
return rc ? NULL : keyblock;
}
/****************
* Get a secret key and store it into sk
*/
int
get_seckey( PKT_secret_key *sk, u32 *keyid )
{
int rc;
struct getkey_ctx_s ctx;
KBNODE kb = NULL;
memset( &ctx, 0, sizeof ctx );
ctx.exact = 1; /* use the key ID exactly as given */
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (1);
ctx.nitems = 1;
ctx.items[0].mode = KEYDB_SEARCH_MODE_LONG_KID;
ctx.items[0].u.kid[0] = keyid[0];
ctx.items[0].u.kid[1] = keyid[1];
ctx.req_algo = sk->req_algo;
ctx.req_usage = sk->req_usage;
rc = lookup( &ctx, &kb, 1 );
if ( !rc ) {
sk_from_block ( &ctx, sk, kb );
}
get_seckey_end( &ctx );
release_kbnode ( kb );
if( !rc ) {
/* check the secret key (this may prompt for a passprase to
* unlock the secret key
*/
rc = check_secret_key( sk, 0 );
}
return rc;
}
/****************
* Check whether the secret key is available. This is just a fast
* check and does not tell us whether the secret key is valid. It
* merely tells other whether there is some secret key.
* Returns: 0 := key is available
* G10ERR_NO_SECKEY := not availabe
*/
int
seckey_available( u32 *keyid )
{
int rc;
KEYDB_HANDLE hd = keydb_new (1);
rc = keydb_search_kid (hd, keyid);
if ( rc == -1 )
rc = G10ERR_NO_SECKEY;
keydb_release (hd);
return rc;
}
/****************
* Return the type of the user id:
*
* Please use the constants KEYDB_SERCH_MODE_xxx
* 0 = Invalid user ID
* 1 = exact match
* 2 = match a substring
* 3 = match an email address
* 4 = match a substring of an email address
* 5 = match an email address, but compare from end
* 6 = word match mode
* 10 = it is a short KEYID (don't care about keyid[0])
* 11 = it is a long KEYID
* 12 = it is a trustdb index (keyid is looked up)
* 16 = it is a 16 byte fingerprint
* 20 = it is a 20 byte fingerprint
* 21 = Unified fingerprint :fpr:pk_algo:
* (We don't use pk_algo yet)
*
* Rules used:
* - If the username starts with 8,9,16 or 17 hex-digits (the first one
* must be in the range 0..9), this is considered a keyid; depending
* on the length a short or complete one.
* - If the username starts with 32,33,40 or 41 hex-digits (the first one
* must be in the range 0..9), this is considered a fingerprint.
* - If the username starts with a left angle, we assume it is a complete
* email address and look only at this part.
* - If the username starts with a colon we assume it is a unified
* key specfification.
* - If the username starts with a '.', we assume it is the ending
* part of an email address
* - If the username starts with an '@', we assume it is a part of an
* email address
* - If the userid start with an '=' an exact compare is done.
* - If the userid starts with a '*' a case insensitive substring search is
* done (This is the default).
* - If the userid starts with a '+' we will compare individual words
* and a match requires that all the words are in the userid.
* Words are delimited by white space or "()<>[]{}.@-+_,;/&!"
* (note that you can't search for these characters). Compare
* is not case sensitive.
*/
int
classify_user_id( const char *name, KEYDB_SEARCH_DESC *desc )
{
const char *s;
int hexprefix = 0;
int hexlength;
int mode = 0;
KEYDB_SEARCH_DESC dummy_desc;
if (!desc)
desc = &dummy_desc;
/* clear the structure so that the mode field is set to zero unless
* we set it to the correct value right at the end of this function */
memset (desc, 0, sizeof *desc);
/* skip leading spaces. Fixme: what is with trailing spaces? */
for(s = name; *s && spacep (s); s++ )
;
switch (*s) {
case 0: /* empty string is an error */
return 0;
case '.': /* an email address, compare from end */
mode = KEYDB_SEARCH_MODE_MAILEND;
s++;
desc->u.name = s;
break;
case '<': /* an email address */
mode = KEYDB_SEARCH_MODE_MAIL;
desc->u.name = s;
break;
case '@': /* part of an email address */
mode = KEYDB_SEARCH_MODE_MAILSUB;
s++;
desc->u.name = s;
break;
case '=': /* exact compare */
mode = KEYDB_SEARCH_MODE_EXACT;
s++;
desc->u.name = s;
break;
case '*': /* case insensitive substring search */
mode = KEYDB_SEARCH_MODE_SUBSTR;
s++;
desc->u.name = s;
break;
case '+': /* compare individual words */
mode = KEYDB_SEARCH_MODE_WORDS;
s++;
desc->u.name = s;
break;
case '#': /* local user id */
return 0; /* This is now obsolete and van't not be used anymore*/
case ':': /*Unified fingerprint */
{
const char *se, *si;
int i;
se = strchr( ++s,':');
if ( !se )
return 0;
for (i=0,si=s; si < se; si++, i++ ) {
if ( !strchr("01234567890abcdefABCDEF", *si ) )
return 0; /* invalid digit */
}
if (i != 32 && i != 40)
return 0; /* invalid length of fpr*/
for (i=0,si=s; si < se; i++, si +=2)
desc->u.fpr[i] = hextobyte(si);
for ( ; i < 20; i++)
desc->u.fpr[i]= 0;
s = se + 1;
mode = KEYDB_SEARCH_MODE_FPR;
}
break;
default:
if (s[0] == '0' && s[1] == 'x') {
hexprefix = 1;
s += 2;
}
hexlength = strspn(s, "0123456789abcdefABCDEF");
if (hexlength >= 8 && s[hexlength] =='!') {
desc->exact = 1;
hexlength++; /* just for the following check */
}
/* check if a hexadecimal number is terminated by EOS or blank */
if (hexlength && s[hexlength] && !spacep(s+hexlength)) {
if (hexprefix) /* a "0x" prefix without correct */
return 0; /* termination is an error */
else /* The first chars looked like */
hexlength = 0; /* a hex number, but really were not. */
}
if (desc->exact)
hexlength--;
if (hexlength == 8
|| (!hexprefix && hexlength == 9 && *s == '0')){
/* short keyid */
if (hexlength == 9)
s++;
desc->u.kid[0] = 0;
desc->u.kid[1] = strtoul( s, NULL, 16 );
mode = KEYDB_SEARCH_MODE_SHORT_KID;
}
else if (hexlength == 16
|| (!hexprefix && hexlength == 17 && *s == '0')) {
/* complete keyid */
char buf[9];
if (hexlength == 17)
s++;
mem2str(buf, s, 9 );
desc->u.kid[0] = strtoul( buf, NULL, 16 );
desc->u.kid[1] = strtoul( s+8, NULL, 16 );
mode = KEYDB_SEARCH_MODE_LONG_KID;
}
else if (hexlength == 32 || (!hexprefix && hexlength == 33
&& *s == '0')) {
/* md5 fingerprint */
int i;
if (hexlength == 33)
s++;
memset(desc->u.fpr+16, 0, 4);
for (i=0; i < 16; i++, s+=2) {
int c = hextobyte(s);
if (c == -1)
return 0;
desc->u.fpr[i] = c;
}
mode = KEYDB_SEARCH_MODE_FPR16;
}
else if (hexlength == 40 || (!hexprefix && hexlength == 41
&& *s == '0')) {
/* sha1/rmd160 fingerprint */
int i;
if (hexlength == 41)
s++;
for (i=0; i < 20; i++, s+=2) {
int c = hextobyte(s);
if (c == -1)
return 0;
desc->u.fpr[i] = c;
}
mode = KEYDB_SEARCH_MODE_FPR20;
}
else {
if (hexprefix) /* This was a hex number with a prefix */
return 0; /* and a wrong length */
desc->exact = 0;
desc->u.name = s;
mode = KEYDB_SEARCH_MODE_SUBSTR; /* default mode */
}
}
desc->mode = mode;
return mode;
}
static int
skip_unusable(void *dummy,u32 *keyid,PKT_user_id *uid)
{
int unusable=0;
KBNODE keyblock;
keyblock=get_pubkeyblock(keyid);
if(!keyblock)
{
log_error("error checking usability status of %s\n",keystr(keyid));
goto leave;
}
/* Is the user ID in question revoked/expired? */
if(uid)
{
KBNODE node;
for(node=keyblock;node;node=node->next)
{
if(node->pkt->pkttype==PKT_USER_ID)
{
if(cmp_user_ids(uid,node->pkt->pkt.user_id)==0
&& (node->pkt->pkt.user_id->is_revoked
|| node->pkt->pkt.user_id->is_expired))
{
unusable=1;
break;
}
}
}
}
if(!unusable)
unusable=pk_is_disabled(keyblock->pkt->pkt.public_key);
leave:
release_kbnode(keyblock);
return unusable;
}
/****************
* Try to get the pubkey by the userid. This function looks for the
* first pubkey certificate which has the given name in a user_id. if
* pk/sk has the pubkey algo set, the function will only return a
* pubkey with that algo. If namelist is NULL, the first key is
* returned. The caller should provide storage for either the pk or
* the sk. If ret_kb is not NULL the function will return the
* keyblock there.
*/
static int
key_byname( GETKEY_CTX *retctx, STRLIST namelist,
PKT_public_key *pk, PKT_secret_key *sk,
int secmode, int include_unusable,
KBNODE *ret_kb, KEYDB_HANDLE *ret_kdbhd )
{
int rc = 0;
int n;
STRLIST r;
GETKEY_CTX ctx;
KBNODE help_kb = NULL;
if( retctx ) {/* reset the returned context in case of error */
assert (!ret_kdbhd); /* not allowed because the handle is
stored in the context */
*retctx = NULL;
}
if (ret_kdbhd)
*ret_kdbhd = NULL;
if(!namelist)
{
ctx = xmalloc_clear (sizeof *ctx);
ctx->nitems = 1;
ctx->items[0].mode=KEYDB_SEARCH_MODE_FIRST;
if(!include_unusable)
ctx->items[0].skipfnc=skip_unusable;
}
else
{
/* build the search context */
for(n=0, r=namelist; r; r = r->next )
n++;
ctx = xmalloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
ctx->nitems = n;
for(n=0, r=namelist; r; r = r->next, n++ )
{
classify_user_id (r->d, &ctx->items[n]);
if (ctx->items[n].exact)
ctx->exact = 1;
if (!ctx->items[n].mode)
{
xfree (ctx);
return G10ERR_INV_USER_ID;
}
if(!include_unusable
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_SHORT_KID
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_LONG_KID
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR16
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR20
&& ctx->items[n].mode!=KEYDB_SEARCH_MODE_FPR)
ctx->items[n].skipfnc=skip_unusable;
}
}
ctx->kr_handle = keydb_new (secmode);
if ( !ret_kb )
ret_kb = &help_kb;
if( secmode ) {
if (sk) {
ctx->req_algo = sk->req_algo;
ctx->req_usage = sk->req_usage;
}
rc = lookup( ctx, ret_kb, 1 );
if ( !rc && sk ) {
sk_from_block ( ctx, sk, *ret_kb );
}
}
else {
if (pk) {
ctx->req_algo = pk->req_algo;
ctx->req_usage = pk->req_usage;
}
rc = lookup( ctx, ret_kb, 0 );
if ( !rc && pk ) {
pk_from_block ( ctx, pk, *ret_kb );
}
}
release_kbnode ( help_kb );
if (retctx) /* caller wants the context */
*retctx = ctx;
else {
if (ret_kdbhd) {
*ret_kdbhd = ctx->kr_handle;
ctx->kr_handle = NULL;
}
get_pubkey_end (ctx);
}
return rc;
}
-/*
- * Find a public key from NAME and returh the keyblock or the key.
- * If ret_kdb is not NULL, the KEYDB handle used to locate this keyblock is
- * returned and the caller is responsible for closing it.
- */
+
+
+/* Find a public key from NAME and return the keyblock or the key. If
+ ret_kdb is not NULL, the KEYDB handle used to locate this keyblock
+ is returned and the caller is responsible for closing it. If a key
+ was not found and NAME is a valid RFC822 mailbox and PKA retrieval
+ has been enabled, we try to import the pkea via the PKA
+ mechanism. */
int
get_pubkey_byname (PKT_public_key *pk,
const char *name, KBNODE *ret_keyblock,
KEYDB_HANDLE *ret_kdbhd, int include_unusable )
{
- int rc;
- STRLIST namelist = NULL;
+ int rc;
+ int again = 0;
+ STRLIST namelist = NULL;
- add_to_strlist( &namelist, name );
- rc = key_byname( NULL, namelist, pk, NULL, 0,
- include_unusable, ret_keyblock, ret_kdbhd);
- free_strlist( namelist );
- return rc;
+ add_to_strlist( &namelist, name );
+ retry:
+ rc = key_byname( NULL, namelist, pk, NULL, 0,
+ include_unusable, ret_keyblock, ret_kdbhd);
+ if (rc == G10ERR_NO_PUBKEY
+ && !again
+ && (opt.keyserver_options.options&KEYSERVER_AUTO_PKA_RETRIEVE)
+ && is_valid_mailbox (name))
+ {
+ /* If the requested name resembles a valid mailbox and
+ automatic retrieval via PKA records has been enabled, we
+ try to import the key via the URI and try again. */
+ unsigned char fpr[MAX_FINGERPRINT_LEN];
+ char *uri;
+ struct keyserver_spec *spec;
+
+ uri = get_pka_info (name, fpr);
+ if (uri)
+ {
+ spec = parse_keyserver_uri (uri, 0, NULL, 0);
+ if (spec)
+ {
+ glo_ctrl.in_auto_key_retrieve++;
+ if (!keyserver_import_fprint (fpr, 20, spec))
+ again = 1;
+ glo_ctrl.in_auto_key_retrieve--;
+ free_keyserver_spec (spec);
+ }
+ xfree (uri);
+ }
+ if (again)
+ goto retry;
+ }
+
+ free_strlist( namelist );
+ return rc;
}
int
get_pubkey_bynames( GETKEY_CTX *retctx, PKT_public_key *pk,
STRLIST names, KBNODE *ret_keyblock )
{
return key_byname( retctx, names, pk, NULL, 0, 1, ret_keyblock, NULL);
}
int
get_pubkey_next( GETKEY_CTX ctx, PKT_public_key *pk, KBNODE *ret_keyblock )
{
int rc;
rc = lookup( ctx, ret_keyblock, 0 );
if ( !rc && pk && ret_keyblock )
pk_from_block ( ctx, pk, *ret_keyblock );
return rc;
}
void
get_pubkey_end( GETKEY_CTX ctx )
{
if( ctx ) {
memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
keydb_release (ctx->kr_handle);
if( !ctx->not_allocated )
xfree( ctx );
}
}
/****************
* Search for a key with the given fingerprint.
* FIXME:
* We should replace this with the _byname function. Thiscsan be done
* by creating a userID conforming to the unified fingerprint style.
*/
int
get_pubkey_byfprint( PKT_public_key *pk,
const byte *fprint, size_t fprint_len)
{
int rc;
if( fprint_len == 20 || fprint_len == 16 ) {
struct getkey_ctx_s ctx;
KBNODE kb = NULL;
memset( &ctx, 0, sizeof ctx );
ctx.exact = 1 ;
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
: KEYDB_SEARCH_MODE_FPR20;
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
rc = lookup( &ctx, &kb, 0 );
if (!rc && pk )
pk_from_block ( &ctx, pk, kb );
release_kbnode ( kb );
get_pubkey_end( &ctx );
}
else
rc = G10ERR_GENERAL; /* Oops */
return rc;
}
/* Get a public key and store it into the allocated pk. This function
differs from get_pubkey_byfprint() in that it does not do a check
of the key to avoid recursion. It should be used only in very
certain cases. PK may be NULL to check just for the existance of
the key. */
int
get_pubkey_byfprint_fast (PKT_public_key *pk,
const byte *fprint, size_t fprint_len)
{
int rc = 0;
KEYDB_HANDLE hd;
KBNODE keyblock;
byte fprbuf[MAX_FINGERPRINT_LEN];
int i;
for (i=0; i < MAX_FINGERPRINT_LEN && i < fprint_len; i++)
fprbuf[i] = fprint[i];
while (i < MAX_FINGERPRINT_LEN)
fprbuf[i++] = 0;
hd = keydb_new (0);
rc = keydb_search_fpr (hd, fprbuf);
if (rc == -1)
{
keydb_release (hd);
return G10ERR_NO_PUBKEY;
}
rc = keydb_get_keyblock (hd, &keyblock);
keydb_release (hd);
if (rc)
{
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
return G10ERR_NO_PUBKEY;
}
assert ( keyblock->pkt->pkttype == PKT_PUBLIC_KEY
|| keyblock->pkt->pkttype == PKT_PUBLIC_SUBKEY );
if (pk)
copy_public_key (pk, keyblock->pkt->pkt.public_key );
release_kbnode (keyblock);
/* Not caching key here since it won't have all of the fields
properly set. */
return 0;
}
/****************
* Search for a key with the given fingerprint and return the
* complete keyblock which may have more than only this key.
*/
int
get_keyblock_byfprint( KBNODE *ret_keyblock, const byte *fprint,
size_t fprint_len )
{
int rc;
if( fprint_len == 20 || fprint_len == 16 ) {
struct getkey_ctx_s ctx;
memset( &ctx, 0, sizeof ctx );
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
: KEYDB_SEARCH_MODE_FPR20;
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
rc = lookup( &ctx, ret_keyblock, 0 );
get_pubkey_end( &ctx );
}
else
rc = G10ERR_GENERAL; /* Oops */
return rc;
}
/****************
* Get a secret key by name and store it into sk
* If NAME is NULL use the default key
*/
static int
get_seckey_byname2( GETKEY_CTX *retctx,
PKT_secret_key *sk, const char *name, int unprotect,
KBNODE *retblock )
{
STRLIST namelist = NULL;
int rc,include_unusable=1;
/* If we have no name, try to use the default secret key. If we
have no default, we'll use the first usable one. */
if( !name && opt.def_secret_key && *opt.def_secret_key )
add_to_strlist( &namelist, opt.def_secret_key );
else if(name)
add_to_strlist( &namelist, name );
else
include_unusable=0;
rc = key_byname( retctx, namelist, NULL, sk, 1, include_unusable,
retblock, NULL );
free_strlist( namelist );
if( !rc && unprotect )
rc = check_secret_key( sk, 0 );
return rc;
}
int
get_seckey_byname( PKT_secret_key *sk, const char *name, int unlock )
{
return get_seckey_byname2 ( NULL, sk, name, unlock, NULL );
}
int
get_seckey_bynames( GETKEY_CTX *retctx, PKT_secret_key *sk,
STRLIST names, KBNODE *ret_keyblock )
{
return key_byname( retctx, names, NULL, sk, 1, 1, ret_keyblock, NULL );
}
int
get_seckey_next( GETKEY_CTX ctx, PKT_secret_key *sk, KBNODE *ret_keyblock )
{
int rc;
rc = lookup( ctx, ret_keyblock, 1 );
if ( !rc && sk && ret_keyblock )
sk_from_block ( ctx, sk, *ret_keyblock );
return rc;
}
void
get_seckey_end( GETKEY_CTX ctx )
{
get_pubkey_end( ctx );
}
/****************
* Search for a key with the given fingerprint.
* FIXME:
* We should replace this with the _byname function. Thiscsan be done
* by creating a userID conforming to the unified fingerprint style.
*/
int
get_seckey_byfprint( PKT_secret_key *sk,
const byte *fprint, size_t fprint_len)
{
int rc;
if( fprint_len == 20 || fprint_len == 16 ) {
struct getkey_ctx_s ctx;
KBNODE kb = NULL;
memset( &ctx, 0, sizeof ctx );
ctx.exact = 1 ;
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (1);
ctx.nitems = 1;
ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
: KEYDB_SEARCH_MODE_FPR20;
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
rc = lookup( &ctx, &kb, 1 );
if (!rc && sk )
sk_from_block ( &ctx, sk, kb );
release_kbnode ( kb );
get_seckey_end( &ctx );
}
else
rc = G10ERR_GENERAL; /* Oops */
return rc;
}
/* Search for a secret key with the given fingerprint and return the
complete keyblock which may have more than only this key. */
int
get_seckeyblock_byfprint (KBNODE *ret_keyblock, const byte *fprint,
size_t fprint_len )
{
int rc;
struct getkey_ctx_s ctx;
if (fprint_len != 20 && fprint_len == 16)
return G10ERR_GENERAL; /* Oops */
memset (&ctx, 0, sizeof ctx);
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (1);
ctx.nitems = 1;
ctx.items[0].mode = (fprint_len==16
? KEYDB_SEARCH_MODE_FPR16
: KEYDB_SEARCH_MODE_FPR20);
memcpy (ctx.items[0].u.fpr, fprint, fprint_len);
rc = lookup (&ctx, ret_keyblock, 1);
get_seckey_end (&ctx);
return rc;
}
/************************************************
************* Merging stuff ********************
************************************************/
/****************
* merge all selfsignatures with the keys.
* FIXME: replace this at least for the public key parts
* by merge_selfsigs.
* It is still used in keyedit.c and
* at 2 or 3 other places - check whether it is really needed.
* It might be needed by the key edit and import stuff because
* the keylock is changed.
*/
void
merge_keys_and_selfsig( KBNODE keyblock )
{
PKT_public_key *pk = NULL;
PKT_secret_key *sk = NULL;
PKT_signature *sig;
KBNODE k;
u32 kid[2] = { 0, 0 };
u32 sigdate = 0;
if (keyblock && keyblock->pkt->pkttype == PKT_PUBLIC_KEY ) {
/* divert to our new function */
merge_selfsigs (keyblock);
return;
}
/* still need the old one because the new one can't handle secret keys */
for(k=keyblock; k; k = k->next ) {
if( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
pk = k->pkt->pkt.public_key; sk = NULL;
if( pk->version < 4 )
pk = NULL; /* not needed for old keys */
else if( k->pkt->pkttype == PKT_PUBLIC_KEY )
keyid_from_pk( pk, kid );
else if( !pk->expiredate ) { /* and subkey */
/* insert the expiration date here */
/*FIXME!!! pk->expiredate = subkeys_expiretime( k, kid );*/
}
sigdate = 0;
}
else if( k->pkt->pkttype == PKT_SECRET_KEY
|| k->pkt->pkttype == PKT_SECRET_SUBKEY ) {
pk = NULL; sk = k->pkt->pkt.secret_key;
if( sk->version < 4 )
sk = NULL;
else if( k->pkt->pkttype == PKT_SECRET_KEY )
keyid_from_sk( sk, kid );
sigdate = 0;
}
else if( (pk || sk ) && k->pkt->pkttype == PKT_SIGNATURE
&& (sig=k->pkt->pkt.signature)->sig_class >= 0x10
&& sig->sig_class <= 0x30 && sig->version > 3
&& !(sig->sig_class == 0x18 || sig->sig_class == 0x28)
&& sig->keyid[0] == kid[0] && sig->keyid[1] == kid[1] ) {
/* okay this is a self-signature which can be used.
* This is not used for subkey binding signature, becuase this
* is done above.
* FIXME: We should only use this if the signature is valid
* but this is time consuming - we must provide another
* way to handle this
*/
const byte *p;
u32 ed;
p = parse_sig_subpkt( sig->hashed, SIGSUBPKT_KEY_EXPIRE, NULL );
if( pk ) {
ed = p? pk->timestamp + buffer_to_u32(p):0;
if( sig->timestamp > sigdate ) {
pk->expiredate = ed;
sigdate = sig->timestamp;
}
}
else {
ed = p? sk->timestamp + buffer_to_u32(p):0;
if( sig->timestamp > sigdate ) {
sk->expiredate = ed;
sigdate = sig->timestamp;
}
}
}
if(pk && (pk->expiredate==0 ||
(pk->max_expiredate && pk->expiredate>pk->max_expiredate)))
pk->expiredate=pk->max_expiredate;
if(sk && (sk->expiredate==0 ||
(sk->max_expiredate && sk->expiredate>sk->max_expiredate)))
sk->expiredate=sk->max_expiredate;
}
}
static int
parse_key_usage(PKT_signature *sig)
{
int key_usage=0;
const byte *p;
size_t n;
byte flags;
p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_KEY_FLAGS,&n);
if(p && n)
{
/* first octet of the keyflags */
flags=*p;
if(flags & 3)
{
key_usage |= PUBKEY_USAGE_SIG;
flags&=~3;
}
if(flags & 12)
{
key_usage |= PUBKEY_USAGE_ENC;
flags&=~12;
}
if(flags & 0x20)
{
key_usage |= PUBKEY_USAGE_AUTH;
flags&=~0x20;
}
if(flags)
key_usage |= PUBKEY_USAGE_UNKNOWN;
}
/* We set PUBKEY_USAGE_UNKNOWN to indicate that this key has a
capability that we do not handle. This serves to distinguish
between a zero key usage which we handle as the default
capabilities for that algorithm, and a usage that we do not
handle. */
return key_usage;
}
/*
* Apply information from SIGNODE (which is the valid self-signature
* associated with that UID) to the UIDNODE:
* - wether the UID has been revoked
* - assumed creation date of the UID
* - temporary store the keyflags here
* - temporary store the key expiration time here
* - mark whether the primary user ID flag hat been set.
* - store the preferences
*/
static void
fixup_uidnode ( KBNODE uidnode, KBNODE signode, u32 keycreated )
{
PKT_user_id *uid = uidnode->pkt->pkt.user_id;
PKT_signature *sig = signode->pkt->pkt.signature;
const byte *p, *sym, *hash, *zip;
size_t n, nsym, nhash, nzip;
sig->flags.chosen_selfsig = 1; /* we chose this one */
uid->created = 0; /* not created == invalid */
if ( IS_UID_REV ( sig ) ) {
uid->is_revoked = 1;
return; /* has been revoked */
}
uid->expiredate = sig->expiredate;
if(sig->flags.expired)
{
uid->is_expired = 1;
return; /* has expired */
}
uid->created = sig->timestamp; /* this one is okay */
uid->selfsigversion = sig->version;
/* If we got this far, it's not expired :) */
uid->is_expired = 0;
/* store the key flags in the helper variable for later processing */
uid->help_key_usage=parse_key_usage(sig);
/* ditto or the key expiration */
uid->help_key_expire = 0;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE, NULL);
if ( p ) {
uid->help_key_expire = keycreated + buffer_to_u32(p);
}
/* Set the primary user ID flag - we will later wipe out some
* of them to only have one in our keyblock */
uid->is_primary = 0;
p = parse_sig_subpkt ( sig->hashed, SIGSUBPKT_PRIMARY_UID, NULL );
if ( p && *p )
uid->is_primary = 2;
/* We could also query this from the unhashed area if it is not in
* the hased area and then later try to decide which is the better
* there should be no security problem with this.
* For now we only look at the hashed one.
*/
/* Now build the preferences list. These must come from the
hashed section so nobody can modify the ciphers a key is
willing to accept. */
p = parse_sig_subpkt ( sig->hashed, SIGSUBPKT_PREF_SYM, &n );
sym = p; nsym = p?n:0;
p = parse_sig_subpkt ( sig->hashed, SIGSUBPKT_PREF_HASH, &n );
hash = p; nhash = p?n:0;
p = parse_sig_subpkt ( sig->hashed, SIGSUBPKT_PREF_COMPR, &n );
zip = p; nzip = p?n:0;
if (uid->prefs)
xfree (uid->prefs);
n = nsym + nhash + nzip;
if (!n)
uid->prefs = NULL;
else {
uid->prefs = xmalloc (sizeof (*uid->prefs) * (n+1));
n = 0;
for (; nsym; nsym--, n++) {
uid->prefs[n].type = PREFTYPE_SYM;
uid->prefs[n].value = *sym++;
}
for (; nhash; nhash--, n++) {
uid->prefs[n].type = PREFTYPE_HASH;
uid->prefs[n].value = *hash++;
}
for (; nzip; nzip--, n++) {
uid->prefs[n].type = PREFTYPE_ZIP;
uid->prefs[n].value = *zip++;
}
uid->prefs[n].type = PREFTYPE_NONE; /* end of list marker */
uid->prefs[n].value = 0;
}
/* see whether we have the MDC feature */
uid->mdc_feature = 0;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_FEATURES, &n);
if (p && n && (p[0] & 0x01))
uid->mdc_feature = 1;
/* and the keyserver modify flag */
uid->ks_modify = 1;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KS_FLAGS, &n);
if (p && n && (p[0] & 0x80))
uid->ks_modify = 0;
}
static void
sig_to_revoke_info(PKT_signature *sig,struct revoke_info *rinfo)
{
rinfo->date = sig->timestamp;
rinfo->algo = sig->pubkey_algo;
rinfo->keyid[0] = sig->keyid[0];
rinfo->keyid[1] = sig->keyid[1];
}
static void
merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo)
{
PKT_public_key *pk = NULL;
KBNODE k;
u32 kid[2];
u32 sigdate, uiddate, uiddate2;
KBNODE signode, uidnode, uidnode2;
u32 curtime = make_timestamp ();
unsigned int key_usage = 0;
u32 keytimestamp = 0;
u32 key_expire = 0;
int key_expire_seen = 0;
byte sigversion = 0;
*r_revoked = 0;
memset(rinfo,0,sizeof(*rinfo));
if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY )
BUG ();
pk = keyblock->pkt->pkt.public_key;
keytimestamp = pk->timestamp;
keyid_from_pk( pk, kid );
pk->main_keyid[0] = kid[0];
pk->main_keyid[1] = kid[1];
if ( pk->version < 4 ) {
/* before v4 the key packet itself contains the expiration
* date and there was no way to change it, so we start with
* the one from the key packet */
key_expire = pk->max_expiredate;
key_expire_seen = 1;
}
/* first pass: find the latest direct key self-signature.
* We assume that the newest one overrides all others
*/
/* In case this key was already merged */
xfree(pk->revkey);
pk->revkey=NULL;
pk->numrevkeys=0;
signode = NULL;
sigdate = 0; /* helper to find the latest signature */
for(k=keyblock; k && k->pkt->pkttype != PKT_USER_ID; k = k->next ) {
if ( k->pkt->pkttype == PKT_SIGNATURE ) {
PKT_signature *sig = k->pkt->pkt.signature;
if ( sig->keyid[0] == kid[0] && sig->keyid[1]==kid[1] ) {
if ( check_key_signature( keyblock, k, NULL ) )
; /* signature did not verify */
else if ( IS_KEY_REV (sig) ){
/* key has been revoked - there is no way to override
* such a revocation, so we theoretically can stop now.
* We should not cope with expiration times for revocations
* here because we have to assume that an attacker can
* generate all kinds of signatures. However due to the
* fact that the key has been revoked it does not harm
* either and by continuing we gather some more info on
* that key.
*/
*r_revoked = 1;
sig_to_revoke_info(sig,rinfo);
}
else if ( IS_KEY_SIG (sig) ) {
/* 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 sensitive and hence in a
different signature). */
if(sig->revkey) {
int i;
pk->revkey=
xrealloc(pk->revkey,sizeof(struct revocation_key)*
(pk->numrevkeys+sig->numrevkeys));
for(i=0;i<sig->numrevkeys;i++)
memcpy(&pk->revkey[pk->numrevkeys++],
sig->revkey[i],
sizeof(struct revocation_key));
}
if( sig->timestamp >= sigdate ) {
if(sig->flags.expired)
; /* signature has expired - ignore it */
else {
sigdate = sig->timestamp;
signode = k;
if( sig->version > sigversion )
sigversion = sig->version;
}
}
}
}
}
}
/* Remove dupes from the revocation keys */
if(pk->revkey)
{
int i,j,x,changed=0;
for(i=0;i<pk->numrevkeys;i++)
{
for(j=i+1;j<pk->numrevkeys;j++)
{
if(memcmp(&pk->revkey[i],&pk->revkey[j],
sizeof(struct revocation_key))==0)
{
/* remove j */
for(x=j;x<pk->numrevkeys-1;x++)
pk->revkey[x]=pk->revkey[x+1];
pk->numrevkeys--;
j--;
changed=1;
}
}
}
if(changed)
pk->revkey=xrealloc(pk->revkey,
pk->numrevkeys*sizeof(struct revocation_key));
}
if ( signode )
{
/* some information from a direct key signature take precedence
* over the same information given in UID sigs.
*/
PKT_signature *sig = signode->pkt->pkt.signature;
const byte *p;
key_usage=parse_key_usage(sig);
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE, NULL);
if ( p )
{
key_expire = keytimestamp + buffer_to_u32(p);
key_expire_seen = 1;
}
/* mark that key as valid: one direct key signature should
* render a key as valid */
pk->is_valid = 1;
}
/* pass 1.5: look for key revocation signatures that were not made
by the key (i.e. did a revocation key issue a revocation for
us?). Only bother to do this if there is a revocation key in
the first place and we're not revoked already. */
if(!*r_revoked && pk->revkey)
for(k=keyblock; k && k->pkt->pkttype != PKT_USER_ID; k = k->next )
{
if ( k->pkt->pkttype == PKT_SIGNATURE )
{
PKT_signature *sig = k->pkt->pkt.signature;
if(IS_KEY_REV(sig) &&
(sig->keyid[0]!=kid[0] || sig->keyid[1]!=kid[1]))
{
int rc=check_revocation_keys(pk,sig);
if(rc==0)
{
*r_revoked=2;
sig_to_revoke_info(sig,rinfo);
/* don't continue checking since we can't be any
more revoked than this */
break;
}
else if(rc==G10ERR_NO_PUBKEY)
pk->maybe_revoked=1;
/* A failure here means the sig did not verify, was
not issued by a revocation key, or a revocation
key loop was broken. If a revocation key isn't
findable, however, the key might be revoked and
we don't know it. */
/* TODO: In the future handle subkey and cert
revocations? PGP doesn't, but it's in 2440. */
}
}
}
/* second pass: look at the self-signature of all user IDs */
signode = uidnode = NULL;
sigdate = 0; /* helper to find the latest signature in one user ID */
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID ) {
if ( uidnode && signode )
{
fixup_uidnode ( uidnode, signode, keytimestamp );
pk->is_valid=1;
}
uidnode = k;
signode = NULL;
sigdate = 0;
}
else if ( k->pkt->pkttype == PKT_SIGNATURE && uidnode ) {
PKT_signature *sig = k->pkt->pkt.signature;
if ( sig->keyid[0] == kid[0] && sig->keyid[1]==kid[1] ) {
if ( check_key_signature( keyblock, k, NULL ) )
; /* signature did not verify */
else if ( (IS_UID_SIG (sig) || IS_UID_REV (sig))
&& sig->timestamp >= sigdate )
{
/* Note: we allow to invalidate cert revocations
* by a newer signature. An attacker can't use this
* because a key should be revoced with a key revocation.
* The reason why we have to allow for that is that at
* one time an email address may become invalid but later
* the same email address may become valid again (hired,
* fired, hired again).
*/
sigdate = sig->timestamp;
signode = k;
signode->pkt->pkt.signature->flags.chosen_selfsig=0;
if( sig->version > sigversion )
sigversion = sig->version;
}
}
}
}
if ( uidnode && signode ) {
fixup_uidnode ( uidnode, signode, keytimestamp );
pk->is_valid = 1;
}
/* If the key isn't valid yet, and we have
--allow-non-selfsigned-uid set, then force it valid. */
if(!pk->is_valid && opt.allow_non_selfsigned_uid)
{
if(opt.verbose)
log_info(_("Invalid key %s made valid by"
" --allow-non-selfsigned-uid\n"),keystr_from_pk(pk));
pk->is_valid = 1;
}
/* The key STILL isn't valid, so try and find an ultimately
trusted signature. */
if(!pk->is_valid)
{
uidnode=NULL;
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k=k->next)
{
if ( k->pkt->pkttype == PKT_USER_ID )
uidnode = k;
else if ( k->pkt->pkttype == PKT_SIGNATURE && uidnode )
{
PKT_signature *sig = k->pkt->pkt.signature;
if(sig->keyid[0] != kid[0] || sig->keyid[1]!=kid[1])
{
PKT_public_key *ultimate_pk;
ultimate_pk=xmalloc_clear(sizeof(*ultimate_pk));
/* We don't want to use the full get_pubkey to
avoid infinite recursion in certain cases.
There is no reason to check that an ultimately
trusted key is still valid - if it has been
revoked or the user should also renmove the
ultimate trust flag. */
if(get_pubkey_fast(ultimate_pk,sig->keyid)==0
&& check_key_signature2(keyblock,k,ultimate_pk,
NULL,NULL,NULL,NULL)==0
&& get_ownertrust(ultimate_pk)==TRUST_ULTIMATE)
{
free_public_key(ultimate_pk);
pk->is_valid=1;
break;
}
free_public_key(ultimate_pk);
}
}
}
}
/* Record the highest selfsig version so we know if this is a v3
key through and through, or a v3 key with a v4 selfsig
somewhere. This is useful in a few places to know if the key
must be treated as PGP2-style or OpenPGP-style. Note that a
selfsig revocation with a higher version number will also raise
this value. This is okay since such a revocation must be
issued by the user (i.e. it cannot be issued by someone else to
modify the key behavior.) */
pk->selfsigversion=sigversion;
/* Now that we had a look at all user IDs we can now get some information
* from those user IDs.
*/
if ( !key_usage ) {
/* find the latest user ID with key flags set */
uiddate = 0; /* helper to find the latest user ID */
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
k = k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID ) {
PKT_user_id *uid = k->pkt->pkt.user_id;
if ( uid->help_key_usage && uid->created > uiddate ) {
key_usage = uid->help_key_usage;
uiddate = uid->created;
}
}
}
}
if ( !key_usage ) { /* no key flags at all: get it from the algo */
key_usage = openpgp_pk_algo_usage ( pk->pubkey_algo );
}
else { /* check that the usage matches the usage as given by the algo */
int x = openpgp_pk_algo_usage ( pk->pubkey_algo );
if ( x ) /* mask it down to the actual allowed usage */
key_usage &= x;
}
pk->pubkey_usage = key_usage;
if ( !key_expire_seen ) {
/* find the latest valid user ID with a key expiration set
* Note, that this may be a different one from the above because
* some user IDs may have no expiration date set */
uiddate = 0;
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
k = k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID ) {
PKT_user_id *uid = k->pkt->pkt.user_id;
if ( uid->help_key_expire && uid->created > uiddate ) {
key_expire = uid->help_key_expire;
uiddate = uid->created;
}
}
}
}
/* Currently only v3 keys have a maximum expiration date, but I'll
bet v5 keys get this feature again. */
if(key_expire==0 || (pk->max_expiredate && key_expire>pk->max_expiredate))
key_expire=pk->max_expiredate;
pk->has_expired = key_expire >= curtime? 0 : key_expire;
pk->expiredate = key_expire;
/* Fixme: we should see how to get rid of the expiretime fields but
* this needs changes at other places too. */
/* and now find the real primary user ID and delete all others */
uiddate = uiddate2 = 0;
uidnode = uidnode2 = NULL;
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID &&
!k->pkt->pkt.user_id->attrib_data) {
PKT_user_id *uid = k->pkt->pkt.user_id;
if (uid->is_primary)
{
if(uid->created > uiddate)
{
uiddate = uid->created;
uidnode = k;
}
else if(uid->created==uiddate && uidnode)
{
/* The dates are equal, so we need to do a
different (and arbitrary) comparison. This
should rarely, if ever, happen. It's good to
try and guarantee that two different GnuPG
users with two different keyrings at least pick
the same primary. */
if(cmp_user_ids(uid,uidnode->pkt->pkt.user_id)>0)
uidnode=k;
}
}
else
{
if(uid->created > uiddate2)
{
uiddate2 = uid->created;
uidnode2 = k;
}
else if(uid->created==uiddate2 && uidnode2)
{
if(cmp_user_ids(uid,uidnode2->pkt->pkt.user_id)>0)
uidnode2=k;
}
}
}
}
if ( uidnode ) {
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
k = k->next ) {
if ( k->pkt->pkttype == PKT_USER_ID &&
!k->pkt->pkt.user_id->attrib_data) {
PKT_user_id *uid = k->pkt->pkt.user_id;
if ( k != uidnode )
uid->is_primary = 0;
}
}
}
else if( uidnode2 ) {
/* none is flagged primary - use the latest user ID we have,
and disambiguate with the arbitrary packet comparison. */
uidnode2->pkt->pkt.user_id->is_primary = 1;
}
else
{
/* None of our uids were self-signed, so pick the one that
sorts first to be the primary. This is the best we can do
here since there are no self sigs to date the uids. */
uidnode = NULL;
for(k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
k = k->next )
{
if(k->pkt->pkttype==PKT_USER_ID
&& !k->pkt->pkt.user_id->attrib_data)
{
if(!uidnode)
{
uidnode=k;
uidnode->pkt->pkt.user_id->is_primary=1;
continue;
}
else
{
if(cmp_user_ids(k->pkt->pkt.user_id,
uidnode->pkt->pkt.user_id)>0)
{
uidnode->pkt->pkt.user_id->is_primary=0;
uidnode=k;
uidnode->pkt->pkt.user_id->is_primary=1;
}
else
k->pkt->pkt.user_id->is_primary=0; /* just to be
safe */
}
}
}
}
}
static void
merge_selfsigs_subkey( KBNODE keyblock, KBNODE subnode )
{
PKT_public_key *mainpk = NULL, *subpk = NULL;
PKT_signature *sig;
KBNODE k;
u32 mainkid[2];
u32 sigdate = 0;
KBNODE signode;
u32 curtime = make_timestamp ();
unsigned int key_usage = 0;
u32 keytimestamp = 0;
u32 key_expire = 0;
const byte *p;
if ( subnode->pkt->pkttype != PKT_PUBLIC_SUBKEY )
BUG ();
mainpk = keyblock->pkt->pkt.public_key;
if ( mainpk->version < 4 )
return; /* (actually this should never happen) */
keyid_from_pk( mainpk, mainkid );
subpk = subnode->pkt->pkt.public_key;
keytimestamp = subpk->timestamp;
subpk->is_valid = 0;
subpk->main_keyid[0] = mainpk->main_keyid[0];
subpk->main_keyid[1] = mainpk->main_keyid[1];
/* find the latest key binding self-signature. */
signode = NULL;
sigdate = 0; /* helper to find the latest signature */
for(k=subnode->next; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY;
k = k->next ) {
if ( k->pkt->pkttype == PKT_SIGNATURE ) {
sig = k->pkt->pkt.signature;
if ( sig->keyid[0] == mainkid[0] && sig->keyid[1]==mainkid[1] ) {
if ( check_key_signature( keyblock, k, NULL ) )
; /* signature did not verify */
else if ( IS_SUBKEY_REV (sig) ) {
/* Note that this means that the date on a
revocation sig does not matter - even if the
binding sig is dated after the revocation sig,
the subkey is still marked as revoked. This
seems ok, as it is just as easy to make new
subkeys rather than re-sign old ones as the
problem is in the distribution. Plus, PGP (7)
does this the same way. */
subpk->is_revoked = 1;
sig_to_revoke_info(sig,&subpk->revoked);
/* although we could stop now, we continue to
* figure out other information like the old expiration
* time */
}
else if ( IS_SUBKEY_SIG (sig) && sig->timestamp >= sigdate )
{
if(sig->flags.expired)
; /* signature has expired - ignore it */
else
{
sigdate = sig->timestamp;
signode = k;
signode->pkt->pkt.signature->flags.chosen_selfsig=0;
}
}
}
}
}
/* no valid key binding */
if ( !signode )
return;
sig = signode->pkt->pkt.signature;
sig->flags.chosen_selfsig=1; /* so we know which selfsig we chose later */
key_usage=parse_key_usage(sig);
if ( !key_usage )
{
/* no key flags at all: get it from the algo */
key_usage = openpgp_pk_algo_usage ( subpk->pubkey_algo );
}
else
{
/* check that the usage matches the usage as given by the algo */
int x = openpgp_pk_algo_usage ( subpk->pubkey_algo );
if ( x ) /* mask it down to the actual allowed usage */
key_usage &= x;
}
subpk->pubkey_usage = key_usage;
p = parse_sig_subpkt (sig->hashed, SIGSUBPKT_KEY_EXPIRE, NULL);
if ( p )
key_expire = keytimestamp + buffer_to_u32(p);
else
key_expire = 0;
subpk->has_expired = key_expire >= curtime? 0 : key_expire;
subpk->expiredate = key_expire;
/* algo doesn't exist */
if(check_pubkey_algo(subpk->pubkey_algo))
return;
subpk->is_valid = 1;
#ifndef DO_BACKSIGS
/* Pretend the backsig is present and accounted for. */
subpk->backsig=2;
#else
/* Find the first 0x19 embedded signature on our self-sig. */
if(subpk->backsig==0)
{
int seq=0;
size_t n;
while((p=enum_sig_subpkt(sig->hashed,
SIGSUBPKT_SIGNATURE,&n,&seq,NULL)))
if(n>3 && ((p[0]==3 && p[2]==0x19) || (p[0]==4 && p[1]==0x19)))
break;
if(p==NULL)
{
seq=0;
/* It is safe to have this in the unhashed area since the
0x19 is located here for convenience, not security. */
while((p=enum_sig_subpkt(sig->unhashed,SIGSUBPKT_SIGNATURE,
&n,&seq,NULL)))
if(n>3 && ((p[0]==3 && p[2]==0x19) || (p[0]==4 && p[1]==0x19)))
break;
}
if(p)
{
PKT_signature *backsig=xmalloc_clear(sizeof(PKT_signature));
IOBUF backsig_buf=iobuf_temp_with_content(p,n);
if(parse_signature(backsig_buf,PKT_SIGNATURE,n,backsig)==0)
{
if(check_backsig(mainpk,subpk,backsig)==0)
subpk->backsig=2;
else
subpk->backsig=1;
}
iobuf_close(backsig_buf);
free_seckey_enc(backsig);
}
}
#endif
}
/*
* Merge information from the self-signatures with the key, so that
* we can later use them more easy.
* The function works by first applying the self signatures to the
* primary key and the to each subkey.
* Here are the rules we use to decide which inormation from which
* self-signature is used:
* We check all self signatures or validity and ignore all invalid signatures.
* All signatures are then ordered by their creation date ....
* For the primary key:
* FIXME the docs
*/
static void
merge_selfsigs( KBNODE keyblock )
{
KBNODE k;
int revoked;
struct revoke_info rinfo;
PKT_public_key *main_pk;
prefitem_t *prefs;
int mdc_feature;
if ( keyblock->pkt->pkttype != PKT_PUBLIC_KEY ) {
if (keyblock->pkt->pkttype == PKT_SECRET_KEY ) {
log_error ("expected public key but found secret key "
"- must stop\n");
/* we better exit here becuase a public key is expected at
other places too. FIXME: Figure this out earlier and
don't get to here at all */
g10_exit (1);
}
BUG ();
}
merge_selfsigs_main ( keyblock, &revoked, &rinfo );
/* now merge in the data from each of the subkeys */
for(k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
merge_selfsigs_subkey ( keyblock, k );
}
}
main_pk = keyblock->pkt->pkt.public_key;
if ( revoked || main_pk->has_expired || !main_pk->is_valid ) {
/* if the primary key is revoked, expired, or invalid we
* better set the appropriate flags on that key and all
* subkeys */
for(k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
PKT_public_key *pk = k->pkt->pkt.public_key;
if(!main_pk->is_valid)
pk->is_valid = 0;
if(revoked && !pk->is_revoked)
{
pk->is_revoked = revoked;
memcpy(&pk->revoked,&rinfo,sizeof(rinfo));
}
if(main_pk->has_expired)
pk->has_expired = main_pk->has_expired;
}
}
return;
}
/* set the preference list of all keys to those of the primary real
* user ID. Note: we use these preferences when we don't know by
* which user ID the key has been selected.
* fixme: we should keep atoms of commonly used preferences or
* use reference counting to optimize the preference lists storage.
* FIXME: it might be better to use the intersection of
* all preferences.
* Do a similar thing for the MDC feature flag.
*/
prefs = NULL;
mdc_feature = 0;
for (k=keyblock; k && k->pkt->pkttype != PKT_PUBLIC_SUBKEY; k = k->next) {
if (k->pkt->pkttype == PKT_USER_ID
&& !k->pkt->pkt.user_id->attrib_data
&& k->pkt->pkt.user_id->is_primary) {
prefs = k->pkt->pkt.user_id->prefs;
mdc_feature = k->pkt->pkt.user_id->mdc_feature;
break;
}
}
for(k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
PKT_public_key *pk = k->pkt->pkt.public_key;
if (pk->prefs)
xfree (pk->prefs);
pk->prefs = copy_prefs (prefs);
pk->mdc_feature = mdc_feature;
}
}
}
/*
* Merge the secret keys from secblock into the pubblock thereby
* replacing the public (sub)keys with their secret counterparts Hmmm:
* It might be better to get away from the concept of entire secret
* keys at all and have a way to store just the real secret parts
* from the key.
*/
static void
merge_public_with_secret ( KBNODE pubblock, KBNODE secblock )
{
KBNODE pub;
assert ( pubblock->pkt->pkttype == PKT_PUBLIC_KEY );
assert ( secblock->pkt->pkttype == PKT_SECRET_KEY );
for (pub=pubblock; pub; pub = pub->next ) {
if ( pub->pkt->pkttype == PKT_PUBLIC_KEY ) {
PKT_public_key *pk = pub->pkt->pkt.public_key;
PKT_secret_key *sk = secblock->pkt->pkt.secret_key;
assert ( pub == pubblock ); /* only in the first node */
/* there is nothing to compare in this case, so just replace
* some information */
copy_public_parts_to_secret_key ( pk, sk );
free_public_key ( pk );
pub->pkt->pkttype = PKT_SECRET_KEY;
pub->pkt->pkt.secret_key = copy_secret_key (NULL, sk);
}
else if ( pub->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
KBNODE sec;
PKT_public_key *pk = pub->pkt->pkt.public_key;
/* this is more complicated: it may happen that the sequence
* of the subkeys dosn't match, so we have to find the
* appropriate secret key */
for (sec=secblock->next; sec; sec = sec->next ) {
if ( sec->pkt->pkttype == PKT_SECRET_SUBKEY ) {
PKT_secret_key *sk = sec->pkt->pkt.secret_key;
if ( !cmp_public_secret_key ( pk, sk ) ) {
copy_public_parts_to_secret_key ( pk, sk );
free_public_key ( pk );
pub->pkt->pkttype = PKT_SECRET_SUBKEY;
pub->pkt->pkt.secret_key = copy_secret_key (NULL, sk);
break;
}
}
}
if ( !sec )
BUG(); /* already checked in premerge */
}
}
}
/* This function checks that for every public subkey a corresponding
* secret subkey is available and deletes the public subkey otherwise.
* We need this function because we can't delete it later when we
* actually merge the secret parts into the pubring.
* The function also plays some games with the node flags.
*/
static void
premerge_public_with_secret ( KBNODE pubblock, KBNODE secblock )
{
KBNODE last, pub;
assert ( pubblock->pkt->pkttype == PKT_PUBLIC_KEY );
assert ( secblock->pkt->pkttype == PKT_SECRET_KEY );
for (pub=pubblock,last=NULL; pub; last = pub, pub = pub->next ) {
pub->flag &= ~3; /* reset bits 0 and 1 */
if ( pub->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
KBNODE sec;
PKT_public_key *pk = pub->pkt->pkt.public_key;
for (sec=secblock->next; sec; sec = sec->next ) {
if ( sec->pkt->pkttype == PKT_SECRET_SUBKEY ) {
PKT_secret_key *sk = sec->pkt->pkt.secret_key;
if ( !cmp_public_secret_key ( pk, sk ) ) {
if ( sk->protect.s2k.mode == 1001 ) {
/* The secret parts are not available so
we can't use that key for signing etc.
Fix the pubkey usage */
pk->pubkey_usage &= ~(PUBKEY_USAGE_SIG
|PUBKEY_USAGE_AUTH);
}
/* transfer flag bits 0 and 1 to the pubblock */
pub->flag |= (sec->flag &3);
break;
}
}
}
if ( !sec ) {
KBNODE next, ll;
if (opt.verbose)
log_info (_("no secret subkey"
" for public subkey %s - ignoring\n"),
keystr_from_pk (pk));
/* we have to remove the subkey in this case */
assert ( last );
/* find the next subkey */
for (next=pub->next,ll=pub;
next && next->pkt->pkttype != PKT_PUBLIC_SUBKEY;
ll = next, next = next->next )
;
/* make new link */
last->next = next;
/* release this public subkey with all sigs */
ll->next = NULL;
release_kbnode( pub );
/* let the loop continue */
pub = last;
}
}
}
/* We need to copy the found bits (0 and 1) from the secret key to
the public key. This has already been done for the subkeys but
got lost on the primary key - fix it here *. */
pubblock->flag |= (secblock->flag & 3);
}
/* See see whether the key fits
* our requirements and in case we do not
* request the primary key, we should select
* a suitable subkey.
* FIXME: Check against PGP 7 whether we still need a kludge
* to favor type 16 keys over type 20 keys when type 20
* has not been explitely requested.
* Returns: True when a suitable key has been found.
*
* We have to distinguish four cases: FIXME!
* 1. No usage and no primary key requested
* Examples for this case are that we have a keyID to be used
* for decrytion or verification.
* 2. No usage but primary key requested
* This is the case for all functions which work on an
* entire keyblock, e.g. for editing or listing
* 3. Usage and primary key requested
* FXME
* 4. Usage but no primary key requested
* FIXME
* FIXME: Tell what is going to happen here and something about the rationale
* Note: We don't use this function if no specific usage is requested;
* This way the getkey functions can be used for plain key listings.
*
* CTX ist the keyblock we are investigating, if FOUNDK is not NULL this
* is the key we actually found by looking at the keyid or a fingerprint and
* may eitehr point to the primary or one of the subkeys.
*/
static int
finish_lookup (GETKEY_CTX ctx)
{
KBNODE keyblock = ctx->keyblock;
KBNODE k;
KBNODE foundk = NULL;
PKT_user_id *foundu = NULL;
#define USAGE_MASK (PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC)
unsigned int req_usage = ( ctx->req_usage & USAGE_MASK );
/* Request the primary if we're certifying another key, and also
if signing data while --pgp6 or --pgp7 is on since pgp 6 and 7
do not understand signatures made by a signing subkey. PGP 8
does. */
int req_prim = (ctx->req_usage & PUBKEY_USAGE_CERT) ||
((PGP6 || PGP7) && (ctx->req_usage & PUBKEY_USAGE_SIG));
u32 latest_date;
KBNODE latest_key;
u32 curtime = make_timestamp ();
assert( keyblock->pkt->pkttype == PKT_PUBLIC_KEY );
ctx->found_key = NULL;
if (ctx->exact) {
for (k=keyblock; k; k = k->next) {
if ( (k->flag & 1) ) {
assert ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY );
foundk = k;
break;
}
}
}
for (k=keyblock; k; k = k->next) {
if ( (k->flag & 2) ) {
assert (k->pkt->pkttype == PKT_USER_ID);
foundu = k->pkt->pkt.user_id;
break;
}
}
if ( DBG_CACHE )
log_debug( "finish_lookup: checking key %08lX (%s)(req_usage=%x)\n",
(ulong)keyid_from_pk( keyblock->pkt->pkt.public_key, NULL),
foundk? "one":"all", req_usage);
if (!req_usage) {
latest_key = foundk? foundk:keyblock;
goto found;
}
if (!req_usage) {
PKT_public_key *pk = foundk->pkt->pkt.public_key;
if (pk->user_id)
free_user_id (pk->user_id);
pk->user_id = scopy_user_id (foundu);
ctx->found_key = foundk;
cache_user_id( keyblock );
return 1; /* found */
}
latest_date = 0;
latest_key = NULL;
/* do not look at subkeys if a certification key is requested */
if ((!foundk || foundk->pkt->pkttype == PKT_PUBLIC_SUBKEY) && !req_prim) {
KBNODE nextk;
/* either start a loop or check just this one subkey */
for (k=foundk?foundk:keyblock; k; k = nextk ) {
PKT_public_key *pk;
nextk = k->next;
if ( k->pkt->pkttype != PKT_PUBLIC_SUBKEY )
continue;
if ( foundk )
nextk = NULL; /* what a hack */
pk = k->pkt->pkt.public_key;
if (DBG_CACHE)
log_debug( "\tchecking subkey %08lX\n",
(ulong)keyid_from_pk( pk, NULL));
if ( !pk->is_valid ) {
if (DBG_CACHE)
log_debug( "\tsubkey not valid\n");
continue;
}
if ( pk->is_revoked ) {
if (DBG_CACHE)
log_debug( "\tsubkey has been revoked\n");
continue;
}
if ( pk->has_expired ) {
if (DBG_CACHE)
log_debug( "\tsubkey has expired\n");
continue;
}
if ( pk->timestamp > curtime && !opt.ignore_valid_from ) {
if (DBG_CACHE)
log_debug( "\tsubkey not yet valid\n");
continue;
}
if ( !((pk->pubkey_usage&USAGE_MASK) & req_usage) ) {
if (DBG_CACHE)
log_debug( "\tusage does not match: want=%x have=%x\n",
req_usage, pk->pubkey_usage );
continue;
}
if (DBG_CACHE)
log_debug( "\tsubkey looks fine\n");
if ( pk->timestamp > latest_date ) {
latest_date = pk->timestamp;
latest_key = k;
}
}
}
/* Okay now try the primary key unless we want an exact
* key ID match on a subkey */
if ((!latest_key && !(ctx->exact && foundk != keyblock)) || req_prim) {
PKT_public_key *pk;
if (DBG_CACHE && !foundk && !req_prim )
log_debug( "\tno suitable subkeys found - trying primary\n");
pk = keyblock->pkt->pkt.public_key;
if ( !pk->is_valid ) {
if (DBG_CACHE)
log_debug( "\tprimary key not valid\n");
}
else if ( pk->is_revoked ) {
if (DBG_CACHE)
log_debug( "\tprimary key has been revoked\n");
}
else if ( pk->has_expired ) {
if (DBG_CACHE)
log_debug( "\tprimary key has expired\n");
}
else if ( !((pk->pubkey_usage&USAGE_MASK) & req_usage) ) {
if (DBG_CACHE)
log_debug( "\tprimary key usage does not match: "
"want=%x have=%x\n",
req_usage, pk->pubkey_usage );
}
else { /* okay */
if (DBG_CACHE)
log_debug( "\tprimary key may be used\n");
latest_key = keyblock;
latest_date = pk->timestamp;
}
}
if ( !latest_key ) {
if (DBG_CACHE)
log_debug("\tno suitable key found - giving up\n");
return 0;
}
found:
if (DBG_CACHE)
log_debug( "\tusing key %08lX\n",
(ulong)keyid_from_pk( latest_key->pkt->pkt.public_key, NULL) );
if (latest_key) {
PKT_public_key *pk = latest_key->pkt->pkt.public_key;
if (pk->user_id)
free_user_id (pk->user_id);
pk->user_id = scopy_user_id (foundu);
}
ctx->found_key = latest_key;
if (latest_key != keyblock && opt.verbose)
{
char *tempkeystr=
xstrdup(keystr_from_pk(latest_key->pkt->pkt.public_key));
log_info(_("using subkey %s instead of primary key %s\n"),
tempkeystr, keystr_from_pk(keyblock->pkt->pkt.public_key));
xfree(tempkeystr);
}
cache_user_id( keyblock );
return 1; /* found */
}
static int
lookup( GETKEY_CTX ctx, KBNODE *ret_keyblock, int secmode )
{
int rc;
KBNODE secblock = NULL; /* helper */
int no_suitable_key = 0;
rc = 0;
while (!(rc = keydb_search (ctx->kr_handle, ctx->items, ctx->nitems))) {
/* If we are searching for the first key we have to make sure
that the next interation does not no an implicit reset.
This can be triggered by an empty key ring. */
if (ctx->nitems && ctx->items->mode == KEYDB_SEARCH_MODE_FIRST)
ctx->items->mode = KEYDB_SEARCH_MODE_NEXT;
rc = keydb_get_keyblock (ctx->kr_handle, &ctx->keyblock);
if (rc) {
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
rc = 0;
goto skip;
}
if ( secmode ) {
/* find the correspondig public key and use this
* this one for the selection process */
u32 aki[2];
KBNODE k = ctx->keyblock;
if (k->pkt->pkttype != PKT_SECRET_KEY)
BUG();
keyid_from_sk (k->pkt->pkt.secret_key, aki);
k = get_pubkeyblock (aki);
if( !k )
{
if (!opt.quiet)
log_info(_("key %s: secret key without public key"
" - skipped\n"), keystr(aki));
goto skip;
}
secblock = ctx->keyblock;
ctx->keyblock = k;
premerge_public_with_secret ( ctx->keyblock, secblock );
}
/* warning: node flag bits 0 and 1 should be preserved by
* merge_selfsigs. For secret keys, premerge did tranfer the
* keys to the keyblock */
merge_selfsigs ( ctx->keyblock );
if ( finish_lookup (ctx) ) {
no_suitable_key = 0;
if ( secmode ) {
merge_public_with_secret ( ctx->keyblock,
secblock);
release_kbnode (secblock);
secblock = NULL;
}
goto found;
}
else
no_suitable_key = 1;
skip:
/* release resources and continue search */
if ( secmode ) {
release_kbnode( secblock );
secblock = NULL;
}
release_kbnode( ctx->keyblock );
ctx->keyblock = NULL;
}
found:
if( rc && rc != -1 )
log_error("keydb_search failed: %s\n", g10_errstr(rc));
if( !rc ) {
*ret_keyblock = ctx->keyblock; /* return the keyblock */
ctx->keyblock = NULL;
}
else if (rc == -1 && no_suitable_key)
rc = secmode ? G10ERR_UNU_SECKEY : G10ERR_UNU_PUBKEY;
else if( rc == -1 )
rc = secmode ? G10ERR_NO_SECKEY : G10ERR_NO_PUBKEY;
if ( secmode ) {
release_kbnode( secblock );
secblock = NULL;
}
release_kbnode( ctx->keyblock );
ctx->keyblock = NULL;
ctx->last_rc = rc;
return rc;
}
/****************
* FIXME: Replace by the generic function
* It does not work as it is right now - it is used at
* 2 places: a) to get the key for an anonyous recipient
* b) to get the ultimately trusted keys.
* The a) usage might have some problems.
*
* set with_subkeys true to include subkeys
* set with_spm true to include secret-parts-missing keys
*
* Enumerate all primary secret keys. Caller must use these procedure:
* 1) create a void pointer and initialize it to NULL
* 2) pass this void pointer by reference to this function
* and provide space for the secret key (pass a buffer for sk)
* 3) call this function as long as it does not return -1
* to indicate EOF.
* 4) Always call this function a last time with SK set to NULL,
* so that can free it's context.
*/
int
enum_secret_keys( void **context, PKT_secret_key *sk,
int with_subkeys, int with_spm )
{
int rc=0;
struct {
int eof;
int first;
KEYDB_HANDLE hd;
KBNODE keyblock;
KBNODE node;
} *c = *context;
if( !c ) { /* make a new context */
c = xmalloc_clear( sizeof *c );
*context = c;
c->hd = keydb_new (1);
c->first = 1;
c->keyblock = NULL;
c->node = NULL;
}
if( !sk ) { /* free the context */
keydb_release (c->hd);
release_kbnode (c->keyblock);
xfree( c );
*context = NULL;
return 0;
}
if( c->eof )
return -1;
do {
/* get the next secret key from the current keyblock */
for (; c->node; c->node = c->node->next) {
if ((c->node->pkt->pkttype == PKT_SECRET_KEY
|| (with_subkeys
&& c->node->pkt->pkttype == PKT_SECRET_SUBKEY) )
&& !(c->node->pkt->pkt.secret_key->protect.s2k.mode==1001
&& !with_spm)) {
copy_secret_key (sk, c->node->pkt->pkt.secret_key );
c->node = c->node->next;
return 0; /* found */
}
}
release_kbnode (c->keyblock);
c->keyblock = c->node = NULL;
rc = c->first? keydb_search_first (c->hd) : keydb_search_next (c->hd);
c->first = 0;
if (rc) {
keydb_release (c->hd); c->hd = NULL;
c->eof = 1;
return -1; /* eof */
}
rc = keydb_get_keyblock (c->hd, &c->keyblock);
c->node = c->keyblock;
} while (!rc);
return rc; /* error */
}
/*********************************************
*********** user ID printing helpers *******
*********************************************/
/****************
* Return a string with a printable representation of the user_id.
* this string must be freed by xfree.
*/
char*
get_user_id_string( u32 *keyid )
{
user_id_db_t r;
char *p;
int pass=0;
/* try it two times; second pass reads from key resources */
do
{
for(r=user_id_db; r; r = r->next )
{
keyid_list_t a;
for (a=r->keyids; a; a= a->next )
{
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] )
{
p = xmalloc( keystrlen() + 1 + r->len + 1 );
sprintf(p, "%s %.*s", keystr(keyid), r->len, r->name );
return p;
}
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
p = xmalloc( keystrlen() + 5 );
sprintf(p, "%s [?]", keystr(keyid));
return p;
}
char*
get_user_id_string_native ( u32 *keyid )
{
char *p = get_user_id_string( keyid );
char *p2 = utf8_to_native( p, strlen(p), 0 );
xfree(p);
return p2;
}
char*
get_long_user_id_string( u32 *keyid )
{
user_id_db_t r;
char *p;
int pass=0;
/* try it two times; second pass reads from key resources */
do {
for(r=user_id_db; r; r = r->next ) {
keyid_list_t a;
for (a=r->keyids; a; a= a->next ) {
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] ) {
p = xmalloc( r->len + 20 );
sprintf(p, "%08lX%08lX %.*s",
(ulong)keyid[0], (ulong)keyid[1],
r->len, r->name );
return p;
}
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
p = xmalloc( 25 );
sprintf(p, "%08lX%08lX [?]", (ulong)keyid[0], (ulong)keyid[1] );
return p;
}
char*
get_user_id( u32 *keyid, size_t *rn )
{
user_id_db_t r;
char *p;
int pass=0;
/* try it two times; second pass reads from key resources */
do {
for(r=user_id_db; r; r = r->next ) {
keyid_list_t a;
for (a=r->keyids; a; a= a->next ) {
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] ) {
p = xmalloc( r->len );
memcpy(p, r->name, r->len );
*rn = r->len;
return p;
}
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
p = xstrdup( _("[User ID not found]") );
*rn = strlen(p);
return p;
}
char*
get_user_id_native( u32 *keyid )
{
size_t rn;
char *p = get_user_id( keyid, &rn );
char *p2 = utf8_to_native( p, rn, 0 );
xfree(p);
return p2;
}
KEYDB_HANDLE
get_ctx_handle(GETKEY_CTX ctx)
{
return ctx->kr_handle;
}
diff --git a/g10/gpgv.c b/g10/gpgv.c
index 1f2687605..dfd247da8 100644
--- a/g10/gpgv.c
+++ b/g10/gpgv.c
@@ -1,415 +1,427 @@
/* gpgv.c - The GnuPG signature verify utility
* Copyright (C) 1998, 1999, 2000, 2001, 2002,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#ifdef HAVE_DOSISH_SYSTEM
#include <fcntl.h> /* for setmode() */
#endif
#ifdef HAVE_LIBREADLINE
#include <stdio.h>
#include <readline/readline.h>
#endif
#define INCLUDED_BY_MAIN_MODULE 1
#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 "g10defs.h"
#include "cardglue.h"
enum cmd_and_opt_values { aNull = 0,
oQuiet = 'q',
oVerbose = 'v',
oBatch = 500,
oKeyring,
oIgnoreTimeConflict,
oStatusFD,
oLoggerFD,
oHomedir,
aTest };
static ARGPARSE_OPTS opts[] = {
{ 301, NULL, 0, N_("@\nOptions:\n ") },
{ oVerbose, "verbose", 0, N_("verbose") },
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
{ oKeyring, "keyring" ,2, N_("take the keys from this keyring")},
{ oIgnoreTimeConflict, "ignore-time-conflict", 0,
N_("make timestamp conflicts only a warning") },
{ oStatusFD, "status-fd" ,1, N_("|FD|write status info to this FD") },
{ oLoggerFD, "logger-fd",1, "@" },
{ oHomedir, "homedir", 2, "@" }, /* defaults to "~/.gnupg" */
{0} };
int g10_errors_seen = 0;
const char *
strusage( int level )
{
const char *p;
switch( level ) {
case 11: p = "gpgv (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: gpgv [options] [files] (-h for help)");
break;
case 41: p =
_("Syntax: gpg [options] [files]\n"
"Check signatures against known trusted keys\n");
break;
default: p = default_strusage(level);
}
return p;
}
static void
i18n_init(void)
{
#ifdef USE_SIMPLE_GETTEXT
set_gettext_file (PACKAGE, "Software\\GNU\\GnuPG");
#else
#ifdef ENABLE_NLS
setlocale( LC_ALL, "" );
bindtextdomain( PACKAGE, G10_LOCALEDIR );
textdomain( PACKAGE );
#endif
#endif
}
int
main( int argc, char **argv )
{
ARGPARSE_ARGS pargs;
int rc=0;
STRLIST sl;
STRLIST nrings=NULL;
unsigned configlineno;
log_set_name("gpgv");
init_signals();
i18n_init();
opt.command_fd = -1; /* no command fd */
opt.pgp2_workarounds = 1;
opt.keyserver_options.options|=KEYSERVER_AUTO_KEY_RETRIEVE;
opt.trust_model = TM_ALWAYS;
opt.batch = 1;
opt.homedir = default_homedir ();
tty_no_terminal(1);
tty_batchmode(1);
disable_dotlock();
set_native_charset (NULL); /* Try to auto set the character set */
pargs.argc = &argc;
pargs.argv = &argv;
pargs.flags= 1; /* do not remove the args */
while( optfile_parse( NULL, NULL, &configlineno, &pargs, opts) ) {
switch( pargs.r_opt ) {
case oQuiet: opt.quiet = 1; break;
case oVerbose: g10_opt_verbose++;
opt.verbose++; opt.list_sigs=1; break;
case oKeyring: append_to_strlist( &nrings, pargs.r.ret_str); break;
case oStatusFD: set_status_fd( pargs.r.ret_int ); break;
case oLoggerFD: log_set_logfile( NULL, pargs.r.ret_int ); break;
case oHomedir: opt.homedir = pargs.r.ret_str; break;
case oIgnoreTimeConflict: opt.ignore_time_conflict = 1; break;
default : pargs.err = 2; break;
}
}
if( log_get_errorcount(0) )
g10_exit(2);
g10_opt_homedir = opt.homedir;
if( opt.verbose > 1 )
set_packet_list_mode(1);
if( !nrings ) /* no keyring given: use default one */
keydb_add_resource ("trustedkeys" EXTSEP_S "gpg", 0, 0);
for(sl = nrings; sl; sl = sl->next )
keydb_add_resource (sl->d, 0, 0 );
FREE_STRLIST(nrings);
if( (rc = verify_signatures( argc, argv ) ))
log_error("verify signatures failed: %s\n", g10_errstr(rc) );
/* cleanup */
g10_exit(0);
return 8; /*NEVER REACHED*/
}
void
g10_exit( int rc )
{
rc = rc? rc : log_get_errorcount(0)? 2 :
g10_errors_seen? 1 : 0;
exit(rc );
}
/* Stub:
* We have to override the trustcheck from pkclist.c becuase
* this utility assumes that all keys in the keyring are trustworthy
*/
int
check_signatures_trust( PKT_signature *sig )
{
return 0;
}
void
read_trust_options(byte *trust_model,ulong *created,ulong *nextcheck,
byte *marginals,byte *completes,byte *cert_depth) {}
/* Stub:
* We don't have the trustdb , so we have to provide some stub functions
* instead
*/
int
cache_disabled_value(PKT_public_key *pk)
{
return 0;
}
void
check_trustdb_stale(void) {}
int
get_validity_info (PKT_public_key *pk, PKT_user_id *uid)
{
return '?';
}
unsigned int
get_validity (PKT_public_key *pk, PKT_user_id *uid)
{
return 0;
}
const char *
trust_value_to_string (unsigned int value)
{
return "err";
}
const char *
uid_trust_string_fixed(PKT_public_key *key,PKT_user_id *uid)
{
return "err";
}
int
get_ownertrust_info (PKT_public_key *pk)
{
return '?';
}
unsigned int
get_ownertrust (PKT_public_key *pk)
{
return TRUST_UNKNOWN;
}
/* Stub:
* Because we only work with trusted keys, it does not make sense to
* get them from a keyserver
*/
int
keyserver_import_keyid( u32 *keyid, void *dummy )
{
return -1;
}
+/* Stub:
+ * Because we only work with trusted keys, it does not make sense to
+ * get them from a keyserver
+ */
+int
+keyserver_import_fprint (const byte *fprint, size_t fprint_len,
+ struct keyserver_spec *keyserver)
+{
+ return -1;
+}
+
+
/* Stub:
* No encryption here but mainproc links to these functions.
*/
int
get_session_key( PKT_pubkey_enc *k, DEK *dek )
{
return G10ERR_GENERAL;
}
/* Stub: */
int
get_override_session_key( DEK *dek, const char *string )
{
return G10ERR_GENERAL;
}
/* Stub: */
int
decrypt_data( void *procctx, PKT_encrypted *ed, DEK *dek )
{
return G10ERR_GENERAL;
}
/* Stub:
* No interactive commnds, so we don't need the helptexts
*/
void
display_online_help( const char *keyword )
{
}
/* Stub:
* We don't use secret keys, but getkey.c links to this
*/
int
check_secret_key( PKT_secret_key *sk, int n )
{
return G10ERR_GENERAL;
}
/* Stub:
* No secret key, so no passphrase needed
*/
DEK *
passphrase_to_dek( u32 *keyid, int pubkey_algo,
int cipher_algo, STRING2KEY *s2k, int mode,
const char *tmp, int *canceled)
{
if (canceled)
*canceled = 0;
return NULL;
}
struct keyserver_spec *parse_preferred_keyserver(PKT_signature *sig) {return NULL;}
struct keyserver_spec *parse_keyserver_uri(const char *uri,int require_scheme,
const char *configname,
unsigned int configlineno)
{
return NULL;
}
void free_keyserver_spec(struct keyserver_spec *keyserver) {}
/* Stubs to avoid linking to photoid.c */
void show_photos(const struct user_attribute *attrs,int count,PKT_public_key *pk) {}
int parse_image_header(const struct user_attribute *attr,byte *type,u32 *len) {return 0;}
char *image_type_to_string(byte type,int string) {return NULL;}
#ifdef ENABLE_CARD_SUPPORT
int agent_scd_getattr (const char *name, struct agent_card_info_s *info) {return 0;}
#endif /* ENABLE_CARD_SUPPORT */
/* Stubs to void linking to ../cipher/cipher.c */
int string_to_cipher_algo( const char *string ) { return 0; }
const char *cipher_algo_to_string( int algo ) { return "?";}
void disable_cipher_algo( int algo ) {}
int check_cipher_algo( int algo ) { return -1;}
unsigned int cipher_get_keylen( int algo ) { return 0; }
unsigned int cipher_get_blocksize( int algo ) {return 0;}
CIPHER_HANDLE cipher_open( int algo, int mode, int secure ) { return NULL;}
void cipher_close( CIPHER_HANDLE c ) {}
int cipher_setkey( CIPHER_HANDLE c, byte *key, unsigned keylen ) { return -1;}
void cipher_setiv( CIPHER_HANDLE c, const byte *iv, unsigned ivlen ){}
void cipher_encrypt( CIPHER_HANDLE c, byte *outbuf,
byte *inbuf, unsigned nbytes ) {}
void cipher_decrypt( CIPHER_HANDLE c, byte *outbuf,
byte *inbuf, unsigned nbytes ) {}
void cipher_sync( CIPHER_HANDLE c ) {}
/* Stubs to avoid linking to ../cipher/random.c */
void random_dump_stats(void) {}
int quick_random_gen( int onoff ) { return -1;}
void randomize_buffer( byte *buffer, size_t length, int level ) {}
int random_is_faked() { return -1;}
byte *get_random_bits( size_t nbits, int level, int secure ) { return NULL;}
void set_random_seed_file( const char *name ) {}
void update_random_seed_file() {}
void fast_random_poll() {}
/* Stubs to avoid linking of ../cipher/primegen.c */
void register_primegen_progress ( void (*cb)( void *, int), void *cb_data ) {}
MPI generate_secret_prime( unsigned nbits ) { return NULL;}
MPI generate_public_prime( unsigned nbits ) { return NULL;}
MPI generate_elg_prime( int mode, unsigned pbits, unsigned qbits,
MPI g, MPI **ret_factors ) { return NULL;}
/* Do not link to ../cipher/rndlinux.c */
void rndlinux_constructor(void) {}
/* Stubs to avoid linking to ../util/ttyio.c */
int tty_batchmode( int onoff ) { return 0; }
void tty_printf( const char *fmt, ... ) { }
void tty_fprintf (FILE *fp, const char *fmt, ... ) { }
void tty_print_string( const byte *p, size_t n ) { }
void tty_print_utf8_string( const byte *p, size_t n ) {}
void tty_print_utf8_string2( const byte *p, size_t n, size_t max_n ) {}
char *tty_get( const char *prompt ) { return NULL;}
char *tty_get_hidden( const char *prompt ) {return NULL; }
void tty_kill_prompt(void) {}
int tty_get_answer_is_yes( const char *prompt ) {return 0;}
int tty_no_terminal(int onoff) {return 0;}
#ifdef HAVE_LIBREADLINE
void tty_enable_completion(rl_completion_func_t *completer) {}
void tty_disable_completion(void) {}
#endif
/* We do not do any locking, so use these stubs here */
void disable_dotlock(void) {}
DOTLOCK create_dotlock( const char *file_to_lock ) { return NULL; }
void destroy_dotlock (DOTLOCK h) {}
int make_dotlock( DOTLOCK h, long timeout ) { return 0;}
int release_dotlock( DOTLOCK h ) {return 0;}
void remove_lockfiles(void) {}
diff --git a/g10/keygen.c b/g10/keygen.c
index 6c27cec90..fb93363e8 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -1,3566 +1,3561 @@
/* keygen.c - generate a key pair
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.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 "cardglue.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,
pBACKUPENCDIR,
pHANDLE
};
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 stream;
armor_filter_context_t afx;
} pub;
struct {
char *fname;
char *newfname;
IOBUF 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 out, KBNODE node );
static int gen_card_key (int algo, int keyno, int is_primary,
KBNODE pub_root, KBNODE sec_root,
u32 expireval, struct para_data_s *para);
static int gen_card_key_with_backup (int algo, int keyno, int is_primary,
KBNODE pub_root, KBNODE sec_root,
u32 expireval, struct para_data_s *para,
const char *backup_dir);
static void
print_status_key_created (int letter, PKT_public_key *pk, const char *handle)
{
byte array[MAX_FINGERPRINT_LEN], *s;
char *buf, *p;
size_t i, n;
if (!handle)
handle = "";
buf = xmalloc (MAX_FINGERPRINT_LEN*2+31 + strlen (handle) + 1);
p = buf;
if (letter || pk)
{
*p++ = letter;
*p++ = ' ';
fingerprint_from_pk (pk, array, &n);
s = array;
for (i=0; i < n ; i++, s++, p += 2)
sprintf (p, "%02X", *s);
}
if (*handle)
{
*p++ = ' ';
for (i=0; handle[i] && i < 100; i++)
*p++ = isspace ((unsigned int)handle[i])? '_':handle[i];
}
*p = 0;
write_status_text ((letter || pk)?STATUS_KEY_CREATED:STATUS_KEY_NOT_CREATED,
buf);
xfree (buf);
}
static void
print_status_key_not_created (const char *handle)
{
print_status_key_created (0, NULL, handle);
}
static void
write_uid( KBNODE root, const char *s )
{
PACKET *pkt = xmalloc_clear(sizeof *pkt );
size_t n = strlen(s);
pkt->pkttype = PKT_USER_ID;
pkt->pkt.user_id = xmalloc_clear( 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;
/* The spec says that all primary keys MUST be able to certify. */
if(sig->sig_class!=0x18)
buf[0] |= 0x01;
if (use & PUBKEY_USAGE_SIG)
buf[0] |= 0x02;
if (use & PUBKEY_USAGE_ENC)
buf[0] |= 0x04 | 0x08;
if (use & PUBKEY_USAGE_AUTH)
buf[0] |= 0x20;
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;
}
/*
* 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. */
char dummy_string[45+1]; /* Enough for 15 items. */
if (!string || !ascii_strcasecmp (string, "default"))
{
if (opt.def_preference_list)
string=opt.def_preference_list;
else
{
dummy_string[0]='\0';
/* The rationale why we use the order AES256,192,128 is
for compatibility reasons with PGP. If gpg would
define AES128 first, we would get the somewhat
confusing situation:
gpg -r pgpkey -r gpgkey ---gives--> AES256
gpg -r gpgkey -r pgpkey ---gives--> AES
Note that by using --personal-cipher-preferences it is
possible to prefer AES128.
*/
/* Make sure we do not add more than 15 items here, as we
could overflow the size of dummy_string. We currently
have at most 12. */
if(!check_cipher_algo(CIPHER_ALGO_AES256))
strcat(dummy_string,"S9 ");
if(!check_cipher_algo(CIPHER_ALGO_AES192))
strcat(dummy_string,"S8 ");
if(!check_cipher_algo(CIPHER_ALGO_AES))
strcat(dummy_string,"S7 ");
if(!check_cipher_algo(CIPHER_ALGO_CAST5))
strcat(dummy_string,"S3 ");
strcat(dummy_string,"S2 "); /* 3DES */
/* 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 */
if(!check_cipher_algo(CIPHER_ALGO_IDEA))
strcat(dummy_string,"S1 ");
/* SHA-1 */
strcat(dummy_string,"H2 ");
if(!check_digest_algo(DIGEST_ALGO_SHA256))
strcat(dummy_string,"H8 ");
/* RIPEMD160 */
strcat(dummy_string,"H3 ");
/* ZLIB */
strcat(dummy_string,"Z2 ");
if(!check_compress_algo(COMPRESS_ALGO_BZIP2))
strcat(dummy_string,"Z3 ");
/* ZIP */
strcat(dummy_string,"Z1");
string=dummy_string;
}
}
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=string_to_cipher_algo(tok)))
{
if(set_one_pref(val,1,tok,sym,&nsym))
rc=-1;
}
else if((val=string_to_digest_algo(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;
}
/* 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=xmalloc_clear(sizeof(PKT_user_id));
if(!prefs_initialized)
keygen_set_std_prefs(NULL,0);
uid->ref=1;
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 = xmalloc_clear (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 = xmalloc_clear (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_keyserver_url(PKT_signature *sig, void *opaque)
{
const char *url=opaque;
if(url)
build_sig_subpkt(sig,SIGSUBPKT_PREF_KS,url,strlen(url));
else
delete_sig_subpkt (sig->hashed,SIGSUBPKT_PREF_KS);
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
make_backsig(PKT_signature *sig, PKT_public_key *pk,
PKT_public_key *sub_pk, PKT_secret_key *sub_sk)
{
PKT_signature *backsig;
int rc;
#ifndef DO_BACKSIGS
/* This is not enabled yet, as I want to get a bit closer to RFC day
before enabling this. I've been burned before :) */
return 0;
#endif
cache_public_key (sub_pk);
rc=make_keysig_packet(&backsig,pk,NULL,sub_pk,sub_sk, 0x19, 0, 0, 0, 0,
NULL,NULL);
if( rc )
log_error("make_keysig_packet failed for backsig: %s\n", g10_errstr(rc) );
else
{
/* get it into a binary packed form. */
IOBUF backsig_out=iobuf_temp();
PACKET backsig_pkt;
init_packet(&backsig_pkt);
backsig_pkt.pkttype=PKT_SIGNATURE;
backsig_pkt.pkt.signature=backsig;
rc=build_packet(backsig_out,&backsig_pkt);
free_packet(&backsig_pkt);
if(rc)
log_error("build_packet failed for backsig: %s\n",g10_errstr(rc));
else
{
size_t pktlen=0;
byte *buf=iobuf_get_temp_buffer(backsig_out);
/* Remove the packet header */
if(buf[0]&0x40)
{
if(buf[1]<192)
{
pktlen=buf[1];
buf+=2;
}
else if(buf[1]<224)
{
pktlen=(buf[1]-192)*256;
pktlen+=buf[2]+192;
buf+=3;
}
else if(buf[1]==255)
{
pktlen =buf[2] << 24;
pktlen|=buf[3] << 16;
pktlen|=buf[4] << 8;
pktlen|=buf[5];
buf+=6;
}
else
BUG();
}
else
{
int mark=1;
switch(buf[0]&3)
{
case 3:
BUG();
break;
case 2:
pktlen =buf[mark++] << 24;
pktlen|=buf[mark++] << 16;
case 1:
pktlen|=buf[mark++] << 8;
case 0:
pktlen|=buf[mark++];
}
buf+=mark;
}
/* now make the binary blob into a subpacket */
build_sig_subpkt(sig,SIGSUBPKT_SIGNATURE,buf,pktlen);
iobuf_close(backsig_out);
}
}
return rc;
}
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", g10_errstr(rc) );
return rc;
}
pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
add_kbnode( root, new_kbnode( pkt ) );
return rc;
}
static int
write_selfsigs( KBNODE sec_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( pub_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", g10_errstr(rc) );
return rc;
}
pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
add_kbnode( sec_root, new_kbnode( pkt ) );
pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = copy_signature(NULL,sig);
add_kbnode( pub_root, new_kbnode( pkt ) );
return rc;
}
/* sub_sk is currently unused (reserved for backsigs) */
static int
write_keybinding( KBNODE root, KBNODE pub_root,
PKT_secret_key *pri_sk, PKT_secret_key *sub_sk,
unsigned int use )
{
PACKET *pkt;
PKT_signature *sig;
int rc=0;
KBNODE node;
PKT_public_key *pri_pk, *sub_pk;
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();
pri_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 (pri_pk);
/* find the last subkey */
sub_pk = NULL;
for(node=pub_root; node; node = node->next ) {
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
sub_pk = node->pkt->pkt.public_key;
}
if( !sub_pk )
BUG();
/* and make the signature */
oduap.usage = use;
oduap.pk = sub_pk;
rc=make_keysig_packet(&sig, pri_pk, NULL, sub_pk, pri_sk, 0x18, 0, 0, 0, 0,
keygen_add_key_flags_and_expire, &oduap );
if( rc ) {
log_error("make_keysig_packet failed: %s\n", g10_errstr(rc) );
return rc;
}
/* make a backsig */
if(use&PUBKEY_USAGE_SIG)
{
rc=make_backsig(sig,pri_pk,sub_pk,sub_sk);
if(rc)
return rc;
}
pkt = xmalloc_clear( 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, int is_subkey)
{
int rc;
PACKET *pkt;
PKT_secret_key *sk;
PKT_public_key *pk;
MPI skey[4];
MPI *factors;
assert( is_ELGAMAL(algo) );
if( nbits < 512 ) {
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 );
}
rc = pubkey_generate( algo, nbits, skey, &factors );
if( rc ) {
log_error("pubkey_generate failed: %s\n", g10_errstr(rc) );
return rc;
}
sk = xmalloc_clear( sizeof *sk );
pk = xmalloc_clear( 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 ) /* 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", g10_errstr(rc) );
free_public_key(pk);
free_secret_key(sk);
return rc;
}
}
pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
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 = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
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, int is_subkey)
{
int rc;
PACKET *pkt;
PKT_secret_key *sk;
PKT_public_key *pk;
MPI skey[5];
MPI *factors;
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 );
}
rc = pubkey_generate( PUBKEY_ALGO_DSA, nbits, skey, &factors );
if( rc ) {
log_error("pubkey_generate failed: %s\n", g10_errstr(rc) );
return rc;
}
sk = xmalloc_clear( sizeof *sk );
pk = xmalloc_clear( 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 ) /* 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", g10_errstr(rc) );
free_public_key(pk);
free_secret_key(sk);
return rc;
}
}
pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
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 = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
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 is_subkey)
{
int rc;
PACKET *pkt;
PKT_secret_key *sk;
PKT_public_key *pk;
MPI skey[6];
MPI *factors;
assert( is_RSA(algo) );
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 );
}
rc = pubkey_generate( algo, nbits, skey, &factors );
if( rc ) {
log_error("pubkey_generate failed: %s\n", g10_errstr(rc) );
return rc;
}
sk = xmalloc_clear( sizeof *sk );
pk = xmalloc_clear( 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 ) /* 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", g10_errstr(rc) );
free_public_key(pk);
free_secret_key(sk);
return rc;
}
}
pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
pkt->pkt.public_key = pk;
add_kbnode(pub_root, new_kbnode( pkt ));
pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
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( !digitp(s) )
return 0;
for( s++; *s; s++)
if( !digitp(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;
}
static void
print_key_flags(int flags)
{
if(flags&PUBKEY_USAGE_SIG)
tty_printf("%s ",_("Sign"));
if(flags&PUBKEY_USAGE_ENC)
tty_printf("%s ",_("Encrypt"));
if(flags&PUBKEY_USAGE_AUTH)
tty_printf("%s ",_("Authenticate"));
}
/* Returns the key flags */
static unsigned int
ask_key_flags(int algo)
{
const char *togglers=_("SsEeAaQq");
char *answer=NULL;
unsigned int current=0;
unsigned int possible=openpgp_pk_algo_usage(algo);
if(strlen(togglers)!=8)
BUG();
/* Preload the current set with the possible set, minus
authentication, since nobody really uses auth yet. */
current=possible&~PUBKEY_USAGE_AUTH;
for(;;)
{
tty_printf("\n");
tty_printf(_("Possible actions for a %s key: "),
pubkey_algo_to_string(algo));
print_key_flags(possible);
tty_printf("\n");
tty_printf(_("Current allowed actions: "));
print_key_flags(current);
tty_printf("\n\n");
if(possible&PUBKEY_USAGE_SIG)
tty_printf(_(" (%c) Toggle the sign capability\n"),
togglers[0]);
if(possible&PUBKEY_USAGE_ENC)
tty_printf(_(" (%c) Toggle the encrypt capability\n"),
togglers[2]);
if(possible&PUBKEY_USAGE_AUTH)
tty_printf(_(" (%c) Toggle the authenticate capability\n"),
togglers[4]);
tty_printf(_(" (%c) Finished\n"),togglers[6]);
tty_printf("\n");
xfree(answer);
answer = cpr_get("keygen.flags",_("Your selection? "));
cpr_kill_prompt();
if(strlen(answer)>1)
continue;
else if(*answer=='\0' || *answer==togglers[6] || *answer==togglers[7])
break;
else if((*answer==togglers[0] || *answer==togglers[1])
&& possible&PUBKEY_USAGE_SIG)
{
if(current&PUBKEY_USAGE_SIG)
current&=~PUBKEY_USAGE_SIG;
else
current|=PUBKEY_USAGE_SIG;
}
else if((*answer==togglers[2] || *answer==togglers[3])
&& possible&PUBKEY_USAGE_ENC)
{
if(current&PUBKEY_USAGE_ENC)
current&=~PUBKEY_USAGE_ENC;
else
current|=PUBKEY_USAGE_ENC;
}
else if((*answer==togglers[4] || *answer==togglers[5])
&& possible&PUBKEY_USAGE_AUTH)
{
if(current&PUBKEY_USAGE_AUTH)
current&=~PUBKEY_USAGE_AUTH;
else
current|=PUBKEY_USAGE_AUTH;
}
}
xfree(answer);
return current;
}
/****************
* 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 (opt.expert)
tty_printf( _(" (%d) DSA (set your own capabilities)\n"), 3 );
if( addmode )
tty_printf(_(" (%d) Elgamal (encrypt only)\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 (set your own capabilities)\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=ask_key_flags(algo);
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 && addmode ) {
algo = PUBKEY_ALGO_ELGAMAL_E;
*r_usage = PUBKEY_USAGE_ENC;
break;
}
else if( algo == 3 && opt.expert ) {
algo = PUBKEY_ALGO_DSA;
*r_usage=ask_key_flags(algo);
break;
}
else if( algo == 2 ) {
algo = PUBKEY_ALGO_DSA;
*r_usage = PUBKEY_USAGE_SIG;
break;
}
else
tty_printf(_("Invalid selection.\n"));
}
return algo;
}
static unsigned
ask_keysize( int algo )
{
unsigned nbits,min,def=2048,max=4096;
if(opt.expert)
min=512;
else
min=1024;
switch(algo)
{
case PUBKEY_ALGO_DSA:
if(opt.expert)
{
def=1024;
max=1024;
}
else
{
tty_printf(_("DSA keypair will have %u bits.\n"),1024);
return 1024;
}
break;
case PUBKEY_ALGO_RSA:
min=1024;
break;
}
tty_printf(_("%s keys may be between %u and %u bits long.\n"),
pubkey_algo_to_string(algo),min,max);
for(;;)
{
char *prompt,*answer;
#define PROMPTSTRING _("What keysize do you want? (%u) ")
prompt=xmalloc(strlen(PROMPTSTRING)+20);
sprintf(prompt,PROMPTSTRING,def);
#undef PROMPTSTRING
answer = cpr_get("keygen.size",prompt);
cpr_kill_prompt();
nbits = *answer? atoi(answer): def;
xfree(prompt);
xfree(answer);
if(nbits<min || nbits>max)
tty_printf(_("%s keysizes must be in the range %u-%u\n"),
pubkey_algo_to_string(algo),min,max);
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 its value in seconds.
* Returns (u32)-1 on error.
* This isn't perfect since scan_isodatestr returns unix time, and
* OpenPGP actually allows a 32-bit time *plus* a 32-bit offset.
* Because of this, we only permit setting expirations up to 2106, but
* OpenPGP could theoretically allow up to 2242. I think we'll all
* just cope for the next few years until we get a 64-bit time_t or
* similar.
*/
u32
parse_expire_string( const char *string )
{
int mult;
u32 seconds,abs_date=0,curtime = make_timestamp();
if( !*string )
seconds = 0;
else if( (abs_date = scan_isodatestr(string)) && abs_date > curtime )
seconds = abs_date - curtime;
else if( (mult=check_valid_days(string)) )
seconds = atoi(string) * 86400L * mult;
else
seconds=(u32)-1;
return seconds;
}
/* object == 0 for a key, and 1 for a sig */
u32
ask_expire_interval(int object,const char *def_expire)
{
u32 interval;
char *answer;
switch(object)
{
case 0:
if(def_expire)
BUG();
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:
if(!def_expire)
BUG();
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
{
char *prompt;
#define PROMPTSTRING _("Signature is valid for? (%s) ")
/* This will actually end up larger than necessary because
of the 2 bytes for '%s' */
prompt=xmalloc(strlen(PROMPTSTRING)+strlen(def_expire)+1);
sprintf(prompt,PROMPTSTRING,def_expire);
#undef PROMPTSTRING
answer = cpr_get("siggen.valid",prompt);
xfree(prompt);
if(*answer=='\0')
answer=xstrdup(def_expire);
}
cpr_kill_prompt();
trim_spaces(answer);
interval = parse_expire_string( answer );
if( interval == (u32)-1 )
{
tty_printf(_("invalid value\n"));
continue;
}
if( !interval )
{
tty_printf((object==0)
? _("Key does not expire at all\n")
: _("Signature does not expire at all\n"));
}
else
{
tty_printf(object==0
? _("Key expires at %s\n")
: _("Signature expires at %s\n"),
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 */
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,NULL);
return x? make_timestamp() + x : 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 the 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( digitp(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 || opt.allow_freeform_uid )
break; /* no email address is okay */
- else if( has_invalid_email_chars(amail)
- || string_count_chr(amail,'@') != 1
- || *amail == '@'
- || amail[strlen(amail)-1] == '@'
- || amail[strlen(amail)-1] == '.'
- || strstr(amail, "..") )
- tty_printf(_("Not a valid email address\n"));
+ else if ( !is_valid_mailbox (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),">");
/* append a warning if we do not have dev/random
* or it is switched into quick testmode */
if( quick_random_gen(-1) )
strcpy(p, " (INSECURE!)" );
/* 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 && !opt.allow_freeform_uid
&& (strchr( aname, '@' ) || strchr( acomment, '@'))) {
fail = 1;
tty_printf(_("Please don't put the email address "
"into the real name or the comment\n") );
}
for(;;) {
/* TRANSLATORS: These are the allowed answers in
lower and uppercase. Below you will find the matching
string which should be translated accordingly and the
letter changed to match the one in the answer string.
n = Change name
c = Change comment
e = Change email
o = Okay (ready, continue)
q = Quit
*/
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;
}
/* FIXME: We need a way to cancel this prompt. */
static DEK *
do_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 = 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 is_subkey )
{
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_E )
rc = gen_elg(algo, nbits, pub_root, sec_root, dek, s2k, sk, expiredate,
is_subkey);
else if( algo == PUBKEY_ALGO_DSA )
rc = gen_dsa(nbits, pub_root, sec_root, dek, s2k, sk, expiredate,
is_subkey);
else if( algo == PUBKEY_ALGO_RSA )
rc = gen_rsa(algo, nbits, pub_root, sec_root, dek, s2k, sk, expiredate,
is_subkey);
else
BUG();
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 = xmalloc_clear( 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( digitp( r->u.value ) )
i = atoi( r->u.value );
else
i = string_to_pubkey_algo( 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 if ( !ascii_strcasecmp (p, "auth") )
use |= PUBKEY_USAGE_AUTH;
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 have_user_id=0;
/* Check that we have all required parameters. */
r = get_parameter( para, pKEYTYPE );
if(r)
{
if(check_pubkey_algo2(get_parameter_algo(para,pKEYTYPE),
PUBKEY_USAGE_SIG))
{
log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
return -1;
}
}
else
{
log_error("%s: no Key-Type specified\n",fname);
return -1;
}
if (parse_parameter_usage (fname, para, pKEYUSAGE))
return -1;
r = get_parameter( para, pSUBKEYTYPE );
if(r)
{
if(check_pubkey_algo( get_parameter_algo( para, pSUBKEYTYPE)))
{
log_error("%s:%d: invalid algorithm\n", fname, r->lnr );
return -1;
}
if(parse_parameter_usage (fname, para, pSUBKEYUSAGE))
return -1;
}
if( get_parameter_value( para, pUSERID ) )
have_user_id=1;
else
{
/* 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 = xmalloc_clear( 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;
have_user_id=1;
}
}
if(!have_user_id)
{
log_error("%s: no User-ID specified\n",fname);
return -1;
}
/* 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 ih secure memory
* but becuase we do this alwasy, why not here */
STRING2KEY *s2k;
DEK *dek;
s2k = xmalloc_secure( sizeof *s2k );
s2k->mode = opt.s2k_mode;
s2k->hash_algo = 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 = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_S2K;
r->u.s2k = s2k;
r->next = para;
para = r;
r = xmalloc_clear( 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 )
{
u32 seconds;
seconds = parse_expire_string( r->u.value );
if( seconds == (u32)-1 )
{
log_error("%s:%d: invalid expire date\n", fname, r->lnr );
return -1;
}
r->u.expire = seconds;
r->key = pKEYEXPIRE; /* change hat entry */
/* also set it for the subkey */
r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYEXPIRE;
r->u.expire = seconds;
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.
* 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 },
{ "Handle", pHANDLE },
{ NULL, 0 }
};
IOBUF fp;
byte *line;
unsigned int maxlen, nline;
char *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)
fname = "-";
fp = iobuf_open (fname);
if (fp && is_secured_file (iobuf_get_fd (fp)))
{
iobuf_close (fp);
fp = NULL;
errno = EPERM;
}
if (!fp) {
log_error (_("can't open `%s': %s\n"), fname, strerror(errno) );
return;
}
iobuf_ioctl (fp, 3, 1, NULL); /* No file caching. */
lnr = 0;
err = NULL;
para = NULL;
maxlen = 1024;
line = NULL;
while ( iobuf_read_line (fp, &line, &nline, &maxlen) ) {
char *keyword, *value;
lnr++;
if( !maxlen ) {
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;
if (proc_parameter_file( para, fname, &outctrl, 0 ))
print_status_key_not_created
(get_parameter_value (para, pHANDLE));
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;
if (proc_parameter_file( para, fname, &outctrl, 0 ))
print_status_key_not_created
(get_parameter_value (para, pHANDLE));
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 = xmalloc_clear( 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( iobuf_error (fp) ) {
log_error("%s:%d: read error\n", fname, lnr);
}
else if( para ) {
outctrl.lnr = lnr;
if (proc_parameter_file( para, fname, &outctrl, 0 ))
print_status_key_not_created (get_parameter_value (para, pHANDLE));
}
if( outctrl.use_files ) { /* close open streams */
iobuf_close( outctrl.pub.stream );
iobuf_close( outctrl.sec.stream );
/* Must invalidate that ugly cache to actually close it. */
if (outctrl.pub.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl.pub.fname);
if (outctrl.sec.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl.sec.fname);
xfree( outctrl.pub.fname );
xfree( outctrl.pub.newfname );
xfree( outctrl.sec.fname );
xfree( outctrl.sec.newfname );
}
release_parameter_list( para );
iobuf_close (fp);
}
/*
* Generate a keypair (fname is only used in batch mode) If
* CARD_SERIALNO is not NULL the fucntion will create the keys on an
* OpenPGP Card. If BACKUP_ENCRYPTION_DIR has been set and
* CARD_SERIALNO is NOT NULL, the encryption key for the card gets
* generate in software, imported to the card and a backup file
* written to directory given by this argument .
*/
void
generate_keypair (const char *fname, const char *card_serialno,
const char *backup_encryption_dir)
{
unsigned int nbits;
char *uid = NULL;
DEK *dek;
STRING2KEY *s2k;
int algo;
unsigned int use;
int both = 0;
u32 expire;
struct para_data_s *para = NULL;
struct para_data_s *r;
struct output_control_s outctrl;
memset( &outctrl, 0, sizeof( outctrl ) );
if (opt.batch && card_serialno)
{
/* We don't yet support unattended key generation. */
log_error (_("can't do this in batch mode\n"));
return;
}
if (opt.batch)
{
read_parameter_file( fname );
return;
}
if (card_serialno)
{
#ifdef ENABLE_CARD_SUPPORT
r = xcalloc (1, sizeof *r + strlen (card_serialno) );
r->key = pSERIALNO;
strcpy( r->u.value, card_serialno);
r->next = para;
para = r;
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;
if (backup_encryption_dir)
{
r = xcalloc (1, sizeof *r + strlen (backup_encryption_dir) );
r->key = pBACKUPENCDIR;
strcpy (r->u.value, backup_encryption_dir);
r->next = para;
para = r;
}
#endif /*ENABLE_CARD_SUPPORT*/
}
else
{
algo = ask_algo( 0, &use );
if( !algo )
{ /* default: DSA with ElG subkey of the specified size */
both = 1;
r = xmalloc_clear( 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 %u bits.\n"),1024);
r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYLENGTH;
strcpy( r->u.value, "1024" );
r->next = para;
para = r;
r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYUSAGE;
strcpy( r->u.value, "sign" );
r->next = para;
para = r;
algo = PUBKEY_ALGO_ELGAMAL_E;
r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYTYPE;
sprintf( r->u.value, "%d", algo );
r->next = para;
para = r;
r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYUSAGE;
strcpy( r->u.value, "encrypt" );
r->next = para;
para = r;
}
else
{
r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYTYPE;
sprintf( r->u.value, "%d", algo );
r->next = para;
para = r;
if (use)
{
r = xmalloc_clear( sizeof *r + 25 );
r->key = pKEYUSAGE;
sprintf( r->u.value, "%s%s%s",
(use & PUBKEY_USAGE_SIG)? "sign ":"",
(use & PUBKEY_USAGE_ENC)? "encrypt ":"",
(use & PUBKEY_USAGE_AUTH)? "auth":"" );
r->next = para;
para = r;
}
}
nbits = ask_keysize( algo );
r = xmalloc_clear( sizeof *r + 20 );
r->key = both? pSUBKEYLENGTH : pKEYLENGTH;
sprintf( r->u.value, "%u", nbits);
r->next = para;
para = r;
}
expire = ask_expire_interval(0,NULL);
r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYEXPIRE;
r->u.expire = expire;
r->next = para;
para = r;
r = xmalloc_clear( 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 = xmalloc_clear( sizeof *r + strlen(uid) );
r->key = pUSERID;
strcpy( r->u.value, uid );
r->next = para;
para = r;
dek = card_serialno? NULL : do_ask_passphrase( &s2k );
if( dek )
{
r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_DEK;
r->u.dek = dek;
r->next = para;
para = r;
r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_S2K;
r->u.s2k = s2k;
r->next = para;
para = r;
}
proc_parameter_file( para, "[internal]", &outctrl, !!card_serialno);
release_parameter_list( para );
}
#ifdef ENABLE_CARD_SUPPORT
/* Generate a raw key and return it as a secret key packet. The
function will ask for the passphrase and return a protected as well
as an unprotected copy of a new secret key packet. 0 is returned
on success and the caller must then free the returned values. */
static int
generate_raw_key (int algo, unsigned int nbits, u32 created_at,
PKT_secret_key **r_sk_unprotected,
PKT_secret_key **r_sk_protected)
{
int rc;
DEK *dek = NULL;
STRING2KEY *s2k = NULL;
PKT_secret_key *sk = NULL;
int i;
size_t nskey, npkey;
npkey = pubkey_get_npkey (algo);
nskey = pubkey_get_nskey (algo);
assert (nskey <= PUBKEY_MAX_NSKEY && npkey < nskey);
if (nbits < 512)
{
nbits = 512;
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 );
}
dek = do_ask_passphrase (&s2k);
sk = xmalloc_clear (sizeof *sk);
sk->timestamp = created_at;
sk->version = 4;
sk->pubkey_algo = algo;
rc = pubkey_generate (algo, nbits, sk->skey, NULL);
if (rc)
{
log_error("pubkey_generate failed: %s\n", g10_errstr(rc) );
goto leave;
}
for (i=npkey; i < nskey; i++)
sk->csum += checksum_mpi (sk->skey[i]);
if (r_sk_unprotected)
*r_sk_unprotected = 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", g10_errstr(rc));
goto leave;
}
}
if (r_sk_protected)
{
*r_sk_protected = sk;
sk = NULL;
}
leave:
if (sk)
free_secret_key (sk);
xfree (dek);
xfree (s2k);
return rc;
}
#endif /* ENABLE_CARD_SUPPORT */
/* Create and delete a dummy packet to start off a list of kbnodes. */
static void
start_tree(KBNODE *tree)
{
PACKET *pkt;
pkt=xmalloc_clear(sizeof(*pkt));
pkt->pkttype=PKT_NONE;
*tree=new_kbnode(pkt);
delete_kbnode(*tree);
}
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 *pri_sk = NULL, *sub_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;
if (outctrl->pub.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->pub.fname);
xfree( outctrl->pub.fname );
outctrl->pub.fname = outctrl->pub.newfname;
outctrl->pub.newfname = NULL;
if (is_secured_filename (outctrl->pub.fname) ) {
outctrl->pub.stream = NULL;
errno = EPERM;
}
else
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 ) {
mode_t oldmask;
iobuf_close(outctrl->sec.stream);
outctrl->sec.stream = NULL;
if (outctrl->sec.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->sec.fname);
xfree( outctrl->sec.fname );
outctrl->sec.fname = outctrl->sec.newfname;
outctrl->sec.newfname = NULL;
oldmask = umask (077);
if (is_secured_filename (outctrl->sec.fname) ) {
outctrl->sec.stream = NULL;
errno = EPERM;
}
else
outctrl->sec.stream = iobuf_create( outctrl->sec.fname );
umask (oldmask);
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 packet which we flag
* as deleted. The very first packet must always be a KEY packet.
*/
start_tree(&pub_root);
start_tree(&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 ),
&pri_sk,
get_parameter_u32( para, pKEYEXPIRE ), 0 );
}
else
{
rc = gen_card_key (PUBKEY_ALGO_RSA, 1, 1, pub_root, sec_root,
get_parameter_u32 (para, pKEYEXPIRE), para);
if (!rc)
{
pri_sk = sec_root->next->pkt->pkt.secret_key;
assert (pri_sk);
}
}
if(!rc && (revkey=get_parameter_revkey(para,pREVOKER)))
{
rc=write_direct_sig(pub_root,pub_root,pri_sk,revkey);
if(!rc)
write_direct_sig(sec_root,pub_root,pri_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_selfsigs(sec_root, pub_root, pri_sk,
get_parameter_uint (para, pKEYUSAGE));
}
/* Write the auth key to the card before the encryption key. This
is a partial workaround for a PGP bug (as of this writing, all
versions including 8.1), that causes it to try and encrypt to
the most recent subkey regardless of whether that subkey is
actually an encryption type. In this case, the auth key is an
RSA key so it succeeds. */
if (!rc && card && get_parameter (para, pAUTHKEYTYPE))
{
rc = gen_card_key (PUBKEY_ALGO_RSA, 3, 0, pub_root, sec_root,
get_parameter_u32 (para, pKEYEXPIRE), para);
if (!rc)
rc = write_keybinding (pub_root, pub_root, pri_sk, sub_sk, PUBKEY_USAGE_AUTH);
if (!rc)
rc = write_keybinding (sec_root, pub_root, pri_sk, sub_sk, PUBKEY_USAGE_AUTH);
}
if( !rc && 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 ),
&sub_sk,
get_parameter_u32( para, pSUBKEYEXPIRE ), 1 );
}
else
{
if ((s = get_parameter_value (para, pBACKUPENCDIR)))
{
/* A backup of the encryption key has been requested.
Generate the key i software and import it then to
the card. Write a backup file. */
rc = gen_card_key_with_backup (PUBKEY_ALGO_RSA, 2, 0,
pub_root, sec_root,
get_parameter_u32 (para,
pKEYEXPIRE),
para, s);
}
else
rc = gen_card_key (PUBKEY_ALGO_RSA, 2, 0, pub_root, sec_root,
get_parameter_u32 (para, pKEYEXPIRE), para);
}
if( !rc )
rc = write_keybinding(pub_root, pub_root, pri_sk, sub_sk,
get_parameter_uint (para, pSUBKEYUSAGE));
if( !rc )
rc = write_keybinding(sec_root, pub_root, pri_sk, sub_sk,
get_parameter_uint (para, pSUBKEYUSAGE));
did_sub = 1;
}
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", g10_errstr(rc) );
if( !rc ) {
rc = write_keyblock( outctrl->sec.stream, sec_root );
if( rc )
log_error("can't write secret key: %s\n", g10_errstr(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"),
g10_errstr (rc));
if (!rc) {
rc = keydb_locate_writable (sec_hd, NULL);
if (rc)
log_error (_("no writable secret keyring found: %s\n"),
g10_errstr (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), g10_errstr(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), g10_errstr(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;
keyid_from_pk(pk,pk->main_keyid);
register_trusted_keyid(pk->main_keyid);
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("\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 "
"subkey for this purpose.\n") );
}
}
}
if( rc ) {
if( opt.batch )
log_error("key generation failed: %s\n", g10_errstr(rc) );
else
tty_printf(_("Key generation failed: %s\n"), g10_errstr(rc) );
print_status_key_not_created ( get_parameter_value (para, pHANDLE) );
}
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,
get_parameter_value (para, pHANDLE));
}
release_kbnode( pub_root );
release_kbnode( sec_root );
if( pri_sk && !card) /* the unprotected secret key unless we have a */
free_secret_key(pri_sk); /* shallow copy in card mode. */
if( sub_sk )
free_secret_key(sub_sk);
}
/****************
* 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 *pri_sk = NULL, *sub_sk = NULL;
int algo;
unsigned int use;
u32 expire;
unsigned nbits;
char *passphrase = NULL;
DEK *dek = NULL;
STRING2KEY *s2k = NULL;
u32 cur_time;
int ask_pass = 0;
/* 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 */
pri_sk = copy_secret_key( NULL, node->pkt->pkt.secret_key );
cur_time = make_timestamp();
if( pri_sk->timestamp > cur_time ) {
ulong d = pri_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 = G10ERR_TIME_CONFLICT;
goto leave;
}
}
if (pri_sk->version < 4) {
log_info (_("NOTE: creating subkeys for v3 keys "
"is not OpenPGP compliant\n"));
goto leave;
}
if (pri_sk->is_protected && pri_sk->protect.s2k.mode == 1001) {
tty_printf(_("Secret parts of primary key are not available.\n"));
rc = G10ERR_NO_SECKEY;
goto leave;
}
/* Unprotect to get the passphrase. */
switch( is_secret_key_protected( pri_sk ) ) {
case -1:
rc = G10ERR_PUBKEY_ALGO;
break;
case 0:
tty_printf(_("This key is not protected.\n"));
break;
case -2:
tty_printf(_("Secret parts of primary key are stored on-card.\n"));
ask_pass = 1;
break;
default:
tty_printf(_("Key is protected.\n"));
rc = check_secret_key( pri_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,NULL);
if( !cpr_enabled() && !cpr_get_answer_is_yes("keygen.sub.okay",
_("Really create? (y/N) ")))
goto leave;
if (ask_pass)
dek = do_ask_passphrase (&s2k);
else if (passphrase) {
s2k = xmalloc_secure( sizeof *s2k );
s2k->mode = opt.s2k_mode;
s2k->hash_algo = 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, &sub_sk, expire, 1 );
if( !rc )
rc = write_keybinding(pub_keyblock, pub_keyblock, pri_sk, sub_sk, use);
if( !rc )
rc = write_keybinding(sec_keyblock, pub_keyblock, pri_sk, sub_sk, use);
if( !rc ) {
okay = 1;
write_status_text (STATUS_KEY_CREATED, "S");
}
leave:
if( rc )
log_error(_("Key generation failed: %s\n"), g10_errstr(rc) );
xfree( passphrase );
xfree( dek );
xfree( s2k );
/* release the copy of the (now unprotected) secret keys */
if( pri_sk )
free_secret_key(pri_sk);
if( sub_sk )
free_secret_key(sub_sk);
set_next_passphrase( NULL );
return okay;
}
#ifdef ENABLE_CARD_SUPPORT
/* Generate a subkey on a card. */
int
generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock,
int keyno, const char *serialno)
{
int okay=0, rc=0;
KBNODE node;
PKT_secret_key *pri_sk = NULL;
int algo;
unsigned int use;
u32 expire;
char *passphrase = NULL;
u32 cur_time;
struct para_data_s *para = NULL;
assert (keyno >= 1 && keyno <= 3);
para = xcalloc (1, sizeof *para + strlen (serialno) );
para->key = pSERIALNO;
strcpy (para->u.value, serialno);
/* 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 */
pri_sk = copy_secret_key (NULL, node->pkt->pkt.secret_key);
cur_time = make_timestamp();
if (pri_sk->timestamp > cur_time)
{
ulong d = pri_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 = G10ERR_TIME_CONFLICT;
goto leave;
}
}
if (pri_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 (pri_sk) )
{
case -1:
rc = G10ERR_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( pri_sk, 0 );
if (!rc)
passphrase = get_last_passphrase();
break;
}
if (rc)
goto leave;
algo = PUBKEY_ALGO_RSA;
expire = ask_expire_interval (0,NULL);
if (keyno == 1)
use = PUBKEY_USAGE_SIG;
else if (keyno == 2)
use = PUBKEY_USAGE_ENC;
else
use = PUBKEY_USAGE_AUTH;
if (!cpr_enabled() && !cpr_get_answer_is_yes("keygen.cardsub.okay",
_("Really create? (y/N) ")))
goto leave;
if (passphrase)
set_next_passphrase (passphrase);
rc = gen_card_key (algo, keyno, 0, pub_keyblock, sec_keyblock, expire, para);
if (!rc)
rc = write_keybinding (pub_keyblock, pub_keyblock, pri_sk, NULL, use);
if (!rc)
rc = write_keybinding (sec_keyblock, pub_keyblock, pri_sk, NULL, use);
if (!rc)
{
okay = 1;
write_status_text (STATUS_KEY_CREATED, "S");
}
leave:
if (rc)
log_error (_("Key generation failed: %s\n"), g10_errstr(rc) );
xfree (passphrase);
/* Release the copy of the (now unprotected) secret keys. */
if (pri_sk)
free_secret_key (pri_sk);
set_next_passphrase( NULL );
release_parameter_list (para);
return okay;
}
#endif /* !ENABLE_CARD_SUPPORT */
/****************
* Write a keyblock to an output stream
*/
static int
write_keyblock( IOBUF out, KBNODE node )
{
for( ; node ; node = node->next )
{
if(!is_deleted_kbnode(node))
{
int rc = build_packet( out, node->pkt );
if( rc )
{
log_error("build_packet(%d) failed: %s\n",
node->pkt->pkttype, g10_errstr(rc) );
return G10ERR_WRITE_FILE;
}
}
}
return 0;
}
static int
gen_card_key (int algo, int keyno, int is_primary,
KBNODE pub_root, KBNODE sec_root,
u32 expireval, struct para_data_s *para)
{
#ifdef ENABLE_CARD_SUPPORT
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");
mpi_free (info.n);
mpi_free (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->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 = is_primary ? 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 = is_primary ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
return 0;
#else
return -1;
#endif /*!ENABLE_CARD_SUPPORT*/
}
static int
gen_card_key_with_backup (int algo, int keyno, int is_primary,
KBNODE pub_root, KBNODE sec_root,
u32 expireval, struct para_data_s *para,
const char *backup_dir)
{
#ifdef ENABLE_CARD_SUPPORT
int rc;
const char *s;
PACKET *pkt;
PKT_secret_key *sk, *sk_unprotected, *sk_protected;
PKT_public_key *pk;
size_t n;
int i;
rc = generate_raw_key (algo, 1024, make_timestamp (),
&sk_unprotected, &sk_protected);
if (rc)
return rc;
/* First, store the key to the card. */
rc = save_unprotected_key_to_card (sk_unprotected, keyno);
if (rc)
{
log_error (_("storing key onto card failed: %s\n"), g10_errstr (rc));
free_secret_key (sk_unprotected);
free_secret_key (sk_protected);
return rc;
}
/* Get rid of the secret key parameters and store the serial numer. */
sk = sk_unprotected;
n = pubkey_get_nskey (sk->pubkey_algo);
for (i=pubkey_get_npkey (sk->pubkey_algo); i < n; i++)
{
mpi_free (sk->skey[i]);
sk->skey[i] = NULL;
}
i = pubkey_get_npkey (sk->pubkey_algo);
sk->skey[i] = mpi_set_opaque (NULL, xstrdup ("dummydata"), 10);
sk->is_protected = 1;
sk->protect.s2k.mode = 1002;
s = get_parameter_value (para, pSERIALNO);
assert (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);
/* Now write the *protected* secret key to the file. */
{
char name_buffer[50];
char *fname;
IOBUF fp;
mode_t oldmask;
keyid_from_sk (sk, NULL);
sprintf (name_buffer,"sk_%08lX%08lX.gpg",
(ulong)sk->keyid[0], (ulong)sk->keyid[1]);
fname = make_filename (backup_dir, name_buffer, NULL);
oldmask = umask (077);
if (is_secured_filename (fname))
{
fp = NULL;
errno = EPERM;
}
else
fp = iobuf_create (fname);
umask (oldmask);
if (!fp)
{
log_error (_("can't create backup file `%s': %s\n"),
fname, strerror(errno) );
xfree (fname);
free_secret_key (sk_unprotected);
free_secret_key (sk_protected);
return G10ERR_OPEN_FILE;
}
pkt = xcalloc (1, sizeof *pkt);
pkt->pkttype = PKT_SECRET_KEY;
pkt->pkt.secret_key = sk_protected;
sk_protected = NULL;
rc = build_packet (fp, pkt);
if (rc)
{
log_error("build packet failed: %s\n", g10_errstr(rc) );
iobuf_cancel (fp);
}
else
{
byte array[MAX_FINGERPRINT_LEN];
char *fprbuf, *p;
iobuf_close (fp);
iobuf_ioctl (NULL, 2, 0, (char*)fname);
log_info (_("NOTE: backup of card key saved to `%s'\n"), fname);
fingerprint_from_sk (sk, array, &n);
p = fprbuf = xmalloc (MAX_FINGERPRINT_LEN*2 + 1 + 1);
for (i=0; i < n ; i++, p += 2)
sprintf (p, "%02X", array[i]);
*p++ = ' ';
*p = 0;
write_status_text_and_buffer (STATUS_BACKUP_KEY_CREATED,
fprbuf,
fname, strlen (fname),
0);
xfree (fprbuf);
}
free_packet (pkt);
xfree (pkt);
xfree (fname);
if (rc)
{
free_secret_key (sk_unprotected);
return rc;
}
}
/* Create the public key from the secret key. */
pk = xcalloc (1, sizeof *pk );
pk->timestamp = sk->timestamp;
pk->version = sk->version;
if (expireval)
pk->expiredate = sk->expiredate = sk->timestamp + expireval;
pk->pubkey_algo = sk->pubkey_algo;
n = pubkey_get_npkey (sk->pubkey_algo);
for (i=0; i < n; i++)
pk->pkey[i] = mpi_copy (sk->skey[i]);
/* Build packets and add them to the node lists. */
pkt = xcalloc (1,sizeof *pkt);
pkt->pkttype = is_primary ? 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 = is_primary ? PKT_SECRET_KEY : PKT_SECRET_SUBKEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
return 0;
#else
return -1;
#endif /*!ENABLE_CARD_SUPPORT*/
}
#ifdef ENABLE_CARD_SUPPORT
int
save_unprotected_key_to_card (PKT_secret_key *sk, int keyno)
{
int rc;
unsigned char *rsa_n = NULL;
unsigned char *rsa_e = NULL;
unsigned char *rsa_p = NULL;
unsigned char *rsa_q = NULL;
unsigned int rsa_n_len, rsa_e_len, rsa_p_len, rsa_q_len;
unsigned char *sexp = NULL;
unsigned char *p;
char numbuf[55], numbuf2[50];
assert (is_RSA (sk->pubkey_algo));
assert (!sk->is_protected);
/* Copy the parameters into straight buffers. */
rsa_n = mpi_get_secure_buffer (sk->skey[0], &rsa_n_len, NULL);
rsa_e = mpi_get_secure_buffer (sk->skey[1], &rsa_e_len, NULL);
rsa_p = mpi_get_secure_buffer (sk->skey[3], &rsa_p_len, NULL);
rsa_q = mpi_get_secure_buffer (sk->skey[4], &rsa_q_len, NULL);
if (!rsa_n || !rsa_e || !rsa_p || !rsa_q)
{
rc = G10ERR_INV_ARG;
goto leave;
}
/* Put the key into an S-expression. */
sexp = p = xmalloc_secure (30
+ rsa_n_len + rsa_e_len + rsa_p_len + rsa_q_len
+ 4*sizeof (numbuf) + 25 + sizeof(numbuf) + 20);
p = stpcpy (p,"(11:private-key(3:rsa(1:n");
sprintf (numbuf, "%u:", rsa_n_len);
p = stpcpy (p, numbuf);
memcpy (p, rsa_n, rsa_n_len);
p += rsa_n_len;
sprintf (numbuf, ")(1:e%u:", rsa_e_len);
p = stpcpy (p, numbuf);
memcpy (p, rsa_e, rsa_e_len);
p += rsa_e_len;
sprintf (numbuf, ")(1:p%u:", rsa_p_len);
p = stpcpy (p, numbuf);
memcpy (p, rsa_p, rsa_p_len);
p += rsa_p_len;
sprintf (numbuf, ")(1:q%u:", rsa_q_len);
p = stpcpy (p, numbuf);
memcpy (p, rsa_q, rsa_q_len);
p += rsa_q_len;
p = stpcpy (p,"))(10:created-at");
sprintf (numbuf2, "%lu", (unsigned long)sk->timestamp);
sprintf (numbuf, "%lu:", (unsigned long)strlen (numbuf2));
p = stpcpy (stpcpy (stpcpy (p, numbuf), numbuf2), "))");
rc = agent_scd_writekey (keyno, sexp, p - sexp);
leave:
xfree (sexp);
xfree (rsa_n);
xfree (rsa_e);
xfree (rsa_p);
xfree (rsa_q);
return rc;
}
#endif /*ENABLE_CARD_SUPPORT*/
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 807857eb4..553bce1a4 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -1,1791 +1,1792 @@
/* keyserver.c - generic keyserver code
* Copyright (C) 2001, 2002, 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#ifdef HAVE_LIBCURL
#include <curl/curl.h>
#endif
#include "filter.h"
#include "keydb.h"
#include "status.h"
#include "exec.h"
#include "main.h"
#include "i18n.h"
#include "iobuf.h"
#include "memory.h"
#include "ttyio.h"
#include "options.h"
#include "packet.h"
#include "trustdb.h"
#include "keyserver-internal.h"
#include "util.h"
#define GET 0
#define SEND 1
#define SEARCH 2
#define GPGKEYS_PREFIX "gpgkeys_"
struct keyrec
{
KEYDB_SEARCH_DESC desc;
u32 createtime,expiretime;
int size,flags;
byte type;
IOBUF uidbuf;
unsigned int lines;
};
/* Tell remote processes about these options */
#define REMOTE_TELL (KEYSERVER_INCLUDE_REVOKED|KEYSERVER_INCLUDE_SUBKEYS|KEYSERVER_TRY_DNS_SRV)
static struct parse_options keyserver_opts[]=
{
{"include-revoked",KEYSERVER_INCLUDE_REVOKED,NULL},
{"include-subkeys",KEYSERVER_INCLUDE_SUBKEYS,NULL},
{"keep-temp-files",KEYSERVER_KEEP_TEMP_FILES,NULL},
{"refresh-add-fake-v3-keyids",KEYSERVER_ADD_FAKE_V3,NULL},
{"auto-key-retrieve",KEYSERVER_AUTO_KEY_RETRIEVE,NULL},
+ {"auto-pka-retrieve",KEYSERVER_AUTO_PKA_RETRIEVE,NULL},
{"try-dns-srv",KEYSERVER_TRY_DNS_SRV,NULL},
{"honor-keyserver-url",KEYSERVER_HONOR_KEYSERVER_URL,NULL},
{NULL,0,NULL}
};
static int keyserver_work(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
int count,struct keyserver_spec *keyserver);
int
parse_keyserver_options(char *options)
{
int ret=1;
char *tok;
while((tok=optsep(&options)))
{
if(tok[0]=='\0')
continue;
/* For backwards compatibility. 1.2.x used honor-http-proxy and
there are a good number of documents published that recommend
it. */
if(ascii_strcasecmp(tok,"honor-http-proxy")==0)
tok="http-proxy";
else if(ascii_strcasecmp(tok,"no-honor-http-proxy")==0)
tok="no-http-proxy";
/* We accept quite a few possible options here - some options to
handle specially, the keyserver_options list, and import and
export options that pertain to keyserver operations. Note
that you must use strncasecmp here as there might be an
=argument attached which will foil the use of strcasecmp. */
#ifdef EXEC_TEMPFILE_ONLY
if(ascii_strncasecmp(tok,"use-temp-files",14)==0 ||
ascii_strncasecmp(tok,"no-use-temp-files",17)==0)
log_info(_("WARNING: keyserver option `%s' is not used"
" on this platform\n"),tok);
#else
if(ascii_strncasecmp(tok,"use-temp-files",14)==0)
opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
else if(ascii_strncasecmp(tok,"no-use-temp-files",17)==0)
opt.keyserver_options.options&=~KEYSERVER_USE_TEMP_FILES;
#endif
else if(!parse_options(tok,&opt.keyserver_options.options,
keyserver_opts,0)
&& !parse_import_options(tok,
&opt.keyserver_options.import_options,0)
&& !parse_export_options(tok,
&opt.keyserver_options.export_options,0))
{
/* All of the standard options have failed, so the option is
destined for a keyserver plugin. */
char *arg=argsplit(tok);
if(arg)
{
char *joined;
joined=xmalloc(strlen(tok)+1+strlen(arg)+1);
/* Make a canonical name=value form with no
spaces */
strcpy(joined,tok);
strcat(joined,"=");
strcat(joined,arg);
add_to_strlist(&opt.keyserver_options.other,joined);
xfree(joined);
}
else
add_to_strlist(&opt.keyserver_options.other,tok);
}
}
return ret;
}
void
free_keyserver_spec(struct keyserver_spec *keyserver)
{
xfree(keyserver->uri);
xfree(keyserver->scheme);
xfree(keyserver->auth);
xfree(keyserver->host);
xfree(keyserver->port);
xfree(keyserver->path);
xfree(keyserver->opaque);
xfree(keyserver);
}
/* TODO: once we cut over to an all-curl world, we don't need this
parser any longer so it can be removed, or at least moved to
keyserver/ksutil.c for limited use in gpgkeys_ldap or the like. */
struct keyserver_spec *
parse_keyserver_uri(const char *uri,int require_scheme,
const char *configname,unsigned int configlineno)
{
int assume_hkp=0;
struct keyserver_spec *keyserver;
const char *idx;
int count;
assert(uri!=NULL);
keyserver=xmalloc_clear(sizeof(struct keyserver_spec));
keyserver->uri=xstrdup(uri);
/* Get the scheme */
for(idx=uri,count=0;*idx && *idx!=':';idx++)
{
count++;
/* Do we see the start of an RFC-2732 ipv6 address here? If so,
there clearly isn't a scheme so get out early. */
if(*idx=='[')
{
/* Was the '[' the first thing in the string? If not, we
have a mangled scheme with a [ in it so fail. */
if(count==1)
break;
else
goto fail;
}
}
if(count==0)
goto fail;
if(*idx=='\0' || *idx=='[')
{
if(require_scheme)
return NULL;
/* Assume HKP if there is no scheme */
assume_hkp=1;
keyserver->scheme=xstrdup("hkp");
}
else
{
int i;
keyserver->scheme=xmalloc(count+1);
/* Force to lowercase */
for(i=0;i<count;i++)
keyserver->scheme[i]=ascii_tolower(uri[i]);
keyserver->scheme[i]='\0';
/* Skip past the scheme and colon */
uri+=count+1;
}
if(ascii_strcasecmp(keyserver->scheme,"x-broken-hkp")==0)
{
deprecated_warning(configname,configlineno,"x-broken-hkp",
"--keyserver-options ","broken-http-proxy");
xfree(keyserver->scheme);
keyserver->scheme=xstrdup("hkp");
add_to_strlist(&opt.keyserver_options.other,"broken-http-proxy");
}
else if(ascii_strcasecmp(keyserver->scheme,"x-hkp")==0)
{
/* Canonicalize this to "hkp" so it works with both the internal
and external keyserver interface. */
xfree(keyserver->scheme);
keyserver->scheme=xstrdup("hkp");
}
if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
{
/* Two slashes means network path. */
/* Skip over the "//", if any */
if(!assume_hkp)
uri+=2;
/* Do we have userinfo auth data present? */
for(idx=uri,count=0;*idx && *idx!='@' && *idx!='/';idx++)
count++;
/* We found a @ before the slash, so that means everything
before the @ is auth data. */
if(*idx=='@')
{
if(count==0)
goto fail;
keyserver->auth=xmalloc(count+1);
strncpy(keyserver->auth,uri,count);
keyserver->auth[count]='\0';
uri+=count+1;
}
/* Is it an RFC-2732 ipv6 [literal address] ? */
if(*uri=='[')
{
for(idx=uri+1,count=1;*idx
&& ((isascii (*idx) && isxdigit(*idx))
|| *idx==':' || *idx=='.');idx++)
count++;
/* Is the ipv6 literal address terminated? */
if(*idx==']')
count++;
else
goto fail;
}
else
for(idx=uri,count=0;*idx && *idx!=':' && *idx!='/';idx++)
count++;
if(count==0)
goto fail;
keyserver->host=xmalloc(count+1);
strncpy(keyserver->host,uri,count);
keyserver->host[count]='\0';
/* Skip past the host */
uri+=count;
if(*uri==':')
{
/* It would seem to be reasonable to limit the range of the
ports to values between 1-65535, but RFC 1738 and 1808
imply there is no limit. Of course, the real world has
limits. */
for(idx=uri+1,count=0;*idx && *idx!='/';idx++)
{
count++;
/* Ports are digits only */
if(!digitp(idx))
goto fail;
}
keyserver->port=xmalloc(count+1);
strncpy(keyserver->port,uri+1,count);
keyserver->port[count]='\0';
/* Skip past the colon and port number */
uri+=1+count;
}
/* Everything else is the path */
if(*uri)
keyserver->path=xstrdup(uri);
else
keyserver->path=xstrdup("/");
}
else if(uri[0]!='/')
{
/* No slash means opaque. Just record the opaque blob and get
out. */
keyserver->opaque=xstrdup(uri);
}
else
{
/* One slash means absolute path. We don't need to support that
yet. */
goto fail;
}
return keyserver;
fail:
free_keyserver_spec(keyserver);
return NULL;
}
struct keyserver_spec *
parse_preferred_keyserver(PKT_signature *sig)
{
struct keyserver_spec *spec=NULL;
const byte *p;
size_t plen;
p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_PREF_KS,&plen);
if(p && plen)
{
byte *dupe=xmalloc(plen+1);
memcpy(dupe,p,plen);
dupe[plen]='\0';
spec=parse_keyserver_uri(dupe,1,NULL,0);
xfree(dupe);
}
return spec;
}
static void
print_keyrec(int number,struct keyrec *keyrec)
{
int i;
iobuf_writebyte(keyrec->uidbuf,0);
iobuf_flush_temp(keyrec->uidbuf);
printf("(%d)\t%s ",number,iobuf_get_temp_buffer(keyrec->uidbuf));
if(keyrec->size>0)
printf("%d bit ",keyrec->size);
if(keyrec->type)
{
const char *str=pubkey_algo_to_string(keyrec->type);
if(str)
printf("%s ",str);
else
printf("unknown ");
}
switch(keyrec->desc.mode)
{
/* If the keyserver helper gave us a short keyid, we have no
choice but to use it. Do check --keyid-format to add a 0x if
needed. */
case KEYDB_SEARCH_MODE_SHORT_KID:
printf("key %s%08lX",
(opt.keyid_format==KF_0xSHORT
|| opt.keyid_format==KF_0xLONG)?"0x":"",
(ulong)keyrec->desc.u.kid[1]);
break;
/* However, if it gave us a long keyid, we can honor
--keyid-format */
case KEYDB_SEARCH_MODE_LONG_KID:
printf("key %s",keystr(keyrec->desc.u.kid));
break;
case KEYDB_SEARCH_MODE_FPR16:
printf("key ");
for(i=0;i<16;i++)
printf("%02X",keyrec->desc.u.fpr[i]);
break;
case KEYDB_SEARCH_MODE_FPR20:
printf("key ");
for(i=0;i<20;i++)
printf("%02X",keyrec->desc.u.fpr[i]);
break;
default:
BUG();
break;
}
if(keyrec->createtime>0)
{
printf(", ");
printf(_("created: %s"),strtimestamp(keyrec->createtime));
}
if(keyrec->expiretime>0)
{
printf(", ");
printf(_("expires: %s"),strtimestamp(keyrec->expiretime));
}
if(keyrec->flags&1)
printf(" (%s)",_("revoked"));
if(keyrec->flags&2)
printf(" (%s)",_("disabled"));
if(keyrec->flags&4)
printf(" (%s)",_("expired"));
printf("\n");
}
/* Returns a keyrec (which must be freed) once a key is complete, and
NULL otherwise. Call with a NULL keystring once key parsing is
complete to return any unfinished keys. */
static struct keyrec *
parse_keyrec(char *keystring)
{
static struct keyrec *work=NULL;
struct keyrec *ret=NULL;
char *record;
int i;
if(keystring==NULL)
{
if(work==NULL)
return NULL;
else if(work->desc.mode==KEYDB_SEARCH_MODE_NONE)
{
xfree(work);
return NULL;
}
else
{
ret=work;
work=NULL;
return ret;
}
}
if(work==NULL)
{
work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
/* Remove trailing whitespace */
for(i=strlen(keystring);i>0;i--)
if(ascii_isspace(keystring[i-1]))
keystring[i-1]='\0';
else
break;
if((record=strsep(&keystring,":"))==NULL)
return ret;
if(ascii_strcasecmp("pub",record)==0)
{
char *tok;
if(work->desc.mode)
{
ret=work;
work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
if((tok=strsep(&keystring,":"))==NULL)
return ret;
classify_user_id(tok,&work->desc);
if(work->desc.mode!=KEYDB_SEARCH_MODE_SHORT_KID
&& work->desc.mode!=KEYDB_SEARCH_MODE_LONG_KID
&& work->desc.mode!=KEYDB_SEARCH_MODE_FPR16
&& work->desc.mode!=KEYDB_SEARCH_MODE_FPR20)
{
work->desc.mode=KEYDB_SEARCH_MODE_NONE;
return ret;
}
/* Note all items after this are optional. This allows us to
have a pub line as simple as pub:keyid and nothing else. */
work->lines++;
if((tok=strsep(&keystring,":"))==NULL)
return ret;
work->type=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
work->size=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(atoi(tok)<=0)
work->createtime=0;
else
work->createtime=atoi(tok);
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(atoi(tok)<=0)
work->expiretime=0;
else
{
work->expiretime=atoi(tok);
/* Force the 'e' flag on if this key is expired. */
if(work->expiretime<=make_timestamp())
work->flags|=4;
}
if((tok=strsep(&keystring,":"))==NULL)
return ret;
while(*tok)
switch(*tok++)
{
case 'r':
case 'R':
work->flags|=1;
break;
case 'd':
case 'D':
work->flags|=2;
break;
case 'e':
case 'E':
work->flags|=4;
break;
}
}
else if(ascii_strcasecmp("uid",record)==0 && work->desc.mode)
{
char *userid,*tok,*decoded;
if((tok=strsep(&keystring,":"))==NULL)
return ret;
if(strlen(tok)==0)
return ret;
userid=tok;
/* By definition, de-%-encoding is always smaller than the
original string so we can decode in place. */
i=0;
while(*tok)
if(tok[0]=='%' && tok[1] && tok[2])
{
if((userid[i]=hextobyte(&tok[1]))==-1)
userid[i]='?';
i++;
tok+=3;
}
else
userid[i++]=*tok++;
/* We don't care about the other info provided in the uid: line
since no keyserver supports marking userids with timestamps
or revoked/expired/disabled yet. */
/* No need to check for control characters, as utf8_to_native
does this for us. */
decoded=utf8_to_native(userid,i,0);
if(strlen(decoded)>opt.screen_columns-10)
decoded[opt.screen_columns-10]='\0';
iobuf_writestr(work->uidbuf,decoded);
xfree(decoded);
iobuf_writestr(work->uidbuf,"\n\t");
work->lines++;
}
/* Ignore any records other than "pri" and "uid" for easy future
growth. */
return ret;
}
/* TODO: do this as a list sent to keyserver_work rather than calling
it once for each key to get the correct counts after the import
(cosmetics, really) and to better take advantage of the keyservers
that can do multiple fetches in one go (LDAP). */
static int
show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
{
char *answer;
if(count && opt.command_fd==-1)
{
static int from=1;
tty_printf("Keys %d-%d of %d for \"%s\". ",from,numdesc,count,search);
from=numdesc+1;
}
answer=cpr_get_no_help("keysearch.prompt",
_("Enter number(s), N)ext, or Q)uit > "));
/* control-d */
if(answer[0]=='\x04')
{
printf("Q\n");
answer[0]='q';
}
if(answer[0]=='q' || answer[0]=='Q')
{
xfree(answer);
return 1;
}
else if(atoi(answer)>=1 && atoi(answer)<=numdesc)
{
char *split=answer,*num;
while((num=strsep(&split," ,"))!=NULL)
if(atoi(num)>=1 && atoi(num)<=numdesc)
keyserver_work(GET,NULL,&desc[atoi(num)-1],1,opt.keyserver);
xfree(answer);
return 1;
}
return 0;
}
/* Count and searchstr are just for cosmetics. If the count is too
small, it will grow safely. If negative it disables the "Key x-y
of z" messages. searchstr should be UTF-8 (rather than native). */
static void
keyserver_search_prompt(IOBUF buffer,const char *searchstr)
{
int i=0,validcount=0,started=0,header=0,count=1;
unsigned int maxlen,buflen,numlines=0;
KEYDB_SEARCH_DESC *desc;
byte *line=NULL;
char *localstr=NULL;
if(searchstr)
localstr=utf8_to_native(searchstr,strlen(searchstr),0);
desc=xmalloc(count*sizeof(KEYDB_SEARCH_DESC));
for(;;)
{
struct keyrec *keyrec;
int rl;
maxlen=1024;
rl=iobuf_read_line(buffer,&line,&buflen,&maxlen);
if(opt.with_colons)
{
if(!header && ascii_strncasecmp("SEARCH ",line,7)==0
&& ascii_strncasecmp(" BEGIN",&line[strlen(line)-7],6)==0)
{
header=1;
continue;
}
else if(ascii_strncasecmp("SEARCH ",line,7)==0
&& ascii_strncasecmp(" END",&line[strlen(line)-5],4)==0)
continue;
printf("%s",line);
}
/* Look for an info: line. The only current info: values
defined are the version and key count. */
if(!started && rl>0 && ascii_strncasecmp("info:",line,5)==0)
{
char *tok,*str=&line[5];
if((tok=strsep(&str,":"))!=NULL)
{
int version;
if(sscanf(tok,"%d",&version)!=1)
version=1;
if(version!=1)
{
log_error(_("invalid keyserver protocol "
"(us %d!=handler %d)\n"),1,version);
break;
}
}
if((tok=strsep(&str,":"))!=NULL && sscanf(tok,"%d",&count)==1)
{
if(count==0)
goto notfound;
else if(count<0)
count=10;
else
validcount=1;
desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
}
started=1;
continue;
}
if(rl==0)
{
keyrec=parse_keyrec(NULL);
if(keyrec==NULL)
{
if(i==0)
{
count=0;
break;
}
if(i!=count)
validcount=0;
for(;;)
{
if(show_prompt(desc,i,validcount?count:0,localstr))
break;
validcount=0;
}
break;
}
}
else
keyrec=parse_keyrec(line);
if(i==count)
{
/* keyserver helper sent more keys than they claimed in the
info: line. */
count+=10;
desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
validcount=0;
}
if(keyrec)
{
desc[i]=keyrec->desc;
if(!opt.with_colons)
{
/* screen_lines - 1 for the prompt. */
if(numlines+keyrec->lines>opt.screen_lines-1)
{
if(show_prompt(desc,i,validcount?count:0,localstr))
break;
else
numlines=0;
}
print_keyrec(i+1,keyrec);
}
numlines+=keyrec->lines;
iobuf_close(keyrec->uidbuf);
xfree(keyrec);
started=1;
i++;
}
}
notfound:
/* Leave this commented out or now, and perhaps for a very long
time. All HKPish servers return HTML error messages for
no-key-found. */
/*
if(!started)
log_info(_("keyserver does not support searching\n"));
else
*/
if(count==0)
{
if(localstr)
log_info(_("key \"%s\" not found on keyserver\n"),localstr);
else
log_info(_("key not found on keyserver\n"));
}
xfree(localstr);
xfree(desc);
xfree(line);
}
static int
curl_can_handle(const char *scheme)
{
#if defined(HAVE_LIBCURL)
const char * const *proto;
curl_version_info_data *data=curl_version_info(CURLVERSION_NOW);
assert(data);
for(proto=data->protocols;*proto;proto++)
if(strcasecmp(*proto,scheme)==0)
return 1;
#elif defined(FAKE_CURL)
/* If we're faking curl, then we only support HTTP */
if(strcasecmp(scheme,"http")==0)
return 1;
#endif
return 0;
}
/* We sometimes want to use a different gpgkeys_xxx for a given
protocol (for example, ldaps is handled by gpgkeys_ldap). Map
these here. */
static const char *
keyserver_typemap(const char *type)
{
if(strcmp(type,"ldap")==0)
return "ldap";
else if(strcmp(type,"ldaps")==0)
return "ldap";
else if(curl_can_handle(type))
return "curl";
else
return type;
}
#define KEYSERVER_ARGS_KEEP " -o \"%O\" \"%I\""
#define KEYSERVER_ARGS_NOKEEP " -o \"%o\" \"%i\""
static int
keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
int count,int *prog,struct keyserver_spec *keyserver)
{
int ret=0,i,gotversion=0,outofband=0;
STRLIST temp;
unsigned int maxlen,buflen;
char *command,*searchstr=NULL;
byte *line=NULL;
struct parse_options *kopts;
struct exec_info *spawn;
const char *scheme;
const char *libexecdir = get_libexecdir ();
assert(keyserver);
#ifdef EXEC_TEMPFILE_ONLY
opt.keyserver_options.options|=KEYSERVER_USE_TEMP_FILES;
#endif
/* Build the filename for the helper to execute */
scheme=keyserver_typemap(keyserver->scheme);
#ifdef DISABLE_KEYSERVER_PATH
/* Destroy any path we might have. This is a little tricky,
portability-wise. It's not correct to delete the PATH
environment variable, as that may fall back to a system built-in
PATH. Similarly, it is not correct to set PATH to the null
string (PATH="") since this actually deletes the PATH environment
variable under MinGW. The safest thing to do here is to force
PATH to be GNUPG_LIBEXECDIR. All this is not that meaningful on
Unix-like systems (since we're going to give a full path to
gpgkeys_foo), but on W32 it prevents loading any DLLs from
directories in %PATH%.
After some more thinking about this we came to the conclusion
that it is better to load the helpers from the directory where
the program of this process lives. Fortunately Windows provides
a way to retrieve this and our get_libexecdir function has been
modified to return just this. Setting the exec-path is not
anymore required.
set_exec_path(libexecdir);
*/
#else
if(opt.exec_path_set)
{
/* If exec-path was set, and DISABLE_KEYSERVER_PATH is
undefined, then don't specify a full path to gpgkeys_foo, so
that the PATH can work. */
command=xmalloc(strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
command[0]='\0';
}
else
#endif
{
/* Specify a full path to gpgkeys_foo. */
command=xmalloc(strlen(libexecdir)+strlen(DIRSEP_S)+
strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
strcpy(command,libexecdir);
strcat(command,DIRSEP_S);
}
strcat(command,GPGKEYS_PREFIX);
strcat(command,scheme);
if(opt.keyserver_options.options&KEYSERVER_USE_TEMP_FILES)
{
if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
{
command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_KEEP)+1);
strcat(command,KEYSERVER_ARGS_KEEP);
}
else
{
command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_NOKEEP)+1);
strcat(command,KEYSERVER_ARGS_NOKEEP);
}
ret=exec_write(&spawn,NULL,command,NULL,0,0);
}
else
ret=exec_write(&spawn,command,NULL,NULL,0,0);
xfree(command);
if(ret)
return ret;
fprintf(spawn->tochild,
"# This is a GnuPG %s keyserver communications file\n",VERSION);
fprintf(spawn->tochild,"VERSION %d\n",KEYSERVER_PROTO_VERSION);
fprintf(spawn->tochild,"PROGRAM %s\n",VERSION);
fprintf(spawn->tochild,"SCHEME %s\n",keyserver->scheme);
if(keyserver->opaque)
fprintf(spawn->tochild,"OPAQUE %s\n",keyserver->opaque);
else
{
if(keyserver->auth)
fprintf(spawn->tochild,"AUTH %s\n",keyserver->auth);
if(keyserver->host)
fprintf(spawn->tochild,"HOST %s\n",keyserver->host);
if(keyserver->port)
fprintf(spawn->tochild,"PORT %s\n",keyserver->port);
if(keyserver->path)
fprintf(spawn->tochild,"PATH %s\n",keyserver->path);
}
/* Write options */
for(i=0,kopts=keyserver_opts;kopts[i].name;i++)
if(opt.keyserver_options.options & kopts[i].bit & REMOTE_TELL)
fprintf(spawn->tochild,"OPTION %s\n",kopts[i].name);
for(temp=opt.keyserver_options.other;temp;temp=temp->next)
fprintf(spawn->tochild,"OPTION %s\n",temp->d);
switch(action)
{
case GET:
{
fprintf(spawn->tochild,"COMMAND GET\n\n");
/* Which keys do we want? */
for(i=0;i<count;i++)
{
if(desc[i].mode==KEYDB_SEARCH_MODE_FPR20)
{
int f;
fprintf(spawn->tochild,"0x");
for(f=0;f<MAX_FINGERPRINT_LEN;f++)
fprintf(spawn->tochild,"%02X",desc[i].u.fpr[f]);
fprintf(spawn->tochild,"\n");
}
else if(desc[i].mode==KEYDB_SEARCH_MODE_FPR16)
{
int f;
fprintf(spawn->tochild,"0x");
for(f=0;f<16;f++)
fprintf(spawn->tochild,"%02X",desc[i].u.fpr[f]);
fprintf(spawn->tochild,"\n");
}
else if(desc[i].mode==KEYDB_SEARCH_MODE_LONG_KID)
fprintf(spawn->tochild,"0x%08lX%08lX\n",
(ulong)desc[i].u.kid[0],
(ulong)desc[i].u.kid[1]);
else if(desc[i].mode==KEYDB_SEARCH_MODE_SHORT_KID)
fprintf(spawn->tochild,"0x%08lX\n",
(ulong)desc[i].u.kid[1]);
else if(desc[i].mode==KEYDB_SEARCH_MODE_NONE)
continue;
else
BUG();
if(keyserver->host)
log_info(_("requesting key %s from %s server %s\n"),
keystr_from_desc(&desc[i]),
keyserver->scheme,keyserver->host);
else
log_info(_("requesting key %s from %s\n"),
keystr_from_desc(&desc[i]),keyserver->uri);
}
fprintf(spawn->tochild,"\n");
break;
}
case SEND:
{
STRLIST key;
/* Note the extra \n here to send an empty keylist block */
fprintf(spawn->tochild,"COMMAND SEND\n\n\n");
for(key=list;key!=NULL;key=key->next)
{
armor_filter_context_t afx;
IOBUF buffer=iobuf_temp();
KBNODE block;
temp=NULL;
add_to_strlist(&temp,key->d);
memset(&afx,0,sizeof(afx));
afx.what=1;
/* Tell the armor filter to use Unix-style \n line
endings, since we're going to fprintf this to a file
that (on Win32) is open in text mode. The win32 stdio
will transform the \n to \r\n and we'll end up with the
proper line endings on win32. This is a no-op on
Unix. */
afx.eol[0]='\n';
iobuf_push_filter(buffer,armor_filter,&afx);
/* TODO: Remove Comment: lines from keys exported this
way? */
if(export_pubkeys_stream(buffer,temp,&block,
opt.keyserver_options.export_options)==-1)
iobuf_close(buffer);
else
{
KBNODE node;
iobuf_flush_temp(buffer);
merge_keys_and_selfsig(block);
fprintf(spawn->tochild,"INFO %08lX%08lX BEGIN\n",
(ulong)block->pkt->pkt.public_key->keyid[0],
(ulong)block->pkt->pkt.public_key->keyid[1]);
for(node=block;node;node=node->next)
{
switch(node->pkt->pkttype)
{
default:
continue;
case PKT_PUBLIC_KEY:
case PKT_PUBLIC_SUBKEY:
{
PKT_public_key *pk=node->pkt->pkt.public_key;
keyid_from_pk(pk,NULL);
fprintf(spawn->tochild,"%sb:%08lX%08lX:%u:%u:%u:%u:",
node->pkt->pkttype==PKT_PUBLIC_KEY?"pu":"su",
(ulong)pk->keyid[0],(ulong)pk->keyid[1],
pk->pubkey_algo,
nbits_from_pk(pk),
pk->timestamp,
pk->expiredate);
if(pk->is_revoked)
fprintf(spawn->tochild,"r");
if(pk->has_expired)
fprintf(spawn->tochild,"e");
fprintf(spawn->tochild,"\n");
}
break;
case PKT_USER_ID:
{
PKT_user_id *uid=node->pkt->pkt.user_id;
int r;
if(uid->attrib_data)
continue;
fprintf(spawn->tochild,"uid:");
/* Quote ':', '%', and any 8-bit
characters */
for(r=0;r<uid->len;r++)
{
if(uid->name[r]==':' || uid->name[r]=='%'
|| uid->name[r]&0x80)
fprintf(spawn->tochild,"%%%02X",
(byte)uid->name[r]);
else
fprintf(spawn->tochild,"%c",uid->name[r]);
}
fprintf(spawn->tochild,":%u:%u:",
uid->created,uid->expiredate);
if(uid->is_revoked)
fprintf(spawn->tochild,"r");
if(uid->is_expired)
fprintf(spawn->tochild,"e");
fprintf(spawn->tochild,"\n");
}
break;
/* This bit is really for the benefit of
people who store their keys in LDAP
servers. It makes it easy to do queries
for things like "all keys signed by
Isabella". */
case PKT_SIGNATURE:
{
PKT_signature *sig=node->pkt->pkt.signature;
if(!IS_UID_SIG(sig))
continue;
fprintf(spawn->tochild,"sig:%08lX%08lX:%X:%u:%u\n",
(ulong)sig->keyid[0],(ulong)sig->keyid[1],
sig->sig_class,sig->timestamp,
sig->expiredate);
}
break;
}
}
fprintf(spawn->tochild,"INFO %08lX%08lX END\n",
(ulong)block->pkt->pkt.public_key->keyid[0],
(ulong)block->pkt->pkt.public_key->keyid[1]);
fprintf(spawn->tochild,"KEY %s BEGIN\n",key->d);
fwrite(iobuf_get_temp_buffer(buffer),
iobuf_get_temp_length(buffer),1,spawn->tochild);
fprintf(spawn->tochild,"KEY %s END\n",key->d);
iobuf_close(buffer);
if(keyserver->host)
log_info(_("sending key %s to %s server %s\n"),
keystr(block->pkt->pkt.public_key->keyid),
keyserver->scheme,keyserver->host);
else
log_info(_("sending key %s to %s\n"),
keystr(block->pkt->pkt.public_key->keyid),
keyserver->uri);
release_kbnode(block);
}
free_strlist(temp);
}
break;
}
case SEARCH:
{
STRLIST key;
fprintf(spawn->tochild,"COMMAND SEARCH\n\n");
/* Which keys do we want? Remember that the gpgkeys_ program
is going to lump these together into a search string. */
for(key=list;key!=NULL;key=key->next)
{
fprintf(spawn->tochild,"%s\n",key->d);
if(key!=list)
{
searchstr=xrealloc(searchstr,
strlen(searchstr)+strlen(key->d)+2);
strcat(searchstr," ");
}
else
{
searchstr=xmalloc(strlen(key->d)+1);
searchstr[0]='\0';
}
strcat(searchstr,key->d);
}
fprintf(spawn->tochild,"\n");
if(keyserver->host)
log_info(_("searching for \"%s\" from %s server %s\n"),
searchstr,keyserver->scheme,keyserver->host);
else
log_info(_("searching for \"%s\" from %s\n"),
searchstr,keyserver->uri);
break;
}
default:
log_fatal(_("no keyserver action!\n"));
break;
}
/* Done sending, so start reading. */
ret=exec_read(spawn);
if(ret)
goto fail;
/* Now handle the response */
for(;;)
{
int plen;
char *ptr;
maxlen=1024;
if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0)
{
ret=G10ERR_READ_FILE;
goto fail; /* i.e. EOF */
}
ptr=line;
/* remove trailing whitespace */
plen=strlen(ptr);
while(plen>0 && ascii_isspace(ptr[plen-1]))
plen--;
plen[ptr]='\0';
if(*ptr=='\0')
break;
if(ascii_strncasecmp(ptr,"VERSION ",8)==0)
{
gotversion=1;
if(atoi(&ptr[8])!=KEYSERVER_PROTO_VERSION)
{
log_error(_("invalid keyserver protocol (us %d!=handler %d)\n"),
KEYSERVER_PROTO_VERSION,atoi(&ptr[8]));
goto fail;
}
}
else if(ascii_strncasecmp(ptr,"PROGRAM ",8)==0)
{
if(ascii_strncasecmp(&ptr[8],VERSION,strlen(VERSION))!=0)
log_info(_("WARNING: keyserver handler from a different"
" version of GnuPG (%s)\n"),&ptr[8]);
}
else if(ascii_strncasecmp(ptr,"OPTION OUTOFBAND",16)==0)
outofband=1; /* Currently the only OPTION */
}
if(!gotversion)
{
log_error(_("keyserver did not send VERSION\n"));
goto fail;
}
if(!outofband)
switch(action)
{
case GET:
{
void *stats_handle;
stats_handle=import_new_stats_handle();
/* Slurp up all the key data. In the future, it might be
nice to look for KEY foo OUTOFBAND and FAILED indicators.
It's harmless to ignore them, but ignoring them does make
gpg complain about "no valid OpenPGP data found". One
way to do this could be to continue parsing this
line-by-line and make a temp iobuf for each key. */
import_keys_stream(spawn->fromchild,stats_handle,
opt.keyserver_options.import_options);
import_print_stats(stats_handle);
import_release_stats_handle(stats_handle);
break;
}
/* Nothing to do here */
case SEND:
break;
case SEARCH:
keyserver_search_prompt(spawn->fromchild,searchstr);
break;
default:
log_fatal(_("no keyserver action!\n"));
break;
}
fail:
xfree(line);
xfree(searchstr);
*prog=exec_finish(spawn);
return ret;
}
static int
keyserver_work(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
int count,struct keyserver_spec *keyserver)
{
int rc=0,ret=0;
if(!keyserver)
{
log_error(_("no keyserver known (use option --keyserver)\n"));
return G10ERR_BAD_URI;
}
#ifdef DISABLE_KEYSERVER_HELPERS
log_error(_("external keyserver calls are not supported in this build\n"));
return G10ERR_KEYSERVER;
#else
/* Spawn a handler */
rc=keyserver_spawn(action,list,desc,count,&ret,keyserver);
if(ret)
{
switch(ret)
{
case KEYSERVER_SCHEME_NOT_FOUND:
log_error(_("no handler for keyserver scheme `%s'\n"),
keyserver->scheme);
break;
case KEYSERVER_NOT_SUPPORTED:
log_error(_("action `%s' not supported with keyserver "
"scheme `%s'\n"),
action==GET?"get":action==SEND?"send":
action==SEARCH?"search":"unknown",
keyserver->scheme);
break;
case KEYSERVER_VERSION_ERROR:
log_error(_(GPGKEYS_PREFIX "%s does not support"
" handler version %d\n"),
keyserver_typemap(keyserver->scheme),
KEYSERVER_PROTO_VERSION);
break;
case KEYSERVER_TIMEOUT:
log_error(_("keyserver timed out\n"));
break;
case KEYSERVER_INTERNAL_ERROR:
default:
log_error(_("keyserver internal error\n"));
break;
}
return G10ERR_KEYSERVER;
}
if(rc)
{
log_error(_("keyserver communications error: %s\n"),g10_errstr(rc));
return rc;
}
return 0;
#endif /* ! DISABLE_KEYSERVER_HELPERS*/
}
int
keyserver_export(STRLIST users)
{
STRLIST sl=NULL;
KEYDB_SEARCH_DESC desc;
int rc=0;
/* Weed out descriptors that we don't support sending */
for(;users;users=users->next)
{
classify_user_id (users->d, &desc);
if(desc.mode!=KEYDB_SEARCH_MODE_SHORT_KID &&
desc.mode!=KEYDB_SEARCH_MODE_LONG_KID &&
desc.mode!=KEYDB_SEARCH_MODE_FPR16 &&
desc.mode!=KEYDB_SEARCH_MODE_FPR20)
{
log_error(_("\"%s\" not a key ID: skipping\n"),users->d);
continue;
}
else
append_to_strlist(&sl,users->d);
}
if(sl)
{
rc=keyserver_work(SEND,sl,NULL,0,opt.keyserver);
free_strlist(sl);
}
return rc;
}
int
keyserver_import(STRLIST users)
{
KEYDB_SEARCH_DESC *desc;
int num=100,count=0;
int rc=0;
/* Build a list of key ids */
desc=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
for(;users;users=users->next)
{
classify_user_id (users->d, &desc[count]);
if(desc[count].mode!=KEYDB_SEARCH_MODE_SHORT_KID &&
desc[count].mode!=KEYDB_SEARCH_MODE_LONG_KID &&
desc[count].mode!=KEYDB_SEARCH_MODE_FPR16 &&
desc[count].mode!=KEYDB_SEARCH_MODE_FPR20)
{
log_error(_("\"%s\" not a key ID: skipping\n"),users->d);
continue;
}
count++;
if(count==num)
{
num+=100;
desc=xrealloc(desc,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
if(count>0)
rc=keyserver_work(GET,NULL,desc,count,opt.keyserver);
xfree(desc);
return rc;
}
int
keyserver_import_fprint(const byte *fprint,size_t fprint_len,
struct keyserver_spec *keyserver)
{
KEYDB_SEARCH_DESC desc;
memset(&desc,0,sizeof(desc));
if(fprint_len==16)
desc.mode=KEYDB_SEARCH_MODE_FPR16;
else if(fprint_len==20)
desc.mode=KEYDB_SEARCH_MODE_FPR20;
else
return -1;
memcpy(desc.u.fpr,fprint,fprint_len);
return keyserver_work(GET,NULL,&desc,1,keyserver);
}
int
keyserver_import_keyid(u32 *keyid,struct keyserver_spec *keyserver)
{
KEYDB_SEARCH_DESC desc;
memset(&desc,0,sizeof(desc));
desc.mode=KEYDB_SEARCH_MODE_LONG_KID;
desc.u.kid[0]=keyid[0];
desc.u.kid[1]=keyid[1];
return keyserver_work(GET,NULL,&desc,1,keyserver);
}
/* code mostly stolen from do_export_stream */
static int
keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
{
int rc=0,ndesc,num=100;
KBNODE keyblock=NULL,node;
KEYDB_HANDLE kdbhd;
KEYDB_SEARCH_DESC *desc;
STRLIST sl;
*count=0;
*klist=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
kdbhd=keydb_new(0);
if(!users)
{
ndesc = 1;
desc = xmalloc_clear ( ndesc * sizeof *desc);
desc[0].mode = KEYDB_SEARCH_MODE_FIRST;
}
else
{
for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++)
;
desc = xmalloc ( ndesc * sizeof *desc);
for (ndesc=0, sl=users; sl; sl = sl->next)
{
if(classify_user_id (sl->d, desc+ndesc))
ndesc++;
else
log_error (_("key \"%s\" not found: %s\n"),
sl->d, g10_errstr (G10ERR_INV_USER_ID));
}
}
while (!(rc = keydb_search (kdbhd, desc, ndesc)))
{
if (!users)
desc[0].mode = KEYDB_SEARCH_MODE_NEXT;
/* read the keyblock */
rc = keydb_get_keyblock (kdbhd, &keyblock );
if( rc )
{
log_error (_("error reading keyblock: %s\n"), g10_errstr(rc) );
goto leave;
}
if((node=find_kbnode(keyblock,PKT_PUBLIC_KEY)))
{
/* This is to work around a bug in some keyservers (pksd and
OKS) that calculate v4 RSA keyids as if they were v3 RSA.
The answer is to refresh both the correct v4 keyid
(e.g. 99242560) and the fake v3 keyid (e.g. 68FDDBC7).
This only happens for key refresh using the HKP scheme
and if the refresh-add-fake-v3-keyids keyserver option is
set. */
if(fakev3 && is_RSA(node->pkt->pkt.public_key->pubkey_algo) &&
node->pkt->pkt.public_key->version>=4)
{
(*klist)[*count].mode=KEYDB_SEARCH_MODE_LONG_KID;
mpi_get_keyid(node->pkt->pkt.public_key->pkey[0],
(*klist)[*count].u.kid);
(*count)++;
if(*count==num)
{
num+=100;
*klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
/* v4 keys get full fingerprints. v3 keys get long keyids.
This is because it's easy to calculate any sort of keyid
from a v4 fingerprint, but not a v3 fingerprint. */
if(node->pkt->pkt.public_key->version<4)
{
(*klist)[*count].mode=KEYDB_SEARCH_MODE_LONG_KID;
keyid_from_pk(node->pkt->pkt.public_key,
(*klist)[*count].u.kid);
}
else
{
size_t dummy;
(*klist)[*count].mode=KEYDB_SEARCH_MODE_FPR20;
fingerprint_from_pk(node->pkt->pkt.public_key,
(*klist)[*count].u.fpr,&dummy);
}
/* This is a little hackish, using the skipfncvalue as a
void* pointer to the keyserver spec, but we don't need
the skipfnc here, and it saves having an additional field
for this (which would be wasted space most of the
time). */
(*klist)[*count].skipfncvalue=NULL;
/* Are we honoring preferred keyservers? */
if(opt.keyserver_options.options&KEYSERVER_HONOR_KEYSERVER_URL)
{
PKT_user_id *uid=NULL;
PKT_signature *sig=NULL;
merge_keys_and_selfsig(keyblock);
for(node=node->next;node;node=node->next)
{
if(node->pkt->pkttype==PKT_USER_ID
&& node->pkt->pkt.user_id->is_primary)
uid=node->pkt->pkt.user_id;
else if(node->pkt->pkttype==PKT_SIGNATURE
&& node->pkt->pkt.signature->
flags.chosen_selfsig && uid)
{
sig=node->pkt->pkt.signature;
break;
}
}
/* Try and parse the keyserver URL. If it doesn't work,
then we end up writing NULL which indicates we are
the same as any other key. */
if(uid && sig)
(*klist)[*count].skipfncvalue=parse_preferred_keyserver(sig);
}
(*count)++;
if(*count==num)
{
num+=100;
*klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
}
if(rc==-1)
rc=0;
leave:
if(rc)
xfree(*klist);
xfree(desc);
keydb_release(kdbhd);
release_kbnode(keyblock);
return rc;
}
/* Note this is different than the original HKP refresh. It allows
usernames to refresh only part of the keyring. */
int
keyserver_refresh(STRLIST users)
{
int rc,count,numdesc,fakev3=0;
KEYDB_SEARCH_DESC *desc;
unsigned int options=opt.keyserver_options.import_options;
/* We switch merge-only on during a refresh, as 'refresh' should
never import new keys, even if their keyids match. */
opt.keyserver_options.import_options|=IMPORT_MERGE_ONLY;
/* Similarly, we switch on fast-import, since refresh may make
multiple import sets (due to preferred keyserver URLs). We don't
want each set to rebuild the trustdb. Instead we do it once at
the end here. */
opt.keyserver_options.import_options|=IMPORT_FAST;
/* If refresh_add_fake_v3_keyids is on and it's a HKP or MAILTO
scheme, then enable fake v3 keyid generation. */
if((opt.keyserver_options.options&KEYSERVER_ADD_FAKE_V3) && opt.keyserver
&& (ascii_strcasecmp(opt.keyserver->scheme,"hkp")==0 ||
ascii_strcasecmp(opt.keyserver->scheme,"mailto")==0))
fakev3=1;
rc=keyidlist(users,&desc,&numdesc,fakev3);
if(rc)
return rc;
count=numdesc;
if(count>0)
{
int i;
/* Try to handle preferred keyserver keys first */
for(i=0;i<count;i++)
{
if(desc[i].skipfncvalue)
{
struct keyserver_spec *keyserver=desc[i].skipfncvalue;
/* We use the keyserver structure we parsed out before.
Note that a preferred keyserver without a scheme://
will be interpreted as hkp:// */
rc=keyserver_work(GET,NULL,&desc[i],1,keyserver);
if(rc)
log_info(_("WARNING: unable to refresh key %s"
" via %s: %s\n"),keystr_from_desc(&desc[i]),
keyserver->uri,g10_errstr(rc));
else
{
/* We got it, so mark it as NONE so we don't try and
get it again from the regular keyserver. */
desc[i].mode=KEYDB_SEARCH_MODE_NONE;
count--;
}
free_keyserver_spec(keyserver);
}
}
}
if(count>0)
{
if(opt.keyserver)
{
if(count==1)
log_info(_("refreshing 1 key from %s\n"),opt.keyserver->uri);
else
log_info(_("refreshing %d keys from %s\n"),
count,opt.keyserver->uri);
}
rc=keyserver_work(GET,NULL,desc,numdesc,opt.keyserver);
}
xfree(desc);
opt.keyserver_options.import_options=options;
/* If the original options didn't have fast import, and the trustdb
is dirty, rebuild. */
if(!(opt.keyserver_options.import_options&IMPORT_FAST))
trustdb_check_or_update();
return rc;
}
int
keyserver_search(STRLIST tokens)
{
if(tokens)
return keyserver_work(SEARCH,tokens,NULL,0,opt.keyserver);
else
return 0;
}
diff --git a/g10/main.h b/g10/main.h
index 787b58add..d3c8083dc 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -1,291 +1,292 @@
/* main.h
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef G10_MAIN_H
#define G10_MAIN_H
#include "types.h"
#include "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). However, the real world
issues of speed and size come into play here. */
#define DEFAULT_CIPHER_ALGO CIPHER_ALGO_CAST5
#define DEFAULT_DIGEST_ALGO DIGEST_ALGO_SHA1
#define DEFAULT_COMPRESS_ALGO COMPRESS_ALGO_ZIP
#define DEFAULT_S2K_DIGEST_ALGO DIGEST_ALGO_SHA1
#define S2K_DIGEST_ALGO (opt.s2k_digest_algo?opt.s2k_digest_algo:DEFAULT_S2K_DIGEST_ALGO)
typedef struct
{
int header_okay;
PK_LIST pk_list;
DEK *symkey_dek;
STRING2KEY *symkey_s2k;
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);
void register_secured_file (const char *fname);
void unregister_secured_file (const char *fname);
int is_secured_file (int fd);
int is_secured_filename (const char *fname);
u16 checksum_u16( unsigned n );
u16 checksum( byte *p, unsigned n );
u16 checksum_mpi( MPI 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 );
#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);
void deprecated_warning(const char *configname,unsigned int configlineno,
const char *option,const char *repl1,const char *repl2);
void deprecated_command (const char *name);
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;
char **value;
};
char *optsep(char **stringp);
char *argsplit(char *string);
int parse_options(char *str,unsigned int *options,
struct parse_options *opts,int noisy);
char *unescape_percent_string (const unsigned char *s);
int has_invalid_email_chars (const char *s);
+int is_valid_mailbox (const char *name);
char *default_homedir (void);
const char *get_libexecdir (void);
/*-- helptext.c --*/
void display_online_help( const char *keyword );
/*-- encode.c --*/
int setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek);
int encode_symmetric( const char *filename );
int encode_store( const char *filename );
int encode_crypt( const char *filename, STRLIST remusr, int use_symkey );
void encode_crypt_files(int nfiles, char **files, STRLIST remusr);
int encrypt_filter( void *opaque, int control,
IOBUF 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_backsig(PKT_public_key *main_pk,PKT_public_key *sub_pk,
PKT_signature *backsig);
int check_key_signature( KBNODE root, KBNODE node, int *is_selfsig );
int check_key_signature2( KBNODE root, KBNODE node, PKT_public_key *check_pk,
PKT_public_key *ret_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 commands, int quiet, int seckey_check );
void show_basic_key_info (KBNODE keyblock);
/*-- keygen.c --*/
u32 parse_expire_string(const char *string);
u32 ask_expire_interval(int object,const char *def_expire);
u32 ask_expiredate(void);
void generate_keypair( const char *fname, const char *card_serialno,
const char *backup_encryption_dir );
int keygen_set_std_prefs (const char *string,int personal);
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_keyserver_url(PKT_signature *sig, void *opaque);
int keygen_add_revkey(PKT_signature *sig, void *opaque);
int generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock );
#ifdef ENABLE_CARD_SUPPORT
int generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock,
int keyno, const char *serialno);
int save_unprotected_key_to_card (PKT_secret_key *sk, int keyno);
#endif
/*-- 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 *a );
IOBUF 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 );
MPI encode_session_key( DEK *dek, unsigned nbits );
MPI encode_md_value( int pubkey_algo, MD_HANDLE md,
int hash_algo, unsigned nbits );
/*-- import.c --*/
int parse_import_options(char *str,unsigned int *options,int noisy);
void import_keys( char **fnames, int nnames,
void *stats_hd, unsigned int options );
int import_keys_stream( IOBUF 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 );
int auto_create_card_key_stub ( const char *serialnostr,
const unsigned char *fpr1,
const unsigned char *fpr2,
const unsigned char *fpr3);
/*-- export.c --*/
int parse_export_options(char *str,unsigned int *options,int noisy);
int export_pubkeys( STRLIST users, unsigned int options );
int export_pubkeys_stream( IOBUF 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 print_subpackets_colon(PKT_signature *sig);
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_keyserver_url(PKT_signature *sig,int indent,int mode);
void show_notation(PKT_signature *sig,int indent,int mode,int which);
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);
void print_card_key_info (FILE *fp, KBNODE keyblock);
/*-- 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);
/*-- signal.c --*/
void init_signals(void);
void pause_on_sigusr( int which );
void block_all_signals(void);
void unblock_all_signals(void);
#ifdef ENABLE_CARD_SUPPORT
/*-- card-util.c --*/
void change_pin (int no, int allow_admin);
void card_status (FILE *fp, char *serialno, size_t serialnobuflen);
void card_edit (STRLIST commands);
int card_generate_subkey (KBNODE pub_keyblock, KBNODE sec_keyblock);
int card_store_subkey (KBNODE node, int use);
#endif
#endif /*G10_MAIN_H*/
diff --git a/g10/mainproc.c b/g10/mainproc.c
index afd347cfc..438543df1 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -1,2009 +1,2012 @@
/* mainproc.c - handle packets
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <time.h>
#include "packet.h"
#include "iobuf.h"
#include "memory.h"
#include "options.h"
#include "util.h"
#include "cipher.h"
#include "keydb.h"
#include "filter.h"
#include "main.h"
#include "status.h"
#include "i18n.h"
#include "trustdb.h"
#include "keyserver-internal.h"
#include "photoid.h"
struct kidlist_item {
struct kidlist_item *next;
u32 kid[2];
int pubkey_algo;
int reason;
};
/****************
* Structure to hold the context
*/
typedef struct mainproc_context *CTX;
struct mainproc_context {
struct mainproc_context *anchor; /* may be useful in the future */
PKT_public_key *last_pubkey;
PKT_secret_key *last_seckey;
PKT_user_id *last_user_id;
md_filter_context_t mfx;
int sigs_only; /* process only signatures and reject all other stuff */
int encrypt_only; /* process only encrytion messages */
STRLIST signed_data;
const char *sigfilename;
DEK *dek;
int last_was_session_key;
KBNODE list; /* the current list of packets */
int have_data;
IOBUF iobuf; /* used to get the filename etc. */
int trustletter; /* temp usage in list_node */
ulong symkeys;
struct kidlist_item *pkenc_list; /* list of encryption packets */
struct {
int op;
int stop_now;
} pipemode;
};
static int do_proc_packets( CTX c, IOBUF a );
static void list_node( CTX c, KBNODE node );
static void proc_tree( CTX c, KBNODE node );
static void
release_list( CTX c )
{
if( !c->list )
return;
proc_tree(c, c->list );
release_kbnode( c->list );
while( c->pkenc_list ) {
struct kidlist_item *tmp = c->pkenc_list->next;
xfree( c->pkenc_list );
c->pkenc_list = tmp;
}
c->pkenc_list = NULL;
c->list = NULL;
c->have_data = 0;
c->last_was_session_key = 0;
c->pipemode.op = 0;
c->pipemode.stop_now = 0;
xfree(c->dek); c->dek = NULL;
}
static int
add_onepass_sig( CTX c, PACKET *pkt )
{
KBNODE node;
if( c->list ) { /* add another packet */
/* We can only append another onepass packet if the list
* does contain only onepass packets */
for( node=c->list; node && node->pkt->pkttype == PKT_ONEPASS_SIG;
node = node->next )
;
if( node ) {
/* this is not the case, so we flush the current thing and
* allow this packet to start a new verification thing */
release_list( c );
c->list = new_kbnode( pkt );
}
else
add_kbnode( c->list, new_kbnode( pkt ));
}
else /* insert the first one */
c->list = node = new_kbnode( pkt );
return 1;
}
static int
add_gpg_control( CTX c, PACKET *pkt )
{
if ( pkt->pkt.gpg_control->control == CTRLPKT_CLEARSIGN_START ) {
/* New clear text signature.
* Process the last one and reset everything */
release_list(c);
}
else if ( pkt->pkt.gpg_control->control == CTRLPKT_PIPEMODE ) {
/* Pipemode control packet */
if ( pkt->pkt.gpg_control->datalen < 2 )
log_fatal ("invalid pipemode control packet length\n");
if (pkt->pkt.gpg_control->data[0] == 1) {
/* start the whole thing */
assert ( !c->list ); /* we should be in a pretty virgin state */
assert ( !c->pipemode.op );
c->pipemode.op = pkt->pkt.gpg_control->data[1];
}
else if (pkt->pkt.gpg_control->data[0] == 2) {
/* the signed material follows in a plaintext packet */
assert ( c->pipemode.op == 'B' );
}
else if (pkt->pkt.gpg_control->data[0] == 3) {
assert ( c->pipemode.op == 'B' );
release_list (c);
/* and tell the outer loop to terminate */
c->pipemode.stop_now = 1;
}
else
log_fatal ("invalid pipemode control packet code\n");
return 0; /* no need to store the packet */
}
if( c->list ) /* add another packet */
add_kbnode( c->list, new_kbnode( pkt ));
else /* insert the first one */
c->list = new_kbnode( pkt );
return 1;
}
static int
add_user_id( CTX c, PACKET *pkt )
{
if( !c->list ) {
log_error("orphaned user ID\n" );
return 0;
}
add_kbnode( c->list, new_kbnode( pkt ) );
return 1;
}
static int
add_subkey( CTX c, PACKET *pkt )
{
if( !c->list ) {
log_error("subkey w/o mainkey\n" );
return 0;
}
add_kbnode( c->list, new_kbnode( pkt ) );
return 1;
}
static int
add_ring_trust( CTX c, PACKET *pkt )
{
if( !c->list ) {
log_error("ring trust w/o key\n" );
return 0;
}
add_kbnode( c->list, new_kbnode( pkt ) );
return 1;
}
static int
add_signature( CTX c, PACKET *pkt )
{
KBNODE node;
if( pkt->pkttype == PKT_SIGNATURE && !c->list ) {
/* This is the first signature for the following datafile.
* GPG does not write such packets; instead it always uses
* onepass-sig packets. The drawback of PGP's method
* of prepending the signature to the data is
* that it is not possible to make a signature from data read
* from stdin. (GPG is able to read PGP stuff anyway.) */
node = new_kbnode( pkt );
c->list = node;
return 1;
}
else if( !c->list )
return 0; /* oops (invalid packet sequence)*/
else if( !c->list->pkt )
BUG(); /* so nicht */
/* add a new signature node id at the end */
node = new_kbnode( pkt );
add_kbnode( c->list, node );
return 1;
}
static int
symkey_decrypt_seskey( DEK *dek, byte *seskey, size_t slen )
{
CIPHER_HANDLE hd;
if(slen < 17 || slen > 33)
{
log_error ( _("weird size for an encrypted session key (%d)\n"),
(int)slen);
return G10ERR_BAD_KEY;
}
hd = cipher_open( dek->algo, CIPHER_MODE_CFB, 1 );
cipher_setkey( hd, dek->key, dek->keylen );
cipher_setiv( hd, NULL, 0 );
cipher_decrypt( hd, seskey, seskey, slen );
cipher_close( hd );
/* now we replace the dek components with the real session key to
decrypt the contents of the sequencing packet. */
dek->keylen=slen-1;
dek->algo=seskey[0];
if(dek->keylen > DIM(dek->key))
BUG ();
/* This is not completely accurate, since a bad passphrase may have
resulted in a garbage algorithm byte, but it's close enough since
a bogus byte here will fail later. */
if(dek->algo==CIPHER_ALGO_IDEA)
idea_cipher_warn(0);
memcpy(dek->key, seskey + 1, dek->keylen);
/*log_hexdump( "thekey", dek->key, dek->keylen );*/
return 0;
}
static void
proc_symkey_enc( CTX c, PACKET *pkt )
{
PKT_symkey_enc *enc;
enc = pkt->pkt.symkey_enc;
if (!enc)
log_error ("invalid symkey encrypted packet\n");
else if(!c->dek)
{
int algo = enc->cipher_algo;
const char *s = cipher_algo_to_string (algo);
if(s)
{
if(!opt.quiet)
{
if(enc->seskeylen)
log_info(_("%s encrypted session key\n"), s );
else
log_info(_("%s encrypted data\n"), s );
}
}
else
log_error(_("encrypted with unknown algorithm %d\n"), algo );
if(check_digest_algo(enc->s2k.hash_algo))
{
log_error(_("passphrase generated with unknown digest"
" algorithm %d\n"),enc->s2k.hash_algo);
s=NULL;
}
c->last_was_session_key = 2;
if(!s || opt.list_only)
goto leave;
if(opt.override_session_key)
{
c->dek = xmalloc_clear( sizeof *c->dek );
if(get_override_session_key(c->dek, opt.override_session_key))
{
xfree(c->dek);
c->dek = NULL;
}
}
else
{
c->dek=passphrase_to_dek(NULL, 0, algo, &enc->s2k, 0, NULL, NULL);
if(c->dek)
{
c->dek->symmetric=1;
/* FIXME: This doesn't work perfectly if a symmetric
key comes before a public key in the message - if
the user doesn't know the passphrase, then there is
a chance that the "decrypted" algorithm will happen
to be a valid one, which will make the returned dek
appear valid, so we won't try any public keys that
come later. */
if(enc->seskeylen)
{
if(symkey_decrypt_seskey(c->dek, enc->seskey,
enc->seskeylen))
{
xfree(c->dek);
c->dek=NULL;
}
}
else
c->dek->algo_info_printed = 1;
}
}
}
leave:
c->symkeys++;
free_packet(pkt);
}
static void
proc_pubkey_enc( CTX c, PACKET *pkt )
{
PKT_pubkey_enc *enc;
int result = 0;
/* check whether the secret key is available and store in this case */
c->last_was_session_key = 1;
enc = pkt->pkt.pubkey_enc;
/*printf("enc: encrypted by a pubkey with keyid %08lX\n", enc->keyid[1] );*/
/* Hmmm: why do I have this algo check here - anyway there is
* function to check it. */
if( opt.verbose )
log_info(_("public key is %s\n"), keystr(enc->keyid) );
if( is_status_enabled() ) {
char buf[50];
sprintf(buf, "%08lX%08lX %d 0",
(ulong)enc->keyid[0], (ulong)enc->keyid[1], enc->pubkey_algo );
write_status_text( STATUS_ENC_TO, buf );
}
if( !opt.list_only && opt.override_session_key ) {
/* It does not make much sense to store the session key in
* secure memory because it has already been passed on the
* command line and the GCHQ knows about it */
c->dek = xmalloc_clear( sizeof *c->dek );
result = get_override_session_key ( c->dek, opt.override_session_key );
if ( result ) {
xfree(c->dek); c->dek = NULL;
}
}
else if( is_ELGAMAL(enc->pubkey_algo)
|| enc->pubkey_algo == PUBKEY_ALGO_DSA
|| is_RSA(enc->pubkey_algo) ) {
if ( !c->dek && ((!enc->keyid[0] && !enc->keyid[1])
|| opt.try_all_secrets
|| !seckey_available( enc->keyid )) ) {
if( opt.list_only )
result = -1;
else {
c->dek = xmalloc_secure_clear( sizeof *c->dek );
if( (result = get_session_key( enc, c->dek )) ) {
/* error: delete the DEK */
xfree(c->dek); c->dek = NULL;
}
}
}
else
result = G10ERR_NO_SECKEY;
}
else
result = G10ERR_PUBKEY_ALGO;
if( result == -1 )
;
else
{
/* store it for later display */
struct kidlist_item *x = xmalloc( sizeof *x );
x->kid[0] = enc->keyid[0];
x->kid[1] = enc->keyid[1];
x->pubkey_algo = enc->pubkey_algo;
x->reason = result;
x->next = c->pkenc_list;
c->pkenc_list = x;
if( !result && opt.verbose > 1 )
log_info( _("public key encrypted data: good DEK\n") );
}
free_packet(pkt);
}
/****************
* Print the list of public key encrypted packets which we could
* not decrypt.
*/
static void
print_pkenc_list( struct kidlist_item *list, int failed )
{
for( ; list; list = list->next ) {
PKT_public_key *pk;
const char *algstr;
if ( failed && !list->reason )
continue;
if ( !failed && list->reason )
continue;
algstr = pubkey_algo_to_string( list->pubkey_algo );
pk = xmalloc_clear( sizeof *pk );
if( !algstr )
algstr = "[?]";
pk->pubkey_algo = list->pubkey_algo;
if( !get_pubkey( pk, list->kid ) )
{
char *p;
log_info( _("encrypted with %u-bit %s key, ID %s, created %s\n"),
nbits_from_pk( pk ), algstr, keystr_from_pk(pk),
strtimestamp(pk->timestamp) );
p=get_user_id_native(list->kid);
fprintf(log_stream(),_(" \"%s\"\n"),p);
xfree(p);
}
else
log_info(_("encrypted with %s key, ID %s\n"),
algstr,keystr(list->kid));
free_public_key( pk );
if( list->reason == G10ERR_NO_SECKEY ) {
if( is_status_enabled() ) {
char buf[20];
sprintf(buf,"%08lX%08lX", (ulong)list->kid[0],
(ulong)list->kid[1] );
write_status_text( STATUS_NO_SECKEY, buf );
}
}
else if (list->reason)
log_info(_("public key decryption failed: %s\n"),
g10_errstr(list->reason));
}
}
static void
proc_encrypted( CTX c, PACKET *pkt )
{
int result = 0;
if (!opt.quiet)
{
if(c->symkeys>1)
log_info(_("encrypted with %lu passphrases\n"),c->symkeys);
else if(c->symkeys==1)
log_info(_("encrypted with 1 passphrase\n"));
print_pkenc_list ( c->pkenc_list, 1 );
print_pkenc_list ( c->pkenc_list, 0 );
}
write_status( STATUS_BEGIN_DECRYPTION );
/*log_debug("dat: %sencrypted data\n", c->dek?"":"conventional ");*/
if( opt.list_only )
result = -1;
else if( !c->dek && !c->last_was_session_key ) {
int algo;
STRING2KEY s2kbuf, *s2k = NULL;
if(opt.override_session_key)
{
c->dek = xmalloc_clear( sizeof *c->dek );
result=get_override_session_key(c->dek, opt.override_session_key);
if(result)
{
xfree(c->dek);
c->dek = NULL;
}
}
else
{
/* assume this is old style conventional encrypted data */
if ( (algo = opt.def_cipher_algo))
log_info (_("assuming %s encrypted data\n"),
cipher_algo_to_string(algo));
else if ( check_cipher_algo(CIPHER_ALGO_IDEA) )
{
algo = opt.def_cipher_algo;
if (!algo)
algo = opt.s2k_cipher_algo;
idea_cipher_warn(1);
log_info (_("IDEA cipher unavailable, "
"optimistically attempting to use %s instead\n"),
cipher_algo_to_string(algo));
}
else
{
algo = CIPHER_ALGO_IDEA;
if (!opt.s2k_digest_algo)
{
/* If no digest is given we assume MD5 */
s2kbuf.mode = 0;
s2kbuf.hash_algo = DIGEST_ALGO_MD5;
s2k = &s2kbuf;
}
log_info (_("assuming %s encrypted data\n"), "IDEA");
}
c->dek = passphrase_to_dek ( NULL, 0, algo, s2k, 0, NULL, NULL );
if (c->dek)
c->dek->algo_info_printed = 1;
}
}
else if( !c->dek )
result = G10ERR_NO_SECKEY;
if( !result )
result = decrypt_data( c, pkt->pkt.encrypted, c->dek );
if( result == -1 )
;
else if( !result || (result==G10ERR_BAD_SIGN && opt.ignore_mdc_error)) {
write_status( STATUS_DECRYPTION_OKAY );
if( opt.verbose > 1 )
log_info(_("decryption okay\n"));
if( pkt->pkt.encrypted->mdc_method && !result )
write_status( STATUS_GOODMDC );
else if(!opt.no_mdc_warn)
log_info (_("WARNING: message was not integrity protected\n"));
if(opt.show_session_key)
{
int i;
char *buf = xmalloc ( c->dek->keylen*2 + 20 );
sprintf ( buf, "%d:", c->dek->algo );
for(i=0; i < c->dek->keylen; i++ )
sprintf(buf+strlen(buf), "%02X", c->dek->key[i] );
log_info( "session key: `%s'\n", buf );
write_status_text ( STATUS_SESSION_KEY, buf );
}
}
else if( result == G10ERR_BAD_SIGN ) {
log_error(_("WARNING: encrypted message has been manipulated!\n"));
write_status( STATUS_BADMDC );
write_status( STATUS_DECRYPTION_FAILED );
}
else {
write_status( STATUS_DECRYPTION_FAILED );
log_error(_("decryption failed: %s\n"), g10_errstr(result));
/* Hmmm: does this work when we have encrypted using multiple
* ways to specify the session key (symmmetric and PK)*/
}
xfree(c->dek); c->dek = NULL;
free_packet(pkt);
c->last_was_session_key = 0;
write_status( STATUS_END_DECRYPTION );
}
static void
proc_plaintext( CTX c, PACKET *pkt )
{
PKT_plaintext *pt = pkt->pkt.plaintext;
int any, clearsig, only_md5, rc;
KBNODE n;
if( pt->namelen == 8 && !memcmp( pt->name, "_CONSOLE", 8 ) )
log_info(_("NOTE: sender requested \"for-your-eyes-only\"\n"));
else if( opt.verbose )
log_info(_("original file name='%.*s'\n"), pt->namelen, pt->name);
free_md_filter_context( &c->mfx );
c->mfx.md = md_open( 0, 0);
/* fixme: we may need to push the textfilter if we have sigclass 1
* and no armoring - Not yet tested
* Hmmm, why don't we need it at all if we have sigclass 1
* Should we assume that plaintext in mode 't' has always sigclass 1??
* See: Russ Allbery's mail 1999-02-09
*/
any = clearsig = only_md5 = 0;
for(n=c->list; n; n = n->next )
{
if( n->pkt->pkttype == PKT_ONEPASS_SIG )
{
/* For the onepass signature case */
if( n->pkt->pkt.onepass_sig->digest_algo )
{
md_enable( c->mfx.md, n->pkt->pkt.onepass_sig->digest_algo );
if( !any && n->pkt->pkt.onepass_sig->digest_algo
== DIGEST_ALGO_MD5 )
only_md5 = 1;
else
only_md5 = 0;
any = 1;
}
if( n->pkt->pkt.onepass_sig->sig_class != 0x01 )
only_md5 = 0;
}
else if( n->pkt->pkttype == PKT_GPG_CONTROL
&& n->pkt->pkt.gpg_control->control
== CTRLPKT_CLEARSIGN_START )
{
/* For the clearsigned message case */
size_t datalen = n->pkt->pkt.gpg_control->datalen;
const byte *data = n->pkt->pkt.gpg_control->data;
/* check that we have at least the sigclass and one hash */
if ( datalen < 2 )
log_fatal("invalid control packet CTRLPKT_CLEARSIGN_START\n");
/* Note that we don't set the clearsig flag for not-dash-escaped
* documents */
clearsig = (*data == 0x01);
for( data++, datalen--; datalen; datalen--, data++ )
md_enable( c->mfx.md, *data );
any = 1;
break; /* no pass signature packets are expected */
}
else if(n->pkt->pkttype==PKT_SIGNATURE)
{
/* For the SIG+LITERAL case that PGP used to use. */
md_enable( c->mfx.md, n->pkt->pkt.signature->digest_algo );
any=1;
}
}
if( !any && !opt.skip_verify )
{
/* This is for the old GPG LITERAL+SIG case. It's not legal
according to 2440, so hopefully it won't come up that
often. There is no good way to specify what algorithms to
use in that case, so these three are the historical
answer. */
md_enable( c->mfx.md, DIGEST_ALGO_RMD160 );
md_enable( c->mfx.md, DIGEST_ALGO_SHA1 );
md_enable( c->mfx.md, DIGEST_ALGO_MD5 );
}
if( opt.pgp2_workarounds && only_md5 && !opt.skip_verify ) {
/* This is a kludge to work around a bug in pgp2. It does only
* catch those mails which are armored. To catch the non-armored
* pgp mails we could see whether there is the signature packet
* in front of the plaintext. If someone needs this, send me a patch.
*/
c->mfx.md2 = md_open( DIGEST_ALGO_MD5, 0);
}
if ( DBG_HASHING ) {
md_start_debug( c->mfx.md, "verify" );
if ( c->mfx.md2 )
md_start_debug( c->mfx.md2, "verify2" );
}
if ( c->pipemode.op == 'B' )
rc = handle_plaintext( pt, &c->mfx, 1, 0 );
else {
rc = handle_plaintext( pt, &c->mfx, c->sigs_only, clearsig );
if( rc == G10ERR_CREATE_FILE && !c->sigs_only) {
/* can't write output but we hash it anyway to
* check the signature */
rc = handle_plaintext( pt, &c->mfx, 1, clearsig );
}
}
if( rc )
log_error( "handle plaintext failed: %s\n", g10_errstr(rc));
free_packet(pkt);
c->last_was_session_key = 0;
/* We add a marker control packet instead of the plaintext packet.
* This is so that we can later detect invalid packet sequences.
*/
n = new_kbnode (create_gpg_control (CTRLPKT_PLAINTEXT_MARK, NULL, 0));
if (c->list)
add_kbnode (c->list, n);
else
c->list = n;
}
static int
proc_compressed_cb( IOBUF a, void *info )
{
return proc_signature_packets( info, a, ((CTX)info)->signed_data,
((CTX)info)->sigfilename );
}
static int
proc_encrypt_cb( IOBUF a, void *info )
{
return proc_encryption_packets( info, a );
}
static void
proc_compressed( CTX c, PACKET *pkt )
{
PKT_compressed *zd = pkt->pkt.compressed;
int rc;
/*printf("zip: compressed data packet\n");*/
if( c->sigs_only )
rc = handle_compressed( c, zd, proc_compressed_cb, c );
else if( c->encrypt_only )
rc = handle_compressed( c, zd, proc_encrypt_cb, c );
else
rc = handle_compressed( c, zd, NULL, NULL );
if( rc )
log_error("uncompressing failed: %s\n", g10_errstr(rc));
free_packet(pkt);
c->last_was_session_key = 0;
}
/****************
* check the signature
* Returns: 0 = valid signature or an error code
*/
static int
do_check_sig( CTX c, KBNODE node, int *is_selfsig,
int *is_expkey, int *is_revkey )
{
PKT_signature *sig;
MD_HANDLE md = NULL, md2 = NULL;
int algo, rc;
assert( node->pkt->pkttype == PKT_SIGNATURE );
if( is_selfsig )
*is_selfsig = 0;
sig = node->pkt->pkt.signature;
algo = sig->digest_algo;
if( (rc=check_digest_algo(algo)) )
return rc;
if( sig->sig_class == 0x00 ) {
if( c->mfx.md )
md = md_copy( c->mfx.md );
else /* detached signature */
md = md_open( 0, 0 ); /* signature_check() will enable the md*/
}
else if( sig->sig_class == 0x01 ) {
/* how do we know that we have to hash the (already hashed) text
* in canonical mode ??? (calculating both modes???) */
if( c->mfx.md ) {
md = md_copy( c->mfx.md );
if( c->mfx.md2 )
md2 = md_copy( c->mfx.md2 );
}
else { /* detached signature */
log_debug("Do we really need this here?");
md = md_open( 0, 0 ); /* signature_check() will enable the md*/
md2 = md_open( 0, 0 );
}
}
else if( (sig->sig_class&~3) == 0x10
|| sig->sig_class == 0x18
|| sig->sig_class == 0x1f
|| sig->sig_class == 0x20
|| sig->sig_class == 0x28
|| sig->sig_class == 0x30 ) {
if( c->list->pkt->pkttype == PKT_PUBLIC_KEY
|| c->list->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
return check_key_signature( c->list, node, is_selfsig );
}
else if( sig->sig_class == 0x20 ) {
log_info(_("standalone revocation - "
"use \"gpg --import\" to apply\n"));
return G10ERR_NOT_PROCESSED;
}
else {
log_error("invalid root packet for sigclass %02x\n",
sig->sig_class);
return G10ERR_SIG_CLASS;
}
}
else
return G10ERR_SIG_CLASS;
rc = signature_check2( sig, md, NULL, is_expkey, is_revkey, NULL );
if( rc == G10ERR_BAD_SIGN && md2 )
rc = signature_check2( sig, md2, NULL, is_expkey, is_revkey, NULL );
md_close(md);
md_close(md2);
return rc;
}
static void
print_userid( PACKET *pkt )
{
if( !pkt )
BUG();
if( pkt->pkttype != PKT_USER_ID ) {
printf("ERROR: unexpected packet type %d", pkt->pkttype );
return;
}
if( opt.with_colons )
{
if(pkt->pkt.user_id->attrib_data)
printf("%u %lu",
pkt->pkt.user_id->numattribs,
pkt->pkt.user_id->attrib_len);
else
print_string( stdout, pkt->pkt.user_id->name,
pkt->pkt.user_id->len, ':');
}
else
print_utf8_string( stdout, pkt->pkt.user_id->name,
pkt->pkt.user_id->len );
}
/****************
* List the certificate in a user friendly way
*/
static void
list_node( CTX c, KBNODE node )
{
int any=0;
int mainkey;
if( !node )
;
else if( (mainkey = (node->pkt->pkttype == PKT_PUBLIC_KEY) )
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
PKT_public_key *pk = node->pkt->pkt.public_key;
if( opt.with_colons )
{
u32 keyid[2];
keyid_from_pk( pk, keyid );
if( mainkey )
c->trustletter = opt.fast_list_mode?
0 : get_validity_info( pk, NULL );
printf("%s:", mainkey? "pub":"sub" );
if( c->trustletter )
putchar( c->trustletter );
printf(":%u:%d:%08lX%08lX:%s:%s::",
nbits_from_pk( pk ),
pk->pubkey_algo,
(ulong)keyid[0],(ulong)keyid[1],
colon_datestr_from_pk( pk ),
colon_strtime (pk->expiredate) );
if( mainkey && !opt.fast_list_mode )
putchar( get_ownertrust_info (pk) );
putchar(':');
if( node->next && node->next->pkt->pkttype == PKT_RING_TRUST) {
putchar('\n'); any=1;
if( opt.fingerprint )
print_fingerprint( pk, NULL, 0 );
printf("rtv:1:%u:\n",
node->next->pkt->pkt.ring_trust->trustval );
}
}
else
printf("%s %4u%c/%s %s%s",
mainkey? "pub":"sub", nbits_from_pk( pk ),
pubkey_letter( pk->pubkey_algo ), keystr_from_pk( pk ),
datestr_from_pk( pk ), mainkey?" ":"");
if( mainkey ) {
/* and now list all userids with their signatures */
for( node = node->next; node; node = node->next ) {
if( node->pkt->pkttype == PKT_SIGNATURE ) {
if( !any ) {
if( node->pkt->pkt.signature->sig_class == 0x20 )
puts("[revoked]");
else
putchar('\n');
any = 1;
}
list_node(c, node );
}
else if( node->pkt->pkttype == PKT_USER_ID ) {
if( any ) {
if( opt.with_colons )
printf("%s:::::::::",
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
else
printf( "uid%*s", 28, "" );
}
print_userid( node->pkt );
if( opt.with_colons )
putchar(':');
putchar('\n');
if( opt.fingerprint && !any )
print_fingerprint( pk, NULL, 0 );
if( node->next
&& node->next->pkt->pkttype == PKT_RING_TRUST ) {
printf("rtv:2:%u:\n",
node->next->pkt->pkt.ring_trust->trustval );
}
any=1;
}
else if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
if( !any ) {
putchar('\n');
any = 1;
}
list_node(c, node );
}
}
}
else
{
/* of subkey */
if( pk->is_revoked )
{
printf(" [");
printf(_("revoked: %s"),revokestr_from_pk(pk));
printf("]");
}
else if( pk->expiredate )
{
printf(" [");
printf(_("expires: %s"),expirestr_from_pk(pk));
printf("]");
}
}
if( !any )
putchar('\n');
if( !mainkey && opt.fingerprint > 1 )
print_fingerprint( pk, NULL, 0 );
}
else if( (mainkey = (node->pkt->pkttype == PKT_SECRET_KEY) )
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
PKT_secret_key *sk = node->pkt->pkt.secret_key;
if( opt.with_colons )
{
u32 keyid[2];
keyid_from_sk( sk, keyid );
printf("%s::%u:%d:%08lX%08lX:%s:%s:::",
mainkey? "sec":"ssb",
nbits_from_sk( sk ),
sk->pubkey_algo,
(ulong)keyid[0],(ulong)keyid[1],
colon_datestr_from_sk( sk ),
colon_strtime (sk->expiredate)
/* fixme: add LID */ );
}
else
printf("%s %4u%c/%s %s ", mainkey? "sec":"ssb",
nbits_from_sk( sk ), pubkey_letter( sk->pubkey_algo ),
keystr_from_sk( sk ), datestr_from_sk( sk ));
if( mainkey ) {
/* and now list all userids with their signatures */
for( node = node->next; node; node = node->next ) {
if( node->pkt->pkttype == PKT_SIGNATURE ) {
if( !any ) {
if( node->pkt->pkt.signature->sig_class == 0x20 )
puts("[revoked]");
else
putchar('\n');
any = 1;
}
list_node(c, node );
}
else if( node->pkt->pkttype == PKT_USER_ID ) {
if( any ) {
if( opt.with_colons )
printf("%s:::::::::",
node->pkt->pkt.user_id->attrib_data?"uat":"uid");
else
printf( "uid%*s", 28, "" );
}
print_userid( node->pkt );
if( opt.with_colons )
putchar(':');
putchar('\n');
if( opt.fingerprint && !any )
print_fingerprint( NULL, sk, 0 );
any=1;
}
else if( node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
if( !any ) {
putchar('\n');
any = 1;
}
list_node(c, node );
}
}
}
if( !any )
putchar('\n');
if( !mainkey && opt.fingerprint > 1 )
print_fingerprint( NULL, sk, 0 );
}
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
PKT_signature *sig = node->pkt->pkt.signature;
int is_selfsig = 0;
int rc2=0;
size_t n;
char *p;
int sigrc = ' ';
if( !opt.verbose )
return;
if( sig->sig_class == 0x20 || sig->sig_class == 0x30 )
fputs("rev", stdout);
else
fputs("sig", stdout);
if( opt.check_sigs ) {
fflush(stdout);
switch( (rc2=do_check_sig( c, node, &is_selfsig, NULL, NULL )) ) {
case 0: sigrc = '!'; break;
case G10ERR_BAD_SIGN: sigrc = '-'; break;
case G10ERR_NO_PUBKEY:
case G10ERR_UNU_PUBKEY: sigrc = '?'; break;
default: sigrc = '%'; break;
}
}
else { /* check whether this is a self signature */
u32 keyid[2];
if( c->list->pkt->pkttype == PKT_PUBLIC_KEY
|| c->list->pkt->pkttype == PKT_SECRET_KEY ) {
if( c->list->pkt->pkttype == PKT_PUBLIC_KEY )
keyid_from_pk( c->list->pkt->pkt.public_key, keyid );
else
keyid_from_sk( c->list->pkt->pkt.secret_key, keyid );
if( keyid[0] == sig->keyid[0] && keyid[1] == sig->keyid[1] )
is_selfsig = 1;
}
}
if( opt.with_colons ) {
putchar(':');
if( sigrc != ' ' )
putchar(sigrc);
printf("::%d:%08lX%08lX:%s:%s:", sig->pubkey_algo,
(ulong)sig->keyid[0], (ulong)sig->keyid[1],
colon_datestr_from_sig(sig),
colon_expirestr_from_sig(sig));
if(sig->trust_depth || sig->trust_value)
printf("%d %d",sig->trust_depth,sig->trust_value);
printf(":");
if(sig->trust_regexp)
print_string(stdout,sig->trust_regexp,
strlen(sig->trust_regexp),':');
printf(":");
}
else
printf("%c %s %s ",
sigrc, keystr(sig->keyid), datestr_from_sig(sig));
if( sigrc == '%' )
printf("[%s] ", g10_errstr(rc2) );
else if( sigrc == '?' )
;
else if( is_selfsig ) {
if( opt.with_colons )
putchar(':');
fputs( sig->sig_class == 0x18? "[keybind]":"[selfsig]", stdout);
if( opt.with_colons )
putchar(':');
}
else if( !opt.fast_list_mode ) {
p = get_user_id( sig->keyid, &n );
print_string( stdout, p, n, opt.with_colons );
xfree(p);
}
if( opt.with_colons )
printf(":%02x%c:", sig->sig_class, sig->flags.exportable?'x':'l');
putchar('\n');
}
else
log_error("invalid node with packet of type %d\n", node->pkt->pkttype);
}
int
proc_packets( void *anchor, IOBUF a )
{
int rc;
CTX c = xmalloc_clear( sizeof *c );
c->anchor = anchor;
rc = do_proc_packets( c, a );
xfree( c );
return rc;
}
int
proc_signature_packets( void *anchor, IOBUF a,
STRLIST signedfiles, const char *sigfilename )
{
CTX c = xmalloc_clear( sizeof *c );
int rc;
c->anchor = anchor;
c->sigs_only = 1;
c->signed_data = signedfiles;
c->sigfilename = sigfilename;
rc = do_proc_packets( c, a );
xfree( c );
return rc;
}
int
proc_encryption_packets( void *anchor, IOBUF a )
{
CTX c = xmalloc_clear( sizeof *c );
int rc;
c->anchor = anchor;
c->encrypt_only = 1;
rc = do_proc_packets( c, a );
xfree( c );
return rc;
}
int
do_proc_packets( CTX c, IOBUF a )
{
PACKET *pkt = xmalloc( sizeof *pkt );
int rc=0;
int any_data=0;
int newpkt;
c->iobuf = a;
init_packet(pkt);
while( (rc=parse_packet(a, pkt)) != -1 ) {
any_data = 1;
if( rc ) {
free_packet(pkt);
/* stop processing when an invalid packet has been encountered
* but don't do so when we are doing a --list-packets. */
if( rc == G10ERR_INVALID_PACKET && opt.list_packets != 2 )
break;
continue;
}
newpkt = -1;
if( opt.list_packets ) {
switch( pkt->pkttype ) {
case PKT_PUBKEY_ENC: proc_pubkey_enc( c, pkt ); break;
case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break;
case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
default: newpkt = 0; break;
}
}
else if( c->sigs_only ) {
switch( pkt->pkttype ) {
case PKT_PUBLIC_KEY:
case PKT_SECRET_KEY:
case PKT_USER_ID:
case PKT_SYMKEY_ENC:
case PKT_PUBKEY_ENC:
case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC:
write_status_text( STATUS_UNEXPECTED, "0" );
rc = G10ERR_UNEXPECTED;
goto leave;
case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break;
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
default: newpkt = 0; break;
}
}
else if( c->encrypt_only ) {
switch( pkt->pkttype ) {
case PKT_PUBLIC_KEY:
case PKT_SECRET_KEY:
case PKT_USER_ID:
write_status_text( STATUS_UNEXPECTED, "0" );
rc = G10ERR_UNEXPECTED;
goto leave;
case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break;
case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break;
case PKT_PUBKEY_ENC: proc_pubkey_enc( c, pkt ); break;
case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
default: newpkt = 0; break;
}
}
else {
switch( pkt->pkttype ) {
case PKT_PUBLIC_KEY:
case PKT_SECRET_KEY:
release_list( c );
c->list = new_kbnode( pkt );
newpkt = 1;
break;
case PKT_PUBLIC_SUBKEY:
case PKT_SECRET_SUBKEY:
newpkt = add_subkey( c, pkt );
break;
case PKT_USER_ID: newpkt = add_user_id( c, pkt ); break;
case PKT_SIGNATURE: newpkt = add_signature( c, pkt ); break;
case PKT_PUBKEY_ENC: proc_pubkey_enc( c, pkt ); break;
case PKT_SYMKEY_ENC: proc_symkey_enc( c, pkt ); break;
case PKT_ENCRYPTED:
case PKT_ENCRYPTED_MDC: proc_encrypted( c, pkt ); break;
case PKT_PLAINTEXT: proc_plaintext( c, pkt ); break;
case PKT_COMPRESSED: proc_compressed( c, pkt ); break;
case PKT_ONEPASS_SIG: newpkt = add_onepass_sig( c, pkt ); break;
case PKT_GPG_CONTROL: newpkt = add_gpg_control(c, pkt); break;
case PKT_RING_TRUST: newpkt = add_ring_trust( c, pkt ); break;
default: newpkt = 0; break;
}
}
/* This is a very ugly construct and frankly, I don't remember why
* I used it. Adding the MDC check here is a hack.
* The right solution is to initiate another context for encrypted
* packet and not to reuse the current one ... It works right
* when there is a compression packet inbetween which adds just
* an extra layer.
* Hmmm: Rewrite this whole module here??
*/
if( pkt->pkttype != PKT_SIGNATURE && pkt->pkttype != PKT_MDC )
c->have_data = pkt->pkttype == PKT_PLAINTEXT;
if( newpkt == -1 )
;
else if( newpkt ) {
pkt = xmalloc( sizeof *pkt );
init_packet(pkt);
}
else
free_packet(pkt);
if ( c->pipemode.stop_now ) {
/* we won't get an EOF in pipemode, so we have to
* break the loop here */
rc = -1;
break;
}
}
if( rc == G10ERR_INVALID_PACKET )
write_status_text( STATUS_NODATA, "3" );
if( any_data )
rc = 0;
else if( rc == -1 )
write_status_text( STATUS_NODATA, "2" );
leave:
release_list( c );
xfree(c->dek);
free_packet( pkt );
xfree( pkt );
free_md_filter_context( &c->mfx );
return rc;
}
/* Helper for pka_uri_from_sig to parse the to-be-verified address out
of the notation data. */
static pka_info_t *
get_pka_address (PKT_signature *sig)
{
const unsigned char *p;
size_t len, n1, n2;
int seq = 0;
pka_info_t *pka = NULL;
while ((p = enum_sig_subpkt (sig->hashed, SIGSUBPKT_NOTATION,
&len, &seq, NULL)))
{
if (len < 8)
continue; /* Notation packet is too short. */
n1 = (p[4]<<8)|p[5];
n2 = (p[6]<<8)|p[7];
if (8 + n1 + n2 != len)
continue; /* Length fields of notation packet are inconsistent. */
p += 8;
if (n1 != 21 || memcmp (p, "pka-address@gnupg.org", 21))
continue; /* Not the notation we want. */
p += n1;
if (n2 < 3)
continue; /* Impossible email address. */
if (pka)
break; /* For now we only use the first valid PKA notation. In
future we might want to keep additional PKA
notations in a linked list. */
pka = xmalloc (sizeof *pka + n2);
pka->valid = 0;
pka->checked = 0;
pka->uri = NULL;
memcpy (pka->email, p, n2);
pka->email[n2] = 0;
- if (has_invalid_email_chars (pka->email))
+ if (!is_valid_mailbox (pka->email))
{
/* We don't accept invalid mail addresses. */
xfree (pka);
pka = NULL;
}
}
return pka;
}
/* Return the URI from a DNS PKA record. If this record has already
be retrieved for the signature we merely return it; if not we go
out and try to get that DNS record. */
static const char *
pka_uri_from_sig (PKT_signature *sig)
{
if (!sig->flags.pka_tried)
{
assert (!sig->pka_info);
sig->flags.pka_tried = 1;
sig->pka_info = get_pka_address (sig);
if (sig->pka_info)
{
char *uri;
uri = get_pka_info (sig->pka_info->email, sig->pka_info->fpr);
if (uri)
{
sig->pka_info->valid = 1;
if (!*uri)
xfree (uri);
else
sig->pka_info->uri = uri;
}
}
}
return sig->pka_info? sig->pka_info->uri : NULL;
}
static int
check_sig_and_print( CTX c, KBNODE node )
{
PKT_signature *sig = node->pkt->pkt.signature;
const char *astr;
int rc, is_expkey=0, is_revkey=0;
if( opt.skip_verify ) {
log_info(_("signature verification suppressed\n"));
return 0;
}
/* It is not in all cases possible to check multiple signatures:
* PGP 2 (which is also allowed by OpenPGP), does use the packet
* sequence: sig+data, OpenPGP does use onepas+data=sig and GnuPG
* sometimes uses (because I did'nt read the specs right) data+sig.
* Because it is possible to create multiple signatures with
* different packet sequence (e.g. data+sig and sig+data) it might
* not be possible to get it right: let's say we have:
* data+sig, sig+data,sig+data and we have not yet encountered the last
* data, we could also see this a one data with 2 signatures and then
* data+sig.
* To protect against this we check that all signatures follow
* without any intermediate packets. Note, that we won't get this
* error when we use onepass packets or cleartext signatures because
* we reset the list every time
*
* FIXME: Now that we have these marker packets, we should create a
* real grammar and check against this.
*/
{
KBNODE n;
int n_sig=0;
for (n=c->list; n; n=n->next ) {
if ( n->pkt->pkttype == PKT_SIGNATURE )
n_sig++;
}
if (n_sig > 1) { /* more than one signature - check sequence */
int tmp, onepass;
for (tmp=onepass=0,n=c->list; n; n=n->next ) {
if (n->pkt->pkttype == PKT_ONEPASS_SIG)
onepass++;
else if (n->pkt->pkttype == PKT_GPG_CONTROL
&& n->pkt->pkt.gpg_control->control
== CTRLPKT_CLEARSIGN_START ) {
onepass++; /* handle the same way as a onepass */
}
else if ( (tmp && n->pkt->pkttype != PKT_SIGNATURE) ) {
log_error(_("can't handle these multiple signatures\n"));
return 0;
}
else if ( n->pkt->pkttype == PKT_SIGNATURE )
tmp = 1;
else if (!tmp && !onepass
&& n->pkt->pkttype == PKT_GPG_CONTROL
&& n->pkt->pkt.gpg_control->control
== CTRLPKT_PLAINTEXT_MARK ) {
/* plaintext before signatures but no one-pass packets*/
log_error(_("can't handle these multiple signatures\n"));
return 0;
}
}
}
}
astr = pubkey_algo_to_string( sig->pubkey_algo );
if(keystrlen()>8)
{
log_info(_("Signature made %s\n"),asctimestamp(sig->timestamp));
log_info(_(" using %s key %s\n"),
astr? astr: "?",keystr(sig->keyid));
}
else
log_info(_("Signature made %s using %s key ID %s\n"),
asctimestamp(sig->timestamp), astr? astr: "?",
keystr(sig->keyid));
rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey );
/* If the key isn't found, check for a preferred keyserver */
if(rc==G10ERR_NO_PUBKEY && sig->flags.pref_ks)
{
const byte *p;
int seq=0;
size_t n;
while((p=enum_sig_subpkt(sig->hashed,SIGSUBPKT_PREF_KS,&n,&seq,NULL)))
{
/* According to my favorite copy editor, in English
grammar, you say "at" if the key is located on a web
page, but "from" if it is located on a keyserver. I'm
not going to even try to make two strings here :) */
log_info(_("Key available at: ") );
print_utf8_string( log_stream(), p, n );
putc( '\n', log_stream() );
if(opt.keyserver_options.options&KEYSERVER_AUTO_KEY_RETRIEVE
&& opt.keyserver_options.options&KEYSERVER_HONOR_KEYSERVER_URL)
{
struct keyserver_spec *spec;
spec=parse_preferred_keyserver(sig);
if(spec)
{
int res;
glo_ctrl.in_auto_key_retrieve++;
res=keyserver_import_keyid(sig->keyid,spec);
glo_ctrl.in_auto_key_retrieve--;
if(!res)
rc=do_check_sig(c, node, NULL, &is_expkey, &is_revkey );
free_keyserver_spec(spec);
if(!rc)
break;
}
}
}
}
/* If the preferred keyserver thing above didn't work, our second
try is to use the URI from a DNS PKA record. */
- if ( rc == G10ERR_NO_PUBKEY )
+ if ( rc == G10ERR_NO_PUBKEY
+ && (opt.keyserver_options.options&KEYSERVER_AUTO_PKA_RETRIEVE))
{
const char *uri = pka_uri_from_sig (sig);
if (uri)
{
+ /* FIXME: We might want to locate the key using the
+ fingerprint instead of the keyid. */
int res;
struct keyserver_spec *spec;
spec = parse_keyserver_uri (uri, 0, NULL, 0);
if (spec)
{
glo_ctrl.in_auto_key_retrieve++;
res = keyserver_import_keyid (sig->keyid, spec);
glo_ctrl.in_auto_key_retrieve--;
free_keyserver_spec (spec);
if (!res)
rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey );
}
}
}
/* If the preferred keyserver thing above didn't work and we got
no information from the DNS PKA, this is a third try. */
if( rc == G10ERR_NO_PUBKEY && opt.keyserver
&& (opt.keyserver_options.options&KEYSERVER_AUTO_KEY_RETRIEVE))
{
int res;
glo_ctrl.in_auto_key_retrieve++;
res=keyserver_import_keyid ( sig->keyid, opt.keyserver );
glo_ctrl.in_auto_key_retrieve--;
if(!res)
rc = do_check_sig(c, node, NULL, &is_expkey, &is_revkey );
}
if( !rc || rc == G10ERR_BAD_SIGN ) {
KBNODE un, keyblock;
int count=0, statno;
char keyid_str[50];
PKT_public_key *pk=NULL;
if(rc)
statno=STATUS_BADSIG;
else if(sig->flags.expired)
statno=STATUS_EXPSIG;
else if(is_expkey)
statno=STATUS_EXPKEYSIG;
else if(is_revkey)
statno=STATUS_REVKEYSIG;
else
statno=STATUS_GOODSIG;
keyblock = get_pubkeyblock( sig->keyid );
sprintf (keyid_str, "%08lX%08lX [uncertain] ",
(ulong)sig->keyid[0], (ulong)sig->keyid[1]);
/* find and print the primary user ID */
for( un=keyblock; un; un = un->next ) {
char *p;
int valid;
if(un->pkt->pkttype==PKT_PUBLIC_KEY)
{
pk=un->pkt->pkt.public_key;
continue;
}
if( un->pkt->pkttype != PKT_USER_ID )
continue;
if ( !un->pkt->pkt.user_id->created )
continue;
if ( un->pkt->pkt.user_id->is_revoked )
continue;
if ( un->pkt->pkt.user_id->is_expired )
continue;
if ( !un->pkt->pkt.user_id->is_primary )
continue;
/* We want the textual primary user ID here */
if ( un->pkt->pkt.user_id->attrib_data )
continue;
assert(pk);
/* Get it before we print anything to avoid interrupting
the output with the "please do a --check-trustdb"
line. */
valid=get_validity(pk,un->pkt->pkt.user_id);
keyid_str[17] = 0; /* cut off the "[uncertain]" part */
write_status_text_and_buffer (statno, keyid_str,
un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,
-1 );
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
if(rc)
log_info(_("BAD signature from \"%s\""),p);
else if(sig->flags.expired)
log_info(_("Expired signature from \"%s\""),p);
else
log_info(_("Good signature from \"%s\""),p);
xfree(p);
if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
fprintf(log_stream()," [%s]\n",trust_value_to_string(valid));
else
fputs("\n", log_stream() );
count++;
}
if( !count ) { /* just in case that we have no valid textual
userid */
char *p;
/* Try for an invalid textual userid */
for( un=keyblock; un; un = un->next ) {
if( un->pkt->pkttype == PKT_USER_ID &&
!un->pkt->pkt.user_id->attrib_data )
break;
}
/* Try for any userid at all */
if(!un) {
for( un=keyblock; un; un = un->next ) {
if( un->pkt->pkttype == PKT_USER_ID )
break;
}
}
if (opt.trust_model==TM_ALWAYS || !un)
keyid_str[17] = 0; /* cut off the "[uncertain]" part */
write_status_text_and_buffer (statno, keyid_str,
un? un->pkt->pkt.user_id->name:"[?]",
un? un->pkt->pkt.user_id->len:3,
-1 );
if(un)
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
else
p=xstrdup("[?]");
if(rc)
log_info(_("BAD signature from \"%s\""),p);
else if(sig->flags.expired)
log_info(_("Expired signature from \"%s\""),p);
else
log_info(_("Good signature from \"%s\""),p);
if (opt.trust_model!=TM_ALWAYS && un)
{
putc(' ', log_stream() );
fputs(_("[uncertain]"), log_stream() );
}
fputs("\n", log_stream() );
}
/* If we have a good signature and already printed
* the primary user ID, print all the other user IDs */
if ( count && !rc ) {
char *p;
for( un=keyblock; un; un = un->next ) {
if( un->pkt->pkttype != PKT_USER_ID )
continue;
if((un->pkt->pkt.user_id->is_revoked
|| un->pkt->pkt.user_id->is_expired)
&& !(opt.verify_options&VERIFY_SHOW_UNUSABLE_UIDS))
continue;
/* Only skip textual primaries */
if ( un->pkt->pkt.user_id->is_primary &&
!un->pkt->pkt.user_id->attrib_data )
continue;
if(un->pkt->pkt.user_id->attrib_data)
{
dump_attribs(un->pkt->pkt.user_id,pk,NULL);
if(opt.verify_options&VERIFY_SHOW_PHOTOS)
show_photos(un->pkt->pkt.user_id->attribs,
un->pkt->pkt.user_id->numattribs,pk,NULL);
}
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
log_info(_(" aka \"%s\""),p);
xfree(p);
if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
{
const char *valid;
if(un->pkt->pkt.user_id->is_revoked)
valid=_("revoked");
else if(un->pkt->pkt.user_id->is_expired)
valid=_("expired");
else
valid=trust_value_to_string(get_validity(pk,
un->pkt->
pkt.user_id));
fprintf(log_stream()," [%s]\n",valid);
}
else
fputs("\n", log_stream() );
}
}
release_kbnode( keyblock );
if( !rc )
{
if(opt.verify_options&VERIFY_SHOW_POLICY_URLS)
show_policy_url(sig,0,1);
else
show_policy_url(sig,0,2);
if(opt.verify_options&VERIFY_SHOW_KEYSERVER_URLS)
show_keyserver_url(sig,0,1);
else
show_keyserver_url(sig,0,2);
if(opt.verify_options&VERIFY_SHOW_NOTATIONS)
show_notation(sig,0,1,
((opt.verify_options&VERIFY_SHOW_STD_NOTATIONS)?1:0)+
((opt.verify_options&VERIFY_SHOW_USER_NOTATIONS)?2:0));
else
show_notation(sig,0,2,0);
}
if( !rc && is_status_enabled() ) {
/* print a status response with the fingerprint */
PKT_public_key *vpk = xmalloc_clear( sizeof *vpk );
if( !get_pubkey( vpk, sig->keyid ) ) {
byte array[MAX_FINGERPRINT_LEN], *p;
char buf[MAX_FINGERPRINT_LEN*4+90], *bufp;
size_t i, n;
bufp = buf;
fingerprint_from_pk( vpk, array, &n );
p = array;
for(i=0; i < n ; i++, p++, bufp += 2)
sprintf(bufp, "%02X", *p );
/* TODO: Replace the reserved '0' in the field below
with bits for status flags (policy url, notation,
etc.). Remember to make the buffer larger to
match! */
sprintf(bufp, " %s %lu %lu %d 0 %d %d %02X ",
strtimestamp( sig->timestamp ),
(ulong)sig->timestamp,(ulong)sig->expiredate,
sig->version,sig->pubkey_algo,sig->digest_algo,
sig->sig_class);
bufp = bufp + strlen (bufp);
if (!vpk->is_primary) {
u32 akid[2];
akid[0] = vpk->main_keyid[0];
akid[1] = vpk->main_keyid[1];
free_public_key (vpk);
vpk = xmalloc_clear( sizeof *vpk );
if (get_pubkey (vpk, akid)) {
/* impossible error, we simply return a zeroed out fpr */
n = MAX_FINGERPRINT_LEN < 20? MAX_FINGERPRINT_LEN : 20;
memset (array, 0, n);
}
else
fingerprint_from_pk( vpk, array, &n );
}
p = array;
for(i=0; i < n ; i++, p++, bufp += 2)
sprintf(bufp, "%02X", *p );
write_status_text( STATUS_VALIDSIG, buf );
}
free_public_key( vpk );
}
if (!rc)
{
pka_uri_from_sig (sig); /* Make sure PKA info is available. */
rc = check_signatures_trust( sig );
}
if(sig->flags.expired)
{
log_info(_("Signature expired %s\n"),
asctimestamp(sig->expiredate));
rc=G10ERR_GENERAL; /* need a better error here? */
}
else if(sig->expiredate)
log_info(_("Signature expires %s\n"),asctimestamp(sig->expiredate));
if(opt.verbose)
log_info(_("%s signature, digest algorithm %s\n"),
sig->sig_class==0x00?_("binary"):
sig->sig_class==0x01?_("textmode"):_("unknown"),
digest_algo_to_string(sig->digest_algo));
if( rc )
g10_errors_seen = 1;
if( opt.batch && rc )
g10_exit(1);
}
else {
char buf[50];
sprintf(buf, "%08lX%08lX %d %d %02x %lu %d",
(ulong)sig->keyid[0], (ulong)sig->keyid[1],
sig->pubkey_algo, sig->digest_algo,
sig->sig_class, (ulong)sig->timestamp, rc );
write_status_text( STATUS_ERRSIG, buf );
if( rc == G10ERR_NO_PUBKEY ) {
buf[16] = 0;
write_status_text( STATUS_NO_PUBKEY, buf );
}
if( rc != G10ERR_NOT_PROCESSED )
log_error(_("Can't check signature: %s\n"), g10_errstr(rc) );
}
return rc;
}
/****************
* Process the tree which starts at node
*/
static void
proc_tree( CTX c, KBNODE node )
{
KBNODE n1;
int rc;
if( opt.list_packets || opt.list_only )
return;
/* we must skip our special plaintext marker packets here becuase
they may be the root packet. These packets are only used in
addionla checks and skipping them here doesn't matter */
while ( node
&& node->pkt->pkttype == PKT_GPG_CONTROL
&& node->pkt->pkt.gpg_control->control
== CTRLPKT_PLAINTEXT_MARK ) {
node = node->next;
}
if (!node)
return;
c->trustletter = ' ';
if( node->pkt->pkttype == PKT_PUBLIC_KEY
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
merge_keys_and_selfsig( node );
list_node( c, node );
}
else if( node->pkt->pkttype == PKT_SECRET_KEY ) {
merge_keys_and_selfsig( node );
list_node( c, node );
}
else if( node->pkt->pkttype == PKT_ONEPASS_SIG ) {
/* check all signatures */
if( !c->have_data ) {
free_md_filter_context( &c->mfx );
/* prepare to create all requested message digests */
c->mfx.md = md_open(0, 0);
/* fixme: why looking for the signature packet and not 1passpacket*/
for( n1 = node; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )); ) {
md_enable( c->mfx.md, n1->pkt->pkt.signature->digest_algo);
}
/* ask for file and hash it */
if( c->sigs_only ) {
rc = hash_datafiles( c->mfx.md, NULL,
c->signed_data, c->sigfilename,
n1? (n1->pkt->pkt.onepass_sig->sig_class == 0x01):0 );
}
else {
rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2,
iobuf_get_real_fname(c->iobuf),
n1? (n1->pkt->pkt.onepass_sig->sig_class == 0x01):0 );
}
if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc));
return;
}
}
else if ( c->signed_data ) {
log_error (_("not a detached signature\n") );
return;
}
for( n1 = node; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )); )
check_sig_and_print( c, n1 );
}
else if( node->pkt->pkttype == PKT_GPG_CONTROL
&& node->pkt->pkt.gpg_control->control
== CTRLPKT_CLEARSIGN_START ) {
/* clear text signed message */
if( !c->have_data ) {
log_error("cleartext signature without data\n" );
return;
}
else if ( c->signed_data ) {
log_error (_("not a detached signature\n") );
return;
}
for( n1 = node; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )); )
check_sig_and_print( c, n1 );
}
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
PKT_signature *sig = node->pkt->pkt.signature;
int multiple_ok=1;
n1=find_next_kbnode(node, PKT_SIGNATURE);
if(n1)
{
byte class=sig->sig_class;
byte hash=sig->digest_algo;
for(; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE)))
{
/* 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. */
if(n1->pkt->pkt.signature->sig_class!=class
|| n1->pkt->pkt.signature->digest_algo!=hash)
{
multiple_ok=0;
log_info(_("WARNING: multiple signatures detected. "
"Only the first will be checked.\n"));
break;
}
}
}
if( sig->sig_class != 0x00 && sig->sig_class != 0x01 )
log_info(_("standalone signature of class 0x%02x\n"),
sig->sig_class);
else if( !c->have_data ) {
/* detached signature */
free_md_filter_context( &c->mfx );
c->mfx.md = md_open(sig->digest_algo, 0);
if( !opt.pgp2_workarounds )
;
else if( sig->digest_algo == DIGEST_ALGO_MD5
&& is_RSA( sig->pubkey_algo ) ) {
/* enable a workaround for a pgp2 bug */
c->mfx.md2 = md_open( DIGEST_ALGO_MD5, 0 );
}
else if( sig->digest_algo == DIGEST_ALGO_SHA1
&& sig->pubkey_algo == PUBKEY_ALGO_DSA
&& sig->sig_class == 0x01 ) {
/* enable the workaround also for pgp5 when the detached
* signature has been created in textmode */
c->mfx.md2 = md_open( sig->digest_algo, 0 );
}
#if 0 /* workaround disabled */
/* Here we have another hack to work around a pgp 2 bug
* It works by not using the textmode for detached signatures;
* this will let the first signature check (on md) fail
* but the second one (on md2) which adds an extra CR should
* then produce the "correct" hash. This is very, very ugly
* hack but it may help in some cases (and break others)
*/
/* c->mfx.md2? 0 :(sig->sig_class == 0x01) */
#endif
if ( DBG_HASHING ) {
md_start_debug( c->mfx.md, "verify" );
if ( c->mfx.md2 )
md_start_debug( c->mfx.md2, "verify2" );
}
if( c->sigs_only ) {
rc = hash_datafiles( c->mfx.md, c->mfx.md2,
c->signed_data, c->sigfilename,
(sig->sig_class == 0x01) );
}
else {
rc = ask_for_detached_datafile( c->mfx.md, c->mfx.md2,
iobuf_get_real_fname(c->iobuf),
(sig->sig_class == 0x01) );
}
if( rc ) {
log_error("can't hash datafile: %s\n", g10_errstr(rc));
return;
}
}
else if ( c->signed_data ) {
log_error (_("not a detached signature\n") );
return;
}
else if ( c->pipemode.op == 'B' )
; /* this is a detached signature trough the pipemode handler */
else if (!opt.quiet)
log_info(_("old style (PGP 2.x) signature\n"));
if(multiple_ok)
for( n1 = node; n1; (n1 = find_next_kbnode(n1, PKT_SIGNATURE )) )
check_sig_and_print( c, n1 );
else
check_sig_and_print( c, node );
}
else {
dump_kbnode (c->list);
log_error(_("invalid root packet detected in proc_tree()\n"));
dump_kbnode (node);
}
}
diff --git a/g10/misc.c b/g10/misc.c
index 88b7b2bb1..14848eed2 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -1,1211 +1,1225 @@
/* misc.c - miscellaneous functions
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
* 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#if defined(__linux__) && defined(__alpha__) && __GLIBC__ < 2
#include <asm/sysinfo.h>
#include <asm/unistd.h>
#endif
#ifdef HAVE_SETRLIMIT
#include <time.h>
#include <sys/time.h>
#include <sys/resource.h>
#endif
#ifdef ENABLE_SELINUX_HACKS
#include <sys/stat.h>
#endif
#ifdef _WIN32
#include <time.h>
#include <process.h>
#include <windows.h>
#include <shlobj.h>
#ifndef CSIDL_APPDATA
#define CSIDL_APPDATA 0x001a
#endif
#ifndef CSIDL_LOCAL_APPDATA
#define CSIDL_LOCAL_APPDATA 0x001c
#endif
#ifndef CSIDL_FLAG_CREATE
#define CSIDL_FLAG_CREATE 0x8000
#endif
#include "errors.h"
#include "dynload.h"
#endif /*_WIN32*/
#include "util.h"
#include "main.h"
#include "photoid.h"
#include "options.h"
#include "i18n.h"
#include "cardglue.h"
#ifdef ENABLE_SELINUX_HACKS
/* A object and a global variable to keep track of files marked as
secured. */
struct secured_file_item
{
struct secured_file_item *next;
ino_t ino;
dev_t dev;
};
static struct secured_file_item *secured_files;
#endif /*ENABLE_SELINUX_HACKS*/
#if defined(__linux__) && defined(__alpha__) && __GLIBC__ < 2
static int
setsysinfo(unsigned long op, void *buffer, unsigned long size,
int *start, void *arg, unsigned long flag)
{
return syscall(__NR_osf_setsysinfo, op, buffer, size, start, arg, flag);
}
void
trap_unaligned(void)
{
unsigned int buf[2];
buf[0] = SSIN_UACPROC;
buf[1] = UAC_SIGBUS | UAC_NOPRINT;
setsysinfo(SSI_NVPAIRS, buf, 1, 0, 0, 0);
}
#else
void
trap_unaligned(void)
{ /* dummy */
}
#endif
int
disable_core_dumps()
{
#ifdef HAVE_DOSISH_SYSTEM
return 0;
#else
#ifdef HAVE_SETRLIMIT
struct rlimit limit;
limit.rlim_cur = 0;
limit.rlim_max = 0;
if( !setrlimit( RLIMIT_CORE, &limit ) )
return 0;
if( errno != EINVAL && errno != ENOSYS )
log_fatal(_("can't disable core dumps: %s\n"), strerror(errno) );
#endif
return 1;
#endif
}
/* For the sake of SELinux we want to restrict access through gpg to
certain files we keep under our own control. This function
registers such a file and is_secured_file may then be used to
check whether a file has ben registered as secured. */
void
register_secured_file (const char *fname)
{
#ifdef ENABLE_SELINUX_HACKS
struct stat buf;
struct secured_file_item *sf;
/* Note that we stop immediatley if something goes wrong here. */
if (stat (fname, &buf))
log_fatal (_("fstat of `%s' failed in %s: %s\n"), fname,
"register_secured_file", strerror (errno));
/* log_debug ("registering `%s' i=%lu.%lu\n", fname, */
/* (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
for (sf=secured_files; sf; sf = sf->next)
{
if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
return; /* Already registered. */
}
sf = xmalloc (sizeof *sf);
sf->ino = buf.st_ino;
sf->dev = buf.st_dev;
sf->next = secured_files;
secured_files = sf;
#endif /*ENABLE_SELINUX_HACKS*/
}
/* Remove a file registerd as secure. */
void
unregister_secured_file (const char *fname)
{
#ifdef ENABLE_SELINUX_HACKS
struct stat buf;
struct secured_file_item *sf, *sfprev;
if (stat (fname, &buf))
{
log_error (_("fstat of `%s' failed in %s: %s\n"), fname,
"unregister_secured_file", strerror (errno));
return;
}
/* log_debug ("unregistering `%s' i=%lu.%lu\n", fname, */
/* (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
for (sfprev=NULL,sf=secured_files; sf; sfprev=sf, sf = sf->next)
{
if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
{
if (sfprev)
sfprev->next = sf->next;
else
secured_files = sf->next;
xfree (sf);
return;
}
}
#endif /*ENABLE_SELINUX_HACKS*/
}
/* Return true if FD is corresponds to a secured file. Using -1 for
FS is allowed and will return false. */
int
is_secured_file (int fd)
{
#ifdef ENABLE_SELINUX_HACKS
struct stat buf;
struct secured_file_item *sf;
if (fd == -1)
return 0; /* No file descriptor so it can't be secured either. */
/* Note that we print out a error here and claim that a file is
secure if something went wrong. */
if (fstat (fd, &buf))
{
log_error (_("fstat(%d) failed in %s: %s\n"), fd,
"is_secured_file", strerror (errno));
return 1;
}
/* log_debug ("is_secured_file (%d) i=%lu.%lu\n", fd, */
/* (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
for (sf=secured_files; sf; sf = sf->next)
{
if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
return 1; /* Yes. */
}
#endif /*ENABLE_SELINUX_HACKS*/
return 0; /* No. */
}
/* Return true if FNAME is corresponds to a secured file. Using NULL,
"" or "-" for FS is allowed and will return false. This function is
used before creating a file, thus it won't fail if the file does
not exist. */
int
is_secured_filename (const char *fname)
{
#ifdef ENABLE_SELINUX_HACKS
struct stat buf;
struct secured_file_item *sf;
if (iobuf_is_pipe_filename (fname) || !*fname)
return 0;
/* Note that we print out a error here and claim that a file is
secure if something went wrong. */
if (stat (fname, &buf))
{
if (errno == ENOENT || errno == EPERM || errno == EACCES)
return 0;
log_error (_("fstat of `%s' failed in %s: %s\n"), fname,
"is_secured_filename", strerror (errno));
return 1;
}
/* log_debug ("is_secured_filename (%s) i=%lu.%lu\n", fname, */
/* (unsigned long)buf.st_dev, (unsigned long)buf.st_ino); */
for (sf=secured_files; sf; sf = sf->next)
{
if (sf->ino == buf.st_ino && sf->dev == buf.st_dev)
return 1; /* Yes. */
}
#endif /*ENABLE_SELINUX_HACKS*/
return 0; /* No. */
}
u16
checksum_u16( unsigned n )
{
u16 a;
a = (n >> 8) & 0xff;
a += n & 0xff;
return a;
}
u16
checksum( byte *p, unsigned n )
{
u16 a;
for(a=0; n; n-- )
a += *p++;
return a;
}
u16
checksum_mpi( MPI a )
{
u16 csum;
byte *buffer;
unsigned nbytes;
unsigned nbits;
buffer = mpi_get_buffer( a, &nbytes, NULL );
nbits = mpi_get_nbits(a);
csum = checksum_u16( nbits );
csum += checksum( buffer, nbytes );
xfree( buffer );
return csum;
}
u32
buffer_to_u32( const byte *buffer )
{
unsigned long a;
a = *buffer << 24;
a |= buffer[1] << 16;
a |= buffer[2] << 8;
a |= buffer[3];
return a;
}
void
print_pubkey_algo_note( int algo )
{
if(algo >= 100 && algo <= 110)
{
static int warn=0;
if(!warn)
{
warn=1;
log_info(_("WARNING: using experimental public key algorithm %s\n"),
pubkey_algo_to_string(algo));
}
}
}
void
print_cipher_algo_note( int algo )
{
if(algo >= 100 && algo <= 110)
{
static int warn=0;
if(!warn)
{
warn=1;
log_info(_("WARNING: using experimental cipher algorithm %s\n"),
cipher_algo_to_string(algo));
}
}
}
void
print_digest_algo_note( int algo )
{
if(algo >= 100 && algo <= 110)
{
static int warn=0;
if(!warn)
{
warn=1;
log_info(_("WARNING: using experimental digest algorithm %s\n"),
digest_algo_to_string(algo));
}
}
else if(algo==DIGEST_ALGO_MD5)
log_info(_("WARNING: digest algorithm %s is deprecated\n"),
digest_algo_to_string(algo));
}
/* Return a string which is used as a kind of process ID */
const byte *
get_session_marker( size_t *rlen )
{
static byte marker[SIZEOF_UNSIGNED_LONG*2];
static int initialized;
if ( !initialized ) {
volatile ulong aa, bb; /* we really want the uninitialized value */
ulong a, b;
initialized = 1;
/* also this marker is guessable it is not easy to use this
* for a faked control packet because an attacker does not
* have enough control about the time the verification does
* take place. Of course, we can add just more random but
* than we need the random generator even for verification
* tasks - which does not make sense. */
a = aa ^ (ulong)getpid();
b = bb ^ (ulong)time(NULL);
memcpy( marker, &a, SIZEOF_UNSIGNED_LONG );
memcpy( marker+SIZEOF_UNSIGNED_LONG, &b, SIZEOF_UNSIGNED_LONG );
}
*rlen = sizeof(marker);
return marker;
}
/****************
* Wrapper around the libgcrypt function with addional checks on
* openPGP contraints for the algo ID.
*/
int
openpgp_cipher_test_algo( int algo )
{
if( algo < 0 || algo > 110 )
return G10ERR_CIPHER_ALGO;
return check_cipher_algo(algo);
}
int
openpgp_pk_test_algo( int algo, unsigned int usage_flags )
{
if( algo < 0 || algo > 110 )
return G10ERR_PUBKEY_ALGO;
return check_pubkey_algo2( algo, usage_flags );
}
int
openpgp_pk_algo_usage ( int algo )
{
int use = 0;
/* they are hardwired in gpg 1.0 */
switch ( algo ) {
case PUBKEY_ALGO_RSA:
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC | PUBKEY_USAGE_AUTH;
break;
case PUBKEY_ALGO_RSA_E:
use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_RSA_S:
use = PUBKEY_USAGE_SIG;
break;
case PUBKEY_ALGO_ELGAMAL_E:
use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_DSA:
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_AUTH;
break;
default:
break;
}
return use;
}
int
openpgp_md_test_algo( int algo )
{
if( algo < 0 || algo > 110 )
return G10ERR_DIGEST_ALGO;
return check_digest_algo(algo);
}
#ifdef USE_IDEA
/* Special warning for the IDEA cipher */
void
idea_cipher_warn(int show)
{
static int warned=0;
if(!warned || show)
{
log_info(_("the IDEA cipher plugin is not present\n"));
log_info(_("please see http://www.gnupg.org/why-not-idea.html "
"for more information\n"));
warned=1;
}
}
#endif
static unsigned long get_signature_count(PKT_secret_key *sk)
{
#ifdef ENABLE_CARD_SUPPORT
if(sk && sk->is_protected && sk->protect.s2k.mode==1002)
{
struct agent_card_info_s info;
if(agent_scd_getattr("SIG-COUNTER",&info)==0)
return info.sig_counter;
}
#endif
/* How to do this without a card? */
return 0;
}
/* Expand %-strings. Returns a string which must be xfreed. Returns
NULL if the string cannot be expanded (too large). */
char *
pct_expando(const char *string,struct expando_args *args)
{
const char *ch=string;
int idx=0,maxlen=0,done=0;
u32 pk_keyid[2]={0,0},sk_keyid[2]={0,0};
char *ret=NULL;
if(args->pk)
keyid_from_pk(args->pk,pk_keyid);
if(args->sk)
keyid_from_sk(args->sk,sk_keyid);
/* This is used so that %k works in photoid command strings in
--list-secret-keys (which of course has a sk, but no pk). */
if(!args->pk && args->sk)
keyid_from_sk(args->sk,pk_keyid);
while(*ch!='\0')
{
char *str=NULL;
if(!done)
{
/* 8192 is way bigger than we'll need here */
if(maxlen>=8192)
goto fail;
maxlen+=1024;
ret=xrealloc(ret,maxlen);
}
done=0;
if(*ch=='%')
{
switch(*(ch+1))
{
case 's': /* short key id */
if(idx+8<maxlen)
{
sprintf(&ret[idx],"%08lX",(ulong)sk_keyid[1]);
idx+=8;
done=1;
}
break;
case 'S': /* long key id */
if(idx+16<maxlen)
{
sprintf(&ret[idx],"%08lX%08lX",
(ulong)sk_keyid[0],(ulong)sk_keyid[1]);
idx+=16;
done=1;
}
break;
case 'k': /* short key id */
if(idx+8<maxlen)
{
sprintf(&ret[idx],"%08lX",(ulong)pk_keyid[1]);
idx+=8;
done=1;
}
break;
case 'K': /* long key id */
if(idx+16<maxlen)
{
sprintf(&ret[idx],"%08lX%08lX",
(ulong)pk_keyid[0],(ulong)pk_keyid[1]);
idx+=16;
done=1;
}
break;
case 'c': /* signature count from card, if any. */
if(idx+10<maxlen)
{
sprintf(&ret[idx],"%lu",get_signature_count(args->sk));
idx+=strlen(&ret[idx]);
done=1;
}
break;
case 'p': /* primary pk fingerprint of a sk */
case 'f': /* pk fingerprint */
case 'g': /* sk fingerprint */
{
byte array[MAX_FINGERPRINT_LEN];
size_t len;
int i;
if((*(ch+1))=='p' && args->sk)
{
if(args->sk->is_primary)
fingerprint_from_sk(args->sk,array,&len);
else if(args->sk->main_keyid[0] || args->sk->main_keyid[1])
{
PKT_public_key *pk=
xmalloc_clear(sizeof(PKT_public_key));
if(get_pubkey_fast(pk,args->sk->main_keyid)==0)
fingerprint_from_pk(pk,array,&len);
else
memset(array,0,(len=MAX_FINGERPRINT_LEN));
free_public_key(pk);
}
else
memset(array,0,(len=MAX_FINGERPRINT_LEN));
}
else if((*(ch+1))=='f' && args->pk)
fingerprint_from_pk(args->pk,array,&len);
else if((*(ch+1))=='g' && args->sk)
fingerprint_from_sk(args->sk,array,&len);
else
memset(array,0,(len=MAX_FINGERPRINT_LEN));
if(idx+(len*2)<maxlen)
{
for(i=0;i<len;i++)
{
sprintf(&ret[idx],"%02X",array[i]);
idx+=2;
}
done=1;
}
}
break;
case 't': /* e.g. "jpg" */
str=image_type_to_string(args->imagetype,0);
/* fall through */
case 'T': /* e.g. "image/jpeg" */
if(str==NULL)
str=image_type_to_string(args->imagetype,2);
if(idx+strlen(str)<maxlen)
{
strcpy(&ret[idx],str);
idx+=strlen(str);
done=1;
}
break;
case '%':
if(idx+1<maxlen)
{
ret[idx++]='%';
ret[idx]='\0';
done=1;
}
break;
/* Any unknown %-keys (like %i, %o, %I, and %O) are
passed through for later expansion. Note this also
handles the case where the last character in the
string is a '%' - the terminating \0 will end up here
and properly terminate the string. */
default:
if(idx+2<maxlen)
{
ret[idx++]='%';
ret[idx++]=*(ch+1);
ret[idx]='\0';
done=1;
}
break;
}
if(done)
ch++;
}
else
{
if(idx+1<maxlen)
{
ret[idx++]=*ch;
ret[idx]='\0';
done=1;
}
}
if(done)
ch++;
}
return ret;
fail:
xfree(ret);
return NULL;
}
void
deprecated_warning(const char *configname,unsigned int configlineno,
const char *option,const char *repl1,const char *repl2)
{
if(configname)
{
if(strncmp("--",option,2)==0)
option+=2;
if(strncmp("--",repl1,2)==0)
repl1+=2;
log_info(_("%s:%d: deprecated option \"%s\"\n"),
configname,configlineno,option);
}
else
log_info(_("WARNING: \"%s\" is a deprecated option\n"),option);
log_info(_("please use \"%s%s\" instead\n"),repl1,repl2);
}
void
deprecated_command (const char *name)
{
log_info(_("WARNING: \"%s\" is a deprecated command - do not use it\n"),
name);
}
const char *
compress_algo_to_string(int algo)
{
const char *s=NULL;
switch(algo)
{
case COMPRESS_ALGO_NONE:
s=_("Uncompressed");
break;
case COMPRESS_ALGO_ZIP:
s="ZIP";
break;
case COMPRESS_ALGO_ZLIB:
s="ZLIB";
break;
#ifdef HAVE_BZIP2
case COMPRESS_ALGO_BZIP2:
s="BZIP2";
break;
#endif
}
return s;
}
int
string_to_compress_algo(const char *string)
{
/* NOTE TO TRANSLATOR: See doc/TRANSLATE about this string. */
if(match_multistr(_("uncompressed|none"),string))
return 0;
else if(ascii_strcasecmp(string,"uncompressed")==0)
return 0;
else if(ascii_strcasecmp(string,"none")==0)
return 0;
else if(ascii_strcasecmp(string,"zip")==0)
return 1;
else if(ascii_strcasecmp(string,"zlib")==0)
return 2;
#ifdef HAVE_BZIP2
else if(ascii_strcasecmp(string,"bzip2")==0)
return 3;
#endif
else if(ascii_strcasecmp(string,"z0")==0)
return 0;
else if(ascii_strcasecmp(string,"z1")==0)
return 1;
else if(ascii_strcasecmp(string,"z2")==0)
return 2;
#ifdef HAVE_BZIP2
else if(ascii_strcasecmp(string,"z3")==0)
return 3;
#endif
else
return -1;
}
int
check_compress_algo(int algo)
{
#ifdef HAVE_BZIP2
if(algo>=0 && algo<=3)
return 0;
#else
if(algo>=0 && algo<=2)
return 0;
#endif
return G10ERR_COMPR_ALGO;
}
int
default_cipher_algo(void)
{
if(opt.def_cipher_algo)
return opt.def_cipher_algo;
else if(opt.personal_cipher_prefs)
return opt.personal_cipher_prefs[0].value;
else
return opt.s2k_cipher_algo;
}
/* There is no default_digest_algo function, but see
sign.c:hash_for() */
int
default_compress_algo(void)
{
if(opt.compress_algo!=-1)
return opt.compress_algo;
else if(opt.personal_compress_prefs)
return opt.personal_compress_prefs[0].value;
else
return DEFAULT_COMPRESS_ALGO;
}
const char *
compliance_option_string(void)
{
switch(opt.compliance)
{
case CO_RFC2440:
return "--openpgp";
case CO_PGP2:
return "--pgp2";
case CO_PGP6:
return "--pgp6";
case CO_PGP7:
return "--pgp7";
case CO_PGP8:
return "--pgp8";
default:
return "???";
}
}
static const char *
compliance_string(void)
{
switch(opt.compliance)
{
case CO_RFC2440:
return "OpenPGP";
case CO_PGP2:
return "PGP 2.x";
case CO_PGP6:
return "PGP 6.x";
case CO_PGP7:
return "PGP 7.x";
case CO_PGP8:
return "PGP 8.x";
default:
return "???";
}
}
void
compliance_failure(void)
{
log_info(_("this message may not be usable by %s\n"),compliance_string());
opt.compliance=CO_GNUPG;
}
/* Break a string into successive option pieces. Accepts single word
options and key=value argument options. */
char *
optsep(char **stringp)
{
char *tok,*end;
tok=*stringp;
if(tok)
{
end=strpbrk(tok," ,=");
if(end)
{
int sawequals=0;
char *ptr=end;
/* what we need to do now is scan along starting with *end,
If the next character we see (ignoring spaces) is an =
sign, then there is an argument. */
while(*ptr)
{
if(*ptr=='=')
sawequals=1;
else if(*ptr!=' ')
break;
ptr++;
}
/* There is an argument, so grab that too. At this point,
ptr points to the first character of the argument. */
if(sawequals)
{
/* Is it a quoted argument? */
if(*ptr=='"')
{
ptr++;
end=strchr(ptr,'"');
if(end)
end++;
}
else
end=strpbrk(ptr," ,");
}
if(end && *end)
{
*end='\0';
*stringp=end+1;
}
else
*stringp=NULL;
}
else
*stringp=NULL;
}
return tok;
}
/* Breaks an option value into key and value. Returns NULL if there
is no value. Note that "string" is modified to remove the =value
part. */
char *
argsplit(char *string)
{
char *equals,*arg=NULL;
equals=strchr(string,'=');
if(equals)
{
char *quote,*space;
*equals='\0';
arg=equals+1;
/* Quoted arg? */
quote=strchr(arg,'"');
if(quote)
{
arg=quote+1;
quote=strchr(arg,'"');
if(quote)
*quote='\0';
}
else
{
size_t spaces;
/* Trim leading spaces off of the arg */
spaces=strspn(arg," ");
arg+=spaces;
}
/* Trim tailing spaces off of the tag */
space=strchr(string,' ');
if(space)
*space='\0';
}
return arg;
}
/* Return the length of the initial token, leaving off any
argument. */
static size_t
optlen(const char *s)
{
char *end=strpbrk(s," =");
if(end)
return end-s;
else
return strlen(s);
}
int
parse_options(char *str,unsigned int *options,
struct parse_options *opts,int noisy)
{
char *tok;
while((tok=optsep(&str)))
{
int i,rev=0;
char *otok=tok;
if(tok[0]=='\0')
continue;
if(ascii_strncasecmp("no-",tok,3)==0)
{
rev=1;
tok+=3;
}
for(i=0;opts[i].name;i++)
{
size_t toklen=optlen(tok);
if(ascii_strncasecmp(opts[i].name,tok,toklen)==0)
{
/* We have a match, but it might be incomplete */
if(toklen!=strlen(opts[i].name))
{
int j;
for(j=i+1;opts[j].name;j++)
{
if(ascii_strncasecmp(opts[j].name,tok,toklen)==0)
{
if(noisy)
log_info(_("ambiguous option `%s'\n"),otok);
return 0;
}
}
}
if(rev)
{
*options&=~opts[i].bit;
if(opts[i].value)
*opts[i].value=NULL;
}
else
{
*options|=opts[i].bit;
if(opts[i].value)
*opts[i].value=argsplit(tok);
}
break;
}
}
if(!opts[i].name)
{
if(noisy)
log_info(_("unknown option `%s'\n"),otok);
return 0;
}
}
return 1;
}
/* Return a new malloced string by unescaping the string S. Escaping
is percent escaping and '+'/space mapping. A binary nul will
silently be replaced by a 0xFF. */
char *
unescape_percent_string (const unsigned char *s)
{
char *buffer, *d;
buffer = d = xmalloc (strlen (s)+1);
while (*s)
{
if (*s == '%' && s[1] && s[2])
{
s++;
*d = xtoi_2 (s);
if (!*d)
*d = '\xff';
d++;
s += 2;
}
else if (*s == '+')
{
*d++ = ' ';
s++;
}
else
*d++ = *s++;
}
*d = 0;
return buffer;
}
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;
}
+/* Check whether NAME represents a valid mailbox according to
+ RFC822. Returns true if so. */
+int
+is_valid_mailbox (const char *name)
+{
+ return !( !name
+ || !*name
+ || has_invalid_email_chars (name)
+ || string_count_chr (name,'@') != 1
+ || *name == '@'
+ || name[strlen(name)-1] == '@'
+ || name[strlen(name)-1] == '.'
+ || strstr (name, "..") );
+}
/* This is a helper function to load a Windows function from either of
one DLLs. */
#ifdef HAVE_W32_SYSTEM
static HRESULT
w32_shgetfolderpath (HWND a, int b, HANDLE c, DWORD d, LPSTR e)
{
static int initialized;
static HRESULT (WINAPI * func)(HWND,int,HANDLE,DWORD,LPSTR);
if (!initialized)
{
static char *dllnames[] = { "shell32.dll", "shfolder.dll", NULL };
void *handle;
int i;
initialized = 1;
for (i=0, handle = NULL; !handle && dllnames[i]; i++)
{
handle = dlopen (dllnames[i], RTLD_LAZY);
if (handle)
{
func = dlsym (handle, "SHGetFolderPathA");
if (!func)
{
dlclose (handle);
handle = NULL;
}
}
}
}
if (func)
return func (a,b,c,d,e);
else
return -1;
}
#endif /*HAVE_W32_SYSTEM*/
/* Set up the default home directory. The usual --homedir option
should be parsed later. */
char *
default_homedir (void)
{
char *dir;
dir = getenv("GNUPGHOME");
#ifdef HAVE_W32_SYSTEM
if (!dir || !*dir)
dir = read_w32_registry_string (NULL, "Software\\GNU\\GnuPG", "HomeDir");
if (!dir || !*dir)
{
char path[MAX_PATH];
/* It might be better to use LOCAL_APPDATA because this is
defined as "non roaming" and thus more likely to be kept
locally. For private keys this is desired. However, given
that many users copy private keys anyway forth and back,
using a system roaming serives might be better than to let
them do it manually. A security conscious user will anyway
use the registry entry to have better control. */
if (w32_shgetfolderpath (NULL, CSIDL_APPDATA|CSIDL_FLAG_CREATE,
NULL, 0, path) >= 0)
{
char *tmp = xmalloc (strlen (path) + 6 +1);
strcpy (stpcpy (tmp, path), "\\gnupg");
dir = tmp;
/* Try to create the directory if it does not yet
exists. */
if (access (dir, F_OK))
CreateDirectory (dir, NULL);
}
}
#endif /*HAVE_W32_SYSTEM*/
if (!dir || !*dir)
dir = GNUPG_HOMEDIR;
return dir;
}
/* Return the name of the libexec directory. The name is allocated in
a static area on the first use. This function won't fail. */
const char *
get_libexecdir (void)
{
#ifdef HAVE_W32_SYSTEM
static int got_dir;
static char dir[MAX_PATH+5];
if (!got_dir)
{
char *p;
if ( !GetModuleFileName ( NULL, dir, MAX_PATH) )
{
log_debug ("GetModuleFileName failed: %s\n", w32_strerror (0));
*dir = 0;
}
got_dir = 1;
p = strrchr (dir, DIRSEP_C);
if (p)
*p = 0;
else
{
log_debug ("bad filename `%s' returned for this process\n", dir);
*dir = 0;
}
}
if (*dir)
return dir;
/* Fallback to the hardwired value. */
#endif /*HAVE_W32_SYSTEM*/
return GNUPG_LIBEXECDIR;
}
diff --git a/g10/options.h b/g10/options.h
index c278b5d29..866e713d3 100644
--- a/g10/options.h
+++ b/g10/options.h
@@ -1,303 +1,304 @@
/* options.h
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004,
* 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
*/
#ifndef G10_OPTIONS_H
#define G10_OPTIONS_H
#include <sys/types.h>
#include <types.h>
#include "main.h"
#include "packet.h"
#ifndef EXTERN_UNLESS_MAIN_MODULE
/* Norcraft can't cope with common symbols */
#if defined (__riscos__) && !defined (INCLUDED_BY_MAIN_MODULE)
#define EXTERN_UNLESS_MAIN_MODULE extern
#else
#define EXTERN_UNLESS_MAIN_MODULE
#endif
#endif
EXTERN_UNLESS_MAIN_MODULE
struct
{
int verbose;
int quiet;
unsigned debug;
int armor;
char *outfile;
off_t max_output;
int dry_run;
int list_only;
int textmode;
int expert;
const char *def_sig_expire;
int ask_sig_expire;
const char *def_cert_expire;
int ask_cert_expire;
int batch; /* run in batch mode */
int answer_yes; /* answer yes on most questions */
int answer_no; /* answer no on most questions */
int check_sigs; /* check key signatures */
int with_colons;
int with_key_data;
int with_fingerprint; /* opt --with-fingerprint active */
int fingerprint; /* list fingerprints */
int list_sigs; /* list signatures */
int no_armor;
int list_packets; /* list-packets mode: 1=normal, 2=invoked by command*/
int def_cipher_algo;
int force_v3_sigs;
int force_v4_certs;
int force_mdc;
int disable_mdc;
int def_digest_algo;
int cert_digest_algo;
int compress_algo;
int compress_level;
int bz2_compress_level;
int bz2_decompress_lowmem;
const char *def_secret_key;
char *def_recipient;
int def_recipient_self;
int def_cert_level;
int min_cert_level;
int ask_cert_level;
int no_version;
int marginals_needed;
int completes_needed;
int max_cert_depth;
const char *homedir;
char *display; /* 5 options to be passed to the gpg-agent */
char *ttyname;
char *ttytype;
char *lc_ctype;
char *lc_messages;
int skip_verify;
int compress_keys;
int compress_sigs;
/* TM_CLASSIC must be zero to accomodate trustdbs generated before
we started storing the trust model inside the trustdb. */
enum
{
TM_CLASSIC=0, TM_PGP=1, TM_EXTERNAL=2, TM_ALWAYS, TM_DIRECT, TM_AUTO
} trust_model;
int force_ownertrust;
enum
{
CO_GNUPG=0, CO_RFC2440, CO_RFC1991, CO_PGP2, CO_PGP6, CO_PGP7, CO_PGP8
} compliance;
enum
{
KF_SHORT, KF_LONG, KF_0xSHORT, KF_0xLONG
} keyid_format;
int pgp2_workarounds;
int shm_coprocess;
const char *set_filename;
STRLIST comments;
int throw_keyid;
const char *photo_viewer;
int s2k_mode;
int s2k_digest_algo;
int s2k_cipher_algo;
int simple_sk_checksum; /* create the deprecated rfc2440 secret
key protection*/
int not_dash_escaped;
int escape_from;
int lock_once;
struct keyserver_spec
{
char *uri;
char *scheme;
char *auth;
char *host;
char *port;
char *path;
char *opaque;
} *keyserver;
struct
{
unsigned int options;
unsigned int import_options;
unsigned int export_options;
STRLIST other;
} keyserver_options;
int exec_disable;
int exec_path_set;
unsigned int import_options;
unsigned int export_options;
unsigned int list_options;
unsigned int verify_options;
char *def_preference_list;
prefitem_t *personal_cipher_prefs;
prefitem_t *personal_digest_prefs;
prefitem_t *personal_compress_prefs;
int no_perm_warn;
int no_mdc_warn;
char *temp_dir;
int no_encrypt_to;
int interactive;
STRLIST sig_notation_data;
STRLIST cert_notation_data;
STRLIST sig_policy_url;
STRLIST cert_policy_url;
STRLIST sig_keyserver_url;
int use_embedded_filename;
int allow_non_selfsigned_uid;
int allow_freeform_uid;
int no_literal;
ulong set_filesize;
int fast_list_mode;
int fixed_list_mode;
int ignore_time_conflict;
int ignore_valid_from;
int ignore_crc_error;
int ignore_mdc_error;
int command_fd;
const char *override_session_key;
int show_session_key;
int use_agent;
const char *gpg_agent_info;
int try_all_secrets;
int no_expensive_trust_checks;
int no_sig_cache;
int no_sig_create_check;
int no_auto_check_trustdb;
int preserve_permissions;
int no_homedir_creation;
struct groupitem *grouplist;
int strict;
int mangle_dos_filenames;
int enable_progress_filter;
unsigned int screen_columns;
unsigned int screen_lines;
byte *show_subpackets;
int rfc2440_text;
/* If true, let write failures on the status-fd exit the process. */
int exit_on_status_write_error;
/* If > 0, limit the number of card insertion prompts to this
value. */
int limit_card_insert_tries;
#ifdef ENABLE_CARD_SUPPORT
const char *ctapi_driver; /* Library to access the ctAPI. */
const char *pcsc_driver; /* Library to access the PC/SC system. */
int disable_ccid; /* Disable the use of the internal CCID driver. */
#endif /*ENABLE_CARD_SUPPORT*/
} opt;
/* CTRL is used to keep some global variables we currently can't
avoid. Future concurrent versions of gpg will put it into a per
request structure CTRL. */
EXTERN_UNLESS_MAIN_MODULE
struct {
int in_auto_key_retrieve; /* True if we are doing an
auto_key_retrieve. */
} glo_ctrl;
#define DBG_PACKET_VALUE 1 /* debug packet reading/writing */
#define DBG_MPI_VALUE 2 /* debug mpi details */
#define DBG_CIPHER_VALUE 4 /* debug cipher handling */
/* (may reveal sensitive data) */
#define DBG_FILTER_VALUE 8 /* debug internal filter handling */
#define DBG_IOBUF_VALUE 16 /* debug iobuf stuff */
#define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
#define DBG_CACHE_VALUE 64 /* debug the cacheing */
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
#define DBG_TRUST_VALUE 256 /* debug the trustdb */
#define DBG_HASHING_VALUE 512 /* debug hashing operations */
#define DBG_EXTPROG_VALUE 1024 /* debug external program calls */
#define DBG_CARD_IO_VALUE 2048 /* debug smart card I/O. */
#define DBG_PACKET (opt.debug & DBG_PACKET_VALUE)
#define DBG_FILTER (opt.debug & DBG_FILTER_VALUE)
#define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
#define DBG_TRUST (opt.debug & DBG_TRUST_VALUE)
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
#define DBG_EXTPROG (opt.debug & DBG_EXTPROG_VALUE)
#define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
#define GNUPG (opt.compliance==CO_GNUPG)
#define RFC1991 (opt.compliance==CO_RFC1991 || opt.compliance==CO_PGP2)
#define RFC2440 (opt.compliance==CO_RFC2440)
#define PGP2 (opt.compliance==CO_PGP2)
#define PGP6 (opt.compliance==CO_PGP6)
#define PGP7 (opt.compliance==CO_PGP7)
#define PGP8 (opt.compliance==CO_PGP8)
/* Various option flags. Note that there should be no common string
names between the IMPORT_ and EXPORT_ flags as they can be mixed in
the keyserver-options option. */
#define IMPORT_LOCAL_SIGS (1<<0)
#define IMPORT_REPAIR_PKS_SUBKEY_BUG (1<<1)
#define IMPORT_FAST (1<<2)
#define IMPORT_SK2PK (1<<3)
#define IMPORT_MERGE_ONLY (1<<4)
#define IMPORT_CLEAN_SIGS (1<<5)
#define IMPORT_CLEAN_UIDS (1<<6)
#define EXPORT_LOCAL_SIGS (1<<0)
#define EXPORT_ATTRIBUTES (1<<1)
#define EXPORT_SENSITIVE_REVKEYS (1<<2)
#define EXPORT_MINIMAL (1<<3)
#define EXPORT_CLEAN_SIGS (1<<4)
#define EXPORT_CLEAN_UIDS (1<<5)
#define EXPORT_RESET_SUBKEY_PASSWD (1<<6)
#define LIST_SHOW_PHOTOS (1<<0)
#define LIST_SHOW_POLICY_URLS (1<<1)
#define LIST_SHOW_STD_NOTATIONS (1<<2)
#define LIST_SHOW_USER_NOTATIONS (1<<3)
#define LIST_SHOW_NOTATIONS (LIST_SHOW_STD_NOTATIONS|LIST_SHOW_USER_NOTATIONS)
#define LIST_SHOW_KEYSERVER_URLS (1<<4)
#define LIST_SHOW_UID_VALIDITY (1<<5)
#define LIST_SHOW_UNUSABLE_UIDS (1<<6)
#define LIST_SHOW_UNUSABLE_SUBKEYS (1<<7)
#define LIST_SHOW_KEYRING (1<<8)
#define LIST_SHOW_SIG_EXPIRE (1<<9)
#define LIST_SHOW_SIG_SUBPACKETS (1<<10)
#define VERIFY_SHOW_PHOTOS (1<<0)
#define VERIFY_SHOW_POLICY_URLS (1<<1)
#define VERIFY_SHOW_STD_NOTATIONS (1<<2)
#define VERIFY_SHOW_USER_NOTATIONS (1<<3)
#define VERIFY_SHOW_NOTATIONS (VERIFY_SHOW_STD_NOTATIONS|VERIFY_SHOW_USER_NOTATIONS)
#define VERIFY_SHOW_KEYSERVER_URLS (1<<4)
#define VERIFY_SHOW_UID_VALIDITY (1<<5)
#define VERIFY_SHOW_UNUSABLE_UIDS (1<<6)
#define KEYSERVER_INCLUDE_REVOKED (1<<0)
#define KEYSERVER_INCLUDE_SUBKEYS (1<<1)
#define KEYSERVER_USE_TEMP_FILES (1<<2)
#define KEYSERVER_KEEP_TEMP_FILES (1<<3)
#define KEYSERVER_ADD_FAKE_V3 (1<<4)
#define KEYSERVER_AUTO_KEY_RETRIEVE (1<<5)
#define KEYSERVER_TRY_DNS_SRV (1<<6)
#define KEYSERVER_HONOR_KEYSERVER_URL (1<<7)
+#define KEYSERVER_AUTO_PKA_RETRIEVE (1<<8)
#endif /*G10_OPTIONS_H*/
diff --git a/g10/pkclist.c b/g10/pkclist.c
index 271aba3ba..a2d34ad50 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -1,1334 +1,1431 @@
/* pkclist.c
* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003,
- * 2004 Free Software Foundation, Inc.
+ * 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* 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 "keydb.h"
#include "memory.h"
#include "util.h"
#include "main.h"
#include "trustdb.h"
#include "ttyio.h"
#include "status.h"
#include "photoid.h"
#include "i18n.h"
#define CONTROL_D ('D' - 'A' + 1)
/****************
* Show the revocation reason as it is stored with the given signature
*/
static void
do_show_revocation_reason( PKT_signature *sig )
{
size_t n, nn;
const byte *p, *pp;
int seq = 0;
const char *text;
while( (p = enum_sig_subpkt (sig->hashed, SIGSUBPKT_REVOC_REASON,
&n, &seq, NULL )) ) {
if( !n )
continue; /* invalid - just skip it */
if( *p == 0 )
text = _("No reason specified");
else if( *p == 0x01 )
text = _("Key is superseded");
else if( *p == 0x02 )
text = _("Key has been compromised");
else if( *p == 0x03 )
text = _("Key is no longer used");
else if( *p == 0x20 )
text = _("User ID is no longer valid");
else
text = NULL;
log_info( _("reason for revocation: ") );
if( text )
fputs( text, log_stream() );
else
fprintf( log_stream(), "code=%02x", *p );
putc( '\n', log_stream() );
n--; p++;
pp = NULL;
do {
/* We don't want any empty lines, so skip them */
while( n && *p == '\n' ) {
p++;
n--;
}
if( n ) {
pp = memchr( p, '\n', n );
nn = pp? pp - p : n;
log_info( _("revocation comment: ") );
print_string( log_stream(), p, nn, 0 );
putc( '\n', log_stream() );
p += nn; n -= nn;
}
} while( pp );
}
}
/* Mode 0: try and find the revocation based on the pk (i.e. check
subkeys, etc.) Mode 1: use only the revocation on the main pk */
void
show_revocation_reason( PKT_public_key *pk, int mode )
{
/* Hmmm, this is not so easy becuase we have to duplicate the code
* used in the trustbd to calculate the keyflags. We need to find
* a clean way to check revocation certificates on keys and
* signatures. And there should be no duplicate code. Because we
* enter this function only when the trustdb told us that we have
* a revoked key, we could simply look for a revocation cert and
* display this one, when there is only one. Let's try to do this
* until we have a better solution. */
KBNODE node, keyblock = NULL;
byte fingerprint[MAX_FINGERPRINT_LEN];
size_t fingerlen;
int rc;
/* get the keyblock */
fingerprint_from_pk( pk, fingerprint, &fingerlen );
rc = get_keyblock_byfprint( &keyblock, fingerprint, fingerlen );
if( rc ) { /* that should never happen */
log_debug( "failed to get the keyblock\n");
return;
}
for( node=keyblock; node; node = node->next ) {
if( (mode && node->pkt->pkttype == PKT_PUBLIC_KEY) ||
( ( node->pkt->pkttype == PKT_PUBLIC_KEY
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
&& !cmp_public_keys( node->pkt->pkt.public_key, pk ) ) )
break;
}
if( !node ) {
log_debug("Oops, PK not in keyblock\n");
release_kbnode( keyblock );
return;
}
/* now find the revocation certificate */
for( node = node->next; node ; node = node->next ) {
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
break;
if( node->pkt->pkttype == PKT_SIGNATURE
&& (node->pkt->pkt.signature->sig_class == 0x20
|| node->pkt->pkt.signature->sig_class == 0x28 ) ) {
/* FIXME: we should check the signature here */
do_show_revocation_reason ( node->pkt->pkt.signature );
break;
}
}
/* We didn't find it, so check if the whole key is revoked */
if(!node && !mode)
show_revocation_reason(pk,1);
release_kbnode( keyblock );
}
/****************
* mode: 0 = standard
* 1 = Without key info and additional menu option 'm'
* this does also add an option to set the key to ultimately trusted.
* Returns:
* -2 = nothing changed - caller should show some additional info
* -1 = quit operation
* 0 = nothing changed
* 1 = new ownertrust now in new_trust
*/
static int
do_edit_ownertrust (PKT_public_key *pk, int mode,
unsigned *new_trust, int defer_help )
{
char *p;
u32 keyid[2];
int changed=0;
int quit=0;
int show=0;
int min_num;
int did_help=defer_help;
unsigned int minimum=get_min_ownertrust(pk);
switch(minimum)
{
default:
case TRUST_UNDEFINED: min_num=1; break;
case TRUST_NEVER: min_num=2; break;
case TRUST_MARGINAL: min_num=3; break;
case TRUST_FULLY: min_num=4; break;
}
keyid_from_pk (pk, keyid);
for(;;) {
/* A string with valid answers.
Note to translators: These are the allowed answers in lower and
uppercase. Below you will find the matching strings which
should be translated accordingly and the letter changed to
match the one in the answer string.
i = please show me more information
m = back to the main menu
s = skip this key
q = quit
*/
const char *ans = _("iImMqQsS");
if( !did_help )
{
if( !mode )
{
KBNODE keyblock, un;
tty_printf(_("No trust value assigned to:\n"));
tty_printf("%4u%c/%s %s\n",nbits_from_pk( pk ),
pubkey_letter( pk->pubkey_algo ),
keystr(keyid), datestr_from_pk( pk ) );
p=get_user_id_native(keyid);
tty_printf(_(" \"%s\"\n"),p);
xfree(p);
keyblock = get_pubkeyblock (keyid);
if (!keyblock)
BUG ();
for (un=keyblock; un; un = un->next)
{
if (un->pkt->pkttype != PKT_USER_ID )
continue;
if (un->pkt->pkt.user_id->is_revoked )
continue;
if (un->pkt->pkt.user_id->is_expired )
continue;
/* Only skip textual primaries */
if (un->pkt->pkt.user_id->is_primary
&& !un->pkt->pkt.user_id->attrib_data )
continue;
if((opt.verify_options&VERIFY_SHOW_PHOTOS)
&& un->pkt->pkt.user_id->attrib_data)
show_photos(un->pkt->pkt.user_id->attribs,
un->pkt->pkt.user_id->numattribs,pk,NULL);
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
tty_printf(_(" aka \"%s\"\n"),p);
}
print_fingerprint (pk, NULL, 2);
tty_printf("\n");
release_kbnode (keyblock);
}
if(opt.trust_model==TM_DIRECT)
{
tty_printf(_("How much do you trust that this key actually "
"belongs to the named user?\n"));
tty_printf("\n");
}
else
{
/* This string also used in keyedit.c:trustsig_prompt */
tty_printf(_("Please decide how far you trust this user to"
" correctly verify other users' keys\n"
"(by looking at passports, checking fingerprints from"
" different sources, etc.)\n"));
tty_printf("\n");
}
if(min_num<=1)
tty_printf (_(" %d = I don't know or won't say\n"), 1);
if(min_num<=2)
tty_printf (_(" %d = I do NOT trust\n"), 2);
if(min_num<=3)
tty_printf (_(" %d = I trust marginally\n"), 3);
if(min_num<=4)
tty_printf (_(" %d = I trust fully\n"), 4);
if (mode)
tty_printf (_(" %d = I trust ultimately\n"), 5);
#if 0
/* not yet implemented */
tty_printf (" i = please show me more information\n");
#endif
if( mode )
tty_printf(_(" m = back to the main menu\n"));
else
{
tty_printf(_(" s = skip this key\n"));
tty_printf(_(" q = quit\n"));
}
tty_printf("\n");
if(minimum)
tty_printf(_("The minimum trust level for this key is: %s\n\n"),
trust_value_to_string(minimum));
did_help = 1;
}
if( strlen(ans) != 8 )
BUG();
p = cpr_get("edit_ownertrust.value",_("Your decision? "));
trim_spaces(p);
cpr_kill_prompt();
if( !*p )
did_help = 0;
else if( *p && p[1] )
;
else if( !p[1] && ((*p >= '0'+min_num) && *p <= (mode?'5':'4')) )
{
unsigned int trust;
switch( *p )
{
case '1': trust = TRUST_UNDEFINED; break;
case '2': trust = TRUST_NEVER ; break;
case '3': trust = TRUST_MARGINAL ; break;
case '4': trust = TRUST_FULLY ; break;
case '5': trust = TRUST_ULTIMATE ; break;
default: BUG();
}
if (trust == TRUST_ULTIMATE
&& !cpr_get_answer_is_yes ("edit_ownertrust.set_ultimate.okay",
_("Do you really want to set this key"
" to ultimate trust? (y/N) ")))
; /* no */
else
{
*new_trust = trust;
changed = 1;
break;
}
}
#if 0
/* not yet implemented */
else if( *p == ans[0] || *p == ans[1] )
{
tty_printf(_("Certificates leading to an ultimately trusted key:\n"));
show = 1;
break;
}
#endif
else if( mode && (*p == ans[2] || *p == ans[3] || *p == CONTROL_D ) )
{
break ; /* back to the menu */
}
else if( !mode && (*p == ans[6] || *p == ans[7] ) )
{
break; /* skip */
}
else if( !mode && (*p == ans[4] || *p == ans[5] ) )
{
quit = 1;
break ; /* back to the menu */
}
xfree(p); p = NULL;
}
xfree(p);
return show? -2: quit? -1 : changed;
}
/*
* Display a menu to change the ownertrust of the key PK (which should
* be a primary key).
* For mode values see do_edit_ownertrust ()
*/
int
edit_ownertrust (PKT_public_key *pk, int mode )
{
unsigned int trust;
int no_help = 0;
for(;;)
{
switch ( do_edit_ownertrust (pk, mode, &trust, no_help ) )
{
case -1: /* quit */
return -1;
case -2: /* show info */
no_help = 1;
break;
case 1: /* trust value set */
trust &= ~TRUST_FLAG_DISABLED;
trust |= get_ownertrust (pk) & TRUST_FLAG_DISABLED;
update_ownertrust (pk, trust );
return 1;
default:
return 0;
}
}
}
/****************
* Check whether we can trust this pk which has a trustlevel of TRUSTLEVEL
* Returns: true if we trust.
*/
static int
do_we_trust( PKT_public_key *pk, unsigned int trustlevel )
{
/* We should not be able to get here with a revoked or expired
key */
if(trustlevel & TRUST_FLAG_REVOKED
|| trustlevel & TRUST_FLAG_SUB_REVOKED
|| (trustlevel & TRUST_MASK) == TRUST_EXPIRED)
BUG();
if( opt.trust_model==TM_ALWAYS )
{
if( opt.verbose )
log_info("No trust check due to `--trust-model always' option\n");
return 1;
}
switch(trustlevel & TRUST_MASK)
{
default:
log_error ("invalid trustlevel %u returned from validation layer\n",
trustlevel);
/* fall thru */
case TRUST_UNKNOWN:
case TRUST_UNDEFINED:
log_info(_("%s: There is no assurance this key belongs"
" to the named user\n"),keystr_from_pk(pk));
return 0; /* no */
case TRUST_MARGINAL:
log_info(_("%s: There is limited assurance this key belongs"
" to the named user\n"),keystr_from_pk(pk));
return 1; /* yes */
case TRUST_FULLY:
if( opt.verbose )
log_info(_("This key probably belongs to the named user\n"));
return 1; /* yes */
case TRUST_ULTIMATE:
if( opt.verbose )
log_info(_("This key belongs to us\n"));
return 1; /* yes */
}
return 1; /* yes */
}
/****************
* wrapper around do_we_trust, so we can ask whether to use the
* key anyway.
*/
static int
do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
{
int rc;
rc = do_we_trust( pk, trustlevel );
if( !opt.batch && !rc )
{
print_pubkey_info(NULL,pk);
print_fingerprint (pk, NULL, 2);
tty_printf("\n");
tty_printf(
_("It is NOT certain that the key belongs to the person named\n"
"in the user ID. If you *really* know what you are doing,\n"
"you may answer the next question with yes.\n"));
tty_printf("\n");
if( cpr_get_answer_is_yes("untrusted_key.override",
_("Use this key anyway? (y/N) ")) )
rc = 1;
/* Hmmm: Should we set a flag to tell the user about
* his decision the next time he encrypts for this recipient?
*/
}
return rc;
}
/****************
* Check whether we can trust this signature.
* Returns: Error if we shall not trust this signatures.
*/
int
check_signatures_trust( PKT_signature *sig )
{
PKT_public_key *pk = xmalloc_clear( sizeof *pk );
unsigned int trustlevel;
int rc=0;
rc = get_pubkey( pk, sig->keyid );
if (rc)
{ /* this should not happen */
log_error("Ooops; the key vanished - can't check the trust\n");
rc = G10ERR_NO_PUBKEY;
goto leave;
}
if ( opt.trust_model==TM_ALWAYS )
{
if( !opt.quiet )
log_info(_("WARNING: Using untrusted key!\n"));
if (opt.with_fingerprint)
print_fingerprint (pk, NULL, 1);
goto leave;
}
if(pk->maybe_revoked && !pk->is_revoked)
log_info(_("WARNING: this key might be revoked (revocation key"
" not present)\n"));
trustlevel = get_validity (pk, NULL);
if ( (trustlevel & TRUST_FLAG_REVOKED) )
{
write_status( STATUS_KEYREVOKED );
if(pk->is_revoked==2)
log_info(_("WARNING: This key has been revoked by its"
" designated revoker!\n"));
else
log_info(_("WARNING: This key has been revoked by its owner!\n"));
log_info(_(" This could mean that the signature is forged.\n"));
show_revocation_reason( pk, 0 );
}
else if ((trustlevel & TRUST_FLAG_SUB_REVOKED) )
{
write_status( STATUS_KEYREVOKED );
log_info(_("WARNING: This subkey has been revoked by its owner!\n"));
show_revocation_reason( pk, 0 );
}
if ((trustlevel & TRUST_FLAG_DISABLED))
log_info (_("Note: This key has been disabled.\n"));
/* If we have PKA information adjust the trustlevel. */
if (sig->pka_info && sig->pka_info->valid)
{
unsigned char fpr[MAX_FINGERPRINT_LEN];
PKT_public_key *primary_pk;
size_t fprlen;
int okay;
primary_pk = xmalloc_clear (sizeof *primary_pk);
get_pubkey (primary_pk, pk->main_keyid);
fingerprint_from_pk (primary_pk, fpr, &fprlen);
free_public_key (primary_pk);
if ( fprlen == 20 && !memcmp (sig->pka_info->fpr, fpr, 20) )
{
okay = 1;
log_info (_("Note: Verified signer's address is `%s'\n"),
sig->pka_info->email);
}
else
{
okay = 0;
log_info (_("Note: Signer's address `%s' "
"does not match DNS entry\n"), sig->pka_info->email);
}
switch ( (trustlevel & TRUST_MASK) )
{
case TRUST_UNKNOWN:
case TRUST_UNDEFINED:
case TRUST_MARGINAL:
if (okay)
{
trustlevel = ((trustlevel & ~TRUST_MASK) | TRUST_FULLY);
log_info ("trustlevel adjusted to FULL due to valid PKA info\n");
}
/* (fall through) */
case TRUST_FULLY:
if (!okay)
{
trustlevel = ((trustlevel & ~TRUST_MASK) | TRUST_NEVER);
log_info ("trustlevel adjusted to NEVER due to bad PKA info\n");
}
break;
}
}
/* Now let the user know what up with the trustlevel. */
switch ( (trustlevel & TRUST_MASK) )
{
case TRUST_EXPIRED:
log_info(_("Note: This key has expired!\n"));
print_fingerprint (pk, NULL, 1);
break;
default:
log_error ("invalid trustlevel %u returned from validation layer\n",
trustlevel);
/* fall thru */
case TRUST_UNKNOWN:
case TRUST_UNDEFINED:
write_status( STATUS_TRUST_UNDEFINED );
log_info(_("WARNING: This key is not certified with"
" a trusted signature!\n"));
log_info(_(" There is no indication that the "
"signature belongs to the owner.\n" ));
print_fingerprint (pk, NULL, 1);
break;
case TRUST_NEVER:
/* currently we won't get that status */
write_status( STATUS_TRUST_NEVER );
log_info(_("WARNING: We do NOT trust this key!\n"));
log_info(_(" The signature is probably a FORGERY.\n"));
if (opt.with_fingerprint)
print_fingerprint (pk, NULL, 1);
rc = G10ERR_BAD_SIGN;
break;
case TRUST_MARGINAL:
write_status( STATUS_TRUST_MARGINAL );
log_info(_("WARNING: This key is not certified with"
" sufficiently trusted signatures!\n"));
log_info(_(" It is not certain that the"
" signature belongs to the owner.\n" ));
print_fingerprint (pk, NULL, 1);
break;
case TRUST_FULLY:
write_status( STATUS_TRUST_FULLY );
if (opt.with_fingerprint)
print_fingerprint (pk, NULL, 1);
break;
case TRUST_ULTIMATE:
write_status( STATUS_TRUST_ULTIMATE );
if (opt.with_fingerprint)
print_fingerprint (pk, NULL, 1);
break;
}
leave:
free_public_key( pk );
return rc;
}
void
release_pk_list( PK_LIST pk_list )
{
PK_LIST pk_rover;
for( ; pk_list; pk_list = pk_rover ) {
pk_rover = pk_list->next;
free_public_key( pk_list->pk );
xfree( pk_list );
}
}
static int
key_present_in_pk_list(PK_LIST pk_list, PKT_public_key *pk)
{
for( ; pk_list; pk_list = pk_list->next)
if (cmp_public_keys(pk_list->pk, pk) == 0)
return 0;
return -1;
}
/****************
* Return a malloced string with a default reciepient if there is any
*/
static char *
default_recipient(void)
{
PKT_secret_key *sk;
byte fpr[MAX_FINGERPRINT_LEN+1];
size_t n;
char *p;
int i;
if( opt.def_recipient )
return xstrdup( opt.def_recipient );
if( !opt.def_recipient_self )
return NULL;
sk = xmalloc_clear( sizeof *sk );
i = get_seckey_byname( sk, NULL, 0 );
if( i ) {
free_secret_key( sk );
return NULL;
}
n = MAX_FINGERPRINT_LEN;
fingerprint_from_sk( sk, fpr, &n );
free_secret_key( sk );
p = xmalloc( 2*n+3 );
*p++ = '0';
*p++ = 'x';
for(i=0; i < n; i++ )
sprintf( p+2*i, "%02X", fpr[i] );
p -= 2;
return p;
}
static int
expand_id(const char *id,STRLIST *into,unsigned int flags)
{
struct groupitem *groups;
int count=0;
for(groups=opt.grouplist;groups;groups=groups->next)
{
/* need strcasecmp() here, as this should be localized */
if(strcasecmp(groups->name,id)==0)
{
STRLIST each,sl;
/* this maintains the current utf8-ness */
for(each=groups->values;each;each=each->next)
{
sl=add_to_strlist(into,each->d);
sl->flags=flags;
count++;
}
break;
}
}
return count;
}
/* For simplicity, and to avoid potential loops, we only expand once -
you can't make an alias that points to an alias. */
static STRLIST
expand_group(STRLIST input)
{
STRLIST sl,output=NULL,rover;
for(rover=input;rover;rover=rover->next)
if(expand_id(rover->d,&output,rover->flags)==0)
{
/* Didn't find any groups, so use the existing string */
sl=add_to_strlist(&output,rover->d);
sl->flags=rover->flags;
}
return output;
}
+
+/* This is the central function to collect the keys for recipients.
+ It is thus used to prepare a public key encryption. encrypt-to
+ keys, default keys and the keys for the actual recipients are all
+ collected here. When not in batch mode and no recipient has been
+ passed on the commandline, the function will also ask for
+ recipients.
+
+ RCPTS is a string list with the recipients; NULL is an allowed
+ value but not very useful. Group expansion is done on these names;
+ they may be in any of the user Id formats we can handle. The flags
+ bits for each string in the string list are used for:
+ Bit 0: This is an encrypt-to recipient.
+ Bit 1: This is a hidden recipient.
+
+ USE is the desired use for the key - usually PUBKEY_USAGE_ENC.
+ RET_PK_LIST.
+
+ On success a list of keys is stored at the address RET_PK_LIST; the
+ caller must free this list. On error the value at this address is
+ not changed.
+ */
int
-build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
+build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned int use )
{
- PK_LIST pk_list = NULL;
- PKT_public_key *pk=NULL;
- int rc=0;
- int any_recipients=0;
- STRLIST rov,remusr;
- char *def_rec = NULL;
-
- if(opt.grouplist)
- remusr=expand_group(rcpts);
- else
- remusr=rcpts;
-
- /* check whether there are any recipients in the list and build the
- * list of the encrypt-to ones (we always trust them) */
- for( rov = remusr; rov; rov = rov->next ) {
- if( !(rov->flags & 1) )
- {
- any_recipients = 1;
+ PK_LIST pk_list = NULL;
+ PKT_public_key *pk=NULL;
+ int rc=0;
+ int any_recipients=0;
+ STRLIST rov,remusr;
+ char *def_rec = NULL;
- if((rov->flags&2) && (PGP2 || PGP6 || PGP7 || PGP8))
- {
- log_info(_("you may not use %s while in %s mode\n"),
- "--hidden-recipient",
- compliance_option_string());
+ /* Try to expand groups if any have been defined. */
+ if (opt.grouplist)
+ remusr = expand_group (rcpts);
+ else
+ remusr = rcpts;
- compliance_failure();
- }
- }
- else if( (use & PUBKEY_USAGE_ENC) && !opt.no_encrypt_to ) {
- pk = xmalloc_clear( sizeof *pk );
- pk->req_usage = use;
- /* We can encrypt-to a disabled key */
- if( (rc = get_pubkey_byname( pk, rov->d, NULL, NULL, 1 )) ) {
- free_public_key( pk ); pk = NULL;
- log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
- write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
- rov->d, strlen (rov->d), -1);
- goto fail;
+ /* Check whether there are any recipients in the list and build the
+ * list of the encrypt-to ones (we always trust them). */
+ for ( rov = remusr; rov; rov = rov->next )
+ {
+ if ( !(rov->flags & 1) )
+ {
+ /* This is a regular recipient; i.e. not an encrypt-to
+ one. */
+ any_recipients = 1;
+
+ /* Hidden recipients are not allowed while in PGP mode,
+ issue a warning and switch into GnuPG mode. */
+ if ((rov->flags&2) && (PGP2 || PGP6 || PGP7 || PGP8))
+ {
+ log_info(_("you may not use %s while in %s mode\n"),
+ "--hidden-recipient",
+ compliance_option_string());
+
+ compliance_failure();
}
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) {
- /* Skip the actual key if the key is already present
- * in the list */
- if (key_present_in_pk_list(pk_list, pk) == 0) {
- free_public_key(pk); pk = NULL;
- log_info(_("%s: skipped: public key already present\n"),
- rov->d);
- }
- else {
- PK_LIST r;
- r = xmalloc( sizeof *r );
- r->pk = pk; pk = NULL;
- r->next = pk_list;
- r->flags = (rov->flags&2)?1:0;
- pk_list = r;
-
- if(r->flags&1 && (PGP2 || PGP6 || PGP7 || PGP8))
- {
- log_info(_("you may not use %s while in %s mode\n"),
- "--hidden-encrypt-to",
- compliance_option_string());
-
- compliance_failure();
- }
- }
- }
- else {
- free_public_key( pk ); pk = NULL;
- log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
- write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
- rov->d, strlen (rov->d), -1);
- goto fail;
- }
- }
+ }
+ else if ( (use & PUBKEY_USAGE_ENC) && !opt.no_encrypt_to )
+ {
+ /* Encryption has been requested and --encrypt-to has not
+ been disabled. Check this encrypt-to key. */
+ pk = xmalloc_clear( sizeof *pk );
+ pk->req_usage = use;
+
+ /* We explicitly allow encrypt-to to an disabled key; thus
+ we pass 1 as last argument. */
+ if ( (rc = get_pubkey_byname ( pk, rov->d, NULL, NULL, 1 )) )
+ {
+ free_public_key ( pk ); pk = NULL;
+ log_error (_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
+ write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
+ rov->d, strlen (rov->d), -1);
+ goto fail;
+ }
+ else if ( !(rc=check_pubkey_algo2 (pk->pubkey_algo, use )) )
+ {
+ /* Skip the actual key if the key is already present
+ * in the list. Add it to our list if not. */
+ if (key_present_in_pk_list(pk_list, pk) == 0)
+ {
+ free_public_key (pk); pk = NULL;
+ log_info (_("%s: skipped: public key already present\n"),
+ rov->d);
+ }
+ else
+ {
+ PK_LIST r;
+ r = xmalloc( sizeof *r );
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->flags = (rov->flags&2)?1:0;
+ pk_list = r;
+
+ /* Hidden encrypt-to recipients are not allowed while
+ in PGP mode, issue a warning and switch into
+ GnuPG mode. */
+ if ((r->flags&1) && (PGP2 || PGP6 || PGP7 || PGP8))
+ {
+ log_info(_("you may not use %s while in %s mode\n"),
+ "--hidden-encrypt-to",
+ compliance_option_string());
+
+ compliance_failure();
+ }
+ }
+ }
+ else
+ {
+ /* The public key is not usable for encryption or not
+ available. */
+ free_public_key( pk ); pk = NULL;
+ log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
+ write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
+ rov->d, strlen (rov->d), -1);
+ goto fail;
+ }
+ }
}
- if( !any_recipients && !opt.batch ) { /* ask */
- int have_def_rec;
- char *answer=NULL;
- STRLIST backlog=NULL;
-
- if(pk_list)
- any_recipients = 1;
- def_rec = default_recipient();
- have_def_rec = !!def_rec;
- if( !have_def_rec )
- tty_printf(_(
- "You did not specify a user ID. (you may use \"-r\")\n"));
- for(;;) {
- rc = 0;
- xfree(answer);
- if( have_def_rec ) {
- answer = def_rec;
- def_rec = NULL;
- }
- else if(backlog) {
- answer=pop_strlist(&backlog);
- }
- else
- {
- PK_LIST iter;
-
- tty_printf("\n");
- tty_printf(_("Current recipients:\n"));
- for(iter=pk_list;iter;iter=iter->next)
- {
- u32 keyid[2];
-
- keyid_from_pk(iter->pk,keyid);
- tty_printf("%4u%c/%s %s \"",
- nbits_from_pk(iter->pk),
- pubkey_letter(iter->pk->pubkey_algo),
- keystr(keyid),
- datestr_from_pk(iter->pk));
-
- if(iter->pk->user_id)
- tty_print_utf8_string(iter->pk->user_id->name,
- iter->pk->user_id->len);
- else
- {
- size_t n;
- char *p = get_user_id( keyid, &n );
- tty_print_utf8_string( p, n );
- xfree(p);
- }
- tty_printf("\"\n");
- }
-
- answer = cpr_get_utf8("pklist.user_id.enter",
- _("\nEnter the user ID. End with an empty line: "));
- trim_spaces(answer);
- cpr_kill_prompt();
- }
- if( !answer || !*answer ) {
- xfree(answer);
- break;
- }
- if(expand_id(answer,&backlog,0))
- continue;
- if( pk )
- free_public_key( pk );
- pk = xmalloc_clear( sizeof *pk );
- pk->req_usage = use;
- rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 );
- if( rc )
- tty_printf(_("No such user ID.\n"));
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) ) {
- if( have_def_rec ) {
- if (key_present_in_pk_list(pk_list, pk) == 0) {
- free_public_key(pk); pk = NULL;
- log_info(_("skipped: public key "
- "already set as default recipient\n") );
- }
- else {
- PK_LIST r = xmalloc( sizeof *r );
- r->pk = pk; pk = NULL;
- r->next = pk_list;
- r->flags = 0; /* no throwing default ids */
- pk_list = r;
- }
- any_recipients = 1;
- continue;
- }
- else {
- int trustlevel;
+ /* If we don't have any recipients yet and we are not in batch mode
+ drop into interactive selection mode. */
+ if ( !any_recipients && !opt.batch )
+ {
+ int have_def_rec;
+ char *answer = NULL;
+ STRLIST backlog = NULL;
+
+ if (pk_list)
+ any_recipients = 1;
+ def_rec = default_recipient();
+ have_def_rec = !!def_rec;
+ if ( !have_def_rec )
+ tty_printf(_("You did not specify a user ID. (you may use \"-r\")\n"));
+
+ for (;;)
+ {
+ rc = 0;
+ xfree(answer);
+ if ( have_def_rec )
+ {
+ /* A default recipient is taken as the first entry. */
+ answer = def_rec;
+ def_rec = NULL;
+ }
+ else if (backlog)
+ {
+ /* This is part of our trick to expand and display groups. */
+ answer = pop_strlist (&backlog);
+ }
+ else
+ {
+ /* Show the list of already collected recipients and ask
+ for more. */
+ PK_LIST iter;
+
+ tty_printf("\n");
+ tty_printf(_("Current recipients:\n"));
+ for (iter=pk_list;iter;iter=iter->next)
+ {
+ u32 keyid[2];
+
+ keyid_from_pk(iter->pk,keyid);
+ tty_printf("%4u%c/%s %s \"",
+ nbits_from_pk(iter->pk),
+ pubkey_letter(iter->pk->pubkey_algo),
+ keystr(keyid),
+ datestr_from_pk(iter->pk));
+
+ if (iter->pk->user_id)
+ tty_print_utf8_string(iter->pk->user_id->name,
+ iter->pk->user_id->len);
+ else
+ {
+ size_t n;
+ char *p = get_user_id( keyid, &n );
+ tty_print_utf8_string( p, n );
+ xfree(p);
+ }
+ tty_printf("\"\n");
+ }
+
+ answer = cpr_get_utf8("pklist.user_id.enter",
+ _("\nEnter the user ID. "
+ "End with an empty line: "));
+ trim_spaces(answer);
+ cpr_kill_prompt();
+ }
+
+ if ( !answer || !*answer )
+ {
+ xfree(answer);
+ break; /* No more recipients entered - get out of loop. */
+ }
+
+ /* Do group expand here too. The trick here is to continue
+ the loop if any expansion occured. The code above will
+ then list all expanded keys. */
+ if (expand_id(answer,&backlog,0))
+ continue;
+
+ /* Get and check key for the current name. */
+ if (pk)
+ free_public_key (pk);
+ pk = xmalloc_clear( sizeof *pk );
+ pk->req_usage = use;
+ rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 );
+ if (rc)
+ tty_printf(_("No such user ID.\n"));
+ else if ( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) )
+ {
+ if ( have_def_rec )
+ {
+ /* No validation for a default recipient. */
+ if (!key_present_in_pk_list(pk_list, pk))
+ {
+ free_public_key (pk); pk = NULL;
+ log_info (_("skipped: public key "
+ "already set as default recipient\n") );
+ }
+ else
+ {
+ PK_LIST r = xmalloc (sizeof *r);
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->flags = 0; /* No throwing default ids. */
+ pk_list = r;
+ }
+ any_recipients = 1;
+ continue;
+ }
+ else
+ { /* Check validity of this key. */
+ int trustlevel;
- trustlevel = get_validity (pk, pk->user_id);
- if( (trustlevel & TRUST_FLAG_DISABLED) ) {
- tty_printf(_("Public key is disabled.\n") );
- }
- else if( do_we_trust_pre( pk, trustlevel ) ) {
- /* Skip the actual key if the key is already present
- * in the list */
- if (key_present_in_pk_list(pk_list, pk) == 0) {
- free_public_key(pk); pk = NULL;
- log_info(_("skipped: public key already set\n") );
- }
- else {
- PK_LIST r;
- r = xmalloc( sizeof *r );
- r->pk = pk; pk = NULL;
- r->next = pk_list;
- r->flags = 0; /* no throwing interactive ids */
- pk_list = r;
- }
- any_recipients = 1;
- continue;
- }
- }
- }
- xfree(def_rec); def_rec = NULL;
- have_def_rec = 0;
- }
- if( pk ) {
- free_public_key( pk );
- pk = NULL;
- }
+ trustlevel = get_validity (pk, pk->user_id);
+ if ( (trustlevel & TRUST_FLAG_DISABLED) )
+ {
+ tty_printf (_("Public key is disabled.\n") );
+ }
+ else if ( do_we_trust_pre (pk, trustlevel) )
+ {
+ /* Skip the actual key if the key is already
+ * present in the list */
+ if (!key_present_in_pk_list(pk_list, pk))
+ {
+ free_public_key(pk); pk = NULL;
+ log_info(_("skipped: public key already set\n") );
+ }
+ else
+ {
+ PK_LIST r;
+ r = xmalloc( sizeof *r );
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->flags = 0; /* No throwing interactive ids. */
+ pk_list = r;
+ }
+ any_recipients = 1;
+ continue;
+ }
+ }
+ }
+ xfree(def_rec); def_rec = NULL;
+ have_def_rec = 0;
+ }
+ if ( pk )
+ {
+ free_public_key( pk );
+ pk = NULL;
+ }
}
- else if( !any_recipients && (def_rec = default_recipient()) ) {
- pk = xmalloc_clear( sizeof *pk );
- pk->req_usage = use;
- /* The default recipient may be disabled */
- rc = get_pubkey_byname( pk, def_rec, NULL, NULL, 1 );
- if( rc )
- log_error(_("unknown default recipient \"%s\"\n"), def_rec );
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) ) {
- /* Mark any_recipients here since the default recipient
+ else if ( !any_recipients && (def_rec = default_recipient()) )
+ {
+ /* We are in batch mode and have only a default recipient. */
+ pk = xmalloc_clear( sizeof *pk );
+ pk->req_usage = use;
+
+ /* The default recipient is allowed to be disabled; thus pass 1
+ as last argument. */
+ rc = get_pubkey_byname (pk, def_rec, NULL, NULL, 1);
+ if (rc)
+ log_error(_("unknown default recipient \"%s\"\n"), def_rec );
+ else if ( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) )
+ {
+ /* Mark any_recipients here since the default recipient
would have been used if it wasn't already there. It
doesn't really matter if we got this key from the default
recipient or an encrypt-to. */
- any_recipients = 1;
- if (key_present_in_pk_list(pk_list, pk) == 0)
- log_info(_("skipped: public key already set as default recipient\n"));
- else {
- PK_LIST r = xmalloc( sizeof *r );
- r->pk = pk; pk = NULL;
- r->next = pk_list;
- r->flags = 0; /* no throwing default ids */
- pk_list = r;
- }
- }
- if( pk ) {
- free_public_key( pk );
- pk = NULL;
- }
- xfree(def_rec); def_rec = NULL;
- }
- else {
- any_recipients = 0;
- for(; remusr; remusr = remusr->next ) {
- if( (remusr->flags & 1) )
- continue; /* encrypt-to keys are already handled */
-
- pk = xmalloc_clear( sizeof *pk );
- pk->req_usage = use;
- if( (rc = get_pubkey_byname( pk, remusr->d, NULL, NULL, 0 )) ) {
- free_public_key( pk ); pk = NULL;
- log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
- write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
- remusr->d, strlen (remusr->d),
- -1);
- goto fail;
- }
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) {
- int trustlevel;
-
- trustlevel = get_validity (pk, pk->user_id);
- if( (trustlevel & TRUST_FLAG_DISABLED) ) {
- free_public_key(pk); pk = NULL;
- log_info(_("%s: skipped: public key is disabled\n"),
- remusr->d);
- write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
- remusr->d,
- strlen (remusr->d),
- -1);
- rc=G10ERR_UNU_PUBKEY;
- goto fail;
- }
- else if( do_we_trust_pre( pk, trustlevel ) ) {
- /* note: do_we_trust may have changed the trustlevel */
-
- /* We have at least one valid recipient. It doesn't matters
- * if this recipient is already present. */
- any_recipients = 1;
-
- /* Skip the actual key if the key is already present
- * in the list */
- if (key_present_in_pk_list(pk_list, pk) == 0) {
- free_public_key(pk); pk = NULL;
- log_info(_("%s: skipped: public key already present\n"),
- remusr->d);
- }
- else {
- PK_LIST r;
- r = xmalloc( sizeof *r );
- r->pk = pk; pk = NULL;
- r->next = pk_list;
- r->flags = (remusr->flags&2)?1:0;
- pk_list = r;
- }
- }
- else { /* we don't trust this pk */
- free_public_key( pk ); pk = NULL;
- write_status_text_and_buffer (STATUS_INV_RECP, "10 ",
- remusr->d,
- strlen (remusr->d),
- -1);
- rc=G10ERR_UNU_PUBKEY;
- goto fail;
- }
- }
- else {
- free_public_key( pk ); pk = NULL;
- write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
- remusr->d,
- strlen (remusr->d),
- -1);
- log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
- goto fail;
- }
- }
+ any_recipients = 1;
+ if (!key_present_in_pk_list(pk_list, pk))
+ log_info (_("skipped: public key already set "
+ "as default recipient\n"));
+ else
+ {
+ PK_LIST r = xmalloc( sizeof *r );
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->flags = 0; /* No throwing default ids. */
+ pk_list = r;
+ }
+ }
+ if ( pk )
+ {
+ free_public_key( pk );
+ pk = NULL;
+ }
+ xfree(def_rec); def_rec = NULL;
}
+ else
+ {
+ /* General case: Check all keys. */
+ any_recipients = 0;
+ for (; remusr; remusr = remusr->next )
+ {
+ if ( (remusr->flags & 1) )
+ continue; /* encrypt-to keys are already handled. */
- if( !rc && !any_recipients ) {
- log_error(_("no valid addressees\n"));
- write_status_text (STATUS_NO_RECP, "0");
- rc = G10ERR_NO_USER_ID;
+ pk = xmalloc_clear( sizeof *pk );
+ pk->req_usage = use;
+ if ( (rc = get_pubkey_byname( pk, remusr->d, NULL, NULL, 0 )) )
+ {
+ /* Key not found or other error. */
+ free_public_key( pk ); pk = NULL;
+ log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
+ write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
+ remusr->d, strlen (remusr->d),
+ -1);
+ goto fail;
+ }
+ else if ( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) )
+ {
+ /* Key found and usable. Check validity. */
+ int trustlevel;
+
+ trustlevel = get_validity (pk, pk->user_id);
+ if ( (trustlevel & TRUST_FLAG_DISABLED) )
+ {
+ /*Key has been disabled. */
+ free_public_key(pk); pk = NULL;
+ log_info(_("%s: skipped: public key is disabled\n"),
+ remusr->d);
+ write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
+ remusr->d,
+ strlen (remusr->d),
+ -1);
+ rc=G10ERR_UNU_PUBKEY;
+ goto fail;
+ }
+ else if ( do_we_trust_pre( pk, trustlevel ) )
+ {
+ /* Note: do_we_trust may have changed the trustlevel */
+
+ /* We have at least one valid recipient. It doesn't
+ * matters if this recipient is already present. */
+ any_recipients = 1;
+
+ /* Skip the actual key if the key is already present
+ * in the list */
+ if (!key_present_in_pk_list(pk_list, pk))
+ {
+ free_public_key(pk); pk = NULL;
+ log_info(_("%s: skipped: public key already present\n"),
+ remusr->d);
+ }
+ else
+ {
+ PK_LIST r;
+ r = xmalloc( sizeof *r );
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->flags = (remusr->flags&2)?1:0;
+ pk_list = r;
+ }
+ }
+ else
+ { /* We don't trust this key. */
+ free_public_key( pk ); pk = NULL;
+ write_status_text_and_buffer (STATUS_INV_RECP, "10 ",
+ remusr->d,
+ strlen (remusr->d),
+ -1);
+ rc=G10ERR_UNU_PUBKEY;
+ goto fail;
+ }
+ }
+ else
+ {
+ /* Key found but not usable for us (e.g. sign-only key). */
+ free_public_key( pk ); pk = NULL;
+ write_status_text_and_buffer (STATUS_INV_RECP, "0 ",
+ remusr->d,
+ strlen (remusr->d),
+ -1);
+ log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
+ goto fail;
+ }
+ }
}
-
+
+ if ( !rc && !any_recipients )
+ {
+ log_error(_("no valid addressees\n"));
+ write_status_text (STATUS_NO_RECP, "0");
+ rc = G10ERR_NO_USER_ID;
+ }
+
fail:
- if( rc )
- release_pk_list( pk_list );
- else
- *ret_pk_list = pk_list;
- if(opt.grouplist)
- free_strlist(remusr);
- return rc;
+ if ( rc )
+ release_pk_list( pk_list );
+ else
+ *ret_pk_list = pk_list;
+ if (opt.grouplist)
+ free_strlist(remusr);
+ return rc;
}
/* In pgp6 mode, disallow all ciphers except IDEA (1), 3DES (2), and
CAST5 (3), all hashes except MD5 (1), SHA1 (2), and RIPEMD160 (3),
and all compressions except none (0) and ZIP (1). pgp7 and pgp8
mode expands the cipher list to include AES128 (7), AES192 (8),
AES256 (9), and TWOFISH (10). pgp8 adds the SHA-256 hash (8). For
a true PGP key all of this is unneeded as they are the only items
present in the preferences subpacket, but checking here covers the
weird case of encrypting to a key that had preferences from a
different implementation which was then used with PGP. I am not
completely comfortable with this as the right thing to do, as it
slightly alters the list of what the user is supposedly requesting.
It is not against the RFC however, as the preference chosen will
never be one that the user didn't specify somewhere ("The
implementation may use any mechanism to pick an algorithm in the
intersection"), and PGP has no mechanism to fix such a broken
preference list, so I'm including it. -dms */
int
algo_available( preftype_t preftype, int algo, void *hint )
{
if( preftype == PREFTYPE_SYM )
{
if(PGP6 && (algo != CIPHER_ALGO_IDEA
&& algo != CIPHER_ALGO_3DES
&& algo != CIPHER_ALGO_CAST5))
return 0;
if(PGP7 && (algo != CIPHER_ALGO_IDEA
&& algo != CIPHER_ALGO_3DES
&& algo != CIPHER_ALGO_CAST5
&& algo != CIPHER_ALGO_AES
&& algo != CIPHER_ALGO_AES192
&& algo != CIPHER_ALGO_AES256
&& algo != CIPHER_ALGO_TWOFISH))
return 0;
/* PGP8 supports all the ciphers we do.. */
return algo && !check_cipher_algo( algo );
}
else if( preftype == PREFTYPE_HASH )
{
if(hint && ((*(int *)hint) != md_digest_length(algo)))
return 0;
if((PGP6 || PGP7) && (algo != DIGEST_ALGO_MD5
&& algo != DIGEST_ALGO_SHA1
&& algo != DIGEST_ALGO_RMD160))
return 0;
if(PGP8 && (algo != DIGEST_ALGO_MD5
&& algo != DIGEST_ALGO_SHA1
&& algo != DIGEST_ALGO_RMD160
&& algo != DIGEST_ALGO_SHA256))
return 0;
return algo && !check_digest_algo( algo );
}
else if( preftype == PREFTYPE_ZIP )
{
if((PGP6 || PGP7) && (algo != COMPRESS_ALGO_NONE
&& algo != COMPRESS_ALGO_ZIP))
return 0;
/* PGP8 supports all the compression algos we do */
return !check_compress_algo( algo );
}
else
return 0;
}
/****************
* Return -1 if we could not find an algorithm.
*/
int
select_algo_from_prefs(PK_LIST pk_list, int preftype, int request, void *hint)
{
PK_LIST pkr;
u32 bits[8];
const prefitem_t *prefs;
int i, j;
int compr_hack=0;
int any;
if( !pk_list )
return -1;
memset( bits, ~0, 8 * sizeof *bits );
for( pkr = pk_list; pkr; pkr = pkr->next ) {
u32 mask[8];
memset( mask, 0, 8 * sizeof *mask );
if( preftype == PREFTYPE_SYM ) {
if( PGP2 &&
pkr->pk->version < 4 &&
pkr->pk->selfsigversion < 4 )
mask[0] |= (1<<1); /* IDEA is implicitly there for v3 keys
with v3 selfsigs (rfc2440:12.1) if
--pgp2 mode is on. This doesn't
mean it's actually available, of
course. */
else
mask[0] |= (1<<2); /* 3DES is implicitly there for everyone else */
}
else if( preftype == PREFTYPE_HASH ) {
/* While I am including this code for completeness, note
that currently --pgp2 mode locks the hash at MD5, so this
function will never even be called. Even if the hash
wasn't locked at MD5, we don't support sign+encrypt in
--pgp2 mode, and that's the only time PREFTYPE_HASH is
used anyway. -dms */
if( PGP2 &&
pkr->pk->version < 4 &&
pkr->pk->selfsigversion < 4 )
mask[0] |= (1<<1); /* MD5 is there for v3 keys with v3
selfsigs when --pgp2 is on. */
else
mask[0] |= (1<<2); /* SHA1 is there for everyone else */
}
else if( preftype == PREFTYPE_ZIP )
mask[0] |= (1<<0); /* Uncompressed is implicit */
if (pkr->pk->user_id) /* selected by user ID */
prefs = pkr->pk->user_id->prefs;
else
prefs = pkr->pk->prefs;
any = 0;
if( prefs ) {
for (i=0; prefs[i].type; i++ ) {
if( prefs[i].type == preftype ) {
mask[prefs[i].value/32] |= 1 << (prefs[i].value%32);
any = 1;
}
}
}
if( (!prefs || !any) && preftype == PREFTYPE_ZIP ) {
mask[0] |= 3; /* asume no_compression and old pgp */
compr_hack = 1;
}
#if 0
log_debug("pref mask=%08lX%08lX%08lX%08lX%08lX%08lX%08lX%08lX\n",
(ulong)mask[7], (ulong)mask[6], (ulong)mask[5], (ulong)mask[4],
(ulong)mask[3], (ulong)mask[2], (ulong)mask[1], (ulong)mask[0]);
#endif
for(i=0; i < 8; i++ )
bits[i] &= mask[i];
#if 0
log_debug("pref bits=%08lX%08lX%08lX%08lX%08lX%08lX%08lX%08lX\n",
(ulong)bits[7], (ulong)bits[6], (ulong)bits[5], (ulong)bits[4],
(ulong)bits[3], (ulong)bits[2], (ulong)bits[1], (ulong)bits[0]);
#endif
}
/* usable algorithms are now in bits
* We now use the last key from pk_list to select
* the algorithm we want to use. there are no
* preferences for the last key, we select the one
* corresponding to first set bit.
*/
i = -1;
any = 0;
/* Can we use the requested algorithm? */
if(request>-1 && (bits[request/32] & (1<<(request%32))) &&
algo_available(preftype,request,hint))
return request;
/* If we have personal prefs set, use them instead of the last key */
if(preftype==PREFTYPE_SYM && opt.personal_cipher_prefs)
prefs=opt.personal_cipher_prefs;
else if(preftype==PREFTYPE_HASH && opt.personal_digest_prefs)
prefs=opt.personal_digest_prefs;
else if(preftype==PREFTYPE_ZIP && opt.personal_compress_prefs)
prefs=opt.personal_compress_prefs;
if( prefs ) {
for(j=0; prefs[j].type; j++ ) {
if( prefs[j].type == preftype ) {
if( (bits[prefs[j].value/32] & (1<<(prefs[j].value%32))) ) {
if( algo_available( preftype, prefs[j].value, hint ) ) {
any = 1;
i = prefs[j].value;
break;
}
}
}
}
}
if( !prefs || !any ) {
for(j=0; j < 256; j++ )
if( (bits[j/32] & (1<<(j%32))) ) {
if( algo_available( preftype, j, hint ) ) {
i = j;
break;
}
}
}
#if 0
log_debug("prefs of type %d: selected %d\n", preftype, i );
#endif
if( compr_hack && !i ) {
/* selected no compression, but we should check whether
* algorithm 1 is also available (the ordering is not relevant
* in this case). */
if( bits[0] & (1<<1) )
i = 1; /* yep; we can use compression algo 1 */
}
/* "If you are building an authentication system, the recipient
may specify a preferred signing algorithm. However, the signer
would be foolish to use a weak algorithm simply because the
recipient requests it." RFC2440:13. If we settle on MD5, and
SHA1 is also available, use SHA1 instead. Of course, if the
user intentionally chose MD5 (by putting it in their personal
prefs), then we should do what they say. */
if(preftype==PREFTYPE_HASH &&
i==DIGEST_ALGO_MD5 && (bits[0] & (1<<DIGEST_ALGO_SHA1)))
{
i=DIGEST_ALGO_SHA1;
if(opt.personal_digest_prefs)
for(j=0; prefs[j].type; j++ )
if(opt.personal_digest_prefs[j].type==PREFTYPE_HASH &&
opt.personal_digest_prefs[j].value==DIGEST_ALGO_MD5)
{
i=DIGEST_ALGO_MD5;
break;
}
}
return i;
}
/*
* Select the MDC flag from the pk_list. We can only use MDC if all recipients
* support this feature
*/
int
select_mdc_from_pklist (PK_LIST pk_list)
{
PK_LIST pkr;
if( !pk_list )
return 0;
for (pkr = pk_list; pkr; pkr = pkr->next) {
int mdc;
if (pkr->pk->user_id) /* selected by user ID */
mdc = pkr->pk->user_id->mdc_feature;
else
mdc = pkr->pk->mdc_feature;
if (!mdc)
return 0; /* at least one recipient does not support it */
}
return 1; /* can be used */
}

File Metadata

Mime Type
text/x-diff
Expires
Mon, Dec 23, 2:10 PM (16 h, 51 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
5c/83/3f38891d30af2990082bb5957f4f

Event Timeline