diff options
author | Stef Walter <stefw@gnome.org> | 2013-01-21 11:04:06 +0100 |
---|---|---|
committer | Stef Walter <stefw@gnome.org> | 2013-02-05 14:54:53 +0100 |
commit | e5816187231ce27e5f634995e62c1d3ae5c5b2f1 (patch) | |
tree | 566db316642a3d87787d1cfbe98e795b32ad1916 /p11-kit | |
parent | 67ce28e9d9ec1528c9b762b0912d6a7e339fbcd5 (diff) |
Allow internal use of token and module info matching
Diffstat (limited to 'p11-kit')
-rw-r--r-- | p11-kit/private.h | 6 | ||||
-rw-r--r-- | p11-kit/uri.c | 55 |
2 files changed, 41 insertions, 20 deletions
diff --git a/p11-kit/private.h b/p11-kit/private.h index 7348e43..f862975 100644 --- a/p11-kit/private.h +++ b/p11-kit/private.h @@ -58,4 +58,10 @@ const char * _p11_get_progname_unlocked (void); void _p11_set_progname_unlocked (const char *progname); +int p11_match_uri_module_info (CK_INFO_PTR one, + CK_INFO_PTR two); + +int p11_match_uri_token_info (CK_TOKEN_INFO_PTR one, + CK_TOKEN_INFO_PTR two); + #endif /* __P11_KIT_PRIVATE_H__ */ diff --git a/p11-kit/uri.c b/p11-kit/uri.c index 8b16e46..826c2c4 100644 --- a/p11-kit/uri.c +++ b/p11-kit/uri.c @@ -40,6 +40,7 @@ #include "debug.h" #include "library.h" #include "pkcs11.h" +#include "private.h" #include "p11-kit.h" #include "uri.h" @@ -314,6 +315,20 @@ p11_kit_uri_get_module_info (P11KitUri *uri) return &uri->module; } +int +p11_match_uri_module_info (CK_INFO_PTR one, + CK_INFO_PTR two) +{ + return (match_struct_string (one->libraryDescription, + two->libraryDescription, + sizeof (one->libraryDescription)) && + match_struct_string (one->manufacturerID, + two->manufacturerID, + sizeof (one->manufacturerID)) && + match_struct_version (&one->libraryVersion, + &two->libraryVersion)); +} + /** * p11_kit_uri_match_module_info: * @uri: the URI @@ -337,14 +352,7 @@ p11_kit_uri_match_module_info (P11KitUri *uri, CK_INFO_PTR info) if (uri->unrecognized) return 0; - return (match_struct_string (uri->module.libraryDescription, - info->libraryDescription, - sizeof (info->libraryDescription)) && - match_struct_string (uri->module.manufacturerID, - info->manufacturerID, - sizeof (info->manufacturerID)) && - match_struct_version (&uri->module.libraryVersion, - &info->libraryVersion)); + return p11_match_uri_module_info (&uri->module, info); } /** @@ -370,6 +378,24 @@ p11_kit_uri_get_token_info (P11KitUri *uri) return &uri->token; } +int +p11_match_uri_token_info (CK_TOKEN_INFO_PTR one, + CK_TOKEN_INFO_PTR two) +{ + return (match_struct_string (one->label, + two->label, + sizeof (one->label)) && + match_struct_string (one->manufacturerID, + two->manufacturerID, + sizeof (one->manufacturerID)) && + match_struct_string (one->model, + two->model, + sizeof (one->model)) && + match_struct_string (one->serialNumber, + two->serialNumber, + sizeof (one->serialNumber))); +} + /** * p11_kit_uri_match_token_info: * @uri: the URI @@ -394,18 +420,7 @@ p11_kit_uri_match_token_info (P11KitUri *uri, CK_TOKEN_INFO_PTR token_info) if (uri->unrecognized) return 0; - return (match_struct_string (uri->token.label, - token_info->label, - sizeof (token_info->label)) && - match_struct_string (uri->token.manufacturerID, - token_info->manufacturerID, - sizeof (token_info->manufacturerID)) && - match_struct_string (uri->token.model, - token_info->model, - sizeof (token_info->model)) && - match_struct_string (uri->token.serialNumber, - token_info->serialNumber, - sizeof (token_info->serialNumber))); + return p11_match_uri_token_info (&uri->token, token_info); } /** |