1 /* 2 * Card profile information (internal) 3 * 4 * Copyright (C) 2002 Olaf Kirch <okir@suse.de> 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2.1 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 */ 20 21 #ifndef _OPENSC_PROFILE_H 22 #define _OPENSC_PROFILE_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #include "libopensc/pkcs15.h" 29 30 #ifndef SC_PKCS15_PROFILE_SUFFIX 31 #define SC_PKCS15_PROFILE_SUFFIX "profile" 32 #endif 33 34 /* Obsolete */ 35 struct auth_info { 36 struct auth_info * next; 37 unsigned int type; /* CHV, AUT, PRO */ 38 unsigned int ref; 39 size_t key_len; 40 u8 key[32]; 41 }; 42 43 struct file_info { 44 char * ident; 45 struct file_info * next; 46 struct sc_file * file; 47 unsigned int dont_free; 48 struct file_info * parent; 49 50 /* Template support */ 51 struct file_info * instance; 52 struct sc_profile * base_template; 53 unsigned int inst_index; 54 sc_path_t inst_path; 55 56 /* Profile extension dependent on the application ID (sub-profile). 57 * Sub-profile is loaded when binding to the particular application 58 * of the multi-application PKCS#15 card. */ 59 char * profile_extension; 60 }; 61 62 /* For now, we assume the PUK always resides 63 * in the same file as the PIN 64 */ 65 struct pin_info { 66 int id; 67 struct pin_info * next; 68 char * file_name; /* obsolete */ 69 unsigned int file_offset; /* obsolete */ 70 struct file_info * file; /* obsolete */ 71 72 struct sc_pkcs15_auth_info pin; 73 }; 74 75 typedef struct sc_macro { 76 char * name; 77 struct sc_macro * next; 78 scconf_list * value; 79 } sc_macro_t; 80 81 /* Template support. 82 * 83 * Templates are EFs or entire hierarchies of DFs/EFs. 84 * When instantiating a template, the file IDs of the 85 * EFs and DFs are combined from the value given in the 86 * profile, and the last octet of the pkcs15 ID. 87 */ 88 typedef struct sc_template { 89 char * name; 90 struct sc_template * next; 91 struct sc_profile * data; 92 struct file_info * file; 93 } sc_template_t; 94 95 #define SC_PKCS15INIT_MAX_OPTIONS 16 96 struct sc_profile { 97 char * name; 98 char * options[SC_PKCS15INIT_MAX_OPTIONS]; 99 100 sc_card_t * card; 101 char * driver; 102 struct sc_pkcs15init_operations *ops; 103 void * dll; /* handle for dynamic modules */ 104 105 struct file_info * mf_info; 106 struct file_info * df_info; 107 struct file_info * ef_list; 108 struct sc_file * df[SC_PKCS15_DF_TYPE_COUNT]; 109 110 struct pin_info * pin_list; 111 struct auth_info * auth_list; 112 sc_template_t * template_list; 113 sc_macro_t * macro_list; 114 115 unsigned int pin_domains; 116 unsigned int pin_maxlen; 117 unsigned int pin_minlen; 118 unsigned int pin_pad_char; 119 unsigned int pin_encoding; 120 unsigned int pin_attempts; 121 unsigned int puk_attempts; 122 unsigned int rsa_access_flags; 123 unsigned int dsa_access_flags; 124 125 struct { 126 unsigned int direct_certificates; 127 unsigned int encode_df_length; 128 unsigned int do_last_update; 129 } pkcs15; 130 131 /* PKCS15 information */ 132 sc_pkcs15_card_t * p15_spec; /* as given by profile */ 133 sc_pkcs15_card_t * p15_data; /* as found on card */ 134 /* flag to indicate whether the TokenInfo::lastUpdate field 135 * needs to be updated (in other words: if the card content 136 * has been changed) */ 137 int dirty; 138 139 /* PKCS15 object ID style */ 140 unsigned int id_style; 141 142 /* Minidriver support style */ 143 unsigned int md_style; 144 }; 145 146 struct sc_profile *sc_profile_new(void); 147 int sc_profile_load(struct sc_profile *, const char *); 148 int sc_profile_finish(struct sc_profile *, const struct sc_app_info *); 149 void sc_profile_free(struct sc_profile *); 150 int sc_profile_build_pkcs15(struct sc_profile *); 151 void sc_profile_get_pin_info(struct sc_profile *, int, struct sc_pkcs15_auth_info *); 152 int sc_profile_get_pin_id(struct sc_profile *, unsigned int, int *); 153 int sc_profile_get_file(struct sc_profile *, const char *, struct sc_file **); 154 int sc_profile_get_file_by_path(struct sc_profile *, const struct sc_path *, struct sc_file **); 155 int sc_profile_get_path(struct sc_profile *, const char *, struct sc_path *); 156 int sc_profile_get_file_in(struct sc_profile *, const sc_path_t *, const char *, sc_file_t **); 157 int sc_profile_instantiate_template(struct sc_profile *, const char *, const sc_path_t *, 158 const char *, const sc_pkcs15_id_t *, sc_file_t **); 159 int sc_profile_add_file(struct sc_profile *, const char *, sc_file_t *); 160 int sc_profile_get_file_instance(struct sc_profile *, const char *, int, sc_file_t **); 161 int sc_profile_get_pin_id_by_reference(struct sc_profile *, unsigned, int, 162 struct sc_pkcs15_auth_info *); 163 int sc_profile_get_parent(struct sc_profile *profile, const char *, sc_file_t **); 164 165 #ifdef __cplusplus 166 } 167 #endif 168 169 #endif /* _OPENSC_PROFILE_H */ 170