1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

10686 Commits

Author SHA1 Message Date
Werner Koch
f0bca16ad3
doc: Explain that qualified.txt is a legacy method.
--
2024-11-22 13:44:43 +01:00
NIIBE Yutaka
261a08566e
scd: No hard lock-up when apdu_connect never returns.
* scd/app.c (new_card_lock): New.
(select_application): Scanning is serialized by NEW_CARD_LOCK.
For app_new_register, we hold the W-lock.
(initialize_module): Initialize NEW_CARD_LOCK.

--

GnuPG-bug-id: 7402
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-18 14:25:58 +09:00
Werner Koch
17b766b0a3
gpgconf: Include a minimal secure version in the --query-swdb output.
* tools/gpgconf.c (query_swdb): Parse the new minver tag.
2024-11-15 09:36:27 +01:00
Werner Koch
e5f450f3bb
gpg: Consider Kyber to be de-vs compliant.
* common/compliance.c (gnupg_pk_is_compliant) <CO_DE_VS>: Consider
Brainpool Kyber variants compliant.
(gnupg_pk_is_allowed): Ditto.
(assumed_de_vs_compliance): Remove variable.
(get_assumed_de_vs_compliance): New.
(get_compliance_cache): Use new accessor.
(gnupg_status_compliance_flag): Ditto.
--

Use

  GNUPG_ASSUME_COMPLIANCE=de-vs gpg --compliance=de-vs ....

for testing.  This returns 2023 instead of 23 to indicate the
non-approval state.

GnuPG-bug-id: 6638
2024-11-14 15:15:11 +01:00
Werner Koch
996e8ae3cb
gpg: Allow "Kyber" as algorithm for the Subkey-Type keyword.
* g10/keygen.c (get_parameter_algo): Make "KYBER" to
PUBKEY_ALGO_KYBER.
--

GnuPG-bug-id: 7397
2024-11-14 14:26:21 +01:00
Werner Koch
7e066f614a
gpg: For composite algos add the algo string to the colons listings.
* g10/keylist.c (list_keyblock_colon): Put the algo string into the
curve field for Kyber.
--

GnuPG-bug-id: 6638
2024-11-14 14:04:50 +01:00
Werner Koch
6b02292d31
gpg: Add option to create Kyber with --full-gen-key.
* g10/keygen.c (PQC_STD_KEY_PARAM_PRI, PQC_STD_KEY_PARAM_SUB): New.
(PQC_STD_KEY_PARAM): Construct from above.
(gen_kyber): Allow short curve names.
(ask_algo): Add Entry for ecc+kyber.
(ask_kyber_variant): New.
(generate_keypair): Generate ECC primary and Kyber sub.
--

GnuPG-bug-id: 6638
2024-11-13 16:13:43 +01:00
Werner Koch
d54db0ac42
gpgconf: Show also the used nPth version with -V
* dirmngr/dirmngr.c (gpgconf_versions): Get and show nPth version.
--

Note that this requires nPth 1.8
2024-11-12 12:07:24 +01:00
Werner Koch
813bd4f3d2
gpg-mail-tube: Fix content type for an attached non-plaintext.
* tools/gpg-mail-tube.c (mail_tube_encrypt): Fix content type for an
attached message.
--

We can't use message/rfc822 if we encrypt this message as a simple PGP
file.
2024-11-12 12:07:24 +01:00
NIIBE Yutaka
d994ffc56a
scd: Clean up app_send_active_apps and app_send_card_list.
* scd/app.c (send_card_and_app_list): Only handle the case with
WANTCARD=NULL.
(app_send_card_list): Follow the change.
(app_send_active_apps): Factor out the case with WANTCARD!=NULL.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-12 15:36:35 +09:00
NIIBE Yutaka
2f6b479919
scd: Fix a memory leak.
* scd/app-help.c (app_help_read_length_of_cert): Free the BUFFER.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-11 13:49:06 +09:00
NIIBE Yutaka
b1f2695d24
scd: Fix resource leaks on error paths.
* scd/app-dinsig.c (do_readcert): Don't return directly but care about
releasing memory.
* scd/app-nks.c (readcert_from_ef): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-11 09:51:54 +09:00
Werner Koch
d37971b45f
gpg: Improve wording for only-pubkeys.
* g10/import.c (parse_import_options): Add a description to
only-pubkeys.
--

