New upstream version 1.0.5

This commit is contained in:
geos_one
2025-08-08 20:34:09 +02:00
commit 5e5aafa7b7
371 changed files with 402888 additions and 0 deletions

118
opensc/errors.h Normal file
View File

@@ -0,0 +1,118 @@
/*
* errors.h: OpenSC error codes
*
* Copyright (C) 2001, 2002 Juha Yrjölä <juha.yrjola@iki.fi>
*
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#ifndef _OPENSC_ERRORS_H
#define _OPENSC_ERRORS_H
#ifdef __cplusplus
extern "C" {
#endif
#define SC_SUCCESS 0
#define SC_NO_ERROR 0
/* Errors related to reader operation */
#define SC_ERROR_READER -1100
#define SC_ERROR_NO_READERS_FOUND -1101
#define SC_ERROR_SLOT_NOT_FOUND -1102
#define SC_ERROR_SLOT_ALREADY_CONNECTED -1103
#define SC_ERROR_CARD_NOT_PRESENT -1104
#define SC_ERROR_CARD_REMOVED -1105
#define SC_ERROR_CARD_RESET -1106
#define SC_ERROR_TRANSMIT_FAILED -1107
#define SC_ERROR_KEYPAD_TIMEOUT -1108
#define SC_ERROR_KEYPAD_CANCELLED -1109
#define SC_ERROR_KEYPAD_PIN_MISMATCH -1110
#define SC_ERROR_KEYPAD_MSG_TOO_LONG -1111
#define SC_ERROR_EVENT_TIMEOUT -1112
#define SC_ERROR_CARD_UNRESPONSIVE -1113
#define SC_ERROR_READER_DETACHED -1114
#define SC_ERROR_READER_REATTACHED -1115
/* Resulting from a card command or related to the card*/
#define SC_ERROR_CARD_CMD_FAILED -1200
#define SC_ERROR_FILE_NOT_FOUND -1201
#define SC_ERROR_RECORD_NOT_FOUND -1202
#define SC_ERROR_CLASS_NOT_SUPPORTED -1203
#define SC_ERROR_INS_NOT_SUPPORTED -1204
#define SC_ERROR_INCORRECT_PARAMETERS -1205
#define SC_ERROR_WRONG_LENGTH -1206
#define SC_ERROR_MEMORY_FAILURE -1207
#define SC_ERROR_NO_CARD_SUPPORT -1208
#define SC_ERROR_NOT_ALLOWED -1209
#define SC_ERROR_INVALID_CARD -1210
#define SC_ERROR_SECURITY_STATUS_NOT_SATISFIED -1211
#define SC_ERROR_AUTH_METHOD_BLOCKED -1212
#define SC_ERROR_UNKNOWN_DATA_RECEIVED -1213
#define SC_ERROR_PIN_CODE_INCORRECT -1214
#define SC_ERROR_FILE_ALREADY_EXISTS -1215
#define SC_ERROR_DATA_OBJECT_NOT_FOUND -1216
/* Returned by OpenSC library when called with invalid arguments */
#define SC_ERROR_INVALID_ARGUMENTS -1300
#define SC_ERROR_CMD_TOO_SHORT -1301
#define SC_ERROR_CMD_TOO_LONG -1302
#define SC_ERROR_BUFFER_TOO_SMALL -1303
#define SC_ERROR_INVALID_PIN_LENGTH -1304
#define SC_ERROR_INVALID_DATA -1305
/* Resulting from OpenSC internal operation */
#define SC_ERROR_INTERNAL -1400
#define SC_ERROR_INVALID_ASN1_OBJECT -1401
#define SC_ERROR_ASN1_OBJECT_NOT_FOUND -1402
#define SC_ERROR_ASN1_END_OF_CONTENTS -1403
#define SC_ERROR_OUT_OF_MEMORY -1404
#define SC_ERROR_TOO_MANY_OBJECTS -1405
#define SC_ERROR_OBJECT_NOT_VALID -1406
#define SC_ERROR_OBJECT_NOT_FOUND -1407
#define SC_ERROR_NOT_SUPPORTED -1408
#define SC_ERROR_PASSPHRASE_REQUIRED -1409
#define SC_ERROR_EXTRACTABLE_KEY -1410
#define SC_ERROR_DECRYPT_FAILED -1411
#define SC_ERROR_WRONG_PADDING -1412
#define SC_ERROR_WRONG_CARD -1413
#define SC_ERROR_CANNOT_LOAD_MODULE -1414
#define SC_ERROR_OFFSET_TOO_LARGE -1415
#define SC_ERROR_NOT_IMPLEMENTED -1416
/* Relating to PKCS #15 init stuff */
#define SC_ERROR_PKCS15INIT -1500
#define SC_ERROR_SYNTAX_ERROR -1501
#define SC_ERROR_INCONSISTENT_PROFILE -1502
#define SC_ERROR_INCOMPATIBLE_KEY -1503
#define SC_ERROR_NO_DEFAULT_KEY -1504
#define SC_ERROR_ID_NOT_UNIQUE -1505
#define SC_ERROR_CANNOT_LOAD_KEY -1006
#define SC_ERROR_INCOMPATIBLE_OBJECT -1007
#define SC_ERROR_TEMPLATE_NOT_FOUND -1008
#define SC_ERROR_INVALID_PIN_REFERENCE -1009
#define SC_ERROR_FILE_TOO_SMALL -1010
/* Errors that do not fit the categories above */
#define SC_ERROR_UNKNOWN -1900
#define SC_ERROR_PKCS15_APP_NOT_FOUND -1901
const char *sc_strerror(int sc_errno);
#ifdef __cplusplus
}
#endif
#endif

103
opensc/opensc-config.in Normal file
View File

