1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-11 21:48:50 +01:00
Commit Graph

8987 Commits

Author SHA1 Message Date
Werner Koch
ea28689547
gpgtar: Emit FAILURE status line.
* tools/gpgtar.c (main): Write status line before exit.
--

Due to the new way we support gpgtar in GPGME we need status lines to
detect a final error.

GnuPG-bug-id: 6497
2023-05-26 15:55:54 +02:00
Werner Koch
7cf8c5c291
agent: Fix printed error in findkey.
* agent/findkey.c (agent_write_private_key): Fix error reporting.
2023-05-26 14:20:07 +02:00
NIIBE Yutaka
fe881167c5
agent,w32: Fix resource leak for a process.
* agent/call-scd.c (agent_scd_check_aliveness): Call assuan_set_flag
only for !HAVE_W32_SYSTEM.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-26 10:08:07 +09:00
Werner Koch
a391d8f4be
gpg: Skip keys found via ADSKs.
* g10/encrypt.c (write_pubkey_enc): Indicate encryption to an ADSK.
* g10/getkey.c (finish_lookup): Skip ADKS keys.
--

If a key is searched by fingerprint or keyid and it happens that this
is an ADSK (subkey with the RENC usage), we need to skip this key
because it is not the key we actually want to encrypt to.  The actual
ADSK key is taken later by looking at all subkeys of the actual
selected key.

This is related to
GnuPG-bug-id: 6504
2023-05-25 16:54:29 +02:00
Werner Koch
625fb54899
w32: Add missing manifests and set a requestedExecutionLevel.
* agent/gpg-agent.w32-manifest.in: New.
* dirmngr/dirmngr-client-w32info.rc: New.
* dirmngr/dirmngr-client.w32-manifest.in: New.
* dirmngr/dirmngr-w32info.rc: New.
* dirmngr/dirmngr.w32-manifest.in: New.
* dirmngr/dirmngr_ldap-w32info.rc: New.
* dirmngr/dirmngr_ldap.w32-manifest.in: New.
* g10/gpgv-w32info.rc: New.
* g10/gpgv.w32-manifest.in: New.
* kbx/keyboxd.w32-manifest.in: New.
* scd/scdaemon.w32-manifest.in: New.
* sm/gpgsm.w32-manifest.in: New.
--

This avoids the use of the VirtualStore uner Windows.

GnuPG-bug-id: 6503

Backported from 2.4; some manifest files already existed in 2.2 but
not in 2.4
2023-05-25 11:10:21 +02:00
NIIBE Yutaka
709ab03bc2
common: Fix parsing ECC key.
* common/sexputil.c (get_ecc_q_from_canon_sexp): Initialize ECC_Q_LEN.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-10 10:09:55 +02:00
NIIBE Yutaka
c40e764108
scd: Fix cmd_apdu on error.
* scd/command.c (cmd_apdu): Fix the code path on error.

--

GnuPG-bug-id: 6476
Reported-by: Robin Krahl
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-05-10 10:08:27 +02:00
Werner Koch
ed3b285cdc
kbx: For non-Windows use 64k buffers by default instead of 128k.
* kbx/keybox-init.c (DEFAULT_LL_BUFFER_SIZE): New.
--

A simple gpg --check-sigs benchmark showed on Linux a small
performance peak at around 64k (5m52 vs. 6m8 for 128k and 6m33 for
system size).
2023-05-10 10:07:41 +02:00
Werner Koch
69b0fa55f6
kbx: Use custom estream buffering
* kbx/keybox-init.c (ll_buffer_size): New var intialized to 128k
(stream_buffers): New var.
(keybox_set_buffersize): New.
(_keybox_ll_open, _keybox_ll_close): Implement buffering.

* sm/gpgsm.c (oKbxBufferSize): New.
(opts): Add option --kbx-buffer-size.
(main): Call keybox_set_buffersize.

* g10/gpg.c: Include keybox.h.
* (oKbxBufferSize): New.
(opts): Add option --kbx-buffer-size.
(main): Call keybox_set_buffersize.
--

Commit message from 2.4:

Running a test on Windows using a pubring.kbx with
Total number of blobs:     2098
              openpgp:     1294
                 x509:      803
and a size of 42MiB with

gpgsm -k --with-validation --disable-dirmngr --kbx-buffer-size N >nul

gives these performance figures using procmon

| N(k) | file events | time(s) |
|------+-------------+---------|
|    0 |     4900000 |      86 |
|   16 |     2456000 |      58 |
|   32 |     1233000 |      43 |
|   64 |      622000 |      37 |
|  128 |      317000 |      32 |
|  256 |      164000 |      31 |
|  512 |       88000 |      30 |

