* exec.c (make_tempdir) [_WIN32]: Modified to properly handle
[gnupg.git] / g10 / app-common.h
blobc80bfb527237067a540b70016bc1a0d4306b3d08
1 /* app-common.h - Common declarations for all card applications
2 * Copyright (C) 2003, 2005 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 2 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, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19 * USA.
21 * $Id$
24 #ifndef GNUPG_SCD_APP_COMMON_H
25 #define GNUPG_SCD_APP_COMMON_H
27 #if GNUPG_MAJOR_VERSION == 1
28 # ifdef ENABLE_AGENT_SUPPORT
29 # include "assuan.h"
30 # endif
31 #else
32 # include <ksba.h>
33 #endif
36 struct app_local_s; /* Defined by all app-*.c. */
38 struct app_ctx_s {
39 int initialized; /* The application has been initialied and the
40 function pointers may be used. Note that for
41 unsupported operations the particular
42 function pointer is set to NULL */
43 int slot; /* Used reader. */
45 /* If this is used by GnuPG 1.4 we need to know the assuan context
46 in case we need to divert the operation to an already running
47 agent. This if ASSUAN_CTX is not NULL we take this as indication
48 that all operations are diverted to gpg-agent. */
49 #if GNUPG_MAJOR_VERSION == 1
50 assuan_context_t assuan_ctx;
51 #endif /*GNUPG_MAJOR_VERSION == 1*/
53 unsigned char *serialno; /* Serialnumber in raw form, allocated. */
54 size_t serialnolen; /* Length in octets of serialnumber. */
55 const char *apptype;
56 unsigned int card_version;
57 int did_chv1;
58 int force_chv1; /* True if the card does not cache CHV1. */
59 int did_chv2;
60 int did_chv3;
61 struct app_local_s *app_local; /* Local to the application. */
62 struct {
63 void (*deinit) (app_t app);
64 gpg_error_t (*learn_status) (app_t app, ctrl_t ctrl);
65 gpg_error_t (*readcert) (app_t app, const char *certid,
66 unsigned char **cert, size_t *certlen);
67 gpg_error_t (*readkey) (app_t app, const char *certid,
68 unsigned char **pk, size_t *pklen);
69 gpg_error_t (*getattr) (app_t app, ctrl_t ctrl, const char *name);
70 gpg_error_t (*setattr) (app_t app, const char *name,
71 gpg_error_t (*pincb)(void*, const char *, char **),
72 void *pincb_arg,
73 const unsigned char *value, size_t valuelen);
74 gpg_error_t (*sign) (app_t app,
75 const char *keyidstr, int hashalgo,
76 gpg_error_t (*pincb)(void*, const char *, char **),
77 void *pincb_arg,
78 const void *indata, size_t indatalen,
79 unsigned char **outdata, size_t *outdatalen );
80 gpg_error_t (*auth) (app_t app, const char *keyidstr,
81 gpg_error_t (*pincb)(void*, const char *, char **),
82 void *pincb_arg,
83 const void *indata, size_t indatalen,
84 unsigned char **outdata, size_t *outdatalen);
85 gpg_error_t (*decipher) (app_t app, const char *keyidstr,
86 gpg_error_t (*pincb)(void*, const char *, char **),
87 void *pincb_arg,
88 const void *indata, size_t indatalen,
89 unsigned char **outdata, size_t *outdatalen);
90 gpg_error_t (*writekey) (app_t app, ctrl_t ctrl,
91 const char *certid, unsigned int flags,
92 gpg_error_t (*pincb)(void*,const char *,char **),
93 void *pincb_arg,
94 const unsigned char *pk, size_t pklen);
95 gpg_error_t (*genkey) (app_t app, ctrl_t ctrl,
96 const char *keynostr, unsigned int flags,
97 gpg_error_t (*pincb)(void*, const char *, char **),
98 void *pincb_arg);
99 gpg_error_t (*change_pin) (app_t app, ctrl_t ctrl,
100 const char *chvnostr, int reset_mode,
101 gpg_error_t (*pincb)(void*, const char *, char **),
102 void *pincb_arg);
103 gpg_error_t (*check_pin) (app_t app, const char *keyidstr,
104 gpg_error_t (*pincb)(void*, const char *, char **),
105 void *pincb_arg);
106 } fnc;
110 #if GNUPG_MAJOR_VERSION == 1
111 gpg_error_t app_select_openpgp (app_t app);
112 gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp);
113 gpg_error_t app_openpgp_storekey (app_t app, int keyno,
114 unsigned char *template, size_t template_len,
115 time_t created_at,
116 const unsigned char *m, size_t mlen,
117 const unsigned char *e, size_t elen,
118 gpg_error_t (*pincb)(void*, const char *, char **),
119 void *pincb_arg);
120 #else
121 /*-- app-help.c --*/
122 gpg_error_t app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip);
123 size_t app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff);
126 /*-- app.c --*/
127 gpg_error_t select_application (ctrl_t ctrl, int slot, const char *name,
128 app_t *r_app);
129 void release_application (app_t app);
130 gpg_error_t app_munge_serialno (app_t app);
131 gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp);
132 gpg_error_t app_write_learn_status (app_t app, ctrl_t ctrl);
133 gpg_error_t app_readcert (app_t app, const char *certid,
134 unsigned char **cert, size_t *certlen);
135 gpg_error_t app_readkey (app_t app, const char *keyid,
136 unsigned char **pk, size_t *pklen);
137 gpg_error_t app_getattr (app_t app, ctrl_t ctrl, const char *name);
138 gpg_error_t app_setattr (app_t app, const char *name,
139 gpg_error_t (*pincb)(void*, const char *, char **),
140 void *pincb_arg,
141 const unsigned char *value, size_t valuelen);
142 gpg_error_t app_sign (app_t app, const char *keyidstr, int hashalgo,
143 gpg_error_t (*pincb)(void*, const char *, char **),
144 void *pincb_arg,
145 const void *indata, size_t indatalen,
146 unsigned char **outdata, size_t *outdatalen );
147 gpg_error_t app_auth (app_t app, const char *keyidstr,
148 gpg_error_t (*pincb)(void*, const char *, char **),
149 void *pincb_arg,
150 const void *indata, size_t indatalen,
151 unsigned char **outdata, size_t *outdatalen);
152 gpg_error_t app_decipher (app_t app, const char *keyidstr,
153 gpg_error_t (*pincb)(void*, const char *, char **),
154 void *pincb_arg,
155 const void *indata, size_t indatalen,
156 unsigned char **outdata, size_t *outdatalen );
157 gpg_error_t app_writekey (app_t app, ctrl_t ctrl,
158 const char *keyidstr, unsigned int flags,
159 gpg_error_t (*pincb)(void*, const char *, char **),
160 void *pincb_arg,
161 const unsigned char *keydata, size_t keydatalen);
162 gpg_error_t app_genkey (app_t app, ctrl_t ctrl,
163 const char *keynostr, unsigned int flags,
164 gpg_error_t (*pincb)(void*, const char *, char **),
165 void *pincb_arg);
166 gpg_error_t app_get_challenge (app_t app, size_t nbytes,
167 unsigned char *buffer);
168 gpg_error_t app_change_pin (app_t app, ctrl_t ctrl,
169 const char *chvnostr, int reset_mode,
170 gpg_error_t (*pincb)(void*, const char *, char **),
171 void *pincb_arg);
172 gpg_error_t app_check_pin (app_t app, const char *keyidstr,
173 gpg_error_t (*pincb)(void*, const char *, char **),
174 void *pincb_arg);
177 /*-- app-openpgp.c --*/
178 gpg_error_t app_select_openpgp (app_t app);
180 /*-- app-nks.c --*/
181 gpg_error_t app_select_nks (app_t app);
183 /*-- app-dinsig.c --*/
184 gpg_error_t app_select_dinsig (app_t app);
186 /*-- app-p15.c --*/
187 gpg_error_t app_select_p15 (app_t app);
190 #endif
194 #endif /*GNUPG_SCD_APP_COMMON_H*/