Miscellaneous¶
RNG, Digest, Creating Objects¶
PKCS11 Interface to the following functions:
- c_generate_random
- c_seed_random
- c_digest
- c_digestkey
- c_create_object
-
pypkcs11.misc.
c_create_object
(h_session, template)¶ Creates an object based on a given python template
Parameters: Returns: (retcode, the handle of the object)
Return type: tuple
-
pypkcs11.misc.
c_digest
(h_session, data_to_digest, digest_flavor, mechanism=None, output_buffer=None)¶ Digests some data
Parameters: - h_session (int) – Session handle
- data_to_digest (bytes) – The data to digest, either a string or a list of strings. If this is a list a multipart operation will be used
- digest_flavor (int) – The flavour of the mechanism to digest (MD2, SHA-1, HAS-160, SHA224, SHA256, SHA384, SHA512)
- mechanism – See the
parse_mechanism()
function for possible values. If None will use digest flavor. - output_buffer (list|int) – Integer or list of integers that specify a size of output buffer to use for an operation. By default will query with NULL pointer buffer to get required size of buffer.
Returns: (retcode, a python string of the digested data)
Return type: tuple
-
pypkcs11.misc.
c_digestkey
(h_session, h_key, digest_flavor, mechanism=None)¶ Digest a key
Parameters:
-
pypkcs11.misc.
c_generate_random
(h_session, length)¶ Generates a sequence of random numbers
Parameters: Returns: (retcode, A string of random data)
Return type: tuple
Find Objects, Attribute Setting/Getting¶
Functions for dealing with object attributes
-
pypkcs11.object_attr_lookup.
c_find_objects
(h_session, template, num_entries)¶ Calls c_find_objects and c_find_objects_init to get a python dictionary of the objects found.
Parameters: - h_session (int) – Session handle
- template – A python dictionary of the object template to look for
- num_entries – The max number of entries to return
Returns: Returns a list of handles of objects found
-
pypkcs11.object_attr_lookup.
c_get_attribute_value
(h_session, h_object, template)¶ Calls C_GetAttrributeValue to get an attribute value based on a python template
Parameters: - h_session (int) – Session handle
- h_object – The handle of the object to get attributes for
- template – A python dictionary representing the template of the attributes to be retrieved
Returns: A python dictionary representing the attributes
-
pypkcs11.object_attr_lookup.
c_set_attribute_value
(h_session, h_object, template)¶ Calls C_SetAttributeValue to set an attribute value based on a python template
Parameters: - h_session (int) – Session handle
- h_object – The handle of the object to get attributes for
- template – A python dictionary representing the template of the attributes to be written
Returns: A python dictionary representing the attributes returned