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 compiled 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-20230314.tar.gz (470.0 kB view details)

Uploaded Source

Built Distributions

cryptoauthlib-20230314-pp39-pypy39_pp73-win_amd64.whl (156.0 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20230314-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-pp38-pypy38_pp73-win_amd64.whl (156.0 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20230314-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-cp311-cp311-win_amd64.whl (156.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

cryptoauthlib-20230314-cp311-cp311-win32.whl (137.9 kB view details)

Uploaded CPython 3.11 Windows x86

cryptoauthlib-20230314-cp311-cp311-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-cp311-cp311-macosx_11_0_arm64.whl (227.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cryptoauthlib-20230314-cp311-cp311-macosx_10_9_x86_64.whl (227.7 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cryptoauthlib-20230314-cp310-cp310-win_amd64.whl (156.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

cryptoauthlib-20230314-cp310-cp310-win32.whl (137.9 kB view details)

Uploaded CPython 3.10 Windows x86

cryptoauthlib-20230314-cp310-cp310-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-cp310-cp310-macosx_11_0_arm64.whl (227.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cryptoauthlib-20230314-cp310-cp310-macosx_10_9_x86_64.whl (227.7 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cryptoauthlib-20230314-cp39-cp39-win_amd64.whl (156.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20230314-cp39-cp39-win32.whl (137.9 kB view details)

Uploaded CPython 3.9 Windows x86

cryptoauthlib-20230314-cp39-cp39-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-cp39-cp39-macosx_11_0_arm64.whl (227.7 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cryptoauthlib-20230314-cp39-cp39-macosx_10_9_x86_64.whl (227.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20230314-cp38-cp38-win_amd64.whl (156.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20230314-cp38-cp38-win32.whl (137.9 kB view details)

Uploaded CPython 3.8 Windows x86

cryptoauthlib-20230314-cp38-cp38-manylinux_2_28_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230314-cp38-cp38-macosx_11_0_arm64.whl (227.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20230314-cp38-cp38-macosx_10_9_x86_64.whl (227.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cryptoauthlib-20230314.tar.gz
  • Upload date:
  • Size: 470.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.8

File hashes

Hashes for cryptoauthlib-20230314.tar.gz
Algorithm Hash digest
SHA256 84258c2c57846054d74a6fe665fec14754540d0ecb6393aab6fb7d05e4c9e7a1
MD5 c02e975190c08604e3e9dfac5e20198b
BLAKE2b-256 a357a6cadde891a79c8bc700b0bf6c1c5525219a42209f0a3a207a2963dbf00f

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-pp39-pypy39_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ffd1630c5182e199c3c98abfe2efe75d3bf0991193ca6abe070aaa0ddbb9c716
MD5 45067a81d2f45b175339a0236399f365
BLAKE2b-256 dc6eb348b378462990817606022662bf8e00440679ce737a1da0f625eca47197

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b331a38dde681b02a9465d904e41a703dad991a9987aac1f3a2c78869fb21c80
MD5 1ab0b067ee2a4c69017a4cb99c7aa492
BLAKE2b-256 ec6174dd6997125b3dc792b1abc7080b43bd04137daba9ee6d62be6e239f0a4a

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-pp38-pypy38_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 05c0f06a9661f99aeac321daa8a9e2957cfa436d2580d951a45f6808212c366d
MD5 4dd3fdfdfa80fb2aeb02c9da13e723f0
BLAKE2b-256 16ea143e107bec23dca984b8134597e8b8e345d91e5a1d6cc5e04c8985798a2e

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4aeb90a9c862e67ef8b2788420c90a1295dc357bcec3b82a374ba0990a3e4463
MD5 c6c494b94397dd2cf8d30b6d6d54416a
BLAKE2b-256 bd1dedf55bffcccf68eb60fc9e5a0085eebfe973d7a42ffbefd24baa755dd343

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 860897e209775f220523fac53cef0c4d4a50d19b08e8359b2c66f4ca66d12e5b
MD5 3901c50a7e9d2ab40641d3cd79bf0435
BLAKE2b-256 1f5ae80cc7dac1d1474d39e105cb08a36dc50ceb8ec9aab2d385b68d07222c7d

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp311-cp311-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 283e39952829a6b93ffc87670be6e0c2eaaee306e4316fa60b015edbea92792a
MD5 bc6c7563a3bc698da3c596ca92a94b9d
BLAKE2b-256 9218c4d15f13e63cdf8c9361f84a4dbbcbda3277a3c8fef9d5db00b8150c1af1

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp311-cp311-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 378f20caef9f176c178ac667805101afdd81aba7b022277857f2524ee69d5b34
MD5 e04874ac45dae2795cc4e68a8046f434
BLAKE2b-256 e7f3a313b0ebcfffd1fe6fed9085b3820e2df108f726c29fd591f4ce52cecd9b

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4cacebcd93e6e9db43f21a8fa78998fc01ed1a14ea0a8eeea035a49b8fc2f8c6
MD5 33626fdedc6a2179e666b839eba90c1d
BLAKE2b-256 abcc220fb15a27b63f95151a918361abf5f3c2719a4959ca34aa5d3cc0cfeedf

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 da352050e3946b36b4b64a2169daa26f14fe830675140604390c4c479eb82391
MD5 cdf2e12d0b3ccac1a9489978f28f2be1
BLAKE2b-256 608ed0d509e667a6adf531f0dab7debe57f259b46ebcd47ccc1264405e3129ae

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 da6bc5902c8128a7ac0ad40ed362235c75eb52f089c4e87d9ca40e3200d8db61
MD5 3493eefa711266555f9685b26f1aa9a1
BLAKE2b-256 5272e0e5a5834e8926fdadd61a6cf991c1aa101253c64f34fa890b78d1f37000

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp310-cp310-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 0e74200b807665bd84b57c726afeb68731f6a55c9da2209b3a428f08a81ad024
MD5 0bcfa882a3a6a3690b3d46b20954754e
BLAKE2b-256 12dba52e611064aa0435ec65487dbd18104de3821e865d2d04d8f7c498cc9fe9

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp310-cp310-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4c0896bacd59c0f48af7a16b4fe3261ff6831aae62e06fc0faa121a556ce822e
MD5 e65869e4241abada23c16a2f8c2e0532
BLAKE2b-256 03d4d6c0a03de6b0f1725c8d1c50265829499c6d23a1f21d5a028aa417b5e4cd

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 186a9ab11ae41d1f6d0f0349a2e05c6df547cb092bd78cf59b8caa1320594d81
MD5 2c1c910b2a924b97686a75847432b8e6
BLAKE2b-256 f765bb6d5fefdaf4baeee73d22f31ef8bbff78599f465e1952a8b7e362777625

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 4a363bd0d2f2dd5a2634f8a5b72791f21db8a1935b64db02c98477294213b8af
MD5 1cb1c11626f269ed642c8dbfffb6a100
BLAKE2b-256 f44c885e542d37ddd552f76c8c06b165bf11c83ee1f1a0410c00cf1a81ca5695

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 67170ee0565e9a1448e87858613e4f8dc15dc1110f49340a6ecaf201de897c2e
MD5 4e9112a197dc2829ecc391edd375952d
BLAKE2b-256 00d8998166c7208f410e502dddc2b7a8728155ce7b2af028767ae0b372d203ac

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp39-cp39-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 03f1ba0cfb06752914476986d1f17f8fe99edbc155249fffd5a0e66af12d754c
MD5 bda1224f9888a71d2167b1d594283bd0
BLAKE2b-256 439459cc270de508043f518b9e24409247d7e183cfa35c8e8746faae9341f4ce

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp39-cp39-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 892a6c51bf947dbb4e5c230b2a3e501ead2eaf1efb06ff963a7347ab7c23a64a
MD5 01c254ad25e7b255c576437c919e2b6f
BLAKE2b-256 d2316032799f96548438b70874e59c7c9c69aba32c27a67affb0d0c194ef6633

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 eb3ba5fa59b06c1ea663b5c17c3e40914b24716757b14cc83f9231b0da228766
MD5 0af031ffce3c7a20b5a40f23eb7b5b5e
BLAKE2b-256 21d36bfc45c8df21ac1ad0d3ec6e58208756662c787d3ae11ff6aaa97da742d4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 fe195a228ab177abd6307700e6217ddf0d69eeb7400b649a8373233062601336
MD5 afc1e8778e137fa2c9386ffc4a822b73
BLAKE2b-256 d5c5ddf5f51db0a1e75813db4ad1003ab723eae660fa387cb7d4c9dbce7cbf23

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 fc15393da1e863c54ac1a462f40cfae6e0ae702eb746b468e0fcce5623a0d793
MD5 eb1471044dcb001905abd8cc9d6e20b8
BLAKE2b-256 272e0ef329c295a43092ee1a31115633750df5bde40572d935450f0dcee66022

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp38-cp38-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 fcbf89cd6dccaf63d1c47c755ab71bd016021e70aed495bd2b1afe5320382a0c
MD5 1225d1dbc85f925099e038d711e315c7
BLAKE2b-256 4bcefa3c43a86d10189f2d533c9624bae0e33a22077127c5adfa4c3dfd885910

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp38-cp38-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3608bcc6d04e8dba982f4e8ac89cd1a8aed5fefe0145a672ed2f3eda1d9fdfc0
MD5 0d1b7df8ac82c1fb8f2b95752cef4f95
BLAKE2b-256 3c9bbcdcf80e513a1b4fb38a7309a4d46c85696ae1b7c67845464265e6193be2

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20230314-cp38-cp38-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c6464c28d095fb2a876a5bc42e8b4fb6d4a3bc06d6398ca1ffd84442c585ea7d
MD5 afb7b64b3630a90b167e4cead34ac3f0
BLAKE2b-256 977399f03dfdc6d7e967e96703843881e3ef6c0d933f8c8a64cb87b17790f3b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230314-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 72700d73138362f9f66df9208b7912f1f0c1a0ce58c8cb7e8c300a48a4fcb941
MD5 22302600f7ed082552b6fb42ac274a7d
BLAKE2b-256 af6bd0fa32100814f2ba2a5a79569288ab68bb6b10cbba8644809154f621f330

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