Gck.Attribute¶
Fields¶
Name |
Type |
Access |
Description |
---|---|---|---|
length |
r/w |
The length of the attribute. May be [constINVALID] if the attribute is invalid. |
|
type |
r/w |
The attribute type, such as |
|
value |
r/w |
The value of the attribute. May be |
Methods¶
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Details¶
- class Gck.Attribute¶
This structure represents a PKCS#11
CK_ATTRIBUTE
. These attributes contain information about a PKCS#11 object. Use [method`Object`.get] or [method`Object`.set] to set and attributes on an object.Although you are free to allocate a
GckAttribute
in your own code, no functions in this library will operate on such an attribute.- classmethod new(attr_type, value, length)[source]¶
- Parameters:
- Returns:
the new attribute; when done with the attribute use
Gck.Attribute.free
() to free it- Return type:
Create a new PKCS#11 attribute. The value will be copied into the new attribute.
- classmethod new_boolean(attr_type, value)[source]¶
- Parameters:
- Returns:
the new attribute; when done with the attribute u
Gck.Attribute.free
() to free it- Return type:
Initialize a PKCS#11 attribute to boolean. This will result in a CK_BBOOL attribute from the PKCS#11 specs.
- classmethod new_date(attr_type, value)[source]¶
- Parameters:
- Returns:
the new attribute; when done with the attribute u
Gck.Attribute.free
() to free it- Return type:
Initialize a PKCS#11 attribute to a date. This will result in a CK_DATE attribute from the PKCS#11 specs.
- classmethod new_empty(attr_type)[source]¶
- Parameters:
attr_type (
int
) – the PKCS#11 attribute type to set on the attribute- Returns:
the new attribute; when done with the attribute use
Gck.Attribute.free
() to free it- Return type:
Create a new PKCS#11 attribute with empty data.
- classmethod new_invalid(attr_type)[source]¶
- Parameters:
attr_type (
int
) – the PKCS#11 attribute type to set on the attribute- Returns:
the new attribute; when done with the attribute use
Gck.Attribute.free
() to free it- Return type:
Create a new PKCS#11 attribute as ‘invalid’ or ‘not found’ state. Specifically this sets the value length to (CK_ULONG)-1 as specified in the PKCS#11 specification.
- classmethod new_string(attr_type, value)[source]¶
- Parameters:
- Returns:
the new attribute; when done with the attribute u
Gck.Attribute.free
() to free it- Return type:
Initialize a PKCS#11 attribute to a string. This will result in an attribute containing the text, but not the null terminator. The text in the attribute will be of the same encoding as you pass to this function.
- classmethod new_ulong(attr_type, value)[source]¶
- Parameters:
- Returns:
the new attribute; when done with the attribute u
Gck.Attribute.free
() to free it- Return type:
Initialize a PKCS#11 attribute to a unsigned long. This will result in a
CK_ULONG
attribute from the PKCS#11 specs.
- clear()[source]¶
Clear allocated memory held by a
Gck.Attribute
.This attribute must have been allocated by a Gck library function, or the results of this method are undefined.
The type of the attribute will remain set.
- dup()[source]¶
- Returns:
the duplicated attribute; use
Gck.Attribute.free
() to free it- Return type:
Duplicate the PKCS#11 attribute. All value memory is also copied.
The self must have been allocated or initialized by a Gck function or the results of this function are undefined.
- equal(attr2)[source]¶
- Parameters:
attr2 (
Gck.Attribute
) – second attribute to compare- Returns:
True
if the attributes are equal.- Return type:
Compare two attributes. Useful with
GLib.HashTable
.
- free()[source]¶
Free an attribute and its allocated memory. These is usually used with attributes that are allocated by [ctor`Attribute`.new] or a similar function.
- get_boolean()[source]¶
- Returns:
The boolean value of the attribute.
- Return type:
Get the CK_BBOOL of a PKCS#11 attribute. No conversion is performed. It is an error to pass an attribute to this function unless you’re know it’s supposed to contain a boolean value.
- get_data()[source]¶
-
Get the raw value in the attribute.
This is useful from scripting languages. C callers will generally access the
Gck.Attribute
struct directly.This function will
None
if the attribute contains empty or invalid data. The returned data must not be modified and is only valid as long as this attribute.
- get_date(value)[source]¶
- Parameters:
value (
GLib.Date
) – The date value to fill in with the parsed date.
Get the CK_DATE of a PKCS#11 attribute. No conversion is performed. It is an error to pass an attribute to this function unless you’re know it’s supposed to contain a value of the right type.
- get_string()[source]¶
- Returns:
a null terminated string, to be freed with
GLib.free
(), orNone
if the value was invalid- Return type:
Get the string value of a PKCS#11 attribute. No conversion is performed. It is an error to pass an attribute to this function unless you’re know it’s supposed to contain a value of the right type.
- get_ulong()[source]¶
- Returns:
The ulong value of the attribute.
- Return type:
Get the CK_ULONG value of a PKCS#11 attribute. No conversion is performed. It is an error to pass an attribute to this function unless you’re know it’s supposed to contain a value of the right type.
- hash()[source]¶
- Returns:
the hash code
- Return type:
Hash an attribute for use in
GLib.HashTable
keys.
- init_copy(src)[source]¶
- Parameters:
src (
Gck.Attribute
) – An attribute to copy.
Initialize a PKCS#11 attribute as a copy of another attribute. This copies the value memory as well.
When done with the copied attribute you should use [method`Attribute`.clear] to free the internal memory.