1 /* ccid-driver.h - USB ChipCardInterfaceDevices driver 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 * ALTERNATIVELY, this file may be distributed under the terms of the 20 * following license, in which case the provisions of this license are 21 * required INSTEAD OF the GNU General Public License. If you wish to 22 * allow use of your version of this file only under the terms of the 23 * GNU General Public License, and not to allow others to use your 24 * version of this file under the terms of the following license, 25 * indicate your decision by deleting this paragraph and the license 26 * below. 27 * 28 * Redistribution and use in source and binary forms, with or without 29 * modification, are permitted provided that the following conditions 30 * are met: 31 * 1. Redistributions of source code must retain the above copyright 32 * notice, and the entire permission notice in its entirety, 33 * including the disclaimer of warranties. 34 * 2. Redistributions in binary form must reproduce the above copyright 35 * notice, this list of conditions and the following disclaimer in the 36 * documentation and/or other materials provided with the distribution. 37 * 3. The name of the author may not be used to endorse or promote 38 * products derived from this software without specific prior 39 * written permission. 40 * 41 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED 42 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 44 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 45 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 46 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 47 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 49 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 50 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 51 * OF THE POSSIBILITY OF SUCH DAMAGE. 52 * 53 * $Id$ 54 */ 55 56 #ifndef CCID_DRIVER_H 57 #define CCID_DRIVER_H 58 59 60 #ifdef CCID_DRIVER_INCLUDE_USB_IDS 61 /* We need to know the vendor to do some hacks. */ 62 enum { 63 VENDOR_CHERRY = 0x046a, 64 VENDOR_SCM = 0x04e6, 65 VENDOR_OMNIKEY= 0x076b, 66 VENDOR_GEMPC = 0x08e6, 67 VENDOR_VEGA = 0x0982, 68 VENDOR_REINER = 0x0c4b, 69 VENDOR_KAAN = 0x0d46, 70 VENDOR_FSIJ = 0x234b, 71 VENDOR_VASCO = 0x1a44, 72 VENDOR_NXP = 0x1fc9, 73 }; 74 75 76 /* Some product ids. */ 77 #define SCM_SCR331 0xe001 78 #define SCM_SCR331DI 0x5111 79 #define SCM_SCR335 0x5115 80 #define SCM_SCR3310 0x5116 /* @MAXX Basic */ 81 #define SCM_SCR3320 0x5117 82 #define SCM_SPR532 0xe003 /* Also used succeeding model SPR332. */ 83 #define CHERRY_ST2000 0x003e 84 #define VASCO_920 0x0920 85 #define GEMPC_PINPAD 0x3478 86 #define GEMPC_CT30 0x3437 87 #define GEMPC_EZIO 0x34c2 /* (!=34c0) Also known as IDBridge CT710 */ 88 #define VEGA_ALPHA 0x0008 89 #define CYBERJACK_GO 0x0504 90 #define CRYPTOUCAN 0x81e6 91 92 #endif /*CCID_DRIVER_INCLUDE_USB_IDS*/ 93 94 95 /* The CID driver returns the same error codes as the status words 96 used by GnuPG's apdu.h. For ease of maintenance they should always 97 match. */ 98 #define CCID_DRIVER_ERR_OUT_OF_CORE 0x10001 99 #define CCID_DRIVER_ERR_INV_VALUE 0x10002 100 #define CCID_DRIVER_ERR_INCOMPLETE_CARD_RESPONSE = 0x10003 101 #define CCID_DRIVER_ERR_NO_DRIVER 0x10004 102 #define CCID_DRIVER_ERR_NOT_SUPPORTED 0x10005 103 #define CCID_DRIVER_ERR_LOCKING_FAILED 0x10006 104 #define CCID_DRIVER_ERR_BUSY 0x10007 105 #define CCID_DRIVER_ERR_NO_CARD 0x10008 106 #define CCID_DRIVER_ERR_CARD_INACTIVE 0x10009 107 #define CCID_DRIVER_ERR_CARD_IO_ERROR 0x1000a 108 #define CCID_DRIVER_ERR_GENERAL_ERROR 0x1000b 109 #define CCID_DRIVER_ERR_NO_READER 0x1000c 110 #define CCID_DRIVER_ERR_ABORTED 0x1000d 111 #define CCID_DRIVER_ERR_NO_PINPAD 0x1000e 112 #define CCID_DRIVER_ERR_USB_OTHER 0x10020 113 #define CCID_DRIVER_ERR_USB_IO 0x10021 114 #define CCID_DRIVER_ERR_USB_ACCESS 0x10023 115 #define CCID_DRIVER_ERR_USB_NO_DEVICE 0x10024 116 #define CCID_DRIVER_ERR_USB_BUSY 0x10026 117 #define CCID_DRIVER_ERR_USB_TIMEOUT 0x10027 118 #define CCID_DRIVER_ERR_USB_OVERFLOW 0x10028 119 #define CCID_DRIVER_ERR_UI_CANCELLED 0x10030 120 #define CCID_DRIVER_ERR_UI_TIMEOUT 0x10031 121 122 struct ccid_driver_s; 123 typedef struct ccid_driver_s *ccid_driver_t; 124 125 struct ccid_dev_table; 126 127 int ccid_set_debug_level (int level); 128 char *ccid_get_reader_list (void); 129 130 gpg_error_t ccid_dev_scan (int *idx_max, void **t_p); 131 void ccid_dev_scan_finish (void *tbl0, int max); 132 unsigned int ccid_get_BAI (int, void *tbl0); 133 int ccid_compare_BAI (ccid_driver_t handle, unsigned int); 134 int ccid_open_reader (const char *spec_reader_name, 135 int idx, void *ccid_table0, 136 ccid_driver_t *handle, char **rdrname_p); 137 int ccid_set_progress_cb (ccid_driver_t handle, 138 void (*cb)(void *, const char *, int, int, int), 139 void *cb_arg); 140 int ccid_set_prompt_cb (ccid_driver_t handle, void (*cb)(void *, int), 141 void *cb_arg); 142 int ccid_shutdown_reader (ccid_driver_t handle); 143 int ccid_close_reader (ccid_driver_t handle); 144 int ccid_get_atr (ccid_driver_t handle, 145 unsigned char *atr, size_t maxatrlen, size_t *atrlen); 146 int ccid_slot_status (ccid_driver_t handle, int *statusbits, int on_wire); 147 int ccid_transceive (ccid_driver_t handle, 148 const unsigned char *apdu, size_t apdulen, 149 unsigned char *resp, size_t maxresplen, size_t *nresp); 150 int ccid_transceive_secure (ccid_driver_t handle, 151 const unsigned char *apdu, size_t apdulen, 152 pininfo_t *pininfo, 153 unsigned char *resp, size_t maxresplen, size_t *nresp); 154 int ccid_transceive_escape (ccid_driver_t handle, 155 const unsigned char *data, size_t datalen, 156 unsigned char *resp, size_t maxresplen, 157 size_t *nresp); 158 int ccid_require_get_status (ccid_driver_t handle); 159 160 161 #endif /*CCID_DRIVER_H*/ 162