Skip to main content

Python Wrapper Library for Microchip Security Products

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cryptoauthlib-20210512.tar.gz (413.4 kB view details)

Uploaded Source

Built Distributions

cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded PyPy macOS 10.9+ x86-64

cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded PyPy macOS 10.9+ x86-64

cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded PyPy macOS 10.9+ x86-64

cryptoauthlib-20210512-cp39-cp39-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20210512-cp38-cp38-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl (129.6 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 3.5m macOS 10.9+ x86-64

cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl (130.2 kB view details)

Uploaded CPython 2.7m macOS 10.9+ x86-64

File details

Details for the file cryptoauthlib-20210512.tar.gz.

File metadata

  • Download URL: cryptoauthlib-20210512.tar.gz
  • Upload date:
  • Size: 413.4 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512.tar.gz
Algorithm Hash digest
SHA256 f16c42313c9a18566794c6bf07ac60fbf1824e9ff3a79791ad368b646f05b006
MD5 7f8b489a51a7433d373d437d829ce3ce
BLAKE2b-256 922cb3c039a3f5e5c5a559edc37714a312c27ea7e5cbcfc5507389f118857d50

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20210512-pp37-pypy37_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c20aff46a66c4ffe020caff2af38f15220adee987e8e6f9e15896636c18c725
MD5 f39f422b379122f5c7abc1881ede5dba
BLAKE2b-256 5d84d8862d29a6142e1f65781ec3efd3d203a7bbbc07564f4e5ec595a315157c

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20210512-pp36-pypy36_pp73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 c4caf9e49e1af451256da41b75f2fa636d75df80575db82cc05aaf66c5337d29
MD5 87e526efde70f16202e6e4697eb7ca64
BLAKE2b-256 7cc37bc9e42646e98ca6ff25e557b964fd611403dc0dd848ff502c0cc5d76cfa

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: PyPy, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-pp27-pypy_73-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5f061a29e8bbf196e705573a10a9021ce284882fa2de3324ce1cf4edaa14f061
MD5 0fc9a889295d52f609788c7d4d1008cb
BLAKE2b-256 7c48759e2c46ce0a3f8fc529cabae63adf464a224015a160f27d3394827b94e9

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 129.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 9b11c79f43fff5f7036456e9c8f6497f62711bf6e0c5141e46a18bf2c6ee9a7d
MD5 2dfb142c499cc5821373a5fdec8c713e
BLAKE2b-256 669e3ccfbd868fa789407aaa2ee320b89321f4602dfe1bcd6d2c617076e9ffba

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 3.9, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 99e384de824b006eea6038c77be332f4e56f931051e9eabaaef786ed610c251d
MD5 86481389df07a91e9b03a573668a7763
BLAKE2b-256 fb17a1af37eaa43c82fe3ccbb054db43c59efb3236e8b3d33cde8251ffe1d8b1

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 129.6 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 41fe0d29230232599489d03ed2311535a6035a8befd35473ef702c09a4aa867a
MD5 68017acb24862e406a1fa1f39097e0a3
BLAKE2b-256 719baa6c33c8bbe7a9981d628f371ac978908beed5d656f9554faa91ef7fb035

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 3.8, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 a6faebdbea070217e5a83fec72d01cc39d05d6342dffa45964b9e971035adedc
MD5 eb079ecce2288f381a7b5b4f1e9e53c6
BLAKE2b-256 fbd6c215b13af12359e417449deb0e45ad92ab7f13a9ef4027f3d4d4e3f39275

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 129.6 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 49807826eb52575d33b19a7f4e58314a94ca16ad0f93527c57058afe389bcd74
MD5 884cebcc101094c47f413532b9484fd9
BLAKE2b-256 bf8a557be1e0315b1530c45a3c1eb52a592e1814efaacd8a79a8cc11661d669f

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 3.7m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4a143b5eb968dc4922fa5bc243316755a7bcc8fda618ebf0663036b930b8e8e2
MD5 b1627c094a80b9ec629d355f66741623
BLAKE2b-256 f750c4491436ba52e725d253e40d04da9fe89b8936e5482d78018b6fa6d97529

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 129.6 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1cbc3f6b81285eb062f23576ffc27c66bf65dd362ccdc8a6d45b7ac069c74226
MD5 d5cf6f6ee863214d55337ade407756d4
BLAKE2b-256 70429db1ea274d33ca0813e1647c1c7033a9ce17de21fb15336927c821ba7b26

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 3.6m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 63b67ce21bf05797735683ce0df953a22238e5bcbd4c2fd4c86d646da4a04dc6
MD5 9301c6870d61741407937911bafa5889
BLAKE2b-256 40fa3f253eee36b1cf7bd778151f11f501ea17c0db277554d7ba8e62f053f2d0

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 129.6 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 775b6a36bff540686d88bd496bfce9690c8bb3c1acc41243392681709e58f8dc
MD5 a4f07f6b682a87dd86a40efda66f6645
BLAKE2b-256 e2520d9cb851d9c505e24fb11ccfe6415188c394625747ad4b1189d5c32e9c35

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 3.5m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp35-cp35m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f579a01f0ddd17ee453c8f5f102b17a6932ff6730a7c3e6640727bfac2d653e1
MD5 21afb21bdcb0f47809e9b9ae63b4ce91
BLAKE2b-256 9ddafd32939cc421cb6bc206d4f51d762a33161c330951ad95288069cfc30767

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl
  • Upload date:
  • Size: 130.2 kB
  • Tags: CPython 2.7m, macOS 10.9+ x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20210512-cp27-cp27m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9edf204191b7c5c424be1db03ec8ca6fbe9bab979013053be2057c8d765a4239
MD5 5c8be0307d3bdd93c1ba92ffb0359bcc
BLAKE2b-256 5ff1adc1846aab75cc3d0dee2d7314d03f53aa363a4c8ffc679201454e0c8285

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page