Using _open instead of CreateFile give the same number of file events
but increased the time slight by one second for the measured buffer
size of 64k and 128k.   Benchmarks for gpg have not been conducted.
2023-05-10 10:07:32 +02:00
Werner Koch
0a4ccab3bd
kbx: Use wrapper functions for es_fclose and es_fopen.
* kbx/keybox-defs.h (KEYBOX_LL_OPEN_READ)
(KEYBOX_LL_OPEN_UPDATE, KEYBOX_LL_OPEN_CREATE): New.
* kbx/keybox-init.c (_keybox_ll_open): New.  Replace all keybox use of
es_fopen by this function.
(_keybox_ll_close): New.  Replace all keybox use of es_fclose by this
function.
--

Note that this has not been done for the utilities and the backend-kbx
of keyboxd.
2023-05-10 10:05:34 +02:00
Werner Koch
9526d4f721
kbx: Add extra flags to fopen for use by Windows.
* kbx/keybox-search.c (open_file): Use sysopen and sequential.
* kbx/keybox-update.c (create_tmp_file): Ditto.
(blob_filecopy): Ditto.
(keybox_set_flags): Ditto.
(keybox_delete): Ditto.
(keybox_compress): Ditto.
--

Under Windows "sysopen" requests that direct API calls (CreateFile et
al.) are used instead of the libc wrappers.  This may or may not
improve the performance.

Using "sequential" is a hint to Windows to assume that a file is in
general access in a sequential manner.  This will have an affect only
with a future libgpg-error.
2023-05-10 09:57:10 +02:00
Werner Koch
b73ced9386
gpgsm: Cache the non-existence of the policy file.
* sm/certchain.c (check_cert_policy): Add simple static cache.
--

It is quite common that a policy file does not exist.  Thus we can
avoid the overhead of trying to open it over and over again just to
assert that it does not exists.
2023-05-10 09:52:33 +02:00
NIIBE Yutaka
cfb1c66ef6
po: Update Japanese Translation.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-04-26 13:43:33 +09:00
NIIBE Yutaka
464e85d435
common: Incorporate upstream changes of regexp.
* regexp/jimregexp.c (regatom): Raise REG_ERR_UNMATCHED_BRACKET when
no matching end bracket.
(regmatch): Fix the end of word check.

--

Original changes:
	Signed-off-by: Steve Bennett <steveb@workware.net.au>

GnuPG-bug-id: 6455
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-04-21 11:57:30 +09:00
Werner Koch
e60544520b
scd,p15: Enforce a min. PIN length for certain cards.
* scd/app-p15.c (verify_pin): Enforce 6 for RSCS cards.
2023-04-20 12:42:08 +02:00
Werner Koch
3ad4b339b8
common: Fix minor bug in the jimregexp code.
* regexp/jimregexp.c (regatom): Make error checking for stray
backslash at end of the string work.  Check that the pattern class is
closed by a bracket.
--

GnuPG-bug-id: 6455
Co-authored-by: Guldrelokk
2023-04-20 12:28:09 +02:00
Eva Bolten
d9a4517d62
po: Fix in German translation
--
2023-04-06 10:21:52 +02:00
Werner Koch
b349ceedfc
gpg: Take care not to encrypt with OCB in de-vs mode
* g10/encrypt.c (use_aead): In de-vs mode use OCB only if the
compatibility flag ist set.
2023-04-06 09:21:33 +02:00
Werner Koch
04f1d9649c
speedo: Fix regression due to switching from gcc 8.3 to 10.2
* build-aux/speedo.mk (speedo_pkg_zlib_make_args): Use -static-libgcc.
2023-03-28 10:39:35 +02:00
Werner Koch
5e33ae3ab4
build: Remove obsolete --with-regex from autogen.rc
--

We always use the included regex library.  This patch avoids a
warning when building for Windows.
2023-03-27 12:51:46 +02:00
Werner Koch
3ec685d32f
doc: Remove the obsolete VS-NfD.prf
--

The apply-profile thing is not anymore used.
2023-03-27 12:28:53 +02:00
Werner Koch
fc351de879
gpg,gpgsm: Extend the use of allow-ecc-encr and vsd-allow-ocb
* g10/keygen.c (keygen_set_std_prefs): Set OCB only with VSD
compatibility flag.
* sm/certreqgen.c (proc_parameters): All ECC generation only with
allow-ecc-encr.
--
2023-03-24 13:50:37 +01:00
Werner Koch
da04477631
gpgtar: Do not allow the use of stdout for --status-fd
* tools/gpgtar.c (main): Don't allow logging via the Registry.  Forbid
using stdout for status-fd in crypt mode.
--