See gnupg-devel for a brief discussion.
2024-11-08 08:35:04 +01:00
Werner Koch
74e81f830d
gpgtar: Make sure to create upper directories for regular files.
* tools/gpgtar-extract.c (extract_directory): Factor parent directory
creation out to ..
(try_mkdir_p): new.
(extract_regular): Create directory on ENOENT.

* g10/pubkey-enc.c (get_it): Use log_info instead of log_error if the
public key was not found for preference checking.
--

If tarball was created with
    tar cf tarball file1.txt foo/file2.txt
the tarball has no entry for foo/ and thus the extraction fails. This
patch fixes this.

GnuPG-bug-id: 7380

The second patch avoid a wrong exist status status line due to the use
of log_error.  But the actual cause needs stuill needs tobe
investigated.
2024-11-07 15:06:17 +01:00
Werner Koch
567fb6eaa0
gpg-mail-type: Assume text/plain for missing content-type.
* tools/gpg-mail-tube.c (mail_tube_encrypt): Rename var ct_text for
clarity.  Replace debug diagnostic by log_info. Assume text/plain for
missing content-type.
--

Without this fix we would create message/rfc822 attachment instead of
a text/plain attachment with the encrypted body.
2024-11-07 10:51:04 +01:00
Werner Koch
b389e04ef5
gpgtar: Use log-file from common.conf only in --batch mode.
* tools/gpgtar.c (main): Do it.
--

This makes the interactive use of gpgtar more convenient and is more
aligned to what gpg and gpgsm do.
2024-11-07 10:51:04 +01:00
NIIBE Yutaka
8359f2e498
scd: Fix getinfo active_apps.
* scd/app.c (send_card_and_app_list): Avoid locking recursively.

--

Fixes-commit: 25a140542a9186a27b7df9cd3ca3d478b59cbf1b
GnuPG-bug-id: 7323
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-07 08:59:01 +09:00
NIIBE Yutaka
25a140542a
scd: Serialize CARD access for send_card_and_app_list.
* scd/app.c (send_card_and_app_list): Lock the CARD.

--

GnuPG-bug-id: 7323
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-11-06 11:36:48 +09:00
Werner Koch
88b04b47e7
po: Align German trustlist question to what we use in Kleopatra.
--

This replaces our long standing wedding style prompt to something more
straight.
2024-11-05 11:49:57 +01:00
Werner Koch
d30e345692
gpg: Allow the use of an ADSK subkey as ADSK subkey.
* g10/packet.h (PKT_public_key): Increased size of req_usage to 16.
* g10/getkey.c (key_byname): Set allow_adsk in the context if ir was
requested via req_usage.
(finish_lookup): Allow RENC usage matching.
* g10/keyedit.c (append_adsk_to_key): Adjust the assert.
* g10/keygen.c (prepare_adsk): Also allow to find an RENC subkey.
--

If an ADSK is to be added it may happen that an ADSK subkey is found
first and this should then be used even that it does not have the E
usage.  However, it used to have that E usage when it was added.

While testing this I found another pecularity: If you do
  gpg -k ADSK_SUBKEY_FPR
without the '!' suffix and no corresponding encryption subkey is dound,
you will get an unusabe key error.  I hesitate to fix that due to
possible side-effects.

GnuPG-bug-id: 6882
2024-10-31 15:11:55 +01:00
NIIBE Yutaka
a7c81efe51
agent: Fix status output for LISTTRUSTED.
* agent/trustlist.c (istrusted_internal): When LISTMODE is enabled,
TRUSTLISTFPR status output should be done.

--

GnuPG-bug-id: 7363
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Fixes-commit: 4275d5fa7a51731544d243ba16628a9958ffe3ce
2024-10-31 09:33:40 +01:00
Werner Koch
48aa9e8265
gpg: Do not fail with an error for a "Note:" diagnostic
* g10/trustdb.c (validate_keys): Use log_info instead of log_error for
not found or expired UTKs.
--

Actually the not-found case used log_error for decades.  The
semantically simialr expired case did thus the same.  The actual
problem is for example in the import case where gpg exits with a
failure despite that a key validation was requested.

GnuPG-bug-id: 7351
2024-10-30 08:13:55 +01:00
Werner Koch
39aa206dc5
speedo: Enable additional runtime protections on Windows.
* build-aux/speedo.mk (speedo_w32_cflags): Remove -mms-bitfields
because it is for a long time the gcc default.  Enable control flow
protection.
--

Note that due to mingw static linking problems with libssp the stack
protector is not yet enabled.

