Changeset 3404
- Timestamp:
- 03/06/08 15:04:29 (10 months ago)
- Location:
- trunk
- Files:
-
- 5 modified
-
etc/opensc.conf.in (modified) (1 diff)
-
src/pkcs11/misc.c (modified) (2 diffs)
-
src/pkcs11/pkcs11-global.c (modified) (7 diffs)
-
src/pkcs11/sc-pkcs11.h (modified) (3 diffs)
-
src/pkcs11/slot.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/etc/opensc.conf.in
r3311 r3404 295 295 app opensc-pkcs11 { 296 296 pkcs11 { 297 # Maximum Number of virtual slots. 298 # If there are more slots than defined here, 299 # the remaining slots will be hidden from PKCS#11. 300 max_virtual_slots = 8; 301 297 302 # Maximum number of slots per smart card. 298 303 # If the card has fewer keys than defined here, 299 304 # the remaining number of slots will be empty. 300 #301 # Note that there is currently a compile time302 # maximum on the overall number of slots303 # the pkcs11 module is able to handle.304 305 num_slots = 4; 305 306 -
trunk/src/pkcs11/misc.c
r3176 r3404 318 318 319 319 /* Set defaults */ 320 conf->pkcs11_max_virtual_slots = SC_PKCS11_DEF_MAX_VIRTUAL_SLOTS; 320 321 conf->num_slots = SC_PKCS11_DEF_SLOTS_PER_CARD; 321 322 conf->hide_empty_tokens = 0; … … 336 337 return; 337 338 339 conf->pkcs11_max_virtual_slots = scconf_get_int(conf_block, "max_virtual_slots", conf->pkcs11_max_virtual_slots); 338 340 conf->num_slots = scconf_get_int(conf_block, "num_slots", conf->num_slots); 339 341 conf->hide_empty_tokens = scconf_get_bool(conf_block, "hide_empty_tokens", 0); -
trunk/src/pkcs11/pkcs11-global.c
r3402 r3404 32 32 sc_context_t *context = NULL; 33 33 struct sc_pkcs11_pool session_pool; 34 struct sc_pkcs11_slot virtual_slots[SC_PKCS11_MAX_VIRTUAL_SLOTS];34 struct sc_pkcs11_slot *virtual_slots = NULL; 35 35 struct sc_pkcs11_card card_table[SC_PKCS11_MAX_READERS]; 36 36 struct sc_pkcs11_config sc_pkcs11_conf; … … 193 193 194 194 rv = sc_pkcs11_init_lock((CK_C_INITIALIZE_ARGS_PTR) pInitArgs); 195 if (rv != CKR_OK) { 196 sc_release_context(context); 197 context = NULL; 198 } 195 if (rv != CKR_OK) 196 goto out; 199 197 200 198 /* set context options */ … … 214 212 215 213 first_free_slot = 0; 214 virtual_slots = malloc(sizeof (*virtual_slots) * sc_pkcs11_conf.pkcs11_max_virtual_slots); 215 if (virtual_slots == NULL) { 216 rv = CKR_HOST_MEMORY; 217 goto out; 218 } 216 219 pool_initialize(&session_pool, POOL_TYPE_SESSION); 217 for (i=0; i< SC_PKCS11_MAX_VIRTUAL_SLOTS; i++)220 for (i=0; i<sc_pkcs11_conf.pkcs11_max_virtual_slots; i++) 218 221 slot_initialize(i, &virtual_slots[i]); 219 222 for (i=0; i<SC_PKCS11_MAX_READERS; i++) … … 226 229 if (context != NULL) 227 230 sc_debug(context, "C_Initialize: result = %d\n", rv); 231 232 if (rv != CKR_OK) { 233 if (context != NULL) { 234 sc_release_context(context); 235 context = NULL; 236 } 237 /* Release and destroy the mutex */ 238 sc_pkcs11_free_lock(); 239 } 240 228 241 return rv; 229 242 } … … 249 262 for (i=0; i < (int)sc_ctx_get_reader_count(context); i++) 250 263 card_removed(i); 264 265 if (virtual_slots) { 266 free(virtual_slots); 267 virtual_slots = NULL; 268 } 251 269 252 270 sc_release_context(context); … … 303 321 CK_ULONG_PTR pulCount) /* receives the number of slots */ 304 322 { 305 CK_SLOT_ID found[ SC_PKCS11_MAX_VIRTUAL_SLOTS];323 CK_SLOT_ID found[sc_pkcs11_conf.pkcs11_max_virtual_slots]; 306 324 int i; 307 325 CK_ULONG numMatches; … … 322 340 323 341 numMatches = 0; 324 for (i=0; i< SC_PKCS11_MAX_VIRTUAL_SLOTS; i++) {342 for (i=0; i<sc_pkcs11_conf.pkcs11_max_virtual_slots; i++) { 325 343 slot = &virtual_slots[i]; 326 344 -
trunk/src/pkcs11/sc-pkcs11.h
r3086 r3404 61 61 #endif 62 62 63 #define SC_PKCS11_ MAX_VIRTUAL_SLOTS 863 #define SC_PKCS11_DEF_MAX_VIRTUAL_SLOTS 8 64 64 #define SC_PKCS11_DEF_SLOTS_PER_CARD 4 65 65 #define SC_PKCS11_MAX_READERS SC_MAX_READERS … … 91 91 92 92 struct sc_pkcs11_config { 93 unsigned int pkcs11_max_virtual_slots; 93 94 unsigned int num_slots; 94 95 unsigned char hide_empty_tokens; … … 336 337 extern struct sc_context *context; 337 338 extern struct sc_pkcs11_pool session_pool; 338 extern struct sc_pkcs11_slot virtual_slots[SC_PKCS11_MAX_VIRTUAL_SLOTS];339 extern struct sc_pkcs11_slot *virtual_slots; 339 340 extern struct sc_pkcs11_card card_table[SC_PKCS11_MAX_READERS]; 340 341 extern struct sc_pkcs11_config sc_pkcs11_conf; -
trunk/src/pkcs11/slot.c
r3086 r3404 64 64 avail = sc_pkcs11_conf.num_slots; 65 65 66 if (first_free_slot + avail > SC_PKCS11_MAX_VIRTUAL_SLOTS)67 avail = SC_PKCS11_MAX_VIRTUAL_SLOTS- first_free_slot;66 if (first_free_slot + avail > sc_pkcs11_conf.pkcs11_max_virtual_slots) 67 avail = sc_pkcs11_conf.pkcs11_max_virtual_slots - first_free_slot; 68 68 card->first_slot = first_free_slot; 69 69 card->max_slots = avail; … … 166 166 CK_SLOT_ID id; 167 167 168 for (id = 0; id < SC_PKCS11_MAX_VIRTUAL_SLOTS; id++)168 for (id = 0; id < sc_pkcs11_conf.pkcs11_max_virtual_slots; id++) 169 169 virtual_slots[id].events = 0; 170 170 } … … 185 185 sc_debug(context, "%d: smart card removed\n", reader); 186 186 187 for (i=0; i< SC_PKCS11_MAX_VIRTUAL_SLOTS; i++) {187 for (i=0; i<sc_pkcs11_conf.pkcs11_max_virtual_slots; i++) { 188 188 if (virtual_slots[i].card && 189 189 virtual_slots[i].card->reader == reader) … … 246 246 return CKR_CRYPTOKI_NOT_INITIALIZED; 247 247 248 if (id < 0 || id >= SC_PKCS11_MAX_VIRTUAL_SLOTS)248 if (id < 0 || id >= sc_pkcs11_conf.pkcs11_max_virtual_slots) 249 249 return CKR_SLOT_ID_INVALID; 250 250 … … 325 325 326 326 card_detect_all(); 327 for (id = 0; id < SC_PKCS11_MAX_VIRTUAL_SLOTS; id++) {327 for (id = 0; id < sc_pkcs11_conf.pkcs11_max_virtual_slots; id++) { 328 328 slot = &virtual_slots[id]; 329 329 if ((slot->events & SC_EVENT_CARD_INSERTED)
