2002-02-22 07:18:43 +00:00
|
|
|
/*
|
|
|
|
* card_ctl command numbers
|
|
|
|
*
|
|
|
|
* There is a range of generic card_ctls, and card-specific
|
|
|
|
* ranges. I've used a 3-letter abbreviation of the card in
|
|
|
|
* the prefix, but that's just a fad :)
|
|
|
|
*
|
|
|
|
* For now, I've reserved these:
|
|
|
|
* 0x0000xxxx generic
|
|
|
|
* 0x4C4658xx Cryptoflex
|
|
|
|
* 0x47504Bxx GPK
|
2002-05-09 10:34:18 +00:00
|
|
|
* 0x544353xx TCOS
|
2002-02-22 07:18:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OPENSC_CARDCTL_H
|
|
|
|
#define _OPENSC_CARDCTL_H
|
|
|
|
|
2003-04-11 11:47:41 +00:00
|
|
|
#include <opensc/types.h>
|
|
|
|
|
2002-04-19 14:23:31 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-02-27 22:15:12 +00:00
|
|
|
#define _CTL_PREFIX(a, b, c) (((a) << 24) | ((b) << 16) | ((c) << 8))
|
2002-02-22 07:18:43 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
/*
|
|
|
|
* Generic card_ctl calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_GENERIC_BASE = 0x00000000,
|
|
|
|
SC_CARDCTL_ERASE_CARD,
|
2002-12-04 09:26:40 +00:00
|
|
|
SC_CARDCTL_GET_DEFAULT_KEY,
|
2003-04-11 11:47:41 +00:00
|
|
|
SC_CARDCTL_LIFECYCLE_GET,
|
|
|
|
SC_CARDCTL_LIFECYCLE_SET,
|
2002-02-22 07:18:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* GPK specific calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_GPK_BASE = _CTL_PREFIX('G', 'P', 'K'),
|
2002-06-17 15:24:21 +00:00
|
|
|
SC_CARDCTL_GPK_VARIANT,
|
2002-02-22 07:18:43 +00:00
|
|
|
SC_CARDCTL_GPK_LOCK,
|
2002-02-23 13:38:01 +00:00
|
|
|
SC_CARDCTL_GPK_PKINIT,
|
|
|
|
SC_CARDCTL_GPK_PKLOAD,
|
2002-11-08 13:50:33 +00:00
|
|
|
SC_CARDCTL_GPK_IS_LOCKED,
|
2002-02-22 07:18:43 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Cryptoflex specific calls
|
|
|
|
*/
|
2002-04-04 20:40:40 +00:00
|
|
|
SC_CARDCTL_CRYPTOFLEX_BASE = _CTL_PREFIX('C', 'F', 'X'),
|
2003-05-22 20:53:15 +00:00
|
|
|
SC_CARDCTL_CRYPTOFLEX_GENERATE_KEY,
|
2002-02-22 07:18:43 +00:00
|
|
|
|
2002-04-04 20:40:40 +00:00
|
|
|
/*
|
|
|
|
* MioCOS specific calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_MIOCOS_BASE = _CTL_PREFIX('M', 'I', 'O'),
|
|
|
|
SC_CARDCTL_MIOCOS_CREATE_AC,
|
2002-05-09 10:34:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* TCOS specific calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_TCOS_BASE = _CTL_PREFIX('T','C','S'),
|
2002-06-04 08:50:39 +00:00
|
|
|
SC_CARDCTL_TCOS_SETPERM,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* eToken specific calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_ETOKEN_BASE = _CTL_PREFIX('E', 'T', 'K'),
|
|
|
|
SC_CARDCTL_ETOKEN_PUT_DATA_FCI,
|
2002-06-06 09:17:52 +00:00
|
|
|
SC_CARDCTL_ETOKEN_PUT_DATA_OCI,
|
2002-06-11 18:13:48 +00:00
|
|
|
SC_CARDCTL_ETOKEN_PUT_DATA_SECI,
|
2003-04-11 11:47:41 +00:00
|
|
|
SC_CARDCTL_ETOKEN_GENERATE_KEY,
|
2003-06-11 10:56:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Starcos specific calls
|
|
|
|
*/
|
|
|
|
SC_CARDCTL_STARCOS_BASE = _CTL_PREFIX('S', 'T', 'A'),
|
2003-06-27 23:01:10 +00:00
|
|
|
SC_CARDCTL_STARCOS_SET_EX_DATA,
|
|
|
|
SC_CARDCTL_STARCOS_GET_EX_DATA,
|
|
|
|
SC_CARDCTL_STARCOS_FREE_EX_DATA,
|
|
|
|
SC_CARDCTL_STARCOS_FREE_ALL_EX_DATA,
|
2003-06-11 10:56:18 +00:00
|
|
|
|
2003-04-11 11:47:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
SC_CARDCTRL_LIFECYCLE_ADMIN,
|
|
|
|
SC_CARDCTRL_LIFECYCLE_USER,
|
2002-02-27 22:15:12 +00:00
|
|
|
};
|
|
|
|
|
2002-12-04 09:26:40 +00:00
|
|
|
/*
|
|
|
|
* Generic cardctl - check if the required key is a default
|
|
|
|
* key (such as the GPK "TEST KEYTEST KEY" key, or the Cryptoflex AAK)
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_default_key {
|
|
|
|
int method; /* SC_AC_XXX */
|
|
|
|
int key_ref; /* key reference */
|
|
|
|
|
|
|
|
size_t len; /* in: max size, out: actual size */
|
|
|
|
u8 * key_data; /* out: key data */
|
|
|
|
};
|
|
|
|
|
2002-02-22 07:18:43 +00:00
|
|
|
/*
|
|
|
|
* GPK lock file.
|
|
|
|
* Parent DF of file must be selected.
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_gpk_lock {
|
|
|
|
struct sc_file * file;
|
|
|
|
unsigned int operation;
|
|
|
|
};
|
|
|
|
|
2002-02-23 13:38:01 +00:00
|
|
|
/*
|
|
|
|
* GPK initialize private key file.
|
|
|
|
* Parent DF must be selected.
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_gpk_pkinit {
|
|
|
|
struct sc_file * file;
|
|
|
|
unsigned int privlen;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* GPK load private key portion.
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_gpk_pkload {
|
|
|
|
struct sc_file * file;
|
|
|
|
u8 * data;
|
|
|
|
unsigned int len;
|
|
|
|
unsigned int datalen;
|
|
|
|
};
|
|
|
|
|
2002-04-04 20:40:40 +00:00
|
|
|
enum {
|
|
|
|
SC_CARDCTL_MIOCOS_AC_PIN,
|
|
|
|
SC_CARDCTL_MIOCOS_AC_CHAL,
|
|
|
|
SC_CARDCTL_MIOCOS_AC_LOGICAL,
|
|
|
|
SC_CARDCTL_MIOCOS_AC_SMARTPIN,
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MioCOS AC info
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_miocos_ac_info {
|
|
|
|
int type;
|
|
|
|
int ref;
|
|
|
|
int max_tries;
|
|
|
|
int enable_ac; /* only applicable to PINs */
|
|
|
|
u8 key_value[8];
|
|
|
|
int max_unblock_tries; /* same here */
|
|
|
|
u8 unblock_value[8]; /* and here */
|
|
|
|
};
|
|
|
|
|
2002-06-04 08:50:39 +00:00
|
|
|
/*
|
|
|
|
* eToken PIN info
|
|
|
|
*/
|
2002-06-11 18:13:48 +00:00
|
|
|
struct sc_cardctl_etoken_obj_info {
|
2002-06-06 09:17:52 +00:00
|
|
|
u8 * data;
|
|
|
|
size_t len;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct sc_cardctl_etoken_genkey_info {
|
|
|
|
u8 * random_data;
|
|
|
|
size_t random_len;
|
|
|
|
unsigned int key_id;
|
|
|
|
unsigned int key_bits;
|
|
|
|
unsigned short fid;
|
2002-06-04 08:50:39 +00:00
|
|
|
};
|
|
|
|
|
2003-05-22 20:53:15 +00:00
|
|
|
/*
|
|
|
|
* Cryptoflex info
|
|
|
|
*/
|
|
|
|
struct sc_cardctl_cryptoflex_genkey_info {
|
|
|
|
unsigned int key_bits;
|
|
|
|
unsigned long exponent;
|
|
|
|
unsigned char * pubkey;
|
|
|
|
unsigned int pubkey_len;
|
|
|
|
};
|
|
|
|
|
2003-06-11 10:56:18 +00:00
|
|
|
/*
|
2003-06-27 23:01:10 +00:00
|
|
|
* Starcos ex_data stuff
|
2003-06-11 10:56:18 +00:00
|
|
|
*/
|
2003-06-27 23:01:10 +00:00
|
|
|
typedef struct sc_starcos_ex_data {
|
|
|
|
struct sc_starcos_ex_data *next;
|
|
|
|
unsigned long key;
|
|
|
|
void *data;
|
|
|
|
void (*free_func)(void *);
|
|
|
|
} sc_starcos_ex_data_t;
|
|
|
|
|
|
|
|
#define SC_STARCOS_PRV_DATA 0x0001 /* for internal use only */
|
|
|
|
#define SC_STARCOS_KEY_ATTR 0x0002 /* set the key attributes */
|
|
|
|
#define SC_STARCOS_PIN_ATTR 0x0004 /* set PIN attribute */
|
|
|
|
|
|
|
|
#define SC_STARCOS_EX_KEY(c,v) (((v) << 16) | (c))
|
|
|
|
|
2003-06-11 10:56:18 +00:00
|
|
|
struct sc_cardctl_starcos_key_attr_st {
|
|
|
|
unsigned long flag; /* key attributes, e.g. SC_SEC_OPERATION_SIGN
|
|
|
|
* or SC_SEC_OPERATION_AUTHENTICATE */
|
|
|
|
};
|
|
|
|
|
2003-06-27 23:01:10 +00:00
|
|
|
struct sc_cardctl_starcos_pin_attr_st {
|
|
|
|
int verify_once;
|
|
|
|
};
|
|
|
|
|
2002-04-19 14:23:31 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-02-22 07:18:43 +00:00
|
|
|
#endif /* _OPENSC_CARDCTL_H */
|
2003-06-27 23:01:10 +00:00
|
|
|
|