diff options
Diffstat (limited to 'src/slot.c')
-rw-r--r-- | src/slot.c | 20 |
1 files changed, 20 insertions, 0 deletions
@@ -15,6 +15,7 @@ static CK_SLOT_INFO_PTR slot_info = NULL; static CK_TOKEN_INFO_PTR slot_token_info = NULL; static CK_ULONG *slot_mech_count; +static CK_MECHANISM_TYPE_PTR *slot_mech_type; static CK_MECHANISM_INFO_PTR *slot_mech_info; /* ---------------------------------------------------------------------------------- @@ -288,6 +289,8 @@ test_slot_mechanisms(void) slot_mech_info = calloc(p11t_slot_count, sizeof(CK_MECHANISM_INFO_PTR)); assert(slot_mech_info); + slot_mech_type = calloc(p11t_slot_count, sizeof(CK_MECHANISM_TYPE_PTR)); + assert(slot_mech_type); for(i = 0; i < p11t_slot_count; ++i) { @@ -377,6 +380,7 @@ test_slot_mechanisms(void) slot_mech_info[i] = mech_info; } + slot_mech_type[i] = mech_list; slot_mech_count[i] = mech_count; } } @@ -446,3 +450,19 @@ p11t_slot_get_token_info(CK_SLOT_ID slot) return NULL; } + +void +p11t_slot_for_each_mech(CK_MECHANISM_TYPE mech_type, + P11tSlotMechCallback callback) +{ + CK_ULONG i, j; + + for(i = 0; i < p11t_slot_count; ++i) + { + for(j = 0; j < slot_mech_count[i]; ++j) + { + if(mech_type == CK_INVALID || slot_mech_type[i][j] == mech_type) + (callback)(slot_ids[i], slot_mech_type[i][j], &slot_mech_info[i][j]); + } + } +} |