summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2017-03-11 12:08:21 +0100
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2017-03-11 12:11:54 +0100
commit975daa6c603bd202c5d75f9481dd2b6f516af85d (patch)
treeb392c9f166794fb32fafcc23a7d50d35b1f21967
parent6dc53de2d42db8798c78872c390e547b41e81720 (diff)
downloadgnutls-tmp-optimize-pkcs11-access.tar.gz
pkcs11: during scan, leave the provider loop asaptmp-optimize-pkcs11-access
This optimizes access when multiple provider modules are available, by avoiding scanning irrelevant ones. Signed-off-by: Nikos Mavrogiannopoulos <nmav@gnutls.org>
-rw-r--r--lib/pkcs11.c30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/pkcs11.c b/lib/pkcs11.c
index 4bd2f3f232..a7b2c2b2f6 100644
--- a/lib/pkcs11.c
+++ b/lib/pkcs11.c
@@ -1202,6 +1202,11 @@ pkcs11_find_slot(struct ck_function_list **module, ck_slot_id_t * slot,
if (providers[x].active == 0)
continue;
+ if (!p11_kit_uri_match_module_info(info,
+ &providers[x].info)) {
+ continue;
+ }
+
nslots = sizeof(slots) / sizeof(slots[0]);
ret = scan_slots(&providers[x], slots, &nslots);
if (ret < 0) {
@@ -1219,17 +1224,12 @@ pkcs11_find_slot(struct ck_function_list **module, ck_slot_id_t * slot,
continue;
}
- if (pkcs11_get_slot_info
- (providers[x].module, slots[z],
- &sinfo) != CKR_OK) {
+ if (!p11_kit_uri_match_token_info(info, &tinfo)) {
continue;
}
- if (!p11_kit_uri_match_token_info
- (info, &tinfo)
- || !p11_kit_uri_match_module_info(info,
- &providers
- [x].info)) {
+ if (pkcs11_get_slot_info
+ (providers[x].module, slots[z], &sinfo) != CKR_OK) {
continue;
}
@@ -1327,6 +1327,10 @@ _pkcs11_traverse_tokens(find_func_t find_func, void *input,
if (flags & SESSION_TRUSTED && providers[x].trusted == 0)
continue;
+ if (info && !p11_kit_uri_match_module_info(info, &providers[x].info)) {
+ continue;
+ }
+
nslots = sizeof(slots) / sizeof(slots[0]);
ret = scan_slots(&providers[x], slots, &nslots);
if (ret < 0) {
@@ -1344,17 +1348,13 @@ _pkcs11_traverse_tokens(find_func_t find_func, void *input,
continue;
}
- if (pkcs11_get_slot_info(module, slots[z],
- &l_sinfo) != CKR_OK) {
+ if (info && !p11_kit_uri_match_token_info(info, &l_tinfo)) {
continue;
}
- if (info != NULL) {
- if (!p11_kit_uri_match_token_info(info, &l_tinfo) ||
- !p11_kit_uri_match_module_info(info, &providers
- [x].info)) {
+ if (pkcs11_get_slot_info(module, slots[z],
+ &l_sinfo) != CKR_OK) {
continue;
- }
}
rv = (module)->C_OpenSession(slots[z],