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

Uploaded Source

Built Distributions

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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

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

Uploaded PyPy Windows x86-64

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

Uploaded PyPy manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11 Windows x86-64

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

Uploaded CPython 3.11 Windows x86

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

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.11 macOS 11.0+ ARM64

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

Uploaded CPython 3.11 macOS 10.9+ x86-64

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

Uploaded CPython 3.10 Windows x86-64

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

Uploaded CPython 3.10 Windows x86

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

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.10 macOS 11.0+ ARM64

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

Uploaded CPython 3.10 macOS 10.9+ x86-64

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

Uploaded CPython 3.9 Windows x86-64

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

Uploaded CPython 3.9 Windows x86

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

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.9 macOS 11.0+ ARM64

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

Uploaded CPython 3.9 macOS 10.9+ x86-64

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 Windows x86

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

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

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

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20221111-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-20221111.tar.gz.

File metadata

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

File hashes

Hashes for cryptoauthlib-20221111.tar.gz
Algorithm Hash digest
SHA256 4f308962c85111570531abce7d5f443f6c375aded48a718e6cb51d34b3d1628e
MD5 2294c276a1fd09edcad309ade9b82a23
BLAKE2b-256 4418c3bbb7335d0797737f72bd06315a6c6f0839f3ada73d399867c007513eb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 4b2d0d0fe33567251dea27244111786995f79e3ac1a84ad56858e404f2b68a3c
MD5 bd6dd87279026b3423ee8dc6d6a01971
BLAKE2b-256 aa9b981677815b645284ac5e221958acec117c3f70300d5734b2ae9520f84ca4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ca9300477b9747bb124445ecc8cf5997fc2b2237610b6792c7ffa25e6fb0352e
MD5 bf4490a46de0eae0ab2e3c3ab4bb3f61
BLAKE2b-256 a1b27c9a85000d2498c42f4278dfe5c3af545455c56a9ddc15e55b53050d2a2b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 745c8ff52aa1854838810b12a0bca3e3236a73a03f07b8051b43deb1d93dba34
MD5 46620c9e0f6e0820f72508698bff3693
BLAKE2b-256 a36fc1e15ceebb0e4f804546c67636cbccf7b33e7a081c511b004c554d2779ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6d0c3f136c4e2a0f77f2d25e2db04bd711aab79eb56e594f56649389cdf23437
MD5 cd9ceb8b6db4daae1413129dcd6d1968
BLAKE2b-256 002f85a988e7b4c66eab203aeb4691be7222a3b85ad163ab22843b7ff2499e41

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 09499424ea4490fed47b24f110f000ba96d8efc37a78172c7be8e3c21cd834da
MD5 998bef3fa6800a615a42dec2c1db3fa2
BLAKE2b-256 28ff4bdb1cc6fdb9edd49f77c1cbf496bb3d8e1f5420c4823596e1f673c2f0e7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 de7a9c1f3bd803a2b02038c76011882d10aeb410b6a251b1399305a2b0a5b853
MD5 86690dc559c29a70398afe843243eb10
BLAKE2b-256 ec62c4c39f335036c9de3706e75e0fce23b38365bef1dccbbd82b0a370425a59

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp311-cp311-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 fdb11a7493e709a155c348ec277eba2a0ba94b9e2d820d72cdb77b4101a54d3c
MD5 494e48bd5ea6db9990fc8f168e51eca0
BLAKE2b-256 8ac445fb496d11cbd160662484e469b89971bb76292d69c89792005994d647f5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3f5e7b95531b783f757c75075bec19dc946f3f53ed73901733f9723548e49fd9
MD5 5233f5b73f73bd2cb46e9f86b42aa4fd
BLAKE2b-256 d473e8b0e9a624d5ee72ed99ba4fc1b0c06e17f2c38abd869fbff6540ba26979

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 2b43c8e529f7a41da87ea7192cec1e4a9be1ea3ed08ea5f26783fc1263983717
MD5 71591b40c364ab5600f856e7bd9e7a4b
BLAKE2b-256 ebb69be06cfd14198693317a68cbfe3692e03982fd4ddfb7059beace7e38d443

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 5791e2db87945de8e237e049963bfb9d8f88159ce8a22429e16662c35c7a229f
MD5 42de2ca471569136e2e8a54f636f1e29
BLAKE2b-256 127dd6c20c6cc9317699e78d9561087961782d1d3ab5711dbf22a4ebbc0a290b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 324aabda9484dde693970197978fefc53c87419b65bbb7c6346b8a7f2de26435
MD5 2e08bafa589546a9626f0877fb6c53fa
BLAKE2b-256 ac956fb511855cc9b95999f0f5f6e1fa313fa799e783e07680b96ec657ab729b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp310-cp310-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 f14e2681dc7bd926e49b31f0855b3ed5c3de64cb4c84263d8ef75d035d3d45e0
MD5 37f478f1905c2a2b7e0fb5b9112ff822
BLAKE2b-256 80476fa5b64583372423c475e9a4c70be241c6313dd1d9a206d24c36f96b767e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 fceee54b183ad416c65be69a583e52e5bf14f7b787023038bed61f1978e36426
MD5 54d6755df50049a1ce2b13a034b72d79
BLAKE2b-256 9e106828c8b1031c3386c9802a7313e23cd9c14de6f3847ef44a7b0c158863d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 857ce22ddc361bf296efcec803126f1e072a61337f17794abf9a9c1dc3d45726
MD5 d61a581a035faf2e943eb6348cd99e26
BLAKE2b-256 5bfc6a743b59c0812e140561834bf09cd521320d211d3494ba3842d9f31bdebe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 b888373569d2cc927466bafeae2affb1c3026fc2684886e1fa2b8105e3ded629
MD5 6481719695691fee10feb9c670fe1004
BLAKE2b-256 9617ff985c3738f222606cec99283de2a4391bca0a81eda0f08a3727da925cd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 611035bbc000fa1af6a5ca9251c7d904c1b3d0b7fb4f8f36795d5ba8f84f4d8b
MD5 4ef5f18425c982eb8a4fa5de069c3b1f
BLAKE2b-256 63456b7669200909c050d13d007da6a758299d7d8ee967fd90af3f47e2c32b4b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp39-cp39-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 cab8834a074613e22caa27885926aee42e0736e6e5ad37e8e45c12a7bbe2f65f
MD5 64dac64e7e2349a56814dcacfa2df0f4
BLAKE2b-256 5c55fd031a72aaff098655b3d23b9b487da0fb0234997aced0205cfd2bd83b5d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 26279da7830784759d4bca7dfd3b9906917734062bac0162e5305dc433c2c3d3
MD5 a9251181078fbce21a2cbb2c789437e1
BLAKE2b-256 c0144a8058f4d4602fc274ea0f971f9e5d8b01f8f00be42c19a4bfc25827e47c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3e7564f7ffa1cf3d985b15fffbf663da009c0942f0804f632286d3716ab865e8
MD5 faef2835cfe779b8ea0d160910c90c61
BLAKE2b-256 8be99f54495e9dc8c63d56c2b2dbfab646295d031bf5817b54deaa85cf7545ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 6032792fbcd7fa830d3e407aa25d4a9041b7e7c0385f7c9dc361e7608ad206a7
MD5 ea259b8b9415be0e0c307bcfd12939d5
BLAKE2b-256 c27e344577dd8cc7c60c3d28db4a06f73067888c8724496fcf6cfb19f3ec0d7e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 cd09fcc8be1195694dffaa27f9c75d635cf38f65cafdd31fb2b70782b1686001
MD5 1e17bfd6a7c453cd89b0bc20072594f3
BLAKE2b-256 2e79fefc54db142531f381f09b7ed70f9b41da99f8d46a444101d52c050effd1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp38-cp38-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 26bb9089a921a5fbcba5aa1f7791fdab6b2c81006784656605381f7de4896d54
MD5 cf3bf8c8ccf83d51882c89ee42a0f312
BLAKE2b-256 dd4db1d0ce54abc1c6669574da702d83c3e4779779b7f4f7837c156c9b6e58a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a9f779379dcca3f2f3434cf6d036a4dbbf4bea2a86f35b2d8829b8615f7754b
MD5 e6179bb58917936a162d35deb7a8a84c
BLAKE2b-256 7357f1c982b4928fe00bbcda59f905a394b01e467442fcc9715ad164a66dd41a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221111-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f9b8321b8e3479b961f35659e876266547c2b591b74b38510aadd8fa39457144
MD5 ad00aaa0c7ee160c6007bbae8699bb15
BLAKE2b-256 df63cd2f0b5ba2a5d349057ef0bd136c96d0cd1a5ee4d60cd9f4de58f9e65a4c

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