Skip to main content

Python CryptoAuthLib module

Introduction

This module provides a thin python ctypes layer to evaluate the cryptoauthlib interface to Microchip CryptoAuthentication devices.

Code Examples

Code examples for python are available on github as part of CryptoAuthTools under the python/examples directory

Installation

CryptoAuthLib python module can be installed through Python's pip tool:

    pip install cryptoauthlib

To upgrade your installation when new releases are made:

    pip install -U cryptoauthlib

If you ever need to remove your installation:

    pip uninstall cryptoauthlib

What does python CryptoAuthLib package do?

CryptoAuthLib module gives access to most functions available as part of standard cryptoauthlib (which is written in 'C'). These python functions for the most part are very similar to 'C' functions. The module in short acts as a wrapper over the 'C' cryptoauth library functions.

Microchip cryptoauthlib product page: Link

Supported hardware

Supported devices

The family of devices supported currently are:

Using cryptoauthlib python module

The following is a 'C' code made using cryptoauthlib 'C' library.

#include "cryptoauthlib.h"

void main()
{
    ATCA_STATUS status;
    uint8_t revision[4];
    uint8_t randomnum[32];

    status = atcab_init(cfg_ateccx08a_kitcdc_default);
    if (status != ATCA_SUCCESS)
    {
        printf("Error");
        exit();
    }

    status = atcab_info(revision);
    if (status != ATCA_SUCCESS)
    {
        printf("Error");
        exit();
    }

    status = atcab_random(randomnum);
    if (status != ATCA_SUCCESS)
    {
        printf("Error");
        exit();
    }
}

The same code in python would be:

from cryptoauthlib import *

ATCA_SUCCESS = 0x00
revision = bytearray(4)
randomnum = bytearray(32)

# Locate and load the compiled library
load_cryptoauthlib()

assert ATCA_SUCCESS == atcab_init(cfg_ateccx08a_kithid_default())

assert ATCA_SUCCESS == atcab_info(revision)
print(''.join(['%02X ' % x for x in revision]))

assert ATCA_SUCCESS == atcab_random(randomnum)
print(''.join(['%02X ' % x for x in randomnum]))

In the above python code, "import cryptoauthlib" imports the python module. load_cryptoauthlib() function loads the ompiled library. The load_cryptoauthlib() is a function that you will not see in the 'C' library, this is a python specific utility function and is required for python scripts to locate and load the compiled library.

In Summary

Step I: Import the module

from cryptoauthlib import *

Step II: Initilize the module

load_cryptoauthlib()

assert ATCA_SUCCESS == atcab_init(cfg_ateccx08a_kithid_default())

Step III: Use Cryptoauthlib APIs

Call library APIs of your choice

Code portability

Microchip's CryptoAuthentication products can now be evaluated with the power and flexibility of python. Once the evaluation stage is done the python code can be ported to 'C' code.

As seen above the python API maintains a 1 to 1 equivalence to the 'C' API in order to easy the transition between the two.

Cryptoauthlib module API documentation

help() command

All of the python function's documentation can be viewed through python's built in help() function.

For example, to get the documentation of atcab_info() function:

    >>> help(cryptoauthlib.atcab_info)
    Help on function atcab_info in module cryptoauthlib.atcab:

    atcab_info(revision)
    Used to get the device revision number. (DevRev)

    Args:
        revision            4-byte bytearray receiving the revision number
                            from the device. (Expects bytearray)

    Returns:
        Status code

dir() command

The dir command without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that object. For example dir(cryptoauthlib) will return all the methods available in the cryptoauthlib module.

Code Examples

Code examples for python are available on github as part of CryptoAuthTools under the python/examples directory

Tests

Module tests can be located in the python/tests of the main cryptoauthlib repository. The README.md has details for how to run the tests. The module tests are not comprehensive for the entire functionality of cryptoauthlib but rather are meant to test the python module code only against the library to ensure the interfaces are correct and ctypes structures match the platform.

Release notes

See Release Notes

Metadata

Release files for cryptoauthlib 20210512

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cryptoauthlib 20210512
File Size Uploaded
cryptoauthlib-20210512.tar.gz 413.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cryptoauthlib 20210512
File
cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl PyPy 3.7 PyPy 3.7 7.3 macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl PyPy 3.6 PyPy 3.6 7.3 macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl PyPy 2.7 PyPy 7.3 macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64 Details
cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.9+ x86-64 Details

Total release size: 2.2 MB

Release files / cryptoauthlib-20210512.tar.gz

