Functions

error_quark ()

message_from_rv (rv)

modules_enumerate_objects (modules, attrs, session_options)

modules_enumerate_uri (modules, uri, session_options)

modules_get_slots (modules, token_present)

modules_initialize_registered (cancellable)

modules_initialize_registered_async (cancellable, callback, *user_data)

modules_initialize_registered_finish (result)

modules_object_for_uri (modules, uri, session_options)

modules_objects_for_uri (modules, uri, session_options)

modules_token_for_uri (modules, uri)

modules_tokens_for_uri (modules, uri)

objects_from_handle_array (session, object_handles)

slots_enumerate_objects (slots, match, options)

uri_data_parse (string, flags)

uri_error_quark ()

value_to_boolean (value)

value_to_ulong (value)

Details

Gck.error_quark()[source]
Return type:

int

Gck.message_from_rv(rv)[source]
Parameters:

rv (int) – The PKCS#11 return value to get a message for.

Returns:

The user readable message.

Return type:

str

Get a message for a PKCS#11 return value or error code. Do not pass CKR_OK or other non-errors to this function.

Gck.modules_enumerate_objects(modules, attrs, session_options)[source]
Parameters:
Returns:

A new enumerator, which should be released with GObject.Object.unref().

Return type:

Gck.Enumerator

Setup an enumerator for listing matching objects on the modules.

This call will not block but will return an enumerator immediately.

Gck.modules_enumerate_uri(modules, uri, session_options)[source]
Parameters:
Raises:

GLib.Error

Returns:

A new Gck.Enumerator, or None if an error occurs.

Return type:

Gck.Enumerator

Enumerate objects that match a URI.

This call will not block. Use the [class`Enumerator`] functions in order to get at the actual objects that match.

Gck.modules_get_slots(modules, token_present)[source]
Parameters:
  • modules ([Gck.Module]) – The modules

  • token_present (bool) – Whether to only list slots with token present

Returns:

A list of Gck.Slot objects.

Return type:

[Gck.Slot]

Get a list of slots for across all of the modules.

Gck.modules_initialize_registered(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – optional cancellation object

Raises:

GLib.Error

Returns:

A newly allocated list of Gck.Module objects.

Return type:

[Gck.Module]

Load and initialize all the registered modules.

Gck.modules_initialize_registered_async(cancellable, callback, *user_data)[source]
Parameters:

Load and initialize all the registered modules asynchronously.

Gck.modules_initialize_registered_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – the asynchronous result

Raises:

GLib.Error

Returns:

a list of newly initialized Gck.Module objects

Return type:

[Gck.Module]

Finishes the asynchronous operation to initialize the registered PKCS#11 modules.

Gck.modules_object_for_uri(modules, uri, session_options)[source]
Parameters:
Raises:

GLib.Error

Returns:

A new Gck.Object which should be released with GObject.Object.unref(), or None if no matching object was found.

Return type:

Gck.Object or None

Find an object that matches a URI.

This call can block. Use [func`modules_enumerate_uri`] for a non-blocking version.

Gck.modules_objects_for_uri(modules, uri, session_options)[source]
Parameters:
Raises:

GLib.Error

Returns:

A (possibly empty) list of ``Gck.Object``s.

Return type:

[Gck.Object]

Find objects that match a URI.

This call can block. Use [func`modules_enumerate_uri`] for a non-blocking version.

Gck.modules_token_for_uri(modules, uri)[source]
Parameters:
  • modules ([Gck.Module]) – The modules

  • uri (str) – The URI that the token must match

Raises:

GLib.Error

Returns:

A newly allocated Gck.Slot or None if no such token was found.

Return type:

Gck.Slot

Lookup a token that matches the URI.

Gck.modules_tokens_for_uri(modules, uri)[source]
Parameters:
  • modules ([Gck.Module]) – The modules

  • uri (str) – The URI that the token must match

Raises:

GLib.Error

Returns:

A list of newly allocated Gck.Slot objects.

Return type:

[Gck.Slot]

Lookup a token that matches the URI.

Gck.objects_from_handle_array(session, object_handles)[source]
Parameters:
  • session (Gck.Session) – The session for these objects

  • object_handles ([int]) – The raw object handles.

Returns:

The list of Gck.Object objects.

Return type:

[Gck.Object]

Initialize a list of Gck.Object from raw PKCS#11 handles. The handles argument must contain contiguous CK_OBJECT_HANDLE handles in an array.

Gck.slots_enumerate_objects(slots, match, options)[source]
Parameters:
Returns:

a new enumerator

Return type:

Gck.Enumerator

Setup an enumerator for listing matching objects on the slots.

This call will not block but will return an enumerator immediately.

Gck.uri_data_parse(string, flags)[source]
Parameters:
  • string (str) – the URI to parse.

  • flags (Gck.UriFlags) – the context in which the URI will be used.

Raises:

GLib.Error

Returns:

a newly allocated Gck.UriData; which should be freed with Gck.UriData.free()

Return type:

Gck.UriData

Parse a PKCS#11 URI for use in a given context.

The result will contain the fields that are relevant for the given context. See Gck.UriData for more info. Other fields will be set to None.

Gck.uri_error_quark()[source]
Return type:

int

Gck.value_to_boolean(value)[source]
Parameters:

value (bytes) – memory to convert

Returns:

Whether the conversion was successful.

result:

A location to store the result

Return type:

(bool, result: bool)

Convert CK_BBOOL type memory to a boolean.

Gck.value_to_ulong(value)[source]
Parameters:

value (bytes) – memory to convert

Returns:

Whether the conversion was successful.

result:

A location to store the result

Return type:

(bool, result: int)

Convert CK_ULONG type memory to a boolean.