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

9971 Commits

Author SHA1 Message Date
NIIBE Yutaka
30d4eb97db
tkd: Support READCERT command.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-23 08:35:20 +09:00
NIIBE Yutaka
01eef54e2c
Merge branch 'master' into gniibe/t6364 2023-03-20 16:40:32 +09:00
NIIBE Yutaka
4c74236dc7
agent: Add TKD command support.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-20 13:42:47 +09:00
NIIBE Yutaka
512213d6ed
tkd: Fix PKSIGN.
Clean up confusion of hashing.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-20 11:08:51 +09:00
NIIBE Yutaka
e57c072ea6
tkd: Add RESTART command.
It will be useful, when TKDaemon will maintain a context for a
connection.

--

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-20 10:13:24 +09:00
NIIBE Yutaka
2c9e9e9294
agent: Fix diverting to TKDaemon.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-17 15:22:52 +09:00
NIIBE Yutaka
d0d728a5b7
tkd: Fix RSA PKSIGN.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-17 15:22:22 +09:00
NIIBE Yutaka
84dd9cf6c3
Fix PKSIGN to get data by EXTRA.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-17 15:22:00 +09:00
NIIBE Yutaka
18a4002eab
tkd: Implement READKEY, returning canon SEXP.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-17 15:20:42 +09:00
NIIBE Yutaka
22be07a08c
tkd: sorted out entities and initialize PKCS#11 on demand.
tkd: host side process which manages KEYs on TOKENs
     It's a KEYGRIP which identifies a KEY.
     it's TKD which administrates: where is a KEY on which TOKEN.
cryptoki (ck): access object of PKCS#11 API.  CRYPTOKI has slots.
token: abstraction of a device.
       Each slots has slot_id.  Slot_id corresponds a TOKEN.
       1:1 map between slot_id and TOKEN.
KEY: TOKEN may have multiple KEYs.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-17 11:37:11 +09:00
Werner Koch
f5347fbc25
dirmngr: Add framework to implement a fake CRL feature.
* dirmngr/fakecrl.c: New.
* dirmngr/dirmngr.h (opt): Add fake_crl.
* dirmngr/dirmngr.c (enum cmd_and_opt_values): Add oFakeCRL.
(opts): Add "fake-crl"
(parse_rereadable_options): Set opt.fake_crl.
* dirmngr/server.c (cmd_isvalid): Take care of fakce CRLs.
2023-03-16 14:52:28 +01:00
Werner Koch
e4ac3e7dec
gpgsm: New option --no-pretty-dn
* sm/gpgsm.c (oNoPrettyDN): New.
(opts): Add --no-pretty-dn.
(main): Implement.
* sm/gpgsm.h (opt): Add no_pretty_dn.
* sm/certdump.c (gpgsm_es_print_name): Act upon.
2023-03-16 09:46:05 +01:00
NIIBE Yutaka
a53441c8dd
tkd: Fix for rescanning the slot list.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-16 14:59:14 +09:00
Werner Koch
e5066f2d1c
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:07:42 +01:00
Werner Koch
56b65f33d2
gpgtar: Print a result status with skiupped 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:24:04 +01:00
Werner Koch
5118beeec1
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:42:12 +01:00
Werner Koch
2e065b4bd2
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-15 09:42:02 +01:00
NIIBE Yutaka
fcae367ab5
tkd: Check CKF_TOKEN_PRESENT, too.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-15 15:05:15 +09:00
NIIBE Yutaka
4a48149d84
tkd: Implement finalizer.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-15 14:44:18 +09:00
Werner Koch
6d792ae2eb
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/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.
--

This change is related to
GnuPG-bug-id: 6386
but should have no visible effect except for the removal of
option --disable-extended-key-format.
2023-03-13 08:53:50 +01:00
NIIBE Yutaka
5d515d7059
agent: Add oTkdaemonProgram.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-13 14:14:48 +09:00
Werner Koch
56ca164684
dirmngr: Add command "GETINFO stats".
* dirmngr/server.c (cmd_getinfo): New sub-command "stats".
(dirmngr_status_helpf): Allow for a CTRL of NULL.
* dirmngr/certcache.c (cert_cache_print_stats): Add arg ctrl and use
dirmngr_status_helpf.  Adjust all callers.
* dirmngr/domaininfo.c (domaininfo_print_stats): Ditto.

* sm/certchain.c (ask_marktrusted): Flush stdout before printing the
fingerprint.
2023-03-10 11:24:48 +01:00
NIIBE Yutaka
d0855b1204
agent: Call TKDaemon READKEY command.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-10 15:39:14 +09:00
Ben Kibbey
be77a7ab8a agent: Try to SETREPEATOK if the pinentry supports it.
* agent/call-pinentry.c (agent_get_passphrase): Do SETREPEATOK.
(agent_askpin): Ditto.

