Commit Graph

9699 Commits

Author SHA1 Message Date
Werner Koch dd727ec968
scd: Renamed a constant in ccid-driver.c
* scd/ccid-driver.c (MAX_DEVICE): Rename to CCID_MAX_DEVICE.
--

Just for documentation reasons.
2022-04-14 10:26:40 +02:00
Werner Koch 6294ae282d
scd: Minor code reorganization
* scd/ccid-driver.c: Move struct defines to the top.
--
2022-04-14 10:15:23 +02:00
Werner Koch 8ac92f0e80
scd: Fix memory leak in ccid-driver.
* scd/ccid-driver.c (ccid_dev_scan): Use loop var and not the count.
--

Due to an assignment out of bounds this might lead to a crash if there
are more than 15 readers.  In any case it fixes a memory leak.
Kudos to the friendly auditor who found that bug.

Fixes-commit: 8a41e73c31
2022-04-14 10:15:23 +02:00
Werner Koch 61038be813
tests: Fix warning in common/t-ssh-utils.c
* common/t-ssh-utils.c (main): Remove continue.
--
Obvious c+p bug.

Fixes-commit: 5e508ffcab
2022-04-14 10:14:51 +02:00
Jakub Jelen c4436ebfa5 agent: Ignore MD5 Fingerprints for ssh keys
--
* agent/command-ssh.c (add_control_entry): Ignore failure of the MD5
  digest

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2022-04-14 11:47:04 +09:00
NIIBE Yutaka 5e508ffcab tests: Fix common/t-ssh-utils.
* common/t-ssh-utils.c (main): Accept an error with MD5 in_fips_mode.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-14 11:46:58 +09:00
Jakub Jelen 1f0651dbfb tests: Honor FIPS mode
* common/t-ssh-utils.c (FLAGS_NOFIPS): New.
  (sample_keys): Add flags member.
  (main): Detect if libgcrypt is in FIPS mode, try SHA256 fingerprints
  first and expect the MD5 ones will fail.
--

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2022-04-14 11:46:55 +09:00
Werner Koch 618aa8689a
scd:p15: Improve the PIN prompt for Genua cards.
* scd/app-p15.c (CARD_PRODUCT_GENUA): New.
(cardproduct2str): Add it.
(read_p15_info): Detect and set GENUA
(make_pin_prompt): Take holder string from the AODF.
2022-04-13 13:06:27 +02:00
Werner Koch 137e59a6a5
sm: Print diagnostic about CRL problems due to Tor mode.
* dirmngr/crlfetch.c (crl_fetch, crl_fetch_default)
(ca_cert_fetch, start_cert_fetch): Factor Tor error out to ...
(no_crl_due_to_tor): new.  Print status note.

* dirmngr/ks-engine-ldap.c (ks_ldap_get)
(ks_ldap_search, ks_ldap_put): Factor Tor error out to ...
(no_ldap_due_to_tor): new.  Print status note.

* dirmngr/ocsp.c (do_ocsp_request): Print status note.
* sm/misc.c (gpgsm_print_further_info): New.
* sm/call-dirmngr.c (warning_and_note_printer): New.
(isvalid_status_cb): Call it.
(lookup_status_cb): Ditto.
(run_command_status_cb): Ditto.

* common/asshelp2.c (vprint_assuan_status): Strip a possible trailing
LF.

--
2022-04-11 17:57:14 +02:00
Werner Koch 0dcc249852
scd: Support for GeNUA cards.
* scd/app-p15.c (read_p15_info): Disable extended mode for Genua
cards.
2022-04-11 17:48:45 +02:00
Werner Koch 198fad9fc1
doc: Typo fix in comment
--
2022-04-08 16:07:34 +02:00
Werner Koch ca3e46a587
tpm: Fix recently introduced syntax error
--

Fixes-commit: 18eff31496
2022-04-08 16:06:09 +02:00
Werner Koch 8945f1aedf
gpg: Remove restrictions for the name part of a user-id.
* g10/keygen.c (ask_user_id): Allow for the name to start with a
digit.  Allow names shorter than 5.
--

The reason for this change is that we don't enforce these constraints
in the --quick-gen-key interface.  I added the constraints right in the
beginning of gnupg to make sure that we have a uniform style for
user-ids.  However, this is all problematic with non-Latin names
and we prefer to use mail addresses anyway.
2022-04-08 16:03:12 +02:00
NIIBE Yutaka 9000081964 agent: Fix for possible support of Cygwin OpenSSH.
* agent/command-ssh.c (start_command_handler_ssh): Use es_sysopen.

--