Without that check a status output would be mixed up with the input to
the internal call of gpg.

Using the Registry key to enable logging is very annoying.
2023-03-15 12:05:45 +01:00
Werner Koch
0045583cd2
gpgtar: Print a result status with skipped files.
* tools/gpgtar.h (struct tarinfo_s): Add new fields.
* tools/gpgtar-extract.c (check_suspicious_name): Add arg info.
(extract_regular): Count files.
(gpgtar_extract): Print stats.
2023-03-15 11:50:34 +01:00
Werner Koch
ed9a420a22
gpgtar: Emit progress status lines in create mode.
* tools/gpgtar.h (opt): Add field status_stream.
* tools/gpgtar.c (main): Set status_stream.
* tools/gpgtar-create.c (global_header_count): Rename to
global_total_files.
(global_written_files): New.
(global_total_data, global_written_data): New.
(struct scanctrl_s): Add field file_count.
(write_progress): New.
(write_file): Add arg skipped_open. Don't bail out immediatly on open
error.  Write progress lines.
(gpgtar_create): Write progress lines.  Print info aout skipped files.
--

GnuPG-bug-id: 6363
(cherry picked from commit f84264e8ac)
2023-03-15 11:28:16 +01:00
Werner Koch
706d557a64
gpg: Delete secret key after "keytocard".
* g10/card-util.c (card_store_subkey): Add arg processed_keys.
* g10/keyedit.c (keyedit_menu): Delete secret key.
--

This used to work using the gpg-agent: learn we called at "save" time.
However, the recent change inhibited the creation of a shadow key by
learn if a regular key still exists.  Now we do an explicit delete key
at save time.  This syncs the behaviour with the description of the
man page.

GnuPG-bug-id: 6378
2023-03-15 09:36:36 +01:00
Werner Koch
2630872cff
scd,openpgp: Switch key attributes between RSA and ECC in writekey.
* common/sexputil.c (get_rsa_pk_from_canon_sexp): Also allow private
keys.
(pubkey_algo_string): Ditto.
* scd/app-openpgp.c (do_writekey): Switch key attributes
--

The scd WRITEKEY command for OpenPGP cards missed proper support to
aautomagically switch key attributes based on the new key.  We had
this only in GENKEY.

GnuPG-bug-id: 6378
2023-03-14 16:16:40 +01:00
Werner Koch
08cc349114
gpg: Allow no version information of Yubikey
* g10/call-agent.c (learn_status_cb): Set is_v2 always for Yubikeys.
--

GnuPG-bug-id: 5100, 6378
Backported-from-master: 1cd615afe3
2023-03-14 11:28:41 +01:00
Werner Koch
b28d9ff865
agent: Do not overwrite a key file by a shadow key file.
* agent/findkey.c: Remove assert.h and use log_assert all over the
file.
(fname_from_keygrip): Add arg for_new.
(is_shadowed_key): New.
(agent_write_private_key): Rewrite to use read, write to new file,
rename pattern.  Ignore attempts to overwrite a regular key file by a
shadow key file.
(read_key_file): Move all cleanup code to the end of the function.
--

GnuPG-bug-id: 6386
I am not shure whether we should allow overwriting with FORCE set.
2023-03-14 10:09:41 +01:00
Werner Koch
4f754caad8
agent: Make --disable-extended-key-format a dummy option.
* agent/agent.h (opt): Remove enable_extended_key_format.
* agent/gpg-agent.c (enum cmd_and_opt_values): Turn
oDisableExtendedKeyFormat and oEnableExtendedKeyFormat into dummy
options.

* agent/protect.c (do_encryption): Remove arg use_ocb and
corresponding code.
(agent_protect): Ditto.  Change all callers.

* agent/command.c (cmd_readkey): Do not test for key availability here
but defer that agent_write_shadow_key.

* agent/findkey.c (agent_write_private_key): Simplify due to the
removal of disable-extended-key-format.
(write_extended_private_key): Fold into agent_write_private_key.
Remove the maybe_update arg.
(agent_write_shadow_key): Ditto.  Simplify.
--

GnuPG-bug-id: 6386
Backported-from-master: 6d792ae2eb
But with large changes to get 2.2 more aligned with master again.  This
is not finished; in particular the bug is not fixed; this comes wit
the next patch.
2023-03-13 12:28:10 +01:00
Werner Koch
db73f17f0c
gpgconf,w32: Also print a GnuPG Install Directory Registry entry
* tools/gpgconf.c (show_other_registry_entries): Add another dir.
2023-03-13 07:45:08 +01:00
NIIBE Yutaka
abcf0116ee
scd: Fix checking memory allocation.
* scd/app-openpgp.c (read_public_key): Fix the memory.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-08 11:04:15 +01:00
Ingo Klöcker
37d7ee8b98
agent: Add translatable text for Caps Lock hint
* agent/call-pinentry.c (start_pinentry): Add new default text.
--

