aboutsummaryrefslogtreecommitdiffstats
path: root/agent/pkdecrypt.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* agent:kem:ecc: Support a key on smartcard.NIIBE Yutaka2024-04-261-73/+211
| | | | | | | | | | | | | | | | | * agent/agent.h (agent_card_ecc_kem): New. * agent/divert-scd.c (agent_card_ecc_kem): New. * agent/pkdecrypt.c (ecc_extract_pk_from_key): New. (ecc_extract_sk_from_key): New. (ecc_raw_kem, get_cardkey, ecc_get_curve): New. (ecc_pgp_kem_decrypt): Support a key on smartcard for ECC. (composite_pgp_kem_decrypt): Handle a case of a key on smartcard. * common/sexputil.c (get_ecc_curve_from_key): New. * common/util.h (get_ecc_curve_from_key): New. -- GnuPG-bug-id: 7097 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent:kem: Fix memory leaks.NIIBE Yutaka2024-04-251-3/+6
| | | | | | | | | * agent/pkdecrypt.c (composite_pgp_kem_decrypt): Release shadow_info memory. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent:kem: Factor out ECC KEM operation from composite KEM.NIIBE Yutaka2024-04-241-107/+136
| | | | | | | | | * agent/pkdecrypt.c (ecc_pgp_kem_decrypt): New. (composite_pgp_kem_decrypt): Use ecc_pgp_kem_decrypt. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Simplify diverting operation to the smartcard.NIIBE Yutaka2024-04-241-10/+5
| | | | | | | | * agent/pkdecrypt.c (agent_pkdecrypt): Remove no_shadow_info variable. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Support Kyber with Brainpool512r1.Werner Koch2024-04-231-0/+6
| | | | | | | | | | | | | | * common/openpgp-oid.c (oidtable): Add GCRY_KEM_RAW_BP512. * agent/pkdecrypt.c (ecc_table): Support bp512 * g10/pkglue.c (do_encrypt_kem): Ditto. * tests/openpgp/samplekeys: Add sample keys for kyber_bp256, bp384, and bp512. * tests/openpgp/privkeys: Add corresponding private keys. * tests/openpgp/samplemsgs: Add sample messages for those keys. -- GnuPG-bug-id: 6815
* Require Libgcrypt 1.11.0Werner Koch2024-04-231-60/+69
| | | | | | | | | | * configure.ac (NEED_LIBGCRYPT_VERSION): Set to 1.11.0 * agent/pkdecrypt.c (struct ecc_params): Move constants to the top. -- It does not make anymore sense to allow building with older Libgcrypt versions. After all PQ key support is a major feature and for this we need Libgcrypt.
* agent:kem: More fix for PQC KEM with X448.NIIBE Yutaka2024-04-231-17/+16
| | | | | | | | | | | * agent/pkdecrypt.c (struct ecc_params): Remove NAME_LEN field. (ecc_table): Update. (get_ecc_params): Use strcmp. (composite_pgp_kem_decrypt): Fix the call of gnupg_kem_combiner. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent:kem: Support other ML-KEM variants.NIIBE Yutaka2024-04-231-11/+40
| | | | | | | | | | * agent/pkdecrypt.c (composite_pgp_kem_decrypt): Care about ML-KEM 512 and 1024. -- Co-authored-by: Werner Koch <[email protected]> Signed-off-by: NIIBE Yutaka <[email protected]>
* agent:kem: Support other ECC curves.NIIBE Yutaka2024-04-231-21/+105
| | | | | | | | | | * agent/pkdecrypt.c (ecc_table): New. (get_ecc_params): New. (composite_pgp_kem_decrypt): Support other curves. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Add more diagnostics to PQC decryption.Werner Koch2024-04-111-16/+69
| | | | | | | | * agent/pkdecrypt.c (composite_pgp_kem_decrypt): Use %d for correctness. Add error diagnostics and one extra check. -- GnuPG-bug-id: 7014
* agent: Rename the function using the word "composite"NIIBE Yutaka2024-04-111-5/+5
| | | | | | | | * agent/pkdecrypt.c (composite_pgp_kem_decrypt): Rename. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Fix PQC decryption.NIIBE Yutaka2024-04-111-28/+9
| | | | | | | | | | * agent/pkdecrypt.c (agent_hybrid_pgp_kem_decrypt): Change the format of SEXP in the protocol for symmetric cipher algorithm identifier. -- GnuPG-bug-id: 7014 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent:kem: Externalize FIXED_INFO.NIIBE Yutaka2024-04-101-18/+51
| | | | | | | | | * agent/pkdecrypt.c (agent_hybrid_pgp_kem_decrypt): Don't hard code the value of FIXED_INFO. Get it from frontend. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* common,agent: Factor out KEM functions into common/kem.c.NIIBE Yutaka2024-04-101-53/+44
| | | | | | | | | | | | | * common/util.h (compute_kmac256): Remove. (gnupg_ecc_kem_kdf, gnupg_kem_combiner): New. * common/kmac.c (compute_kmac256): Don't expose. (gnupg_ecc_kem_kdf, gnupg_kem_combiner): New. * agent/pkdecrypt.c (agent_hybrid_pgp_kem_decrypt): Use gnupg_ecc_kem_kdf and gnupg_kem_combiner. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Make "PKDECRYPT --kem" with optional value work.Werner Koch2024-04-051-0/+4
| | | | | | | | | | | | * agent/command.c (cmd_pkdecrypt): Fix comparison. * agent/agent.h (enum kemids): Rename type and strip trailing comma. * agent/pkdecrypt.c (agent_hybrid_pgp_kem_decrypt): Allow building with Libgcrypt < 1.11 -- Eventually we should change the libgcrypt requirement in configure.
* agent: Add initial support for hybrid ECC+PQC decryption with KEM.NIIBE Yutaka2024-04-051-1/+311
| | | | | | | | | | | | | | | | | * agent/agent.h (enum kemid): New. (agent_kem_decrypt): New. * agent/command.c (cmd_pkdecrypt): Support --kem option to call agent_kem_decrypt. * agent/pkdecrypt.c (reverse_buffer): New. (agent_hybrid_pgp_kem_decrypt): New. (agent_kem_decrypt): New. -- Now, it only supports X25519 + ML-KEM. GnuPG-bug-id: 7014 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Show "no secret key" instead of "card removed".Werner Koch2023-03-011-4/+11
| | | | | | | | | | | | | | | * agent/findkey.c (agent_key_from_file): Check the error of read_key_file again. * agent/pkdecrypt.c (agent_pkdecrypt): Restore error if no card was found. Also remove useless condition. -- The first patch fixes a likely merge error. The second is about the actual return code: If we have no smardcard but simply try to decrypt with the current smartcard we should return the originla error code. GnuPG-bug-id: 5170 Fixes-commit: eda3c688fc2e85c7cd63029cb9caf06552d203b4
* agent: Move confirmation handling into findkey.c.NIIBE Yutaka2022-05-201-3/+3
| | | | | | | | | | | | | | | | | | * agent/agent.h (divert_tpm2_pksign, divert_tpm2_pkdecrypt): Fix API. (divert_pksign, divert_pkdecrypt): Likewise. * agent/divert-scd.c (ask_for_card): Remove. (divert_pksign, divert_pkdecrypt): Don't call ask_for_card. * agent/divert-tpm2.c (divert_tpm2_pksign, divert_tpm2_pkdecrypt): Remove DESC_TEXT argument. * agent/findkey.c (prompt_for_card): New (was: ask_for_card). (agent_key_from_file): Call prompt_for_card when it's a key on card. * agent/pkdecrypt.c (agent_pkdecrypt): Follow the change of API. * agent/pksign.c (agent_pksign_do): Likewise. -- Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Supply GRIP=NULL for agent_key_from_file, for real use.NIIBE Yutaka2022-05-191-1/+1
| | | | | | | | | | | | * agent/findkey.c (agent_key_from_file): Change the semantics of GRIP. Now, it's NULL for use by PKDECRYPT and PKSIGN/PKAUTH. * agent/pkdecrypt.c (agent_pkdecrypt): Set GRIP=NULL. * agent/pksign.c (agent_pksign_do): Likewise. -- GnuPG-bug-id: 5099 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Use "Created:" field for creation time.NIIBE Yutaka2022-03-251-1/+1
| | | | | | | | | | | | | | * agent/agent.h (agent_key_from_file): Change the declaration. * agent/findkey.c (agent_key_from_file): Return timestamp. * agent/pkdecrypt.c (agent_pkdecrypt): Follow the change. * agent/pksign.c (agent_pkdecrypt): Likewise. * agent/command.c (cmd_passwd, cmd_export_key): Likewise. (cmd_keytocard): Use timestamp in private key file in "Created:". -- GnuPG-bug-id: 5538 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Add new shadow key type and functions to call tpm2daemonJames Bottomley2021-03-101-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * agent/call-tpm2d.c: New. * divert-tpm2.c: New. * agent/Makefile.am: Add new files. * agent/agent.h (DAEMON_TPM2D): New. Add stub fucntions. * agent/call-daemon.c (GNUPG_MODULE_NAME_TPM2DAEMON): New. * agent/command.c (do_one_keyinfo): Handle tpmv2. * agent/gpg-agent.c (oTpm2daemonProgram): New. (opts): New option --tpm2daemon-program. (parse_rereadable_options): Handle option. * agent/pkdecrypt.c (agent_pkdecrypt): Divert to tpm2d. (agent_pksign_do): Ditto. --- A new shadow key type: "tpm2-v1" is introduced signalling that the shadowed key is handled by the tpm2daemon. A function to identify this type is introduced and diversions to the tpm2daemon functions are conditioned on this function for pkign and pkdecrypt where the same diversions to scd are currently done. The (info) field of the shadowed key stores the actual TPM key. The TPM key is encrypted so only the physical TPM it was created on can read it (so no special protection is required for the info filed), but if the (info) field becomes corrupt or damaged, the key will be lost (unlike the token case, where the key is actually moved inside the token). Note, this commit adds handling for existing TPM format shadow keys, but there is still no way to create them. Signed-off-by: James Bottomley <[email protected]> Additional changes: * Add ChangeLog entries. * Some minor indentation fixes. * agent/Makefile.am (gpg_agent_SOURCES): Change to make distcheck work. * agent/agent.h [!HAVE_LIBTSS]: Do not return -EINVAL but an gpg_error_t. Mark args as unused. * agent/protect.c (agent_is_tpm2_key): Free BUF. Signed-off-by: Werner Koch <[email protected]>
* agent: Allow decryption with card but no file.NIIBE Yutaka2020-12-081-2/+5
| | | | | | | | | | * agent/pkdecrypt.c (agent_pkdecrypt): Support decryption with card but without a stub key. -- GnuPG-bug-id: 5170 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Clean up the API of agent_pkdecrypt.NIIBE Yutaka2020-12-081-21/+21
| | | | | | | * agent/agent.h (agent_pkdecrypt): Use gpg_error_t type. * agent/pkdecrypt.c (agent_pkdecrypt): Use gpg_error_t type. Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Support scdaemon operation using KEYGRIP.NIIBE Yutaka2019-05-151-2/+2
| | | | | | | | | | | | | | | | | | | | | * agent/agent.h (struct card_key_info_s): New. (divert_pksign, divert_pkdecrypt): New API. * agent/call-scd.c (card_keyinfo_cb): New. (agent_card_free_keyinfo, agent_card_keyinfo): New. * agent/divert-scd.c (ask_for_card): Having GRIP argument, ask scdaemon with agent_card_keyinfo. (divert_pksign, divert_pkdecrypt): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Supply GRIP. * agent/pksign.c (agent_pksign_do): Ditto. -- We are going to relax the requirment for SERIALNO of card. It's OK, when a card doesn't have recorded SERIALNO. If a card has a key with GRIP, it can be used. GnuPG-bug-id: 2291, 4301 Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Replace most assert by log_assert.Werner Koch2019-05-141-3/+2
| | | | --
* Use the gpgrt log functions if possible.Werner Koch2017-11-271-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * common/logging.c: Do not build any code if we can use the gpgrt_log functions. (log_logv_with_prefix): Rename to log_logv_prefix and change order of args so that this function matches its printf like counterpart gpgrt_logv_prefix. Change all callers. (log_debug_with_string): Rename to log_debug_string. Change all callers. (log_printhex): Move first arg to end so that this function matches its printf like counterpart gpgrt_log_printhex. Change all callers. * common/logging.h: Divert to gpgrt/libgpg-error if we can use the gpgrt_log functions. (bug_at): Add inline versions if we can use the gpgrt_log functions. * configure.ac (GPGRT_ENABLE_LOG_MACROS): Add to AH_BOTTOM. (mycflags): Add -Wno-format-zero-length. -- This patch enables the use of the log function from libgpgrt (aka libgpg-error). Instead of checking a version number, we enable them depending on macros set by recent gpg-error versions. Eventually the whole divert stuff can be removed. The -Wno-format-zero-length is required because log_printhex can be called with an empty format string. Note that this is fully specified standard C behaviour. Signed-off-by: Werner Koch <[email protected]>
* Spelling fixes in docs and comments.NIIBE Yutaka2017-04-281-1/+1
| | | | | | | | | | -- In addition, fix trailing spaces in tests/inittests. GnuPG-bug-id: 3121 Reported-by: ka7 (klemens) Signed-off-by: NIIBE Yutaka <[email protected]>
* agent: Prepare to pass an additional parameter to the getpin callback.Werner Koch2017-02-221-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | * agent/call-scd.c (writekey_parm_s, inq_needpin_s): Merge into ... (inq_needpin_parm_s): new struct. Add new field 'getpin_cb_desc'. Change users to set all fields. (inq_needpin): Pass GETPIN_CB_DESC to the GETPIN_CB. (agent_card_pksign): Add arg 'desc_text' and change arg 'getpin_cb' to take an additional arg 'desc_text'. (agent_card_pkdecrypt): Ditto. (agent_card_writekey): Change arg 'getpin_cb' to take an additional arg 'desc_text'. (agent_card_scd): Ditto. * agent/divert-scd.c (getpin_cb): Add new arg 'desc_text'. (divert_pksign): Add new arg 'desc_text' and pass is to agent_card_pksign. (divert_pkdecrypt): Add new arg 'desc_text' and pass is to agent_card_pkdecrypt. * agent/pkdecrypt.c (agent_pkdecrypt): Pass DESC_TEXT to divert_pkdecrypt. * agent/pksign.c (agent_pksign_do): Pass DESC_TEXT to divert_pksign. -- Signed-off-by: Werner Koch <[email protected]>
* Change all http://www.gnu.org in license notices to https://Werner Koch2016-11-051-1/+1
| | | | --
* agent: Replace some sprintf.Werner Koch2014-12-021-8/+3
| | | | | | | | | * agent/call-scd.c (agent_card_pksign): Replace sprintf by bin2hex. * agent/command-ssh.c (ssh_identity_register): Ditto. * agent/pkdecrypt.c (agent_pkdecrypt): Replace sprintf by put_membuf_printf. Signed-off-by: Werner Koch <[email protected]>
* agent: Return NO_SECKEY instead of ENONET for PKSIGN and others.Werner Koch2014-08-181-3/+1
| | | | | | * agent/pksign.c (agent_pksign_do): Replace ENONET by NO_SECKEY. * agent/findkey.c (agent_key_from_file): No diagnostic for NO_SECKEY. * agent/pkdecrypt.c (agent_pkdecrypt): Replace checking for ENOENT.
* agent: API change of agent_key_from_file.NIIBE Yutaka2014-03-111-1/+1
| | | | | | | | | | | | * agent/findkey.c (agent_key_from_file): Always return S-expression. * agent/command.c (cmd_passwd): Distinguish by SHADOW_INFO. (cmd_export_key): Likewise. Free SHADOW_INFO. (cmd_keytocard): Likewise. Release S_SKEY. * agent/pkdecrypt.c (agent_pkdecrypt): Likewise. * agent/pksign.c (agent_pksign_do): Likewise. Use the S-expression to know the key type. Signed-off-by: NIIBE Yutaka <[email protected]>
* gpg: Make decryption with the OpenPGP card work.Werner Koch2013-08-281-3/+7
| | | | | | | | | | | | | | | | | | | | | | | | * 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]>
* Nuked almost all trailing white space.post-nuke-of-trailing-wsWerner Koch2011-02-041-4/+2
| | | | | | | | 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.
* More agent support for gpg.Werner Koch2010-10-131-2/+0
|
* Exporting secret keys via gpg-agent is now basically supported.Werner Koch2010-10-011-1/+3
| | | | | | A couple of forward ported changes. Doc updates.
* s/CACHE_MODE_IMPGEN/CACHE_MODE_NONCE/.Werner Koch2010-09-011-1/+1
| | | | | Prepare for more use cases of the cache nonce.
* Fix bug #1053Werner Koch2009-05-151-1/+1
| | | | | Add option --qualitybar to command GET_PASSPHRASE.
* Print NO_SECKEY status line in gpgsm.Werner Koch2009-03-251-1/+4
| | | | | This fixes bug#1020.
* Changed to GPLv3.Werner Koch2007-07-041-4/+2
| | | | | Removed intl/.
* The big Assuan error code removal.Werner Koch2006-09-061-1/+1
|
* See ChangeLogsWerner Koch2006-08-291-6/+14
|
* Updated FSF's address.Werner Koch2006-06-201-1/+2
|
* gcc-4 defaults forced me to edit many many files to get rid of theWerner Koch2005-06-161-1/+1
| | | | | | | char * vs. unsigned char * warnings. The GNU coding standards used to say that these mismatches are okay and better than a bunch of casts. Obviously this has changed now.
* New debugging optionhs, updates to the manual.Werner Koch2005-06-071-1/+2
|
* * call-scd.c (init_membuf, put_membuf, get_membuf): Removed. WeWerner Koch2004-12-201-10/+12
| | | | | | | | | | | | | | | now use the identical implementation from ../common/membuf.c. * pksign.c (agent_pksign): Changed arg OUTFP to OUTBUF and use membuf functions to return the value. * pkdecrypt.c (agent_pkdecrypt): Ditto. * genkey.c (agent_genkey): Ditto. * command.c (cmd_pksign, cmd_pkdecrypt, cmd_genkey): Replaced assuan_get_data_fp() by a the membuf scheme. (clear_outbuf, write_and_clear_outbuf): New. * membuf.c (put_membuf): Wipe out buffer after a failed realloc.
* * command.c (cmd_setkeydesc): New.Werner Koch2004-02-131-2/+4
| | | | | | | | | | | | (register_commands): Add command SETKEYDESC. (cmd_pksign, cmd_pkdecrypt): Use the key description. (reset_notify): Reset the description. * findkey.c (unprotect): Add arg DESC_TEXT. (agent_key_from_file): Ditto. * pksign.c (agent_pksign): Ditto. * pkdecrypt.c (agent_pkdecrypt): Ditto. Made CIPHERTEXT an unsigned char*.
* * findkey.c (agent_key_from_file): Extra paranoid wipe.Werner Koch2004-02-031-6/+6
| | | | | | | | | | * protect.c (agent_unprotect): Ditto. (merge_lists): Ditto. Add arg RESULTLEN. * pkdecrypt.c (agent_pkdecrypt): Don't show the secret key even in debug mode. * protect.c: Add DSA and Elgamal description.
* * findkey.c (agent_key_from_file): Now return an error code soWerner Koch2004-01-161-3/+2
| | | | | | | | | that we have more detailed error messages in the upper layers. This fixes the handling pinentry's cancel button. * pksign.c (agent_pksign): Changed accordingly. * pkdecrypt.c (agent_pkdecrypt): Ditto. * command.c (cmd_passwd): Ditto.
* Mainly changes to adjust for the changed KSBA API.Werner Koch2003-11-121-1/+0
|