2002-04-05 15:06:33 +00:00
|
|
|
/*
|
|
|
|
* types.h: OpenSC general types
|
|
|
|
*
|
2006-12-19 21:31:17 +00:00
|
|
|
* Copyright (C) 2001, 2002 Juha Yrjölä <juha.yrjola@iki.fi>
|
2002-04-05 15:06:33 +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,
|
|
|
|
* 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
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2002-04-05 15:06:33 +00:00
|
|
|
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
|
2002-04-17 09:01:11 +00:00
|
|
|
#define SC_PATH_TYPE_PATH_PROT 3 /* path of a file containing
|
2007-08-22 18:38:02 +00:00
|
|
|
EnvelopedData objects */
|
2007-01-02 10:04:35 +00:00
|
|
|
#define SC_PATH_TYPE_FROM_CURRENT 4
|
|
|
|
#define SC_PATH_TYPE_PARENT 5
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
|
|
#define SC_MAX_PATH_SIZE 16
|
2006-01-11 23:41:17 +00:00
|
|
|
#define SC_MAX_PATH_STRING_SIZE (SC_MAX_PATH_SIZE * 2 + 1)
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
|
|
typedef struct sc_path {
|
|
|
|
u8 value[SC_MAX_PATH_SIZE];
|
|
|
|
size_t len;
|
2002-12-02 13:42:03 +00:00
|
|
|
|
|
|
|
/* 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.
|
|
|
|
*/
|
2002-04-05 15:06:33 +00:00
|
|
|
int index;
|
2002-12-02 13:42:03 +00:00
|
|
|
int count;
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2010-01-25 16:10:54 +00:00
|
|
|
#define SC_MAX_AC_OPS 20
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
|
|
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;
|
2002-04-17 13:36:35 +00:00
|
|
|
u8 *type_attr;
|
|
|
|
size_t type_attr_len;
|
|
|
|
|
2002-04-05 15:06:33 +00:00
|
|
|
unsigned int magic;
|
|
|
|
} sc_file_t;
|
|
|
|
|
2005-12-28 20:01:43 +00:00
|
|
|
/* 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
|
|
|
|
|
2002-04-05 15:06:33 +00:00
|
|
|
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 */
|
2002-12-23 18:47:27 +00:00
|
|
|
u8 control; /* Set if APDU should go to the reader */
|
2002-04-05 15:06:33 +00:00
|
|
|
|
|
|
|
unsigned int sw1, sw2; /* Status words returned in R-APDU */
|
2005-12-28 20:01:43 +00:00
|
|
|
|
|
|
|
unsigned long flags;
|
2002-04-05 15:06:33 +00:00
|
|
|
} sc_apdu_t;
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2002-04-05 15:06:33 +00:00
|
|
|
#endif
|