2008-05-15 Marcus Brinkmann <marcus@g10code.de>
[gnupg.git] / g10 / call-agent.h
blobb3e8ae2b67d60dbda4417ff7ec4cee324e18f6c8
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 *serialno; /* malloced hex string. */
27 char *disp_name; /* malloced. */
28 char *disp_lang; /* malloced. */
29 int disp_sex; /* 0 = unspecified, 1 = male, 2 = female */
30 char *pubkey_url; /* malloced. */
31 char *login_data; /* malloced. */
32 char *private_do[4]; /* malloced. */
33 char cafpr1valid;
34 char cafpr2valid;
35 char cafpr3valid;
36 char cafpr1[20];
37 char cafpr2[20];
38 char cafpr3[20];
39 char fpr1valid;
40 char fpr2valid;
41 char fpr3valid;
42 char fpr1[20];
43 char fpr2[20];
44 char fpr3[20];
45 u32 fpr1time;
46 u32 fpr2time;
47 u32 fpr3time;
48 unsigned long sig_counter;
49 int chv1_cached; /* True if a PIN is not required for each
50 signing. Note that the gpg-agent might cache
51 it anyway. */
52 int chvmaxlen[3]; /* Maximum allowed length of a CHV. */
53 int chvretry[3]; /* Allowed retries for the CHV; 0 = blocked. */
56 struct agent_card_genkey_s {
57 char fprvalid;
58 char fpr[20];
59 u32 created_at;
60 gcry_mpi_t n;
61 gcry_mpi_t e;
65 /* Release the card info structure. */
66 void agent_release_card_info (struct agent_card_info_s *info);
68 /* Return card info. */
69 int agent_learn (struct agent_card_info_s *info);
71 /* Update INFO with the attribute NAME. */
72 int agent_scd_getattr (const char *name, struct agent_card_info_s *info);
74 /* Send a SETATTR command to the SCdaemon. */
75 int agent_scd_setattr (const char *name,
76 const unsigned char *value, size_t valuelen,
77 const char *serialno);
79 /* Send a WRITEKEY command to the SCdaemon. */
80 int agent_scd_writekey (int keyno, const char *serialno,
81 const unsigned char *keydata, size_t keydatalen);
83 /* Send a GENKEY command to the SCdaemon. */
84 int agent_scd_genkey (struct agent_card_genkey_s *info, int keyno, int force,
85 const char *serialno, u32 createtime);
87 /* Send a PKSIGN command to the SCdaemon. */
88 int agent_scd_pksign (const char *keyid, int hashalgo,
89 const unsigned char *indata, size_t indatalen,
90 unsigned char **r_buf, size_t *r_buflen);
92 /* Send a PKDECRYPT command to the SCdaemon. */
93 int agent_scd_pkdecrypt (const char *serialno,
94 const unsigned char *indata, size_t indatalen,
95 unsigned char **r_buf, size_t *r_buflen);
97 /* Change the PIN of an OpenPGP card or reset the retry counter. */
98 int agent_scd_change_pin (int chvno, const char *serialno);
100 /* Send the CHECKPIN command to the SCdaemon. */
101 int agent_scd_checkpin (const char *serialno);
103 /* Dummy function, only implemented by gpg 1.4. */
104 void agent_clear_pin_cache (const char *sn);
107 /* Send the GET_PASSPHRASE command to the agent. */
108 gpg_error_t agent_get_passphrase (const char *cache_id,
109 const char *err_msg,
110 const char *prompt,
111 const char *desc_msg,
112 char **r_passphrase);
114 /* Send the CLEAR_PASSPHRASE command to the agent. */
115 gpg_error_t agent_clear_passphrase (const char *cache_id);
118 #endif /*GNUPG_G10_CALL_AGENT_H*/