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.

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-20200205.tar.gz (274.1 kB view details)

Uploaded Source

Built Distributions

cryptoauthlib-20200205-cp38-cp38-macosx_10_13_x86_64.whl (109.0 kB view details)

Uploaded CPython 3.8 macOS 10.13+ x86-64

cryptoauthlib-20200205-cp37-cp37m-win_amd64.whl (104.9 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20200205-cp37-cp37m-win32.whl (93.9 kB view details)

Uploaded CPython 3.7m Windows x86

cryptoauthlib-20200205-cp37-cp37m-macosx_10_13_intel.whl (109.0 kB view details)

Uploaded CPython 3.7m macOS 10.13+ intel

cryptoauthlib-20200205-cp36-cp36m-win_amd64.whl (104.9 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20200205-cp36-cp36m-win32.whl (93.9 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20200205-cp36-cp36m-macosx_10_13_intel.whl (109.0 kB view details)

Uploaded CPython 3.6m macOS 10.13+ intel

cryptoauthlib-20200205-cp35-cp35m-win_amd64.whl (104.9 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20200205-cp35-cp35m-win32.whl (93.9 kB view details)

Uploaded CPython 3.5m Windows x86

cryptoauthlib-20200205-cp35-cp35m-macosx_10_13_intel.whl (109.0 kB view details)

Uploaded CPython 3.5m macOS 10.13+ intel

cryptoauthlib-20200205-cp27-cp27m-win_amd64.whl (104.9 kB view details)

Uploaded CPython 2.7m Windows x86-64

cryptoauthlib-20200205-cp27-cp27m-win32.whl (93.9 kB view details)

Uploaded CPython 2.7m Windows x86

cryptoauthlib-20200205-cp27-cp27m-macosx_10_13_intel.whl (109.0 kB view details)

Uploaded CPython 2.7m macOS 10.13+ intel

File details

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

File metadata

  • Download URL: cryptoauthlib-20200205.tar.gz
  • Upload date:
  • Size: 274.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205.tar.gz
Algorithm Hash digest
SHA256 9814949d9e060ae0b525b3d0149ad89aaa68d8a68cfb0276f64465cffbd8d5ae
MD5 fe5b666c3a12cc1db6703748d91c8686
BLAKE2b-256 84448136e16a91f47ad1e01b31475e499cf0468755471b7f83044d7d5ee83477

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp38-cp38-macosx_10_13_x86_64.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp38-cp38-macosx_10_13_x86_64.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: CPython 3.8, macOS 10.13+ x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp38-cp38-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 9475d4d4fc6462e77689f4b07a0a11e71a9fd2a11baa0ecf75ae20b7eefac949
MD5 3fd9863037e1752a09738b6ce4db09fd
BLAKE2b-256 6d8ef52435adbe33e497d818cd0a85f082e0bf95d10dd1e5e2626a8594fb456d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20200205-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 104.9 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for cryptoauthlib-20200205-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 0831c123309d5f6a665a38d11d8a4fd71c2f5f70904ec61cda29006ece4baad3
MD5 a80bf378c11b78453129a800e93692da
BLAKE2b-256 9cd1f88cb95ad895e9008be26a62f94f448bf993421bfe31431a7bdc1b2dfd69

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp37-cp37m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.5

File hashes

Hashes for cryptoauthlib-20200205-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 1da3efaa025626559a54af1a872119b9ff00ae1a387a2132dbdec6e9831648aa
MD5 89547f8539991f98faaca95ff813ff70
BLAKE2b-256 2a7490aaffb4b19b447ed7aae0cb01ad2aa3c0f22f1dc637f05e1cdb4a15a1a5

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp37-cp37m-macosx_10_13_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp37-cp37m-macosx_10_13_intel.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: CPython 3.7m, macOS 10.13+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp37-cp37m-macosx_10_13_intel.whl
Algorithm Hash digest
SHA256 5f641a26748274e8f19e4c8e5e1988c20499b9680e1e117ec4b9ff37adf48b2f
MD5 32a1c755abea6de6e43848aa3e970b9a
BLAKE2b-256 1311933406f8224fcf9bfd568371cbed742ab9da69285219fcdc5a948a8f9c00

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20200205-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 104.9 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for cryptoauthlib-20200205-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 be804f9ad9ece51cf812924d596e4babe44bbf3561b4f41d4ddc19693997e984
MD5 8486ddfa0e003a612a141ae12bd7db3f
BLAKE2b-256 88de2bcffc21db2e76b1289fc2f0feda3f09c57d32e1caf7c5c27e40e7c08662

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp36-cp36m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.6.8

File hashes

Hashes for cryptoauthlib-20200205-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 0c2f687078fb2bbae5b9455158da30e0a3b445b884e16ea9342b87df1b564ed5
MD5 0e791d636994b69fc10d810c562e216b
BLAKE2b-256 e60c7b554b69dfd11e75bbdbe6c9b7e69d65b9b35d5f263bdd38f4dc2f0f85b7

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp36-cp36m-macosx_10_13_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp36-cp36m-macosx_10_13_intel.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: CPython 3.6m, macOS 10.13+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp36-cp36m-macosx_10_13_intel.whl
Algorithm Hash digest
SHA256 2d08440d226944da159d50f870056cf303e6e600cb96ffe6197637a4e7188d98
MD5 4581cf408dc230165f413af56d4f13cb
BLAKE2b-256 5e1fffbda57db8b5aa41cc9b1475c8f34119e7b2a7bd9f0f7aad62f5725cbfdb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20200205-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 104.9 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20200205-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 046342c7197b5f1d34b85a2dbaabe6e33280d03a46637023da66a291a07735e3
MD5 b8d21b530e44de6b75899752053699ac
BLAKE2b-256 e8002172f16a03a9b4ad05fca724e3b9175957041663d5ad80deaf872523212a

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp35-cp35m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20200205-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 b1915df28f5cfdfada3a3bd72c8cd4e14b848e07ac94abd459dc9d83ada7598b
MD5 51a8cdafecccb28dec8e0c175a7f381a
BLAKE2b-256 6151185faab8541b13e81f15c56b1efecdb9652acd4d0fe5739b01086a030aa7

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp35-cp35m-macosx_10_13_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp35-cp35m-macosx_10_13_intel.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: CPython 3.5m, macOS 10.13+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp35-cp35m-macosx_10_13_intel.whl
Algorithm Hash digest
SHA256 9b3d776e06b4433aa374dec6f26049e79b6ff55b21a8f3f1f37cdc492e5eba39
MD5 f986dd8b2d98eaca398c164c408f4e84
BLAKE2b-256 78dd658d72feb61ab6676c936b881d1a0305d728eb0c204069642705b160f636

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 104.9 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 5592e921f23a77f5f9820a335b3b6fc03a06330b0d9f4f451ef3d045fd215c57
MD5 9e97f94be7e6cfbb085713d9bbdecd4a
BLAKE2b-256 4c564046a2fabb4eb60eef6cdccc93b36c42b76f5a0e3c1202376929ba111bcf

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp27-cp27m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 93.9 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 7558ccdb159eb25ba6a290dc25bfdaba5c87db0d45c71c1e4ad20054ad763c69
MD5 cd08d12ed81d5caa073fc9d043a93fb5
BLAKE2b-256 6b03705e8209a99feff5a4145f6efa07ec51402f9fe8129b176890b8bb0fb270

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20200205-cp27-cp27m-macosx_10_13_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20200205-cp27-cp27m-macosx_10_13_intel.whl
  • Upload date:
  • Size: 109.0 kB
  • Tags: CPython 2.7m, macOS 10.13+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/44.0.0 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/2.7.17

File hashes

Hashes for cryptoauthlib-20200205-cp27-cp27m-macosx_10_13_intel.whl
Algorithm Hash digest
SHA256 c90eaf5ae73a39ec5aa24cc0fd45b8e11dea0acfec706e1ff89922714f5e9f30
MD5 0043cef7ca250315eaef1e6ff1415062
BLAKE2b-256 f51bce2d6261309bbc96793238a78c0ce751a76ca1a720aa21c725343045c412

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