aboutsummaryrefslogtreecommitdiffstats
path: root/scd (unfollow)
Commit message (Collapse)AuthorFilesLines
2023-05-01scd: Fix cmd_apdu on error.NIIBE Yutaka2-2/+5
* scd/command.c (cmd_apdu): Fix the code path on error. -- GnuPG-bug-id: 6476 Reported-by: Robin Krahl Signed-off-by: NIIBE Yutaka <[email protected]>
2023-04-21gpg: Fix writing ECDH keys to OpenPGP smartcards.Werner Koch1-21/+65
* agent/command.c (cmd_keytocard): Add new arg for ECDH params. * scd/app-openpgp.c (ecc_writekey): Use provided ECDH params to compute the fingerprint. * g10/call-agent.c (agent_keytocard): Add arg ecdh_param_str. * g10/keyid.c (ecdh_param_str_from_pk): New. * g10/card-util.c (card_store_subkey): Pass ECDH params to writekey. * g10/keygen.c (card_store_key_with_backup): Ditto. * scd/app-openpgp.c (store_fpr): Add arg update. (rsa_read_pubkey, ecc_read_pubkey): Add arg meta_update and avoid writing the fingerprint back to the card if not set. (read_public_key): Also add arg meta_update. (get_public_key): Do not pass it as true here... (do_genkey): ... but here. (rsa_write_key, ecc_writekey): Force string the fingerprint. -- The problem showed up because in 2.4 we changed the standard ECDH parameter some years ago. Now when trying to write an ECDH key created by 2.2 with 2.4 to an openpgp card, scdaemon computes a wrong fingerprint and thus gpg was not able to find the key again by fingerprint. The patch also avoids updating the stored fingerprint in certain situations. This fix is somewhat related to GnuPG-bug-id: 6378
2023-04-20scd,p15: Enforce a min. PIN length for certain cards.Werner Koch1-5/+10
* scd/app-p15.c (verify_pin): Enforce 6 for RSCS cards.
2023-04-18scd: On a Yubikey re-select the last app after the use of APDU.Werner Koch3-2/+22
* scd/app-common.h (struct card_ctx_s): Add maybe_check_aid flag. * scd/command.c (cmd_apdu): Set it. * scd/app.c (check_external_interference): Consult this flag. (maybe_switch_app): Do a re-select if this flag is set. -- After the gpg-card tool has issued a Yubikey specific command the current application is not anymore correctly selected. This then results in all kind of errors. We detect this now and try to re-select the last app.
2023-04-17Fix use of GNUPG_PROCESS_DETACHED.NIIBE Yutaka1-4/+1
Signed-off-by: NIIBE Yutaka <[email protected]>
2023-03-15scd,openpgp: Switch key attributes between RSA and ECC in writekey.Werner Koch1-5/+30
* 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-08scd: Fix checking memory allocation.NIIBE Yutaka1-1/+1
* scd/app-openpgp.c (read_public_key): Fix the memory. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2023-02-23doc: Minor comment fixes.Werner Koch1-1/+1
--
2022-12-09scd:p15: Skip deleted records.Werner Koch1-8/+37
* scd/app-p15.c (select_and_read_record): Special case deleted records. Support 3 byte TLVs. (read_ef_prkdf): Skip deleted records. (read_ef_pukdf): Ditto. (read_ef_cdf): Ditto. (read_ef_aodf): Ditto. -- This fixes a problem with some CardOS 5 applications.
2022-11-29common: Support new spawn functions for Windows.NIIBE Yutaka1-0/+4
-- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-28Replace gnupg_spawn_process_detached for POSIX.NIIBE Yutaka1-5/+15
Signed-off-by: NIIBE Yutaka <[email protected]>
2022-11-17scd: Redact --debug cardio output of a VERIFY APDU.Werner Koch1-2/+16
* scd/apdu.c (pcsc_send_apdu) [DBG_CARD_IO]: Detect and redact a VERIFY. (send_apdu_ccid): Ditto. -- This should handle the most common case. GnuPG-bug-id: 5085
2022-11-15scd:nks: Fix ECC signing if key not given by keygrip.Werner Koch1-0/+2
* scd/app-nks.c (keygripstr_from_pk_file): Set r_algo if not in cache.
2022-10-25scd:nks: Support non-ESIGN signing with the Signature Card v2Werner Koch1-8/+20
* scd/app-nks.c (do_sign): Handle ECC for NKS cards
2022-09-14agent,dirmngr,gpg,scd: Clean up for modern compiler.NIIBE Yutaka2-1/+2
* agent/protect.c (agent_get_shadow_info_type): It's a write only variable, useful for debugging. * g10/key-check.c (key_check_all_keysigs): Likewise. * g10/keyedit.c (show_basic_key_info, menu_expire): Likewise. * scd/app-sc-hsm.c (read_ef_prkd): Likewise. * dirmngr/crlfetch.c (fetch_next_ksba_cert): Initialize the vars. * dirmngr/ks-action.c (ks_action_help): Remove unused variables. * dirmngr/server.c (make_keyserver_item): Likewise. * dirmngr/validate.c (check_cert_sig): Initialize the variable. * scd/app-p15.c (select_and_read_record): Likewise. * tests/gpgscm/scheme.c (scheme_init_new): A function with no args. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-09-13gpg,common,scd,sm: Function prototype fixes for modern compiler.NIIBE Yutaka1-1/+1
* common/gettime.c (gnupg_get_time): It has no arguments. * common/signal.c (gnupg_block_all_signals): Likewise. (gnupg_unblock_all_signals): Likewise. * common/utf8conv.c (get_native_charset): Likewise. * g10/cpr.c (is_status_enabled, cpr_enabled): Likewise. * g10/getkey.c (getkey_disable_caches): Likewise. * g10/keygen.c (ask_expiredate): Likewise. * g10/passphrase.c (have_static_passphrase): Likewise. (get_last_passphrase): Likewise. * g10/tdbio.c (tdbio_is_dirty, tdbio_sync): Likewise. (tdbio_get_dbname, open_db, tdbio_db_matches_options): Likewise. (tdbio_read_nextcheck): Likewise. * g10/trustdb.c (how_to_fix_the_trustdb): Likewise. * scd/scdaemon.c (scd_get_socket_name): Likewise. * sm/passphrase.c (have_static_passphrase): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-08-25scd: Add npth_unprotect/npth_protect for blocking operations.NIIBE Yutaka1-0/+20
* scd/ccid-driver.c (ccid_open_usb_reader): Name the thread. (ccid_vendor_specific_setup, ccid_open_usb_reader): Wrap blocking operations by npth_unprotect/npth_protect. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-08-22scd: Add a libusb debug level.Werner Koch1-1/+33
* scd/ccid-driver.c (USE_LIBUSB_DEBUG_CB): New const. (debug_libusb_cb): new. (ccid_set_debug_level): Use it. -- This allows to see the libusb log in our usual debug output. For this the option debug-ccid-driver needs to be given 5 or more times.
2022-07-28scd:opengpg: Minor vendor name fixWerner Koch1-1/+1
--
2022-07-28scd:openpgp: New vendorWerner Koch1-0/+1
--
2022-07-13scd:openpgp: Fix workaround for Yubikey heuristics.NIIBE Yutaka1-8/+21
* scd/app-openpgp.c (parse_algorithm_attribute): Handle the case of firmware 5.4, too. -- GnuPG-bug-id: 6070 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-06-10scd: Support specifying keygrip for learn command.NIIBE Yutaka1-2/+8
* scd/command.c (cmd_learn): Allow keygrip argument. -- GnuPG-bug-id: 6002 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-06-10scd,openpgp: Support READCERT by keygrip.NIIBE Yutaka1-1/+22
* scd/app-openpgp.c (do_readcert): Allow use of keygrip. -- GnuPG-bug-id: 6002 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-06-01scd:nks: Don't flag the ESIGN keypair EF as encryption capable.Werner Koch1-1/+1
* scd/app-nks.c (filelist): Tweak 0x4531. -- Actually the certificate has no encryption usage but we should also tell that via KEYINFO so that this key is never tried to create an encryption certificate.
2022-06-01scd:nks: Some code cleanup.Werner Koch1-107/+100
* scd/app-nks.c (find_fid_by_keyref): Factor keyref parsing out to ... (parse_keyref): new. (do_readcert): Use new function instead of partly duplicated code. Make detection of keygrip more robust. (do_readkey): Make detection of keygrip more robust. (do_with_keygrip): Use get_nks_tag. -- Also added a couple of comments.
2022-05-29scd:nks: Support the Telesec ESIGN application.Werner Koch1-26/+81
* scd/app-nks.c (find_fid_by_keyref): Disable the cache for now. (readcert_from_ef): Considere an all zero certificate as not found. (do_sign): Support ECC and the ESIGN application. -- This allows me to create qualified signatures using my Telesec card. There is of course more work to do but this is the first step. Note: The design of the FID cache needs to be reconsidered. Until that the lookup here has been disabled. The do_sign code should be revamped to be similar to what we do in app-p15. GnuPG-bug-id: 5219, 4938
2022-05-26scd: Return USAGE information for KEYINFO command.NIIBE Yutaka6-71/+103
* scd/command.c (hlp_keyinfo): Update. (send_keyinfo): Add a USAGE argument. * scd/scdaemon.h (send_keyinfo): Add a USAGE argument. * scd/app-nks.c (set_usage_string): New. (do_learn_status_core, do_readkey): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-openpgp.c (get_usage_string): New. (send_keypair_info): Use get_usage_string. (send_keyinfo_if_available): Add USAGE to call send_keyinfo, using get_usage_string. * scd/app-p15.c (set_usage_string): New. (send_keypairinfo): Use set_usage_string. (do_with_keygrip): Add USAGE to call send_keyinfo, using set_usage_string. * scd/app-piv.c (do_with_keygrip): Add USAGE to call send_keyinfo. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-26scd,piv: Fix status report of KEYPAIRINFO.NIIBE Yutaka1-1/+1
* scd/app-piv.c (do_readkey): Use "-" for usage when not available. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-25agent,scd: Make sure to set CONFIDENTIAL flag in Assuan.NIIBE Yutaka1-0/+2
* agent/call-scd.c (inq_needpin): Call assuan_begin_confidential and assuan_end_confidential, and wipe the memory after use. * agent/command.c (cmd_preset_passphrase): Likewise. (cmd_put_secret): Likewise. * scd/command.c (pin_cb): Likewise. -- GnuPG-bug-id: 5977 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-24scd: Support automatic card selection for READCERT with keygrip.NIIBE Yutaka1-1/+5
* scd/command.c (cmd_readcert): Select by KEYGRIP. -- GnuPG-bug-id: 6003 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-17scd: Fix use of SCardListReaders for PC/SC.NIIBE Yutaka1-1/+1
* scd/apdu.c (apdu_dev_list_start): Initialize NREADER. -- Reported-by: Ludovic Rousseau GnuPG-bug-id: 5979 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-11scd: Fail when no good algorithm attribute.NIIBE Yutaka1-19/+30
* scd/app-openpgp.c (parse_algorithm_attribute): Return the error. (change_keyattr): Follow the change. (app_select_openpgp): Handle the error of parse_algorithm_attribute. -- This change allows following invocation of app_select_openpgp, which may work well (if the problem is device side for initial connection). GnuPG-bug-id: 5963 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-10scd:openpgp: New card vendor.Werner Koch1-0/+1
-- BTW, we should add a function to read out the entire table so that you can ask scdaemon for that list. iirc, Kleopatra still uses a copy of the table.
2022-05-06scd:p15: Improve the displayed S/N for Technology Nexus cards.Werner Koch1-3/+36
* scd/app-p15.c (any_control_or_space_mem): New. (get_dispserialno): Add new code. -- This works with my test cards and now reflects what's printed on the front matter of the card.
2022-05-06scd:p15: Fix the the sanity check of the displayed S/N.Werner Koch1-2/+6
* scd/app-p15.c (any_control_or_space): Fix loop. -- This check is only done to avoid printing wrongly encoded S/N for human consumption. e
2022-05-06scd: Add workaround for ECC attribute on Yubikey.NIIBE Yutaka1-1/+2
* scd/app-openpgp.c (parse_algorithm_attribute): Skip possibly bogus octet in a key attribute. -- GnuPG-bug-id: 5963 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-05-05scd:p15: Fix reading certificates without length info.Werner Koch1-6/+23
* scd/app-p15.c (readcert_by_cdf): Do not use extended mode if the CDF object has no length info. Add debug output when reading a cert. (read_p15_info): No more need to disable extended mode for GeNUA cards.
2022-05-05scd: New debug flags "card".Werner Koch2-2/+5
* scd/scdaemon.c (debug_flags): Add "card". * scd/scdaemon.h (DBG_CARD_VALUE, DBG_CARD): New. -- Some information from parsing the card are often very helpful. However, the card_io triggered APDU dumps are in most cases too heavy. Thus this new debug flag.
2022-04-25scd: Fix hard-coded constant for RSA auth.NIIBE Yutaka1-3/+9
* scd/app-openpgp.c (do_auth): Allow larger data for RSA-4096. -- OpenPGPcard specification says that it will be rejected by the card when it's larger. We have been the check on host side too, but it was written when it only had a support for RSA-2048. Signed-off-by: NIIBE Yutaka <[email protected]>
2022-04-22scd: Don't inhibit SSH authentication for larger data if it can.NIIBE Yutaka1-0/+5
* scd/app-openpgp.c (do_auth): Use command chaining if available. -- GnuPG-bug-id: 5935 Signed-off-by: NIIBE Yutaka <[email protected]>
2022-04-14scd: Renamed a constant in ccid-driver.cWerner Koch1-3/+3
* scd/ccid-driver.c (MAX_DEVICE): Rename to CCID_MAX_DEVICE. -- Just for documentation reasons.
2022-04-14scd: Minor code reorganizationWerner Koch1-16/+22
* scd/ccid-driver.c: Move struct defines to the top. --
2022-04-14scd: Fix memory leak in ccid-driver.Werner Koch1-9/+9
* 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: 8a41e73c31adb86d4a7dca4da695e5ad1347811f
2022-04-13scd:p15: Improve the PIN prompt for Genua cards.Werner Koch1-4/+26
* 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-11scd: Support for GeNUA cards.Werner Koch1-1/+10
* scd/app-p15.c (read_p15_info): Disable extended mode for Genua cards.
2022-03-31scd,tpm2d: Fix for consistent use of socket FD.NIIBE Yutaka3-5/+5
* 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 <[email protected]>
2022-03-29scd,w32: Fix socket resource leak.NIIBE Yutaka1-23/+26
* 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 <[email protected]>
2022-03-15scd: Fix DEVINFO with no --watch.NIIBE Yutaka2-2/+2
* scd/app.c (app_send_devinfo): Fix for outputing once. * scd/command.c (hlp_devinfo): Fix comment. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-03-11Fix previous commit.NIIBE Yutaka1-1/+4
-- Signed-off-by: NIIBE Yutaka <[email protected]>
2022-03-10scd: Enhance PASSWD command to accept KEYGRIP optionally.NIIBE Yutaka1-3/+8
* scd/command.c (cmd_passwd): Handle KEYGRIP optionally. -- GnuPG-bug-id: 5862 Signed-off-by: NIIBE Yutaka <[email protected]>