chiark / gitweb /
Import gnupg2_2.1.17.orig.tar.bz2
[gnupg2.git] / scd / iso7816.h
1 /* iso7816.h - ISO 7816 commands
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 3 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, see <https://www.gnu.org/licenses/>.
18  */
19
20 #ifndef ISO7816_H
21 #define ISO7816_H
22
23 #if GNUPG_MAJOR_VERSION == 1
24 #include "cardglue.h"
25 #endif
26
27 /* Command codes used by iso7816_check_pinpad. */
28 #define ISO7816_VERIFY                0x20
29 #define ISO7816_CHANGE_REFERENCE_DATA 0x24
30 #define ISO7816_RESET_RETRY_COUNTER   0x2C
31
32
33 /* Information to be passed to pinpad equipped readers.  See
34    ccid-driver.c for details. */
35 struct pininfo_s
36 {
37   int fixedlen;  /*
38                   * -1: Variable length input is not supported,
39                   *     no information of fixed length yet.
40                   *  0: Use variable length input.
41                   * >0: Fixed length of PIN.
42                   */
43   int minlen;
44   int maxlen;
45 };
46 typedef struct pininfo_s pininfo_t;
47
48
49 gpg_error_t iso7816_map_sw (int sw);
50
51 gpg_error_t iso7816_select_application (int slot,
52                                         const char *aid, size_t aidlen,
53                                         unsigned int flags);
54 gpg_error_t iso7816_select_file (int slot, int tag, int is_dir,
55                                  unsigned char **result, size_t *resultlen);
56 gpg_error_t iso7816_select_path (int slot,
57                                  const unsigned short *path, size_t pathlen,
58                                  unsigned char **result, size_t *resultlen);
59 gpg_error_t iso7816_list_directory (int slot, int list_dirs,
60                                     unsigned char **result, size_t *resultlen);
61 gpg_error_t iso7816_apdu_direct (int slot,
62                                  const void *apdudata, size_t apdudatalen,
63                                  int handle_more,
64                                  unsigned char **result, size_t *resultlen);
65 gpg_error_t iso7816_check_pinpad (int slot, int command,
66                                   pininfo_t *pininfo);
67 gpg_error_t iso7816_verify (int slot,
68                             int chvno, const char *chv, size_t chvlen);
69 gpg_error_t iso7816_verify_kp (int slot, int chvno, pininfo_t *pininfo);
70 gpg_error_t iso7816_change_reference_data (int slot, int chvno,
71                                const char *oldchv, size_t oldchvlen,
72                                const char *newchv, size_t newchvlen);
73 gpg_error_t iso7816_change_reference_data_kp (int slot, int chvno,
74                                               int is_exchange,
75                                               pininfo_t *pininfo);
76 gpg_error_t iso7816_reset_retry_counter (int slot, int chvno,
77                                          const char *newchv, size_t newchvlen);
78 gpg_error_t iso7816_reset_retry_counter_with_rc (int slot, int chvno,
79                                                  const char *data,
80                                                  size_t datalen);
81 gpg_error_t iso7816_get_data (int slot, int extended_mode, int tag,
82                               unsigned char **result, size_t *resultlen);
83 gpg_error_t iso7816_put_data (int slot, int extended_mode, int tag,
84                               const void *data, size_t datalen);
85 gpg_error_t iso7816_put_data_odd (int slot, int extended_mode, int tag,
86                                   const void *data, size_t datalen);
87 gpg_error_t iso7816_manage_security_env (int slot, int p1, int p2,
88                                          const unsigned char *data,
89                                          size_t datalen);
90 gpg_error_t iso7816_compute_ds (int slot, int extended_mode,
91                                 const unsigned char *data, size_t datalen,
92                                 int le,
93                                 unsigned char **result, size_t *resultlen);
94 gpg_error_t iso7816_decipher (int slot, int extended_mode,
95                               const unsigned char *data, size_t datalen,
96                               int le, int padind,
97                               unsigned char **result, size_t *resultlen);
98 gpg_error_t iso7816_internal_authenticate (int slot, int extended_mode,
99                                    const unsigned char *data, size_t datalen,
100                                    int le,
101                                    unsigned char **result, size_t *resultlen);
102 gpg_error_t iso7816_generate_keypair (int slot, int extended_mode,
103                                     const char *data, size_t datalen,
104                                     int le,
105                                     unsigned char **result, size_t *resultlen);
106 gpg_error_t iso7816_read_public_key (int slot, int extended_mode,
107                                     const char *data, size_t datalen,
108                                     int le,
109                                     unsigned char **result, size_t *resultlen);
110 gpg_error_t iso7816_get_challenge (int slot,
111                                    int length, unsigned char *buffer);
112
113 gpg_error_t iso7816_read_binary (int slot, size_t offset, size_t nmax,
114                                  unsigned char **result, size_t *resultlen);
115 gpg_error_t iso7816_read_record (int slot, int recno, int reccount,
116                                  int short_ef,
117                                  unsigned char **result, size_t *resultlen);
118
119 #endif /*ISO7816_H*/