(cherry picked from commit afe87ffc08e14317f4ef5bbe2940d07203a43808)
2024-10-29 13:45:14 +01:00
Werner Koch
18081e2ecf
gpgsm: Terminate key listing on output write error.
* sm/keylist.c (list_internal_keys): Detect write errors to the output
stream.

* sm/server.c (any_failure_printed): New var.
(gpgsm_status2): Handle new var.  Move statusfp init to ...
(gpgsm_init_statusfp): new function.
(gpgsm_exit_failure_status): New.
* sm/gpgsm.c (main): Explicit statusfp init.
(gpgsm_exit): Print failure status on error.
--
Test by using

  gpgsm -k >/dev/full
  gpgsm -k --wit-colons >/dev/full

and also by redirecting to a file on a small partition.

GnuPG-bug-id: 6185
2024-10-23 11:43:08 +02:00
NIIBE Yutaka
40707c8bff
agent: Fix resource leak for PRIMARY_CTX.
* agent/call-daemon.c (wait_child_thread): Call assuan_release for
PRIMARY_CTX when it's kept for reuse.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-22 09:51:03 +09:00
Werner Koch
51b7bb9106
common: Fix test for the assumed compliance.
* common/compliance.c (gnupg_status_compliance_flag): Fix test.
--

In general the cache is used to query this flag but in this function
it is used directly and we need to adjust the test.

Thanks to Ingo for reporting this.
2024-10-21 17:08:59 +02:00
NIIBE Yutaka
347ab07c62
build: Don't remove --disable-endian-check.
* configure.ac (WORDS_BIGENDIAN): Use the autoconf macro,
instead of our own BIG_ENDIAN_HOST.
(DISABLED_ENDIAN_CHECK): Keep --disable-endian-check supported.
* g10/rmd160.c (transform): Use WORDS_BIGENDIAN.

--

Fixes-commit: f8bf5e01f76620cc550253cc2575754872cf64aa
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-16 11:41:46 +09:00
NIIBE Yutaka
71840b57f4
common: Fix a race condition in creating socketdir.
* common/homedir.c (_gnupg_socketdir_internal): Check return code
of gnupg_mkdir and handle the case of GPG_ERR_EEXIST.

--

GnuPG-bug-id: 7332
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-16 10:04:18 +09:00
Werner Koch
374195e741
gpgsm: Fix cached istrusted lookup.
* sm/call-agent.c (gpgsm_agent_istrusted): Actually set istrusted
list.
--

Fixes-commit: 9087c1d3637cf1c61744ece0002dc0dc5675d7c9
2024-10-15 09:45:55 +02:00
Werner Koch
f8b1b7b4df
dirmngr: Print a brief list of URLs with LISTCRLS.
* dirmngr/crlcache.c (crl_cache_list): Print a summary of URLs.

* sm/call-dirmngr.c (gpgsm_dirmngr_run_command): Print a notice to
stdout if the dirmngr has been disabled.
--

GnuPG-bug-id: 7337
2024-10-14 16:48:37 +02:00
NIIBE Yutaka
f8bf5e01f7
build: Use AC_C_BIGENDIAN for detecting endian.
* acinclude.m4 (GNUPG_CHECK_ENDIAN): Remove.
* configure.ac (BIG_ENDIAN_HOST): Use AC_C_BIGENDIAN
to detect endian and set BIG_ENDIAN_HOST.

--

Reported-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-11 09:57:49 +09:00
NIIBE Yutaka
57dce1ee62
common,gpg,scd,sm: Fix for Curve25519 OID supporting new and old.
* common/util.h (openpgp_curve_to_oid): Add new argument to select OID
by OpenPGP version.
* common/openpgp-oid.c (openpgp_curve_to_oid): Implement returning
selected OID for Curve25519.
* common/openpgp-fpr.c (compute_openpgp_fpr_ecc): Follow the change,
selecting by the version.
* g10/export.c (match_curve_skey_pk): Likewise.
(transfer_format_to_openpgp): Likewise.
* g10/gpg.c (list_config): Likewise, print new OID.
* g10/keygen.c (ecckey_from_sexp): Likewise, selecting by the version.
* sm/encrypt.c (ecdh_encrypt): Likewise, don't care.
* sm/minip12.c (build_ecc_key_sequence): Likewise, new OID.
* scd/app-openpgp.c (ecdh_params, gen_challenge): Likewise, don't
care.
(ecc_read_pubkey, change_keyattr_from_string, ecc_writekey): Likewise,
old OID.

--

