2003-10-02 12:20:12 +02:00
|
|
|
/* app-common.h - Common declarations for all card applications
|
2005-05-20 22:37:08 +02:00
|
|
|
* Copyright (C) 2003, 2005 Free Software Foundation, Inc.
|
2003-09-28 15:41:58 +02:00
|
|
|
*
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
*
|
|
|
|
* GnuPG is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-05-31 10:39:18 +02:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
|
|
|
|
* USA.
|
2004-10-20 11:39:56 +02:00
|
|
|
*
|
|
|
|
* $Id$
|
2003-09-28 15:41:58 +02:00
|
|
|
*/
|
|
|
|
|
2003-10-02 12:20:12 +02:00
|
|
|
#ifndef GNUPG_SCD_APP_COMMON_H
|
|
|
|
#define GNUPG_SCD_APP_COMMON_H
|
2003-09-28 15:41:58 +02:00
|
|
|
|
2005-05-20 22:37:08 +02:00
|
|
|
#if GNUPG_MAJOR_VERSION == 1
|
|
|
|
# ifdef ENABLE_AGENT_SUPPORT
|
|
|
|
# include "assuan.h"
|
|
|
|
# endif
|
|
|
|
#else
|
|
|
|
# include <ksba.h>
|
2004-04-27 10:23:45 +02:00
|
|
|
#endif
|
|
|
|
|
2005-05-20 22:37:08 +02:00
|
|
|
|
2004-04-27 10:23:45 +02:00
|
|
|
struct app_local_s; /* Defined by all app-*.c. */
|
|
|
|
|
2003-09-28 15:41:58 +02:00
|
|
|
struct app_ctx_s {
|
|
|
|
int initialized; /* The application has been initialied and the
|
|
|
|
function pointers may be used. Note that for
|
|
|
|
unsupported operations the particular
|
|
|
|
function pointer is set to NULL */
|
|
|
|
int slot; /* Used reader. */
|
2005-05-20 22:37:08 +02:00
|
|
|
|
|
|
|
/* If this is used by GnuPG 1.4 we need to know the assuan context
|
|
|
|
in case we need to divert the operation to an already running
|
|
|
|
agent. This if ASSUAN_CTX is not NULL we take this as indication
|
|
|
|
that all operations are diverted to gpg-agent. */
|
2005-05-31 12:11:01 +02:00
|
|
|
#if GNUPG_MAJOR_VERSION == 1
|
2005-05-20 22:37:08 +02:00
|
|
|
assuan_context_t assuan_ctx;
|
|
|
|
#endif /*GNUPG_MAJOR_VERSION == 1*/
|
|
|
|
|
2003-09-28 15:41:58 +02:00
|
|
|
unsigned char *serialno; /* Serialnumber in raw form, allocated. */
|
|
|
|
size_t serialnolen; /* Length in octets of serialnumber. */
|
2004-04-27 10:23:45 +02:00
|
|
|
const char *apptype;
|
2003-09-28 15:41:58 +02:00
|
|
|
unsigned int card_version;
|
|
|
|
int did_chv1;
|
2003-10-02 12:20:12 +02:00
|
|
|
int force_chv1; /* True if the card does not cache CHV1. */
|
2003-09-28 15:41:58 +02:00
|
|
|
int did_chv2;
|
|
|
|
int did_chv3;
|
2004-04-27 10:23:45 +02:00
|
|
|
struct app_local_s *app_local; /* Local to the application. */
|
2003-09-28 15:41:58 +02:00
|
|
|
struct {
|
2004-04-27 10:23:45 +02:00
|
|
|
void (*deinit) (app_t app);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*learn_status) (app_t app, ctrl_t ctrl);
|
|
|
|
gpg_error_t (*readcert) (app_t app, const char *certid,
|
2004-04-27 10:23:45 +02:00
|
|
|
unsigned char **cert, size_t *certlen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*readkey) (app_t app, const char *certid,
|
|
|
|
unsigned char **pk, size_t *pklen);
|
|
|
|
gpg_error_t (*getattr) (app_t app, ctrl_t ctrl, const char *name);
|
|
|
|
gpg_error_t (*setattr) (app_t app, const char *name,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *value, size_t valuelen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*sign) (app_t app,
|
2003-09-28 15:41:58 +02:00
|
|
|
const char *keyidstr, int hashalgo,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen );
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*auth) (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*decipher) (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
2005-05-21 16:04:32 +02:00
|
|
|
gpg_error_t (*writekey) (app_t app, ctrl_t ctrl,
|
|
|
|
const char *certid, unsigned int flags,
|
|
|
|
gpg_error_t (*pincb)(void*,const char *,char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *pk, size_t pklen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*genkey) (app_t app, ctrl_t ctrl,
|
2003-09-28 15:41:58 +02:00
|
|
|
const char *keynostr, unsigned int flags,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*change_pin) (app_t app, ctrl_t ctrl,
|
2003-09-28 15:41:58 +02:00
|
|
|
const char *chvnostr, int reset_mode,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-09-28 15:41:58 +02:00
|
|
|
void *pincb_arg);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*check_pin) (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-21 20:22:21 +02:00
|
|
|
void *pincb_arg);
|
2003-09-28 15:41:58 +02:00
|
|
|
} fnc;
|
|
|
|
|
2003-10-02 12:20:12 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#if GNUPG_MAJOR_VERSION == 1
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_select_openpgp (app_t app);
|
|
|
|
gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp);
|
|
|
|
gpg_error_t app_openpgp_storekey (app_t app, int keyno,
|
2004-10-21 18:56:22 +02:00
|
|
|
unsigned char *template, size_t template_len,
|
|
|
|
time_t created_at,
|
|
|
|
const unsigned char *m, size_t mlen,
|
|
|
|
const unsigned char *e, size_t elen,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2004-10-21 18:56:22 +02:00
|
|
|
void *pincb_arg);
|
2003-10-02 12:20:12 +02:00
|
|
|
#else
|
2004-04-27 10:23:45 +02:00
|
|
|
/*-- app-help.c --*/
|
|
|
|
gpg_error_t app_help_get_keygrip_string (ksba_cert_t cert, char *hexkeygrip);
|
|
|
|
size_t app_help_read_length_of_cert (int slot, int fid, size_t *r_certoff);
|
|
|
|
|
|
|
|
|
2003-10-02 12:20:12 +02:00
|
|
|
/*-- app.c --*/
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t select_application (ctrl_t ctrl, int slot, const char *name,
|
|
|
|
app_t *r_app);
|
2004-04-27 10:23:45 +02:00
|
|
|
void release_application (app_t app);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_munge_serialno (app_t app);
|
|
|
|
gpg_error_t app_get_serial_and_stamp (app_t app, char **serial, time_t *stamp);
|
|
|
|
gpg_error_t app_write_learn_status (app_t app, ctrl_t ctrl);
|
|
|
|
gpg_error_t app_readcert (app_t app, const char *certid,
|
2004-04-27 10:23:45 +02:00
|
|
|
unsigned char **cert, size_t *certlen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_readkey (app_t app, const char *keyid,
|
|
|
|
unsigned char **pk, size_t *pklen);
|
|
|
|
gpg_error_t app_getattr (app_t app, ctrl_t ctrl, const char *name);
|
|
|
|
gpg_error_t app_setattr (app_t app, const char *name,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *value, size_t valuelen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_sign (app_t app, const char *keyidstr, int hashalgo,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen );
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_auth (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_decipher (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg,
|
|
|
|
const void *indata, size_t indatalen,
|
|
|
|
unsigned char **outdata, size_t *outdatalen );
|
2005-05-21 16:04:32 +02:00
|
|
|
gpg_error_t app_writekey (app_t app, ctrl_t ctrl,
|
|
|
|
const char *keyidstr, unsigned int flags,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
|
|
|
void *pincb_arg,
|
|
|
|
const unsigned char *keydata, size_t keydatalen);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_genkey (app_t app, ctrl_t ctrl,
|
2004-04-27 10:23:45 +02:00
|
|
|
const char *keynostr, unsigned int flags,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_get_challenge (app_t app, size_t nbytes,
|
|
|
|
unsigned char *buffer);
|
|
|
|
gpg_error_t app_change_pin (app_t app, ctrl_t ctrl,
|
2004-04-27 10:23:45 +02:00
|
|
|
const char *chvnostr, int reset_mode,
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-02 12:20:12 +02:00
|
|
|
void *pincb_arg);
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_check_pin (app_t app, const char *keyidstr,
|
|
|
|
gpg_error_t (*pincb)(void*, const char *, char **),
|
2003-10-21 20:22:21 +02:00
|
|
|
void *pincb_arg);
|
2003-10-02 12:20:12 +02:00
|
|
|
|
|
|
|
|
|
|
|
/*-- app-openpgp.c --*/
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_select_openpgp (app_t app);
|
2003-10-02 12:20:12 +02:00
|
|
|
|
2004-04-27 10:23:45 +02:00
|
|
|
/*-- app-nks.c --*/
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_select_nks (app_t app);
|
2004-04-27 10:23:45 +02:00
|
|
|
|
|
|
|
/*-- app-dinsig.c --*/
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_select_dinsig (app_t app);
|
2004-04-27 10:23:45 +02:00
|
|
|
|
2004-10-20 11:39:56 +02:00
|
|
|
/*-- app-p15.c --*/
|
2005-05-20 22:37:08 +02:00
|
|
|
gpg_error_t app_select_p15 (app_t app);
|
2004-10-20 11:39:56 +02:00
|
|
|
|
|
|
|
|
|
|
|
#endif
|
2004-04-27 10:23:45 +02:00
|
|
|
|
2003-10-02 12:20:12 +02:00
|
|
|
|
2003-09-28 15:41:58 +02:00
|
|
|
|
2003-10-02 12:20:12 +02:00
|
|
|
#endif /*GNUPG_SCD_APP_COMMON_H*/
|
2003-09-28 15:41:58 +02:00
|
|
|
|
|
|
|
|
|
|
|
|