aboutsummaryrefslogtreecommitdiffstats
path: root/scd/apdu.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2014-03-07w32: Silence warnings about unused vars.Werner Koch1-4/+5
* agent/gpg-agent.c (main) [W32]: Mark unused vars. * sm/gpgsm.c (run_protect_tool) [W32]: Ditto. * g10/trustdb.c (check_regexp) [DISABLE_REGEX]: Ditto. * scd/scdaemon.c (main) [W32]: Ditto. (handle_connections) [W32]: Ditto. (handle_signal) [W32]: Do not build the function at all. * scd/apdu.c (pcsc_send_apdu_direct): Ditto. (connect_pcsc_card): s/long/pcsc_dword_t/. (open_pcsc_reader_direct): Remove var listlen.
2013-11-18Make use of the *_NAME etc macros.Werner Koch1-1/+1
Replace hardwired strings at many places with new macros from config.h and use the new strusage macro replacement feature. * common/asshelp.c (lock_spawning) [W32]: Change the names of the spawn sentinels. * agent/command.c (cmd_import_key): Use asprintf to create the prompt.
2013-11-13scd: more pinpad input fix for PC/SC.NIIBE Yutaka1-10/+5
* scd/apdu.c (check_pcsc_pinpad): Set default values here. (pcsc_pinpad_verify, pcsc_pinpad_modify): Remove setting default values, as it's too late. -- GnuPG-bug-id: 1549
2013-11-11scd: more pinpad fix.NIIBE Yutaka1-8/+5
* scd/apdu.c (check_pcsc_pinpad): Set ->minlen and ->maxlen only when those are specified. (pcsc_pinpad_modify): Remove old check code. -- GnuPG-bug-id: 1549
2013-10-29scd: pinpad fix for PC/SC on Windows.NIIBE Yutaka1-1/+8
* scd/apdu.c (SCARD_CTL_CODE): Fix for Windows.
2013-10-25scd: fix pinpad input on Windows.NIIBE Yutaka1-1/+2
* scd/apdu.c (open_pcsc_reader_direct): Don't call pcsc_vendor_specific_init here, but... (connect_pcsc_card): Call it here. -- Thanks to Martin Wolters for the bug report.
2013-10-16scd: add pinpad readers information for PC/SC service.NIIBE Yutaka1-11/+26
* scd/apdu.c (pcsc_vendor_specific_init): Add information for Cherry ST-2xxx, Reiner cyberJack, Vasco DIGIPASS, FSIJ Gnuk Token, and KAAN Advance. --
2013-10-15scd: remove pin length check.NIIBE Yutaka1-6/+0
* scd/apdu.c (pcsc_pinpad_verify): Remove old check code for pin length. -- GnuPG-bug-id: 1549
2013-08-30scd: Use vendor and product id macros also in apdu.cWerner Koch1-2/+3
* scd/ccid-driver.c: Move vendor and product ids to ... * scd/ccid-driver.h: here. * scd/apdu.c (CCID_DRIVER_INCLUDE_USB_IDS): Define to include ids. (pcsc_vendor_specific_init): Use vendor and product id macros. Signed-off-by: Werner Koch <[email protected]>
2013-08-30scd: PC/SC pinpad input improvement.NIIBE Yutaka1-62/+168
* scd/apdu.c (struct reader_table_s): Add members: PINMIN, PINMAX, and PINPAD_VERLEN_SUPPORTED. (CM_IOCTL_VENDOR_IFD_EXCHANGE, FEATURE_GET_TLV_PROPERTIES, PCSCv2_PART10_PROPERTY_*): New. (new_reader_slot): Initialize pinpad_varlen_supported, pinmin, pinmax. (pcsc_vendor_specific_init): New. (open_pcsc_reader_direct, open_pcsc_reader_wrapped): Call pcsc_vendor_specific_init. (check_pcsc_pinpad): Not detect here but use the result of pcsc_vendor_specific_init. (pcsc_pinpad_verify, pcsc_pinpad_modify): Specify bNumberMessage. -- Signed-off-by: NIIBE Yutaka --
2013-08-21scd: Make SPRx32 pinpad work with PC/SC on Windows.Werner Koch1-7/+27
* scd/apdu.c (CM_IOCTL_GET_FEATURE_REQUEST): Use SCARD_CTL_CODE. (SCARD_CTL_CODE): Define if not defined. (reader_table_s): Add is_spr532. (new_reader_slot): Clear it. (check_pcsc_pinpad): Set it. (pcsc_pinpad_verify, pcsc_pinpad_modify): Add fix for SPR532. Signed-off-by: Werner Koch <[email protected]>
2013-08-21scd: Improve --enable-pinpad-varlen.Werner Koch1-1/+7
* tools/gpgconf-comp.c (gc_options_scdaemon): Add enable-pinpad-varlen. * scd/apdu.c (check_pcsc_pinpad): Detect SPRx32 reader. Signed-off-by: Werner Koch <[email protected]>
2013-08-01scd: Fix a syntax error for Apple and Windows.Werner Koch1-1/+1
* scd/apdu.c (pcsc_dword_t) [W32]: Fix syntax error.
2013-03-26scd: PC/SC status fix.NIIBE Yutaka1-3/+5
* scd/apdu.c (pcsc_get_status_direct): Check PCSC_STATE_MUTE only when PCSC_STATE_PRESENT. * scd/pcsc-wrapper.c (handle_status): Ditto.
2013-03-26scd: PC/SC cleanup (more).NIIBE Yutaka1-6/+6
* scd/apdu.c (control_pcsc_direct, control_pcsc_wrapped, control_pcsc) (check_pcsc_pinpad, pcsc_pinpad_verify, pcsc_pinpad_modify): Use pcsc_dword_t.
2013-03-22scd: PC/SC cleanup.NIIBE Yutaka1-57/+71
* scd/apdu.c (pcsc_dword_t): New. It was named as DWORD (double-word) when a word was 16-bit. (struct reader_table_s): Fixes for types. (struct pcsc_readerstate_s) [__APPLE__]: Enable #pragma pack(1). Throughout: Fixes for types. * scd/pcsc-wrapper.c: Likewise. -- Problem reported for 1.4.x by the issue 1358.
2013-03-21scd: change default value of pinpad maxlen.NIIBE Yutaka1-2/+2
* scd/apdu.c (pcsc_pinpad_verify, pcsc_pinpad_modify): Default value of maxlen for pinpad input is now 15 (was: 25). * scd/ccid-driver.c (ccid_transceive_secure): Likewise. -- For newer PC/SC, it is better to use FEATURE_GET_TLV_PROPERTIES to get bMaxPINSize.
2013-02-08scd: Rename 'keypad' to 'pinpad'.NIIBE Yutaka1-38/+38
* NEWS: Mention scd changes. * agent/divert-scd.c (getpin_cb): Change message. * agent/call-scd.c (inq_needpin): Change the protocol to POPUPPINPADPROMPT and DISMISSPINPADPROMPT. * scd/command.c (pin_cb): Likewise. * scd/apdu.c (struct reader_table_s): Rename member functions. (check_pcsc_pinpad, pcsc_pinpad_verify, pcsc_pinpad_modify, check_ccid_pinpad, ccid_pinpad_operation, apdu_check_pinpad apdu_pinpad_verify, apdu_pinpad_modify): Rename. * scd/apdu.h (SW_HOST_NO_PINPAD, apdu_check_pinpad) (apdu_pinpad_verify, apdu_pinpad_modify): Rename. * scd/iso7816.h (iso7816_check_pinpad): Rename. * scd/iso7816.c (map_sw): Use SW_HOST_NO_PINPAD. (iso7816_check_pinpad): Rename. (iso7816_verify_kp, iso7816_change_reference_data_kp): Follow the change. * scd/ccid-driver.h (CCID_DRIVER_ERR_NO_PINPAD): Rename. * scd/ccid-driver.c (ccid_transceive_secure): Use it. * scd/app-dinsig.c (verify_pin): Follow the change. * scd/app-nks.c (verify_pin): Follow the change. * scd/app-openpgp.c (check_pinpad_request): Rename. (parse_login_data, verify_a_chv, verify_chv3, do_change_pin): Follow the change. * scd/scdaemon.c (oDisablePinpad, oEnablePinpadVarlen): Rename. * scd/scdaemon.h (opt): Rename to disable_pinpad, enable_pinpad_varlen. * tools/gpgconf-comp.c (gc_options_scdaemon): Rename to disable-pinpad.
2013-02-05SCD: Better interoperability.NIIBE Yutaka1-2/+2
* scd/apdu.c: Fill bTeoPrologue[2] field. -- ccid-1.4.5 or older requires this field is filled by application.
2013-02-05SCD: Support fixed length PIN input for keypad (PC/SC).NIIBE Yutaka1-11/+15
* scd/apdu.c (pcsc_keypad_verify): SUpport fixed length PIN input for keypad. (pcsc_keypad_modify): Likewise. * scd/ccid-driver.c (ccid_transceive_secure): Clean up.
2013-02-05SCD: Support fixed length PIN input for keypad.NIIBE Yutaka1-4/+4
* scd/iso7816.h (struct pininfo_s): Remove MODE and add FIXEDLEN. * scd/app-dinsig.c (verify_pin): Initialize FIXEDLEN to unknown. * scd/app-nks.c (verify_pin): Likewise. * scd/app-openpgp.c (verify_a_chv, verify_chv3, do_change_pin): Likewise. * scd/apdu.c (check_pcsc_keypad): Add comment. (pcsc_keypad_verify, pcsc_keypad_modify): PC/SC driver only support readers with the feature of variable length input (yet). (apdu_check_keypad): Set FIXEDLEN. * scd/ccid-driver.c (ccid_transceive_secure): Add GEMPC_PINPAD specific settings. Support fixed length PIN input for keypad.
2013-02-05SCD: API cleanup for keypad handling.NIIBE Yutaka1-62/+37
* scd/iso7816.h (struct pininfo_s): Rename from iso7816_pininfo_s. Change meaning of MODE. (pininfo_t): Rename from iso7816_pininfo_t. * scd/sc-copykeys.c: Include "iso7816.h". * scd/scdaemon.c, scd/command.c: Likewise. * scd/ccid-driver.c: Include "scdaemon.h" and "iso7816.h". (ccid_transceive_secure): Follow the change of PININFO_T. * scd/app.c: Include "apdu.h" after "iso7816.h". * scd/iso7816.c (iso7816_check_keypad, iso7816_verify_kp) (iso7816_change_reference_data_kp): Follow the change of API. * scd/apdu.c (struct reader_table_s): Change API of CHECK_KEYPAD, KEYPAD_VERIFY, KEYPAD_MODIFY to have arg of PININFO_T. (check_pcsc_keypad, check_ccid_keypad): Likewise. (apdu_check_keypad, apdu_keypad_verify, apdu_keypad_modify): Likewise. (pcsc_keypad_verify, pcsc_keypad_modify, ct_send_apdu) (pcsc_send_apdu_direct, pcsc_send_apdu_wrapped, pcsc_send_apdu) (send_apdu_ccid, ccid_keypad_operation, my_rapdu_send_apdu, send_apdu) (send_le): Follow the change of API. * scd/apdu.h (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Change the API. * scd/app-dinsig.c, scd/app-nks.c, scd/app-openpgp.c: Follow the change.
2013-02-05SCD: Clean up. Remove PADLEN for keypad input.NIIBE Yutaka1-30/+10
* scd/apdu.c (struct pininfo_s): Use iso7816_pininfo_s. (struct reader_table_s): Remove last arg from check_keypad method. (check_pcsc_keypad, check_pcsc_keypad): Remove PIN_PADLEN. (pcsc_keypad_verify, pcsc_keypad_modify): Don't check PIN_PADLEN. (send_apdu_ccid, ccid_keypad_operation): Remove PIN_PADLEN. (apdu_check_keypad, apdu_keypad_verify, apdu_keypad_modify): Likewise. * scd/apdu.h (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Remove PIN_PADLEN. * scd/ccid-driver.c (ccid_transceive_secure): Remove PIN_PADLEN. * scd/ccid-driver.h (ccid_transceive_secure): Remove PIN_PADLEN. * scd/iso7816.c (iso7816_check_keypad, iso7816_verify_kp) (iso7816_change_reference_data_kp): Remove PADLEN. * scd/iso7816.h (struct iso7816_pininfo_s): Remove PADLEN, PADCHAR. -- In the OpenPGPcard specification, password comes with no padding. In GnuPG, we support keypad input for OpenPGPcard only. Thus, it is useless to try to support padding for keypad input.
2013-01-11SCD: Hold lock for pinpad input.NIIBE Yutaka1-3/+30
* scd/apdu.c (apdu_check_keypad, apdu_keypad_verify) (apdu_keypad_modify): Hold lock to serialize communication.
2012-12-04Revert SCD changes of 2010-05-03.NIIBE Yutaka1-19/+1
* scd/apdu.c (pcsc_no_service): Remove. (open_pcsc_reader_direct, open_pcsc_reader_wrapped): Remove pcsc_no_service support. (apdu_open_reader): Remove R_NO_SERVICE. * scd/apdu.h (apdu_open_reader): Remove R_NO_SERVICE. * scd/command.c (reader_disabled): Remove. (get_current_reader): Follow the change of R_NO_SERVICE. (open_card, cmd_serialno, scd_command_handler): Remove reader_disabled support. * scd/sc-copykeys.c (main): Follow the change of R_NO_SERVICE. -- Daemon should handle all possible cases. Even if such a difficult case like reader_disabled, it should not exit.
2012-10-31SCD: Upon error, open_pcsc_reader_wrapped does same as _direct.NIIBE Yutaka1-1/+10
* scd/apdu.c (PCSC_E_NO_SERVICE): New. (open_pcsc_reader_direct): Use PCSC_E_NO_SERVICE. (open_pcsc_reader_wrapped): Set pcsc_no_service.
2012-06-25scd: handle reader/token removal.NIIBE Yutaka1-0/+1
* scd/apdu.c (pcsc_error_to_sw): PCSC_E_UNKNOWN_READER means SW_HOST_NO_READER.
2012-06-05Change all quotes in strings and comments to the new GNU standard.Werner Koch1-4/+4
The asymmetric quotes used by GNU in the past (`...') don't render nicely on modern systems. We now use two \x27 characters ('...'). The proper solution would be to use the correct Unicode symmetric quotes here. However this has the disadvantage that the system requires Unicode support. We don't want that today. If Unicode is available a generated po file can be used to output proper quotes. A simple sed script like the one used for en@quote is sufficient to change them. The changes have been done by applying sed -i "s/\`\([^'\`]*\)'/'\1'/g" to most files and fixing obvious problems by hand. The msgid strings in the po files were fixed with a similar command.
2012-04-10Fix killing PID -1.Ben Kibbey1-6/+12
When the KILLSCD command had been sent a race condition would occur causing PID -1 getting killed, which on Linux seems to terminate all applications for the current user.
2012-01-25Port to npth.Marcus Brinkmann1-30/+43
* configure.ac: Don't check for PTH but for NPTH. (AH_BOTTOM): Remove PTH_SYSCALL_SOFT. (have_pth): Rename to ... (have_npth): ... this. (USE_GNU_NPTH): Rename to ... (USE_GNU_PTH): ... this. * m4/npth.m4: New file. * agent/Makefile.am, agent/cache.c, agent/call-pinentry.c, agent/call-scd.c, agent/findkey.c, agent/gpg-agent.c, agent/trustlist.c, common/Makefile.am, common/estream.c, common/exechelp-posix.c, common/exechelp-w32.c, common/exechelp-w32ce.c, common/http.c, common/init.c, common/sysutils.c, dirmngr/Makefile.am, dirmngr/crlfetch.c, dirmngr/dirmngr.c, dirmngr/dirmngr_ldap.c, dirmngr/ldap-wrapper-ce.c, dirmngr/ldap-wrapper.c, dirmngr/ldap.c, g13/Makefile.am, g13/call-gpg.c, g13/g13.c, g13/runner.c, scd/Makefile.am, scd/apdu.c, scd/app.c, scd/ccid-driver.c, scd/command.c, scd/scdaemon.c, tools/Makefile.am: Port to npth.
2012-01-06Merge ccid_driver_improvement branch.NIIBE Yutaka1-4/+4
* scd/apdu.c (ccid_keypad_operation): Rename from ccid_keypad_verify. (open_ccid_reader): Use ccid_keypad_operation for verify and modify. * scd/ccid-driver.c (VENDOR_VASCO, VASCO_920): New. (ccid_transceive_apdu_level): Permit sending packet where apdulen <= 289. Support receiving packets in a chain. (ccid_transceive_secure): Maximum is 15 for VASCO DIGIPASS 920. Support keypad_modify method such as CHANGE_REFERENCE_DATA: 0x24.
2011-12-20Add error log and debug log for pcsc_keypad_verify and pcsc_keypad_modify.NIIBE Yutaka1-4/+22
* scd/apdu.c (pcsc_keypad_verify): Add debug log and error log. (pcsc_keypad_modify): Likewise.
2011-12-19scd: Fix for card change returning GPG_ERR_CARD_RESET.Werner Koch1-2/+1
* scd/apdu.c (apdu_connect): Do not test for zero atrlen. -- When gpg-agent prompts for insertion of a card this error would be returned. Co-authored-by: Ben Kibbey <[email protected]>
2011-12-14scd: Add more status word values for documentation.Werner Koch1-2/+5
2011-12-14scd: Add debug option for reader function calls.Werner Koch1-65/+140
* scd/scdaemon.h (DBG_READER_VALUE, DBG_READER): New. * scd/apdu.c (apdu_open_reader, apdu_close_reader) (apdu_shutdown_reader, apdu_connect, apdu_disconnect) (apdu_reset, apdu_get_atr, apdu_get_status): Add debug code. (apdu_activate): Remove this unused function.
2011-12-12Fix detection of card removal and insertion.Werner Koch1-2/+13
* scd/apdu.c (apdu_connect): Return status codes for no card available and inactive card. * scd/command.c (TEST_CARD_REMOVAL): Also test for GPG_ERR_CARD_RESET. (open_card): Map apdu_connect status to GPG_ERR_CARD_RESET.
2011-12-02Fix pinpad input support for passphrase modification.NIIBE Yutaka1-31/+13
* apdu.c (pcsc_keypad_verify): Have dummy Lc field with value 0. (pcsc_keypad_modify): Likewise. (pcsc_keypad_modify): It's only for ISO7816_CHANGE_REFERENCE_DATA. bConfirmPIN value is determined by the parameter p0. * app-openpgp.c (do_change_pin): The flag use_keypad should be 0 when reset_mode is on, or resetcode is on. use_keypad only makes sense for iso7816_change_reference_data_kp. * iso7816.h (iso7816_put_data_kp): Remove. (iso7816_reset_retry_counter_kp): Remove. (iso7816_reset_retry_counter_with_rc_kp): Remove. (iso7816_change_reference_data_kp): Add an argument: IS_EXCHANGE. * iso7816.c (iso7816_put_data_kp): Remove. (iso7816_reset_retry_counter_kp): Remove. (iso7816_reset_retry_counter_with_rc_kp): Remove. (iso7816_change_reference_data_kp): Add an argument: IS_EXCHANGE.
2011-11-29PC/SC pinpad support (pinpad input for modify pass phrase with resetcode, by ↵NIIBE Yutaka1-24/+27
admin).
2011-11-29PC/SC pinpad support (pinpad input for modify pass phrase).NIIBE Yutaka1-0/+111
2011-11-28PC/SC pinpad support.NIIBE Yutaka1-3/+359
Before this change, it is layered like following: iso7816_verify iso7816_verify_kp apdu_send_simple, apdu_send_simple_kp ... After this change, it will be layered like: iso7816_verify iso7816_verify_kp apdu_send_simple apdu_keypad_verify ... and apdu_send_simple_kp will be deprecated. For PC/SC API, we use: SCardControl API to compose CCID PC_to_RDR_Secure message SCardTransmit API to compose CCID PC_to_RDR_XfrBlock message Considering the support of PC/SC, we have nothing to share between _kp version of iso7816_* and no _kp version.
2011-08-10Fixed set but unused variable bugsWerner Koch1-2/+1
2011-02-23Lock scdaemon to CCID if once found.Werner Koch1-2/+16
This solves a problem where ccid was used, the card unplugged and then scdaemon tries to find a new (plugged in) reader and thus will eventually try PC/SC over and over again. Also added an explicit --kill command to gpgconf.
2011-02-04Nuked almost all trailing white space.post-nuke-of-trailing-wsWerner Koch1-25/+25
We better do this once and for all instead of cluttering all future commits with diffs of trailing white spaces. In the majority of cases blank or single lines are affected and thus this change won't disturb a git blame too much. For future commits the pre-commit scripts checks that this won't happen again.
2011-01-25Detect non operational readers.Werner Koch1-3/+17
Backport from 2.0.
2010-11-17Smartcard related updatesWerner Koch1-9/+26
2009-09-03Fix for extended length Le in decipherWerner Koch1-2/+0
2009-07-21Make bug reporting address easier changeable.Werner Koch1-0/+1
2009-07-16Add code to better handle unplugging of a reader.Werner Koch1-1/+28
2009-07-13* ccid-driver.c (struct ccid_driver_s): Add fields last_progress,Werner Koch1-1/+36
progress_cb and progress_cb_arg. (ccid_set_progress_cb): New. (print_progress): New. (ccid_transceive): Call print_progress for wait time extensions. * apdu.c (struct reader_table_s): Add field set_progress_cb. (new_reader_slot): Clear that field. (open_ccid_reader): Set it to .. (set_progress_cb_ccid_reader): ... new fucntion. * app.c (print_progress_line): New. (lock_reader): Add arg CTRL to set a progress callback and change all callers to provide it. (unlock_reader): Remove the progress callback.
2009-06-29Reworked the estream memory buffer allocation.Werner Koch1-0/+3
Committed already posted patches for the v2 card.