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

Uploaded Source

Built Distributions

cryptoauthlib-20230326-pp39-pypy39_pp73-win_amd64.whl (157.0 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-pp38-pypy38_pp73-win_amd64.whl (157.0 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-cp311-cp311-win_amd64.whl (157.0 kB view details)

Uploaded CPython 3.11 Windows x86-64

cryptoauthlib-20230326-cp311-cp311-win32.whl (138.7 kB view details)

Uploaded CPython 3.11 Windows x86

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

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-cp311-cp311-macosx_11_0_arm64.whl (229.0 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cryptoauthlib-20230326-cp311-cp311-macosx_10_9_x86_64.whl (229.0 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cryptoauthlib-20230326-cp310-cp310-win_amd64.whl (157.0 kB view details)

Uploaded CPython 3.10 Windows x86-64

cryptoauthlib-20230326-cp310-cp310-win32.whl (138.7 kB view details)

Uploaded CPython 3.10 Windows x86

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

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-cp310-cp310-macosx_11_0_arm64.whl (229.0 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cryptoauthlib-20230326-cp310-cp310-macosx_10_9_x86_64.whl (229.0 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cryptoauthlib-20230326-cp39-cp39-win_amd64.whl (157.0 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20230326-cp39-cp39-win32.whl (138.7 kB view details)

Uploaded CPython 3.9 Windows x86

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

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-cp39-cp39-macosx_11_0_arm64.whl (229.0 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cryptoauthlib-20230326-cp39-cp39-macosx_10_9_x86_64.whl (229.0 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20230326-cp38-cp38-win_amd64.whl (157.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20230326-cp38-cp38-win32.whl (138.7 kB view details)

Uploaded CPython 3.8 Windows x86

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

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20230326-cp38-cp38-macosx_11_0_arm64.whl (229.0 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20230326-cp38-cp38-macosx_10_9_x86_64.whl (229.0 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20230326.tar.gz
Algorithm Hash digest
SHA256 d45579cbebd14e797e5d544c83a29b7650ac0f34dc22e6a3c96037a798a4bd2a
MD5 d8bd0a8df3ad0c9129a04293f9745ee3
BLAKE2b-256 d278ed5995160c8e279c57da88445553cadf6940ac2ca94c5e61d523af9c483c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 c7b808e3dc3ac0f04e3a7d7756271faee0bbcb3923e33f7ec804e84e722a3b15
MD5 e6f955dd76d407179cdc5c084c67bfe3
BLAKE2b-256 bbbd1b81363dd78e716b7ceec868df03351a92dedce7362e1f7616974cc73e87

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d6b84c63ac5b929a25adec80631a8ba221e65db42d6e8cf2ce2d201185661fb
MD5 4776691f91a200594e855d4fc55a8373
BLAKE2b-256 6cd33a4fad025322f6d0198fd024c696c5a11911c894c246f2f39af5cc41001c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 a99dce18b7adc8c4bd602342b08678ce767085b616a2ff8c3e1d84bb19831e04
MD5 94ba4495e32e74fa7f1354bb58bc4243
BLAKE2b-256 f8d0740c3a63332fd93d26f8f80295ca4a110556a7c9e3724aa68c58d4d50bff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 3c45647a1cac96f8f2d72f9ffeaf5aadfa4fbf7799ab1592396a5508c636b00d
MD5 26db3a1591fb2ad7dc8a31b7bbb47479
BLAKE2b-256 64bf1fe3de01c98d4e9045495af62408f18b2163b0f740b63494b1c06bca9324

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 ea6250e83c2d3e10039503958a28f2ed2b423bdbd327f7fd9ecadec9c8102fc9
MD5 d19f7fef66843aa800461fe076b07981
BLAKE2b-256 dbca200e2f892d8d499c52579399c5305bf6e0803109787e35a40d7f6e5e45b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 c443f5291317613ea6aa45887366b720e19acb07fd0a36de69fb937061e17b30
MD5 bceb9a99a90d467043bfe67c3e50163a
BLAKE2b-256 a2d5c8c4ffe85713f5f1496f3f35f1d24b790571d9af489a16cda1b25b8b62b6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 7b6b1eb9b3b6dcc0ad5b3ed01bd5b99957ae1b56f1dfce7c4c42ed3a2f89b34b
MD5 b30654de0ef67799b64b2bd89bc95671
BLAKE2b-256 8140f2605f7d407b4dae8cc0ea00fbcd2666cf9edbda25211564ba30486ec4e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50209cd84d1d84c05fa5fbd4faed6f71cdf62aa417477ba297ddb8763fb0f961
MD5 34c24c28d462c055566b3074e664f66c
BLAKE2b-256 c638b97c08f9c279af95a6e374b98cafdcee60476b7238ec68caf39cda9f418c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 36440a6f2f40865a9212a1e2b2eefcac81800c113de86d3c623c1f6df040386d
MD5 a49b436c1389b507280dd5099bf13ae2
BLAKE2b-256 e1eef8ea87bed322cd7752b9a10061105ed35e8383206177d94d13e14bdb1aa1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4b0cdb00b0c00c599e24ba887df99602661fc0510b582d72cb48f6cffedb6adc
MD5 134642d0c4554df2fca1f9754615dd47
BLAKE2b-256 4affae782126a942fa73cf03627b24a5cd9e0985d8be509dab2955814384ec43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 ae3744b78229f2927677a86e26cfaddfc8b613092fcc9360f5ded2fb65d91fa5
MD5 e171c135f841b0f30cf1b4a62de13344
BLAKE2b-256 5f952f1259902362383b1b9561465f9c6ddcae7eed8bc4d8df010c2d31596c6e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 066b3df9aa86bd12062b7a1bf425db5dc4f4b87e6f9b8d4183e9340e2783a2da
MD5 e0976bfa2c8fc750a77200a9246b7377
BLAKE2b-256 8f4e79e2423c5f01565afa45127d9e7540c35464778fcfcfbb8861c1f6aa6a3f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42838e38fa416b59a2368a7471abf42402f77ecd5b41dddac285664741c941c9
MD5 4b8a120315f995806a5600feefe9b5be
BLAKE2b-256 4f92c69e8064afea9c9791dfdac4a0bf224c0f74f6475fb36f9360a275df4810

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 cd19805472895291ac7354b44254cf96bc2088b4c4dbe58b00a658f6ba94621d
MD5 000c8c45c2780da17a3adb6a414613e9
BLAKE2b-256 5ca6f6e8aaddb36b679945512c9a00226a7758dba2efb75368d34ec10e228958

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 88881a37c083df3ecb2a313763114ff3352cd7b8f840a708b97fd4716aa51a37
MD5 1b3094dcf10f08116ff4a41b2379fcde
BLAKE2b-256 99e88a24cbb260b43bafc5c39e00289e73ab0f9df869a19745407d24cfe39946

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 572618b7c5349be8fe398797a98d653177e6710b24dc2cff22707a938c7c9afe
MD5 50fe306b6db0c3c385fd8daa502eeefe
BLAKE2b-256 01e3d97ae4b621952288e7825703492942cff39b71602f1d59fae71563e75a62

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 b379bbfaee218ed898a72300322a07c1087946d7af8bab723b06e65a55adea8f
MD5 3f810b936a77343f551ecaf3c9bddd86
BLAKE2b-256 87585f93b886e8ba71c61223e69b21b98854e8255239ddeb9b46ec0472290912

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1b2a0feb46f80286e71c3fbd7ce0d14616fb3c211e5d0869e8fa7fe0f7f29f15
MD5 7e90e24f93768942896b5a017aa8aa6d
BLAKE2b-256 1629a6bb339809e869faeff65d5b00bb1011c8656666e0e37fa7900bc5d81e5e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 b8e8b825bf1f7b0dddd86b43dcbfc4fb8cc7b3c04a9ff9c0fbac77aee425ff84
MD5 b8f89362aa1959e4c1055edfbc1a2578
BLAKE2b-256 1418d808b9f6543534e46b60fb8d5aa4c082e8b81dd511260f68b9c2cf434587

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4265f21289198f1c77d54670dea09866c71a78942230efdb188e090b42d43aed
MD5 e7e6196917252d2d3ee0339b7a91d6df
BLAKE2b-256 cb2f1985ea1808f6fab883a4b3e00a4e98aad6b96a979b3cee5d58bb8053520a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 3438d4f898a010de4da5303b2e7f51d1045703d07854102f18a1f79f8a2e371a
MD5 7f68ded0e1406d4210db9537e9cd22c2
BLAKE2b-256 32167014eced453747c68e56297f9c3228f0b08cf197394ba4d9ff615a271506

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f8504dcf97a9abc2a57ff793d5112d9b4eec1b44dd13813ad8979366622bd195
MD5 53f0c0730eed6f8562fcd65ee732348f
BLAKE2b-256 8eae544ad38b1c18e9e9649b1142a76f1fd9c3151572470226e1ad18a81046a4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ac5aa32ee4242c8f5e9b2a813ec29a540243e681137707173a7c6e275d8c17d
MD5 0455839535c2bd4d89154a4590cb401e
BLAKE2b-256 d2ad12dd02a26327a606eb4dab2111012b4a2110f7b641f7a05aff186b0cf94d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20230326-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 07370e8d37eb442a0763abdc6e42d903733778fa223e72c3a82ace0c42e87267
MD5 69970b91be1abb7e96d0b1ccaca6541f
BLAKE2b-256 4e8813a2c7699cd9423ec1c5f75e7dcd7bb54029092be7d0be4d003ced23f466

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