1
/* scdaemon.h - Global definitions for the SCdaemon
2
* Copyright (C) 2001, 2002, 2003 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24
#ifdef GPG_ERR_SOURCE_DEFAULT
25
#error GPG_ERR_SOURCE_DEFAULT already defined
27
#define GPG_ERR_SOURCE_DEFAULT GPG_ERR_SOURCE_SCD
28
#include <gpg-error.h>
29
#define map_assuan_err(a) \
30
map_assuan_err_with_source (GPG_ERR_SOURCE_DEFAULT, (a))
36
#include "../common/util.h"
37
#include "../common/errors.h"
40
#define MAX_DIGEST_LEN 24
42
/* A large struct name "opt" to keep global flags */
44
unsigned int debug; /* debug flags (DBG_foo_VALUE) */
45
int debug_sc; /* OpenSC debug level */
46
int verbose; /* verbosity level */
47
int quiet; /* be as quiet as possible */
48
int dry_run; /* don't change any persistent data */
49
int batch; /* batch mode */
50
const char *homedir; /* configuration directory name */
51
const char *ctapi_driver; /* Library to access the ctAPI. */
52
const char *pcsc_driver; /* Library to access the PC/SC system. */
53
const char *reader_port; /* NULL or reder port to use. */
54
int disable_opensc; /* Disable the use of the OpenSC framework. */
55
int disable_ccid; /* Disable the use of the internal CCID driver. */
56
int allow_admin; /* Allow the use of admin commands for certain
58
strlist_t disabled_applications; /* card applications we do not
63
#define DBG_COMMAND_VALUE 1 /* debug commands i/o */
64
#define DBG_MPI_VALUE 2 /* debug mpi details */
65
#define DBG_CRYPTO_VALUE 4 /* debug low level crypto */
66
#define DBG_MEMORY_VALUE 32 /* debug memory allocation stuff */
67
#define DBG_CACHE_VALUE 64 /* debug the caching */
68
#define DBG_MEMSTAT_VALUE 128 /* show memory statistics */
69
#define DBG_HASHING_VALUE 512 /* debug hashing operations */
70
#define DBG_ASSUAN_VALUE 1024
71
#define DBG_CARD_IO_VALUE 2048
73
#define DBG_COMMAND (opt.debug & DBG_COMMAND_VALUE)
74
#define DBG_CRYPTO (opt.debug & DBG_CRYPTO_VALUE)
75
#define DBG_MEMORY (opt.debug & DBG_MEMORY_VALUE)
76
#define DBG_CACHE (opt.debug & DBG_CACHE_VALUE)
77
#define DBG_HASHING (opt.debug & DBG_HASHING_VALUE)
78
#define DBG_ASSUAN (opt.debug & DBG_ASSUAN_VALUE)
79
#define DBG_CARD_IO (opt.debug & DBG_CARD_IO_VALUE)
81
struct server_local_s;
85
struct server_control_s {
86
struct server_local_s *server_local;
87
int reader_slot; /* Slot of the open reader or -1 if not open. */
88
struct card_ctx_s *card_ctx;
89
struct app_ctx_s *app_ctx;
93
} in_data; /* helper to store the value we are going to sign */
97
typedef struct server_control_s *CTRL;
98
typedef struct server_control_s *ctrl_t;
99
typedef struct card_ctx_s *CARD;
100
typedef struct app_ctx_s *APP;
101
typedef struct app_ctx_s *app_t;
104
void scd_exit (int rc);
105
void scd_init_default_ctrl (CTRL ctrl);
108
void scd_command_handler (int);
109
void send_status_info (CTRL ctrl, const char *keyword, ...);
110
void scd_update_reader_status_file (void);
113
int card_open (CARD *rcard);
114
void card_close (CARD card);
115
int card_get_serial_and_stamp (CARD card, char **serial, time_t *stamp);
116
int card_enum_keypairs (CARD card, int idx,
117
unsigned char *keygrip,
119
int card_enum_certs (CARD card, int idx, char **certid, int *certtype);
120
int card_read_cert (CARD card, const char *certidstr,
121
unsigned char **cert, size_t *ncert);
122
int card_sign (CARD card,
123
const char *keyidstr, int hashalgo,
124
int (pincb)(void*, const char *, char **),
126
const void *indata, size_t indatalen,
127
unsigned char **outdata, size_t *outdatalen );
128
int card_decipher (CARD card, const char *keyidstr,
129
int (pincb)(void*, const char *, char **),
131
const void *indata, size_t indatalen,
132
unsigned char **outdata, size_t *outdatalen);
135
#endif /*SCDAEMON_H*/