2001-12-29 02:07:32 +00:00
|
|
|
|
/*
|
2001-11-24 13:32:52 +00:00
|
|
|
|
* opensc.h: OpenSC library header file
|
2001-11-01 15:43:20 +00:00
|
|
|
|
*
|
2002-04-05 14:46:44 +00:00
|
|
|
|
* Copyright (C) 2001, 2002 Juha Yrj<EFBFBD>l<EFBFBD> <juha.yrjola@iki.fi>
|
2001-11-01 15:43:20 +00:00
|
|
|
|
*
|
2001-11-06 18:34:19 +00:00
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
2001-11-01 15:43:20 +00:00
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2001-11-06 18:34:19 +00:00
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
* Lesser General Public License for more details.
|
2001-11-01 15:43:20 +00:00
|
|
|
|
*
|
2001-11-06 18:34:19 +00:00
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
2001-11-01 15:43:20 +00:00
|
|
|
|
*/
|
|
|
|
|
|
2005-02-20 08:26:27 +00:00
|
|
|
|
/**
|
2002-01-10 23:02:48 +00:00
|
|
|
|
* @file opensc.h
|
|
|
|
|
* @brief OpenSC library core header file
|
|
|
|
|
*/
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2001-12-13 21:19:11 +00:00
|
|
|
|
#ifndef _OPENSC_H
|
|
|
|
|
#define _OPENSC_H
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2002-03-24 14:12:38 +00:00
|
|
|
|
#include <stdio.h>
|
2005-03-26 19:35:35 +00:00
|
|
|
|
#ifdef HAVE_UNISTD_H
|
2005-03-23 23:24:13 +00:00
|
|
|
|
#include <unistd.h>
|
2005-03-26 19:35:35 +00:00
|
|
|
|
#endif
|
2002-03-24 14:12:38 +00:00
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
|
#ifdef __cplusplus
|
2001-12-08 15:27:40 +00:00
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
2002-04-19 14:23:31 +00:00
|
|
|
|
#include <opensc/scconf.h>
|
|
|
|
|
#include <opensc/errors.h>
|
|
|
|
|
#include <opensc/types.h>
|
|
|
|
|
|
2001-12-30 21:17:34 +00:00
|
|
|
|
#ifndef __GNUC__
|
|
|
|
|
#undef inline
|
|
|
|
|
#define inline
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* Different APDU cases */
|
2001-11-01 15:43:20 +00:00
|
|
|
|
#define SC_APDU_CASE_NONE 0
|
|
|
|
|
#define SC_APDU_CASE_1 1
|
|
|
|
|
#define SC_APDU_CASE_2_SHORT 2
|
|
|
|
|
#define SC_APDU_CASE_3_SHORT 3
|
|
|
|
|
#define SC_APDU_CASE_4_SHORT 4
|
|
|
|
|
#define SC_APDU_CASE_2_EXT 5
|
|
|
|
|
#define SC_APDU_CASE_3_EXT 6
|
|
|
|
|
#define SC_APDU_CASE_4_EXT 7
|
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* File types */
|
|
|
|
|
#define SC_FILE_TYPE_DF 0x04
|
|
|
|
|
#define SC_FILE_TYPE_INTERNAL_EF 0x03
|
|
|
|
|
#define SC_FILE_TYPE_WORKING_EF 0x01
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* EF structures */
|
|
|
|
|
#define SC_FILE_EF_UNKNOWN 0x00
|
2001-11-17 00:11:29 +00:00
|
|
|
|
#define SC_FILE_EF_TRANSPARENT 0x01
|
|
|
|
|
#define SC_FILE_EF_LINEAR_FIXED 0x02
|
|
|
|
|
#define SC_FILE_EF_LINEAR_FIXED_TLV 0x03
|
2001-12-25 20:45:48 +00:00
|
|
|
|
#define SC_FILE_EF_LINEAR_VARIABLE 0x04
|
2001-12-29 02:07:32 +00:00
|
|
|
|
#define SC_FILE_EF_LINEAR_VARIABLE_TLV 0x05
|
2001-12-25 20:45:48 +00:00
|
|
|
|
#define SC_FILE_EF_CYCLIC 0x06
|
2001-12-29 02:07:32 +00:00
|
|
|
|
#define SC_FILE_EF_CYCLIC_TLV 0x07
|
2001-12-25 20:45:48 +00:00
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* File status flags */
|
2001-12-25 20:45:48 +00:00
|
|
|
|
#define SC_FILE_STATUS_ACTIVATED 0x00
|
|
|
|
|
#define SC_FILE_STATUS_INVALIDATED 0x01
|
2005-03-30 18:18:46 +00:00
|
|
|
|
#define SC_FILE_STATUS_CREATION 0x02 /* Full access in this state,
|
|
|
|
|
(at least for SetCOS 4.4 */
|
2001-11-17 00:11:29 +00:00
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* Access Control flags */
|
2002-02-20 09:56:47 +00:00
|
|
|
|
#define SC_AC_NONE 0x00000000
|
|
|
|
|
#define SC_AC_CHV 0x00000001 /* Card Holder Verif. */
|
|
|
|
|
#define SC_AC_TERM 0x00000002 /* Terminal auth. */
|
|
|
|
|
#define SC_AC_PRO 0x00000004 /* Secure Messaging */
|
|
|
|
|
#define SC_AC_AUT 0x00000008 /* Key auth. */
|
|
|
|
|
|
2002-04-02 12:57:17 +00:00
|
|
|
|
#define SC_AC_SYMBOLIC 0x00000010 /* internal use only */
|
2002-02-20 09:56:47 +00:00
|
|
|
|
#define SC_AC_UNKNOWN 0xFFFFFFFE
|
|
|
|
|
#define SC_AC_NEVER 0xFFFFFFFF
|
2001-12-29 02:07:32 +00:00
|
|
|
|
|
|
|
|
|
/* Operations relating to access control (in case of DF) */
|
|
|
|
|
#define SC_AC_OP_SELECT 0
|
|
|
|
|
#define SC_AC_OP_LOCK 1
|
|
|
|
|
#define SC_AC_OP_DELETE 2
|
|
|
|
|
#define SC_AC_OP_CREATE 3
|
|
|
|
|
#define SC_AC_OP_REHABILITATE 4
|
|
|
|
|
#define SC_AC_OP_INVALIDATE 5
|
2002-01-08 13:56:50 +00:00
|
|
|
|
#define SC_AC_OP_LIST_FILES 6
|
2002-03-09 15:11:46 +00:00
|
|
|
|
#define SC_AC_OP_CRYPTO 7
|
2002-04-05 15:06:33 +00:00
|
|
|
|
/* If you add more OPs here, make sure you increase
|
|
|
|
|
* SC_MAX_AC_OPS in types.h */
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
/* Operations relating to access control (in case of EF) */
|
|
|
|
|
#define SC_AC_OP_READ 0
|
|
|
|
|
#define SC_AC_OP_UPDATE 1
|
|
|
|
|
#define SC_AC_OP_WRITE 2
|
|
|
|
|
#define SC_AC_OP_ERASE 3
|
|
|
|
|
/* rehab and invalidate are the same as in DF case */
|
|
|
|
|
|
2002-02-21 19:23:21 +00:00
|
|
|
|
/* sc_*_record() flags */
|
|
|
|
|
#define SC_RECORD_EF_ID_MASK 0x0001F
|
|
|
|
|
#define SC_RECORD_BY_REC_ID 0x00000
|
|
|
|
|
#define SC_RECORD_BY_REC_NR 0x00100
|
|
|
|
|
#define SC_RECORD_CURRENT 0
|
2001-12-29 02:07:32 +00:00
|
|
|
|
|
|
|
|
|
/* various maximum values */
|
2005-02-20 08:26:27 +00:00
|
|
|
|
#define SC_MAX_READER_DRIVERS 6
|
2003-03-10 21:22:42 +00:00
|
|
|
|
#define SC_MAX_READERS 16
|
2005-02-20 08:26:27 +00:00
|
|
|
|
#define SC_MAX_CARD_DRIVERS 32
|
|
|
|
|
#define SC_MAX_CARD_DRIVER_SNAME_SIZE 16
|
2002-02-24 19:32:14 +00:00
|
|
|
|
#define SC_MAX_SLOTS 4
|
2003-10-19 18:05:03 +00:00
|
|
|
|
#define SC_MAX_CARD_APPS 8
|
2002-02-11 15:55:34 +00:00
|
|
|
|
#define SC_MAX_APDU_BUFFER_SIZE 258
|
2003-11-20 15:39:38 +00:00
|
|
|
|
#define SC_MAX_PIN_SIZE 256 /* OpenPGP card has 254 max */
|
2001-11-07 13:45:41 +00:00
|
|
|
|
#define SC_MAX_ATR_SIZE 33
|
2002-02-20 09:56:47 +00:00
|
|
|
|
#define SC_MAX_AID_SIZE 16
|
2005-02-02 10:21:10 +00:00
|
|
|
|
/* Beware: the following needs to be a multiple of 4
|
2002-03-13 20:24:31 +00:00
|
|
|
|
* or else sc_update_binary will not work on GPK */
|
|
|
|
|
#define SC_APDU_CHOP_SIZE 248
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2002-02-20 09:56:47 +00:00
|
|
|
|
#define SC_AC_KEY_REF_NONE 0xFFFFFFFF
|
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
#define SC_SEC_OPERATION_DECIPHER 0x0001
|
|
|
|
|
#define SC_SEC_OPERATION_SIGN 0x0002
|
2003-04-16 15:58:57 +00:00
|
|
|
|
#define SC_SEC_OPERATION_AUTHENTICATE 0x0003
|
2001-12-21 23:34:47 +00:00
|
|
|
|
|
2002-01-16 23:59:18 +00:00
|
|
|
|
/* sc_security_env flags */
|
2002-01-20 21:20:09 +00:00
|
|
|
|
#define SC_SEC_ENV_ALG_REF_PRESENT 0x0001
|
|
|
|
|
#define SC_SEC_ENV_FILE_REF_PRESENT 0x0002
|
|
|
|
|
#define SC_SEC_ENV_KEY_REF_PRESENT 0x0004
|
|
|
|
|
/* FIXME: the flag below is misleading */
|
|
|
|
|
#define SC_SEC_ENV_KEY_REF_ASYMMETRIC 0x0008
|
|
|
|
|
#define SC_SEC_ENV_ALG_PRESENT 0x0010
|
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
/* PK algorithms */
|
2002-01-20 21:20:09 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA 0
|
|
|
|
|
#define SC_ALGORITHM_DSA 1
|
|
|
|
|
#define SC_ALGORITHM_EC 2
|
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
/* Symmetric algorithms */
|
|
|
|
|
#define SC_ALGORITHM_DES 64
|
|
|
|
|
#define SC_ALGORITHM_3DES 65
|
|
|
|
|
|
2002-04-17 08:56:58 +00:00
|
|
|
|
/* Hash algorithms */
|
|
|
|
|
#define SC_ALGORITHM_MD5 128
|
|
|
|
|
#define SC_ALGORITHM_SHA1 129
|
|
|
|
|
|
|
|
|
|
/* Key derivation algorithms */
|
|
|
|
|
#define SC_ALGORITHM_PBKDF2 192
|
|
|
|
|
|
|
|
|
|
/* Key encryption algoprithms */
|
|
|
|
|
#define SC_ALGORITHM_PBES2 256
|
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
#define SC_ALGORITHM_ONBOARD_KEY_GEN 0x80000000
|
2002-11-08 14:14:42 +00:00
|
|
|
|
#define SC_ALGORITHM_NEED_USAGE 0x40000000
|
2002-03-01 11:52:55 +00:00
|
|
|
|
#define SC_ALGORITHM_SPECIFIC_FLAGS 0x0000FFFF
|
2002-03-08 05:59:57 +00:00
|
|
|
|
|
|
|
|
|
#define SC_ALGORITHM_RSA_RAW 0x00000001
|
2005-02-20 08:26:27 +00:00
|
|
|
|
/* If the card is willing to produce a cryptogram padded with the following
|
2002-03-10 11:48:57 +00:00
|
|
|
|
* methods, set these flags accordingly. */
|
2002-03-12 13:00:57 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_PADS 0x0000000E
|
2003-06-11 10:56:04 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_PAD_NONE 0x00000000
|
2002-03-08 05:59:57 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_PAD_PKCS1 0x00000002
|
|
|
|
|
#define SC_ALGORITHM_RSA_PAD_ANSI 0x00000004
|
|
|
|
|
#define SC_ALGORITHM_RSA_PAD_ISO9796 0x00000008
|
2002-03-10 11:48:57 +00:00
|
|
|
|
|
2005-02-20 08:26:27 +00:00
|
|
|
|
/* If the card is willing to produce a cryptogram with the following
|
2002-03-10 11:48:57 +00:00
|
|
|
|
* hash values, set these flags accordingly. */
|
2002-03-08 05:59:57 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_HASH_NONE 0x00000010
|
2002-12-17 20:14:41 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_HASHES 0x000001E0
|
2002-03-08 05:59:57 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_HASH_SHA1 0x00000020
|
|
|
|
|
#define SC_ALGORITHM_RSA_HASH_MD5 0x00000040
|
|
|
|
|
#define SC_ALGORITHM_RSA_HASH_MD5_SHA1 0x00000080
|
2002-12-17 20:14:41 +00:00
|
|
|
|
#define SC_ALGORITHM_RSA_HASH_RIPEMD160 0x00000100
|
2002-01-07 18:23:34 +00:00
|
|
|
|
|
2003-04-02 06:58:20 +00:00
|
|
|
|
/* A 64-bit uint, used in sc_current_time() */
|
|
|
|
|
#ifndef _WIN32
|
2003-08-18 14:54:37 +00:00
|
|
|
|
typedef unsigned long long sc_timestamp_t;
|
2005-01-30 19:20:38 +00:00
|
|
|
|
#define msleep(t) usleep((t) * 1000)
|
2003-04-02 06:58:20 +00:00
|
|
|
|
#else
|
2003-08-18 14:54:37 +00:00
|
|
|
|
typedef unsigned __int64 sc_timestamp_t;
|
2005-01-30 19:20:38 +00:00
|
|
|
|
#define msleep(t) Sleep(t)
|
|
|
|
|
#define sleep(t) Sleep((t) * 1000)
|
2003-04-02 06:58:20 +00:00
|
|
|
|
#endif
|
|
|
|
|
|
2003-01-03 16:32:06 +00:00
|
|
|
|
/* Event masks for sc_wait_for_event() */
|
|
|
|
|
#define SC_EVENT_CARD_INSERTED 0x0001
|
|
|
|
|
#define SC_EVENT_CARD_REMOVED 0x0002
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_security_env {
|
2002-03-08 05:59:57 +00:00
|
|
|
|
unsigned long flags;
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int operation;
|
2002-01-20 21:20:09 +00:00
|
|
|
|
unsigned int algorithm, algorithm_flags;
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
2002-01-20 21:20:09 +00:00
|
|
|
|
unsigned int algorithm_ref;
|
|
|
|
|
struct sc_path file_ref;
|
|
|
|
|
u8 key_ref[8];
|
|
|
|
|
size_t key_ref_len;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_security_env_t;
|
2002-01-20 21:20:09 +00:00
|
|
|
|
|
2002-03-08 05:59:57 +00:00
|
|
|
|
struct sc_algorithm_id {
|
|
|
|
|
unsigned int algorithm;
|
|
|
|
|
struct sc_object_id obj_id;
|
2002-04-17 08:56:58 +00:00
|
|
|
|
void *params;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct sc_pbkdf2_params {
|
|
|
|
|
u8 salt[16];
|
|
|
|
|
size_t salt_len;
|
|
|
|
|
int iterations;
|
2003-05-30 08:54:42 +00:00
|
|
|
|
size_t key_length;
|
2002-04-17 08:56:58 +00:00
|
|
|
|
struct sc_algorithm_id hash_alg;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct sc_pbes2_params {
|
|
|
|
|
struct sc_algorithm_id derivation_alg;
|
|
|
|
|
struct sc_algorithm_id key_encr_alg;
|
2002-03-08 05:59:57 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_algorithm_info {
|
2002-03-01 11:52:55 +00:00
|
|
|
|
unsigned int algorithm;
|
|
|
|
|
unsigned int key_length;
|
2004-12-22 09:54:41 +00:00
|
|
|
|
unsigned int flags;
|
2002-03-08 05:59:57 +00:00
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
union {
|
|
|
|
|
struct sc_rsa_info {
|
2004-12-22 09:54:41 +00:00
|
|
|
|
unsigned long exponent;
|
2002-03-01 11:52:55 +00:00
|
|
|
|
} _rsa;
|
|
|
|
|
} u;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_algorithm_info_t;
|
2002-03-01 11:52:55 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_app_info {
|
2002-02-20 09:56:47 +00:00
|
|
|
|
u8 aid[SC_MAX_AID_SIZE];
|
|
|
|
|
size_t aid_len;
|
|
|
|
|
char *label;
|
|
|
|
|
struct sc_path path;
|
|
|
|
|
u8 *ddo;
|
|
|
|
|
size_t ddo_len;
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2002-02-20 09:56:47 +00:00
|
|
|
|
const char *desc; /* App description, if known */
|
2002-02-26 11:23:25 +00:00
|
|
|
|
int rec_nr; /* -1, if EF(DIR) is transparent */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_app_info_t;
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2002-01-20 21:20:09 +00:00
|
|
|
|
struct sc_card_cache {
|
|
|
|
|
struct sc_path current_path;
|
2001-12-20 13:57:58 +00:00
|
|
|
|
};
|
|
|
|
|
|
2002-01-28 21:04:53 +00:00
|
|
|
|
#define SC_PROTO_T0 0x00000001
|
|
|
|
|
#define SC_PROTO_T1 0x00000002
|
|
|
|
|
#define SC_PROTO_RAW 0x00001000
|
|
|
|
|
#define SC_PROTO_ANY 0xFFFFFFFF
|
|
|
|
|
|
2002-02-24 19:32:14 +00:00
|
|
|
|
struct sc_reader_driver {
|
|
|
|
|
const char *name;
|
|
|
|
|
const char *short_name;
|
|
|
|
|
struct sc_reader_operations *ops;
|
2003-12-18 16:35:28 +00:00
|
|
|
|
|
|
|
|
|
size_t max_send_size, max_recv_size;
|
|
|
|
|
int apdu_masquerade;
|
2004-10-18 08:24:12 +00:00
|
|
|
|
void *dll;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
};
|
2003-12-18 16:35:28 +00:00
|
|
|
|
#define SC_APDU_MASQUERADE_NONE 0x00
|
|
|
|
|
#define SC_APDU_MASQUERADE_4AS3 0x01
|
|
|
|
|
#define SC_APDU_MASQUERADE_1AS2 0x02
|
|
|
|
|
#define SC_APDU_MASQUERADE_1AS2_ALWAYS 0x04
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
2002-12-23 18:47:27 +00:00
|
|
|
|
/* slot flags */
|
2002-02-24 19:32:14 +00:00
|
|
|
|
#define SC_SLOT_CARD_PRESENT 0x00000001
|
2003-01-19 17:47:07 +00:00
|
|
|
|
#define SC_SLOT_CARD_CHANGED 0x00000002
|
2002-12-23 18:47:27 +00:00
|
|
|
|
/* slot capabilities */
|
|
|
|
|
#define SC_SLOT_CAP_DISPLAY 0x00000001
|
|
|
|
|
#define SC_SLOT_CAP_PIN_PAD 0x00000002
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_slot_info {
|
2005-02-20 08:26:27 +00:00
|
|
|
|
int id;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
unsigned long flags, capabilities;
|
|
|
|
|
unsigned int supported_protocols, active_protocol;
|
|
|
|
|
u8 atr[SC_MAX_ATR_SIZE];
|
|
|
|
|
size_t atr_len;
|
2002-03-26 11:38:40 +00:00
|
|
|
|
|
|
|
|
|
struct _atr_info {
|
|
|
|
|
u8 *hist_bytes;
|
|
|
|
|
size_t hist_bytes_len;
|
|
|
|
|
int Fi, f, Di, N;
|
|
|
|
|
u8 FI, DI;
|
|
|
|
|
} atr_info;
|
|
|
|
|
|
2002-02-24 19:32:14 +00:00
|
|
|
|
void *drv_data;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_slot_info_t;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
|
|
|
|
struct sc_event_listener {
|
|
|
|
|
unsigned int event_mask;
|
|
|
|
|
void (*func)(void *, const struct sc_slot_info *, unsigned int event);
|
|
|
|
|
};
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_reader {
|
2002-02-24 19:32:14 +00:00
|
|
|
|
struct sc_context *ctx;
|
|
|
|
|
const struct sc_reader_driver *driver;
|
|
|
|
|
const struct sc_reader_operations *ops;
|
|
|
|
|
void *drv_data;
|
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
|
|
struct sc_slot_info slot[SC_MAX_SLOTS];
|
|
|
|
|
int slot_count;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_reader_t;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
2002-12-23 18:47:27 +00:00
|
|
|
|
/* This will be the new interface for handling PIN commands.
|
|
|
|
|
* It is supposed to support pin pads (with or without display)
|
|
|
|
|
* attached to the reader.
|
|
|
|
|
*/
|
|
|
|
|
#define SC_PIN_CMD_VERIFY 0
|
|
|
|
|
#define SC_PIN_CMD_CHANGE 1
|
|
|
|
|
#define SC_PIN_CMD_UNBLOCK 2
|
|
|
|
|
|
|
|
|
|
#define SC_PIN_CMD_USE_PINPAD 0x0001
|
|
|
|
|
#define SC_PIN_CMD_NEED_PADDING 0x0002
|
|
|
|
|
|
|
|
|
|
#define SC_PIN_ENCODING_ASCII 0
|
|
|
|
|
#define SC_PIN_ENCODING_BCD 1
|
2003-07-14 13:20:49 +00:00
|
|
|
|
#define SC_PIN_ENCODING_GLP 2 /* Global Platform - Card Specification <20> v 2.0.1 */
|
2002-12-23 18:47:27 +00:00
|
|
|
|
|
2003-01-14 19:55:45 +00:00
|
|
|
|
struct sc_pin_cmd_pin {
|
|
|
|
|
const char *prompt; /* Prompt to display */
|
|
|
|
|
|
|
|
|
|
const u8 *data; /* PIN, if given by the appliction */
|
|
|
|
|
int len; /* set to -1 to get pin from pin pad */
|
|
|
|
|
|
|
|
|
|
size_t min_length; /* min/max length of PIN */
|
|
|
|
|
size_t max_length;
|
2005-01-07 18:50:04 +00:00
|
|
|
|
unsigned int encoding; /* ASCII-numeric, BCD, etc */
|
2003-01-14 19:55:45 +00:00
|
|
|
|
size_t pad_length; /* filled in by the card driver */
|
|
|
|
|
u8 pad_char;
|
2004-10-22 07:29:07 +00:00
|
|
|
|
size_t offset; /* PIN offset in the APDU */
|
|
|
|
|
size_t length_offset; /* Effective PIN length offset in the APDU */
|
2003-01-14 19:55:45 +00:00
|
|
|
|
};
|
2002-12-23 18:47:27 +00:00
|
|
|
|
|
|
|
|
|
struct sc_pin_cmd_data {
|
|
|
|
|
unsigned int cmd;
|
|
|
|
|
unsigned int flags;
|
|
|
|
|
|
|
|
|
|
unsigned int pin_type; /* usually SC_AC_CHV */
|
|
|
|
|
int pin_reference;
|
|
|
|
|
|
2003-01-14 19:55:45 +00:00
|
|
|
|
struct sc_pin_cmd_pin pin1, pin2;
|
2002-12-23 18:47:27 +00:00
|
|
|
|
|
|
|
|
|
struct sc_apdu *apdu; /* APDU of the PIN command */
|
|
|
|
|
};
|
|
|
|
|
|
2004-07-19 16:51:41 +00:00
|
|
|
|
/* structure for the card serial number (normally the ICCSN) */
|
|
|
|
|
#define SC_MAX_SERIALNR 32
|
|
|
|
|
|
|
|
|
|
typedef struct sc_serial_number {
|
|
|
|
|
u8 value[SC_MAX_SERIALNR];
|
|
|
|
|
size_t len;
|
|
|
|
|
} sc_serial_number_t;
|
|
|
|
|
|
2002-02-24 19:32:14 +00:00
|
|
|
|
#define SC_DISCONNECT 0
|
|
|
|
|
#define SC_DISCONNECT_AND_RESET 1
|
|
|
|
|
#define SC_DISCONNECT_AND_UNPOWER 2
|
|
|
|
|
#define SC_DISCONNECT_AND_EJECT 3
|
|
|
|
|
|
|
|
|
|
struct sc_reader_operations {
|
|
|
|
|
/* Called during sc_establish_context(), when the driver
|
|
|
|
|
* is loaded */
|
|
|
|
|
int (*init)(struct sc_context *ctx, void **priv_data);
|
|
|
|
|
/* Called when the driver is being unloaded. finish() has to
|
|
|
|
|
* deallocate the private data and any resources. */
|
2002-04-05 14:46:44 +00:00
|
|
|
|
int (*finish)(struct sc_context *ctx, void *priv_data);
|
2002-02-24 19:32:14 +00:00
|
|
|
|
/* Called when releasing a reader. release() has to
|
|
|
|
|
* deallocate the private data. Other fields will be
|
|
|
|
|
* freed by OpenSC. */
|
|
|
|
|
int (*release)(struct sc_reader *reader);
|
|
|
|
|
|
|
|
|
|
int (*detect_card_presence)(struct sc_reader *reader,
|
|
|
|
|
struct sc_slot_info *slot);
|
|
|
|
|
int (*connect)(struct sc_reader *reader, struct sc_slot_info *slot);
|
|
|
|
|
int (*disconnect)(struct sc_reader *reader, struct sc_slot_info *slot,
|
|
|
|
|
int action);
|
|
|
|
|
int (*transmit)(struct sc_reader *reader, struct sc_slot_info *slot,
|
|
|
|
|
const u8 *sendbuf, size_t sendsize,
|
2002-12-23 18:47:27 +00:00
|
|
|
|
u8 *recvbuf, size_t *recvsize,
|
2005-01-24 11:31:11 +00:00
|
|
|
|
unsigned long control);
|
2002-02-24 19:32:14 +00:00
|
|
|
|
int (*lock)(struct sc_reader *reader, struct sc_slot_info *slot);
|
|
|
|
|
int (*unlock)(struct sc_reader *reader, struct sc_slot_info *slot);
|
|
|
|
|
int (*set_protocol)(struct sc_reader *reader, struct sc_slot_info *slot,
|
|
|
|
|
unsigned int proto);
|
2002-12-23 18:47:27 +00:00
|
|
|
|
/* Pin pad functions */
|
|
|
|
|
int (*display_message)(struct sc_reader *, struct sc_slot_info *,
|
|
|
|
|
const char *);
|
2003-06-23 12:56:36 +00:00
|
|
|
|
int (*perform_verify)(struct sc_reader *, struct sc_slot_info *,
|
2002-12-23 18:47:27 +00:00
|
|
|
|
struct sc_pin_cmd_data *);
|
2003-01-03 16:32:06 +00:00
|
|
|
|
|
|
|
|
|
/* Wait for an event */
|
2005-02-20 08:26:27 +00:00
|
|
|
|
int (*wait_for_event)(struct sc_reader **readers,
|
2003-01-03 16:32:06 +00:00
|
|
|
|
struct sc_slot_info **slots,
|
|
|
|
|
size_t nslots,
|
|
|
|
|
unsigned int event_mask,
|
|
|
|
|
int *reader_index,
|
|
|
|
|
unsigned int *event,
|
|
|
|
|
int timeout);
|
2002-02-24 19:32:14 +00:00
|
|
|
|
};
|
|
|
|
|
|
2003-01-14 11:22:33 +00:00
|
|
|
|
/* Mutexes - this is just a dummy struct used for type
|
|
|
|
|
* safety; internally we use objects defined by the
|
|
|
|
|
* underlying thread model
|
|
|
|
|
*/
|
|
|
|
|
typedef struct sc_mutex sc_mutex_t;
|
|
|
|
|
|
2003-10-14 21:56:56 +00:00
|
|
|
|
struct sc_mutex *sc_mutex_new(void);
|
|
|
|
|
void sc_mutex_lock(struct sc_mutex *p);
|
|
|
|
|
void sc_mutex_unlock(struct sc_mutex *p);
|
|
|
|
|
void sc_mutex_free(struct sc_mutex *p);
|
|
|
|
|
|
2002-03-01 11:52:55 +00:00
|
|
|
|
/*
|
|
|
|
|
* Card flags
|
2005-02-22 07:59:42 +00:00
|
|
|
|
*
|
|
|
|
|
* Used to hint about card specific capabilities and algorithms
|
|
|
|
|
* supported to the card driver. Used in sc_atr_table and
|
|
|
|
|
* card_atr block structures in the configuration file.
|
|
|
|
|
*
|
|
|
|
|
* Unknown, card vendor specific values may exists, but must
|
|
|
|
|
* not conflict with values defined here. All actions defined
|
|
|
|
|
* by the flags must be handled by the card driver themselves.
|
2002-03-01 11:52:55 +00:00
|
|
|
|
*/
|
2005-02-22 07:59:42 +00:00
|
|
|
|
|
2005-02-23 19:09:39 +00:00
|
|
|
|
/* Mask for card vendor specific values */
|
|
|
|
|
#define SC_CARD_FLAG_VENDOR_MASK 0xFFFF0000
|
|
|
|
|
|
2005-02-22 07:59:42 +00:00
|
|
|
|
/* Hint SC_ALGORITHM_ONBOARD_KEY_GEN */
|
|
|
|
|
#define SC_CARD_FLAG_ONBOARD_KEY_GEN 0x00000001
|
|
|
|
|
/* Hint SC_CARD_CAP_RNG */
|
|
|
|
|
#define SC_CARD_FLAG_RNG 0x00000002
|
2002-03-01 11:52:55 +00:00
|
|
|
|
|
|
|
|
|
/*
|
2005-02-20 08:26:27 +00:00
|
|
|
|
* Card capabilities
|
2002-03-01 11:52:55 +00:00
|
|
|
|
*/
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
|
|
|
|
/* Card can handle large (> 256 bytes) buffers in calls to
|
|
|
|
|
* read_binary, write_binary and update_binary; if not,
|
|
|
|
|
* several successive calls to the corresponding function
|
|
|
|
|
* is made. */
|
2002-03-01 11:52:55 +00:00
|
|
|
|
#define SC_CARD_CAP_APDU_EXT 0x00000001
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
|
|
|
|
/* Card can handle operations specified in the
|
2002-03-01 11:52:55 +00:00
|
|
|
|
* EMV 4.0 standard. */
|
|
|
|
|
#define SC_CARD_CAP_EMV 0x00000002
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
|
|
|
|
/* Card has on-board random number source. */
|
2003-01-15 13:20:02 +00:00
|
|
|
|
#define SC_CARD_CAP_RNG 0x00000004
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
|
|
|
|
/* Card doesn't return any File Control Info. */
|
2005-02-01 07:52:40 +00:00
|
|
|
|
#define SC_CARD_CAP_NO_FCI 0x00000008
|
2002-03-01 11:52:55 +00:00
|
|
|
|
|
2005-03-30 18:25:50 +00:00
|
|
|
|
/* Use the card's ACs in sc_pkcs15init_authenticate(),
|
|
|
|
|
* instead of relying on the ACL info in the profile files. */
|
|
|
|
|
#define SC_CARD_CAP_USE_FCI_AC 0x00000010
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_card {
|
2001-12-22 20:43:09 +00:00
|
|
|
|
struct sc_context *ctx;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
struct sc_reader *reader;
|
|
|
|
|
struct sc_slot_info *slot;
|
2001-12-22 20:43:09 +00:00
|
|
|
|
|
2005-02-06 19:40:40 +00:00
|
|
|
|
int type; /* Card type, for card driver internal use */
|
2002-01-07 18:23:34 +00:00
|
|
|
|
unsigned long caps, flags;
|
2005-01-30 19:20:38 +00:00
|
|
|
|
unsigned int wait_resend_apdu; /* Delay (msec) before responding to an SW12 = 6CXX */
|
2002-01-07 18:23:34 +00:00
|
|
|
|
int cla;
|
2001-12-22 20:43:09 +00:00
|
|
|
|
u8 atr[SC_MAX_ATR_SIZE];
|
|
|
|
|
size_t atr_len;
|
2003-12-18 16:35:28 +00:00
|
|
|
|
size_t max_send_size;
|
|
|
|
|
size_t max_recv_size;
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
|
|
|
|
struct sc_app_info *app[SC_MAX_CARD_APPS];
|
|
|
|
|
int app_count;
|
2002-02-26 11:23:25 +00:00
|
|
|
|
struct sc_file *ef_dir;
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2002-03-08 05:59:57 +00:00
|
|
|
|
struct sc_algorithm_info *algorithms;
|
|
|
|
|
int algorithm_count;
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2001-12-25 20:45:48 +00:00
|
|
|
|
int lock_count;
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2003-02-20 12:51:07 +00:00
|
|
|
|
struct sc_card_driver *driver;
|
2002-01-08 13:56:50 +00:00
|
|
|
|
struct sc_card_operations *ops;
|
2003-05-28 20:52:33 +00:00
|
|
|
|
const char *name;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
void *drv_data;
|
2003-02-20 23:19:01 +00:00
|
|
|
|
int max_pin_len;
|
2002-01-20 21:20:09 +00:00
|
|
|
|
|
|
|
|
|
struct sc_card_cache cache;
|
|
|
|
|
int cache_valid;
|
|
|
|
|
|
2004-07-19 16:51:41 +00:00
|
|
|
|
sc_serial_number_t serialnr;
|
|
|
|
|
|
2003-01-14 11:22:33 +00:00
|
|
|
|
sc_mutex_t *mutex;
|
|
|
|
|
|
2001-12-25 20:45:48 +00:00
|
|
|
|
unsigned int magic;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_card_t;
|
2001-12-20 13:57:58 +00:00
|
|
|
|
|
|
|
|
|
struct sc_card_operations {
|
2001-12-22 20:43:09 +00:00
|
|
|
|
/* Called in sc_connect_card(). Must return 1, if the current
|
|
|
|
|
* card can be handled with this driver, or 0 otherwise. ATR
|
|
|
|
|
* field of the sc_card struct is filled in before calling
|
|
|
|
|
* this function. */
|
|
|
|
|
int (*match_card)(struct sc_card *card);
|
|
|
|
|
|
|
|
|
|
/* Called when ATR of the inserted card matches an entry in ATR
|
|
|
|
|
* table. May return SC_ERROR_INVALID_CARD to indicate that
|
|
|
|
|
* the card cannot be handled with this driver. */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*init)(struct sc_card *card);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
/* Called when the card object is being freed. finish() has to
|
|
|
|
|
* deallocate all possible private data. */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*finish)(struct sc_card *card);
|
2002-02-21 18:53:23 +00:00
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
/* ISO 7816-4 functions */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
|
2001-12-21 23:34:47 +00:00
|
|
|
|
int (*read_binary)(struct sc_card *card, unsigned int idx,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
u8 * buf, size_t count, unsigned long flags);
|
2001-12-21 23:34:47 +00:00
|
|
|
|
int (*write_binary)(struct sc_card *card, unsigned int idx,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
const u8 * buf, size_t count, unsigned long flags);
|
2001-12-21 23:34:47 +00:00
|
|
|
|
int (*update_binary)(struct sc_card *card, unsigned int idx,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
const u8 * buf, size_t count, unsigned long flags);
|
2001-12-21 23:34:47 +00:00
|
|
|
|
int (*erase_binary)(struct sc_card *card, unsigned int idx,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2002-02-21 19:23:21 +00:00
|
|
|
|
|
2001-12-29 02:07:32 +00:00
|
|
|
|
int (*read_record)(struct sc_card *card, unsigned int rec_nr,
|
|
|
|
|
u8 * buf, size_t count, unsigned long flags);
|
2002-02-21 19:23:21 +00:00
|
|
|
|
int (*write_record)(struct sc_card *card, unsigned int rec_nr,
|
|
|
|
|
const u8 * buf, size_t count, unsigned long flags);
|
|
|
|
|
int (*append_record)(struct sc_card *card, const u8 * buf,
|
|
|
|
|
size_t count, unsigned long flags);
|
|
|
|
|
int (*update_record)(struct sc_card *card, unsigned int rec_nr,
|
|
|
|
|
const u8 * buf, size_t count, unsigned long flags);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
|
|
|
|
|
/* select_file: Does the equivalent of SELECT FILE command specified
|
|
|
|
|
* in ISO7816-4. Stores information about the selected file to
|
2002-01-01 17:25:10 +00:00
|
|
|
|
* <file>, if not NULL. */
|
2001-12-22 23:51:12 +00:00
|
|
|
|
int (*select_file)(struct sc_card *card, const struct sc_path *path,
|
2002-02-20 09:56:47 +00:00
|
|
|
|
struct sc_file **file_out);
|
2003-07-10 11:38:02 +00:00
|
|
|
|
int (*get_response)(struct sc_card *card, sc_apdu_t *orig_apdu, size_t count);
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*get_challenge)(struct sc_card *card, u8 * buf, size_t count);
|
|
|
|
|
|
2002-01-07 18:23:34 +00:00
|
|
|
|
/*
|
|
|
|
|
* ISO 7816-8 functions
|
|
|
|
|
*/
|
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/* verify: Verifies reference data of type <acl>, identified by
|
|
|
|
|
* <ref_qualifier>. If <tries_left> is not NULL, number of verifying
|
|
|
|
|
* tries left is saved in case of verification failure, if the
|
|
|
|
|
* information is available. */
|
|
|
|
|
int (*verify)(struct sc_card *card, unsigned int type,
|
|
|
|
|
int ref_qualifier, const u8 *data, size_t data_len,
|
|
|
|
|
int *tries_left);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
|
2003-05-20 08:30:46 +00:00
|
|
|
|
/* logout: Resets all access rights that were gained. */
|
|
|
|
|
int (*logout)(struct sc_card *card);
|
|
|
|
|
|
2001-12-22 20:43:09 +00:00
|
|
|
|
/* restore_security_env: Restores a previously saved security
|
|
|
|
|
* environment, and stores information about the environment to
|
|
|
|
|
* <env_out>, if not NULL. */
|
2002-01-16 23:59:18 +00:00
|
|
|
|
int (*restore_security_env)(struct sc_card *card, int se_num);
|
2001-12-22 20:43:09 +00:00
|
|
|
|
|
|
|
|
|
/* set_security_env: Initializes the security environment on card
|
|
|
|
|
* according to <env>, and stores the environment as <se_num> on the
|
|
|
|
|
* card. If se_num <= 0, the environment will not be stored. */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*set_security_env)(struct sc_card *card,
|
2001-12-22 20:43:09 +00:00
|
|
|
|
const struct sc_security_env *env, int se_num);
|
2002-01-07 18:23:34 +00:00
|
|
|
|
/* decipher: Engages the deciphering operation. Card will use the
|
|
|
|
|
* security environment set in a call to set_security_env or
|
|
|
|
|
* restore_security_env. */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*decipher)(struct sc_card *card, const u8 * crgram,
|
|
|
|
|
size_t crgram_len, u8 * out, size_t outlen);
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2002-01-07 18:23:34 +00:00
|
|
|
|
/* compute_signature: Generates a digital signature on the card. Similiar
|
2002-01-09 01:03:10 +00:00
|
|
|
|
* to the function decipher. */
|
2001-12-20 13:57:58 +00:00
|
|
|
|
int (*compute_signature)(struct sc_card *card, const u8 * data,
|
|
|
|
|
size_t data_len, u8 * out, size_t outlen);
|
2002-02-10 18:04:03 +00:00
|
|
|
|
int (*change_reference_data)(struct sc_card *card, unsigned int type,
|
|
|
|
|
int ref_qualifier,
|
2001-12-20 13:57:58 +00:00
|
|
|
|
const u8 *old, size_t oldlen,
|
|
|
|
|
const u8 *newref, size_t newlen,
|
|
|
|
|
int *tries_left);
|
2002-02-10 18:04:03 +00:00
|
|
|
|
int (*reset_retry_counter)(struct sc_card *card, unsigned int type,
|
|
|
|
|
int ref_qualifier,
|
2001-12-20 13:57:58 +00:00
|
|
|
|
const u8 *puk, size_t puklen,
|
|
|
|
|
const u8 *newref, size_t newlen);
|
2002-01-08 13:56:50 +00:00
|
|
|
|
/*
|
|
|
|
|
* ISO 7816-9 functions
|
|
|
|
|
*/
|
2002-01-17 11:44:27 +00:00
|
|
|
|
int (*create_file)(struct sc_card *card, struct sc_file *file);
|
2002-01-08 13:56:50 +00:00
|
|
|
|
int (*delete_file)(struct sc_card *card, const struct sc_path *path);
|
2002-01-09 01:03:10 +00:00
|
|
|
|
/* list_files: Enumerates all the files in the current DF, and
|
|
|
|
|
* writes the corresponding file identifiers to <buf>. Returns
|
|
|
|
|
* the number of bytes stored. */
|
|
|
|
|
int (*list_files)(struct sc_card *card, u8 *buf, size_t buflen);
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2002-02-15 23:17:58 +00:00
|
|
|
|
int (*check_sw)(struct sc_card *card, int sw1, int sw2);
|
2002-02-21 18:53:23 +00:00
|
|
|
|
int (*card_ctl)(struct sc_card *card, unsigned long request,
|
|
|
|
|
void *data);
|
2003-07-14 17:39:19 +00:00
|
|
|
|
int (*process_fci)(struct sc_card *card, struct sc_file *file,
|
|
|
|
|
const u8 *buf, size_t buflen);
|
2003-07-28 13:19:49 +00:00
|
|
|
|
int (*construct_fci)(struct sc_card *card, const struct sc_file *file,
|
|
|
|
|
u8 *out, size_t *outlen);
|
2002-12-23 18:47:27 +00:00
|
|
|
|
|
|
|
|
|
/* pin_cmd: verify/change/unblock command; optionally using the
|
|
|
|
|
* card's pin pad if supported.
|
|
|
|
|
*/
|
|
|
|
|
int (*pin_cmd)(struct sc_card *, struct sc_pin_cmd_data *,
|
|
|
|
|
int *tries_left);
|
2003-10-30 17:04:02 +00:00
|
|
|
|
|
|
|
|
|
int (*get_data)(sc_card_t *, unsigned int, u8 *, size_t);
|
|
|
|
|
int (*put_data)(sc_card_t *, unsigned int, const u8 *, size_t);
|
2004-01-06 13:33:32 +00:00
|
|
|
|
|
|
|
|
|
int (*delete_record)(sc_card_t *card, unsigned int rec_nr);
|
2001-12-20 13:57:58 +00:00
|
|
|
|
};
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_card_driver {
|
2002-01-08 13:56:50 +00:00
|
|
|
|
const char *name;
|
|
|
|
|
const char *short_name;
|
2001-12-20 13:57:58 +00:00
|
|
|
|
struct sc_card_operations *ops;
|
2002-12-03 15:40:40 +00:00
|
|
|
|
struct sc_atr_table *atr_map;
|
|
|
|
|
unsigned int natrs;
|
2004-10-18 08:24:12 +00:00
|
|
|
|
void *dll;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_card_driver_t;
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
typedef struct sc_context {
|
2002-03-24 14:12:38 +00:00
|
|
|
|
scconf_context *conf;
|
2002-03-26 11:38:40 +00:00
|
|
|
|
scconf_block *conf_blocks[3];
|
2002-03-24 14:12:38 +00:00
|
|
|
|
char *app_name;
|
2001-12-19 21:58:04 +00:00
|
|
|
|
int debug;
|
|
|
|
|
|
2003-10-14 09:56:50 +00:00
|
|
|
|
int suppress_errors;
|
2002-01-24 16:02:54 +00:00
|
|
|
|
FILE *debug_file, *error_file;
|
2003-10-22 06:49:59 +00:00
|
|
|
|
char *preferred_language;
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
2005-02-20 08:26:27 +00:00
|
|
|
|
const struct sc_reader_driver *reader_drivers[SC_MAX_READER_DRIVERS];
|
2002-02-24 19:32:14 +00:00
|
|
|
|
void *reader_drv_data[SC_MAX_READER_DRIVERS];
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
2002-02-24 19:32:14 +00:00
|
|
|
|
struct sc_reader *reader[SC_MAX_READERS];
|
|
|
|
|
int reader_count;
|
2005-02-20 08:26:27 +00:00
|
|
|
|
|
|
|
|
|
struct sc_card_driver *card_drivers[SC_MAX_CARD_DRIVERS];
|
2002-12-19 16:16:42 +00:00
|
|
|
|
struct sc_card_driver *forced_driver;
|
2002-03-24 14:12:38 +00:00
|
|
|
|
|
2003-01-14 11:22:33 +00:00
|
|
|
|
sc_mutex_t *mutex;
|
|
|
|
|
|
2002-03-24 14:12:38 +00:00
|
|
|
|
unsigned int magic;
|
2005-03-08 20:59:35 +00:00
|
|
|
|
} sc_context_t;
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2001-11-05 19:39:18 +00:00
|
|
|
|
/* Base64 encoding/decoding functions */
|
2001-12-22 13:38:25 +00:00
|
|
|
|
int sc_base64_encode(const u8 *in, size_t inlen, u8 *out, size_t outlen,
|
|
|
|
|
size_t linelength);
|
|
|
|
|
int sc_base64_decode(const char *in, u8 *out, size_t outlen);
|
2001-11-04 13:57:04 +00:00
|
|
|
|
|
2003-04-02 06:58:20 +00:00
|
|
|
|
/* Returns the current time in milliseconds */
|
2003-08-18 14:54:37 +00:00
|
|
|
|
sc_timestamp_t sc_current_time(void);
|
2003-04-02 06:58:20 +00:00
|
|
|
|
|
2001-11-05 19:39:18 +00:00
|
|
|
|
/* APDU handling functions */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_transmit_apdu(sc_card_t *card, sc_apdu_t *apdu);
|
|
|
|
|
void sc_format_apdu(sc_card_t *card, sc_apdu_t *apdu, int cse, int ins,
|
2001-12-22 13:38:25 +00:00
|
|
|
|
int p1, int p2);
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Establishes an OpenSC context
|
|
|
|
|
* @param ctx A pointer to a pointer that will receive the allocated context
|
2002-03-24 14:12:38 +00:00
|
|
|
|
* @param app_name A string that identifies the application, used primarily
|
|
|
|
|
* in finding application-specific configuration data. Can be NULL.
|
2002-01-10 23:02:48 +00:00
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_establish_context(sc_context_t **ctx, const char *app_name);
|
2002-03-24 14:12:38 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
2002-03-24 14:12:38 +00:00
|
|
|
|
* Releases an established OpenSC context
|
|
|
|
|
* @param ctx A pointer to the context structure to be released
|
2002-01-10 23:02:48 +00:00
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_release_context(sc_context_t *ctx);
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Forces the use of a specified card driver
|
|
|
|
|
* @param ctx OpenSC context
|
|
|
|
|
* @param short_name The short name of the driver to use (e.g. 'emv')
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_set_card_driver(sc_context_t *ctx, const char *short_name);
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Connects to a card in a reader and auto-detects the card driver.
|
|
|
|
|
* The ATR (Answer to Reset) string of the card is also retrieved.
|
2002-02-24 19:32:14 +00:00
|
|
|
|
* @param reader Reader structure
|
|
|
|
|
* @param slot_id Slot ID to connect to
|
2002-01-10 23:02:48 +00:00
|
|
|
|
* @param card The allocated card object will go here */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_connect_card(sc_reader_t *reader, int slot_id,
|
|
|
|
|
sc_card_t **card);
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Disconnects from a card, and frees the card structure. Any locks
|
|
|
|
|
* made by the application must be released before calling this function.
|
|
|
|
|
* NOTE: The card is not reset nor powered down after the operation.
|
|
|
|
|
* @param card The card to disconnect
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_disconnect_card(sc_card_t *card, int action);
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Returns 1 if the magic value of the card object is correct. Mostly
|
|
|
|
|
* used internally by the library.
|
|
|
|
|
* @param card The card object to check
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
inline int sc_card_valid(const sc_card_t *card);
|
2001-11-17 15:48:10 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Checks if a card is present in a reader
|
2002-02-24 19:32:14 +00:00
|
|
|
|
* @param reader Reader structure
|
2003-01-19 17:47:07 +00:00
|
|
|
|
* @param slot_id Slot ID
|
|
|
|
|
* @retval If an error occured, the return value is a (negative)
|
|
|
|
|
* OpenSC error code. If no card is present, 0 is returned.
|
|
|
|
|
* Otherwise, a positive value is returned, which is a
|
|
|
|
|
* combination of flags. The flag SC_SLOT_CARD_PRESENT is
|
|
|
|
|
* always set. In addition, if the card was exchanged,
|
|
|
|
|
* the SC_SLOT_CARD_CHANGED flag is set.
|
2002-01-10 23:02:48 +00:00
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_detect_card_presence(sc_reader_t *reader, int slot_id);
|
2001-11-17 15:48:10 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
2003-01-03 16:32:06 +00:00
|
|
|
|
* Waits for an event on readers. Note: only the event is detected,
|
|
|
|
|
* there is no update of any card or other info.
|
|
|
|
|
* @param readers array of pointer to a Reader structure
|
|
|
|
|
* @param reader_count amount of readers in the array
|
2002-02-26 11:23:25 +00:00
|
|
|
|
* @param slot_id Slot ID
|
2003-01-05 17:59:43 +00:00
|
|
|
|
* @param event_mask The types of events to wait for; this should
|
|
|
|
|
* be ORed from one of the following
|
|
|
|
|
* SC_EVENT_CARD_REMOVED
|
|
|
|
|
* SC_EVENT_CARD_INSERTED
|
2003-01-03 16:32:06 +00:00
|
|
|
|
* @param reader (OUT) the reader on which the event was detected
|
2003-01-05 17:59:43 +00:00
|
|
|
|
* @param event (OUT) the events that occurred. This is also ORed
|
|
|
|
|
* from the SC_EVENT_CARD_* constants listed above.
|
2002-01-10 23:02:48 +00:00
|
|
|
|
* @param timeout Amount of millisecs to wait; -1 means forever
|
|
|
|
|
* @retval < 0 if an error occured
|
2003-01-03 16:32:06 +00:00
|
|
|
|
* @retval = 0 if a an event happened
|
|
|
|
|
* @retval = 1 if the timeout occured
|
2002-01-10 23:02:48 +00:00
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_wait_for_event(sc_reader_t **readers, int *slots, size_t nslots,
|
2003-01-03 16:32:06 +00:00
|
|
|
|
unsigned int event_mask,
|
|
|
|
|
int *reader, unsigned int *event, int timeout);
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Locks the card against modification from other threads.
|
|
|
|
|
* After the initial call to sc_lock, the card is protected from
|
|
|
|
|
* access from other processes. The function may be called several times.
|
|
|
|
|
* @param card The card to lock
|
|
|
|
|
* @retval SC_SUCCESS on success
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_lock(sc_card_t *card);
|
2005-02-20 08:26:27 +00:00
|
|
|
|
/**
|
2002-01-10 23:02:48 +00:00
|
|
|
|
* Unlocks a previously locked card. After the lock count drops to zero,
|
|
|
|
|
* the card is again placed in shared mode, where other processes
|
|
|
|
|
* may access or lock it.
|
|
|
|
|
* @param card The card to unlock
|
|
|
|
|
* @retval SC_SUCCESS on success
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_unlock(sc_card_t *card);
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2001-11-04 14:08:38 +00:00
|
|
|
|
/* ISO 7816-4 related functions */
|
2002-01-01 17:25:10 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/**
|
|
|
|
|
* Does the equivalent of ISO 7816-4 command SELECT FILE.
|
|
|
|
|
* @param card The card on which to issue the command
|
|
|
|
|
* @param path The path, file id or name of the desired file
|
2002-02-20 09:56:47 +00:00
|
|
|
|
* @param file If not NULL, will receive a pointer to a new structure
|
2002-01-10 23:02:48 +00:00
|
|
|
|
* @retval SC_SUCCESS on success
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_select_file(sc_card_t *card, const sc_path_t *path,
|
|
|
|
|
sc_file_t **file);
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_list_files(sc_card_t *card, u8 * buf, size_t buflen);
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2002-01-10 23:02:48 +00:00
|
|
|
|
/* TODO: finish writing API docs */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_read_binary(sc_card_t *card, unsigned int idx, u8 * buf,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_write_binary(sc_card_t *card, unsigned int idx, const u8 * buf,
|
2002-01-08 13:56:50 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_update_binary(sc_card_t *card, unsigned int idx, const u8 * buf,
|
2002-01-13 23:56:13 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2002-02-11 15:55:34 +00:00
|
|
|
|
/**
|
|
|
|
|
* Reads a record from the current (i.e. selected) file.
|
|
|
|
|
* @param card The card on which to issue the command
|
2002-02-20 09:56:47 +00:00
|
|
|
|
* @param rec_nr SC_READ_RECORD_CURRENT or a record number starting from 1
|
2002-02-11 15:55:34 +00:00
|
|
|
|
* @param buf Pointer to a buffer for storing the data
|
|
|
|
|
* @param count Number of bytes to read
|
|
|
|
|
* @param flags Flags
|
|
|
|
|
* @retval Number of bytes read or an error value
|
|
|
|
|
*/
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_read_record(sc_card_t *card, unsigned int rec_nr, u8 * buf,
|
2001-12-29 02:07:32 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_write_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf,
|
2002-02-21 19:23:21 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_append_record(sc_card_t *card, const u8 * buf, size_t count,
|
2002-02-21 19:23:21 +00:00
|
|
|
|
unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_update_record(sc_card_t *card, unsigned int rec_nr, const u8 * buf,
|
2002-02-21 19:23:21 +00:00
|
|
|
|
size_t count, unsigned long flags);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_delete_record(sc_card_t *card, unsigned int rec_nr);
|
2002-02-21 19:23:21 +00:00
|
|
|
|
|
2003-10-30 17:04:02 +00:00
|
|
|
|
/* get/put data functions */
|
|
|
|
|
int sc_get_data(sc_card_t *, unsigned int, u8 *, size_t);
|
|
|
|
|
int sc_put_data(sc_card_t *, unsigned int, const u8 *, size_t);
|
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_get_challenge(sc_card_t *card, u8 * rndout, size_t len);
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2001-11-06 18:34:19 +00:00
|
|
|
|
/* ISO 7816-8 related functions */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_restore_security_env(sc_card_t *card, int se_num);
|
|
|
|
|
int sc_set_security_env(sc_card_t *card,
|
2002-01-16 23:59:18 +00:00
|
|
|
|
const struct sc_security_env *env, int se_num);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_decipher(sc_card_t *card, const u8 * crgram, size_t crgram_len,
|
2001-12-22 13:38:25 +00:00
|
|
|
|
u8 * out, size_t outlen);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_compute_signature(sc_card_t *card, const u8 * data,
|
2001-12-22 13:38:25 +00:00
|
|
|
|
size_t data_len, u8 * out, size_t outlen);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_verify(sc_card_t *card, unsigned int type, int ref, const u8 *buf,
|
2002-01-10 23:02:48 +00:00
|
|
|
|
size_t buflen, int *tries_left);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_logout(sc_card_t *card);
|
|
|
|
|
int sc_pin_cmd(sc_card_t *card, struct sc_pin_cmd_data *, int *tries_left);
|
|
|
|
|
int sc_change_reference_data(sc_card_t *card, unsigned int type,
|
2002-02-10 18:04:03 +00:00
|
|
|
|
int ref, const u8 *old, size_t oldlen,
|
|
|
|
|
const u8 *newref, size_t newlen,
|
2001-12-02 19:21:46 +00:00
|
|
|
|
int *tries_left);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_reset_retry_counter(sc_card_t *card, unsigned int type,
|
2002-02-10 18:04:03 +00:00
|
|
|
|
int ref, const u8 *puk, size_t puklen,
|
|
|
|
|
const u8 *newref, size_t newlen);
|
2002-12-23 18:47:27 +00:00
|
|
|
|
int sc_build_pin(u8 *buf, size_t buflen, struct sc_pin_cmd_pin *pin, int pad);
|
2003-07-15 10:49:28 +00:00
|
|
|
|
/* pkcs1 padding/encoding functions */
|
|
|
|
|
int sc_pkcs1_add_01_padding(const u8 *in, size_t in_len, u8 *out,
|
|
|
|
|
size_t *out_len, size_t mod_length);
|
|
|
|
|
int sc_pkcs1_strip_01_padding(const u8 *in_dat, size_t in_len, u8 *out_dat,
|
|
|
|
|
size_t *out_len);
|
|
|
|
|
int sc_pkcs1_strip_02_padding(const u8 *data, size_t len, u8 *out_dat,
|
|
|
|
|
size_t *out_len);
|
|
|
|
|
int sc_pkcs1_add_digest_info_prefix(unsigned int algorithm, const u8 *in_dat,
|
|
|
|
|
size_t in_len, u8 *out_dat, size_t *out_len);
|
|
|
|
|
int sc_pkcs1_strip_digest_info_prefix(unsigned int *algorithm,
|
|
|
|
|
const u8 *in_dat, size_t in_len, u8 *out_dat, size_t *out_len);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_pkcs1_encode(sc_context_t *ctx, unsigned long flags,
|
2003-07-15 10:49:28 +00:00
|
|
|
|
const u8 *in, size_t in_len, u8 *out, size_t *out_len, size_t mod_len);
|
|
|
|
|
int sc_strip_zero_padding(const u8 *in,size_t in_len, u8 *out, size_t *out_len);
|
2001-11-17 00:11:29 +00:00
|
|
|
|
/* ISO 7816-9 */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_create_file(sc_card_t *card, sc_file_t *file);
|
|
|
|
|
int sc_delete_file(sc_card_t *card, const sc_path_t *path);
|
2001-11-17 00:11:29 +00:00
|
|
|
|
|
2002-02-21 18:53:23 +00:00
|
|
|
|
/* Card controls */
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_card_ctl(sc_card_t *card, unsigned long command, void *arg);
|
2002-02-21 18:53:23 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
inline int sc_file_valid(const sc_file_t *file);
|
|
|
|
|
sc_file_t * sc_file_new(void);
|
|
|
|
|
void sc_file_free(sc_file_t *file);
|
|
|
|
|
void sc_file_dup(sc_file_t **dest, const sc_file_t *src);
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_file_add_acl_entry(sc_file_t *file, unsigned int operation,
|
2002-02-20 09:56:47 +00:00
|
|
|
|
unsigned int method, unsigned long key_ref);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
const struct sc_acl_entry * sc_file_get_acl_entry(const sc_file_t *file,
|
2002-02-20 09:56:47 +00:00
|
|
|
|
unsigned int operation);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
void sc_file_clear_acl_entries(sc_file_t *file, unsigned int operation);
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_file_set_sec_attr(sc_file_t *file, const u8 *sec_attr,
|
2002-03-28 14:13:36 +00:00
|
|
|
|
size_t sec_attr_len);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_file_set_prop_attr(sc_file_t *file, const u8 *prop_attr,
|
2002-03-28 14:13:36 +00:00
|
|
|
|
size_t prop_attr_len);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_file_set_type_attr(sc_file_t *file, const u8 *type_attr,
|
2002-04-17 13:36:35 +00:00
|
|
|
|
size_t type_attr_len);
|
2002-03-28 14:13:36 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
void sc_format_path(const char *path_in, sc_path_t *path_out);
|
2003-08-29 12:55:30 +00:00
|
|
|
|
const char *sc_print_path(const sc_path_t *path_in);
|
2003-10-13 14:34:18 +00:00
|
|
|
|
int sc_compare_path(const sc_path_t *, const sc_path_t *);
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_append_path(sc_path_t *dest, const sc_path_t *src);
|
|
|
|
|
int sc_append_path_id(sc_path_t *dest, const u8 *id, size_t idlen);
|
|
|
|
|
int sc_append_file_id(sc_path_t *dest, unsigned int fid);
|
2001-12-29 02:07:32 +00:00
|
|
|
|
int sc_hex_to_bin(const char *in, u8 *out, size_t *outlen);
|
2005-08-03 18:43:40 +00:00
|
|
|
|
int sc_bin_to_hex(const u8 *, size_t, char *, size_t, int separator);
|
2005-08-03 09:00:00 +00:00
|
|
|
|
int sc_compare_oid(const struct sc_object_id *oid1, const struct sc_object_id *oid2);
|
2002-12-10 13:26:31 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_get_cache_dir(sc_context_t *ctx, char *buf, size_t bufsize);
|
|
|
|
|
int sc_make_cache_dir(sc_context_t *ctx);
|
2001-12-29 02:07:32 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
int sc_enum_apps(sc_card_t *card);
|
|
|
|
|
void sc_free_apps(sc_card_t *card);
|
|
|
|
|
const sc_app_info_t * sc_find_pkcs15_app(sc_card_t *card);
|
|
|
|
|
const sc_app_info_t * sc_find_app_by_aid(sc_card_t *card,
|
|
|
|
|
const u8 *aid, size_t aid_len);
|
|
|
|
|
int sc_update_dir(sc_card_t *card, sc_app_info_t *app);
|
2002-02-20 09:56:47 +00:00
|
|
|
|
|
|
|
|
|
struct sc_card_error {
|
|
|
|
|
int SWs;
|
|
|
|
|
int errorno;
|
|
|
|
|
const char *errorstr;
|
|
|
|
|
};
|
2001-11-01 15:43:20 +00:00
|
|
|
|
|
2002-06-14 12:52:56 +00:00
|
|
|
|
extern const char *sc_get_version(void);
|
2001-11-04 14:08:38 +00:00
|
|
|
|
|
2004-10-18 08:24:12 +00:00
|
|
|
|
#define SC_IMPLEMENT_DRIVER_VERSION(a) \
|
2004-10-08 21:29:55 +00:00
|
|
|
|
static const char *drv_version = (a); \
|
|
|
|
|
const char *sc_driver_version()\
|
|
|
|
|
{ \
|
|
|
|
|
return drv_version; \
|
|
|
|
|
}
|
|
|
|
|
|
2003-12-18 16:35:28 +00:00
|
|
|
|
extern struct sc_reader_driver *sc_get_pcsc_driver(void);
|
|
|
|
|
extern struct sc_reader_driver *sc_get_ctapi_driver(void);
|
|
|
|
|
extern struct sc_reader_driver *sc_get_openct_driver(void);
|
2002-02-24 19:32:14 +00:00
|
|
|
|
|
2005-03-08 20:59:35 +00:00
|
|
|
|
extern sc_card_driver_t *sc_get_default_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_emv_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_etoken_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_cryptoflex_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_cyberflex_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_gpk_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_iso7816_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_miocos_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_mcrd_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_setcos_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_starcos_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_tcos_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_openpgp_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_jcop_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_oberthur_driver(void);
|
|
|
|
|
extern sc_card_driver_t *sc_get_belpic_driver(void);
|
2005-07-01 08:26:55 +00:00
|
|
|
|
extern sc_card_driver_t *sc_get_atrust_acos_driver(void);
|
2001-11-17 14:55:41 +00:00
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
|
#ifdef __cplusplus
|
2001-12-08 15:27:40 +00:00
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-11-01 15:43:20 +00:00
|
|
|
|
#endif
|