Fix bug#1011.
[gnupg.git] / g10 / call-agent.h
bloba89f483deeda84cfb83fafbea592faa4ebc69838
1 /* call-agent.h - Divert operations to the agent
2 * Copyright (C) 2003 Free Software Foundation, Inc.
4 * This file is part of GnuPG.
6 * GnuPG is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
11 * GnuPG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef GNUPG_G10_CALL_AGENT_H
20 #define GNUPG_G10_CALL_AGENT_H
23 struct agent_card_info_s
25 int error; /* private. */
26 char *apptype; /* Malloced application type string. */
27 char *serialno; /* malloced hex string. */
28 char *disp_name; /* malloced. */
29 char *disp_lang; /* malloced. */
30 int disp_sex; /* 0 = unspecified, 1 = male, 2 = female */
31 char *pubkey_url; /* malloced. */
32 char *login_data; /* malloced. */
33 char *private_do[4]; /* malloced. */
34 char cafpr1valid;
35 char cafpr2valid;
36 char cafpr3valid;
37 char cafpr1[20];
38 char cafpr2[20];
39 char cafpr3[20];
40 char fpr1valid;
41 char fpr2valid;
42 char fpr3valid;
43 char fpr1[20];
44 char fpr2[20];
45 char fpr3[20];
46 u32 fpr1time;
47 u32 fpr2time;
48 u32 fpr3time;
49 unsigned long sig_counter;
50 int chv1_cached; /* True if a PIN is not required for each
51 signing. Note that the gpg-agent might cache
52 it anyway. */
53 int is_v2; /* True if this is a v2 card. */
54 int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
55 int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
56 struct { /* Array with key attributes. */
57 int algo; /* Algorithm identifier. */
58 unsigned int nbits; /* Supported keysize. */
59 } key_attr[3];
60 struct {
61 unsigned int ki:1; /* Key import available. */
62 unsigned int aac:1; /* Algorithm attributes are changeable. */
63 } extcap;
66 struct agent_card_genkey_s {
67 char fprvalid;
68 char fpr[20];
69 u32 created_at;
70 gcry_mpi_t n;
71 gcry_mpi_t e;
75 /* Release the card info structure. */
76 void agent_release_card_info (struct agent_card_info_s *info);
78 /* Return card info. */
79 int agent_learn (struct agent_card_info_s *info);
81 /* Update INFO with the attribute NAME. */
82 int agent_scd_getattr (const char *name, struct agent_card_info_s *info);
84 /* Send a SETATTR command to the SCdaemon. */
85 int agent_scd_setattr (const char *name,
86 const unsigned char *value, size_t valuelen,
87 const char *serialno);
89 /* Send a WRITECERT command to the SCdaemon. */
90 int agent_scd_writecert (const char *certidstr,
91 const unsigned char *certdata, size_t certdatalen);
93 /* Send a WRITEKEY command to the SCdaemon. */
94 int agent_scd_writekey (int keyno, const char *serialno,
95 const unsigned char *keydata, size_t keydatalen);
97 /* Send a GENKEY command to the SCdaemon. */
98 int agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force,
99 const char *serialno, u32 createtime);
101 /* Send a PKSIGN command to the SCdaemon. */
102 int agent_scd_pksign (const char *keyid, int hashalgo,
103 const unsigned char *indata, size_t indatalen,
104 unsigned char **r_buf, size_t *r_buflen);
106 /* Send a PKDECRYPT command to the SCdaemon. */
107 int agent_scd_pkdecrypt (const char *serialno,
108 const unsigned char *indata, size_t indatalen,
109 unsigned char **r_buf, size_t *r_buflen);
111 /* Send a READKEY command to the SCdaemon. */
112 int agent_scd_readcert (const char *certidstr,
113 void **r_buf, size_t *r_buflen);
115 /* Change the PIN of an OpenPGP card or reset the retry counter. */
116 int agent_scd_change_pin (int chvno, const char *serialno);
118 /* Send the CHECKPIN command to the SCdaemon. */
119 int agent_scd_checkpin (const char *serialno);
121 /* Dummy function, only implemented by gpg 1.4. */
122 void agent_clear_pin_cache (const char *sn);
125 /* Send the GET_PASSPHRASE command to the agent. */
126 gpg_error_t agent_get_passphrase (const char *cache_id,
127 const char *err_msg,
128 const char *prompt,
129 const char *desc_msg,
130 int repeat,
131 int check,
132 char **r_passphrase);
134 /* Send the CLEAR_PASSPHRASE command to the agent. */
135 gpg_error_t agent_clear_passphrase (const char *cache_id);
137 /* Present the prompt DESC and ask the user to confirm. */
138 gpg_error_t gpg_agent_get_confirmation (const char *desc);
141 #endif /*GNUPG_G10_CALL_AGENT_H*/