GnuPG-bug-id: 4950
(cherry picked from commit b2a6e5b516)
2023-03-07 14:08:38 +01:00
Werner Koch
e4f61df850
gpg: Implement encryption to ADSKs.
* g10/getkey.c (get_pubkey_fromfile): Add optional arg r_keyblock.
* g10/pkclist.c (find_and_check_key): Also encrypt to RENC subkeys.
* g10/getkey.c (parse_key_usage): Make public.
* g10/misc.c (openpgp_pk_algo_usage): Take PUBKEY_USAGE_RENC in
account.
* g10/packet.h (PKT_public_key): Change pubkey_usage from byte to u16.
(PKT_user_id): Cosmetic fix: change help_key_usage from int to u16.
* g10/sig-check.c (check_signature_metadata_validity): Handle time
conflict for ADSKs.
--

GnuPG-bug-id: 6395

This patch handles ADSK keys and encrypts to them.  It does not yet
allow the creation of them.  We backport this from master early to get
this part of the code out into the field.
2023-03-03 10:09:47 +01:00
Werner Koch
fde59f9ae6
gpg: Get the signature keyid from the issuer fpr.
* g10/parse-packet.c (parse_signature): Parse the ISSUER_FPR subpacket
and use that to get the keyid.
--

Because ADSKs are created w/o the issuer subpacket (despite that this
is still a v4 signature) we need to get the key id from the
issuer_fpr.  This does not harm and we still fallback to the the
issuer.  Note that for ease of future backporting we also take v5
fingerprints into account.
2023-03-03 10:09:45 +01:00
Werner Koch
202ed9e281
gpg: Support key flags for RENC, TIME, and GROUP.
* g10/packet.h (PUBKEY_USAGE_RENC): New.
(PUBKEY_USAGE_TIME): New.
(PUBKEY_USAGE_GROUP): New.
* g10/getkey.c (parse_key_usage): Set the new key flags.
* g10/keyedit.c (show_key_with_all_names_colon): Show the new key
flags.
* g10/keyid.c (usagestr_from_pk): Ditto
* g10/keylist.c (print_capabilities): Ditto.
* g10/keygen.c (parse_usagestr): Parse line and set new flags.
(quickgen_set_para): Show flags.
--

See draft-koch-openpgp-2015-rfc4880bis-00 for the current version.
Actually these flags have been in the draft for years now.  This patch
is a first step to make use of them.
2023-03-03 09:04:29 +01:00
Werner Koch
a5d9be1e28
gpgconf: Print some standard envvars with -X
* tools/gpgconf.c (show_configs): Add a list of envvars and print
them.
--

Note that for simplicity we to not distinguish between Windows and
Linux here.
2023-02-28 14:43:53 +01:00
Werner Koch
ffc2522855
gpgsm: Improve cert lookup callback from dirmngr.
* sm/gpgsm.h (FIND_CERT_ALLOW_AMBIG): New.
(FIND_CERT_WITH_EPHEM): New.
* sm/certlist.c (gpgsm_find_cert): Replace arg allow_ambiguous by a
generic flags arg.  Implement the new flag FIND_CERT_WITH_EPHEM.
* sm/call-dirmngr.c (inq_certificate): Return also ephemeral marked
certs.
--

The dirmngr may need to get a certificate from gpgsm's store in the
course of verifying a CRL.  In some cases the certificate is still
marked as epehemeral - this needs to be returned as well.

This _may_ also fix
GnuPG-bug-id: 4436
2023-02-26 19:11:27 +01:00
Werner Koch
332098a0f7
sm: Fix issuer certificate look error due to legacy error code.
* sm/certchain.c (find_up): Get rid of the legacy return code -1 and
chnage var name rc to err.
(gpgsm_walk_cert_chain): Change var name rc to err.
(do_validate_chain): Get rid of the legacy return code -1.

