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,
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
36 struct app_local_s
; /* Defined by all app-*.c. */
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 */
44 int ref_count
; /* Number of connections currently using this
45 application context. fixme: We might want to
46 merg this witghn INITIALIZED above. */
48 int slot
; /* Used reader. */
50 /* If this is used by GnuPG 1.4 we need to know the assuan context
51 in case we need to divert the operation to an already running
52 agent. This if ASSUAN_CTX is not NULL we take this as indication
53 that all operations are diverted to gpg-agent. */
54 #if GNUPG_MAJOR_VERSION == 1
55 assuan_context_t assuan_ctx
;
56 #endif /*GNUPG_MAJOR_VERSION == 1*/
58 unsigned char *serialno
; /* Serialnumber in raw form, allocated. */
59 size_t serialnolen
; /* Length in octets of serialnumber. */
61 unsigned int card_version
;
63 int force_chv1
; /* True if the card does not cache CHV1. */
66 struct app_local_s
*app_local
; /* Local to the application. */
68 void (*deinit
) (app_t app
);
69 gpg_error_t (*learn_status
) (app_t app
, ctrl_t ctrl
);
70 gpg_error_t (*readcert
) (app_t app
, const char *certid
,
71 unsigned char **cert
, size_t *certlen
);
72 gpg_error_t (*readkey
) (app_t app
, const char *certid
,
73 unsigned char **pk
, size_t *pklen
);
74 gpg_error_t (*getattr
) (app_t app
, ctrl_t ctrl
, const char *name
);
75 gpg_error_t (*setattr
) (app_t app
, const char *name
,
76 gpg_error_t (*pincb
)(void*, const char *, char **),
78 const unsigned char *value
, size_t valuelen
);
79 gpg_error_t (*sign
) (app_t app
,
80 const char *keyidstr
, int hashalgo
,
81 gpg_error_t (*pincb
)(void*, const char *, char **),
83 const void *indata
, size_t indatalen
,
84 unsigned char **outdata
, size_t *outdatalen
);
85 gpg_error_t (*auth
) (app_t app
, const char *keyidstr
,
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 (*decipher
) (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 (*writekey
) (app_t app
, ctrl_t ctrl
,
96 const char *certid
, unsigned int flags
,
97 gpg_error_t (*pincb
)(void*,const char *,char **),
99 const unsigned char *pk
, size_t pklen
);
100 gpg_error_t (*genkey
) (app_t app
, ctrl_t ctrl
,
101 const char *keynostr
, unsigned int flags
,
102 gpg_error_t (*pincb
)(void*, const char *, char **),
104 gpg_error_t (*change_pin
) (app_t app
, ctrl_t ctrl
,
105 const char *chvnostr
, int reset_mode
,
106 gpg_error_t (*pincb
)(void*, const char *, char **),
108 gpg_error_t (*check_pin
) (app_t app
, const char *keyidstr
,
109 gpg_error_t (*pincb
)(void*, const char *, char **),
115 #if GNUPG_MAJOR_VERSION == 1
116 gpg_error_t
app_select_openpgp (app_t app
);
117 gpg_error_t
app_get_serial_and_stamp (app_t app
, char **serial
, time_t *stamp
);
118 gpg_error_t
app_openpgp_storekey (app_t app
, int keyno
,
119 unsigned char *template, size_t template_len
,
121 const unsigned char *m
, size_t mlen
,
122 const unsigned char *e
, size_t elen
,
123 gpg_error_t (*pincb
)(void*, const char *, char **),
127 gpg_error_t
app_help_get_keygrip_string (ksba_cert_t cert
, char *hexkeygrip
);
128 size_t app_help_read_length_of_cert (int slot
, int fid
, size_t *r_certoff
);
132 void app_dump_state (void);
133 void application_notify_card_removed (int slot
);
134 gpg_error_t
check_application_conflict (ctrl_t ctrl
, const char *name
);
135 gpg_error_t
select_application (ctrl_t ctrl
, int slot
, const char *name
,
137 void release_application (app_t app
);
138 gpg_error_t
app_munge_serialno (app_t app
);
139 gpg_error_t
app_get_serial_and_stamp (app_t app
, char **serial
, time_t *stamp
);
140 gpg_error_t
app_write_learn_status (app_t app
, ctrl_t ctrl
);
141 gpg_error_t
app_readcert (app_t app
, const char *certid
,
142 unsigned char **cert
, size_t *certlen
);
143 gpg_error_t
app_readkey (app_t app
, const char *keyid
,
144 unsigned char **pk
, size_t *pklen
);
145 gpg_error_t
app_getattr (app_t app
, ctrl_t ctrl
, const char *name
);
146 gpg_error_t
app_setattr (app_t app
, const char *name
,
147 gpg_error_t (*pincb
)(void*, const char *, char **),
149 const unsigned char *value
, size_t valuelen
);
150 gpg_error_t
app_sign (app_t app
, const char *keyidstr
, int hashalgo
,
151 gpg_error_t (*pincb
)(void*, const char *, char **),
153 const void *indata
, size_t indatalen
,
154 unsigned char **outdata
, size_t *outdatalen
);
155 gpg_error_t
app_auth (app_t app
, const char *keyidstr
,
156 gpg_error_t (*pincb
)(void*, const char *, char **),
158 const void *indata
, size_t indatalen
,
159 unsigned char **outdata
, size_t *outdatalen
);
160 gpg_error_t
app_decipher (app_t app
, const char *keyidstr
,
161 gpg_error_t (*pincb
)(void*, const char *, char **),
163 const void *indata
, size_t indatalen
,
164 unsigned char **outdata
, size_t *outdatalen
);
165 gpg_error_t
app_writekey (app_t app
, ctrl_t ctrl
,
166 const char *keyidstr
, unsigned int flags
,
167 gpg_error_t (*pincb
)(void*, const char *, char **),
169 const unsigned char *keydata
, size_t keydatalen
);
170 gpg_error_t
app_genkey (app_t app
, ctrl_t ctrl
,
171 const char *keynostr
, unsigned int flags
,
172 gpg_error_t (*pincb
)(void*, const char *, char **),
174 gpg_error_t
app_get_challenge (app_t app
, size_t nbytes
,
175 unsigned char *buffer
);
176 gpg_error_t
app_change_pin (app_t app
, ctrl_t ctrl
,
177 const char *chvnostr
, int reset_mode
,
178 gpg_error_t (*pincb
)(void*, const char *, char **),
180 gpg_error_t
app_check_pin (app_t app
, const char *keyidstr
,
181 gpg_error_t (*pincb
)(void*, const char *, char **),
185 /*-- app-openpgp.c --*/
186 gpg_error_t
app_select_openpgp (app_t app
);
189 gpg_error_t
app_select_nks (app_t app
);
191 /*-- app-dinsig.c --*/
192 gpg_error_t
app_select_dinsig (app_t app
);
195 gpg_error_t
app_select_p15 (app_t app
);
202 #endif /*GNUPG_SCD_APP_COMMON_H*/