1 /* app-common.h - Common declarations for all card applications
2 * Copyright (C) 2003, 2005, 2008 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/>.
22 #ifndef GNUPG_SCD_APP_COMMON_H
23 #define GNUPG_SCD_APP_COMMON_H
25 #if GNUPG_MAJOR_VERSION == 1
26 # ifdef ENABLE_AGENT_SUPPORT
34 #define APP_CHANGE_FLAG_RESET 1
35 #define APP_CHANGE_FLAG_NULLPIN 2
38 struct app_local_s
; /* Defined by all app-*.c. */
41 /* Number of connections currently using this application context.
42 If this is not 0 the application has been initialized and the
43 function pointers may be used. Note that for unsupported
44 operations the particular function pointer is set to NULL */
45 unsigned int ref_count
;
47 /* Flag indicating that a reset has been done for that application
48 and that this context is merely lingering and just should not be
52 /* Used reader slot. */
55 /* If this is used by GnuPG 1.4 we need to know the assuan context
56 in case we need to divert the operation to an already running
57 agent. This if ASSUAN_CTX is not NULL we take this as indication
58 that all operations are diverted to gpg-agent. */
59 #if GNUPG_MAJOR_VERSION == 1
60 assuan_context_t assuan_ctx
;
61 #endif /*GNUPG_MAJOR_VERSION == 1*/
63 unsigned char *serialno
; /* Serialnumber in raw form, allocated. */
64 size_t serialnolen
; /* Length in octets of serialnumber. */
66 unsigned int card_version
;
68 int force_chv1
; /* True if the card does not cache CHV1. */
71 struct app_local_s
*app_local
; /* Local to the application. */
73 void (*deinit
) (app_t app
);
74 gpg_error_t (*learn_status
) (app_t app
, ctrl_t ctrl
, unsigned int flags
);
75 gpg_error_t (*readcert
) (app_t app
, const char *certid
,
76 unsigned char **cert
, size_t *certlen
);
77 gpg_error_t (*readkey
) (app_t app
, const char *certid
,
78 unsigned char **pk
, size_t *pklen
);
79 gpg_error_t (*getattr
) (app_t app
, ctrl_t ctrl
, const char *name
);
80 gpg_error_t (*setattr
) (app_t app
, const char *name
,
81 gpg_error_t (*pincb
)(void*, const char *, char **),
83 const unsigned char *value
, size_t valuelen
);
84 gpg_error_t (*sign
) (app_t app
,
85 const char *keyidstr
, int hashalgo
,
86 gpg_error_t (*pincb
)(void*, const char *, char **),
88 const void *indata
, size_t indatalen
,
89 unsigned char **outdata
, size_t *outdatalen
);
90 gpg_error_t (*auth
) (app_t app
, const char *keyidstr
,
91 gpg_error_t (*pincb
)(void*, const char *, char **),
93 const void *indata
, size_t indatalen
,
94 unsigned char **outdata
, size_t *outdatalen
);
95 gpg_error_t (*decipher
) (app_t app
, const char *keyidstr
,
96 gpg_error_t (*pincb
)(void*, const char *, char **),
98 const void *indata
, size_t indatalen
,
99 unsigned char **outdata
, size_t *outdatalen
);
100 gpg_error_t (*writecert
) (app_t app
, ctrl_t ctrl
,
102 gpg_error_t (*pincb
)(void*,const char *,char **),
104 const unsigned char *data
, size_t datalen
);
105 gpg_error_t (*writekey
) (app_t app
, ctrl_t ctrl
,
106 const char *keyid
, unsigned int flags
,
107 gpg_error_t (*pincb
)(void*,const char *,char **),
109 const unsigned char *pk
, size_t pklen
);
110 gpg_error_t (*genkey
) (app_t app
, ctrl_t ctrl
,
111 const char *keynostr
, unsigned int flags
,
113 gpg_error_t (*pincb
)(void*, const char *, char **),
115 gpg_error_t (*change_pin
) (app_t app
, ctrl_t ctrl
,
116 const char *chvnostr
, unsigned int flags
,
117 gpg_error_t (*pincb
)(void*, const char *, char **),
119 gpg_error_t (*check_pin
) (app_t app
, const char *keyidstr
,
120 gpg_error_t (*pincb
)(void*, const char *, char **),
126 #if GNUPG_MAJOR_VERSION == 1
127 gpg_error_t
app_select_openpgp (app_t app
);
128 gpg_error_t
app_get_serial_and_stamp (app_t app
, char **serial
, time_t *stamp
);
129 gpg_error_t
app_openpgp_storekey (app_t app
, int keyno
,
130 unsigned char *template, size_t template_len
,
132 const unsigned char *m
, size_t mlen
,
133 const unsigned char *e
, size_t elen
,
134 gpg_error_t (*pincb
)(void*, const char *, char **),
138 gpg_error_t
app_help_get_keygrip_string (ksba_cert_t cert
, char *hexkeygrip
);
139 size_t app_help_read_length_of_cert (int slot
, int fid
, size_t *r_certoff
);
143 void app_dump_state (void);
144 void application_notify_card_reset (int slot
);
145 gpg_error_t
check_application_conflict (ctrl_t ctrl
, const char *name
);
146 gpg_error_t
select_application (ctrl_t ctrl
, int slot
, const char *name
,
148 char *get_supported_applications (void);
149 void release_application (app_t app
);
150 gpg_error_t
app_munge_serialno (app_t app
);
151 gpg_error_t
app_get_serial_and_stamp (app_t app
, char **serial
, time_t *stamp
);
152 gpg_error_t
app_write_learn_status (app_t app
, ctrl_t ctrl
,
154 gpg_error_t
app_readcert (app_t app
, const char *certid
,
155 unsigned char **cert
, size_t *certlen
);
156 gpg_error_t
app_readkey (app_t app
, const char *keyid
,
157 unsigned char **pk
, size_t *pklen
);
158 gpg_error_t
app_getattr (app_t app
, ctrl_t ctrl
, const char *name
);
159 gpg_error_t
app_setattr (app_t app
, const char *name
,
160 gpg_error_t (*pincb
)(void*, const char *, char **),
162 const unsigned char *value
, size_t valuelen
);
163 gpg_error_t
app_sign (app_t app
, const char *keyidstr
, int hashalgo
,
164 gpg_error_t (*pincb
)(void*, const char *, char **),
166 const void *indata
, size_t indatalen
,
167 unsigned char **outdata
, size_t *outdatalen
);
168 gpg_error_t
app_auth (app_t app
, const char *keyidstr
,
169 gpg_error_t (*pincb
)(void*, const char *, char **),
171 const void *indata
, size_t indatalen
,
172 unsigned char **outdata
, size_t *outdatalen
);
173 gpg_error_t
app_decipher (app_t app
, const char *keyidstr
,
174 gpg_error_t (*pincb
)(void*, const char *, char **),
176 const void *indata
, size_t indatalen
,
177 unsigned char **outdata
, size_t *outdatalen
);
178 gpg_error_t
app_writecert (app_t app
, ctrl_t ctrl
,
179 const char *certidstr
,
180 gpg_error_t (*pincb
)(void*, const char *, char **),
182 const unsigned char *keydata
, size_t keydatalen
);
183 gpg_error_t
app_writekey (app_t app
, ctrl_t ctrl
,
184 const char *keyidstr
, unsigned int flags
,
185 gpg_error_t (*pincb
)(void*, const char *, char **),
187 const unsigned char *keydata
, size_t keydatalen
);
188 gpg_error_t
app_genkey (app_t app
, ctrl_t ctrl
,
189 const char *keynostr
, unsigned int flags
,
191 gpg_error_t (*pincb
)(void*, const char *, char **),
193 gpg_error_t
app_get_challenge (app_t app
, size_t nbytes
,
194 unsigned char *buffer
);
195 gpg_error_t
app_change_pin (app_t app
, ctrl_t ctrl
,
196 const char *chvnostr
, int reset_mode
,
197 gpg_error_t (*pincb
)(void*, const char *, char **),
199 gpg_error_t
app_check_pin (app_t app
, const char *keyidstr
,
200 gpg_error_t (*pincb
)(void*, const char *, char **),
204 /*-- app-openpgp.c --*/
205 gpg_error_t
app_select_openpgp (app_t app
);
208 gpg_error_t
app_select_nks (app_t app
);
210 /*-- app-dinsig.c --*/
211 gpg_error_t
app_select_dinsig (app_t app
);
214 gpg_error_t
app_select_p15 (app_t app
);
216 /*-- app-geldkarte.c --*/
217 gpg_error_t
app_select_geldkarte (app_t app
);
224 #endif /*GNUPG_SCD_APP_COMMON_H*/