* sm/keydb.c (keydb_search): Replace return code -1 by
GPG_ERR_NOT_FOUND.
(keydb_set_cert_flags): Replace return code -1 by GPG_ERR_NOT_FOUND.
* sm/certchain.c (find_up_search_by_keyid): Ditto.
(find_up_external, find_up, find_up_dirmngr): Ditto.
(gpgsm_walk_cert_chain): Ditto.
(get_regtp_ca_info): Ditto.
* sm/certlist.c (gpgsm_add_to_certlist): Ditto.
(gpgsm_find_cert): Ditto.
* sm/delete.c (delete_one): Ditto.
* sm/export.c (gpgsm_export): Ditto.
(gpgsm_p12_export): Ditto.
* sm/import.c (gpgsm_import_files): Ditto.
* sm/keylist.c (list_cert_colon): Ditto.
(list_internal_keys): Ditto.
* sm/sign.c (add_certificate_list): Ditto.

--

This bug was detected while fixing
GnuPG-bug-id: 4757
Backported-from-master: 473b83d1b9

Some extra code has been taken from
commit ed6ebb696e
2023-02-24 17:46:39 +01:00
NIIBE Yutaka
d6aa8bcbbb
scd: Parse "Algorithm Information" data object in scdaemon.
* scd/app-openpgp.c (data_objects): 0x00FA for binary data.
(do_getattr): Parse the data and send it in status lines.
(get_algorithm_attribute_string): New.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
Backported-from-master: eba2563dab
Backported-from-master: 43bbc25b0f
2023-02-17 13:04:09 +01:00
Werner Koch
1915b95ffd
scd:p15: Add pre-check for ascii-numeric PINs.
* scd/app-p15.c (verify_pin): ascii-numeric is different than BCD.

(cherry picked from commit 029924a46e)
Added a few typo fixes.
2023-02-17 12:15:08 +01:00
Werner Koch
326f6fa166
scd:p15: Use APP_CARD macro at some other places.
--

This makes back porting easier.
2023-02-17 12:09:57 +01:00
Werner Koch
adf387b3f1
scd: Improve reading of binary records.
* scd/iso7816.c (iso7816_read_binary_ext): Handle the 0x6a86 SW the
same as 6b00.
* scd/apdu.c (apdu_get_atr): Modify debug messages.
* scd/app-p15.c (app_select_p15): Print FCI on error.
(read_p15_info): Clean up diag in presence of debug options.
--

Some cards return 6a86 instead of 6b00.

Signed-off-by: Werner Koch <wk@gnupg.org>
Backported-from-master: 44f977d0e3
2023-02-17 12:02:35 +01:00
Werner Koch
88606cc484
scd:p15: Handle cards with bad encoded path objects.
* scd/app-p15.c (read_ef_prkdf, read_ef_pukdf)
(read_ef_cdf, read_ef_aodf): Allow for a zero length path and
correctly skip unsupported auth types.
--

Signed-off-by: Werner Koch <wk@gnupg.org>
Backported-from-master: 7a8545c91b
2023-02-17 11:38:57 +01:00
Werner Koch
1d6ed0a1b4
gpg: --gen-random code cleanup by using es_set_binary.
* g10/gpg.c (main): Replace setmode by es_set_binary and use only when
needed.
--

It is better to use our es_set_binary than to use a Windows specific
method which still worked but is fragile because estream might be
changed.  We now set binary only when needed.  Note that it does not
harm to call es_set_binary more often than needed.
2023-02-16 13:17:56 +01:00
Werner Koch
af9a1b5599
agent: Do not consider --min-passphrase-len for the magic wand.
* agent/call-pinentry.c (generate_pin): Lock to exactly 30 octets.
* g10/gpg.c (main) <aGenRandom>: Add Level 30.

(cherry picked from commit ae2f1f0785)
2023-02-16 12:12:55 +01:00
Werner Koch
1d8191faee
gpg: Add level 16 to --gen-random
* g10/gpg.c (main): Add that hack.
--

This is an yet undocumented hack to allow printing hex encoded random
number with gpg.  The level is forced to be 1 which is is good for
almost all uses.  Note that --armor is ignored.

Signed-off-by: Werner Koch <wk@gnupg.org>
Backported-from-master: d847f0651a
2023-02-16 12:05:03 +01:00
Werner Koch
67a2973bf9
gpg: Make "--list-options show-sig-subpackets=n,m" work again.
* g10/gpg.c (parse_list_options): Set value for show-sig-subpackets.
--

Fixes-commit: b6ba7054a0
2023-01-31 11:36:32 +01:00
Werner Koch
fbc1813779
gpgtar: Fix parent directory creation bug
* tools/gpgtar-extract.c (extract_directory): Ignore EEXIST on parent
directory creation.
2023-01-26 12:01:12 +01:00
Werner Koch
c66dacb98a
gpgtar: Allow decryption from stdin.
* tools/gpgtar.c (main): Revamp switch and fix usage test for aDecrypt
and aList.
--

GnuPG-bug-id: 6355
2023-01-26 11:58:25 +01:00