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

Uploaded Source

Built Distributions

cryptoauthlib-20181026-cp36-cp36m-win_amd64.whl (90.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20181026-cp36-cp36m-win32.whl (79.6 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20181026-cp35-cp35m-win_amd64.whl (90.3 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20181026-cp35-cp35m-win32.whl (79.6 kB view details)

Uploaded CPython 3.5m Windows x86

cryptoauthlib-20181026-cp27-cp27m-win_amd64.whl (90.3 kB view details)

Uploaded CPython 2.7m Windows x86-64

cryptoauthlib-20181026-cp27-cp27m-win32.whl (79.6 kB view details)

Uploaded CPython 2.7m Windows x86

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026.tar.gz
  • Upload date:
  • Size: 245.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20181026.tar.gz
Algorithm Hash digest
SHA256 3e6c4c13e3855f0b2ae81804552be4718edd83811c74fe24d5e69efd33f6284b
MD5 723197c44f60e9b7391dc8cf2a41eaf3
BLAKE2b-256 2e4afe57eea0bcaab74f2cd0955f19716ced8c1ce55c72bca48737019b50ef27

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 90.3 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cryptoauthlib-20181026-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1e71498fb310ed31c6167bb86c9a6ec9d00034178e85919bd8ab0ae3824d04a9
MD5 b875b0bdfe9b0177b8ccfda168e55631
BLAKE2b-256 4130ec3dc5408b56d39b758819bda20838f50099f0ba1e7813de9262445abf25

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 79.6 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cryptoauthlib-20181026-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 911dd6f26cb37e167c15ef68cc05ac80e7b0f15b61b1d0165b0fca0fa8b74d99
MD5 e3ffb2958815e82eb2b1662fb429b130
BLAKE2b-256 6bb1917400e937e0256a992b102bdf6c31f23aaae7ef8887af4c6cfff99ba398

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 90.3 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20181026-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 b1709bcbe2987ed2a95202e27427d897f81e6f2c907fade02ddb0301bf8418ee
MD5 329a91346f01ec79c70e5100d9c4c731
BLAKE2b-256 4b5994c11af2f9f66f8a77d980bd815d2a90090945ce5a394da0e222bd0e9a34

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 79.6 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20181026-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 13ff9460a48978eeeec39a117cbeacfe8579eca1c9d64212fa19b443ba8aadeb
MD5 5824d231840878eeea5004b12e7f9b7d
BLAKE2b-256 43f69cd73300385571257ea5d88df436f15548d63933dd152c912d75a2f68850

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 90.3 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20181026-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 a2fe6718dfd636aa7b99ba11ee54db6ccf23ad950ae04731dd34d9cf612e20b6
MD5 2b486c3759d70e7469d7057c80e6eb2d
BLAKE2b-256 55466facd2ae9ba7ca55ed9878f71b34f9ea0d22c4b7d85465bf02eae6f5240e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20181026-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 79.6 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20181026-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 4aed43cfeb5133b116d06e7aa2cc96173268d773e36b5978086fbfcd7396128e
MD5 e0d9c904686a1f398fb225b09c99ec34
BLAKE2b-256 43895c8969b1af1b3b6339b0d0ad8064326be21d6b7538623ad7300c57a69b1c

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