With new (not-yet-released) libgpg-error, gpg-agent should be able to
handle connection from Cygwin version of OpenSSH.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-07 16:39:40 +09:00
NIIBE Yutaka b47a23f5fa w32: Exclude tests with HOME.
* common/t-session-env.c [HAVE_W32_SYSTEM] (test_all): HOME is not
defined, so, exclude the tests.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-06 13:28:15 +09:00
NIIBE Yutaka 39d478f5ba w32: Fix for make check.
* common/Makefile.am (module_tests): Exclude t-exechelp and
t-exectool.
* common/t-stringhelp.c (mygetcwd): Convert '\' to '/'.
* tests/cms/Makefile.am: Add $(EXEEXT).
* tests/gpgme/Makefile.am: Likewise.
* tests/migrations/Makefile.am: Likewise.
* tests/openpgp/Makefile.am: Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-06 11:28:00 +09:00
NIIBE Yutaka 48ee11722d agent:w32: Fix for use of socket.
* agent/command-ssh.c (get_client_info): Use type gnupg_fd_t for
socket, until call of socket API.
(start_command_handler_ssh): Don't convert here.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-04-04 16:39:27 +09:00
NIIBE Yutaka f584ad9504 scd,tpm2d: Fix for consistent use of socket FD.
* scd/command.c (scd_command_handler): Use gnupg_fd_t for the argument
but no INT2FD to listen.  Use GNUPG_INVALID_FD.
* tpm2d/command.c (tpm2d_command_handler): Likewise.
* scd/scdaemon.c (start_connection_thread): Follow the change.
* tpm2d/tpm2daemon.c (start_connection_thread): Likewise.
* scd/scdaemon.h (scd_command_handler): Use gnupg_fd_t.
* tpm2d/tpm2daemon.h (tpm2d_command_handler): Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-31 21:03:13 +09:00
NIIBE Yutaka 01ade6945d dirmngr: Fix for SOCK.
* dirmngr/http.c (connect_with_timeout): Use FD2INT to unwrap SOCK.

--

GnuPG-bug-id: 5899
Reported-by: Eli Zaretskii
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-30 13:05:41 +09:00
NIIBE Yutaka 18eff31496 tpm2d: Fix socket resource leak on Windows.
* tpm2d/tpm2daemon.c (main): Use gnupg_fd_t for socket, and use
assuan_sock_close for the socket allocated by assuan_sock_new.
(handle_connections): Use gnupg_fd_t for listen_fd.
Use assuan_sock_close for the socket by npth_accept.

--

Apply the same change of scdaemon to tpm2daemon.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-30 13:01:14 +09:00
NIIBE Yutaka 2189b4bb63 common,w32: Fix handle_to_fd to match use of _open_osfhandle.
* common/exechelp-w32.c (handle_to_fd): Use intptr_t.
(gnupg_wait_processes): Fix to use pid_to_handle.

--

Both of original MinGW and MinGW-W64 use intptr_t for the first
argument of _open_osfhandle.  So, intptr_t is better here.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-30 11:44:06 +09:00
NIIBE Yutaka d05221065f dirmngr: Clean up for not supporting WindowsCE.
* dirmngr/Makefile.am (dirmngr_SOURCES): Remove w32-ldap-help.h.
* dirmngr/cdblib.c (cdb_init): Remove for __MINGW32CE__.
* dirmngr/w32-ldap-help.h: Remove.

--

Fixes-commit: 4c295646ba
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-29 13:41:04 +09:00
NIIBE Yutaka 2cebba7274 gpg,tools: Remove use of repo only zlib-riscos.h.
* g10/compress.c: Don't use zlib-riscos.h.
* tools/gpgsplit.c: Likewise.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-29 12:07:18 +09:00
NIIBE Yutaka a67a09be30 scd,w32: Fix socket resource leak.
* scd/scdaemon.c (main): Use gnupg_fd_t for socket, and use
assuan_sock_close for the socket allocated by assuan_sock_new.
(handle_connections): Use gnupg_fd_t for listen_fd.
Use assuan_sock_close for the socket by npth_accept.

--

GnuPG-bug-id: 5029
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-29 09:55:02 +09:00
Werner Koch 435861b9fb
dirmngr: Escape more characters in WKD requests.
* dirmngr/server.c (proc_wkd_get): Also escape '#' and '+'
--
GnuPG-bug-id: 5902
2022-03-28 16:12:03 +02:00
Werner Koch 253fcb9777
gpg: Remove EAX from the preference list.
* g10/gpg.c (main): Remove note about rfc4880bis.
* g10/keygen.c (keygen_set_std_prefs): Use only OCB in the AEAD
preference list.
--

It is more than unlikely that EAX will ever be used in practice and
thus we remove it from the preference list.
2022-03-28 15:25:55 +02:00
NIIBE Yutaka f0a1c79f60 agent: KEYTOCARD prefers to specified time.
* agent/command.c (cmd_keytocard): Timestamp at "Created:" field is
only used when time is not specified.

--

