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

Uploaded Source

Built Distributions

cryptoauthlib-20190830-cp37-cp37m-win_amd64.whl (103.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20190830-cp37-cp37m-win32.whl (92.4 kB view details)

Uploaded CPython 3.7m Windows x86

cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl (105.8 kB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

cryptoauthlib-20190830-cp36-cp36m-win_amd64.whl (103.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20190830-cp36-cp36m-win32.whl (92.4 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl (105.8 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

cryptoauthlib-20190830-cp35-cp35m-win_amd64.whl (103.6 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20190830-cp35-cp35m-win32.whl (92.4 kB view details)

Uploaded CPython 3.5m Windows x86

cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl (105.8 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl (103.6 kB view details)

Uploaded CPython 2.7m Windows x86-64

cryptoauthlib-20190830-cp27-cp27m-win32.whl (92.5 kB view details)

Uploaded CPython 2.7m Windows x86

cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl (105.8 kB view details)

Uploaded CPython 2.7m macOS 10.6+ intel

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830.tar.gz
Algorithm Hash digest
SHA256 b734eeed1355970157900059ca2993d34b00ec47dd673309bd646c071d1cf5ce
MD5 206298979d0a2109a57fd93248d8cd16
BLAKE2b-256 6f2aa3f7b565bd9e59f52abfebc7c93c91690a28d0198face30b40bd8c4cebfe

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 1f174fde04558f4c0fe5aecd75ecedc498c633a8d7413e40b5476e8524ef6897
MD5 c18cbbc85811a1b2c20d4e089ab352c2
BLAKE2b-256 f1c4a5148b4e0f8871a571af362e1b45d2fa37c185af0c0c73b0b36395042fbf

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 e45221d4ab4e237359f59a0575f178c768cf76d6421a969582bd098116b3b72a
MD5 8001b1d384fc6bf2d1960b9fa08ebd5b
BLAKE2b-256 a69d7b84c757f3cecb4eacb501f49d36cc3207f1fd2fe117bd641ece2e811f44

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 75d534b9fe7f50ac851e1a569db81fb245793089f6d289f329320709886ba5d4
MD5 387fde88ceb2c0837077fb7f658769ad
BLAKE2b-256 9bd12194cfb8a980119fbc4d9630e2ec6ceed45632d19fababcec4e65a3ec2d7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8738c2e783c15e442b85d20d51613f1430f8c8b3c8e47157ab509761e4d89dc2
MD5 21db1852616bfa3b7e1cbc29edf2ee7e
BLAKE2b-256 6260807d21abf20b91ae75c68de0d25cd784a379ecc7d42036470f2a75a956d7

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 bc0d7dbe304f99ecb46a25233a18b296afcf41a0ab8a98f58ba3cabd45f5b2d3
MD5 ef805865a61c11ec27e66526e6cf17af
BLAKE2b-256 819da24792713a82b4545ee14ee0103218b34062c0871f62c766fddb6cdd606c

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: CPython 3.6m, macOS 10.6+ intel
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 7ada6fc2acc5a2960ff1b1503a3e20255919d7bda9a81276c425bcbeeb2a8bce
MD5 7f3f0b770fb683b8ef832492d52053fe
BLAKE2b-256 c6b6cf123de1e2373c1239cfe6f6d2aa53bc34a28f1475af93399a09c263ff13

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 3b18ec41818d51accdcf202b778f9f5f3f099d3fd7de17210bac1e36ddfb5f46
MD5 bcb785e8f3ace82477d07fa70626a70e
BLAKE2b-256 6fd28c6b9e205c4e04731499093101b1abc3ac2444ec0d0a9b5e35c99c6f1bca

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190830-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 3feddd9d10d8a8768d42bbb824339aeb06365ff8d8bb03a7757bd4d5603cab4b
MD5 394e457ff294e6f6e1fa6f7ca4dbeb60
BLAKE2b-256 f49a88f72422df4d30fce60d7f839f9c5b8c08bcd34ac199519c0e0d122a6c02

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: CPython 3.5m, macOS 10.6+ intel
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a4cb980cecb32070d8bddc8b9f2df0948754a65dc3eb2f3bc60c87e225272373
MD5 00f69dc12edb7722629c78083adc859f
BLAKE2b-256 ae5e292a2eb3ad96c3f6e9db8b16ed6d43f005108693a21ec6da817314bd1f89

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 103.6 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 f74b3839d17e4c4e1b299f899079ab7c701b65d82c9046faa01c0d20844b0f2e
MD5 9401f16c7f30c0cb9f951c03951e56ad
BLAKE2b-256 1c4023653354764a9b621f139eb51c9478285eea03a2e512981eee7f9ca6f497

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190830-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 92.5 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 e65dce3ad44d5106b368742f8d4349a0b6eff5bdc3d6187e5734adec25ec45fb
MD5 6b357376a297480fae1497177ab5e460
BLAKE2b-256 8f343da27b5b1df328689dd75caaa0a84c21203a80c4d85116949411faeaf843

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 105.8 kB
  • Tags: CPython 2.7m, macOS 10.6+ intel
  • Uploaded using 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

File hashes

Hashes for cryptoauthlib-20190830-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 e06fe30868e26022006b2376813559b52d062e8b3afc2eae546673663e9b9e69
MD5 69ea19ca4e4ede3f98a2ed1c97b9d4ec
BLAKE2b-256 e7da12342b527061264ceb037640af29db2d20ec2092454a3d7be6eff3062db2

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