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 20190304

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

Built distributions (wheels)

Table of built distributions (wheels) for cryptoauthlib 20190304
File
cryptoauthlib-20190304-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
cryptoauthlib-20190304-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190304-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
cryptoauthlib-20190304-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-64 Details
cryptoauthlib-20190304-cp35-cp35m-win32.whl CPython 3.5 CPython 3.5 pymalloc Windows x86-32 Details
cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386) Details
cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-64 Details
cryptoauthlib-20190304-cp27-cp27m-win32.whl CPython 2.7 CPython 2.7 pymalloc Windows x86-32 Details
cryptoauthlib-20190304-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.4 MB

Release files / cryptoauthlib-20190304.tar.gz

Download URL cryptoauthlib-20190304.tar.gz
Size 255.1 kB
Tags Source
SHA-256 checksum
How to use checksums
63c2cd007b2cb4e46d8fce0a0cd42d4b34fb965b9b5e16a41527814833f0da7e
BLAKE2b-256 checksum
How to use checksums
a6b9698260893ad00c0a730012c1ef7e22c7dc214d219af790069a57a48fbf0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp37-cp37m-win_amd64.whl
Size 97.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
2e9d825d904fee2602433ee9b28259c4ce10c54ec102c90bdee48b27bd6d98f9
BLAKE2b-256 checksum
How to use checksums
e2997d3b999e114dfc8de77fe466b040e89e0d256a1f859f33eced5f633449b7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

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

Download URL cryptoauthlib-20190304-cp37-cp37m-win32.whl
Size 86.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
9944a981dc69111b76343e1566128a9322d33692992cbc23471922d22fe69927
BLAKE2b-256 checksum
How to use checksums
f41d75c8686aca851d90fcf17715c220b84c4a841e57302d27cf9076640df8c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

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

Download URL cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl
Size 101.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
eb5cdc0891c3fa2d380306667f7a2155438db7be83be24682807100c7a681fd7
BLAKE2b-256 checksum
How to use checksums
e4d9006bd5bddd38834785f632f34d8eaf9fcceb47b4afa628434c8ae94b39fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp36-cp36m-win_amd64.whl
Size 97.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
0e76fff545ec1ee78c81032123ba487d3c707497e7d696a4a77128b689e453fd
BLAKE2b-256 checksum
How to use checksums
1dd3139126ff039937a434e8f1f72f0032fa0816736cc8ded7ac8a090ec961c5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

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

Download URL cryptoauthlib-20190304-cp36-cp36m-win32.whl
Size 86.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
8542bbe01f5b0fcf4899e5d5c9520ff446aa7ee326c908e8a7834a5c700dd5c7
BLAKE2b-256 checksum
How to use checksums
f1f5c2a2966ba3ee13a00b30c293a4a58b9cf3e0dbe0053b36b058bf4a255f44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

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

Download URL cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl
Size 101.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
3551d4eedffcff9207094010455bfb6e6ef14311824962a1a626b4140096fe03
BLAKE2b-256 checksum
How to use checksums
0e8d18513c59f73d65edeb16fd4bbcab9c6a7bd3094f3eacaf36fe8f9c80f99b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl
Size 97.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
07616964fed80627800ddde1b24e09855062f3abf619d62f837a116b4af5bf1a
BLAKE2b-256 checksum
How to use checksums
954648935a384d3b492bc1d09e81c2bdc0a418e9f5d263b2680a9536feb2b357
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4

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

Download URL cryptoauthlib-20190304-cp35-cp35m-win32.whl
Size 86.6 kB
Tags CPython 3.5 CPython 3.5 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
282d8fa0b04b773e1535d8d9a35e548dde1b4ca5eecb3eeba6d2548f80c16c22
BLAKE2b-256 checksum
How to use checksums
c61a5e723218ee2d7073cab6717a22c064537c46048a3a59723a0e3f8abcf12b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4

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

Download URL cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl
Size 101.5 kB
Tags CPython 3.5 CPython 3.5 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
574f243b71ab00d3ec2b039be0ba48f7775fd8b8c8312c4720d828bb3ada7ed4
BLAKE2b-256 checksum
How to use checksums
fdfd19a43a6d42a429beea54583274dea4266984be006169d011b57db9dfd87c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl
Size 97.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
b994430538d2caccc9a7747a053ee77693642e83d45b96b3c5f8460dcf627579
BLAKE2b-256 checksum
How to use checksums
08bb2142b6acf9407db4dafb27e583590ecafbf349c9b8a687bfb119a8c25d72
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp27-cp27m-win32.whl
Size 86.7 kB
Tags CPython 2.7 CPython 2.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
310fb4a1e9f2247d868fcd88000daf367254d1e16bbee35284f203b118a1e47f
BLAKE2b-256 checksum
How to use checksums
ec7958202ffd68c93c004a319a77449776aa0afb62ed38b681917bec67d27668
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

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

Download URL cryptoauthlib-20190304-cp27-cp27m-macosx_10_6_intel.whl
Size 101.5 kB
Tags CPython 2.7 CPython 2.7 pymalloc macOS 10.6+ Intel (x86-64, i386)
SHA-256 checksum
How to use checksums
a5da66445769d1290c2468060e0e90c9eaa97495c4b9f13f0fdc4cd1a5b77a84
BLAKE2b-256 checksum
How to use checksums
ce9de32ea46008522bdea93ee5c1a7048e5c7d3fdbd04c80eeab419faba86011
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

Release history Release notifications | RSS feed

This release

20190304 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