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

Uploaded Source

Built Distributions

cryptoauthlib-20221018-pp39-pypy39_pp73-win_amd64.whl (149.6 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20221018-pp38-pypy38_pp73-win_amd64.whl (149.6 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20221018-pp37-pypy37_pp73-win_amd64.whl (149.6 kB view details)

Uploaded PyPy Windows x86-64

cryptoauthlib-20221018-cp311-cp311-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.11 Windows x86-64

cryptoauthlib-20221018-cp311-cp311-win32.whl (132.3 kB view details)

Uploaded CPython 3.11 Windows x86

cryptoauthlib-20221018-cp311-cp311-macosx_11_0_arm64.whl (220.3 kB view details)

Uploaded CPython 3.11 macOS 11.0+ ARM64

cryptoauthlib-20221018-cp311-cp311-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.11 macOS 10.9+ x86-64

cryptoauthlib-20221018-cp310-cp310-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.10 Windows x86-64

cryptoauthlib-20221018-cp310-cp310-win32.whl (132.3 kB view details)

Uploaded CPython 3.10 Windows x86

cryptoauthlib-20221018-cp310-cp310-macosx_11_0_arm64.whl (220.3 kB view details)

Uploaded CPython 3.10 macOS 11.0+ ARM64

cryptoauthlib-20221018-cp310-cp310-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.10 macOS 10.9+ x86-64

cryptoauthlib-20221018-cp39-cp39-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.9 Windows x86-64

cryptoauthlib-20221018-cp39-cp39-win32.whl (132.3 kB view details)

Uploaded CPython 3.9 Windows x86

cryptoauthlib-20221018-cp39-cp39-macosx_11_0_arm64.whl (220.3 kB view details)

Uploaded CPython 3.9 macOS 11.0+ ARM64

cryptoauthlib-20221018-cp39-cp39-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.9 macOS 10.9+ x86-64

cryptoauthlib-20221018-cp38-cp38-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.8 Windows x86-64

cryptoauthlib-20221018-cp38-cp38-win32.whl (132.3 kB view details)

Uploaded CPython 3.8 Windows x86

cryptoauthlib-20221018-cp38-cp38-macosx_11_0_arm64.whl (220.3 kB view details)

Uploaded CPython 3.8 macOS 11.0+ ARM64

cryptoauthlib-20221018-cp38-cp38-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.8 macOS 10.9+ x86-64

cryptoauthlib-20221018-cp37-cp37m-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20221018-cp37-cp37m-win32.whl (132.3 kB view details)

Uploaded CPython 3.7m Windows x86

cryptoauthlib-20221018-cp37-cp37m-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.7m macOS 10.9+ x86-64

cryptoauthlib-20221018-cp36-cp36m-win_amd64.whl (149.6 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20221018-cp36-cp36m-win32.whl (132.3 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20221018-cp36-cp36m-macosx_10_9_x86_64.whl (220.3 kB view details)

Uploaded CPython 3.6m macOS 10.9+ x86-64

File details

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

File metadata

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

File hashes

Hashes for cryptoauthlib-20221018.tar.gz
Algorithm Hash digest
SHA256 97bc96c64d2095189a58761c7301b63c59ea21eb298e4d0a4e75f2bba5f4dabc
MD5 91cb6ff2f5dd9286f9df296a0a7f92af
BLAKE2b-256 d1bb20b214783fbc252099aebae2c7141e296c5a19b5d2d250a091c9d05ea4f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-pp39-pypy39_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 16c2c247767dd9501cf264c6c08780981b6f85173a724342b4c9a6113a909434
MD5 d5061236f35fa4a0c0ca5291ac4e8de9
BLAKE2b-256 081ef9ace8ba2b64c230f416d225e347f6f12cd44250539a1f91d0bfd2ee2501

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-pp38-pypy38_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 9a78cfd817749bac2c6b121dee92506476b27efd2e5870d7d443b2f1342e9e19
MD5 aef73567f67ab23a4b8cb4f67f1795e7
BLAKE2b-256 e4574ed9e6df16d96d3f9ecfdad45fca2e3334fdaf25dbcc6544d0e4e3841d6e

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-pp37-pypy37_pp73-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-pp37-pypy37_pp73-win_amd64.whl
Algorithm Hash digest
SHA256 5198ea3eaa955b1c4af6f27602903e3e092c8394c05f3893093483b3303df129
MD5 389a44c16bf1a9e7b6541c0ccaf5a3ca
BLAKE2b-256 e5a662b6532fb1cfceb2520679f11c2e4c08d0374c4ef3e01092d10f3fb48662

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 0eadf8765f255ae46124c6495b7c2a892d1af6f1956616947aa75d56550c9615
MD5 6a85595e78549e4626af9d670efa8179
BLAKE2b-256 bbcea7258e488e82883cf566219b010f6973ff7312a17664cf3216eea749175e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp311-cp311-win32.whl
Algorithm Hash digest
SHA256 eb24c32a33c25e742d3c2c514e791e54f887f47fc46784ef98b1aaa8e0dd3952
MD5 a02782b9b6ca877286d6165600a53be0
BLAKE2b-256 5332414e58f754b1a3fc4d79585ba41a3e4b855aa5c5c0d565c8996a8e584be5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a364d9b3fa4074329709fd1106e63997e4ee746b44821728794733891f63fd2b
MD5 be46db3c1701cf2ada9ddfc6e0732b4e
BLAKE2b-256 c4b66de62197ecf647d7e72798d5708efb852669fc2f39c25339f0ca7993a44e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 6bf1d9217049a5c5e2e8eb1cfb6452e7cb8ac08081f08c85c33852e7febeff06
MD5 4897486e465d3b2af7703db1f4057037
BLAKE2b-256 5635578653fa57827f4012613fe908813481f9c0638723902e2a4776be663540

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 f0a44ee560e4dd4692ff542e0fe8668d5c9c036e3b458bd37b6cf9dd3939d808
MD5 eb1bfb3d57174d068e939a0df743a5bb
BLAKE2b-256 1894b9481f437ec91da75338d291239684be477c05fb2f558963c77bb681df16

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp310-cp310-win32.whl
Algorithm Hash digest
SHA256 3ddde4e743abf3556a58d67f7628878a8ef886204dd9a5b0c05ce1045eb5d899
MD5 ea923089c8f3262da4af0335d1a4ba30
BLAKE2b-256 89085b6847f4f35644f16c200a3032f53bcc7829cd595343362c60ebbf7ed2b2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 7263b217c26c098f25dcd5e82f511dd7e487dfdc042bd8cfb53be007820ee909
MD5 9efadf9a08d294d1e2c1aa2df5aa252e
BLAKE2b-256 55bdad75693058ae04e7a92c527b592f460a0b23f06fd0b4b9c43eb3b310d5d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f57f53f56397e220e2b0a67fbe69f51041216d2009235b237d8626c844a3e977
MD5 8fb9c77fb64f8d355d3592787bcab892
BLAKE2b-256 d53b4d3e0770964f60caf198292febde1b8c5a83b3a85304af0f0beb8aa847a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 ac4aa7245b24adb75c1b8c48cde0aad17b642a5027a2628b0671be25bc9c1ee8
MD5 e6d9d514cd0e31b15818ec5192e2b06a
BLAKE2b-256 ca3aa5f33ac744017f7d857fc82568651fdd85386c38a0def3d4b9cb8d879b9e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp39-cp39-win32.whl
Algorithm Hash digest
SHA256 685a1a2631a4e1029f6a45b48eef28c34465cc0408f2253f51c2f6ec81767a6f
MD5 d4df512a3bd60ca4c3a517bb4bafe9e6
BLAKE2b-256 2acfde2e5d8eb91cedb8d4b87e7d75227b2320745db5807b26c3f53f5695a842

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab4a8c8f428d7c2b1a33cc26b47037aa45ebdeeb0192e31e0597410c4daf3379
MD5 147240c6adafa1343a03457a38aaaafd
BLAKE2b-256 46b81515908dd4e538e541d36a693af5796567044d831edf58b554a681f6ea64

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 93246f0cda65dcdf3bd7c364222b7381834194af71eb3a34aa477e483e791367
MD5 343863b8498cbac11a77f2dabd38db62
BLAKE2b-256 b8f5e1f74c71c02d48ce5222db8940186bdb953fed5e073b621cb4a8b6d5b156

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 2ea94279a1c1c65dd42d99ea5ba97ff86eb9337f9ed2aef8ee319731502c164a
MD5 1a91f3bfa84f843d8b1228d21cb27836
BLAKE2b-256 ce5fc008e4e3c9c8583215fb650e783056ef18d1d728fe8a8a0f61d966d3eb56

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 0809f824f9f403fe2e6c18cc377232e6ce0fc9d5a2e1bbcb1ebe6a69da3cf538
MD5 92c882a28bc68d8e6548fde61496e3c8
BLAKE2b-256 200c7a4baa7687da0142ba2b90dbb22dda7dcba64f1c6619dda2fbda91116a43

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp38-cp38-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 935faef4c0e4621218cb2320406abcaec961f47c8b87f3cce14eb2299687eeff
MD5 57f9ae733e1583c492a109950f10d2c8
BLAKE2b-256 75fbca3c41fc405aea6759ca91b7b85ddc16b316a9d97fcff6f4c798391f97f3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 5c44ed424b202718019a7f0d93ff31606ce71938eec20548c9e17f4212f93af8
MD5 ce0f4f549a587bb5dcf20bb79b81f98c
BLAKE2b-256 d8f7c8f20a4416f964b7ce83e163ec5f54135b7215451396fe3fc54d55c87ee9

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp37-cp37m-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 ad95ab70a4983b2f6ec1dce046202559286e3c242f17e840d78506134aede90b
MD5 ac0419bf8c88a4276f7642d078d37084
BLAKE2b-256 f358367e516d0a5d5d71f6ef200de016eae7a918e508a0471560fb88633f1984

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp37-cp37m-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 0dc5e741a7f3336d4402b28a2173ae2e9410ad1bdf9bc4649315a6b8dbdc8fc2
MD5 f25700c721f7fc89a81dbd7e43653bc0
BLAKE2b-256 aa30fc0a29951c1f8aeac40c297bfa2b13b8727f8ca59b9952ec3246626ef4e4

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp37-cp37m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f1c4208100655ae93ea1e79db4ebbbe488246b0aa990d376851124367d27f576
MD5 40524c0a0d2b4b799350198354284c0a
BLAKE2b-256 13338f4d5bcfa33dcb3a041c26120ccfe415d09f83a8c0ca12e38f3301a6df43

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 9833592caede7b07e1c1832a7747dba664f5b1b0f2640de9bddd57b8cd222f5c
MD5 807430cd74c37240a6ef4b9bb6b4db15
BLAKE2b-256 ed006c5e7116585b937656841b9de3a1034f289de7d35c68443709d8e2583d2f

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 e619d96ba1dad47bfdadf9dd0d48417562908b3976a0235a46533f9a9e9d1550
MD5 d058eb0f0b9650224d7b1fc94ad0fb33
BLAKE2b-256 4872ee4191d00274143f41ce2f7b9673fd62eb363ef8dd947c5cf17f96fd66ec

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20221018-cp36-cp36m-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for cryptoauthlib-20221018-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 9eac0d8c9106be934ec35716931f3c61735018ee20187042ddfe3a0775f83ce3
MD5 566a480c211d91ae00f619fe0db37f60
BLAKE2b-256 450863cbbb54e879e7be359121e357520a560ca06ae955b25a3ff83fe0e29e2f

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