2002-04-02 13:26:42 +00:00
|
|
|
/*
|
|
|
|
* Card profile information (internal)
|
|
|
|
*
|
2015-10-05 12:06:23 +00:00
|
|
|
* Copyright (C) 2002 Olaf Kirch <okir@suse.de>
|
2017-03-14 21:47:13 +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
|
2002-04-02 13:26:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _OPENSC_PROFILE_H
|
|
|
|
#define _OPENSC_PROFILE_H
|
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2010-03-04 08:14:36 +00:00
|
|
|
#include "libopensc/pkcs15.h"
|
2002-04-02 13:26:42 +00:00
|
|
|
|
|
|
|
#ifndef SC_PKCS15_PROFILE_SUFFIX
|
|
|
|
#define SC_PKCS15_PROFILE_SUFFIX "profile"
|
|
|
|
#endif
|
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
/* Obsolete */
|
2002-04-02 13:26:42 +00:00
|
|
|
struct auth_info {
|
|
|
|
struct auth_info * next;
|
|
|
|
unsigned int type; /* CHV, AUT, PRO */
|
|
|
|
unsigned int ref;
|
|
|
|
size_t key_len;
|
|
|
|
u8 key[32];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct file_info {
|
|
|
|
char * ident;
|
|
|
|
struct file_info * next;
|
|
|
|
struct sc_file * file;
|
2002-04-08 15:50:11 +00:00
|
|
|
unsigned int dont_free;
|
2002-04-02 13:26:42 +00:00
|
|
|
struct file_info * parent;
|
2003-10-13 16:13:12 +00:00
|
|
|
|
|
|
|
/* Template support */
|
|
|
|
struct file_info * instance;
|
|
|
|
struct sc_profile * base_template;
|
|
|
|
unsigned int inst_index;
|
|
|
|
sc_path_t inst_path;
|
2011-01-17 14:51:10 +00:00
|
|
|
|
2011-03-20 12:18:55 +00:00
|
|
|
/* Profile extension dependent on the application ID (sub-profile).
|
2011-01-17 14:51:10 +00:00
|
|
|
* Sub-profile is loaded when binding to the particular application
|
|
|
|
* of the multi-application PKCS#15 card. */
|
2011-03-20 12:18:55 +00:00
|
|
|
char * profile_extension;
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* For now, we assume the PUK always resides
|
|
|
|
* in the same file as the PIN
|
|
|
|
*/
|
|
|
|
struct pin_info {
|
2010-03-05 10:37:11 +00:00
|
|
|
int id;
|
2002-04-02 13:26:42 +00:00
|
|
|
struct pin_info * next;
|
2003-10-13 16:13:12 +00:00
|
|
|
char * file_name; /* obsolete */
|
|
|
|
unsigned int file_offset; /* obsolete */
|
|
|
|
struct file_info * file; /* obsolete */
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2011-06-05 15:46:25 +00:00
|
|
|
struct sc_pkcs15_auth_info pin;
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
typedef struct sc_macro {
|
|
|
|
char * name;
|
|
|
|
struct sc_macro * next;
|
|
|
|
scconf_list * value;
|
|
|
|
} sc_macro_t;
|
|
|
|
|
|
|
|
/* Template support.
|
|
|
|
*
|
|
|
|
* Templates are EFs or entire hierarchies of DFs/EFs.
|
|
|
|
* When instantiating a template, the file IDs of the
|
|
|
|
* EFs and DFs are combined from the value given in the
|
|
|
|
* profile, and the last octet of the pkcs15 ID.
|
|
|
|
*/
|
|
|
|
typedef struct sc_template {
|
|
|
|
char * name;
|
|
|
|
struct sc_template * next;
|
|
|
|
struct sc_profile * data;
|
|
|
|
struct file_info * file;
|
|
|
|
} sc_template_t;
|
|
|
|
|
2003-11-19 20:37:02 +00:00
|
|
|
#define SC_PKCS15INIT_MAX_OPTIONS 16
|
2002-04-02 13:26:42 +00:00
|
|
|
struct sc_profile {
|
2003-11-19 20:37:02 +00:00
|
|
|
char * name;
|
|
|
|
char * options[SC_PKCS15INIT_MAX_OPTIONS];
|
|
|
|
|
2003-10-14 09:57:29 +00:00
|
|
|
sc_card_t * card;
|
2002-04-02 13:26:42 +00:00
|
|
|
char * driver;
|
|
|
|
struct sc_pkcs15init_operations *ops;
|
2004-10-25 10:43:50 +00:00
|
|
|
void * dll; /* handle for dynamic modules */
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2002-04-03 11:52:30 +00:00
|
|
|
struct file_info * mf_info;
|
|
|
|
struct file_info * df_info;
|
2002-04-02 13:26:42 +00:00
|
|
|
struct file_info * ef_list;
|
|
|
|
struct sc_file * df[SC_PKCS15_DF_TYPE_COUNT];
|
|
|
|
|
|
|
|
struct pin_info * pin_list;
|
|
|
|
struct auth_info * auth_list;
|
2003-10-13 16:13:12 +00:00
|
|
|
sc_template_t * template_list;
|
|
|
|
sc_macro_t * macro_list;
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2003-10-13 16:13:12 +00:00
|
|
|
unsigned int pin_domains;
|
2002-04-02 13:26:42 +00:00
|
|
|
unsigned int pin_maxlen;
|
|
|
|
unsigned int pin_minlen;
|
|
|
|
unsigned int pin_pad_char;
|
|
|
|
unsigned int pin_encoding;
|
|
|
|
unsigned int pin_attempts;
|
|
|
|
unsigned int puk_attempts;
|
|
|
|
unsigned int rsa_access_flags;
|
|
|
|
unsigned int dsa_access_flags;
|
|
|
|
|
2003-11-19 20:37:02 +00:00
|
|
|
struct {
|
|
|
|
unsigned int direct_certificates;
|
|
|
|
unsigned int encode_df_length;
|
2005-08-29 20:48:00 +00:00
|
|
|
unsigned int do_last_update;
|
2003-11-19 20:37:02 +00:00
|
|
|
} pkcs15;
|
|
|
|
|
2002-04-02 13:26:42 +00:00
|
|
|
/* PKCS15 information */
|
2003-10-21 11:05:35 +00:00
|
|
|
sc_pkcs15_card_t * p15_spec; /* as given by profile */
|
|
|
|
sc_pkcs15_card_t * p15_data; /* as found on card */
|
2005-08-05 19:07:24 +00:00
|
|
|
/* flag to indicate whether the TokenInfo::lastUpdate field
|
|
|
|
* needs to be updated (in other words: if the card content
|
|
|
|
* has been changed) */
|
|
|
|
int dirty;
|
2009-11-10 18:51:24 +00:00
|
|
|
|
|
|
|
/* PKCS15 object ID style */
|
|
|
|
unsigned int id_style;
|
2012-05-26 07:17:21 +00:00
|
|
|
|
|
|
|
/* Minidriver support style */
|
|
|
|
unsigned int md_style;
|
2002-04-02 13:26:42 +00:00
|
|
|
};
|
|
|
|
|
2004-12-22 09:48:27 +00:00
|
|
|
struct sc_profile *sc_profile_new(void);
|
2011-01-17 15:51:47 +00:00
|
|
|
int sc_profile_load(struct sc_profile *, const char *);
|
|
|
|
int sc_profile_finish(struct sc_profile *, const struct sc_app_info *);
|
|
|
|
void sc_profile_free(struct sc_profile *);
|
|
|
|
int sc_profile_build_pkcs15(struct sc_profile *);
|
2011-06-05 15:46:25 +00:00
|
|
|
void sc_profile_get_pin_info(struct sc_profile *, int, struct sc_pkcs15_auth_info *);
|
2011-01-17 15:51:47 +00:00
|
|
|
int sc_profile_get_pin_id(struct sc_profile *, unsigned int, int *);
|
|
|
|
int sc_profile_get_file(struct sc_profile *, const char *, struct sc_file **);
|
|
|
|
int sc_profile_get_file_by_path(struct sc_profile *, const struct sc_path *, struct sc_file **);
|
|
|
|
int sc_profile_get_path(struct sc_profile *, const char *, struct sc_path *);
|
|
|
|
int sc_profile_get_file_in(struct sc_profile *, const sc_path_t *, const char *, sc_file_t **);
|
|
|
|
int sc_profile_instantiate_template(struct sc_profile *, const char *, const sc_path_t *,
|
|
|
|
const char *, const sc_pkcs15_id_t *, sc_file_t **);
|
|
|
|
int sc_profile_add_file(struct sc_profile *, const char *, sc_file_t *);
|
|
|
|
int sc_profile_get_file_instance(struct sc_profile *, const char *, int, sc_file_t **);
|
2012-04-02 21:40:05 +00:00
|
|
|
int sc_profile_get_pin_id_by_reference(struct sc_profile *, unsigned, int,
|
2011-06-05 15:46:25 +00:00
|
|
|
struct sc_pkcs15_auth_info *);
|
2011-01-17 15:51:47 +00:00
|
|
|
int sc_profile_get_parent(struct sc_profile *profile, const char *, sc_file_t **);
|
2002-04-02 13:26:42 +00:00
|
|
|
|
2005-02-02 10:21:10 +00:00
|
|
|
#ifdef __cplusplus
|
2002-04-19 14:23:31 +00:00
|
|
|
}
|
|
|
|
#endif
|
2002-04-02 13:26:42 +00:00
|
|
|
|
|
|
|
#endif /* _OPENSC_PROFILE_H */
|