summaryrefslogtreecommitdiffstats
path: root/scd/ccid-driver.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* indent: Fix spellingDaniel Kahn Gillmor2024-05-311-1/+1
| | | | | | | | | | | | | -- These are non-substantive corrections for minor spelling mistakes within the GnuPG codebase. With something like this applied to the codebase, and a judiciously tuned spellchecker integrated as part of a standard test suite, it should be possible to keep a uniform orthography within the project. GnuPG-bug-id: 7116
* scd: Improve code reability of ccid-driver.cWerner Koch2024-03-071-96/+49
| | | | | * scd/ccid-driver.c (my_npth_unprotect, my_npth_protect): New. Replace all direct uses by these wrappers.
* scd: Add support for ACR-122UWerner Koch2024-03-071-1/+5
| | | | | | | | | * scd/ccid-driver.h (VENDOR_ACR, ACR_122U): New. * scd/ccid-driver.c (ccid_open_usb_reader): Do not call libsub_set_interface_alt_setting for this reader. -- Co-authored-by: markus.montkowski@gnupg.com
* scd: Let the CCID module auto detach the kernel driver.Werner Koch2024-03-071-0/+14
| | | | | | | | | | | | * scd/ccid-driver.c (ccid_open_usb_reader): Call libusb_set_auto_detach_kernel_driver. * scd/scdaemon.c (oCompatibilityFlags): New. (opts): Add option "compatibility-flags". (compatibility_flags): New. (main): Parse flags. * scd/scdaemon.h (opt): Add field compat_flags. (COMPAT_CCID_NO_AUTO_DETACH): New.
* scd: Add npth_unprotect/npth_protect for blocking operations.NIIBE Yutaka2022-08-251-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 <gniibe@fsij.org>
* scd: Add a libusb debug level.Werner Koch2022-08-221-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.
* scd: Renamed a constant in ccid-driver.cWerner Koch2022-04-141-3/+3
| | | | | | | * scd/ccid-driver.c (MAX_DEVICE): Rename to CCID_MAX_DEVICE. -- Just for documentation reasons.
* scd: Minor code reorganizationWerner Koch2022-04-141-16/+22
| | | | | * scd/ccid-driver.c: Move struct defines to the top. --
* scd: Fix memory leak in ccid-driver.Werner Koch2022-04-141-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
* scd:ccid: Handle LIBUSB_TRANSFER_OVERFLOW interrupt transfer.NIIBE Yutaka2021-06-231-0/+5
| | | | | | * scd/ccid-driver.c (intr_cb): Ignore LIBUSB_TRANSFER_OVERFLOW. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Fix CCID driver for SCM SPR332/SPR532.NIIBE Yutaka2021-04-081-1/+13
| | | | | | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_pinpad_setup): New. (ccid_vendor_specific_setup): Only send CLEAR_HALT. (ccid_transceive_secure): Each time, use send_escape_cmd. -- GnuPG-bug-id: 5297 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Replace all assert macros by the log_assert macro.Werner Koch2021-03-311-2/+1
| | | | Signed-off-by: Werner Koch <wk@gnupg.org>
* scd:ccid:spr532: Extend abort_cmd for initialization time.NIIBE Yutaka2020-12-091-11/+18
| | | | | | | | | * scd/ccid-driver.c (abort_cmd): Add INIT argument to support synchronize until success, even ignoring timeout. (bulk_in): Normal use case of abort_cmd. (ccid_vendor_specific_init): Initial use case of abort_cmd. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd:ccid: Call libusb_clear_halt in ccid_vendor_specific_setup.NIIBE Yutaka2020-12-091-0/+1
| | | | | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_setup): Only for SPR532, call libusb_clear_halt. -- GnuPG-bug-id: 5167 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd:ccid: Revert the addition of libusb_clear_halt for EP_INTR.NIIBE Yutaka2020-12-091-1/+0
| | | | | | | | | * scd/ccid-driver.c (ccid_setup_intr): Don't call libusb_clear_halt. -- GnuPG-bug-id: 5167 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd:ccid-driver: Fix pinpad error handling for cancel/timeout.NIIBE Yutaka2020-11-271-1/+10
| | | | | | | | | | | | | | * scd/apdu.h (SW_HOST_UI_CANCELLED, SW_HOST_UI_TIMEOUT): New. * scd/ccid-driver.h (CCID_DRIVER_ERR_UI_CANCELLED): New. (CCID_DRIVER_ERR_UI_TIMEOUT): New. * scd/ccid-driver.c (bulk_in): Handle PIN input cancel/timeout error. * scd/iso7816.c (map_sw): Support SW_HOST_UI_CANCELLED and SW_HOST_UI_TIMEOUT. -- GnuPG-bug-id: 4614 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver: Fix a race condition on close.NIIBE Yutaka2020-11-051-12/+25
| | | | | | | | | | | | | | | | | | | | | * scd/ccid-driver.c (ccid_require_get_status): For VENDOR_SCM reader, return 0 only at the initial call. (bulk_in): Don't detect an error for VENDOR_SCM reader, just kicking the loop, to invoke scd_update_reader_status_file, which calls ccid_slot_status again. (ccid_slot_status): Move the call of ccid_vendor_specific_setup to... (ccid_get_atr): ... here. -- For readers with interrupt transfer support, it is only intr_cb which sets handle->powered_off to 1. Keeping this condition makes no race. The function ccid_slot_status can also detect a communication error, which causes apdu_close_reader (but not setting ->powered_off). GnuPG-bug-id: 5121 Fixes-commit: 920f258eb6018ecec1d63bad6a0fb0772f72affa Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver thing only for SPR532.NIIBE Yutaka2020-10-261-6/+14
| | | | | | | | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_setup): New. Limit only for SPR532, excluding other readers by SCM. (ccid_slot_status): Use ccid_vendor_specific_setup. -- We follow the setup procedure of libccid implementation, which sends the escape command for SPR532 only. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver limiting only for SPR532.NIIBE Yutaka2020-10-241-1/+1
| | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_init): Only do that for SPR532. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver: More fix for SPR532.NIIBE Yutaka2020-09-301-4/+4
| | | | | | | | | * scd/ccid-driver.c (bulk_in): Handle the case of missing intr_cb. -- GnuPG-bug-id: 5065 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver fix.NIIBE Yutaka2020-09-291-2/+5
| | | | | | | * scd/ccid-driver.c (intr_cb): More useful debug output. (ccid_slot_status): Remove redundant condition. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver: Call libusb_clear_halt at ccid_setup_intr.NIIBE Yutaka2020-09-291-3/+1
| | | | | | | * scd/ccid-driver.c (ccid_setup_intr): Reset the endpoint. (ccid_vendor_specific_init): Don't call libusb_clear_halt. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID driver: Fix a failure path.NIIBE Yutaka2020-09-281-0/+1
| | | | | | | * scd/ccid-driver.c (ccid_open_usb_reader): On error, call libusb_release_interface. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Internal CCID: Handle LIBUSB_ERROR_TIMEOUT at ccid_get_atr.NIIBE Yutaka2020-09-281-1/+2
| | | | | | | | | | | * scd/ccid-driver.c (ccid_slot_status): Handle LIBUSB_ERROR_TIMEOUT. -- With SPR532, at the first connection, it fails by LIBUSB_ERROR_TIMEOUT, but no retry. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Change handling of SPR532 card reader.NIIBE Yutaka2020-09-281-4/+17
| | | | | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_init): Put some workaround for SPR532 initialization. (ccid_slot_status): Send ESCape command after GetSlotStatus. GnuPG-bug-id: 5065 Fixes-commit: 4fae55f8ee11b3f710524e5e8b8a91b159949f2d Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: For SPR532, submit the ESCape command at initialization.NIIBE Yutaka2020-09-251-14/+13
| | | | | | | | | | * scd/ccid-driver.c (ccid_vendor_specific_init): Submit the ESC command for VENDOR_SCM. (ccid_transceive_secure): Don't submit the ESC command every time. -- Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Fix CCID internal driver for interrupt transfer.NIIBE Yutaka2020-09-241-3/+36
| | | | | | | | | | | | | | * scd/ccid-driver.c (intr_cb): Handle the case of multiple messages. -- SPR532 USB Smart Card Reader (also know as SPR332) may send two messages at once for a single interrupt transfer. An example transfer observed was like: 50 03 50 02, which is considered valid, according to the CCID specification. GnuPG-bug-id: 5065 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Increase the number of supported readers from 4 to 16.Werner Koch2020-09-041-1/+1
| | | | | | | | | | -- The limit on 4 readers I introduced in 2003 is too low for some of our use cases. 16 looks better. TODO: Return a useful error message in gpg-card if the limit has been reached. Signed-off-by: Werner Koch <wk@gnupg.org>
* scd: Map some error codes from libusb to ccid-driver error codes.Werner Koch2020-08-121-11/+27
| | | | | | | | | | | | | | | * scd/ccid-driver.h (CCID_DRIVER_ERR_USB_*): New error codes. * scd/apdu.h: New SW_HOST error codes. * scd/apdu.c (host_sw_string): Print them * scd/ccid-driver.c (map_libusb_error): New. (ccid_open_usb_reader, bulk_in, abort_cmd): Map libusb error codes. * scd/iso7816.c (map_sw): Map new codes to gpg-error. -- This change will help to get low level error conditions from hipher application code. Signed-off-by: Werner Koch <wk@gnupg.org>
* Spelling cleanup.Daniel Kahn Gillmor2020-02-191-2/+2
| | | | | | | | | | | | | | | | No functional changes, just fixing minor spelling issues. --- Most of these were identified from the command line by running: codespell \ --ignore-words-list fpr,stati,keyserver,keyservers,asign,cas,iff,ifset \ --skip '*.po,ChangeLog*,help.*.txt,*.jpg,*.eps,*.pdf,*.png,*.gpg,*.asc' \ doc g13 g10 kbx agent artwork scd tests tools am common dirmngr sm \ NEWS README README.maint TODO Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
* doc: Fixed variable naming.Werner Koch2019-11-261-1/+1
| | | | | | | | * kbx/keybox.h: Fix naming of arguments. * scd/ccid-driver.c (print_error) [TEST]: Add missing break. Note that this is anyway an impossible case. Signed-off-by: Werner Koch <wk@gnupg.org>
* scd,ccid: Fix detection of supported readers with pinpad.NIIBE Yutaka2019-11-151-3/+4
| | | | | | | * scd/ccid-driver.c (ccid_transceive_secure): When not supported, return CCID_DRIVER_ERR_NOT_SUPPORTED. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd,ccid: Fix GEMPC_EZIO handling.NIIBE Yutaka2019-10-281-5/+5
| | | | | | | | * scd/ccid-driver.c (ccid_transceive_secure): Fix for 08e6:34c2. Fixes-commit: c933c15d587a1c0df3f4b3bf37d8d15164dd318f GnuPG-bug-id: 4654 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd,ccid: Add 08e6:34c2 (GEMPC_EZIO).NIIBE Yutaka2019-10-151-7/+21
| | | | | | | * scd/ccid-driver.c (ccid_transceive_secure): Add pinpad support for 08e6:34c2 which supports extended APDU exchange. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Clean up the structure for future fix of PC/SC.NIIBE Yutaka2019-09-111-5/+10
| | | | | | | | | | | | * scd/apdu.c (struct dev_list): Rename from ccid_table, with void*. (open_ccid_reader): Follow the change. (apdu_dev_list_start, apdu_dev_list_finish): Likewise. (apdu_open_reader): Likewise. * scd/ccid-driver.c (ccid_dev_scan): Use void *. (ccid_dev_scan_finish, ccid_get_BAI, ccid_open_usb_reader): Likewise. * scd/ccid-driver.h: Change the APIs. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Handle CCID bwi of time extension.NIIBE Yutaka2019-07-251-1/+6
| | | | | | | | | | | | | * scd/ccid-driver.c (bulk_in): Increase timeout by the multiplier value as defined section 6.2.6 in CCID specification. -- For TPDU level transfer, it was handled. This is fix for APDU level transfer. GnuPG-bug-id: 4646 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Fix bBWI value.NIIBE Yutaka2019-07-251-2/+2
| | | | | | | | | | * scd/ccid-driver.c (ccid_transceive_apdu_level): Use bBWI=0 for APDU level transfer. (ccid_transceive): Use bBWI=0 or the value returend by WTX for TPDU level transfer. GnuPG-bug-id: 4654 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Remove useless GNUPG_SCD_MAIN_HEADER macro.Werner Koch2019-07-121-8/+3
| | | | | | | | | * scd/apdu.c (): Remove never set and useless macro. * scd/ccid-driver.c: Ditto. * scd/iso7816.c: Ditto. -- Signed-off-by: Werner Koch <wk@gnupg.org>
* scd: Fix internal CCID driver, so that -DTEST works.NIIBE Yutaka2019-07-111-42/+55
| | | | | | * scd/ccid-driver.c: Support a test program by ccid-driver. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Fix debug logging of the internal CCID driver.NIIBE Yutaka2019-07-111-4/+9
| | | | | | | * scd/ccid-driver.c [GNUPG_MAJOR_VERSION] (DEBUGOUT): Use log_debug. Fixes-commit: 79c99921e35921140c83d7c101829d95f038f3da Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: ccid-driver: Initial getting ATR more robustly.NIIBE Yutaka2019-07-091-18/+39
| | | | | | | | | * scd/ccid-driver.c (send_power_off): New. (do_close_reader): Use send_power_off. (ccid_get_atr): Add error recovery. GnuPG-bug-id: 4616 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* spelling: Fix "synchronize"Daniel Kahn Gillmor2019-06-241-1/+1
| | | | Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
* scd: Remove unused cruft from GnuPG 1.xWerner Koch2019-05-161-16/+4
| | | | | | | | | * scd/apdu.c: Remove code used only by GnuPG 1. * scd/app-openpgp.c: Ditto. * scd/ccid-driver.c: Ditto. * scd/iso7816.c: Ditto. Signed-off-by: Werner Koch <wk@gnupg.org>
* scd: Better handling of timeout and time extension.NIIBE Yutaka2019-04-041-7/+4
| | | | | | | | | * scd/ccid-driver.c (CCID_CMD_TIMEOUT_LONGER): Remove. (ccid_transceive): Don't use x4 blindly for bBWI, but use dynamically determined value. Use value from variable wait_more for bulk_in. Set wait_more by the value of time extension request. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: internal driver: Submit SET_INTERFACE control transfer.NIIBE Yutaka2019-02-221-8/+6
| | | | | | | | | | | | | | | | | | * scd/ccid-driver.c (ccid_open_usb_reader): Alway submit SET_INTERFACE control transfer. -- This handling is not mondatory, but it's better to do so, because there are card reader with pinpad and token with ack button, which support user interaction. User interaction status should be reset at open time. The status should be reset when the session is closed/stopped. In practice, since cleanup routine in a driver may not be called properly, it's good to submit SET_INTERFACE at open time. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Fix for USB INTERRUPT transfer.NIIBE Yutaka2019-01-071-2/+1
| | | | | | | | | | | | | * scd/ccid-driver.c (intr_cb): When LIBUSB_TRANSFER_NO_DEVICE, just handle this event as failure. -- It used to try another interrupt transfer request to make sure if it fails again. GnuPG-bug-id: 4308 Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* all: fix spelling and typosDaniel Kahn Gillmor2018-10-241-3/+3
| | | | Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
* scd: Support "acknowledge button" feature.NIIBE Yutaka2018-10-111-1/+29
| | | | | | | | | | | | | * scd/apdu.c (set_prompt_cb): New member function. (set_prompt_cb_ccid_reader): New function. (open_ccid_reader): Initialize with set_prompt_cb_ccid_reader. (apdu_set_prompt_cb): New. * scd/app.c (lock_app, unlock_app): Add call to apdu_set_prompt_cb. * ccid-driver.c (ccid_set_prompt_cb): New. (bulk_in): Call ->prompt_cb when timer extension. * scd/command.c (popup_prompt): New. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
* scd: Add support for Trustica Cryptoucan.Jiří Keresteš2018-07-261-0/+6
|
* scd: Fix suspend/resume handling for CCID driver.NIIBE Yutaka2018-03-151-1/+2
| | | | | | | | | | | | | * scd/ccid-driver.c (intr_cb): Try submitting INTERRUPT urb to see if it's suspend/resume. -- Upon suspend/resume, LIBUSB_TRANSFER_NO_DEVICE is returned, since all URBs are cancelled. We need to see if it's real NODEV error or its by suspend/resume. We can distinguish by sending URB again. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>