2003-06-05 07:14:21 +00:00
|
|
|
/* call-agent.h - Divert operations to the agent
|
|
|
|
* Copyright (C) 2003 Free Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2007-07-04 19:49:40 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-05 07:14:21 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2003-06-05 07:14:21 +00:00
|
|
|
*/
|
|
|
|
#ifndef GNUPG_G10_CALL_AGENT_H
|
2011-02-04 12:57:53 +01:00
|
|
|
#define GNUPG_G10_CALL_AGENT_H
|
2003-06-05 07:14:21 +00:00
|
|
|
|
2018-03-28 18:44:45 +09:00
|
|
|
struct key_attr {
|
|
|
|
int algo; /* Algorithm identifier. */
|
|
|
|
union {
|
|
|
|
unsigned int nbits; /* Supported keysize. */
|
|
|
|
const char *curve; /* Name of curve. */
|
|
|
|
};
|
|
|
|
};
|
2003-06-27 20:53:09 +00:00
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
struct agent_card_info_s
|
2006-05-23 16:19:43 +00:00
|
|
|
{
|
2003-06-27 20:53:09 +00:00
|
|
|
int error; /* private. */
|
2015-11-09 16:15:44 +09:00
|
|
|
char *reader; /* Reader information. */
|
2009-01-13 14:01:56 +00:00
|
|
|
char *apptype; /* Malloced application type string. */
|
2020-04-03 10:00:57 +02:00
|
|
|
unsigned int manufacturer_id;
|
|
|
|
char *manufacturer_name; /* malloced. */
|
2003-07-01 08:34:45 +00:00
|
|
|
char *serialno; /* malloced hex string. */
|
2003-06-27 20:53:09 +00:00
|
|
|
char *disp_name; /* malloced. */
|
2003-07-24 09:06:43 +00:00
|
|
|
char *disp_lang; /* malloced. */
|
|
|
|
int disp_sex; /* 0 = unspecified, 1 = male, 2 = female */
|
2003-06-27 20:53:09 +00:00
|
|
|
char *pubkey_url; /* malloced. */
|
2003-07-24 09:06:43 +00:00
|
|
|
char *login_data; /* malloced. */
|
2006-05-23 16:19:43 +00:00
|
|
|
char *private_do[4]; /* malloced. */
|
2018-08-27 16:57:04 +02:00
|
|
|
char cafpr1len; /* Length of the CA-fingerprint or 0 if invalid. */
|
|
|
|
char cafpr2len;
|
|
|
|
char cafpr3len;
|
2004-07-01 17:42:09 +00:00
|
|
|
char cafpr1[20];
|
|
|
|
char cafpr2[20];
|
|
|
|
char cafpr3[20];
|
2018-08-27 16:57:04 +02:00
|
|
|
unsigned char fpr1len; /* Length of the fingerprint or 0 if invalid. */
|
|
|
|
unsigned char fpr2len;
|
|
|
|
unsigned char fpr3len;
|
2003-06-27 20:53:09 +00:00
|
|
|
char fpr1[20];
|
|
|
|
char fpr2[20];
|
|
|
|
char fpr3[20];
|
2006-05-23 16:19:43 +00:00
|
|
|
u32 fpr1time;
|
|
|
|
u32 fpr2time;
|
|
|
|
u32 fpr3time;
|
2018-03-01 19:03:23 +01:00
|
|
|
char grp1[20]; /* The keygrip for OPENPGP.1 */
|
|
|
|
char grp2[20]; /* The keygrip for OPENPGP.2 */
|
|
|
|
char grp3[20]; /* The keygrip for OPENPGP.3 */
|
2003-07-24 09:06:43 +00:00
|
|
|
unsigned long sig_counter;
|
|
|
|
int chv1_cached; /* True if a PIN is not required for each
|
|
|
|
signing. Note that the gpg-agent might cache
|
|
|
|
it anyway. */
|
2008-09-25 10:06:02 +00:00
|
|
|
int is_v2; /* True if this is a v2 card. */
|
2003-07-24 09:06:43 +00:00
|
|
|
int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
|
|
|
|
int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
|
2018-03-28 18:44:45 +09:00
|
|
|
struct key_attr key_attr[3];
|
2009-07-22 17:21:47 +00:00
|
|
|
struct {
|
|
|
|
unsigned int ki:1; /* Key import available. */
|
|
|
|
unsigned int aac:1; /* Algorithm attributes are changeable. */
|
2018-03-22 15:50:31 +09:00
|
|
|
unsigned int kdf:1; /* KDF object to support PIN hashing available. */
|
2018-10-25 16:20:20 +09:00
|
|
|
unsigned int bt:1; /* Button for confirmation available. */
|
2009-07-22 17:21:47 +00:00
|
|
|
} extcap;
|
2014-12-15 17:38:40 +01:00
|
|
|
unsigned int status_indicator;
|
2019-07-19 13:26:49 +09:00
|
|
|
int kdf_do_enabled; /* Non-zero if card has a KDF object, 0 if not. */
|
2018-11-15 13:57:31 +09:00
|
|
|
int uif[3]; /* True if User Interaction Flag is on. */
|
2020-09-08 15:34:42 +09:00
|
|
|
strlist_t supported_keyalgo[3];
|
2003-06-27 20:53:09 +00:00
|
|
|
};
|
|
|
|
|
2020-02-12 17:29:51 +01:00
|
|
|
|
|
|
|
/* Object to store information from the KEYPAIRINFO or the KEYINFO
|
|
|
|
* status lines. */
|
|
|
|
struct keypair_info_s
|
2020-01-16 13:01:46 +09:00
|
|
|
{
|
2020-02-12 17:29:51 +01:00
|
|
|
struct keypair_info_s *next;
|
2020-02-13 14:03:59 +01:00
|
|
|
char keygrip[2 * KEYGRIP_LEN + 1]; /* Stored in hex. */
|
|
|
|
char *serialno; /* NULL or the malloced serialno. */
|
|
|
|
char *idstr; /* Malloced keyref (e.g. "OPENPGP.1") */
|
|
|
|
unsigned int usage; /* Key usage flags. */
|
|
|
|
u32 keytime; /* Key creation time from the card's DO. */
|
|
|
|
int algo; /* Helper to store the pubkey algo. */
|
2020-01-16 13:01:46 +09:00
|
|
|
};
|
2020-02-12 17:29:51 +01:00
|
|
|
typedef struct keypair_info_s *keypair_info_t;
|
2003-07-23 07:11:06 +00:00
|
|
|
|
|
|
|
/* Release the card info structure. */
|
|
|
|
void agent_release_card_info (struct agent_card_info_s *info);
|
|
|
|
|
2003-06-27 20:53:09 +00:00
|
|
|
/* Return card info. */
|
2015-04-03 17:39:59 +09:00
|
|
|
int agent_scd_learn (struct agent_card_info_s *info, int force);
|
2014-10-19 14:09:04 +02:00
|
|
|
|
2019-04-01 18:37:02 +02:00
|
|
|
/* Get the keypariinfo directly from scdaemon. */
|
2019-04-03 17:45:35 +02:00
|
|
|
gpg_error_t agent_scd_keypairinfo (ctrl_t ctrl, const char *keyref,
|
2020-02-13 14:03:59 +01:00
|
|
|
keypair_info_t *r_list);
|
2019-04-01 18:37:02 +02:00
|
|
|
|
2017-03-16 14:32:51 +09:00
|
|
|
/* Return list of cards. */
|
|
|
|
int agent_scd_cardlist (strlist_t *result);
|
|
|
|
|
2020-02-12 17:29:51 +01:00
|
|
|
/* Free a keypair info list. */
|
|
|
|
void free_keypair_info (keypair_info_t l);
|
2020-01-16 13:01:46 +09:00
|
|
|
|
|
|
|
/* Return card key information. */
|
|
|
|
gpg_error_t agent_scd_keyinfo (const char *keygrip, int cap,
|
2020-02-12 17:29:51 +01:00
|
|
|
keypair_info_t *result);
|
2020-01-16 13:01:46 +09:00
|
|
|
|
2017-03-16 14:32:51 +09:00
|
|
|
/* Return the serial number, possibly select by DEMAND. */
|
|
|
|
int agent_scd_serialno (char **r_serialno, const char *demand);
|
|
|
|
|
2014-12-15 17:38:40 +01:00
|
|
|
/* Send an APDU to the card. */
|
|
|
|
gpg_error_t agent_scd_apdu (const char *hexapdu, unsigned int *r_sw);
|
|
|
|
|
2019-04-03 15:30:10 +02:00
|
|
|
/* Get attribute NAME from the card and store at R_VALUE. */
|
|
|
|
gpg_error_t agent_scd_getattr_one (const char *name, char **r_value);
|
|
|
|
|
2003-09-30 17:34:38 +00:00
|
|
|
/* Update INFO with the attribute NAME. */
|
|
|
|
int agent_scd_getattr (const char *name, struct agent_card_info_s *info);
|
|
|
|
|
2021-03-09 13:50:30 -08:00
|
|
|
/* send the KEYTOTPM command */
|
|
|
|
int agent_keytotpm (ctrl_t ctrl, const char *hexgrip);
|
|
|
|
|
2013-02-06 14:01:23 +09:00
|
|
|
/* Send the KEYTOCARD command. */
|
|
|
|
int agent_keytocard (const char *hexgrip, int keyno, int force,
|
|
|
|
const char *serialno, const char *timestamp);
|
|
|
|
|
2003-06-27 20:53:09 +00:00
|
|
|
/* Send a SETATTR command to the SCdaemon. */
|
2019-04-01 18:12:35 +02:00
|
|
|
gpg_error_t agent_scd_setattr (const char *name,
|
|
|
|
const void *value, size_t valuelen);
|
2003-06-27 20:53:09 +00:00
|
|
|
|
2008-09-23 09:57:45 +00:00
|
|
|
/* Send a WRITECERT command to the SCdaemon. */
|
|
|
|
int agent_scd_writecert (const char *certidstr,
|
|
|
|
const unsigned char *certdata, size_t certdatalen);
|
|
|
|
|
2003-06-27 20:53:09 +00:00
|
|
|
/* Send a GENKEY command to the SCdaemon. */
|
2016-10-20 13:30:47 +09:00
|
|
|
int agent_scd_genkey (int keyno, int force, u32 *createtime);
|
2003-06-27 20:53:09 +00:00
|
|
|
|
2019-04-02 18:57:09 +02:00
|
|
|
/* Send a READCERT command to the SCdaemon. */
|
2009-06-17 09:45:50 +00:00
|
|
|
int agent_scd_readcert (const char *certidstr,
|
|
|
|
void **r_buf, size_t *r_buflen);
|
|
|
|
|
2019-04-02 18:57:09 +02:00
|
|
|
/* Send a READKEY command to the SCdaemon. */
|
2020-02-13 14:03:59 +01:00
|
|
|
gpg_error_t agent_scd_readkey (ctrl_t ctrl, const char *keyrefstr,
|
2020-02-11 20:51:33 +01:00
|
|
|
gcry_sexp_t *r_result, u32 *r_keytime);
|
2019-04-02 18:57:09 +02:00
|
|
|
|
2003-07-23 07:11:06 +00:00
|
|
|
/* Change the PIN of an OpenPGP card or reset the retry counter. */
|
2006-05-23 16:19:43 +00:00
|
|
|
int agent_scd_change_pin (int chvno, const char *serialno);
|
2003-06-27 20:53:09 +00:00
|
|
|
|
2003-10-21 17:12:21 +00:00
|
|
|
/* Send the CHECKPIN command to the SCdaemon. */
|
|
|
|
int agent_scd_checkpin (const char *serialno);
|
|
|
|
|
2006-10-04 16:45:04 +00:00
|
|
|
/* Send the GET_PASSPHRASE command to the agent. */
|
|
|
|
gpg_error_t agent_get_passphrase (const char *cache_id,
|
|
|
|
const char *err_msg,
|
|
|
|
const char *prompt,
|
|
|
|
const char *desc_msg,
|
2020-07-08 14:33:09 +02:00
|
|
|
int newsymkey,
|
2009-03-17 12:13:32 +00:00
|
|
|
int repeat,
|
2009-05-15 19:26:46 +00:00
|
|
|
int check,
|
2006-10-04 16:45:04 +00:00
|
|
|
char **r_passphrase);
|
|
|
|
|
|
|
|
/* Send the CLEAR_PASSPHRASE command to the agent. */
|
|
|
|
gpg_error_t agent_clear_passphrase (const char *cache_id);
|
|
|
|
|
2009-08-11 10:56:44 +00:00
|
|
|
/* Present the prompt DESC and ask the user to confirm. */
|
|
|
|
gpg_error_t gpg_agent_get_confirmation (const char *desc);
|
|
|
|
|
2010-01-08 19:18:49 +00:00
|
|
|
/* Return the S2K iteration count as computed by gpg-agent. */
|
2019-01-26 23:10:38 +01:00
|
|
|
unsigned long agent_get_s2k_count (void);
|
2010-01-08 19:18:49 +00:00
|
|
|
|
2010-04-21 16:26:17 +00:00
|
|
|
/* Check whether a secret key for public key PK is available. Returns
|
2020-01-17 15:11:02 +09:00
|
|
|
0 if not available, positive value if the secret key is available. */
|
|
|
|
int agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk);
|
2010-04-20 17:57:50 +00:00
|
|
|
|
Spelling cleanup.
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>
2020-02-18 09:34:42 -05:00
|
|
|
/* Ask the agent whether a secret key is available for any of the
|
2010-10-01 20:33:53 +00:00
|
|
|
keys (primary or sub) in KEYBLOCK. Returns 0 if available. */
|
|
|
|
gpg_error_t agent_probe_any_secret_key (ctrl_t ctrl, kbnode_t keyblock);
|
|
|
|
|
|
|
|
|
2010-04-20 17:57:50 +00:00
|
|
|
/* Return infos about the secret key with HEXKEYGRIP. */
|
|
|
|
gpg_error_t agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip,
|
2016-06-10 16:15:33 -04:00
|
|
|
char **r_serialno, int *r_cleartext);
|
2010-04-20 17:57:50 +00:00
|
|
|
|
|
|
|
/* Generate a new key. */
|
2016-06-02 21:21:08 +02:00
|
|
|
gpg_error_t agent_genkey (ctrl_t ctrl,
|
|
|
|
char **cache_nonce_addr, char **passwd_nonce_addr,
|
2010-10-14 16:34:31 +00:00
|
|
|
const char *keyparms, int no_protection,
|
2020-08-19 13:43:16 +02:00
|
|
|
const char *passphrase, time_t timestamp,
|
2010-04-20 17:57:50 +00:00
|
|
|
gcry_sexp_t *r_pubkey);
|
|
|
|
|
2020-02-11 20:51:33 +01:00
|
|
|
/* Read a public key. FROMCARD may be 0, 1, or 2. */
|
2011-11-06 17:01:31 +01:00
|
|
|
gpg_error_t agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
|
|
|
|
unsigned char **r_pubkey);
|
|
|
|
|
2010-04-21 16:26:17 +00:00
|
|
|
/* Create a signature. */
|
2010-09-01 12:49:05 +00:00
|
|
|
gpg_error_t agent_pksign (ctrl_t ctrl, const char *cache_nonce,
|
|
|
|
const char *hexkeygrip, const char *desc,
|
2013-02-07 20:37:58 +01:00
|
|
|
u32 *keyid, u32 *mainkeyid, int pubkey_algo,
|
2010-04-20 17:57:50 +00:00
|
|
|
unsigned char *digest, size_t digestlen,
|
|
|
|
int digestalgo,
|
|
|
|
gcry_sexp_t *r_sigval);
|
|
|
|
|
2010-04-23 11:36:59 +00:00
|
|
|
/* Decrypt a ciphertext. */
|
|
|
|
gpg_error_t agent_pkdecrypt (ctrl_t ctrl, const char *keygrip, const char *desc,
|
2013-02-07 20:37:58 +01:00
|
|
|
u32 *keyid, u32 *mainkeyid, int pubkey_algo,
|
2010-04-23 11:36:59 +00:00
|
|
|
gcry_sexp_t s_ciphertext,
|
2013-08-26 17:29:54 +02:00
|
|
|
unsigned char **r_buf, size_t *r_buflen,
|
|
|
|
int *r_padding);
|
2010-04-20 17:57:50 +00:00
|
|
|
|
2010-08-31 15:58:39 +00:00
|
|
|
/* Retrieve a key encryption key. */
|
|
|
|
gpg_error_t agent_keywrap_key (ctrl_t ctrl, int forexport,
|
|
|
|
void **r_kek, size_t *r_keklen);
|
|
|
|
|
|
|
|
/* Send a key to the agent. */
|
|
|
|
gpg_error_t agent_import_key (ctrl_t ctrl, const char *desc,
|
2015-12-24 14:15:58 +09:00
|
|
|
char **cache_nonce_addr, const void *key,
|
2017-07-24 17:18:42 +02:00
|
|
|
size_t keylen, int unattended, int force,
|
2020-08-19 13:43:16 +02:00
|
|
|
u32 *keyid, u32 *mainkeyid, int pubkey_algo,
|
|
|
|
u32 timestamp);
|
2010-08-31 15:58:39 +00:00
|
|
|
|
2010-10-01 20:33:53 +00:00
|
|
|
/* Receive a key from the agent. */
|
|
|
|
gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip,
|
2016-06-10 16:15:34 -04:00
|
|
|
const char *desc, int openpgp_protected,
|
|
|
|
char **cache_nonce_addr,
|
2017-07-24 16:03:25 +02:00
|
|
|
unsigned char **r_result, size_t *r_resultlen,
|
2018-11-15 12:19:02 +09:00
|
|
|
u32 *keyid, u32 *mainkeyid, int pubkey_algo);
|
2010-10-01 20:33:53 +00:00
|
|
|
|
2014-04-15 16:40:48 +02:00
|
|
|
/* Delete a key from the agent. */
|
|
|
|
gpg_error_t agent_delete_key (ctrl_t ctrl, const char *hexkeygrip,
|
2016-05-10 11:01:42 +02:00
|
|
|
const char *desc, int force);
|
2014-04-15 16:40:48 +02:00
|
|
|
|
2010-10-26 09:10:29 +00:00
|
|
|
/* Change the passphrase of a key. */
|
|
|
|
gpg_error_t agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc,
|
2016-06-02 21:21:08 +02:00
|
|
|
int verify,
|
2010-10-26 09:10:29 +00:00
|
|
|
char **cache_nonce_addr, char **passwd_nonce_addr);
|
2014-09-19 19:38:13 +02:00
|
|
|
/* Get the version reported by gpg-agent. */
|
|
|
|
gpg_error_t agent_get_version (ctrl_t ctrl, char **r_version);
|
2006-10-04 16:45:04 +00:00
|
|
|
|
2003-06-27 20:53:09 +00:00
|
|
|
|
2010-10-26 09:10:29 +00:00
|
|
|
#endif /*GNUPG_G10_CALL_AGENT_H*/
|