Signed-off-by: Ben Kibbey <bjk@luxsci.net>
2023-03-09 20:12:07 -08:00
Werner Koch
b52a0e244a
dirmngr: Distinguish between "no crl" and "crl not trusted".
* dirmngr/crlcache.h (CRL_CACHE_NOTTRUSTED): New.
* dirmngr/crlcache.c (cache_isvalid): Set this status.
(crl_cache_cert_isvalid): Map it to GPG_ERR_NOT_TRUSTED.
(crl_cache_reload_crl): Move diagnostic to ...
* dirmngr/crlfetch.c (crl_fetch): here.
* dirmngr/server.c (cmd_isvalid): Map it to GPG_ERR_NOT_TRUSTED.
* dirmngr/validate.c (check_revocations): Handle new status.  Improve
diagnostics.
* common/status.c (get_inv_recpsgnr_code): Map INV_CRL_OBJ.
* common/audit.c (proc_type_verify): Ditto.
--

This avoids repeated loading of CRLs in case of untrusted root
certificates.
2023-03-09 18:28:39 +01:00
NIIBE Yutaka
08ef809c5e
agent: Add divert to tkdaemon.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-09 14:38:19 +09:00
Werner Koch
65288fc52f
keyboxd: Allow import of v0 certificates.
* kbx/backend-support.c (be_is_x509_blob): Loose detection.
--

Here is a sample v0 cert:

-----BEGIN CERTIFICATE-----
MIIDAzCCAmwCEQC5L2DMiJ+hekYJuFtwbIqvMA0GCSqGSIb3DQEBBQUAMIHBMQsw
CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0Ns
YXNzIDIgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBH
MjE6MDgGA1UECxMxKGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9y
aXplZCB1c2Ugb25seTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazAe
Fw05ODA1MTgwMDAwMDBaFw0yODA4MDEyMzU5NTlaMIHBMQswCQYDVQQGEwJVUzEX
MBUGA1UEChMOVmVyaVNpZ24sIEluYy4xPDA6BgNVBAsTM0NsYXNzIDIgUHVibGlj
IFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkgLSBHMjE6MDgGA1UECxMx
KGMpIDE5OTggVmVyaVNpZ24sIEluYy4gLSBGb3IgYXV0aG9yaXplZCB1c2Ugb25s
eTEfMB0GA1UECxMWVmVyaVNpZ24gVHJ1c3QgTmV0d29yazCBnzANBgkqhkiG9w0B
AQEFAAOBjQAwgYkCgYEAp4gBIXQs5xoD8JjhlzwPIQjxnNuX6Zr8wgQGE75fUsjM
HiwSViy4AWkszJkfrbCWrnkE8hM5wXuYuggs6MKEEyyqaekJ9MepAqRCwiNPStjw
DqL7MWzJ5m+ZJwf15vRMeJ5t60aG+rmGyVTyssSv1EYcWskVMP8NbPUtDm3Of3cC
AwEAATANBgkqhkiG9w0BAQUFAAOBgQByLvl/0fFx+8Se9sVeUYpAmLho+Jscg9ji
nb3/7aHmZuovCfTK1+qlK5X2JGCGTUQug6XELaDTrnhpb3LabK4I8GOSN+a7xDAX
rXfMSTWqz9iP0b63GJZHc2pUIjRkLbYWm1lbtFFZOrMLFPQS32eg9K0yZF6xRnIn
jBJ7xUS0rg==
-----END CERTIFICATE-----
2023-03-08 16:09:56 +01:00
Werner Koch
d2d1db8860
gpg,gpgsm: New option --log-time
* g10/gpg.c (oLogTime): New.
(opts): Add "log-time".
(opt_log_time): New var.
(main): Implement.
* sm/gpgsm.c (oLogTime): New.
(opts): Add "log-time".
(opt_log_time): New var.
(main): Implement.
2023-03-08 15:10:52 +01:00
Werner Koch
2d088176b4
dirmngr: Minor code cleanup in the CRL cache.
* dirmngr/crlcache.c (INVCRL_TOO_OLD): New.
(INVCRL_UNKNOWN_EXTN, INVCRL_GENERAL): New.
(open_dir, crl_cache_insert): Use the new constants.
(list_one_crl_entry): Make diagnostics robust for new INVCRL codes.
2023-03-08 14:37:50 +01:00
Werner Koch
2a13f7f9dc
gpgsm: Strip trailing zeroes from detached signatures.
* common/ksba-io-support.c: Include tlv.h
(struct reader_cb_parm_s): Add new fields.
(starts_with_sequence): New.
(simple_reader_cb): Handle stripping.
* common/ksba-io-support.h (GNUPG_KSBA_IO_STRIP): New.
(gnupg_ksba_create_reader): Handle the new flag.
* sm/verify.c (gpgsm_verify): Use the new flag for detached
signatures.
--