GnuPG-bug-id: 7316
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-08 15:25:41 +09:00
NIIBE Yutaka
f5703994d4
common,gpg,scd,sm: Use openpgp_oid_or_name_to_curve to get curve.
* common/sexputil.c (pubkey_algo_string): Use
openpgp_oid_or_name_to_curve.
* g10/card-util.c (current_card_status, ask_card_keyattr): Likewise.
* scd/app-piv.c (writekey_ecc): Likewise.
* sm/fingerprint.c (gpgsm_get_key_algo_info): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-08 14:58:29 +09:00
Werner Koch
b287fb5775
Implement GNUPG_ASSUME_COMPLIANCE envvar for testing
* common/compliance.c (assumed_de_vs_compliance): New.
(get_compliance_cache): Check envvar and fake compliance.
(gnupg_status_compliance_flag): Return 2023 for de-vs if in faked
mode.
* g10/gpg.c (gpgconf_list): For compliance_de_vs return 23 or 2023.
--

The user visible changes are that

   GNUPG_ASSUME_COMPLIANCE=de-vs gpgconf --list-options gpg \
     | awk -F: '$1=="compliance_de_vs" {print $8}'

returns 2023 if "compliance de-vs" is found in gpg.conf.  If
eventually the software is arpproved the returned value will be 23 and
not 1 as it was before.  Consumers should check whether they see value
of true (Kleopatra does this right now) and also check whether the
value is > 2000 and in this case print a beta/non-approved warning.

The envvar is currently used to assume that the underlying libgcrypt
is compliant and approved.  This is not yet the case but eventually
libgcrypt will announce this itself and from then on the envvar is not
anymore required for testing.
2024-10-07 09:59:26 +02:00
Werner Koch
e8858807bc
gpg: Emit status error for an invalid ADSK.
* g10/keygen.c (prepare_adsk): Emit status error.
--

This is useful for GPGME.

GnuPG-bug-id: 7322
2024-10-07 08:24:04 +02:00
Werner Koch
f8f6c6c761
gpgsm: Add compatibility flag no-keyinfo-cache
* sm/gpgsm.c (compatibility_flags): Add flag.
* sm/gpgsm.h (COMPAT_NO_KEYINFO_CACHE): New.
* sm/call-agent.c (gpgsm_agent_istrusted): Act upon it.
(gpgsm_agent_keyinfo): Ditto.
2024-10-04 12:24:00 +02:00
Werner Koch
241971fac0
gpgsm: Implement a cache for the KEYINFO queries.
* sm/gpgsm.h (struct keyinfo_cache_item_s): New.
(struct server_control_s): Add keyinfo_cache and keyinfo_cache_valid.
* sm/call-agent.c (keyinfo_cache_disabled): New flag.
(release_a_keyinfo_cache): New.
(gpgsm_flush_keyinfo_cache): New.
(struct keyinfo_status_parm_s): New.
(keyinfo_status_cb): Implement a fill mode.
(gpgsm_agent_keyinfo): Implement a cache.
* sm/server.c (reset_notify): Flush the cache.
* sm/gpgsm.c (gpgsm_deinit_default_ctrl): Ditto.
--

In almost all cases we have just a few private keys in the agent and
thus it is better to fetch them early.  This does not work in a
restricted connection but we take care and disable the cache in this
case.

This cache gives a a minor speed up.

GnuPG-bug-id: 7308
2024-10-02 16:45:09 +02:00
Werner Koch
ef2be95258
gpgsm: Use a cache for ISTRUSTED queries.
* sm/call-agent.c (struct istrusted_cache_s): New.
(istrusted_cache, istrusted_cache_valid): New.
(istrusted_cache_disabled): New.
(flush_istrusted_cache): New.
(struct istrusted_status_parm_s): New.
(istrusted_status_cb): Fill the cache.
(gpgsm_agent_istrusted): Implement a cache.
--

Not a really measurable performance improvements on Linux but maybe
somewhat on Windows (not yet tested).  However, it does not clutter
the log files with IPC calls returning NOT_TRUSTED.

GnuPG-bug-id: 7308
2024-10-02 16:45:01 +02:00
Werner Koch
4275d5fa7a
agent: Add option --status to the LISTRUSTED command.
* agent/trustlist.c (istrusted_internal): Add arg listmode and print
new status line in this mode.  Adjust callers.
(agent_listtrusted): Add new args ctrl and status_mode.  Get all
trusted keys and then call is_trusted_internal for all of them.

* agent/command.c (cmd_listtrusted): Add new option --status.
--

