CryptoAuthLib v3.7.8
Microchip CryptoAuthentication Library
 
Loading...
Searching...
No Matches
cryptoauthlib.library Namespace Reference

Data Structures

class  _CtypeIterator
 
class  AtcaReference
 
class  AtcaStructure
 
class  AtcaUnion
 
class  cal_buffer
 

Functions

def indent (lines, insert)
 
def _force_local_library ()
 
def load_cryptoauthlib (lib=None)
 
def get_cryptoauthlib ()
 
def get_device_name (revision)
 
def get_device_name_with_device_id (revision)
 
def get_device_type_id (name)
 
def get_size_by_name (name)
 
def get_ctype_by_name (name)
 
def get_ctype_structure_instance (structure, value)
 
def get_ctype_array_instance (array, value)
 
def _get_field_definition (obj, name)
 
def _def_to_field (f_type, f_size=None)
 
def _convert_pointer_to_list (p, length)
 
def _get_attribute_from_ctypes (obj, obj_type, length=None, *args)
 
def _check_type_rationality (cls)
 
def _array_to_code (obj, name=None, parent=None, **kwargs)
 
def _object_definition_code (obj, name=None, parent=None, parent_name=None, anon=None, type_info=None, check_names={}, **kwargs)
 
def _union_to_code (obj, name=None, parent=None, anon=None, entry=None, parent_name=None, type_info=None, **kwargs)
 
def _structure_to_code (obj, name=None, parent=None, type_info=None, parent_name=None, **kwargs)
 
def _obj_to_code (obj, name, parent=None, anon=None, parent_name=None, **kwargs)
 
def _pointer_to_code (obj, name=None, parent=None, parent_name=None, check_names={}, skip_references=[], **kwargs)
 
def _is_pointer (obj, type_info=None, **kwargs)
 
def _to_code (obj, name=None, **kwargs)
 
def _structure_to_string (item, int level=0)
 
def _ctype_from_definition (cls)
 
def ctypes_to_bytes (obj)
 
def create_byte_buffer (init_or_size)
 

Variables

 try :
 
dict ATCA_NAMES = {'i2c': 'i2c', 'hid': 'kithid', 'sha': 'sha204', 'ecc': 'eccx08'}
 
None _CRYPTO_LIB = None
 
dict _CTYPES_BY_SIZE = {1: c_uint8, 2: c_uint16, 4:c_uint32}
 
 _fields_
 

Detailed Description

Cryptoauthlib Library Management

Function Documentation

◆ _array_to_code()

def cryptoauthlib.library._array_to_code (   obj,
  name = None,
  parent = None,
**  kwargs 
)
protected
Convert an array like item from a ctypes structure into a C language formatted
string

◆ _check_type_rationality()

def cryptoauthlib.library._check_type_rationality (   cls)
protected
This checks the structure or union size against the constants that are stored in the library
during compilation. This is not an absolute guarentee that alignment is completely correct
but it will catch most cases of incompability between the compiled library that is installed
and the python module

◆ _convert_pointer_to_list()

def cryptoauthlib.library._convert_pointer_to_list (   p,
  length 
)
protected
Pointer types can be frustrating to interact with generally when processing data in python
so this converts them into types that are iterable and bounded

◆ _ctype_from_definition()

def cryptoauthlib.library._ctype_from_definition (   cls)
protected
Extends the ctypes structure and union types to add a new attribute _def_ which is a dictionary
of field attributes. This extends functionality by quite a bit by supporting additional types
and field linkages

◆ _def_to_field()

def cryptoauthlib.library._def_to_field (   f_type,
  f_size = None 
)
protected
Helper function to convert an entry in the _def_ dictionary to the 
tuple required for a _field_ entry

◆ _force_local_library()

def cryptoauthlib.library._force_local_library ( )
protected
In some environments loading seems to fail under all circumstances unless
brute forcing it.

◆ _get_attribute_from_ctypes()

