aboutsummaryrefslogtreecommitdiffstats
path: root/scd/app-nks.c (unfollow)
Commit message (Collapse)AuthorFilesLines
2022-11-25scd: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-11-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 -- Backported-from-master: 959c627892121ce9707bfa36f2510216b4f6f247 GnuPG-bug-id: 6252
2022-11-25scd: Use app_get_slot at more places.Werner Koch1-7/+8
-- This is helpful for backporting other changes.
2022-11-25scd: Use APP_LEARN_FLAG_KEYPAIRINFO with more apps.Werner Koch1-1/+1
* scd/app-nks.c (do_learn_status_core): Use new flag. * scd/app-sc-hsm.c (do_learn_status): Ditto. -- The flag was already backported to some apps but not to these.
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-28scd:nks: Support non-ESIGN signing with the Signature Card v2Werner Koch1-8/+20
* scd/app-nks.c (do_sign): Handle ECC for NKS cards -- Backported-from-master: 959c627892121ce9707bfa36f2510216b4f6f247 GnuPG-bug-id: 6252
2022-10-28scd: Use app_get_slot at more places.Werner Koch1-7/+8
-- This is helpful for backporting other changes.
2022-10-28scd: Use APP_LEARN_FLAG_KEYPAIRINFO with more apps.Werner Koch1-1/+1
* scd/app-nks.c (do_learn_status_core): Use new flag. * scd/app-sc-hsm.c (do_learn_status): Ditto. -- The flag was already backported to some apps but not to these.
2022-10-20scd: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. (cherry picked from commit 3a2fb1c30633373d17880469e0b84ab2a9524585)
2022-10-20scd: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. (cherry picked from commit b92b3206e72b635fd815eaf85e7acc67c2a52ffe)
2022-10-20scd: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, 6252 Backported-from-master: 07eaf006c2763a6b40d2734b1c6704da466e0ed0
2022-10-20scd:nks: Return USAGE information for KEYINFO command.NIIBE Yutaka1-21/+20
* 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/command.c (send_keyinfo): Add arg usage. -- Signed-off-by: NIIBE Yutaka <[email protected]> Backported-from-master: 5264d3f58e8a8362900c3518bdd683ff9a23cccc GnuPG-bug-id: 6252 This backports only the NKS parts of the original patch Signed-off-by: Werner Koch <[email protected]>
2022-10-20scd:nks: Handle APP_READKEY_FLAG_INFO.Werner Koch1-52/+117
* scd/app-nks.c (keygripstr_from_pk_file): Fix ignored error. (get_nks_tag): New. (do_learn_status_core): Use it. Make sure not to mange the KEYPAIRINFO line if no usage is known. (do_readkey): Output the KEYPAIRINFO for the keygrip case. -- Note that this only handles the most common case of providing a keygrip. $AUTHKEYID and ODLM are not yet supported. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 63320ba2f8147ee86f4406c9590f6b28cad4771d)
2022-10-20scd:nks: Add support for signing plain SHA-2 digests.Ingo Klöcker1-17/+67
* scd/app-nks.c (do_sign): Handle plain SHA-2 digests and verify encoding of ASN.1 encoded hashes. -- This makes it possible to create CSRs for NetKey card keys which are signed with SHA256 by default. GnuPG-bug-id: 5184 (cherry picked from commit 8fe976d5b9a0f2902868737dd502c749565222a6)
2022-10-20scd:nks: Support READKEY with keygrip and for "NKS-IDLM" keyref.NIIBE Yutaka1-0/+22
* scd/app-nks.c (do_readkey): Allow KEYGRIP access. Support NKS-IDLM.XXXX keyref. -- GnuPG-bug-id: 5150 Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 3b392630881350baabeba16fa760bad04be94d03)
2022-10-20scd:nks: Factor out pubkey retrieval from keygrip handling.NIIBE Yutaka1-84/+72
* scd/app-nks.c (pubkey_from_pk_file): New. (keygripstr_from_pk_file): Use pubkey_from_pk_file. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit b7c087375d84c31ab8a645cd81e6b1e6185cb30d)
2022-10-20scd:nks: Add support of KEYGRIP for do_readcert.NIIBE Yutaka1-0/+18
* scd/app-nks.c (do_readcert): Support KEYGRIP. -- GnuPG-bug-id: 5150 Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 4020cd9d656264bec5e7fb5e45c5e06eff8656c3)
2022-10-20scd:nks: Factor out iteration over filelist.NIIBE Yutaka1-78/+114
* scd/app-nks.c (iterate_over_filelist): New. (do_with_keygrip): Use iterate_over_filelist. Signed-off-by: NIIBE Yutaka <[email protected]> (cherry picked from commit 6c4365847666cefac73ccc743a99fac473da2186)
2022-10-20scd:nks: Fix caching keygrip (more).NIIBE Yutaka1-5/+7
* scd/app-nks.c (keygripstr_from_pk_file): Distinguish by APP_ID. -- GnuPG-bug-id: 5150, 5161 Signed-off-by: NIIBE Yutaka <[email protected]> Backported-from-master: 87d2c579cc38c1d2787945650125fb0e0336652c Fixes-commit: 00f594e3ecb26b010e87d5491b648369e7a92408
2022-10-20scd:nks: Minor additions to the basic IDLM application support.Werner Koch1-15/+25
* scd/app-nks.c (filelist): Use special value -1 for IDLM pubkeys. (keygripstr_from_pk_file): Handle special value. (do_readcert): Ditto. (do_writecert): Ditto. -- This allows to get information about the keys from the card. However the do_readkey still requires a fallback to readcert. This does not work because there are no certificates yet on the card. The fix is to fully implement do_readkey. (cherry picked from commit 806547d9d243b26c2275fc00c645ee39d258b49b)
2022-10-20scd,nks: Fix caching keygrip.NIIBE Yutaka1-3/+4
* scd/app-nks.c (keygripstr_from_pk_file): Identify by cfid if available. -- GnuPG-bug-id: 5150, 6252 Signed-off-by: NIIBE Yutaka <[email protected]> Backported-from-master: 920154370834ad8d947aed19c9d914a27dde6baa:
2022-10-20scd:nks: Emit the algo string with KEYPAIRINFOWerner Koch1-15/+48
* scd/app-nks.c (do_learn_status_core): Emit the algo string as part of a KEYPAIRINFO. (struct fid_cache_s): Add field algostr. (flush_fid_cache): Release it. (keygripstr_from_pk_file): Fill it and add it to the cache. Use a single exit label. Set algostr. -- Signed-off-by: Werner Koch <[email protected]> Backported-from-master: 26da47ae53d51e16ae6867cd419ddbf124a94933 Backported-from-master: 006944b856ee2202905290e8a2f5523a7877d444 GnuPG-bug-id: 6252, 5144 This has been backported to keep this, and only this, module in sync with master. All other changes from the original patch have been stripped.
2022-10-20scd:nks: Implement writecert for the Signature card v2.Werner Koch1-8/+110
* scd/iso7816.c (CMD_UPDATE_BINARY): New. (iso7816_update_binary): New. * scd/app-nks.c (do_deinit): Factor some code out to... (flush_fid_cache): new. (do_writecert): New. (app_select_nks): Register new handler. -- This has been backported only to make the following backpoorts easier. The code is only used in 2.3; for details see the original commit message. Signed-off-by: Werner Koch <[email protected]> Backported-from-master: c1663c690b29d2dea8bc782c42de5eca08a24cc9 GnuPG-bug-id: 6252
2022-10-20scd:nks: Fix certificate read problem with TCOS signature card v2.Werner Koch1-0/+2
* scd/app-nks.c (filelist): Add a dedicated key entry for ESIGN. (do_readcert): Test for the app_id. -- Signed-off-by: Werner Koch <[email protected]> Backported-from-master: 07aef873ebc77241e9a2be225537319f6fc15a41 GnuPG-bug-id: 6252
2022-10-20scd:nks: Fix remaining tries warning in --reset mode.Werner Koch1-9/+10
* scd/app-nks.c (do_change_pin): Change computation of 'remaining'. -- Signed-off-by: Werner Koch <[email protected]> Backported-from-master: 2429e8559844e27de478d7e90834a714b3748834 GnuPG-bug-id: 6252
2022-10-20scd:nks: Add framework to support IDKey cards.Werner Koch1-51/+124
* scd/app-nks.c (NKS_APP_IDLM): New. (struct app_local_s): Replace NKS_VERSION by the global APPVERSION. (do_learn_status): Always send CHV-STATUS. (find_fid_by_keyref): Basic support for IDLM only use. (do_learn_status_core): Ditto. (do_readcert): Ditto. (verify_pin): Ditto. (parse_pwidstr): Ditto. (do_with_keygrip): Ditto. (switch_application): Ditto. (app_select_nks): Fallback to IDLM. -- Backported-from-master: 1f6a39092fe4b5f02bc4741a0a23d102d30f4063 GnuPG-bug-id: 6252 Also not directly required for the Signature Card 2.0, it is easier to port this patch as well.
2022-10-20scd:nks: Get the PIN prompts right for the Signature CardWerner Koch1-56/+136
* scd/app-nks.c (get_dispserialno): Move more to the top. (do_getattr): Add $DISPSERIALNO and SERIALNO. Make CHV-STATUS work with NKS15. (verify_pin): Use dedicated min. PIN lengths. (parse_pwidstr): Support NKS15 -- GnuPG-bug-id: 4938 Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit aecc008acb64ebbb6c667c4a128af4e61da57f84)
2022-10-20scd:nks: Support decryption using ECDH.Werner Koch1-74/+307
* scd/app-nks.c (struct fid_cache_s): Add field 'algo'. (keygripstr_from_pk_file): Add arg 'r_algo' to return the algo. (find_fid_by_keyref): Ditto. (get_dispserialno): New. (make_prompt): New. (verify_pin): Provide better prompts. (do_decipher): Support ECDH. (parse_pwidstr): Add hack tospecify any pwid.. (do_change_pin): Support Signature Card V2.0 (NKS15) style NullPIN. Provide a better prompt. -- GnuPG-bug-id: 4938, 6252 Signed-off-by: Werner Koch <[email protected]> Backported-from-master: af45d884aa1c3eccbc6972a2e5197ece3fd1987a
2022-10-20scd:nks: Add do_with_keygrip and implement a cache.Werner Koch1-90/+349
* scd/app-nks.c (struct fid_cache_s): New. (struct app_local_s): Add field 'fid_cache'. (do_deinit): Release the cache. (keygripstr_from_pk_file): Implement the cache. (find_fid_by_keyref): New (do_sign, do_decipher): Use new function. (do_with_keygrip): New. -- Signed-off-by: Werner Koch <[email protected]> Backported-from-master: 1e72a1a218490c0fc07811a02ddad6cc38913f77 GnuPG-bug-id: 6252
2022-10-20scd:nks: Allow retrieving certificates from a Signature Card v.20Werner Koch1-165/+302
* scd/app-nks.c: Major rework to support non-RSA cards. -- This is a fist step so support this ECC card. The code has been reworked while taking care that old cards should keep on working. Signed-off-by: Werner Koch <[email protected]> Backported-from-master: f05a32e5c9db7d0840c74fccc350a9e0ff5fb819 GnuPG-bug-id: 6252
2021-05-20Assorted memory leak fixes on the error code paths.Werner Koch1-1/+1
-- These are taken from these commits: 98c52ae * card: Intialize pointer to avoid double free fc5fac8 * kbx: Avoid uninitialized read fa0771f * g10: Avoid memory leaks 25aa353 * dirmgr: Avoid double free 33a2362 * agent: Fix memory leaks e6132bc * sm: Avoid memory leaks and double double-free 2af7bb2 * g10: Fix memory leaks 0d2c1e9 * dirmgr: clean up memory on error code paths GnuPG-bug-id: 5393 Signed-off-by: Werner Koch <[email protected]>
2021-04-29scd: Extend iso7816_select_pathWerner Koch1-1/+1
* scd/iso7816.c (iso7816_select_path): Add arg top_fd. * scd/app-nks.c (do_readkey): Adjust for this change (select_ef_by_path: Ditto. * common/tlv.h: Include membuf.h. -- Including membuf.h is just for easier backporting. In 2.3 it is actually required in tlv.h but in 2.2 we right now only use it indirect.
2021-02-19scd: Change parameters of readkey fucntion pointer.Werner Koch1-3/+3
* scd/app-common.h (APP_READKEY_FLAG_ADVANCED): New. (struct app_ctx_s): Replace param advanced by flags in readkey. Change all users.
2021-02-19scd: Pass ctrl parameter to more app functions.Werner Koch1-6/+12
* scd/app-common.h (struct app_ctx_s): Add parameter ctrl to function pointers for readkey, setattr, sign, auth, decipher, and check_pin. -- This is a yet another patch to allow for easier backporting.
2021-02-19scd: Change the apptype from a string to an enum.Werner Koch1-1/+1
* scd/app-common.h (cardtype_t): New. (apptype_t): New. (struct app_ctx_s): Change type of field apptype. Add fields appversion and cardtype. Adjust all app-*.c for the new type. * scd/app.c (supported_app_list): New. (strapptype): New. (apptype_from_name): New. (app_dump_state): Use strapptype. (app_write_learn_status): Ditto. (app_getattr): Ditto. (check_conflict): Use apptype_from_name and integer comparison. * scd/app-openpgp.c: Replace app->card_version by app->appversion. -- This is another patch to make backporting from 2.3 easier.
2021-02-19scd: Add some compatibility code for easier backporting.Werner Koch1-1/+0
* scd/app-common.h (APP_WRITEKEY_FLAG_FORCE): New. (APP_READKEY_FLAG_INFO): New. (APP_LEARN_FLAG_KEYPAIRINFO): New. (APP_LEARN_FLAG_MULTI): New. (struct app_ctx_s): New forward declaration. (struct app_ctx_s): Add members prep_reselect, reselect, and with_keygrip. (KEYGRIP_ACTION_SEND_DATA): New. (KEYGRIP_ACTION_WRITE_STATUS): New. (KEYGRIP_ACTION_LOOKUP): New. (APP_CARD): New macro. * scd/scdaemon.h: Include app-common.h and remove from all other files. (app_t): Move typedef to ... * scd/app-common.h: here. -- These changes will make it easier to backport changes from 2.3 to 2.2. Signed-off-by: Werner Koch <[email protected]>
2020-04-15scd: Factor common PIN status check out.Werner Koch1-41/+5
* scd/iso7816.h (ISO7816_VERIFY_ERROR): New. (ISO7816_VERIFY_NO_PIN): New. (ISO7816_VERIFY_BLOCKED): New. (ISO7816_VERIFY_NULLPIN): New. (ISO7816_VERIFY_NOT_NEEDED): New. * scd/iso7816.c (iso7816_verify_status): New. * scd/app-nks.c (get_chv_status): Use new function. -- Signed-off-by: Werner Koch <[email protected]> Backported from master: - Removed the non-existant app-piv.c patches. Signed-off-by: Werner Koch <[email protected]>
2019-08-21scd:nks: Extend keypairinfo with usage flags.Werner Koch1-0/+11
* scd/app-nks.c (do_learn_status_core): Return usage. Signed-off-by: Werner Koch <[email protected]>
2019-08-21scd: New standard attributes $ENCRKEYID and $SIGNKEYID.Werner Koch1-4/+20
* g10/call-agent.c (agent_scd_keypairinfo): Use --keypairinfo. * sm/call-agent.c (gpgsm_agent_scd_keypairinfo): Ditto. * scd/app-openpgp.c (do_getattr): Add attributes "$ENCRKEYID" and "$SIGNKEYID". * scd/app-nks.c (do_getattr): Add attributes too. -- We already have $AUTHKEYID to locate the keyref of the key to be used with ssh. It will also be useful to have default keyref for encryption and signing. For example, this will allow us to replace the use of "OPENPGP.2" by a app type specific keyref. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 2b1135cf920cf3d863813d60f032d476dcccfb58) Removed changes for the non-existing app-piv.c. Added support for NKS.
2019-01-22scd: Add option --clear to PASSWD.Werner Koch1-0/+3
* scd/command.c (cmd_passwd): Add option --clear. (send_status_printf): New. * scd/app-common.h (APP_CHANGE_FLAG_CLEAR): New. * scd/app-nks.c (do_change_pin): Return an error if that option is used. * scd/app-openpgp.c (do_change_pin): Ditto. -- Card application may support this option to clear the PIN verification status of a specific PIN. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 29929e65521279eabc98a67c766fe485057405a9)
2019-01-22scd: One new and one improved 7816 function.Werner Koch1-2/+2
* scd/apdu.c (apdu_send_direct): New arg R_SW. * scd/command.c (cmd_apdu): Ditto. * scd/iso7816.c (iso7816_apdu_direct): New arg R_SW. (iso7816_general_authenticate): New. * scd/app-nks.c (get_chv_status, get_nks_version): Pass NULL for new arg. -- iso7816_general_authenticate will be used for the PIV card support. The new arg to iso7816_apdu_direct and apdu_send_direct allows to get the raw status word back without the need to handle an output buffer. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 70bb5c7931598590b1acfae90bf4657f5911d2d3)
2017-03-07Remove -I option to common.NIIBE Yutaka1-3/+3
* dirmngr/Makefile.am (AM_CPPFLAGS): Remove -I$(top_srcdir)/common. * g10/Makefile.am (AM_CPPFLAGS): Ditto. * g13/Makefile.am (AM_CPPFLAGS): Ditto. * kbx/Makefile.am (AM_CPPFLAGS): Ditto. * scd/Makefile.am (AM_CPPFLAGS): Ditto. * sm/Makefile.am (AM_CPPFLAGS): Ditto. * tools/Makefile.am (AM_CPPFLAGS): Ditto. * Throughout: Follow the change. Signed-off-by: NIIBE Yutaka <[email protected]>
2017-03-06scd: Fix API of select_file/_path.NIIBE Yutaka1-4/+4
* scd/iso7816.c (iso7816_select_file, iso7816_select_path): Remove unused arguments. * scd/app-dinsig.c (do_readcert): Follow the change. * scd/app-help.c (app_help_read_length_of_cert): Likewise. * scd/app-nks.c (keygripstr_from_pk_file, do_readcert, do_readkey) (switch_application): Likewise. * scd/app-p15.c (select_and_read_binary, select_ef_by_path) (micardo_mse, app_select_p15): Likewise. * scd/app.c (app_new_register): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
2017-02-21Clean up word replication.Yuri Chornoivan1-1/+1
-- This fixes extra word repetitions (like "the the" or "is is") in the code and docs. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2016-11-05Change all http://www.gnu.org in license notices to https://Werner Koch1-1/+1
--
2016-11-04scd: Add --advanced option for READKEY.NIIBE Yutaka1-2/+6
* scd/command.c (cmd_readkey) : Support ADVANCED arg. * scd/app.c (app_readcert): Add ADVANCED arg. * scd/app-openpgp.c (do_readkey): Implement ADVANCED arg. * scd/app-nks.c (do_readkey): Error return with GPG_ERR_NOT_SUPPORTED. -- "SCD READKEY --advanced OPENPGP.3" returns key in advanced format. With this suport, poldi-ctrl will be no longer needed. Signed-off-by: NIIBE Yutaka <[email protected]>
2016-11-02Spelling: correct spelling of "passphrase".Daniel Kahn Gillmor1-1/+1
There were several different variant spellings of "passphrase". This should fix them all for all English text. I did notice that po/it.po contains multiple instances of "passhprase", which also looks suspect to me, but i do not know Italian, so i did not try to correct it. Signed-off-by: Daniel Kahn Gillmor <[email protected]>
2015-02-11Use inline functions to convert buffer data to scalars.Werner Koch1-1/+2
* 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]>
2013-08-30scd: Suppress gcc warning about possible uninitialized use.Werner Koch1-1/+4
* scd/app-nks.c (parse_pwidstr): Always init r_pwid. Signed-off-by: Werner Koch <[email protected]>
2013-08-28gpg: Make decryption with the OpenPGP card work.Werner Koch1-1/+4
* scd/app-common.h (APP_DECIPHER_INFO_NOPAD): New. * scd/app-openpgp.c (do_decipher): Add arg R_INFO. * scd/app-nks.c (do_decipher): Add arg R_INFO as a dummy. * scd/app.c (app_decipher): Add arg R_INFO. * scd/command.c (cmd_pkdecrypt): Print status line "PADDING". * agent/call-scd.c (padding_info_cb): New. (agent_card_pkdecrypt): Add arg R_PADDING. * agent/divert-scd.c (divert_pkdecrypt): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Ditto. * agent/command.c (cmd_pkdecrypt): Print status line "PADDING". * g10/call-agent.c (padding_info_cb): New. (agent_pkdecrypt): Add arg R_PADDING. * g10/pubkey-enc.c (get_it): Use padding info. -- Decryption using a card never worked in gpg 2.1 because the information whether the pkcs#1 padding needs to be removed was not available. Gpg < 2.1 too this info from the secret sub key but that has gone in 2.1. Signed-off-by: Werner Koch <[email protected]>