Note that this works only if --assume-binary is given.  The use case
for the feature is PDF signature checking where the PDF specs require
that the detached signature is padded with zeroes.
2023-03-08 11:00:00 +01:00
NIIBE Yutaka
c3dee068f9
Implement READKEY command.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-08 14:30:33 +09:00
NIIBE Yutaka
4e391d95e0
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:33:18 +09:00
NIIBE Yutaka
86d1d3ecd2
Add login feature.
Tested with YKCS#11 ECDSA and SoftHSM2 RSA.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-06 14:08:04 +09:00
NIIBE Yutaka
e944cead95
Use two-phase sign to match PKCS#11 API.
Tested Scute for RSA and ECDSA.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-06 11:53:07 +09:00
NIIBE Yutaka
6f5debd36a
Fix the length of ECDSA.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-06 11:16:03 +09:00
NIIBE Yutaka
aa8c5d12ef
Fix keygrip computation.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-03 20:44:24 +09:00
NIIBE Yutaka
395bcbc0ff
Fix listing keys.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-03 18:19:12 +09:00
Werner Koch
6bfb4a8d12
doc: Typo fixes and new notes in DETAILS
--
2023-03-03 08:50:08 +01:00
NIIBE Yutaka
22f945cf30
Implement token_keyinfo.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-03 14:39:12 +09:00
NIIBE Yutaka
601e1e28df
Add key->flags member.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-03 14:02:04 +09:00
NIIBE Yutaka
20ba5794bf
Fix assuan context things.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-03 12:02:07 +09:00
NIIBE Yutaka
ef83c46362
Implement token_sign.
Still assuan_context_t should be fixed.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-02 15:13:59 +09:00
NIIBE Yutaka
338736c0fe
Move functions.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-03-02 13:01:45 +09:00
Werner Koch
ef5a48dd51
gpg: Actually encrypt 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.
--

GnuPG-bug-id: 6395
2023-03-01 19:16:12 +01:00
Werner Koch
3a18378a92
gpg: Allow adding of Additional Decryption Subkeys.
* g10/free-packet.c (copy_public_key): Factor some code out to ...
(copy_public_key_basics): new.
* g10/build-packet.c (build_sig_subpkt_from_sig): New arg signhints.
* g10/packet.h (PUBKEY_USAGE_RENC): Fix value.
(SIGNHINT_KEYSIG, SIGNHINT_SELFSIG): Moved from sign.c.
(SIGNHINT_ADSK): New.
(PKT_public_key): Change pubkey_usage from byte to u16.
(PKT_user_id): Cosmetic fix: change help_key_usage from int to u16.
* g10/getkey.c (parse_key_usage): Make public.
* g10/misc.c (openpgp_pk_algo_usage): Take PUBKEY_USAGE_RENC in
account.
* g10/sign.c (update_keysig_packet): Set SIGNHINT_ADSK.
(make_keysig_packet): Ditto.
(do_sign): No time warp check in ADSK mode.
* g10/sig-check.c (check_signature_metadata_validity): Ditto.
* g10/keygen.c (struct opaque_data_usage_and_pk): Remove.
(write_keybinding): Do not use the removed struct.
(do_add_key_flags): Support PUBKEY_USAGE_RENC and others.
(keygen_add_key_flags_and_expire): Rewrite and make public.
* g10/keyedit.c (enum cmdids): Add cmdADDADSK.
(keyedit_menu): Add command "addadsk".
(menu_addadsk): New.
--

This makes use of a new encryption flag:

  The "restricted encryption key" (2nd,0x04) does not take part in any
  automatic selection of encryption keys.  It is only found on a
  subkey signature (type 0x18), one that refers to the key the flag
  applies to.

Followup patches will add encryption support and a --quick command.

GnuPG-bug-id: 6395
2023-03-01 17:22:20 +01:00
Werner Koch
1aaadede76
agent: Show "no secret key" instead of "card removed".
* agent/findkey.c (agent_key_from_file): Check the error of
read_key_file again.
* agent/pkdecrypt.c (agent_pkdecrypt): Restore error if no card was
found.  Also remove useless condition.
--

The first patch fixes a likely merge error.  The second is about the
actual return code: If we have no smardcard but simply try to decrypt
with the current smartcard we should return the originla error code.

GnuPG-bug-id: 5170
Fixes-commit: eda3c688fc2e85c7cd63029cb9caf06552d203b4
2023-03-01 16:49:40 +01:00
Werner Koch
523b3e1773
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:41:20 +01:00
NIIBE Yutaka
5055718fec
Define routines for pkcs11.c in the header.
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-02-27 18:41:31 +09:00
NIIBE Yutaka
d30ce02dd6
Start tkdaemon to offer PKCS#11 module access.
Currently, it's a mock-up.

Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
2023-02-27 15:54:14 +09:00
Werner Koch
5d96aab27d
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:14:22 +01:00