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 unsigned int app_help_count_bits (const unsigned char *a
, size_t len
);
139 gpg_error_t
app_help_get_keygrip_string (ksba_cert_t cert
, char *hexkeygrip
);
140 size_t app_help_read_length_of_cert (int slot
, int fid
, size_t *r_certoff
);
144 void app_dump_state (void);
145 void application_notify_card_reset (int slot
);
146 gpg_error_t
check_application_conflict (ctrl_t ctrl
, const char *name
);
147 gpg_error_t
select_application (ctrl_t ctrl
, int slot
, const char *name
,
149 char *get_supported_applications (void);
150 void release_application (app_t app
);
151 gpg_error_t
app_munge_serialno (app_t app
);
152 gpg_error_t
app_get_serial_and_stamp (app_t app
, char **serial
, time_t *stamp
);
153 gpg_error_t
app_write_learn_status (app_t app
, ctrl_t ctrl
,
155 gpg_error_t
app_readcert (app_t app
, const char *certid
,
156 unsigned char **cert
, size_t *certlen
);
157 gpg_error_t
app_readkey (app_t app
, const char *keyid
,
158 unsigned char **pk
, size_t *pklen
);
159 gpg_error_t
app_getattr (app_t app
, ctrl_t ctrl
, const char *name
);
160 gpg_error_t
app_setattr (app_t app
, const char *name
,
161 gpg_error_t (*pincb
)(void*, const char *, char **),
163 const unsigned char *value
, size_t valuelen
);
164 gpg_error_t
app_sign (app_t app
, const char *keyidstr
, int hashalgo
,
165 gpg_error_t (*pincb
)(void*, const char *, char **),
167 const void *indata
, size_t indatalen
,
168 unsigned char **outdata
, size_t *outdatalen
);
169 gpg_error_t
app_auth (app_t app
, const char *keyidstr
,
170 gpg_error_t (*pincb
)(void*, const char *, char **),
172 const void *indata
, size_t indatalen
,
173 unsigned char **outdata
, size_t *outdatalen
);
174 gpg_error_t
app_decipher (app_t app
, const char *keyidstr
,
175 gpg_error_t (*pincb
)(void*, const char *, char **),
177 const void *indata
, size_t indatalen
,
178 unsigned char **outdata
, size_t *outdatalen
);
179 gpg_error_t
app_writecert (app_t app
, ctrl_t ctrl
,
180 const char *certidstr
,
181 gpg_error_t (*pincb
)(void*, const char *, char **),
183 const unsigned char *keydata
, size_t keydatalen
);
184 gpg_error_t
app_writekey (app_t app
, ctrl_t ctrl
,
185 const char *keyidstr
, unsigned int flags
,
186 gpg_error_t (*pincb
)(void*, const char *, char **),
188 const unsigned char *keydata
, size_t keydatalen
);
189 gpg_error_t
app_genkey (app_t app
, ctrl_t ctrl
,
190 const char *keynostr
, unsigned int flags
,
192 gpg_error_t (*pincb
)(void*, const char *, char **),
194 gpg_error_t
app_get_challenge (app_t app
, size_t nbytes
,
195 unsigned char *buffer
);
196 gpg_error_t
app_change_pin (app_t app
, ctrl_t ctrl
,
197 const char *chvnostr
, int reset_mode
,
198 gpg_error_t (*pincb
)(void*, const char *, char **),
200 gpg_error_t
app_check_pin (app_t app
, const char *keyidstr
,
201 gpg_error_t (*pincb
)(void*, const char *, char **),
205 /*-- app-openpgp.c --*/
206 gpg_error_t
app_select_openpgp (app_t app
);
209 gpg_error_t
app_select_nks (app_t app
);
211 /*-- app-dinsig.c --*/
212 gpg_error_t
app_select_dinsig (app_t app
);
215 gpg_error_t
app_select_p15 (app_t app
);
217 /*-- app-geldkarte.c --*/
218 gpg_error_t
app_select_geldkarte (app_t app
);
225 #endif /*GNUPG_SCD_APP_COMMON_H*/