~ubuntu-branches/ubuntu/precise/gnupg2/precise-proposed

« back to all changes in this revision

Viewing changes to scd/scdaemon.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Mueller
  • Date: 2005-03-29 10:30:32 UTC
  • Revision ID: james.westby@ubuntu.com-20050329103032-sj42n2ain3ipx310
Tags: upstream-1.9.15
ImportĀ upstreamĀ versionĀ 1.9.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* scdaemon.h - Global definitions for the SCdaemon
 
2
 *      Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
 
3
 *
 
4
 * This file is part of GnuPG.
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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
 
19
 */
 
20
 
 
21
#ifndef SCDAEMON_H
 
22
#define SCDAEMON_H
 
23
 
 
24
#ifdef GPG_ERR_SOURCE_DEFAULT
 
25
#error GPG_ERR_SOURCE_DEFAULT already defined
 
26
#endif
 
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))
 
31
 
 
32
#include <errno.h>
 
33
 
 
34
#include <time.h>
 
35
#include <gcrypt.h>
 
36
#include "../common/util.h"
 
37
#include "../common/errors.h"
 
38
 
 
39
 
 
40
#define MAX_DIGEST_LEN 24 
 
41
 
 
42
/* A large struct name "opt" to keep global flags */
 
43
struct {
 
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
 
57
                          cards. */
 
58
  strlist_t disabled_applications;  /* card applications we do not
 
59
                                       want to use. */
 
60
} opt;
 
61
 
 
62
 
 
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
 
72
 
 
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)
 
80
 
 
81
struct server_local_s;
 
82
struct card_ctx_s;
 
83
struct app_ctx_s;
 
84
 
 
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;
 
90
  struct {
 
91
    unsigned char *value;  
 
92
    int valuelen;
 
93
  } in_data;  /* helper to store the value we are going to sign */
 
94
 
 
95
};
 
96
 
 
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;
 
102
 
 
103
/*-- scdaemon.c --*/
 
104
void scd_exit (int rc);
 
105
void scd_init_default_ctrl (CTRL ctrl);
 
106
 
 
107
/*-- command.c --*/
 
108
void scd_command_handler (int);
 
109
void send_status_info (CTRL ctrl, const char *keyword, ...);
 
110
void scd_update_reader_status_file (void);
 
111
 
 
112
/*-- card.c --*/
 
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,
 
118
                        char **keyid);
 
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 **),
 
125
               void *pincb_arg,
 
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 **),
 
130
                   void *pincb_arg,
 
131
                   const void *indata, size_t indatalen,
 
132
                   unsigned char **outdata, size_t *outdatalen);
 
133
 
 
134
 
 
135
#endif /*SCDAEMON_H*/