Gck.Attributes

Fields

None

Methods

class

new (reserved)

at (index)

contains (match)

count ()

dump ()

find (attr_type)

find_boolean (attr_type)

find_date (attr_type)

find_string (attr_type)

find_ulong (attr_type)

ref ()

ref_sink ()

to_string ()

unref ()

Details

class Gck.Attributes

A set of [struct`Attribute`] structures.

These attributes contain information about a PKCS11 object. Use [method`Object`.get] or [method`Object`.set] to set and retrieve attributes on an object.

classmethod new(reserved)[source]
Parameters:

reserved (int) – Should be set to always be [constINVALID]

Returns:

a floating reference to the new attributes array; when done with the array release it with Gck.Attributes.unref().

Return type:

Gck.Attributes

Create a new empty GckAttributes array.

The returned set of attributes is floating, and should either be passed to another gck library function which consumes this floating reference, or if you wish to keep these attributes around you should ref them with Gck.Attributes.ref_sink() and unref them later with Gck.Attributes.unref().

at(index)[source]
Parameters:

index (int) – The attribute index to retrieve.

Returns:

the specified attribute

Return type:

Gck.Attribute

Get attribute at the specified index in the attribute array.

Use [method`Attributes`.count] to determine how many attributes are in the array.

contains(match)[source]
Parameters:

match (Gck.Attribute) – The attribute to find

Returns:

True if the attributes contain the attribute.

Return type:

bool

Check whether the attributes contain a certain attribute.

count()[source]
Returns:

The number of contained attributes.

Return type:

int

Get the number of attributes in this attribute array.

dump()[source]

Dump the attributes using g_printerr().

find(attr_type)[source]
Parameters:

attr_type (int) – The type of attribute to find.

Returns:

the first attribute found with the specified type, or None

Return type:

Gck.Attribute

Find an attribute with the specified type in the array.

find_boolean(attr_type)[source]
Parameters:

attr_type (int) – The type of attribute to find.

Returns:

Whether a value was found or not.

value:

The resulting bool value.

Return type:

(bool, value: bool)

Find an attribute with the specified type in the array.

The attribute (if found) must be of the right size to store a boolean value (ie: CK_BBOOL). If the attribute is marked invalid then it will be treated as not found.

find_date(attr_type)[source]
Parameters:

attr_type (int) – The type of attribute to find.

Returns:

Whether a value was found or not.

value:

The resulting GLib.Date value.

Return type:

(bool, value: GLib.Date)

Find an attribute with the specified type in the array.

The attribute (if found) must be of the right size to store a date value (ie: CK_DATE). If the attribute is marked invalid then it will be treated as not found.

find_string(attr_type)[source]
Parameters:

attr_type (int) – The type of attribute to find.

Returns:

Whether a value was found or not.

value:

The resulting string value.

Return type:

(bool, value: str)

Find an attribute with the specified type in the array.

If the attribute is marked invalid then it will be treated as not found. The resulting string will be null-terminated, and must be freed by the caller using GLib.free().

find_ulong(attr_type)[source]
Parameters:

attr_type (int) – The type of attribute to find.

Returns:

Whether a value was found or not.

value:

The resulting int value.

Return type:

(bool, value: int)

Find an attribute with the specified type in the array.

The attribute (if found) must be of the right size to store a unsigned long value (ie: CK_ULONG). If the attribute is marked invalid then it will be treated as not found.

ref()[source]
Returns:

the attributes

Return type:

Gck.Attributes

Reference this attributes array.

ref_sink()[source]
Returns:

the referenced attributes

Return type:

Gck.Attributes

Gck.Attributes uses a floating reference count system. [method`Builder`.end] and [ctor`Attributes`.new_empty] both return floating references.

Calling this function on a GckAttributes with a floating reference will convert the floating reference into a full reference. Calling this function on a non-floating GckAttributes results in an additional normal reference being added.

In other words, if the self is floating, then this call “assumes ownership” of the floating reference, converting it to a normal reference. If the self is not floating, then this call adds a new normal reference increasing the reference count by one.

All Gck library functions that assume ownership of floating references are documented as such. Essentially any Gck function that performs an operation using a Gck.Attributes argument rather than operating on the attributes themselves, will accept a floating reference.

to_string()[source]
Returns:

a newly allocated string

Return type:

str

Print out attributes to a string in aform that’s useful for debugging or logging.

The format of the string returned may change in the future.

unref()[source]

Unreference this attribute array.

When all outstanding references are gone, the array will be freed.