Gck.Object

g GObject.Object GObject.Object Gck.Object Gck.Object GObject.Object->Gck.Object

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

from_handle (session, object_handle)

cache_lookup (attr_types, cancellable)

cache_lookup_async (attr_types, cancellable, callback, *user_data)

cache_lookup_finish (result)

destroy (cancellable)

destroy_async (cancellable, callback, *user_data)

destroy_finish (result)

equal (object2)

get_async (attr_types, cancellable, callback, *user_data)

get_data (attr_type, cancellable)

get_data_async (attr_type, allocator, cancellable, callback, *user_data)

get_data_finish (result)

get_finish (result)

get_full (attr_types, cancellable)

get_handle ()

get_module ()

get_session ()

get_template (attr_type, cancellable)

get_template_async (attr_type, cancellable, callback, *user_data)

get_template_finish (result)

hash ()

set (attrs, cancellable)

set_async (attrs, cancellable, callback, *user_data)

set_finish (result)

set_template (attr_type, attrs, cancellable)

set_template_async (attr_type, attrs, cancellable, callback, *user_data)

set_template_finish (result)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

handle

int

r/w/co

PKCS11 Object Handle

module

Gck.Module

r/w/co

PKCS11 Module

session

Gck.Session

r/w/co

PKCS11 Session to make calls on

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

reserved

[object]

r

Class Details

