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

Uploaded Source

Built Distributions

cryptoauthlib-20190104-cp37-cp37m-win_amd64.whl (92.8 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20190104-cp37-cp37m-win32.whl (81.9 kB view details)

Uploaded CPython 3.7m Windows x86

cryptoauthlib-20190104-cp36-cp36m-win_amd64.whl (92.8 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20190104-cp36-cp36m-win32.whl (81.9 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20190104-cp35-cp35m-win_amd64.whl (92.8 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20190104-cp35-cp35m-win32.whl (81.9 kB view details)

Uploaded CPython 3.5m Windows x86

cryptoauthlib-20190104-cp27-cp27m-win_amd64.whl (92.8 kB view details)

Uploaded CPython 2.7m Windows x86-64

cryptoauthlib-20190104-cp27-cp27m-win32.whl (82.0 kB view details)

Uploaded CPython 2.7m Windows x86

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190104.tar.gz
Algorithm Hash digest
SHA256 1b6f7ea0f9d7e9ecd682cb9d3e01e35829993a8536e2472d17efd582e70960c0
MD5 324dce9ee5206a7d65b0def7c2685942
BLAKE2b-256 e79b774aeb1b81ad46485f6ac2e47b1d55a2e0ddd696c412989a1b36ef654ed2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190104-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 92.8 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for cryptoauthlib-20190104-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 38ab4a1dd8bd2641f17989a78f52e62f00f05fa152b3aedfaeff7a5aa406ea52
MD5 1cfaf2a6fdec69eb73a5cc160288d8a8
BLAKE2b-256 8c70ba154ec04054e78574bf5feffbc4b02292b075665ca5071b3e4edd43205d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190104-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 81.9 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.0

File hashes

Hashes for cryptoauthlib-20190104-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 1c0a99d47760ff7b733629671876385762d95b2616575b9730e2530e79ce1b6a
MD5 11b2bd8bb24b6a434b2fccbb31e16b32
BLAKE2b-256 1c78690bef174152518b8ebdb54b2dbfa62de40aa1bbe715095dd1a73399b142

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190104-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 92.8 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.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.6.6

File hashes

Hashes for cryptoauthlib-20190104-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 1e6363f539a3cafe63b4c70d0fb204139df8dbccc58c63e92360419b60dbbb97
MD5 8fc1fb3add01d83608ca4fc403c9d7a9
BLAKE2b-256 b806464ee4e08eda3f9921566b46fb914d68d81000e2a95de9ad0859a4a42806

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190104-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 a4801881fe7c9252815efd8f364c628d962ded93c5f517b3fe9f2ef566590760
MD5 205477c31f2da216902958719ae58f1f
BLAKE2b-256 e68b4c43c5f70725e70ff30e34d5e631da6341a3e6e2d5d8433d022dde0030c9

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190104-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 92.8 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.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20190104-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 24b16eb868c840afd3e41adbb025a6f73d9bc603ea0f9d6a404bc1ef305582a8
MD5 92c294b3d388ae77575f46e2a4d78ac0
BLAKE2b-256 1551daf777da164c92c47fc4e020f5345d775acd1d64f3cefd4b3667b48c8eb6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190104-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 808871ddcb5315c6899fb34cc979ea154bc75cf406dabecd69f1a4714ba081fd
MD5 085ad64fc16c985a99d5471c8c1eba1c
BLAKE2b-256 f77efbebeb650859287f75f0226c7429c28476a09993a0aeef6ac2888a896d94

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190104-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 92.8 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.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190104-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 231d118ca35e858e81f664da58b0410d9eea80cc6f56b30360b6c96b5e0fc4ed
MD5 04fa6f10be92fb23b0dd60e59c11d773
BLAKE2b-256 8091f1712cbb3fc0f5e02129fe2202cf9a966579aadfdaaa5161e933395898bb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20190104-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 bbbeea62a15882480122e3ee94368845b119753a335b3e88f3bbc3f3c02629fe
MD5 55c2f0f50bcd784f35b9b0aec7d34ce6
BLAKE2b-256 f39110320b22808853c88ae70719a728b5b510c0b40f9026c403101ff327485d

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