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 */
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. */
56 unsigned int card_version
;
58 int force_chv1
; /* True if the card does not cache CHV1. */
61 struct app_local_s
*app_local
; /* Local to the application. */
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 **),
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 **),
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 **),
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 **),
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 **),
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 **),
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 **),
103 gpg_error_t (*check_pin
) (app_t app
, const char *keyidstr
,
104 gpg_error_t (*pincb
)(void*, const char *, char **),
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
,
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 **),
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
);
127 gpg_error_t
select_application (ctrl_t ctrl
, int slot
, const char *name
,
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 **),
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 **),
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 **),
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 **),
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 **),
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 **),
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 **),
172 gpg_error_t
app_check_pin (app_t app
, const char *keyidstr
,
173 gpg_error_t (*pincb
)(void*, const char *, char **),
177 /*-- app-openpgp.c --*/
178 gpg_error_t
app_select_openpgp (app_t app
);
181 gpg_error_t
app_select_nks (app_t app
);
183 /*-- app-dinsig.c --*/
184 gpg_error_t
app_select_dinsig (app_t app
);
187 gpg_error_t
app_select_p15 (app_t app
);
194 #endif /*GNUPG_SCD_APP_COMMON_H*/