@@ -0,0 +1,103 @@
#!/bin/sh
# Copyright (C) 1999 Free Software Foundation, Inc.
#
# This file is free software; as a special exception the author gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# This file is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
version="0.11.13"
prefix="/usr"
exec_prefix="/usr"
exec_prefix_set=no
libdir=""
includedir="@abs_top_srcdir@"
opensc_cflags=""
opensc_libs=""
usage()
{
cat <<EOF
Usage: opensc-config [OPTIONS]
Options:
[--prefix[=DIR]]
[--exec-prefix[=DIR]]
[--version]
[--libs]
[--cflags]
EOF
exit $1
}
if test $# -eq 0; then
usage 1 1>&2
fi
while test $# -gt 0; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case $1 in
--prefix=*)
prefix=$optarg
if test $exec_prefix_set = no ; then
exec_prefix=$optarg
fi
;;
--prefix)
echo_prefix=yes
;;
--exec-prefix=*)
exec_prefix=$optarg
exec_prefix_set=yes
;;
--exec-prefix)
echo_exec_prefix=yes
;;
--version)
echo "${version}"
exit 0
;;
--cflags)
echo_cflags=yes
;;
--libs)
echo_libs=yes
;;
*)
usage 1 1>&2
;;
esac
shift
done
if test "$echo_prefix" = "yes"; then
echo $prefix
fi
if test "$echo_exec_prefix" = "yes"; then
echo $exec_prefix
fi
if test "$echo_cflags" = "yes"; then
if test "${includedir}" != "/usr/include" ; then
includes="-I${includedir}"
for i in ${opensc_cflags} ; do
if test "$i" = "-I${includedir}" ; then
includes=""
fi
done
fi
echo $includes $opensc_cflags
fi
if test "$echo_libs" = "yes"; then
echo ${opensc_libs}
fi

1182
opensc/opensc.h Normal file

File diff suppressed because it is too large Load Diff

735
opensc/pkcs15.h Normal file
View File

