Prepare for OpenPGP cards with extended length support.
[gnupg.git] / scd / iso7816.h
blob44e50d784aa3de8a19c5c208bd50eb0942147d6d
1 /* iso7816.h - ISO 7816 commands
2 * Copyright (C) 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 3 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, see <http://www.gnu.org/licenses/>.
19 * $Id$
22 #ifndef ISO7816_H
23 #define ISO7816_H
25 #if GNUPG_MAJOR_VERSION == 1
26 #include "cardglue.h"
27 #endif
29 /* Command codes used by iso7816_check_keypad. */
30 #define ISO7816_VERIFY 0x20
31 #define ISO7816_CHANGE_REFERENCE_DATA 0x24
32 #define ISO7816_RESET_RETRY_COUNTER 0x2C
35 /* Information to be passed to keypad equipped readers. See
36 ccid-driver.c for details. */
37 struct iso7816_pininfo_s
39 int mode; /* A mode of 0 means: Do not use the keypad. */
40 int minlen;
41 int maxlen;
42 int padlen;
43 int padchar;
45 typedef struct iso7816_pininfo_s iso7816_pininfo_t;
48 gpg_error_t iso7816_map_sw (int sw);
50 gpg_error_t iso7816_select_application (int slot,
51 const char *aid, size_t aidlen,
52 unsigned int flags);
53 gpg_error_t iso7816_select_file (int slot, int tag, int is_dir,
54 unsigned char **result, size_t *resultlen);
55 gpg_error_t iso7816_select_path (int slot,
56 const unsigned short *path, size_t pathlen,
57 unsigned char **result, size_t *resultlen);
58 gpg_error_t iso7816_list_directory (int slot, int list_dirs,
59 unsigned char **result, size_t *resultlen);
60 gpg_error_t iso7816_apdu_direct (int slot,
61 const void *apdudata, size_t apdudatalen,
62 int handle_more,
63 unsigned char **result, size_t *resultlen);
64 gpg_error_t iso7816_check_keypad (int slot, int command,
65 iso7816_pininfo_t *pininfo);
66 gpg_error_t iso7816_verify (int slot,
67 int chvno, const char *chv, size_t chvlen);
68 gpg_error_t iso7816_verify_kp (int slot,
69 int chvno, const char *chv, size_t chvlen,
70 iso7816_pininfo_t *pininfo);
71 gpg_error_t iso7816_change_reference_data (int slot, int chvno,
72 const char *oldchv, size_t oldchvlen,
73 const char *newchv, size_t newchvlen);
74 gpg_error_t iso7816_change_reference_data_kp (int slot, int chvno,
75 const char *oldchv, size_t oldchvlen,
76 const char *newchv, size_t newchvlen,
77 iso7816_pininfo_t *pininfo);
78 gpg_error_t iso7816_reset_retry_counter (int slot, int chvno,
79 const char *newchv, size_t newchvlen);
80 gpg_error_t iso7816_reset_retry_counter_kp (int slot, int chvno,
81 const char *newchv,
82 size_t newchvlen,
83 iso7816_pininfo_t *pininfo);
84 gpg_error_t iso7816_reset_retry_counter_with_rc (int slot, int chvno,
85 const char *data,
86 size_t datalen);
87 gpg_error_t iso7816_get_data (int slot, int tag,
88 unsigned char **result, size_t *resultlen);
89 gpg_error_t iso7816_put_data (int slot, int extended_mode, int tag,
90 const unsigned char *data, size_t datalen);
91 gpg_error_t iso7816_put_data_odd (int slot, int extended_mode, int tag,
92 const unsigned char *data, size_t datalen);
93 gpg_error_t iso7816_manage_security_env (int slot, int p1, int p2,
94 const unsigned char *data,
95 size_t datalen);
96 gpg_error_t iso7816_compute_ds (int slot,
97 const unsigned char *data, size_t datalen,
98 unsigned char **result, size_t *resultlen);
99 gpg_error_t iso7816_decipher (int slot, int extended_mode,
100 const unsigned char *data, size_t datalen,
101 int padind,
102 unsigned char **result, size_t *resultlen);
103 gpg_error_t iso7816_internal_authenticate (int slot,
104 const unsigned char *data, size_t datalen,
105 unsigned char **result, size_t *resultlen);
106 gpg_error_t iso7816_generate_keypair (int slot,
107 const unsigned char *data, size_t datalen,
108 unsigned char **result, size_t *resultlen);
109 gpg_error_t iso7816_read_public_key (int slot,
110 const unsigned char *data, size_t datalen,
111 unsigned char **result, size_t *resultlen);
112 gpg_error_t iso7816_get_challenge (int slot,
113 int length, unsigned char *buffer);
115 gpg_error_t iso7816_read_binary (int slot, size_t offset, size_t nmax,
116 unsigned char **result, size_t *resultlen);
117 gpg_error_t iso7816_read_record (int slot, int recno, int reccount,
118 int short_ef,
119 unsigned char **result, size_t *resultlen);
121 #endif /*ISO7816_H*/