class Gck.Object(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gck.ObjectClass

Holds a handle to a PKCS11 object such as a key or certificate. Token objects are stored on the token persistently. Others are transient and are called session objects.

classmethod from_handle(session, object_handle)[source]
Parameters:
  • session (Gck.Session) – The session through which this object is accessed or created.

  • object_handle (int) – The raw CK_OBJECT_HANDLE of the object.

Returns:

The new object

Return type:

Gck.Object

Initialize a Gck.Object from a raw PKCS#11 handle. Normally you would use [method`Session`.create_object] or [method`Session`.find_objects] to access objects.

cache_lookup(attr_types, cancellable)[source]
Parameters:
  • attr_types ([int]) – the types of attributes to update

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

Raises:

GLib.Error

Returns:

the attributes retrieved or None on failure

Return type:

Gck.Attributes

Lookup attributes in the cache, or retrieve them from the object if necessary.

If self is a Gck.ObjectCache then this will lookup the attributes there first if available, otherwise will read them from the object and update the cache.

If self is not a Gck.ObjectCache, then the attributes will simply be read from the object.

This may block, use the asynchronous version when this is not desirable

cache_lookup_async(attr_types, cancellable, callback, *user_data)[source]
Parameters:

Lookup attributes in the cache, or retrieve them from the object if necessary.

If self is a Gck.ObjectCache then this will lookup the attributes there first if available, otherwise will read them from the object and update the cache.

If self is not a Gck.ObjectCache, then the attributes will simply be read from the object.

This will return immediately and complete asynchronously

cache_lookup_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – the asynchrounous result passed to the callback

Raises:

GLib.Error

Returns:

the attributes retrieved or None on failure

Return type:

Gck.Attributes

Complete an operation to lookup attributes in the cache or retrieve them from the object if necessary.

destroy(cancellable)[source]
Parameters:

cancellable (Gio.Cancellable or None) – Optional cancellable object, or None to ignore.

Raises:

GLib.Error

Returns:

Whether the call was successful or not.

Return type:

bool

Destroy a PKCS#11 object, deleting it from storage or the session. This call may block for an indefinite period.

destroy_async(cancellable, callback, *user_data)[source]
Parameters:

Destroy a PKCS#11 object, deleting it from storage or the session. This call will return immediately and complete asynchronously.

destroy_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result of the destory operation passed to the callback.

Raises:

GLib.Error

Returns:

Whether the object was destroyed successfully or not.

Return type:

bool

Get the status of the operation to destroy a PKCS#11 object, begun with Gck.Object.destroy_async().

equal(object2)[source]
Parameters:

object2 (Gck.Object) – a pointer to the second Gck.Object

Returns:

True if object1 and object2 are equal. False if either is not a Gck.Object.

Return type:

bool

Checks equality of two objects. Two Gck.Object objects can point to the same underlying PKCS#11 object.

get_async(attr_types, cancellable, callback, *user_data)[source]
Parameters:

Get the specified attributes from the object. The attributes will be cleared of their current values, and new attributes will be stored. The attributes should not be accessed in any way except for referencing and unreferencing them until Gck.Object.get_finish() is called.

This call returns immediately and completes asynchronously.

get_data(attr_type, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

the resulting PKCS#11 attribute data, or None if an error occurred

Return type:

bytes

Get the data for the specified attribute from the object. For convenience the returned data has a null terminator.

This call may block for an indefinite period.

get_data_async(attr_type, allocator, cancellable, callback, *user_data)[source]
Parameters:

Get the data for the specified attribute from the object.

This call will return immediately and complete asynchronously.

get_data_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result passed to the callback.

Raises:

GLib.Error

Returns:

The PKCS#11 attribute data or None if an error occurred.

Return type:

bytes

Get the result of an operation to get attribute data from an object. For convenience the returned data has an extra null terminator, not included in the returned length.

get_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result passed to the callback.

Raises:

GLib.Error

Returns:

The filled in attributes structure if successful or None if not successful.

Return type:

Gck.Attributes

Get the result of a get operation and return specified attributes from the object.

No extra references are added to the returned attributes pointer.

get_full(attr_types, cancellable)[source]
Parameters:
  • attr_types ([int]) – the types of the attributes to get

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

Raises:

GLib.Error

Returns:

a pointer to the filled in attributes if successful, or None if not

Return type:

Gck.Attributes

Get the specified attributes from the object. This call may block for an indefinite period.

No extra references are added to the returned attributes pointer. During this call you may not access the attributes in any way.

get_handle()[source]
Returns:

the raw CK_OBJECT_HANDLE object handle

Return type:

int

Get the raw PKCS#11 handle of a Gck.Object.

get_module()[source]
Returns:

the module, which should be unreffed after use

Return type:

Gck.Module

Get the PKCS#11 module to which this object belongs.

get_session()[source]
Returns:

the assigned session, which must be unreffed after use

Return type:

Gck.Session

Get the PKCS#11 session assigned to make calls on when operating on this object.

This will only return a session if it was set explitly on this object. By default an object will open and close sessions appropriate for its calls.

get_template(attr_type, cancellable)[source]
Parameters:
  • attr_type (int) – The template attribute type.

  • cancellable (Gio.Cancellable or None) – Optional cancellation object, or None.

Raises:

GLib.Error

Returns:

the resulting PKCS#11 attribute template, or None if an error occurred

Return type:

Gck.Attributes

Get an attribute template from the object. The attr_type must be for an attribute which returns a template.

This call may block for an indefinite period.

get_template_async(attr_type, cancellable, callback, *user_data)[source]
Parameters:

Get an attribute template from the object. The attr_type must be for an attribute which returns a template.

This call will return immediately and complete asynchronously.

get_template_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result passed to the callback.

Raises:

GLib.Error

Returns:

the resulting PKCS#11 attribute template, or None if an error occurred

Return type:

Gck.Attributes

Get the result of an operation to get attribute template from an object.

hash()[source]
Returns:

An integer that can be used as a hash value, or 0 if invalid.

Return type:

int

Create a hash value for the Gck.Object.

This function is intended for easily hashing a Gck.Object to add to a GLib.HashTable or similar data structure.

set(attrs, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

Whether the call was successful or not.

Return type:

bool

Set PKCS#11 attributes on an object. This call may block for an indefinite period.

If the attrs Gck.Attributes is floating, it is consumed.

set_async(attrs, cancellable, callback, *user_data)[source]
Parameters:

Set PKCS#11 attributes on an object. This call will return immediately and completes asynchronously.

If the attrs Gck.Attributes is floating, it is consumed.

set_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result of the destory operation passed to the callback.

Raises:

GLib.Error

Returns:

Whether the attributes were successfully set on the object or not.

Return type:

bool

Get the status of the operation to set attributes on a PKCS#11 object, begun with Gck.Object.set_async().

set_template(attr_type, attrs, cancellable)[source]
Parameters:
Raises:

GLib.Error

Returns:

True if the operation succeeded.

Return type:

bool

Set an attribute template on the object. The attr_type must be for an attribute which contains a template.

If the attrs Gck.Attributes is floating, it is consumed.

This call may block for an indefinite period.

set_template_async(attr_type, attrs, cancellable, callback, *user_data)[source]
Parameters:

Set an attribute template on the object. The attr_type must be for an attribute which contains a template.

If the attrs Gck.Attributes is floating, it is consumed.

This call will return immediately and complete asynchronously.

set_template_finish(result)[source]
Parameters:

result (Gio.AsyncResult) – The result passed to the callback.

Raises:

GLib.Error

Returns:

True if the operation succeeded.

Return type:

bool

Get the result of an operation to set attribute template on an object.

Property Details

Gck.Object.props.handle
Name:

handle

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The raw PKCS11 handle for this object.

Gck.Object.props.module
Name:

module

Type:

Gck.Module

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The Gck.Module that this object belongs to.

Gck.Object.props.session
Name:

session

Type:

Gck.Session

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

The PKCS11 session to make calls on when this object needs to perform operations on itself.

If this is None then a new session is opened for each operation, such as gck_object_get(), Gck.Object.set() or Gck.Object.destroy().