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.

Metadata

Release files for cryptoauthlib 20190830

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 20190830
File Size Uploaded
cryptoauthlib-20190830.tar.gz 262.4 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for cryptoauthlib 20190830
File
cryptoauthlib-20190830-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
cryptoauthlib-20190830-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190830-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
cryptoauthlib-20190830-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190830-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
cryptoauthlib-20190830-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
cryptoauthlib-20190830-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details

Total release size: 1.5 MB

Release files / cryptoauthlib-20190830.tar.gz

Download URL cryptoauthlib-20190830.tar.gz
Size 262.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b734eeed1355970157900059ca2993d34b00ec47dd673309bd646c071d1cf5ce
BLAKE2b-256 checksum
How to use checksums
6f2aa3f7b565bd9e59f52abfebc7c93c91690a28d0198face30b40bd8c4cebfe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

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

Download URL cryptoauthlib-20190830-cp37-cp37m-win_amd64.whl
Size 103.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
1f174fde04558f4c0fe5aecd75ecedc498c633a8d7413e40b5476e8524ef6897
BLAKE2b-256 checksum
How to use checksums
f1c4a5148b4e0f8871a571af362e1b45d2fa37c185af0c0c73b0b36395042fbf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / cryptoauthlib-20190830-cp37-cp37m-win32.whl

Download URL cryptoauthlib-20190830-cp37-cp37m-win32.whl
Size 92.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e45221d4ab4e237359f59a0575f178c768cf76d6421a969582bd098116b3b72a
BLAKE2b-256 checksum
How to use checksums
a69d7b84c757f3cecb4eacb501f49d36cc3207f1fd2fe117bd641ece2e811f44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.7.4

Release files / cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl

Download URL cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl
Size 105.8 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
75d534b9fe7f50ac851e1a569db81fb245793089f6d289f329320709886ba5d4
BLAKE2b-256 checksum
How to use checksums
9bd12194cfb8a980119fbc4d9630e2ec6ceed45632d19fababcec4e65a3ec2d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

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

Download URL cryptoauthlib-20190830-cp36-cp36m-win_amd64.whl
Size 103.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8738c2e783c15e442b85d20d51613f1430f8c8b3c8e47157ab509761e4d89dc2
BLAKE2b-256 checksum
How to use checksums
6260807d21abf20b91ae75c68de0d25cd784a379ecc7d42036470f2a75a956d7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

Release files / cryptoauthlib-20190830-cp36-cp36m-win32.whl

Download URL cryptoauthlib-20190830-cp36-cp36m-win32.whl
Size 92.4 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
bc0d7dbe304f99ecb46a25233a18b296afcf41a0ab8a98f58ba3cabd45f5b2d3
BLAKE2b-256 checksum
How to use checksums
819da24792713a82b4545ee14ee0103218b34062c0871f62c766fddb6cdd606c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.8

Release files / cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl

Download URL cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl
Size 105.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
7ada6fc2acc5a2960ff1b1503a3e20255919d7bda9a81276c425bcbeeb2a8bce
BLAKE2b-256 checksum
How to use checksums
c6b6cf123de1e2373c1239cfe6f6d2aa53bc34a28f1475af93399a09c263ff13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

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

Download URL cryptoauthlib-20190830-cp35-cp35m-win_amd64.whl
Size 103.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
3b18ec41818d51accdcf202b778f9f5f3f099d3fd7de17210bac1e36ddfb5f46
BLAKE2b-256 checksum
How to use checksums
6fd28c6b9e205c4e04731499093101b1abc3ac2444ec0d0a9b5e35c99c6f1bca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

Release files / cryptoauthlib-20190830-cp35-cp35m-win32.whl

Download URL cryptoauthlib-20190830-cp35-cp35m-win32.whl
Size 92.4 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
3feddd9d10d8a8768d42bbb824339aeb06365ff8d8bb03a7757bd4d5603cab4b
BLAKE2b-256 checksum
How to use checksums
f49a88f72422df4d30fce60d7f839f9c5b8c08bcd34ac199519c0e0d122a6c02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.5.4

Release files / cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl

Download URL cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl
Size 105.8 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
a4cb980cecb32070d8bddc8b9f2df0948754a65dc3eb2f3bc60c87e225272373
BLAKE2b-256 checksum
How to use checksums
ae5e292a2eb3ad96c3f6e9db8b16ed6d43f005108693a21ec6da817314bd1f89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

Release files / cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl

Download URL cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl
Size 103.6 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
f74b3839d17e4c4e1b299f899079ab7c701b65d82c9046faa01c0d20844b0f2e
BLAKE2b-256 checksum
How to use checksums
1c4023653354764a9b621f139eb51c9478285eea03a2e512981eee7f9ca6f497
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

Release files / cryptoauthlib-20190830-cp27-cp27m-win32.whl

Download URL cryptoauthlib-20190830-cp27-cp27m-win32.whl
Size 92.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e65dce3ad44d5106b368742f8d4349a0b6eff5bdc3d6187e5734adec25ec45fb
BLAKE2b-256 checksum
How to use checksums
8f343da27b5b1df328689dd75caaa0a84c21203a80c4d85116949411faeaf843
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

Release files / cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl

Download URL cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl
Size 105.8 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e06fe30868e26022006b2376813559b52d062e8b3afc2eae546673663e9b9e69
BLAKE2b-256 checksum
How to use checksums
e7da12342b527061264ceb037640af29db2d20ec2092454a3d7be6eff3062db2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/2.7.16

Release history Release notifications | RSS feed

This release

20190830 This release

13 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