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 20200208

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

Built distributions (wheels)

Table of built distributions (wheels) for cryptoauthlib 20200208
File
cryptoauthlib-20200208-pp36-pypy36_pp73-win32.whl PyPy 3.6 PyPy 3.6 7.3 Windows x86-32 Details
cryptoauthlib-20200208-pp27-pypy_73-win32.whl PyPy 2.7 PyPy 7.3 Windows x86-32 Details
cryptoauthlib-20200208-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
cryptoauthlib-20200208-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
cryptoauthlib-20200208-cp38-cp38-macosx_10_13_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.13+ x86-64 Details
cryptoauthlib-20200208-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
cryptoauthlib-20200208-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
cryptoauthlib-20200208-cp37-cp37m-macosx_10_13_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ Intel (x86-64, i386) Details
cryptoauthlib-20200208-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
cryptoauthlib-20200208-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
cryptoauthlib-20200208-cp36-cp36m-macosx_10_13_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ Intel (x86-64, i386) Details
cryptoauthlib-20200208-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
cryptoauthlib-20200208-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
cryptoauthlib-20200208-cp35-cp35m-macosx_10_13_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ Intel (x86-64, i386) Details
cryptoauthlib-20200208-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
cryptoauthlib-20200208-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
cryptoauthlib-20200208-cp27-cp27m-macosx_10_13_intel.whl CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ Intel (x86-64, i386) Details

Total release size: 2.0 MB

Release files / cryptoauthlib-20200208.tar.gz

Download URL cryptoauthlib-20200208.tar.gz
Size 274.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b04a4097c6f8d4b539c7425261eac3353016405b863fec2d827152ce3a652bf
BLAKE2b-256 checksum
How to use checksums
1bedda1709095abd203e37892f7183b68433382ce6a0f6129dfa0ac47e2ba85c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Release files / cryptoauthlib-20200208-pp36-pypy36_pp73-win32.whl

Download URL cryptoauthlib-20200208-pp36-pypy36_pp73-win32.whl
Size 93.6 kB
Tags PyPy 3.6 PyPy 3.6 7.3 Windows x86-32
SHA-256 checksum
How to use checksums
f5c65a8a4439186d202ea527c3728bbc42add94bd70dc4657808969a5c04e56f
BLAKE2b-256 checksum
How to use checksums
5331e28c5b59113afd8d2d4163bb7c265ed6b1f9df8d5751c79fcb0a9c0d5248
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-pp27-pypy_73-win32.whl

Download URL cryptoauthlib-20200208-pp27-pypy_73-win32.whl
Size 93.6 kB
Tags PyPy 2.7 PyPy 7.3 Windows x86-32
SHA-256 checksum
How to use checksums
fce6ef315545b66a8c92ae9e07a5c9a2a07082df03db3e1caae3ad833990bb03
BLAKE2b-256 checksum
How to use checksums
85bb8be23e53c8663cfb60eb829598354295988c72d30ddc398cef9f1acb4342
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

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

Download URL cryptoauthlib-20200208-cp38-cp38-win_amd64.whl
Size 106.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
026221789eab981ad3922a74b1b83d82f820b4f4225c6d2cf65eaba75d446de1
BLAKE2b-256 checksum
How to use checksums
da18308431232ea26c253c97398ddf466bdf416deda5231615955da758ff608c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp38-cp38-win32.whl

Download URL cryptoauthlib-20200208-cp38-cp38-win32.whl
Size 93.6 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
1648910e1a72374ce031fc01c5765354ecf2fb57c1e0c4391880d72bf48f540f
BLAKE2b-256 checksum
How to use checksums
d8921ed2fc7f9968c789f52b22b75d96a0514537c96b93ecfce3b744f1f9b907
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp38-cp38-macosx_10_13_x86_64.whl

Download URL cryptoauthlib-20200208-cp38-cp38-macosx_10_13_x86_64.whl
Size 109.0 kB
Tags CPython 3.8 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
2b1d72fe153b507ebf00141f64b9b5205745ff17ddb494f6a96d4f246a73d697
BLAKE2b-256 checksum
How to use checksums
13498574e11a09dc59ab4dbf1534388f38e706dce5a91adbefc1c4fb67e6efee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

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

Download URL cryptoauthlib-20200208-cp37-cp37m-win_amd64.whl
Size 106.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
c4503756060cd41cc8861b3fb6c6c3a1df9ca53c71f2aadff24ad55e26ee3c72
BLAKE2b-256 checksum
How to use checksums
12a89195510bd11ff1013b1dc0fd30657b880f83d46ed082575d18628bc34b01
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

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