def cryptoauthlib.library._get_attribute_from_ctypes (   obj,
  obj_type,
  length = None,
args 
)
protected
Helper function that is used by AtcaStructure and AtcaUnion to intercept attribute access
to those objects and convert the resulting values into easier to use python objects based
on the configuration of the structure/union

◆ _get_field_definition()

def cryptoauthlib.library._get_field_definition (   obj,
  name 
)
protected
Get meta information about the ctypes structure/union by accessing
the field description attributes of the class that were provided
as part of the ctype structure/union definition

◆ _is_pointer()

def cryptoauthlib.library._is_pointer (   obj,
  type_info = None,
**  kwargs 
)
protected
Checks to see if object looks like a pointer

◆ _obj_to_code()

def cryptoauthlib.library._obj_to_code (   obj,
  name,
  parent = None,
  anon = None,
  parent_name = None,
**  kwargs 
)
protected
Convert python/ctypes object into a C language representation

◆ _object_definition_code()

def cryptoauthlib.library._object_definition_code (   obj,
  name = None,
  parent = None,
  parent_name = None,
  anon = None,
  type_info = None,
  check_names = {},
**  kwargs 
)
protected
Emits the first half of the assignment of this object

◆ _pointer_to_code()

def cryptoauthlib.library._pointer_to_code (   obj,
  name = None,
  parent = None,
  parent_name = None,
  check_names = {},
  skip_references = [],
**  kwargs 
)
protected
Convert the pointer into a representative object by creating a definition in the prepend
area

◆ _structure_to_code()

def cryptoauthlib.library._structure_to_code (   obj,
  name = None,
  parent = None,
  type_info = None,
  parent_name = None,
**  kwargs 
)
protected
Emits a string with a C language representation of the structure(s) following pointers the
best that is can

◆ _structure_to_string()

def cryptoauthlib.library._structure_to_string (   item,
int   level = 0 
)
protected
Emits a readable string of the structure elements coverting types and following pointers and arrays
the best that is can

◆ _to_code()

def cryptoauthlib.library._to_code (   obj,
  name = None,
**  kwargs 
)
protected
Map object types to the proper renderer function by catching pointer like objects first

Returns: (append, prepend)

◆ ctypes_to_bytes()

def cryptoauthlib.library.ctypes_to_bytes (   obj)
Convert a ctypes structure/array into bytes. This is for python2 compatibility

◆ get_cryptoauthlib()

def cryptoauthlib.library.get_cryptoauthlib ( )
This is a helper function for the other python files in this module to use the loaded library

◆ get_ctype_array_instance()

def cryptoauthlib.library.get_ctype_array_instance (   array,
  value 
)
Internal Helper Function: Convert python list into ctype array
:param value: Value to convert
:param array: Conversion Class (resulting type)
:return:

◆ get_ctype_by_name()

def cryptoauthlib.library.get_ctype_by_name (   name)
For known (atca_utils_sizes.c) types that are custom to the library retrieve the size

◆ get_ctype_structure_instance()

def cryptoauthlib.library.get_ctype_structure_instance (   structure,
  value 
)
Internal Helper Function:  Convert a value into the correct ctypes structure for a given field
:param value: Value to convert
:param structure: Conversion Class (resulting type)
:return:

◆ get_device_name()

def cryptoauthlib.library.get_device_name (   revision)
Returns the device name based on the info byte array values returned by atcab_info

◆ get_device_name_with_device_id()

def cryptoauthlib.library.get_device_name_with_device_id (   revision)
Returns the device name based on the info byte array values returned by atcab_info for ECC204 family

◆ get_device_type_id()

def cryptoauthlib.library.get_device_type_id (   name)
Returns the ATCADeviceType value based on the device name

◆ get_size_by_name()

def cryptoauthlib.library.get_size_by_name (   name)
Get the size of an object in the library using the name_size api from atca_utils_sizes.c

◆ load_cryptoauthlib()

def cryptoauthlib.library.load_cryptoauthlib (   lib = None)
Load CryptoAauthLib into Python environment
raise LibraryLoadError if cryptoauthlib library can't be loaded