@@ -0,0 +1,735 @@
/*
* pkcs15.h: OpenSC PKCS#15 header file
*
* Copyright (C) 2001, 2002 Juha Yrjölä <juha.yrjola@iki.fi>
*
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#ifndef _OPENSC_PKCS15_H
#define _OPENSC_PKCS15_H
#ifdef __cplusplus
extern "C" {
#endif
#include <opensc/opensc.h>
#define SC_PKCS15_CACHE_DIR ".eid"
#define SC_PKCS15_PIN_MAGIC 0x31415926
#define SC_PKCS15_MAX_PINS 8
#define SC_PKCS15_MAX_LABEL_SIZE 255
#define SC_PKCS15_MAX_ID_SIZE 255
struct sc_pkcs15_id {
u8 value[SC_PKCS15_MAX_ID_SIZE];
size_t len;
};
typedef struct sc_pkcs15_id sc_pkcs15_id_t;
#define SC_PKCS15_CO_FLAG_PRIVATE 0x00000001
#define SC_PKCS15_CO_FLAG_MODIFIABLE 0x00000002
#define SC_PKCS15_CO_FLAG_OBJECT_SEEN 0x80000000 /* for PKCS #11 module */
#define SC_PKCS15_PIN_FLAG_CASE_SENSITIVE 0x0001
#define SC_PKCS15_PIN_FLAG_LOCAL 0x0002
#define SC_PKCS15_PIN_FLAG_CHANGE_DISABLED 0x0004
#define SC_PKCS15_PIN_FLAG_UNBLOCK_DISABLED 0x0008
#define SC_PKCS15_PIN_FLAG_INITIALIZED 0x0010
#define SC_PKCS15_PIN_FLAG_NEEDS_PADDING 0x0020
#define SC_PKCS15_PIN_FLAG_UNBLOCKING_PIN 0x0040
#define SC_PKCS15_PIN_FLAG_SO_PIN 0x0080
#define SC_PKCS15_PIN_FLAG_DISABLE_ALLOW 0x0100
#define SC_PKCS15_PIN_FLAG_INTEGRITY_PROTECTED 0x0200
#define SC_PKCS15_PIN_FLAG_CONFIDENTIALITY_PROTECTED 0x0400
#define SC_PKCS15_PIN_FLAG_EXCHANGE_REF_DATA 0x0800
#define SC_PKCS15_PIN_TYPE_BCD 0
#define SC_PKCS15_PIN_TYPE_ASCII_NUMERIC 1
#define SC_PKCS15_PIN_TYPE_UTF8 2
#define SC_PKCS15_PIN_TYPE_HALFNIBBLE_BCD 3
#define SC_PKCS15_PIN_TYPE_ISO9564_1 4
struct sc_pkcs15_pin_info {
struct sc_pkcs15_id auth_id;
int reference;
unsigned int flags, type;
size_t min_length, stored_length, max_length;
u8 pad_char;
struct sc_path path;
int tries_left;
unsigned int magic;
};
typedef struct sc_pkcs15_pin_info sc_pkcs15_pin_info_t;
#define SC_PKCS15_ALGO_OP_COMPUTE_CHECKSUM 0x01
#define SC_PKCS15_ALGO_OP_COMPUTE_SIGNATURE 0x02
#define SC_PKCS15_ALGO_OP_VERIFY_CHECKSUM 0x04
#define SC_PKCS15_ALGO_OP_VERIFY_SIGNATURE 0x08
#define SC_PKCS15_ALGO_OP_ENCIPHER 0x10
#define SC_PKCS15_ALGO_OP_DECIPHER 0x20
#define SC_PKCS15_ALGO_OP_HASH 0x40
#define SC_PKCS15_ALGO_OP_GENERATE_KEY 0x80
struct sc_pkcs15_algorithm_info {
int reference;
int algorithm, supported_operations;
};
/* A large integer, big endian notation */
struct sc_pkcs15_bignum {
u8 * data;
size_t len;
};
typedef struct sc_pkcs15_bignum sc_pkcs15_bignum_t;
struct sc_pkcs15_der {
u8 * value;
size_t len;
};
typedef struct sc_pkcs15_der sc_pkcs15_der_t;
struct sc_pkcs15_pubkey_rsa {
sc_pkcs15_bignum_t modulus;
sc_pkcs15_bignum_t exponent;
};
struct sc_pkcs15_prkey_rsa {
/* public components */
sc_pkcs15_bignum_t modulus;
sc_pkcs15_bignum_t exponent;
/* private components */
sc_pkcs15_bignum_t d;
sc_pkcs15_bignum_t p;
sc_pkcs15_bignum_t q;
/* optional CRT elements */
sc_pkcs15_bignum_t iqmp;
sc_pkcs15_bignum_t dmp1;
sc_pkcs15_bignum_t dmq1;
};
struct sc_pkcs15_pubkey_dsa {
sc_pkcs15_bignum_t pub;
sc_pkcs15_bignum_t p;
sc_pkcs15_bignum_t q;
sc_pkcs15_bignum_t g;
};
struct sc_pkcs15_prkey_dsa {
/* public components */
sc_pkcs15_bignum_t pub;
sc_pkcs15_bignum_t p;
sc_pkcs15_bignum_t q;
sc_pkcs15_bignum_t g;
/* private key */
sc_pkcs15_bignum_t priv;
};
struct sc_pkcs15_pubkey_gostr3410 {
sc_pkcs15_bignum_t xy;
};
struct sc_pkcs15_prkey_gostr3410 {
/* private components */
sc_pkcs15_bignum_t d;
};
struct sc_pkcs15_pubkey {
int algorithm;
/* Decoded key */
union {
struct sc_pkcs15_pubkey_rsa rsa;
struct sc_pkcs15_pubkey_dsa dsa;
struct sc_pkcs15_pubkey_gostr3410 gostr3410;
} u;
/* DER encoded raw key */
sc_pkcs15_der_t data;
};
typedef struct sc_pkcs15_pubkey sc_pkcs15_pubkey_t;
struct sc_pkcs15_prkey {
unsigned int algorithm;
union {
struct sc_pkcs15_prkey_rsa rsa;
struct sc_pkcs15_prkey_dsa dsa;
struct sc_pkcs15_prkey_gostr3410 gostr3410;
} u;
};
typedef struct sc_pkcs15_prkey sc_pkcs15_prkey_t;
/* Enveloped objects can be used to provide additional
* protection to non-native private keys */
struct sc_pkcs15_enveloped_data {
/* recipient info */
sc_pkcs15_id_t id; /* key ID */
struct sc_algorithm_id ke_alg; /* key-encryption algo */
u8 *key; /* encrypted key */
size_t key_len;
struct sc_algorithm_id ce_alg; /* content-encryption algo */
u8 *content; /* encrypted content */
size_t content_len;
};
struct sc_pkcs15_cert {
int version;
u8 *serial;
size_t serial_len;
u8 *issuer;
size_t issuer_len;
u8 *subject;
size_t subject_len;
u8 *crl;
size_t crl_len;
struct sc_pkcs15_pubkey key;
u8 *data; /* DER encoded raw cert */
size_t data_len;
};
typedef struct sc_pkcs15_cert sc_pkcs15_cert_t;
struct sc_pkcs15_cert_info {
struct sc_pkcs15_id id; /* correlates to private key id */
int authority; /* boolean */
/* identifiers [2] SEQUENCE OF CredentialIdentifier{{KeyIdentifiers}} */
struct sc_path path;
sc_pkcs15_der_t value;
};
typedef struct sc_pkcs15_cert_info sc_pkcs15_cert_info_t;
struct sc_pkcs15_data {
u8 *data; /* DER encoded raw data object */
size_t data_len;
};
typedef struct sc_pkcs15_data sc_pkcs15_data_t;
struct sc_pkcs15_data_info {
/* FIXME: there is no pkcs15 ID in DataType */
struct sc_pkcs15_id id;
/* Identify the application:
* either or both may be set */
char app_label[SC_PKCS15_MAX_LABEL_SIZE];
struct sc_object_id app_oid;
struct sc_path path;
};
typedef struct sc_pkcs15_data_info sc_pkcs15_data_info_t;
#define SC_PKCS15_PRKEY_USAGE_ENCRYPT 0x01
#define SC_PKCS15_PRKEY_USAGE_DECRYPT 0x02
#define SC_PKCS15_PRKEY_USAGE_SIGN 0x04
#define SC_PKCS15_PRKEY_USAGE_SIGNRECOVER 0x08
#define SC_PKCS15_PRKEY_USAGE_WRAP 0x10
#define SC_PKCS15_PRKEY_USAGE_UNWRAP 0x20
#define SC_PKCS15_PRKEY_USAGE_VERIFY 0x40
#define SC_PKCS15_PRKEY_USAGE_VERIFYRECOVER 0x80
#define SC_PKCS15_PRKEY_USAGE_DERIVE 0x100
#define SC_PKCS15_PRKEY_USAGE_NONREPUDIATION 0x200
#define SC_PKCS15_PRKEY_ACCESS_SENSITIVE 0x01
#define SC_PKCS15_PRKEY_ACCESS_EXTRACTABLE 0x02
#define SC_PKCS15_PRKEY_ACCESS_ALWAYSSENSITIVE 0x04
#define SC_PKCS15_PRKEY_ACCESS_NEVEREXTRACTABLE 0x08
#define SC_PKCS15_PRKEY_ACCESS_LOCAL 0x10
#define SC_PKCS15_PARAMSET_GOSTR3410_A 1
#define SC_PKCS15_PARAMSET_GOSTR3410_B 2
#define SC_PKCS15_PARAMSET_GOSTR3410_C 3
#define SC_PKCS15_GOSTR3410_KEYSIZE 256
struct sc_pkcs15_keyinfo_gostparams
{
unsigned int gostr3410, gostr3411, gost28147;
};
struct sc_pkcs15_prkey_info {
struct sc_pkcs15_id id; /* correlates to public certificate id */
unsigned int usage, access_flags;
int native, key_reference;
size_t modulus_length;
u8 *subject;
size_t subject_len;
void *params;
size_t params_len;
struct sc_path path;
};
typedef struct sc_pkcs15_prkey_info sc_pkcs15_prkey_info_t;
struct sc_pkcs15_pubkey_info {
struct sc_pkcs15_id id; /* correlates to private key id */
unsigned int usage, access_flags;
int native, key_reference;
size_t modulus_length;
u8 *subject;
size_t subject_len;
void *params;
size_t params_len;
struct sc_path path;
};
typedef struct sc_pkcs15_pubkey_info sc_pkcs15_pubkey_info_t;
#define SC_PKCS15_TYPE_CLASS_MASK 0xF00
#define SC_PKCS15_TYPE_PRKEY 0x100
#define SC_PKCS15_TYPE_PRKEY_RSA 0x101
#define SC_PKCS15_TYPE_PRKEY_DSA 0x102
#define SC_PKCS15_TYPE_PRKEY_GOSTR3410 0x103
#define SC_PKCS15_TYPE_PUBKEY 0x200
#define SC_PKCS15_TYPE_PUBKEY_RSA 0x201
#define SC_PKCS15_TYPE_PUBKEY_DSA 0x202
#define SC_PKCS15_TYPE_PUBKEY_GOSTR3410 0x203
#define SC_PKCS15_TYPE_CERT 0x400
#define SC_PKCS15_TYPE_CERT_X509 0x401
#define SC_PKCS15_TYPE_CERT_SPKI 0x402
#define SC_PKCS15_TYPE_DATA_OBJECT 0x500
#define SC_PKCS15_TYPE_AUTH 0x600
#define SC_PKCS15_TYPE_AUTH_PIN 0x601
#define SC_PKCS15_TYPE_TO_CLASS(t) (1 << ((t) >> 8))
#define SC_PKCS15_SEARCH_CLASS_PRKEY 0x0002U
#define SC_PKCS15_SEARCH_CLASS_PUBKEY 0x0004U
#define SC_PKCS15_SEARCH_CLASS_CERT 0x0010U
#define SC_PKCS15_SEARCH_CLASS_DATA 0x0020U
#define SC_PKCS15_SEARCH_CLASS_AUTH 0x0040U
struct sc_pkcs15_object {
unsigned int type;
/* CommonObjectAttributes */
char label[SC_PKCS15_MAX_LABEL_SIZE]; /* zero terminated */
unsigned int flags;
struct sc_pkcs15_id auth_id;
int user_consent;
/* Object type specific data */
void *data;
struct sc_pkcs15_df *df; /* can be NULL, if object is 'floating' */
struct sc_pkcs15_object *next, *prev; /* used only internally */
struct sc_pkcs15_der der;
};
typedef struct sc_pkcs15_object sc_pkcs15_object_t;
/* PKCS #15 DF types */
#define SC_PKCS15_PRKDF 0
#define SC_PKCS15_PUKDF 1
#define SC_PKCS15_PUKDF_TRUSTED 2
#define SC_PKCS15_SKDF 3
#define SC_PKCS15_CDF 4
#define SC_PKCS15_CDF_TRUSTED 5
#define SC_PKCS15_CDF_USEFUL 6
#define SC_PKCS15_DODF 7
#define SC_PKCS15_AODF 8
#define SC_PKCS15_DF_TYPE_COUNT 9
struct sc_pkcs15_df {
struct sc_file *file;
struct sc_path path;
int record_length;
unsigned int type;
int enumerated;
struct sc_pkcs15_df *next, *prev;
};
typedef struct sc_pkcs15_df sc_pkcs15_df_t;
struct sc_pkcs15_unusedspace {
sc_path_t path;
sc_pkcs15_id_t auth_id;
struct sc_pkcs15_unusedspace *next, *prev;
};
typedef struct sc_pkcs15_unusedspace sc_pkcs15_unusedspace_t;
#define SC_PKCS15_CARD_MAGIC 0x10203040
typedef struct {
int se;
struct sc_object_id owner;
u8 aid[SC_MAX_AID_SIZE];
size_t aid_len;
} sc_pkcs15_sec_env_info_t;
typedef struct {
unsigned int version;
unsigned int flags;
char *label;
char *serial_number;
char *manufacturer_id;
char *last_update;
char *preferred_language;
sc_pkcs15_sec_env_info_t **seInfo;
size_t num_seInfo;
} sc_pkcs15_tokeninfo_t;
typedef struct sc_pkcs15_card {
sc_card_t *card;
char *label;
/* fields from TokenInfo: */
int version;
char *serial_number, *manufacturer_id;
char *last_update;
unsigned int flags;
struct sc_pkcs15_algorithm_info alg_info[1];
sc_file_t *file_app;
sc_file_t *file_tokeninfo, *file_odf, *file_unusedspace;
struct sc_pkcs15_df *df_list;
struct sc_pkcs15_object *obj_list;
int record_lengths[SC_PKCS15_DF_TYPE_COUNT];
sc_pkcs15_unusedspace_t *unusedspace_list;
int unusedspace_read;
struct sc_pkcs15_card_opts {
int use_cache;
} opts;
sc_pkcs15_sec_env_info_t **seInfo;
size_t num_seInfo;
unsigned int magic;
void *dll_handle; /* shared lib for emulated cards */
char *preferred_language;
} sc_pkcs15_card_t;
#define SC_PKCS15_CARD_FLAG_READONLY 0x01
#define SC_PKCS15_CARD_FLAG_LOGIN_REQUIRED 0x02
#define SC_PKCS15_CARD_FLAG_PRN_GENERATION 0x04
#define SC_PKCS15_CARD_FLAG_EID_COMPLIANT 0x08
#define SC_PKCS15_CARD_FLAG_SIGN_WITH_DECRYPT 0x10000000
#define SC_PKCS15_CARD_FLAG_EMULATED 0x20000000
#define SC_PKCS15_CARD_FLAG_FIX_INTEGERS 0x40000000
/* sc_pkcs15_bind: Binds a card object to a PKCS #15 card object
* and initializes a new PKCS #15 card object. Will return
* SC_ERROR_PKCS15_APP_NOT_FOUND, if the card hasn't got a
* valid PKCS #15 file structure. */
int sc_pkcs15_bind(struct sc_card *card,
struct sc_pkcs15_card **pkcs15_card);
/* sc_pkcs15_unbind: Releases a PKCS #15 card object, and frees any
* memory allocations done on the card object. */
int sc_pkcs15_unbind(struct sc_pkcs15_card *card);
int sc_pkcs15_get_objects(struct sc_pkcs15_card *card, unsigned int type,
struct sc_pkcs15_object **ret, size_t ret_count);
int sc_pkcs15_get_objects_cond(struct sc_pkcs15_card *card, unsigned int type,
int (* func)(struct sc_pkcs15_object *, void *),
void *func_arg,
struct sc_pkcs15_object **ret, size_t ret_count);
int sc_pkcs15_find_object_by_id(sc_pkcs15_card_t *, unsigned int,
const sc_pkcs15_id_t *,
sc_pkcs15_object_t **);
struct sc_pkcs15_card * sc_pkcs15_card_new(void);
void sc_pkcs15_card_free(struct sc_pkcs15_card *p15card);
void sc_pkcs15_card_clear(sc_pkcs15_card_t *p15card);
int sc_pkcs15_decipher(struct sc_pkcs15_card *p15card,
const struct sc_pkcs15_object *prkey_obj,
unsigned long flags,
const u8 *in, size_t inlen, u8 *out, size_t outlen);
int sc_pkcs15_compute_signature(struct sc_pkcs15_card *p15card,
const struct sc_pkcs15_object *prkey_obj,
unsigned long alg_flags, const u8 *in,
size_t inlen, u8 *out, size_t outlen);
int sc_pkcs15_read_pubkey(struct sc_pkcs15_card *card,
const struct sc_pkcs15_object *obj,
struct sc_pkcs15_pubkey **out);
int sc_pkcs15_decode_pubkey_rsa(struct sc_context *ctx,
struct sc_pkcs15_pubkey_rsa *pubkey,
const u8 *, size_t);
int sc_pkcs15_encode_pubkey_rsa(struct sc_context *,
struct sc_pkcs15_pubkey_rsa *, u8 **, size_t *);
int sc_pkcs15_decode_pubkey_dsa(struct sc_context *ctx,
struct sc_pkcs15_pubkey_dsa *pubkey,
const u8 *, size_t);
int sc_pkcs15_encode_pubkey_dsa(struct sc_context *,
struct sc_pkcs15_pubkey_dsa *, u8 **, size_t *);
int sc_pkcs15_decode_pubkey(struct sc_context *,
struct sc_pkcs15_pubkey *, const u8 *, size_t);
int sc_pkcs15_encode_pubkey(struct sc_context *,
struct sc_pkcs15_pubkey *, u8 **, size_t *);
void sc_pkcs15_erase_pubkey(struct sc_pkcs15_pubkey *pubkey);
void sc_pkcs15_free_pubkey(struct sc_pkcs15_pubkey *pubkey);
int sc_pkcs15_read_prkey(struct sc_pkcs15_card *card,
const struct sc_pkcs15_object *obj,
const char *passphrase,
struct sc_pkcs15_prkey **out);
int sc_pkcs15_decode_prkey(struct sc_context *,
struct sc_pkcs15_prkey *,
const u8 *, size_t);
int sc_pkcs15_encode_prkey(struct sc_context *,
struct sc_pkcs15_prkey *,
u8 **, size_t *);
void sc_pkcs15_erase_prkey(struct sc_pkcs15_prkey *prkey);
void sc_pkcs15_free_prkey(struct sc_pkcs15_prkey *prkey);
int sc_pkcs15_read_data_object(struct sc_pkcs15_card *p15card,
const struct sc_pkcs15_data_info *info,
struct sc_pkcs15_data **data_object_out);
int sc_pkcs15_find_data_object_by_id(struct sc_pkcs15_card *p15card,
const struct sc_pkcs15_id *id,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_data_object_by_app_oid(struct sc_pkcs15_card *p15card,
const struct sc_object_id *app_oid,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_data_object_by_name(struct sc_pkcs15_card *p15card,
const char *app_label,
const char *label,
struct sc_pkcs15_object **out);
void sc_pkcs15_free_data_object(struct sc_pkcs15_data *data_object);
int sc_pkcs15_read_certificate(struct sc_pkcs15_card *card,
const struct sc_pkcs15_cert_info *info,
struct sc_pkcs15_cert **cert);
void sc_pkcs15_free_certificate(struct sc_pkcs15_cert *cert);
int sc_pkcs15_find_cert_by_id(struct sc_pkcs15_card *card,
const struct sc_pkcs15_id *id,
struct sc_pkcs15_object **out);
/* sc_pkcs15_create_cdf: Creates a new certificate DF on a card pointed
* by <card>. Information about the file, such as the file ID, is read
* from <file>. <certs> has to be NULL-terminated. */
int sc_pkcs15_create_cdf(struct sc_pkcs15_card *card,
struct sc_file *file,
const struct sc_pkcs15_cert_info **certs);
int sc_pkcs15_create(struct sc_pkcs15_card *p15card, struct sc_card *card);
int sc_pkcs15_find_prkey_by_id(struct sc_pkcs15_card *card,
const struct sc_pkcs15_id *id,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_prkey_by_id_usage(struct sc_pkcs15_card *card,
const struct sc_pkcs15_id *id,
unsigned int usage,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_prkey_by_reference(sc_pkcs15_card_t *,
const sc_path_t *, int,
sc_pkcs15_object_t **);
int sc_pkcs15_find_pubkey_by_id(struct sc_pkcs15_card *card,
const struct sc_pkcs15_id *id,
struct sc_pkcs15_object **out);
int sc_pkcs15_verify_pin(struct sc_pkcs15_card *card,
struct sc_pkcs15_pin_info *pin,
const u8 *pincode, size_t pinlen);
int sc_pkcs15_change_pin(struct sc_pkcs15_card *card,
struct sc_pkcs15_pin_info *pin,
const u8 *oldpincode, size_t oldpinlen,
const u8 *newpincode, size_t newpinlen);
int sc_pkcs15_unblock_pin(struct sc_pkcs15_card *card,
struct sc_pkcs15_pin_info *pin,
const u8 *puk, size_t puklen,
const u8 *newpin, size_t newpinlen);
int sc_pkcs15_find_pin_by_auth_id(struct sc_pkcs15_card *card,
const struct sc_pkcs15_id *id,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_pin_by_reference(struct sc_pkcs15_card *card,
const sc_path_t *path, int reference,
struct sc_pkcs15_object **out);
int sc_pkcs15_find_so_pin(struct sc_pkcs15_card *card,
struct sc_pkcs15_object **out);
int sc_pkcs15_encode_dir(struct sc_context *ctx,
struct sc_pkcs15_card *card,
u8 **buf, size_t *buflen);
int sc_pkcs15_parse_tokeninfo(sc_context_t *ctx,
sc_pkcs15_tokeninfo_t *ti,
const u8 *buf, size_t blen);
int sc_pkcs15_encode_tokeninfo(struct sc_context *ctx,
sc_pkcs15_tokeninfo_t *ti,
u8 **buf, size_t *buflen);
int sc_pkcs15_encode_odf(struct sc_context *ctx,
struct sc_pkcs15_card *card,
u8 **buf, size_t *buflen);
int sc_pkcs15_encode_df(struct sc_context *ctx,
struct sc_pkcs15_card *p15card,
struct sc_pkcs15_df *df,
u8 **buf, size_t *bufsize);
int sc_pkcs15_encode_cdf_entry(struct sc_context *ctx,
const struct sc_pkcs15_object *obj, u8 **buf,
size_t *bufsize);
int sc_pkcs15_encode_prkdf_entry(struct sc_context *ctx,
const struct sc_pkcs15_object *obj, u8 **buf,
size_t *bufsize);
int sc_pkcs15_encode_pukdf_entry(struct sc_context *ctx,
const struct sc_pkcs15_object *obj, u8 **buf,
size_t *bufsize);
int sc_pkcs15_encode_dodf_entry(struct sc_context *ctx,
const struct sc_pkcs15_object *obj, u8 **buf,
size_t *bufsize);
int sc_pkcs15_encode_aodf_entry(struct sc_context *ctx,
const struct sc_pkcs15_object *obj, u8 **buf,
size_t *bufsize);
int sc_pkcs15_parse_df(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_df *df);
int sc_pkcs15_read_df(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_df *df);
int sc_pkcs15_decode_cdf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj,
const u8 **buf, size_t *bufsize);
int sc_pkcs15_decode_dodf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj,
const u8 **buf, size_t *bufsize);
int sc_pkcs15_decode_aodf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj,
const u8 **buf, size_t *bufsize);
int sc_pkcs15_decode_prkdf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj,
const u8 **buf, size_t *bufsize);
int sc_pkcs15_decode_pukdf_entry(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj,
const u8 **buf, size_t *bufsize);
int sc_pkcs15_decode_enveloped_data(struct sc_context *ctx,
struct sc_pkcs15_enveloped_data *result,
const u8 *buf, size_t buflen);
int sc_pkcs15_encode_enveloped_data(struct sc_context *ctx,
struct sc_pkcs15_enveloped_data *data,
u8 **buf, size_t *buflen);
int sc_pkcs15_add_object(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj);
void sc_pkcs15_remove_object(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_object *obj);
int sc_pkcs15_add_df(struct sc_pkcs15_card *p15card,
unsigned int type, const sc_path_t *path,
const struct sc_file *file);
void sc_pkcs15_remove_df(struct sc_pkcs15_card *p15card,
struct sc_pkcs15_df *df);
int sc_pkcs15_add_unusedspace(struct sc_pkcs15_card *p15card,
const sc_path_t *path, const sc_pkcs15_id_t *auth_id);
void sc_pkcs15_remove_unusedspace(struct sc_pkcs15_card *p15card,
sc_pkcs15_unusedspace_t *obj);
int sc_pkcs15_parse_unusedspace(const u8 * buf, size_t buflen,
struct sc_pkcs15_card *card);
int sc_pkcs15_encode_unusedspace(sc_context_t *ctx,
struct sc_pkcs15_card *p15card,
u8 **buf, size_t *buflen);
void sc_pkcs15_free_prkey_info(sc_pkcs15_prkey_info_t *key);
void sc_pkcs15_free_pubkey_info(sc_pkcs15_pubkey_info_t *key);
void sc_pkcs15_free_cert_info(sc_pkcs15_cert_info_t *cert);
void sc_pkcs15_free_data_info(sc_pkcs15_data_info_t *data);
void sc_pkcs15_free_pin_info(sc_pkcs15_pin_info_t *pin);
void sc_pkcs15_free_object(sc_pkcs15_object_t *obj);
/* File content wrapping */
int sc_pkcs15_wrap_data(struct sc_context *ctx,
const char *passphrase,
const u8 *in, size_t in_len,
u8 **out, size_t *out_len);
int sc_pkcs15_unwrap_data(struct sc_context *ctx,
const char *passphrase,
const u8 *in, size_t in_len,
u8 **out, size_t *out_len);
/* Generic file i/o */
int sc_pkcs15_read_file(struct sc_pkcs15_card *p15card,
const struct sc_path *path,
u8 **buf, size_t *buflen,
struct sc_file **file_out);
/* Caching functions */
int sc_pkcs15_read_cached_file(struct sc_pkcs15_card *p15card,
const struct sc_path *path,
u8 **buf, size_t *bufsize);
int sc_pkcs15_cache_file(struct sc_pkcs15_card *p15card,
const struct sc_path *path,
const u8 *buf, size_t bufsize);
/* PKCS #15 ID handling functions */
int sc_pkcs15_compare_id(const struct sc_pkcs15_id *id1,
const struct sc_pkcs15_id *id2);
const char *sc_pkcs15_print_id(const struct sc_pkcs15_id *id);
void sc_pkcs15_format_id(const char *id_in, struct sc_pkcs15_id *id_out);
int sc_pkcs15_hex_string_to_id(const char *in, struct sc_pkcs15_id *out);
void sc_der_copy(sc_pkcs15_der_t *, const sc_pkcs15_der_t *);
void sc_der_clear(sc_pkcs15_der_t *);
/* Prepend 'parent' to 'child' in case 'child' is a relative path */
int sc_pkcs15_make_absolute_path(const sc_path_t *parent, sc_path_t *child);
/* New object search API.
* More complex, but also more powerful.
*/
typedef struct sc_pkcs15_search_key {
unsigned int class_mask;
unsigned int type;
const sc_pkcs15_id_t * id;
const struct sc_object_id *app_oid;
const sc_path_t * path;
unsigned int usage_mask, usage_value;
unsigned int flags_mask, flags_value;
unsigned int match_reference : 1;
int reference;
const char * app_label;
const char * label;
} sc_pkcs15_search_key_t;
int sc_pkcs15_search_objects(sc_pkcs15_card_t *, sc_pkcs15_search_key_t *,
sc_pkcs15_object_t **, size_t);
/* This structure is passed to the new sc_pkcs15emu_*_init functions */
typedef struct sc_pkcs15emu_opt {
scconf_block *blk;
unsigned int flags;
} sc_pkcs15emu_opt_t;
#define SC_PKCS15EMU_FLAGS_NO_CHECK 0x00000001
extern int sc_pkcs15_bind_synthetic(sc_pkcs15_card_t *);
extern int sc_pkcs15_is_emulation_only(sc_card_t *);
int sc_pkcs15emu_object_add(sc_pkcs15_card_t *p15card, unsigned int type,
const sc_pkcs15_object_t *obj, const void *data);
/* some wrapper functions for sc_pkcs15emu_object_add */
int sc_pkcs15emu_add_pin_obj(sc_pkcs15_card_t *,
const sc_pkcs15_object_t *, const sc_pkcs15_pin_info_t *);
int sc_pkcs15emu_add_rsa_prkey(sc_pkcs15_card_t *,
const sc_pkcs15_object_t *, const sc_pkcs15_prkey_info_t *);
int sc_pkcs15emu_add_rsa_pubkey(sc_pkcs15_card_t *,
const sc_pkcs15_object_t *, const sc_pkcs15_pubkey_info_t *);
int sc_pkcs15emu_add_x509_cert(sc_pkcs15_card_t *p15card,
const sc_pkcs15_object_t *, const sc_pkcs15_cert_info_t *);
int sc_pkcs15emu_add_data_object(sc_pkcs15_card_t *p15card,
const sc_pkcs15_object_t *, const sc_pkcs15_data_info_t *);
#ifdef __cplusplus
}
#endif
#endif