Download URL cryptoauthlib-20200208-cp37-cp37m-win32.whl
Size 93.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
a0049dda82c7a9ea206502f6959c786b2fe2767829a4451edf477fdcb43781e6
BLAKE2b-256 checksum
How to use checksums
3565d4ca7e49efda0e25d44012524f0a4aeebb927a2c3a1882527db8274a123a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp37-cp37m-macosx_10_13_intel.whl

Download URL cryptoauthlib-20200208-cp37-cp37m-macosx_10_13_intel.whl
Size 109.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
e5ca855365827c4adc04db8d608cfd27d12ebea9f29358a8fd130686f318485a
BLAKE2b-256 checksum
How to use checksums
81e4b827ddd670b93f309c5c48f93ddbf970b46a6fff2cd1a2a2f14207b42ffe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

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

Download URL cryptoauthlib-20200208-cp36-cp36m-win_amd64.whl
Size 106.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
4b3b4f321e3d559c899845e63eb4c037fecd9c460b987cf30861a13e9fd21162
BLAKE2b-256 checksum
How to use checksums
1df4f38eff81c498a914e032bcb8cd65dd86face048b3a8548627fcdc350f3c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

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

Download URL cryptoauthlib-20200208-cp36-cp36m-win32.whl
Size 93.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e06082fa25577b89e225d7185ecae48733098848f189f0b79366ab921a3ecc4e
BLAKE2b-256 checksum
How to use checksums
c7e8016c87bd7f23eef695c21294b6ed0b1a80551dd330dcfd0a9cb1ab9e5e37
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp36-cp36m-macosx_10_13_intel.whl

Download URL cryptoauthlib-20200208-cp36-cp36m-macosx_10_13_intel.whl
Size 109.0 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
a457500b0d5fd6caaf0989c2af3a8c6f4c28ab0b3c5e57d3f4b8985ce780cb46
BLAKE2b-256 checksum
How to use checksums
84284e04b980db21a3ad3edf08e2106f81019233fe2089efd4d69c2a2586a25d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

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

Download URL cryptoauthlib-20200208-cp35-cp35m-win_amd64.whl
Size 106.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
40e27a5bed7ce47167d06cfc2e3a4708989c72573fb446f2b6067e11bc873be8
BLAKE2b-256 checksum
How to use checksums
f27c1df9866389653f27a343d61931f3a459e08ef0ef5f94b6bc2a44172b3967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

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

Download URL cryptoauthlib-20200208-cp35-cp35m-win32.whl
Size 93.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
3058dcd41e650468bb281f9b4f25d32484ca8912be13be7523f4ea6c169476b2
BLAKE2b-256 checksum
How to use checksums
c73a94c18f6eb9685dfaedf96d2fea6554342df54b38ff75146919d403919284
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp35-cp35m-macosx_10_13_intel.whl

Download URL cryptoauthlib-20200208-cp35-cp35m-macosx_10_13_intel.whl
Size 109.0 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
6b4a18369b2a181366f5eaf5c28e35af54255e21d48c29351beb6ca8c0759317
BLAKE2b-256 checksum
How to use checksums
c9605f319c8ff905dfb52eaaf2c221d611d120d88c4008571951f18bc8cdbf75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

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

Download URL cryptoauthlib-20200208-cp27-cp27m-win_amd64.whl
Size 106.1 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
536f9a1be9e579a2dcb9b88da17f99677736c0859533ef33c6c165a00b08d4c3
BLAKE2b-256 checksum
How to use checksums
d24a6269a15be2643a5a34da3b371deef17cda593b3aac6ec9a9892ae9d3a08b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

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

Download URL cryptoauthlib-20200208-cp27-cp27m-win32.whl
Size 93.6 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
63cef0d7b2c01746cb30799e36a23db5e51581221e78ff08919901c4f356c9b7
BLAKE2b-256 checksum
How to use checksums
17c3a373c1d17cf086785f82773e4317430d9ff1517bba90ad4fa03c9e8da820
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.5

Release files / cryptoauthlib-20200208-cp27-cp27m-macosx_10_13_intel.whl

Download URL cryptoauthlib-20200208-cp27-cp27m-macosx_10_13_intel.whl
Size 109.0 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.13+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
8f6bdd441b2fb9f1e11162e0ad13edf5214cd42bb1909a457ccc43cbe0e88d75
BLAKE2b-256 checksum
How to use checksums
6c96d20cc29a85384dec6226ec1c1e5f72b471012ba21dc291c3f449a27ac1c7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.15.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/2.7.17

Release history Release notifications | RSS feed

This release

20200208 This release

18 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