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

Uploaded Source

Built Distributions

cryptoauthlib-20221114-pp39-pypy39_pp73-win_amd64.whl (154.8 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-pp38-pypy38_pp73-win_amd64.whl (154.8 kB view details)

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-cp311-cp311-win_amd64.whl (154.8 kB view details)

Uploaded CPython 3.11 Windows x86-64

cryptoauthlib-20221114-cp311-cp311-win32.whl (136.8 kB view details)

Uploaded CPython 3.11 Windows x86

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

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-cp311-cp311-macosx_11_0_arm64.whl (225.4 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cryptoauthlib-20221114-cp311-cp311-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cryptoauthlib-20221114-cp310-cp310-win_amd64.whl (154.8 kB view details)

Uploaded CPython 3.10 Windows x86-64

cryptoauthlib-20221114-cp310-cp310-win32.whl (136.8 kB view details)

Uploaded CPython 3.10 Windows x86

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

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-cp310-cp310-macosx_11_0_arm64.whl (225.4 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cryptoauthlib-20221114-cp310-cp310-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cryptoauthlib-20221114-cp39-cp39-win_amd64.whl (154.8 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20221114-cp39-cp39-win32.whl (136.8 kB view details)

Uploaded CPython 3.9 Windows x86

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

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-cp39-cp39-macosx_11_0_arm64.whl (225.4 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cryptoauthlib-20221114-cp39-cp39-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20221114-cp38-cp38-win_amd64.whl (154.8 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20221114-cp38-cp38-win32.whl (136.8 kB view details)

Uploaded CPython 3.8 Windows x86

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

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

cryptoauthlib-20221114-cp38-cp38-macosx_11_0_arm64.whl (225.4 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20221114-cp38-cp38-macosx_10_9_x86_64.whl (225.4 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20221114.tar.gz
Algorithm Hash digest
SHA256 cc63dba63f1983c12ad18ecb3f1595083feffc0cb827d2a8d3a54c850d26ed5d
MD5 aab4751905a63fdb9eccf2a9be3995a7
BLAKE2b-256 5658eb4e4f3535c83cf5e58bad0142d7db8776409966ffa29649a4ff04e329a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 509a4bcd366e7070ecb89513a9b522388c4c26fa08d959891969937fc833657d
MD5 0db710d4e6c733d63389349aa6856fe1
BLAKE2b-256 3eb3adcb8fc62f1ffe2766dd45290fd5b1407ea9d8c1daa339c090c9653ae58c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d6ada216642acc6791656d0dd70ac0621e1c752601520f7c40478537e71d1b33
MD5 19d06c5af5a32f76af90cf1c1c1f0579
BLAKE2b-256 fd8185762358d42ce5e5f2d066be5bf3d4de0224c2d0c279e4d73f94dd59eb26

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 ad3f689f33e8cc5f9181fab07f5a8731ef8d288dd7d8403254692e20c1db392d
MD5 4901807225d8b5aea41a1bce56be07bc
BLAKE2b-256 a6895e79c1ec59637f391693cebed98149fafcceadced1f7812cf284cc07a551

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e31c3a1463369b387105123c2747490cc142358244ed933db55952a0d5db726
MD5 dc4e619ff2af671cebfb213e70eded0f
BLAKE2b-256 80ac927733920c85e35a566fd6b215ccaf7b21622800826459efc87790a59c38

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 90d1418ccf64d78affed136687cb3f18872d4b7612a4284d0407b7a059c6e375
MD5 1fdb4c22030e40d34996ecadf7881013
BLAKE2b-256 fdcf45f0e2727cf73e93df998947652de9c1355d294edd6014896d40b0ab18e2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 5c44837656a44f19db606383ed472924e8f457a41a7f610cc897dae5827a5f34
MD5 8a3c84d1ceb0d7b7b3f99928f758bee1
BLAKE2b-256 7e929dee6002aa4ea4e66b2771aca7b9690817df5f268ef7f018f8cafb65230d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 67ffd80534a786435cae82e79a265e46e1379512ddd723ab15351ba8bcbdc77b
MD5 e8ccd599bef390e89d1e891e665a1ef4
BLAKE2b-256 4bb63f0802fc46d50da2fbf4d3e9f01bdfcf4d8c55b182abfd0fd9976a845f43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e02dcef015a3141c3466377c1886b5bcf635207d156ac7c63648d38b993ee6ca
MD5 87bbd90167a1dea9443cc221877fe583
BLAKE2b-256 9a8864ab8b8171af6dae053d55c90aad2739694ccf5694acc15853f5c41ab228

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 19326ef321b239d9643bfc4ab999e8adb1c1116f00c85956a2b09b7b1c574b80
MD5 3c4e827062e75aeffceda5c1780fbab2
BLAKE2b-256 4e81d6465aa41a2a074b8bb9c75d6df14fa7badc75c36d1f657eb95c81c3a0ed

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ee579627cebb069cac6bd2df3d1e6901ff8a50e1093728d373b2ed1681315165
MD5 4653480064de5f06e9b866b55edefe5a
BLAKE2b-256 e48aeeb2349183e4ab6e928918df9a28ddb13334ec6cdb29ecace93f3ff946b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 24efb67102c54357c2176db7b54b0541429075fdb0c2e167fdd6d1d441a5bd71
MD5 99ebc837d35d336e70f45feb6105c578
BLAKE2b-256 6d2df75c3f38f93514968740011ec24f3720167d6f296f685730d38c58986221

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 bab17f993dabf01f1552fba8b8f759b958c54ab269d369b1ae32125f15f10244
MD5 e0fc78d9d557e87bbe893e8e8b8452c0
BLAKE2b-256 1d6965395399035a037731a2c90ed737cfe5c3b68a60705abae7f051d5b33f8f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e82adc3ad32c53a066609c9f4560ae05a68501cbc09897ffa0f90b631dd5d36b
MD5 2228374ffe8080bb0a695d1277d9b0e1
BLAKE2b-256 88f20a3e55929d826e8d24c12cce3fd2245f7c4bf619ca55b1ba3e4f2c7ac254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 efc5def96e2bc8a82e1d7c6e9abbf5f12b94f5a4723a598e9bd741cdf824c03f
MD5 68ec279e843c23df0ee20e7915108cc0
BLAKE2b-256 77a4a430f05c09bcbf572c5770d06e37ea6f04ac31acaf5a3de14482c8e3a5b3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a240f752041b661e64525a798bb7c94b1ee0acfbad58f88a30f0bbb3e1d58365
MD5 87238aef4a34abd56982ee3ee5ab0c9f
BLAKE2b-256 c869211037026883a9082740a5d757e029aa819b9fbfd6e6376e318892e6a753

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 d1813bcfa0e1007599310fd4be1e74d5c07daee395c80e4ffbded9904e4238de
MD5 509f4b1fe9d7745c740640604062baaf
BLAKE2b-256 2a715ae9c3f4aee953168a2d72388e4a1e937846eb51253d9086355c8036e5d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 662124c64236e86801182b7038cde64aca7462295627268a859511b75c8b95cb
MD5 383f4d3c48f12773710573947161942a
BLAKE2b-256 46561e96ec1f8e84acb9b7fa37ccffb6c1e1a5c8bf73df8a0fd8fb7fb22833cd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a84e437fb6d0e56373a75cee4baff5365421806fa361438e3a5d311c8764cc67
MD5 14d86d3efd0c4a63313d7e292e7bb038
BLAKE2b-256 56846122dd26bf17ee64576ee33048876302e34d29835b6471d16691735f9eae

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 621d205c487d877b5a3a1bce037737f9fd75dbfccce1409a5818ae91ee7d6e14
MD5 a59fcb09dec5fddf1d42aacbcf9203b0
BLAKE2b-256 bc8cd8866e7f5612f2b08c11e78d6064a0014b7d697b169c06e1f6c55d9f90ca

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2c76888d3863dbf3110a1d96285d128de758649851b7a0ed3b13ac1aca01b117
MD5 4cb7a88bd9f7e3584ef887fd00abebe1
BLAKE2b-256 4060783b343fd62f39d8a7f46f645860883b5a2028ea87485bdca8114397743f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 54e62b9c6781dba0d21d9a833e92cfe459e1bdec8c3e8835c400f36d3cd190a0
MD5 d916076ce6e86d78ffe8452f1bfcb08d
BLAKE2b-256 53270a7e3631c8a26f6a6591788ff6d3137fb85194151e603d27a4ac7a2ba1ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a7bf4a82dd6a69ced1f3994e3fc676bb1578952fe1bfbad7dae6f8ac8b26176f
MD5 a2a6ad3b1fc2cfe68af07aa31bcd1110
BLAKE2b-256 b77148fe76dd2e1e1fc6aebe101bcd28a8fc8d3a5f2be6af2ffd8080b8d8dd73

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fe43246c9935ddb4e43a443a0729512fa7afae9ec010427e3f948efa4765e794
MD5 a76ab55a11d0cc9c2cfc4cdadb1aac47
BLAKE2b-256 0252bbe0d58c984b7941e0952ebccfd2f7ae2900a7b14a07673d95c86216aa0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221114-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bbcae7561a59b1bf0ada3f135c9fd9ed930d0e0822eb8501e09e2bf4d27a4b54
MD5 261a11939c0dd2be3fb4e7f58476f959
BLAKE2b-256 785b85bfe7ae36a883f5484210195105cefee27069951ca5593ec307ec074a95

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