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 ompiled 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.

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

Uploaded Source

Built Distributions

cryptoauthlib-20190304-cp37-cp37m-win_amd64.whl (97.5 kB view details)

Uploaded CPython 3.7m Windows x86-64

cryptoauthlib-20190304-cp37-cp37m-win32.whl (86.6 kB view details)

Uploaded CPython 3.7m Windows x86

cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl (101.5 kB view details)

Uploaded CPython 3.7m macOS 10.6+ intel

cryptoauthlib-20190304-cp36-cp36m-win_amd64.whl (97.5 kB view details)

Uploaded CPython 3.6m Windows x86-64

cryptoauthlib-20190304-cp36-cp36m-win32.whl (86.6 kB view details)

Uploaded CPython 3.6m Windows x86

cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl (101.5 kB view details)

Uploaded CPython 3.6m macOS 10.6+ intel

cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl (97.5 kB view details)

Uploaded CPython 3.5m Windows x86-64

cryptoauthlib-20190304-cp35-cp35m-win32.whl (86.6 kB view details)

Uploaded CPython 3.5m Windows x86

cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl (101.5 kB view details)

Uploaded CPython 3.5m macOS 10.6+ intel

cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl (97.5 kB view details)

Uploaded CPython 2.7m Windows x86-64

cryptoauthlib-20190304-cp27-cp27m-win32.whl (86.7 kB view details)

Uploaded CPython 2.7m Windows x86

cryptoauthlib-20190304-cp27-cp27m-macosx_10_6_intel.whl (101.5 kB view details)

Uploaded CPython 2.7m macOS 10.6+ intel

File details

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

File metadata

  • Download URL: cryptoauthlib-20190304.tar.gz
  • Upload date:
  • Size: 255.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.2.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304.tar.gz
Algorithm Hash digest
SHA256 63c2cd007b2cb4e46d8fce0a0cd42d4b34fb965b9b5e16a41527814833f0da7e
MD5 782722af4d59a35ba431d5963f0766bf
BLAKE2b-256 a6b9698260893ad00c0a730012c1ef7e22c7dc214d219af790069a57a48fbf0f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190304-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for cryptoauthlib-20190304-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 2e9d825d904fee2602433ee9b28259c4ce10c54ec102c90bdee48b27bd6d98f9
MD5 505f17895f2489759ad7d0e3dc2c2804
BLAKE2b-256 e2997d3b999e114dfc8de77fe466b040e89e0d256a1f859f33eced5f633449b7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190304-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for cryptoauthlib-20190304-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 9944a981dc69111b76343e1566128a9322d33692992cbc23471922d22fe69927
MD5 87ae972708c9886bfba74d148ca66af6
BLAKE2b-256 f41d75c8686aca851d90fcf17715c220b84c4a841e57302d27cf9076640df8c5

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 101.5 kB
  • Tags: CPython 3.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp37-cp37m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 eb5cdc0891c3fa2d380306667f7a2155438db7be83be24682807100c7a681fd7
MD5 4ce2dff11ca55f1b69221b062f2e95bf
BLAKE2b-256 e4d9006bd5bddd38834785f632f34d8eaf9fcceb47b4afa628434c8ae94b39fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190304-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for cryptoauthlib-20190304-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 0e76fff545ec1ee78c81032123ba487d3c707497e7d696a4a77128b689e453fd
MD5 b7dbf04f79cebc22e332fc6a05738f84
BLAKE2b-256 1dd3139126ff039937a434e8f1f72f0032fa0816736cc8ded7ac8a090ec961c5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cryptoauthlib-20190304-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.6.8

File hashes

Hashes for cryptoauthlib-20190304-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 8542bbe01f5b0fcf4899e5d5c9520ff446aa7ee326c908e8a7834a5c700dd5c7
MD5 75c61d233be146cba58b63dd0aa7d1ba
BLAKE2b-256 f1f5c2a2966ba3ee13a00b30c293a4a58b9cf3e0dbe0053b36b058bf4a255f44

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 101.5 kB
  • Tags: CPython 3.6m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp36-cp36m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 3551d4eedffcff9207094010455bfb6e6ef14311824962a1a626b4140096fe03
MD5 a9d61034e1f05a09bab7ca08ad3459e3
BLAKE2b-256 0e8d18513c59f73d65edeb16fd4bbcab9c6a7bd3094f3eacaf36fe8f9c80f99b

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: CPython 3.5m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20190304-cp35-cp35m-win_amd64.whl
Algorithm Hash digest
SHA256 07616964fed80627800ddde1b24e09855062f3abf619d62f837a116b4af5bf1a
MD5 f31a6d455d42a7f7a7e8223139b286a6
BLAKE2b-256 954648935a384d3b492bc1d09e81c2bdc0a418e9f5d263b2680a9536feb2b357

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp35-cp35m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp35-cp35m-win32.whl
  • Upload date:
  • Size: 86.6 kB
  • Tags: CPython 3.5m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.5.4

File hashes

Hashes for cryptoauthlib-20190304-cp35-cp35m-win32.whl
Algorithm Hash digest
SHA256 282d8fa0b04b773e1535d8d9a35e548dde1b4ca5eecb3eeba6d2548f80c16c22
MD5 9123c558de51d18200fcc2543b6d5e0c
BLAKE2b-256 c61a5e723218ee2d7073cab6717a22c064537c46048a3a59723a0e3f8abcf12b

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 101.5 kB
  • Tags: CPython 3.5m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp35-cp35m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 574f243b71ab00d3ec2b039be0ba48f7775fd8b8c8312c4720d828bb3ada7ed4
MD5 69bed25ec65d985245880752653496c7
BLAKE2b-256 fdfd19a43a6d42a429beea54583274dea4266984be006169d011b57db9dfd87c

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl
  • Upload date:
  • Size: 97.5 kB
  • Tags: CPython 2.7m, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp27-cp27m-win_amd64.whl
Algorithm Hash digest
SHA256 b994430538d2caccc9a7747a053ee77693642e83d45b96b3c5f8460dcf627579
MD5 5166b96d364ddeb95f0696d6262b82e1
BLAKE2b-256 08bb2142b6acf9407db4dafb27e583590ecafbf349c9b8a687bfb119a8c25d72

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp27-cp27m-win32.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp27-cp27m-win32.whl
  • Upload date:
  • Size: 86.7 kB
  • Tags: CPython 2.7m, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp27-cp27m-win32.whl
Algorithm Hash digest
SHA256 310fb4a1e9f2247d868fcd88000daf367254d1e16bbee35284f203b118a1e47f
MD5 19c20cfe0e2c322e3b852a8bb8967bff
BLAKE2b-256 ec7958202ffd68c93c004a319a77449776aa0afb62ed38b681917bec67d27668

See more details on using hashes here.

File details

Details for the file cryptoauthlib-20190304-cp27-cp27m-macosx_10_6_intel.whl.

File metadata

  • Download URL: cryptoauthlib-20190304-cp27-cp27m-macosx_10_6_intel.whl
  • Upload date:
  • Size: 101.5 kB
  • Tags: CPython 2.7m, macOS 10.6+ intel
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/2.7.15

File hashes

Hashes for cryptoauthlib-20190304-cp27-cp27m-macosx_10_6_intel.whl
Algorithm Hash digest
SHA256 a5da66445769d1290c2468060e0e90c9eaa97495c4b9f13f0fdc4cd1a5b77a84
MD5 f6ad464b46ef3a44d88565eb6f297ba1
BLAKE2b-256 ce9de32ea46008522bdea93ee5c1a7048e5c7d3fdbd04c80eeab419faba86011

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