![]() |
![]() |
![]() |
p11-kit | ![]() |
---|---|---|---|---|
Top | Description |
void p11_kit_set_progname (const char *progname); void p11_kit_be_quiet (void); void p11_kit_be_loud (void); const char* p11_kit_message (void); void (*p11_kit_destroyer) (void *data); typedef P11KitIter; P11KitIter * p11_kit_iter_new (P11KitUri *uri); void p11_kit_iter_set_session_flags (P11KitIter *iter, CK_FLAGS flags); void p11_kit_iter_add_callback (P11KitIter *iter, p11_kit_iter_callback callback, void *callback_data, p11_kit_destroyer callback_destroy); CK_RV (*p11_kit_iter_callback) (P11KitIter *iter, CK_BBOOL *matches, void *data); void p11_kit_iter_add_filter (P11KitIter *iter, CK_ATTRIBUTE *matching, CK_ULONG count); void p11_kit_iter_begin (P11KitIter *iter, CK_FUNCTION_LIST_PTR *modules); void p11_kit_iter_begin_with (P11KitIter *iter, CK_FUNCTION_LIST_PTR module, CK_SLOT_ID slot, CK_SESSION_HANDLE session); CK_RV p11_kit_iter_next (P11KitIter *iter); CK_FUNCTION_LIST_PTR p11_kit_iter_get_module (P11KitIter *iter); CK_SLOT_ID p11_kit_iter_get_slot (P11KitIter *iter); CK_SESSION_HANDLE p11_kit_iter_get_session (P11KitIter *iter); CK_SESSION_HANDLE p11_kit_iter_keep_session (P11KitIter *iter); CK_OBJECT_HANDLE p11_kit_iter_get_object (P11KitIter *iter); CK_RV p11_kit_iter_load_attributes (P11KitIter *iter, CK_ATTRIBUTE *template, CK_ULONG count); void p11_kit_iter_free (P11KitIter *iter);
API that is not yet stable enough to be enabled by default. In all likelyhood this will be included in the next release. To use this API you must define a MACRO. See the p11-kit.h header for more details.
void p11_kit_set_progname (const char *progname);
Set the program base name that is used by the enable-in
and disable-in
module configuration options.
Normally this is automatically calculated from the program's argument list. You would usually call this before initializing p11-kit modules.
|
the program base name |
void p11_kit_be_quiet (void);
Once this function is called, the p11-kit library will no longer print failure or warning messages to stderr.
void p11_kit_be_loud (void);
Tell the p11-kit library will print failure or warning messages to stderr.
This is the default behavior, but can be changed using p11_kit_be_quiet()
.
const char* p11_kit_message (void);
Gets the failure message for a recently called p11-kit function, which returned a failure code on this thread. Not all functions set this message. Each function that does so, will note it in its documentation.
If the most recent p11-kit function did not fail, then this will return NULL. The string is owned by the p11-kit library and is only valid on the same thread that the failed function executed on.
Returns : |
The last failure message, or NULL .
|
void (*p11_kit_destroyer) (void *data);
A callback called to free a resource.
|
data to destroy |
P11KitIter * p11_kit_iter_new (P11KitUri *uri);
Create a new PKCS#11 iterator for iterating over objects. Only
objects that match the uri
will be returned by the iterator.
Relevant information in uri
is copied, and you need not keep
uri
around.
If no uri
is specified then the iterator will iterate over all
objects, unless otherwise filtered.
|
a PKCS#11 URI to filter on, or NULL . allow-none. |
Returns : |
transfer full. transfer full. |
void p11_kit_iter_set_session_flags (P11KitIter *iter, CK_FLAGS flags);
Set the PKCS#11 session flags to be used when the iterator opens new sessions.
|
the iterator |
|
set of session flags |
void p11_kit_iter_add_callback (P11KitIter *iter, p11_kit_iter_callback callback, void *callback_data, p11_kit_destroyer callback_destroy);
Adds a callback to the iterator which will be called each time that an object is iterated.
These callbacks can also perform filtering. If any callback
indicates through it's matches
argument that
the object should not match, then that object will not be iterated
as far as p11_kit_iter_next()
is concerned.
|
the iterator |
|
a function to call for each iteration |
|
data to pass to the function. allow-none. |
|
used to cleanup the data. allow-none. |
CK_RV (*p11_kit_iter_callback) (P11KitIter *iter, CK_BBOOL *matches, void *data);
A callback setup with p11_kit_iter_add_callback()
. This callback is
called for each object iterated.
If the callback sets matches
to CK_FALSE, then this object is
skipped and not matched by p11_kit_iter_next()
. If you return
anything but CKR_OK, then the iteration is stopped, and
p11_kit_iter_next()
returns the result code.
|
the iterator |
|
whether to match the current object. out. |
|
callback data |
Returns : |
CKR_OK to continue iterating, CKR_CANCEL to stop, or anything else to fail |
void p11_kit_iter_add_filter (P11KitIter *iter, CK_ATTRIBUTE *matching, CK_ULONG count);
Add a filter to limit the objects that the iterator iterates over.
Only objects matching the passed in attributes will be iterated. This function can be called multiple times.
The matching
attributes are copied.
|
the iterator |
|
the attributes that the objects should match. array length=count. |
|
the number of attributes |
void p11_kit_iter_begin (P11KitIter *iter, CK_FUNCTION_LIST_PTR *modules);
Begin iterating PKCS#11 objects in the given modules
.
The modules
arguments should be a null-terminated list of
pointers to the modules' PKCS#11 function pointers.
For each module, all initialized slots will be iterated over, having sessions opened for each of them in turn, and searched for objects matching the search criteria.
|
the iterator |
|
array zero-terminated=1. array zero-terminated=1. |
void p11_kit_iter_begin_with (P11KitIter *iter, CK_FUNCTION_LIST_PTR module, CK_SLOT_ID slot, CK_SESSION_HANDLE session);
Begin iterating PKCS#11 objects in the given module
.
If slot
is non-zero then the iteration will be limited to that
slot.
If session
is non-zero then the iteration will be limited to
objects visible through that session, which implies that they
are also limited to the slot which the session was opened for.
|
the iterator |
|
the module to iterate over |
|
the slot to iterate objects in, or zero. allow-none. |
|
the session to search for objects on, or zero. allow-none. |
CK_RV p11_kit_iter_next (P11KitIter *iter);
Iterate to the next matching object.
To access the object, session and so on, use the p11_kit_iter_get_object()
,
p11_kit_iter_get_session()
, and p11_kit_iter_get_module()
functions.
This call must only be called after either p11_kit_iter_begin()
or p11_kit_iter_begin_with()
have been called.
Objects which are skipped by callbacks will not be returned here as matching objects.
|
the iterator |
Returns : |
CKR_OK if an object matched, CKR_CANCEL if no more objects, or another error |
CK_FUNCTION_LIST_PTR p11_kit_iter_get_module (P11KitIter *iter);
Get the module function pointers for the current matching object.
This can only be called after p11_kit_iter_next()
succeeds.
|
the iterator |
Returns : |
the module which the current matching object is in |
CK_SLOT_ID p11_kit_iter_get_slot (P11KitIter *iter);
Get the slot which the current matching object is on.
This can only be called after p11_kit_iter_next()
succeeds.
|
the iterator |
Returns : |
the slot of the current matching object |
CK_SESSION_HANDLE p11_kit_iter_get_session (P11KitIter *iter);
Get the session which the current matching object is acessible through.
This can only be called after p11_kit_iter_next()
succeeds.
The session may be closed after the next p11_kit_iter_next()
call
unless p11_kit_iter_keep_session()
is called.
|
the iterator |
Returns : |
the slot of the current matching object |
CK_SESSION_HANDLE p11_kit_iter_keep_session (P11KitIter *iter);
After calling this function the session open for iterating
the current object will not be automatically closed by
the iterator after later calls to p11_kit_iter_next()
or
p11_kit_iter_free()
.
It is the callers responsibility to close this session, after the iterator has been freed. The session may still be used by the iterator if further iterations are performed.
This can only be called after p11_kit_iter_next()
succeeds.
|
the iterator |
Returns : |
the current session |
CK_OBJECT_HANDLE p11_kit_iter_get_object (P11KitIter *iter);
Get the current matching object.
This can only be called after p11_kit_iter_next()
succeeds.
|
the iterator |
Returns : |
the current matching object |
CK_RV p11_kit_iter_load_attributes (P11KitIter *iter, CK_ATTRIBUTE *template, CK_ULONG count);
Retrieve attributes for the current matching object.
Each attribute in the array will be filled in with the value
of that attribute retrieved from the object. After use the
attribute value memory pointed to by the pValue
of each attribute should be freed with the free()
function.
If the pValue
of an attribute is not NULL
passed
to this function, then it will be passed to
realloc()
to allocate the correct amount
of space for the attribute value.
If any attribute is not present on the object, or is sensitive and
cannot be retrieved, then the pValue
will be NULL.
If pValue
was not NULL
when passed to this function
then it will be freed with free()
. In these
cases CKR_OK
is returned.
This can only be called after p11_kit_iter_next()
succeeds.
|
the iterator |
|
the attributes to load. array length=count. inout length=count. |
|
the number of attributes |
Returns : |
CKR_OK or a failure code |