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

« back to all changes in this revision

Viewing changes to scd/apdu.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
/* apdu.h - ISO 7816 APDU functions and low level I/O
 
2
 *      Copyright (C) 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
 * $Id$
 
21
 */
 
22
 
 
23
#ifndef APDU_H
 
24
#define APDU_H
 
25
 
 
26
/* ISO 7816 values for the statusword are defined here because they
 
27
   should not be visible to the users of the actual ISO command
 
28
   API. */
 
29
enum {
 
30
  SW_MORE_DATA      = 0x6100, /* Note: that the low byte must be
 
31
                                 masked of.*/
 
32
  SW_EOF_REACHED    = 0x6282,
 
33
  SW_EEPROM_FAILURE = 0x6581,
 
34
  SW_WRONG_LENGTH   = 0x6700,
 
35
  SW_CHV_WRONG      = 0x6982,
 
36
  SW_CHV_BLOCKED    = 0x6983,
 
37
  SW_USE_CONDITIONS = 0x6985,
 
38
  SW_BAD_PARAMETER  = 0x6a80, /* (in the data field) */
 
39
  SW_NOT_SUPPORTED  = 0x6a81,
 
40
  SW_FILE_NOT_FOUND = 0x6a82,
 
41
  SW_RECORD_NOT_FOUND = 0x6a83,
 
42
  SW_REF_NOT_FOUND  = 0x6a88,
 
43
  SW_BAD_P0_P1      = 0x6b00,
 
44
  SW_INS_NOT_SUP    = 0x6d00,
 
45
  SW_CLA_NOT_SUP    = 0x6e00,
 
46
  SW_SUCCESS        = 0x9000,
 
47
 
 
48
  /* The follwoing statuswords are no real ones but used to map host
 
49
     OS errors into status words.  A status word is 16 bit so that
 
50
     those values can't be issued by a card. */
 
51
  SW_HOST_OUT_OF_CORE = 0x10001,  /* No way yet to differentiate
 
52
                                     between errnos on a failed malloc. */
 
53
  SW_HOST_INV_VALUE     = 0x10002,
 
54
  SW_HOST_INCOMPLETE_CARD_RESPONSE = 0x10003,
 
55
  SW_HOST_NO_DRIVER     = 0x10004,
 
56
  SW_HOST_NOT_SUPPORTED = 0x10005,
 
57
  SW_HOST_LOCKING_FAILED= 0x10006,
 
58
  SW_HOST_BUSY          = 0x10007,
 
59
  SW_HOST_NO_CARD       = 0x10008,
 
60
  SW_HOST_CARD_INACTIVE = 0x10009,
 
61
  SW_HOST_CARD_IO_ERROR = 0x1000a,
 
62
  SW_HOST_GENERAL_ERROR = 0x1000b,
 
63
  SW_HOST_NO_READER     = 0x1000c,
 
64
  SW_HOST_ABORTED       = 0x1000d
 
65
};
 
66
 
 
67
 
 
68
 
 
69
/* Note , that apdu_open_reader returns no status word but -1 on error. */
 
70
int apdu_open_reader (const char *portstr);
 
71
int apdu_open_remote_reader (const char *portstr,
 
72
                             const unsigned char *cookie, size_t length,
 
73
                             int (*readfnc) (void *opaque,
 
74
                                             void *buffer, size_t size),
 
75
                             void *readfnc_value,
 
76
                             int (*writefnc) (void *opaque,
 
77
                                              const void *buffer, size_t size),
 
78
                             void *writefnc_value,
 
79
                             void (*closefnc) (void *opaque),
 
80
                             void *closefnc_value);
 
81
int apdu_shutdown_reader (int slot);
 
82
int apdu_close_reader (int slot);
 
83
int apdu_enum_reader (int slot, int *used);
 
84
unsigned char *apdu_get_atr (int slot, size_t *atrlen);
 
85
 
 
86
const char *apdu_strerror (int rc);
 
87
 
 
88
 
 
89
/* These apdu functions do return status words. */
 
90
 
 
91
int apdu_activate (int slot);
 
92
int apdu_reset (int slot);
 
93
int apdu_get_status (int slot, int hang,
 
94
                     unsigned int *status, unsigned int *changed);
 
95
int apdu_send_simple (int slot, int class, int ins, int p0, int p1,
 
96
                      int lc, const char *data);
 
97
int apdu_send (int slot, int class, int ins, int p0, int p1,
 
98
               int lc, const char *data,
 
99
               unsigned char **retbuf, size_t *retbuflen);
 
100
int apdu_send_le (int slot, int class, int ins, int p0, int p1,
 
101
                  int lc, const char *data, int le,
 
102
                  unsigned char **retbuf, size_t *retbuflen);
 
103
int apdu_send_direct (int slot,
 
104
                      const unsigned char *apdudata, size_t apdudatalen,
 
105
                      int handle_more,
 
106
                      unsigned char **retbuf, size_t *retbuflen);
 
107
 
 
108
 
 
109
#endif /*APDU_H*/
 
110
 
 
111
 
 
112