227
opensc/scconf.h Normal file
View File

@@ -0,0 +1,227 @@
/*
* $Id: scconf.h 620 2011-05-25 14:49:04Z felfert $
*
* Copyright (C) 2002
* Antti Tapaninen <aet@cc.hut.fi>
*
* Originally based on source by Timo Sirainen <tss@iki.fi>
*
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#ifndef _SC_CONF_H
#define _SC_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _scconf_entry {
const char *name;
unsigned int type;
unsigned int flags;
void *parm;
void *arg;
} scconf_entry;
/* Entry flags */
#define SCCONF_PRESENT 0x00000001
#define SCCONF_MANDATORY 0x00000002
#define SCCONF_ALLOC 0x00000004
#define SCCONF_ALL_BLOCKS 0x00000008
#define SCCONF_VERBOSE 0x00000010 /* For debugging purposes only */
/* Entry types */
#define SCCONF_CALLBACK 1
#define SCCONF_BLOCK 2
#define SCCONF_LIST 3
#define SCCONF_BOOLEAN 11
#define SCCONF_INTEGER 12
#define SCCONF_STRING 13
typedef struct _scconf_block scconf_block;
typedef struct _scconf_list {
struct _scconf_list *next;
char *data;
} scconf_list;
#define SCCONF_ITEM_TYPE_COMMENT 0 /* key = NULL, comment */
#define SCCONF_ITEM_TYPE_BLOCK 1 /* key = key, block */
#define SCCONF_ITEM_TYPE_VALUE 2 /* key = key, list */
typedef struct _scconf_item {
struct _scconf_item *next;
int type;
char *key;
union {
char *comment;
scconf_block *block;
scconf_list *list;
} value;
} scconf_item;
struct _scconf_block {
scconf_block *parent;
scconf_list *name;
scconf_item *items;
};
typedef struct {
char *filename;
int debug;
scconf_block *root;
char *errmsg;
} scconf_context;
/* Allocate scconf_context
* The filename can be NULL
*/
extern scconf_context *scconf_new(const char *filename);
/* Free scconf_context
*/
extern void scconf_free(scconf_context * config);
/* Parse configuration
* Returns 1 = ok, 0 = error, -1 = error opening config file
*/
extern int scconf_parse(scconf_context * config);
/* Parse a static configuration string
* Returns 1 = ok, 0 = error
*/
extern int scconf_parse_string(scconf_context * config, const char *string);
/* Parse entries
*/
extern int scconf_parse_entries(const scconf_context * config, const scconf_block * block, scconf_entry * entry);
/* Write config to a file
* If the filename is NULL, use the config->filename
* Returns 0 = ok, else = errno
*/
extern int scconf_write(scconf_context * config, const char *filename);
/* Write configuration entries to block
*/
extern int scconf_write_entries(scconf_context * config, scconf_block * block, scconf_entry * entry);
/* Find a block by the item_name
* If the block is NULL, the root block is used
*/
extern const scconf_block *scconf_find_block(const scconf_context * config, const scconf_block * block, const char *item_name);
/* Find blocks by the item_name
* If the block is NULL, the root block is used
* The key can be used to specify what the blocks first name should be
*/
extern scconf_block **scconf_find_blocks(const scconf_context * config, const scconf_block * block, const char *item_name, const char *key);
/* Get a list of values for option
*/
extern const scconf_list *scconf_find_list(const scconf_block * block, const char *option);
/* Return the first string of the option
* If no option found, return def
*/
extern const char *scconf_get_str(const scconf_block * block, const char *option, const char *def);
/* Return the first value of the option as integer
* If no option found, return def
*/
extern int scconf_get_int(const scconf_block * block, const char *option, int def);
/* Return the first value of the option as boolean
* If no option found, return def
*/
extern int scconf_get_bool(const scconf_block * block, const char *option, int def);
/* Write value to a block as a string
*/
extern const char *scconf_put_str(scconf_block * block, const char *option, const char *value);
/* Write value to a block as an integer
*/
extern int scconf_put_int(scconf_block * block, const char *option, int value);
/* Write value to a block as a boolean
*/
extern int scconf_put_bool(scconf_block * block, const char *option, int value);
/* Add block structure
* If the block is NULL, the root block is used
*/
extern scconf_block *scconf_block_add(scconf_context * config, scconf_block * block, const char *key, const scconf_list *name);
/* Copy block structure (recursive)
*/
extern scconf_block *scconf_block_copy(const scconf_block * src, scconf_block ** dst);
/* Free block structure (recursive)
*/
extern void scconf_block_destroy(scconf_block * block);
/* Add item to block structure
* If the block is NULL, the root block is used
*/
extern scconf_item *scconf_item_add(scconf_context * config, scconf_block * block, scconf_item * item, int type, const char *key, const void *data);
/* Copy item structure (recursive)
*/
extern scconf_item *scconf_item_copy(const scconf_item * src, scconf_item ** dst);
/* Free item structure (recursive)
*/
extern void scconf_item_destroy(scconf_item * item);
/* Add a new value to the list
*/
extern scconf_list *scconf_list_add(scconf_list ** list, const char *value);
/* Copy list structure
*/
extern scconf_list *scconf_list_copy(const scconf_list * src, scconf_list ** dst);
/* Free list structure
*/
extern void scconf_list_destroy(scconf_list * list);
/* Return the length of an list array
*/
extern int scconf_list_array_length(const scconf_list * list);
/* Return the combined length of the strings on all arrays
*/
extern int scconf_list_strings_length(const scconf_list * list);
/* Return an allocated string that contains all
* the strings in a list separated by the filler
* The filler can be NULL
*/
extern char *scconf_list_strdup(const scconf_list * list, const char *filler);
/* Returns an allocated array of const char *pointers to
* list elements.
* Last pointer is NULL
* Array must be freed, but pointers to strings belong to scconf_list
*/
extern const char **scconf_list_toarray(const scconf_list * list);
#ifdef __cplusplus
}
#endif
#endif

