2003-06-05 09:14:21 +02: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 21:49:40 +02:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-05 09:14:21 +02: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
|
2007-07-04 21:49:40 +02:00
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
2003-06-05 09:14:21 +02:00
|
|
|
*/
|
|
|
|
#ifndef GNUPG_G10_CALL_AGENT_H
|
2011-02-04 12:57:53 +01:00
|
|
|
#define GNUPG_G10_CALL_AGENT_H
|
2003-06-05 09:14:21 +02:00
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2011-02-04 12:57:53 +01:00
|
|
|
struct agent_card_info_s
|
2006-05-23 18:19:43 +02:00
|
|
|
{
|
2003-06-27 22:53:09 +02:00
|
|
|
int error; /* private. */
|
2009-01-13 15:01:56 +01:00
|
|
|
char *apptype; /* Malloced application type string. */
|
2003-07-01 10:34:45 +02:00
|
|
|
char *serialno; /* malloced hex string. */
|
2003-06-27 22:53:09 +02:00
|
|
|
char *disp_name; /* malloced. */
|
2003-07-24 11:06:43 +02:00
|
|
|
char *disp_lang; /* malloced. */
|
|
|
|
int disp_sex; /* 0 = unspecified, 1 = male, 2 = female */
|
2003-06-27 22:53:09 +02:00
|
|
|
char *pubkey_url; /* malloced. */
|
2003-07-24 11:06:43 +02:00
|
|
|
char *login_data; /* malloced. */
|
2006-05-23 18:19:43 +02:00
|
|
|
char *private_do[4]; /* malloced. */
|
2004-07-01 19:42:09 +02:00
|
|
|
char cafpr1valid;
|
|
|
|
char cafpr2valid;
|
|
|
|
char cafpr3valid;
|
|
|
|
char cafpr1[20];
|
|
|
|
char cafpr2[20];
|
|
|
|
char cafpr3[20];
|
2003-06-27 22:53:09 +02:00
|
|
|
char fpr1valid;
|
|
|
|
char fpr2valid;
|
|
|
|
char fpr3valid;
|
|
|
|
char fpr1[20];
|
|
|
|
char fpr2[20];
|
|
|
|
char fpr3[20];
|
2006-05-23 18:19:43 +02:00
|
|
|
u32 fpr1time;
|
|
|
|
u32 fpr2time;
|
|
|
|
u32 fpr3time;
|
2003-07-24 11:06:43 +02: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 12:06:02 +02:00
|
|
|
int is_v2; /* True if this is a v2 card. */
|
2003-07-24 11:06:43 +02:00
|
|
|
int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
|
|
|
|
int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
|
2009-05-15 21:26:46 +02:00
|
|
|
struct { /* Array with key attributes. */
|
|
|
|
int algo; /* Algorithm identifier. */
|
|
|
|
unsigned int nbits; /* Supported keysize. */
|
2011-02-04 12:57:53 +01:00
|
|
|
} key_attr[3];
|
2009-07-22 19:21:47 +02:00
|
|
|
struct {
|
|
|
|
unsigned int ki:1; /* Key import available. */
|
|
|
|
unsigned int aac:1; /* Algorithm attributes are changeable. */
|
|
|
|
} extcap;
|
2014-12-15 17:38:40 +01:00
|
|
|
unsigned int status_indicator;
|
2003-06-27 22:53:09 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct agent_card_genkey_s {
|
|
|
|
char fprvalid;
|
|
|
|
char fpr[20];
|
|
|
|
u32 created_at;
|
|
|
|
gcry_mpi_t n;
|
|
|
|
gcry_mpi_t e;
|
|
|
|
};
|
|
|
|
|
2003-07-23 09:11:06 +02:00
|
|
|
|
|
|
|
/* Release the card info structure. */
|
|
|
|
void agent_release_card_info (struct agent_card_info_s *info);
|
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
/* Return card info. */
|
2015-04-03 10:39:59 +02:00
|
|
|
int agent_scd_learn (struct agent_card_info_s *info, int force);
|
2014-10-19 14:09:04 +02:00
|
|
|
|
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);
|
|
|
|
|
2003-09-30 19:34:38 +02:00
|
|
|
/* Update INFO with the attribute NAME. */
|
|
|
|
int agent_scd_getattr (const char *name, struct agent_card_info_s *info);
|
|
|
|
|
2013-02-06 06:01:23 +01:00
|
|
|
/* Send the KEYTOCARD command. */
|
|
|
|
int agent_keytocard (const char *hexgrip, int keyno, int force,
|
|
|
|
const char *serialno, const char *timestamp);
|
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
/* Send a SETATTR command to the SCdaemon. */
|
|
|
|
int agent_scd_setattr (const char *name,
|
2006-05-23 18:19:43 +02:00
|
|
|
const unsigned char *value, size_t valuelen,
|
|
|
|
const char *serialno);
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2008-09-23 11:57:45 +02:00
|
|
|
/* Send a WRITECERT command to the SCdaemon. */
|
|
|
|
int agent_scd_writecert (const char *certidstr,
|
|
|
|
const unsigned char *certdata, size_t certdatalen);
|
|
|
|
|
2006-08-16 12:47:53 +02:00
|
|
|
/* Send a WRITEKEY command to the SCdaemon. */
|
|
|
|
int agent_scd_writekey (int keyno, const char *serialno,
|
|
|
|
const unsigned char *keydata, size_t keydatalen);
|
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
/* Send a GENKEY command to the SCdaemon. */
|
2006-05-23 18:19:43 +02:00
|
|
|
int agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force,
|
2007-07-05 18:58:19 +02:00
|
|
|
const char *serialno, u32 createtime);
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2009-06-17 11:45:50 +02:00
|
|
|
/* Send a READKEY command to the SCdaemon. */
|
|
|
|
int agent_scd_readcert (const char *certidstr,
|
|
|
|
void **r_buf, size_t *r_buflen);
|
|
|
|
|
2003-07-23 09:11:06 +02:00
|
|
|
/* Change the PIN of an OpenPGP card or reset the retry counter. */
|
2006-05-23 18:19:43 +02:00
|
|
|
int agent_scd_change_pin (int chvno, const char *serialno);
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2003-10-21 19:12:21 +02:00
|
|
|
/* Send the CHECKPIN command to the SCdaemon. */
|
|
|
|
int agent_scd_checkpin (const char *serialno);
|
|
|
|
|
2006-05-23 18:19:43 +02:00
|
|
|
/* Dummy function, only implemented by gpg 1.4. */
|
|
|
|
void agent_clear_pin_cache (const char *sn);
|
2003-10-21 19:12:21 +02:00
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2006-10-04 18:45:04 +02: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,
|
2009-03-17 13:13:32 +01:00
|
|
|
int repeat,
|
2009-05-15 21:26:46 +02:00
|
|
|
int check,
|
2006-10-04 18:45:04 +02: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 12:56:44 +02:00
|
|
|
/* Present the prompt DESC and ask the user to confirm. */
|
|
|
|
gpg_error_t gpg_agent_get_confirmation (const char *desc);
|
|
|
|
|
2010-01-08 20:18:49 +01:00
|
|
|
/* Return the S2K iteration count as computed by gpg-agent. */
|
|
|
|
gpg_error_t agent_get_s2k_count (unsigned long *r_count);
|
|
|
|
|
2010-04-21 18:26:17 +02:00
|
|
|
/* Check whether a secret key for public key PK is available. Returns
|
|
|
|
0 if the secret key is available. */
|
|
|
|
gpg_error_t agent_probe_secret_key (ctrl_t ctrl, PKT_public_key *pk);
|
2010-04-20 19:57:50 +02:00
|
|
|
|
2010-10-01 22:33:53 +02:00
|
|
|
/* Ask the agent whether a secret key is availabale for any of the
|
|
|
|
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 19:57:50 +02:00
|
|
|
/* Return infos about the secret key with HEXKEYGRIP. */
|
|
|
|
gpg_error_t agent_get_keyinfo (ctrl_t ctrl, const char *hexkeygrip,
|
|
|
|
char **r_serialno);
|
|
|
|
|
|
|
|
/* Generate a new key. */
|
2010-09-01 11:48:35 +02:00
|
|
|
gpg_error_t agent_genkey (ctrl_t ctrl, char **cache_nonce_addr,
|
2010-10-14 18:34:31 +02:00
|
|
|
const char *keyparms, int no_protection,
|
2015-01-21 11:31:20 +01:00
|
|
|
const char *passphrase,
|
2010-04-20 19:57:50 +02:00
|
|
|
gcry_sexp_t *r_pubkey);
|
|
|
|
|
2011-11-06 17:01:31 +01:00
|
|
|
/* Read a public key. */
|
|
|
|
gpg_error_t agent_readkey (ctrl_t ctrl, int fromcard, const char *hexkeygrip,
|
|
|
|
unsigned char **r_pubkey);
|
|
|
|
|
2010-04-21 18:26:17 +02:00
|
|
|
/* Create a signature. */
|
2010-09-01 14:49:05 +02: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 19:57:50 +02:00
|
|
|
unsigned char *digest, size_t digestlen,
|
|
|
|
int digestalgo,
|
|
|
|
gcry_sexp_t *r_sigval);
|
|
|
|
|
2010-04-23 13:36:59 +02: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 13:36:59 +02: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 19:57:50 +02:00
|
|
|
|
2010-08-31 17:58:39 +02: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,
|
2010-09-01 11:48:35 +02:00
|
|
|
char **cache_nonce_addr,
|
2013-05-22 10:50:12 +02:00
|
|
|
const void *key, size_t keylen, int unattended);
|
2010-08-31 17:58:39 +02:00
|
|
|
|
2010-10-01 22:33:53 +02:00
|
|
|
/* Receive a key from the agent. */
|
|
|
|
gpg_error_t agent_export_key (ctrl_t ctrl, const char *keygrip,
|
|
|
|
const char *desc, char **cache_nonce_addr,
|
|
|
|
unsigned char **r_result, size_t *r_resultlen);
|
|
|
|
|
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,
|
|
|
|
const char *desc);
|
|
|
|
|
2010-10-26 11:10:29 +02:00
|
|
|
/* Change the passphrase of a key. */
|
|
|
|
gpg_error_t agent_passwd (ctrl_t ctrl, const char *hexkeygrip, const char *desc,
|
|
|
|
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 18:45:04 +02:00
|
|
|
|
2003-06-27 22:53:09 +02:00
|
|
|
|
2010-10-26 11:10:29 +02:00
|
|
|
#endif /*GNUPG_G10_CALL_AGENT_H*/
|