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

Uploaded Source

Built Distributions

cryptoauthlib-20240926-pp310-pypy310_pp73-win_amd64.whl (149.4 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20240926-pp39-pypy39_pp73-win_amd64.whl (149.4 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20240926-pp38-pypy38_pp73-win_amd64.whl (149.4 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20240926-cp313-cp313-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.13 Windows x86-64

cryptoauthlib-20240926-cp313-cp313-win32.whl (130.9 kB view details)

Uploaded CPython 3.13 Windows x86

cryptoauthlib-20240926-cp312-cp312-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.12 Windows x86-64

cryptoauthlib-20240926-cp312-cp312-win32.whl (130.9 kB view details)

Uploaded CPython 3.12 Windows x86

cryptoauthlib-20240926-cp312-cp312-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.12 macOS 11.0+ ARM64

cryptoauthlib-20240926-cp312-cp312-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.12 macOS 10.9+ x86-64

cryptoauthlib-20240926-cp311-cp311-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.11 Windows x86-64

cryptoauthlib-20240926-cp311-cp311-win32.whl (130.9 kB view details)

Uploaded CPython 3.11 Windows x86

cryptoauthlib-20240926-cp311-cp311-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cryptoauthlib-20240926-cp311-cp311-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cryptoauthlib-20240926-cp310-cp310-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.10 Windows x86-64

cryptoauthlib-20240926-cp310-cp310-win32.whl (130.9 kB view details)

Uploaded CPython 3.10 Windows x86

cryptoauthlib-20240926-cp310-cp310-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cryptoauthlib-20240926-cp310-cp310-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cryptoauthlib-20240926-cp39-cp39-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20240926-cp39-cp39-win32.whl (130.9 kB view details)

Uploaded CPython 3.9 Windows x86

cryptoauthlib-20240926-cp39-cp39-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cryptoauthlib-20240926-cp39-cp39-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20240926-cp38-cp38-win_amd64.whl (149.4 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20240926-cp38-cp38-win32.whl (130.9 kB view details)

Uploaded CPython 3.8 Windows x86

cryptoauthlib-20240926-cp38-cp38-macosx_11_0_arm64.whl (412.6 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20240926-cp38-cp38-macosx_10_9_x86_64.whl (412.6 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

File details

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

File metadata

  • Download URL: cryptoauthlib-20240926.tar.gz
  • Upload date:
  • Size: 546.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for cryptoauthlib-20240926.tar.gz
Algorithm Hash digest
SHA256 1e6a01411cf6381524eda4fc88a02305a9def992fa3a5e1448e55750c070d8ae
MD5 13fa77aa83af53d05cf73385c3997f65
BLAKE2b-256 a0195fde6580f32b21c8d641c58917a98c3d11da70482a8493277fed7f577806

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-pp310-pypy310_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-pp310-pypy310_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 74d046b77effb4f1c7017341c1d8fdcf8327c60fcc8a85135df90a537ce934d8
MD5 923f626d1e5221d0488d4b84c21a7deb
BLAKE2b-256 5833cdad1fc56e536b4d220605976fc0074a803f99a3411ac1c56b87d6791c57

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 2931af7fc54a32c004399a34f8f73d815c4b3a262209cd250cb38d0f88b51f1b
MD5 3a52824db70707839802aefa8cd04a68
BLAKE2b-256 2415aa7303b660571ef81b7485f0606bbc2d6f9b6547c6f857b6c7e39a0cc76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 d16051db2fbe89b8df71fdf088d6b613e9e791f414011c6ff5e94be89e5ab6e4
MD5 7059539912fbadf9990c260ae234746f
BLAKE2b-256 f66ebb37d78a689bcceaff9f290d5a8ad4b53d7a79e61e6cde299d6bdad2710e

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 d8ba79e94e4fa92eef7b4502d9e1ba4cac0a54534db75a0d000f7983772e827e
MD5 a169af5cddc3d9a6e0a495bf56a04874
BLAKE2b-256 16a1d631dec218ee23aa88a34709f636bf8542c05277191b945d86ede1d796a9

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp313-cp313-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp313-cp313-win32.whl
Algorithm Hash digest
SHA256 de10367332f227fa95305ce4e7641d6180cfc5313f2a4115a2c667630a94c9f4
MD5 37066ded3585f07f5637f4a893742dde
BLAKE2b-256 37b9b01b787d7fe44d92bdd821912986b8c854631c0cdcce889411e0782c213a

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 6af758919c3de7477e538db518a87d3a3f500cb0d461a22f64c80c5aa1fd2709
MD5 cce4ea28d77ddf95aebfd5b094fc086b
BLAKE2b-256 9f4d575fc8b76d8dd3540569b037802d0b986535cd9c1a97ee8477b5849f9d84

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp312-cp312-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp312-cp312-win32.whl
Algorithm Hash digest
SHA256 c616cafb42c235129268b3f3d30eacd613997e1851eb5328cd83e4e3c85e528a
MD5 3d4088ea526af20aaedb62ecf4ac2245
BLAKE2b-256 cc51ae51594be148954e498804306524b8b634bd726537caaac4eb9d3198a009

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 42755f21ea0483743d9fc383982a19abd85fd357d3d3f824404c0aef18369925
MD5 8f5344ca4e15852e8ea11d8bcf0153f4
BLAKE2b-256 97a866a9afce8e24b1772ea4bc74c534798f1c168fe15c11416d216ef13d0a76

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20240926-cp312-cp312-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp312-cp312-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f637629f20d693ba06cc5e1a729caab368479dcc12eecb95028bcbcf38655e7f
MD5 57b06c7f9ec662ab4aeef26530b3a45f
BLAKE2b-256 720340e8418c688caadebb69fa3bd5ab08624505ac1a259a14bfcd40add5da7b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 bfa4941de1f91fa6e8f73b24caf1ff534e862adba1a37e1681363996ab7fd1f8
MD5 9a9603e10a5d7f35cb07ba276f772c34
BLAKE2b-256 1dcfe82f47dba72d57b30747da32a4c06271c4ff5c72ed65a31f241d8cb80ebc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 b6a1962662a4363cd8aca537e90f27eb30491958e9da7d3bb5ad9b4a64a51f00
MD5 3a712278af1a5936b423e519987c82f7
BLAKE2b-256 40beca218fc16707c6bf8fb691daf805919458b410eb337d942a0f1ab229da4a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0ef66210a315f8c2307a34d149184b76f4bb87ca08f07e7fa1592a0f90d9a8e0
MD5 95fefc6840df3bb62577a8bcd0ccff0e
BLAKE2b-256 40e1acd0bf462d4248c478cc11764a3156883b06936c8b642eda6bbb690b9a22

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 88005d1dea35f94aeb84e8f795de1112a58f4b6ed8bb3c01a68a617e76601959
MD5 52a40ae14a8cb5f1ede6863bac276de0
BLAKE2b-256 2a17100fb11c86e728eb80aedfa046a3e252620677529c4d76c889bc86580e0f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 ec492eab395f493f456857fe32c5b4069a441d67d83cc7ab925efd1ef758b89c
MD5 e8439fcf26723ed9e4d9583f1106795b
BLAKE2b-256 888356acc2ddd50a176edf10200edbc771dd088261cf622e1ff8415f7c5a27cc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 a4fdfffa8c246d6355c277ceb02a8057dc14512b0e44d296967aab8d0366b803
MD5 e3e8b0c6c557a3aff4e028daf31f3b98
BLAKE2b-256 05403b455d1fe8f1809b2082b21dbcfd1df75c05e8847862da52ecfa1fda491f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8196bc44a15f2dd823869de4311251df98c44beb968ffccbb67c49a273b6dcef
MD5 6a08aa48830e040af4c90dd035ffe02f
BLAKE2b-256 5d60d5834d4ee30434bb83f5f2a835db4e945cc08c72a4354586c627923c4d31

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 06b62babb2e87063fab369792ed09d7451c9dd12e687369d7c528924afb09a6e
MD5 b24d172df5cc4c23234a2af0872a9a54
BLAKE2b-256 bdff0daecdab6483c66b3ccdd3115217aff048c599991ec4db88e1760ae1e633

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7cd1e593798824a28418126e696047f3850358001c0afbc72359d1e7615979bd
MD5 ffb4870db9ee979562b54ac4d93a0e95
BLAKE2b-256 05c99199ae785945f0f86d28db998bcaabe82fa4db277aa719613511f224a5e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 6ca9cfbc0c87c96a0ea3d864263c6f936835270712ec0cc0341c1e82395ad05c
MD5 6478266bdf7cc5d7c18faf53b53e895b
BLAKE2b-256 73ea9ba67213ee900c9fbba7e30ce3e5bb2ff40121f2261f611a04d2282a0c8d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c06fd0b73645eb1e699b03ed9fc3bddf2a23eb8fc0a02d748ace71772e19be68
MD5 22981b8341b61ad23e73b1f27076c318
BLAKE2b-256 af8d89c002f0b6a457fde17f61fe2f4be225643bb1dd57a0e120a9a8f7779032

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 d6518e6e5a5fe4018ba74faaee8456b1cc386179b81db73613454ef28759395c
MD5 e5cb2a090795f95852be27e0c6f4d172
BLAKE2b-256 154183f0a34d59d173fa21fdd266c5012bdeae919a921da4c7cec3c97fb92501

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 e38d2690e1367d04ea876334696cd8f3777113cc2d8488e3b8bb56689db24f07
MD5 9fa65a64bdbba958fda2d636fb05ac5e
BLAKE2b-256 e0cb0bc72bf1ed03a7977e4a8e6dcda22676e5d35a630858d3abb224e82d3877

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 abc4dea4befdaf36ad45057f717502aef3911651d014ffdbb5593ea50899e177
MD5 6ba82d6129cd0413089f668797ca5e6a
BLAKE2b-256 99dc7be940f139b88ac0dda795a8a1bd2a90f7ff3f69f30abd2bc82d95e8a3d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 acdb6efb6f5143e8cc4812467b0582b3827e256db9d4960e0a5c9f1f147fea2a
MD5 525b70760a7847f230dcc6e92f2b66e0
BLAKE2b-256 8feb3eb06c6a92e12dd40360afbae3314ba2f4734ac3ba26521bb23991402e01

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20240926-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 ed1c7da2ce5564faff1122540f00014e8d7db1e06fcfdbc5d4a79a3d9c5b86b9
MD5 e609ec9e84cd7974bf1a5583691a9ecb
BLAKE2b-256 448d98717a68f73f7502453ed15f45d02a25fdb76ffdd870065219a29234037e

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