This allows in a non-restricted connection to list all trusted keys in
one go.
2024-10-01 18:07:32 +02:00
Werner Koch
f50dde6269
gpgsm: Possible improvement for some rare P12 files.
* sm/minip12.c (parse_shrouded_key_bag): Increase size of salt buffer.
--

Reported on the mailing list.  The change does not seem to have a big
regression risk, thus applied.  See below for the mail

# ------------------------ >8 ------------------------
https://lists.gnupg.org/pipermail/gnupg-users/2024-September/067312.html
2024-10-01 12:36:16 +02:00
Werner Koch
f197fe34f2
gpgconf: Add list flag to trusted-key et al.
* tools/gpgconf-comp.c (known_options_gpg): Add list flag to sume
options.
--

GnuPG-bug-id: 7313
2024-10-01 10:51:13 +02:00
NIIBE Yutaka
e789122578
gpg: Robust error handling for SCD READKEY.
* g10/keygen.c (ask_algo): List the card key only when it's valid.

--

GnuPG-bug-id: 7309
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2024-10-01 10:55:11 +09:00
Werner Koch
0e283a0ebc
gpgsm: Silence messages about dirmngr cache lookup failed.
* sm/certchain.c (find_up_dirmngr): Skip if we know that there is no
dirmngr.
2024-09-30 18:47:31 +02:00
Werner Koch
8190853642
gpgsm: Silence the fingerprint output in quiet mode.
* sm/certchain.c (ask_marktrusted): Avoid fingerprint printing in
quiet mode
--

And also don't print it anymore after the agent told us that the
feature has been disabled.
2024-09-30 18:33:26 +02:00
Werner Koch
ce0580a599
gpgsm: Use a cache to speed up parent certificate lookup.
* sm/gpgsm.h (COMPAT_NO_CHAIN_CACHE): New.
(struct cert_cache_item_s, cert_cache_item_t): New.
(struct server_control_s): Add parent_cert_cache.
* sm/gpgsm.c (compatibility_flags): Add "no-chain-cache".
(parent_cache_stats): New.
(gpgsm_exit): Print the stats with --debug=memstat.
(gpgsm_deinit_default_ctrl): Release the cache.
* sm/certchain.c (gpgsm_walk_cert_chain): Cache the certificates.
(do_validate_chain): Ditto.
--

This gives another boost of 30% (from 6.5 to 4.0 seconds in the test
environment with ~1000 certs).  do_validate_chain actually brings us
the speedup becuase the gpgsm_walk_cert_chain is not used during a key
listing.  For the latter we actually cache all certificates because
that was easier.

GnuPG-bug-id: 7308
2024-09-30 18:22:25 +02:00
Werner Koch
cb6c506e4e
sm: Optmize clearing of the ephemeral flag.
* kbx/keybox-search.c (keybox_get_cert): Store the blob clags in the
cert object.
* sm/certchain.c (do_validate_chain): Skip clearing of the ephemeral
flag if we know that it is not set.
--

GnuPG-bug-id: 7308
2024-09-27 15:50:51 +02:00
Werner Koch
ca953ae5f7
agent: Replace hack for old Libgcrypt versions for auto-expand-secmem.
* agent/gpg-agent.c (main) <oAutoExpandSecmem>: Use Libgcrypt const.
2024-09-27 10:59:49 +02:00
Werner Koch
19871fa08c
agent: Better diagnostic for a failed key unprotection.
* agent/findkey.c (unprotect): Print a diagnostic if unprotection
failed.
--

GnuPG-bug-id: 6375
2024-09-27 10:55:45 +02:00
Werner Koch
19f2f00bfd
gpg: Exclude expired trusted keys from the key validation process.
* g10/trustdb.c (copy_key_item): New.
(validate_keys): Use a stripped down UTK list w/o expired keys.
--

This patch makes sure that an expired trusted key is not used for
trust computation.  The test case is to delete a trusted key from the
keyring, import a copy of that key which has already expired, check
that a signed key is not anymore fully trusted and finally import a
prolonged version of the trusted key and check that the signed key is
now again fully trusted.

GnuPG-bug-id: 7200
2024-09-25 15:21:55 +02:00
Werner Koch
a0aea09264
gpg: Validate the trustdb after the import of a trusted key.
* g10/import.c (import_one_real): Rename non_self to non_self_or_utk.
If not set after chk_self_sigs check whether the imported key is an
ultimately trusted key.
--

The revalidation mark was only set if the imported key had a new key
signature.  This is in general correct but not if the imported key is
a trusted key.

GnuPG-bug-id: 7200
2024-09-25 15:21:30 +02:00