aboutsummaryrefslogtreecommitdiffstats
path: root/scd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* scd: PC/SC reader selection by partial string match.NIIBE Yutaka2015-04-301-4/+8
| | | | | | | | | | | | | | | | | * scd/apdu.c (open_pcsc_reader_direct): Partial string match. -- The card reader name by PC/SC service might include USB bus, which varies (on some platform like GNU/Linux). Thus, it's better to match partial string. Original patch was submitted by anstein. I changed it to fallback to the first reader if no match found. Note that we need to change pcsc-wrapper.c in 2.0 backport. GnuPG-bug-id: 1618, 1930
* common: Remove two JNLIB_ macros (jnlib merge).Werner Koch2015-04-243-9/+5
| | | | | | | | | | * configure.ac: Merge seperate jnlib checks. (HAVE_JNLIB_LOGGING): Remove. * common/logging.c, common/simple-pwquery.c (JNLIB_NEED_AFLOCAL): Rename to GNUPG_COMMON_NEED_AFLOCAL. Change all tests. -- Signed-off-by: Werner Koch <[email protected]>
* scd: better handling of extended APDU.NIIBE Yutaka2015-04-143-83/+87
| | | | | | | | | | | | | | | | * scd/apdu.c (send_le): Bug fix for not append Z when lc<0&&le<0. * scd/app-common.h (struct app_ctx_s): Use bit fields for flags. * scd/ccid-driver.c (CCID_MAX_BUF): New. Only for OpenPGPcard. (struct ccid_driver_s): New field of max_ccid_msglen. Remove ifsd field. (parse_ccid_descriptor): Initialize max_ccid_msglen. (ccid_transceive_apdu_level): Implement sending extended APDU in chain of CCID message. -- With this patch, we won't need PC/SC library/service any more. GnuPG-bug-id: 1947
* Remove obsolete directories from AM_CPPFLAGS.Werner Koch2015-04-101-1/+1
|
* Rename DBG_ASSUAN to DBG_IPC and add separate DBG_EXTPROG.Werner Koch2015-04-062-6/+6
| | | | * g10/options.h (DBG_EXTPROG_VALUE): Separate from DBG_IPC_VALUE.
* scd: Fix possible NULL deref in apdu.cWerner Koch2015-03-151-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | | * scd/apdu.c (control_pcsc_direct): Take care of BUFLEN being NULL. (control_pcsc_wrapped): Ditto. -- pcsc_vendor_specific_init calls the above with BUFFER and BUFLEN as NULL. Reported by Stack 0.3: bug: anti-dce model: | control_pcsc.exit77: %retval.0.i.i76 = phi i32 [ %rc.0.i.i.i73, \ %pcsc_error_to_sw.exit.i.i74 ], [ 0, %if.end.i.i75 ] %tobool198 = icmp ne i32 %retval.0.i.i76, 0, !dbg !728 br i1 %tobool198, label %if.then199, label %if.end200, !dbg !728 stack: - /home/wk/s/gnupg/scd/apdu.c:1882:0 ncore: 1 core: - /home/wk/s/gnupg/scd/apdu.c:1309:0 - buffer overflow
* scd: fix for 64-bit arch.NIIBE Yutaka2015-03-091-3/+3
| | | | | | | | | | * agent/pksign.c (agent_pksign_do): Use int. * scd/app-openpgp.c (get_public_key): Likewise. -- On 64-bit architecture, int and size_t might be different. For the first argument for '%b', int is expected.
* scd: Fix regression in 2.1.2 (due to commit 2183683)Werner Koch2015-02-121-2/+2
| | | | | | | | * scd/apdu.c (pcsc_vendor_specific_init): Replace use of bufNN_to_uint by direct code. -- Hey, that was little endian.
* Use inline functions to convert buffer data to scalars.Werner Koch2015-02-114-26/+22
| | | | | | | | | | | | | | | * common/host2net.h (buf16_to_ulong, buf16_to_uint): New. (buf16_to_ushort, buf16_to_u16): New. (buf32_to_size_t, buf32_to_ulong, buf32_to_uint, buf32_to_u32): New. -- Commit 91b826a38880fd8a989318585eb502582636ddd8 was not enough to avoid all sign extension on shift problems. Hanno Böck found a case with an invalid read due to this problem. To fix that once and for all almost all uses of "<< 24" and "<< 8" are changed by this patch to use an inline function from host2net.h. Signed-off-by: Werner Koch <[email protected]>
* Add a hook to be called right after main.Werner Koch2015-01-281-0/+1
| | | | | | * common/init.c (early_system_init): New stub function. Signed-off-by: Werner Koch <[email protected]>
* scd: Fix varargs call for 64-bit arch on ECC keys.NIIBE Yutaka2015-01-281-14/+12
| | | | | | | | | | | | | * scd/app-openpgp.c (store_fpr): Remove CARD_VERSION from the arguments. (rsa_writekey): Follow the change. (do_genkey): Likewise. (ecc_writekey): Likewise. Cast to size_t. -- KEYTOCARD caused SEGV of scdaemon on 64-bit arch. That's because int is 32-bit, but size_t is 64-bit.
* ccid: Remove incorrect expression leading to errors.Joshua Rogers2015-01-251-1/+1
| | | | | | | | | | | | | | * scd/ccid-driver.c (send_escape_cmd): Fix setting of 'rc'. -- Variable 'rc' in send_escape_cmd was overwritten before it was returned, leading to incorrect computation. Signed-off-by: Joshua Rogers <[email protected]> [Log entry reformatted - wk] (cherry picked from commit 3d9f8bf1dc0c7165a5d2a31568ed425d2dc3b91e)
* scd: Allow for certificates > 1024 with PC/SC.Andreas Schwier2015-01-131-1/+1
| | | | | | | | | | * scd/pcsc-wrapper.c (handle_transmit): Enlarge buffer to 4096 too allow for larger certificates. -- Cherry-pick from 5798673156a66f4c39e1d34e358b03539194d57c. Forward ported from 2.0.
* scd: fix get_public_key for OpenPGPcard v1.0.Joshua Rogers2015-01-081-1/+1
| | | | | | | | | | | * scd/app-openpgp.c (get_public_key): correctly close 'fp' upon use. -- Inside the get_public_key function, 'fp' was opened using popen, but incorrectly closed using fclose. Debian-Bug-Id: 773474
* scd: fix merge failure.NIIBE Yutaka2015-01-061-2/+0
| | | | | | | | | * scd/apdu.c (pcsc_pinpad_verify): Remove wrong lines inserted by merge. -- Thanks to Joshua Rogers for reviewing and reporting.
* scd: Avoid double-free on error condition in scdDaniel Kahn Gillmor2014-12-221-4/+2
| | | | | | | | | | | | * scd/command.c (cmd_readkey): avoid double-free of cert -- When ksba_cert_new() fails, cert will be double-freed. Debian-Bug-Id: 773471 Original patch changed by wk to do the free only at leave.
* scd: ECDH Support.NIIBE Yutaka2014-12-221-100/+69
| | | | | | | | | | | | | | | | * agent/divert-scd.c (divert_pkdecrypt): Support ECDH. * scd/app-openpgp.c (get_algo_byte, store_fpr): Support ECDH. (send_key_attr): Support ECDH. Fix EdDSA algorithm value. (retrieve_key_material): Initialize fields. (get_public_key, ecc_writekey, do_writekey): Support ECDH. (ecdh_writekey): Remove. (do_decipher): Support ECDH. (parse_algorithm_attribute): Support ECDH. Fix EdDSA. -- Following the gpg-agent protocol, SCDaemon's counter part is now implemented.
* gpg: Add sub-command "factory-reset" to --card-edit.Werner Koch2014-12-155-8/+10
| | | | | | | | | | | | | | | | | | * common/util.h (GPG_ERR_OBJ_TERM_STATE): New. * scd/iso7816.c (map_sw): Add this error code. * scd/app-openpgp.c (do_getattr): Return the life cycle indicator. * scd/app.c (select_application): Allow a return value of GPG_ERR_OBJ_TERM_STATE. * scd/scdaemon.c (set_debug): Print the DBG_READER value. * g10/call-agent.c (start_agent): Print a status line for the termination state. (agent_scd_learn): Make arg "info" optional. (agent_scd_apdu): New. * g10/card-util.c (send_apdu): New. (factory_reset): New. (card_edit): Add command factory-reset. Signed-off-by: Werner Koch <[email protected]>
* scd: Fix possibly inhibited checkpin of the admin pin.Werner Koch2014-12-121-1/+1
| | | | | | | * scd/app-openpgp.c (do_check_pin): Do not check a byte of a released buffer. Signed-off-by: Werner Koch <[email protected]>
* scd: Fix for EdDSA.NIIBE Yutaka2014-12-081-3/+5
| | | | | * scd/app-openpgp.c (get_algo_byte): It catches 22. (store_fpr): It's MPI usually, but it's opaque bytes for EdDSA.
* scd: Fix for NIST P-256.NIIBE Yutaka2014-12-051-6/+12
| | | | | | * g10/card-util.c (card_store_subkey): Error check. * scd/app-opengpg.c (ecc_writekey): Support NIST P-256. (do_writekey): Error check.
* scd: Implement socket redirection.Werner Koch2014-12-011-25/+67
| | | | | | | | | | | | * scd/scdaemon.c (ENAMETOOLONG): New. (redir_socket_name): New. (cleanup): Take care of a redirected socket. (main): Pass redir_socket_name to create_server_socket. (create_socket_name): Remove superfluous length check. (create_server_socket): Add arg r_redir_name and implement redirection. Replace assert for older Assuan by an error message. Signed-off-by: Werner Koch <[email protected]>
* Remove use of gnulib (part 1)Werner Koch2014-11-112-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * gl/: Remove entire tree. * configure.ac: Remove gnulib tests and the gl/ Makefile. (setenv): Add to AC_CHECK_FUNCS. * autogen.rc (extra_aclocal_flags): Set to empty. * Makefile.am (ACLOCAL_AMFLAGS): Remove -I gl/m4 (SUBDIRS): Remove gl/. * agent/Makefile.am (common_libs): Remove ../gl/gnulib.a * common/Makefile.am (t_common_ldadd): Ditto. * dirmngr/Makefile.am (dirmngr_LDADD): Ditto. (dirmngr_ldap_LDADD, dirmngr_client_LDADD): Ditto. * g10/Makefile.am (needed_libs): Ditto. * g13/Makefile.am (g13_LDADD): Ditto. * kbx/Makefile.am (kbxutil_LDADD): Ditto. ($(PROGRAMS)): Ditto. * scd/Makefile.am (scdaemon_LDADD): Ditto. * sm/Makefile.am (common_libs): Ditto. * tools/Makefile.am (common_libs, commonpth_libs): Ditto. * agent/gpg-agent.c: Remove "mkdtemp.h" * g10/exec.c: Ditto. * scd/scdaemon.c: Ditto. * tools/symcryptrun.c: Ditto. * common/sysutils.c: Remove "setenv.h" * common/t-timestuff.c: Use putenv if setenv is not available. -- gnulib has always been a cause of trouble in GnuPG because we used only a very few functions and the complex include machinery of gnulib is quite complex and the cause for many build problems for example on OS X. This is not gnulib's fault but due to our limited use of gnulib and that we only rarely update the gnulib code to avoid regressions. In part two we will address the functions mkdtemp setenv unsetenv strpbrk which may bot be implemented on all platforms. They are not required on a libc based system. Signed-off-by: Werner Koch <[email protected]>
* Change a couple of files to use abbreviated copyright notes.Werner Koch2014-11-041-2/+2
| | | | | | | | | -- Also fixed some of my own copyright notices due to the termination of my assignment. The one displayed by --version is kept at FSF because we had contributors in 2014 with FSF assignments and it gives the FSF some visibility.
* Use a unique capitalization for "Note:".Werner Koch2014-10-101-2/+2
| | | | --
* Remove support for the GPG_AGENT_INFO envvar.Werner Koch2014-10-031-64/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | * agent/agent.h (opt): Remove field use_standard_socket. * agent/command.c (cmd_killagent): Always allow killing. * agent/gpg-agent.c (main): Turn --{no,}use-standard-socket and --write-env-file into dummy options. Always return true for --use-standard-socket-p. Do not print the GPG_AGENT_INFO envvar setting or set that envvar. (create_socket_name): Simplify by removing non standard socket support. (check_for_running_agent): Ditto. * common/asshelp.c (start_new_gpg_agent): Remove GPG_AGENT_INFO use. * common/simple-pwquery.c (agent_open): Ditto. * configure.ac (GPG_AGENT_INFO_NAME): Remove. * g10/server.c (gpg_server): Do not print the AgentInfo comment. * g13/server.c (g13_server): Ditto. * sm/server.c (gpgsm_server): Ditto. * tools/gpgconf.c (main): Simplify by removing non standard socket support. -- The indented fix to allow using a different socket than the one in the gnupg home directory is to change Libassuan to check whether the socket files exists as a regualr file with a special keyword to redirect to another socket file name.
* scd: Fix int/short mismatch in format string of app-p15.cWerner Koch2014-09-181-4/+8
| | | | | | | * scd/app-p15.c (parse_certid): Use snprintf and cast value. (send_certinfo): Ditto. (send_keypairinfo): Ditto. (do_getattr): Ditto.
* Switch to the libgpg-error provided estream.Werner Koch2014-08-264-11/+10
| | | | | | | | | | * configure.ac (NEED_GPG_ERROR_VERSION): Reguire 1.14. (GPGRT_ENABLE_ES_MACROS): Define. (estream_INIT): Remove. * m4/estream.m4: Remove. * common/estream-printf.c, common/estream-printf.h: Remove. * common/estream.c, common/estream.h: Remove. * common/init.c (_init_common_subsystems): Call gpgrt initialization.
* scd: Minor changes to app-sc-hsm.Werner Koch2014-08-141-228/+269
| | | | | | | | | | | * scd/app-sc-hsm.c: Re-indendet some parts and set some vars to NULL after xfree for improbed robustness. (read_ef_prkd): Replace serial operator by blocks for better readability. (apply_PKCS_padding): Rewrite for easier auditing. (strip_PKCS15_padding): Ditto. Add stricter check on SRCLEN. Signed-off-by: Werner Koch <[email protected]>
* scd: Minor and editorial changes to app-sc-hsm.cWerner Koch2014-07-251-149/+172
| | | | | | | | | | | | | * scd/app-sc-hsm.c (select_and_read_binary): Use SW_ macro. (parse_certid): Remove useless test. (send_certinfo, send_keypairinfo): Shrink malloc to the needed size. (do_getattr): Ditto. (verify_pin): Use SW_ macro. (do_decipher): Replace OFS variable and extend comment. -- Code parts which have not been audited are marked with a warning pragma.
* scd: Add a new status word code.Werner Koch2014-07-252-0/+2
| | | | | * scd/apdu.h (SW_REF_DATA_INV): New. * scd/apdu.c (apdu_strerror): Add string.
* scd: Comment typo fixes.Werner Koch2014-07-251-5/+5
| | | | --
* scd: Support for SmartCard-HSMAndreas Schwier2014-07-254-1/+2027
| | | | | | | | | | | | | | | | | | * scd/app-sc-hsm.c: New. * scd/app.c (select_application, get_supported_applications): Register new app. -- Add a read/only driver for scdaemon that provides access to keys and certificates on a SmartCard-HSM (www.smartcard-hsm.com). The driver supports RSA and ECC keys on SmartCard-HSM cards and USB-Sticks. The driver does not yet support the MicroSD edition. -- ChangeLog and FSF copyright year fix by wk.
* scd: Do not use the pcsc-wrapper.Werner Koch2014-07-223-10/+5
| | | | | | | | * scd/apdu.c (NEED_PCSC_WRAPPER): Do not define. * scd/Makefile.am (libexec_PROGRAMS): Remove gnupg-pcsc-wrapper (gnupg_pcsc_wrapper_SOURCES): Remove. (gnupg_pcsc_wrapper_LDADD): Remove. (gnupg_pcsc_wrapper_CFLAGS): Remove.
* scd: Add pinpad support for REINER SCT cyberJack goNIIBE Yutaka2014-06-272-0/+3
| | | | | | | | | | * scd/ccid-driver.h (VENDOR_REINER, CYBERJACK_GO): New. * scd/ccid-driver.c (ccid_transceive_secure): Handle the case for VENDOR_REINER. Original work was by Alina Friedrichsen (tiny change). -- This is revised version which adapts changes of ccid-driver and was later ported from branch-2.0 to master (2.1)
* scd: Support reader Gemalto IDBridge CT30Werner Koch2014-06-272-0/+6
| | | | | | | | | * scd/ccid-driver.h (GEMPC_CT30): New product id. * scd/ccid-driver.c (parse_ccid_descriptor): Add quirk for that reader. -- GnuPG-bug-id: 1638
* Make more use of *_NAME macros.Werner Koch2014-05-081-7/+10
| | | | | | | | | * configure.ac (GPG_DISP_NAME, GPGSM_DISP_NAME): New. (GPG_AGENT_DISP_NAME, SCDAEMON_DISP_NAME): New. (DIRMNGR_DISP_NAME, G13_DISP_NAME): New. (GPGCONF_DISP_NAME): New. (SCDAEMON_SOCK_NAME): New. * common/argparse.c (show_help): Map description string.
* Use "samethread" mode keyword for some es_fopenmem.Werner Koch2014-05-061-1/+1
| | | | | | * dirmngr/ks-engine-hkp.c (armor_data): Add mode keyword. * g10/call-dirmngr.c (ks_put_inq_cb): Ditto. * scd/atr.c (atr_dump): Ditto.
* common: Cleanup the use of USE_NPTH and HAVE_NPTH macros.Werner Koch2014-05-021-12/+2
| | | | | | | | | | | | | | | | | * configure.ac (HAVE_NPTH): New ac_define. * common/estream.c: Use USE_NPTH instead of HAVE_NPTH. * common/http.c: Ditto. Replace remaining calls to pth by npth calls. (connect_server): Remove useless _(). * common/exechelp-posix.c, common/exechelp-w32.c * common/exechelp-w32ce.c: Use HAVE_PTH to include npth.h. * common/init.c (_init_common_subsystems): Remove call to pth_init. * common/sysutils.c (gnupg_sleep): Use npth_sleep. * scd/ccid-driver.c (my_sleep): Ditto. -- USE_NPTH is used in case were we may build with and without nPth. The missing definition HAVE_NPTH didn't allowed us to build outher sources with nPTh support.
* scd: EdDSA support.NIIBE Yutaka2014-04-091-43/+121
| | | | | | | | | | | | | | | * scd/app-openpgp.c (KEY_TYPE_EDDSA, CURVE_ED25519): New. (struct app_local_s): Add eddsa. (get_algo_byte, store_fpr): Support KEY_TYPE_EDDSA. (get_ecc_key_parameters, get_curve_name): Support CURVE_ED25519. (send_key_attr, get_public_key): Support KEY_TYPE_EDDSA. (build_ecc_privkey_template): Rename as it supports both of ECDSA and EdDSA. (ecc_writekey): Rename. Support CURVE_ED25519, too. (do_writekey): Follow the change of ecc_writekey. (do_auth): Support KEY_TYPE_EDDSA. (parse_ecc_curve): Support CURVE_ED25519. Bug fix for other curves. (parse_algorithm_attribute): Bug fix for ECDH. Support EdDSA.
* scd: Silent compiler warnings about unused variables.Werner Koch2014-04-081-0/+10
| | | | | | | * scd/app-openpgp.c (build_ecdsa_privkey_template): Mark unused arg. (ecdh_writekey): Mark unused args. Signed-off-by: Werner Koch <[email protected]>
* scd: writekey support of ECC.NIIBE Yutaka2014-03-121-93/+424
| | | | | | | | | | | | | * scd/app-openpgp.c (CURVE_SEC_P256K1, get_algo_byte): New. (store_fpr): Support ECC keys with varargs. (get_ecc_key_parameters, get_curve_name): Support secp256k1. (parse_ecc_curve): Likewise. (build_ecdsa_privkey_template, rsa_writekey, ecdsa_writekey): New. (ecdh_writekey): New. Not implemented yet. (do_writekey): Call rsa_writekey, ecdsa_writekey, or ecdh_writekey. (do_genkey): Follow the change of store_fpr. Signed-off-by: NIIBE Yutaka <[email protected]>
* scd: acquire lock in new_reader_slot.Werner Koch2014-03-101-48/+70
| | | | | | | | | | | | | | | | | | | | | * scd/apdu.c (new_reader_slot): Acquire lock. (open_ct_reader, open_pcsc_reader_direct, open_pcsc_reader_wrapped) (open_ccid_reader, open_rapdu_reader): Release lock. (lock_slot, trylock_slot, unlock_slot): Move more to the top. -- Fixes a test case of: No libpcsclite1 installed. Run gpg-agent Run command "gpg-connect-agent learn /bye" with no card/token Sometimes it fails: ERR 100663356 Not supported <SCD> While it should be always: ERR 100663404 Card error <SCD> (cherry picked from commit 4f557cb9c2ebe274d6aacc60a09cd919055d01ed) Resolved conflicts: scd/apdu.c: pth/npth changes. Move lock helpers to the top. Take care of removed pcsc_no_service.
* w32: Silence warnings about unused vars.Werner Koch2014-03-072-8/+14
| | | | | | | | | | | | * 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.
* Fix syntax error for building on APPLE.Werner Koch2014-03-071-1/+1
| | | | | | | | | | * scd/pcsc-wrapper.c [__APPLE__]: Fix syntax error. -- For W32 and probably for Cygwin we don't need the wrapper, thus the problems does not exhibit itself. (cherry picked from commit 8ddf604659b93754ffa6dea295678a8adc293f90)
* Ignore obsolete option --disable-keypad.Werner Koch2014-03-071-0/+3
| | | | | | | | | | | | | | | * scd/scdaemon.c (opts): Ignore --disable-keypad. -- The renaming of --disable-keypad to --disable-pinpad might mess up configuration files managed with a GUI. The GUI does not not anymore know about the old option and would allow the user to switch "disable-pinpad" on. However, a "disable-keypad" might still linger in the conf file with gpgconf not knowing about it. Thus the conf file would always be rejected and manual intervention would be required. Ignoring the old option nicely solves the problem. (cherry picked from commit e24e92d7e244edd578c0c1f0fba6e0070cb5f104)
* Make use of the *_NAME etc macros.Werner Koch2013-11-183-5/+5
| | | | | | | | | 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.
* scd: more pinpad input fix for PC/SC.NIIBE Yutaka2013-11-131-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
* scd: more pinpad fix.NIIBE Yutaka2013-11-111-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
* scd: pinpad fix for PC/SC on Windows.NIIBE Yutaka2013-10-291-1/+8
| | | | * scd/apdu.c (SCARD_CTL_CODE): Fix for Windows.