Fixes-commit: c795be79c1
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-28 09:08:08 +09:00
Werner Koch 90caa7ad59
dirmngr: Workaround for a certain broken LDAP URL
* dirmngr/ldap.c (url_fetch_ldap): Detect and replace.
--

The actual URL causing this is

ldap://ldap.dgnservice.de:389/CN=CRL-1,O=DGN%20Service%20GmbH,\
C=DE?certificateRevocationList?base?objectClass=cRLDistributionPoint

It is actually not very helpful because I had problems finding the
issuer cert:

CN=dgnservice CRL2101 13:PN,O=DGN Deutsches Gesundheitsnetz \
Service GmbH,C=DE
2022-03-25 13:36:20 +01:00
Werner Koch 0f03bdcd2e
common,w32: Fix early home dir creation.
* common/homedir.c (w32_try_mkdir): Remove.
(standard_homedir): Call gnupg_mkdir directly.
(_gnupg_socketdir_internal): Ditto.
--
GnuPG-bug-id: 5895
2022-03-25 13:22:46 +01:00
NIIBE Yutaka caba9df726 tools:gpgconf: Fix gc_component table.
* tools/gpgconf-comp.c [!BUILD_WITH_TPM2D] (gc_component): Add a dummy
entry.

--

GnuPG-bug-id: 5701
Reported-by: Adriaan de Groot
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-25 14:28:22 +09:00
NIIBE Yutaka c795be79c1 agent: Use "Created:" field for creation time.
* agent/agent.h (agent_key_from_file): Change the declaration.
* agent/findkey.c (agent_key_from_file): Return timestamp.
* agent/pkdecrypt.c (agent_pkdecrypt): Follow the change.
* agent/pksign.c (agent_pkdecrypt): Likewise.
* agent/command.c (cmd_passwd, cmd_export_key): Likewise.
(cmd_keytocard): Use timestamp in private key file in "Created:".

--

GnuPG-bug-id: 5538
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-25 14:10:46 +09:00
NIIBE Yutaka 25d37a0a6a dirmngr: Suppress error message on trial reading as PEM format.
* dirmngr/dirmngr-client.c (read_pem_certificate): Add NO_ERRMSG
argument to suppress the error message.
(read_certificate, squid_loop_body): Follow the change.

--

GnuPG-bug-id: 5531
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-25 08:41:51 +09:00
NIIBE Yutaka 4d19759ce5 dirmngr: Clear the error count to try certificate as binary.
* dirmngr/dirmngr-client.c (read_certificate): Call
log_get_errorcount.

--

GnuPG-bug-id: 5531
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-24 13:55:32 +09:00
NIIBE Yutaka 01329da8a7 kbx: Fix searching for FPR20 in version 2 blob.
* kbx/keybox-search.c (blob_cmp_fpr_part): Don't change FPROFF, since
it's caller which tweaks the offset.
(has_short_kid, has_long_kid): Examine the key flags to determine if
fingerprint 32 or 20.

--

GnuPG-bug-id: 5888
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-24 13:21:03 +09:00
Werner Koch ed53d41b4c
gpgtar: New option --with-log
* tools/gpgtar.c: New option --with-log.
* tools/gpgtar.h (opt): Add field with_log.
* tools/gpgtar-extract.c (gpgtar_extract): Move directory string
building up.  Add option --log-file if needed.
* tools/gpgtar-create.c (gpgtar_create): Make tmpbuf static becuase it
is used outside of its scope.
* tools/gpgtar-list.c (gpgtar_list): Ditto.
2022-03-22 10:19:55 +01:00
Werner Koch 92c8ae720e
dirmngr: Make WKD_GET work even for servers not handling SRV RRs.
* dirmngr/server.c (proc_wkd_get): Take care of DNS server failures
--

Unfortunately there are resolver setups which don't handle SRV records
but return a server error.  We let a not found error pass, because
that merely means the domain does not exists.

GnuPG-bug-id: 4729
2022-03-21 22:38:22 +01:00
Werner Koch e5ef5e3b91
gpgtar: Finally use a pipe for decryption.
* tools/gpgtar.h (opt): Add new flags.
* tools/gpgtar.c: new options --batch, --yes, --no, --status-fd, and
--require-compliance.
(main): Init signals.
* tools/gpgtar-create.c: Add new header files.
(gpgtar_create): Rework to use a pipe for encryption and signing.
* tools/gpgtar-list.c: Add new header files.
(gpgtar_list): Rework to use a pipe for decryption.
* tools/gpgtar-extract.c: Add new header files.
(gpgtar_extract): Rework to use a pipe for decryption.
--

Fixes-commit: 40dbee86f3
2022-03-21 13:21:20 +01:00
NIIBE Yutaka 2f1afc1296 common: Fix another race condition, and address the other one.
* common/dotlock.c (dotlock_take_unix): Do same when same PID
process detects stale lockfile.  Add comment.