130
opensc/types.h Normal file
View File

@@ -0,0 +1,130 @@
/*
* types.h: OpenSC general types
*
* Copyright (C) 2001, 2002 Juha Yrjölä <juha.yrjola@iki.fi>
*
* 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,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
*/
#ifndef _OPENSC_TYPES_H
#define _OPENSC_TYPES_H
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned char u8;
#define SC_MAX_OBJECT_ID_OCTETS 16
struct sc_object_id {
int value[SC_MAX_OBJECT_ID_OCTETS];
};
#define SC_PATH_TYPE_FILE_ID 0
#define SC_PATH_TYPE_DF_NAME 1
#define SC_PATH_TYPE_PATH 2
#define SC_PATH_TYPE_PATH_PROT 3 /* path of a file containing
EnvelopedData objects */
#define SC_PATH_TYPE_FROM_CURRENT 4
#define SC_PATH_TYPE_PARENT 5
#define SC_MAX_PATH_SIZE 16
#define SC_MAX_PATH_STRING_SIZE (SC_MAX_PATH_SIZE * 2 + 1)
typedef struct sc_path {
u8 value[SC_MAX_PATH_SIZE];
size_t len;
/* The next two fields are used in PKCS15, where
* a Path object can reference a portion of a file -
* count octets starting at offset index.
*/
int index;
int count;
int type;
} sc_path_t;
typedef struct sc_acl_entry {
unsigned int method; /* See SC_AC_* */
unsigned int key_ref; /* SC_AC_KEY_REF_NONE or an integer */
struct sc_acl_entry *next;
} sc_acl_entry_t;
#define SC_MAX_AC_OPS 9
typedef struct sc_file {
struct sc_path path;
u8 name[16]; /* DF name */
size_t namelen; /* length of DF name */
int type, shareable, ef_structure;
size_t size; /* Size of file (in bytes) */
int id; /* Short file id (2 bytes) */
int status; /* Status flags */
struct sc_acl_entry *acl[SC_MAX_AC_OPS]; /* Access Control List */
int record_length; /* In case of fixed-length or cyclic EF */
int record_count; /* Valid, if not transparent EF or DF */
u8 *sec_attr;
size_t sec_attr_len;
u8 *prop_attr;
size_t prop_attr_len;
u8 *type_attr;
size_t type_attr_len;
unsigned int magic;
} sc_file_t;
/* use command chaining if the Lc value is greater than normally
* allowed
*/
#define SC_APDU_FLAGS_CHAINING 0x00000001UL
/* do not automatically call GET RESPONSE to read all available
* data
*/
#define SC_APDU_FLAGS_NO_GET_RESP 0x00000002UL
/* do not automatically try a re-transmit with a new length
* if the card returns 0x6Cxx (wrong length)
*/
#define SC_APDU_FLAGS_NO_RETRY_WL 0x00000004UL
typedef struct sc_apdu {
int cse; /* APDU case */
u8 cla, ins, p1, p2; /* CLA, INS, P1 and P2 bytes */
size_t lc, le; /* Lc and Le bytes */
const u8 *data; /* C-APDU data */
size_t datalen; /* length of data in C-APDU */
u8 *resp; /* R-APDU data buffer */
size_t resplen; /* in: size of R-APDU buffer,
* out: length of data returned in R-APDU */
u8 sensitive; /* Set if either the command or
* the response contains secrets,
* e.g. a PIN. */
u8 control; /* Set if APDU should go to the reader */
unsigned int sw1, sw2; /* Status words returned in R-APDU */
unsigned long flags;
} sc_apdu_t;
#ifdef __cplusplus
}
#endif
#endif