Download URL cryptoauthlib-20210512.tar.gz
Size 413.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f16c42313c9a18566794c6bf07ac60fbf1824e9ff3a79791ad368b646f05b006
BLAKE2b-256 checksum
How to use checksums
922cb3c039a3f5e5c5a559edc37714a312c27ea7e5cbcfc5507389f118857d50
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags PyPy 3.7 PyPy 3.7 7.3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5c20aff46a66c4ffe020caff2af38f15220adee987e8e6f9e15896636c18c725
BLAKE2b-256 checksum
How to use checksums
5d84d8862d29a6142e1f65781ec3efd3d203a7bbbc07564f4e5ec595a315157c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags PyPy 3.6 PyPy 3.6 7.3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
c4caf9e49e1af451256da41b75f2fa636d75df80575db82cc05aaf66c5337d29
BLAKE2b-256 checksum
How to use checksums
7cc37bc9e42646e98ca6ff25e557b964fd611403dc0dd848ff502c0cc5d76cfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags PyPy 2.7 PyPy 7.3 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
5f061a29e8bbf196e705573a10a9021ce284882fa2de3324ce1cf4edaa14f061
BLAKE2b-256 checksum
How to use checksums
7c48759e2c46ce0a3f8fc529cabae63adf464a224015a160f27d3394827b94e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp39-cp39-win_amd64.whl

Download URL cryptoauthlib-20210512-cp39-cp39-win_amd64.whl
Size 129.6 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
9b11c79f43fff5f7036456e9c8f6497f62711bf6e0c5141e46a18bf2c6ee9a7d
BLAKE2b-256 checksum
How to use checksums
669e3ccfbd868fa789407aaa2ee320b89321f4602dfe1bcd6d2c617076e9ffba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
99e384de824b006eea6038c77be332f4e56f931051e9eabaaef786ed610c251d
BLAKE2b-256 checksum
How to use checksums
fb17a1af37eaa43c82fe3ccbb054db43c59efb3236e8b3d33cde8251ffe1d8b1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp38-cp38-win_amd64.whl

Download URL cryptoauthlib-20210512-cp38-cp38-win_amd64.whl
Size 129.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
41fe0d29230232599489d03ed2311535a6035a8befd35473ef702c09a4aa867a
BLAKE2b-256 checksum
How to use checksums
719baa6c33c8bbe7a9981d628f371ac978908beed5d656f9554faa91ef7fb035
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 3.8 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
a6faebdbea070217e5a83fec72d01cc39d05d6342dffa45964b9e971035adedc
BLAKE2b-256 checksum
How to use checksums
fbd6c215b13af12359e417449deb0e45ad92ab7f13a9ef4027f3d4d4e3f39275
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl

Download URL cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl
Size 129.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
49807826eb52575d33b19a7f4e58314a94ca16ad0f93527c57058afe389bcd74
BLAKE2b-256 checksum
How to use checksums
bf8a557be1e0315b1530c45a3c1eb52a592e1814efaacd8a79a8cc11661d669f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
4a143b5eb968dc4922fa5bc243316755a7bcc8fda618ebf0663036b930b8e8e2
BLAKE2b-256 checksum
How to use checksums
f750c4491436ba52e725d253e40d04da9fe89b8936e5482d78018b6fa6d97529
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl

Download URL cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl
Size 129.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
1cbc3f6b81285eb062f23576ffc27c66bf65dd362ccdc8a6d45b7ac069c74226
BLAKE2b-256 checksum
How to use checksums
70429db1ea274d33ca0813e1647c1c7033a9ce17de21fb15336927c821ba7b26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
63b67ce21bf05797735683ce0df953a22238e5bcbd4c2fd4c86d646da4a04dc6
BLAKE2b-256 checksum
How to use checksums
40fa3f253eee36b1cf7bd778151f11f501ea17c0db277554d7ba8e62f053f2d0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl

Download URL cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl
Size 129.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
775b6a36bff540686d88bd496bfce9690c8bb3c1acc41243392681709e58f8dc
BLAKE2b-256 checksum
How to use checksums
e2520d9cb851d9c505e24fb11ccfe6415188c394625747ad4b1189d5c32e9c35
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f579a01f0ddd17ee453c8f5f102b17a6932ff6730a7c3e6640727bfac2d653e1
BLAKE2b-256 checksum
How to use checksums
9ddafd32939cc421cb6bc206d4f51d762a33161c330951ad95288069cfc30767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release files / cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl

Download URL cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl
Size 130.2 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
9edf204191b7c5c424be1db03ec8ca6fbe9bab979013053be2057c8d765a4239
BLAKE2b-256 checksum
How to use checksums
5ff1adc1846aab75cc3d0dee2d7314d03f53aa363a4c8ffc679201454e0c8285
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.5

Release history Release notifications | RSS feed

This release

20210512 This release

15 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page