--

GnuPG-bug-id: 5884
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-19 14:47:59 +09:00
NIIBE Yutaka 0ba69e5581 gpg: Always use version >= 4 to generate signature.
* g10/sign.c (update_keysig_packet): Make sure sig->version >= 4.

--

GnuPG-bug-id: 5809
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-19 13:38:37 +09:00
Werner Koch 06b70daa50
gpg: Print info about the used AEAD algorithm in the compliance msg.
* g10/misc.c (openpgp_cipher_algo_mode_name): New.
* g10/decrypt-data.c (decrypt_data): Use function here.
--

Note that openpgp_cipher_algo_mode_name is different from the version
2.2 becuase we append ".CFB" here.

Without this change we would see

  gpg: cipher algorithm 'AES256' may not be used in
  --compliance=de-vs mode

This is confusing because AES256 is compliant.  Now we see

  gpg: cipher algorithm 'AES256.OCB' may not be used in
  --compliance=de-vs mode

which gives a hint on the problem.
2022-03-18 14:19:24 +01:00
Werner Koch 449d2fbcde
common: New function map_static_strings
* common/mapstrings.c (struct intmapping_s): New.
(map_static_strings): New.
* common/stringhelp.c (do_strconcat): Rename to ...
(vstrconcat): this and make global.

* common/t-mapstrings.c (test_map_static_strings): New test.
2022-03-18 14:14:39 +01:00
Werner Koch 8631d4cfe2
gpg: Allow decryption of symencr even for non-compliant cipher.
* g10/decrypt-data.c (decrypt_data): Add arg compliance_error.  Adjust
all callers.  Fail on compliance error only in --require-compliance
mode.  Make sure to return an error if the buffer is missing; actually
that should be an assert.
* g10/mainproc.c (proc_encrypted): Delay printing of the compliance
mode status.  Consult the compliance error now returned by
decrypt_data.
--

The actual case here is that we fail hard if a message has been AEAD
encrypted with one AEAD capable key and also with one passphrase.  In
general the preference system takes care of not using AEAD if one
recipient's key does not support it.  However, if the sender uses her
own AEAD-capable key _and_ a passphrase the message will be AEAD
encrypted.  This change allows to decrypt that anyway along with a
warning message.

Note that this does currently not work in 2.3 due to a non-compliant
libgcrypt.  We will however, backport this to 2.2.
2022-03-18 11:14:54 +01:00
Werner Koch 6d6438a361
common: New flags for gnupg_spawn_process
* common/exechelp.h (GNUPG_SPAWN_KEEP_STDIN): New.
(GNUPG_SPAWN_KEEP_STDOUT): New.
(GNUPG_SPAWN_KEEP_STDERR): New.
* common/exechelp-posix.c (do_exec): Add arg flags and implement new
flags.
* common/exechelp-w32.c (gnupg_spawn_process): Implement new flags.
2022-03-18 11:14:54 +01:00
NIIBE Yutaka d94b411f12 common: Fix a race condition removing stale lockfile.
* common/dotlock.c (read_lockfile): Return the file descriptor when
R_FD is available.
(dotlock_take_unix): Check the case the lockfile was already removed.

--

GnuPG-bug-id: 5884
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-18 14:33:53 +09:00
NIIBE Yutaka a30359cecb common: More heavy test condition for t-dotlock.c.
* common/t-dotlock.c (lock_and_unlock): Use usleep and faster.
Loop at least once.  Use getrandom for random time.
(main): Add new option --one-shot to run lock/unlock once.

--

GnuPG-bug-id: 5884
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-18 12:01:45 +09:00
NIIBE Yutaka c6dd9ff929 scd: Fix DEVINFO with no --watch.
* scd/app.c (app_send_devinfo): Fix for outputing once.
* scd/command.c (hlp_devinfo): Fix comment.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-15 15:19:11 +09:00
NIIBE Yutaka 665b59a066 Fix previous commit.
--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-11 14:09:22 +09:00
NIIBE Yutaka 934864d399 scd: Enhance PASSWD command to accept KEYGRIP optionally.
* scd/command.c (cmd_passwd): Handle KEYGRIP optionally.

--

GnuPG-bug-id: 5862
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-10 11:11:38 +09:00
NIIBE Yutaka d577ed2956 scd: Use same idiom for same work.
* scd/command.c (cmd_serialno, cmd_getattr): Use 'while' instead of
'for'.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2022-03-10 11:02:11 +09:00
Jakub Jelen eadf12a52c sign: Construct valid AEAD packets.
* g10/sign.c (sign_symencrypt_file): Insert correct version and AEAD
  information into symkey packet.

--

GnuPG-bug-id: 5856
Signed-off-by: Jakub Jelen <jjelen@redhat.com>
2022-03-09 11:06:42 +09:00