Use cryptoauthlib's Python interface to communicate with ateccX08 chips on a RaspberryPi
643
This image contains Microchip's cryptoauthlib and Python compiled for the RaspberryPi and arm32v7 architecture for use with the ateccX08 series chips. You can use cryptoauthtools demo scripts against this docker with a few caveats noted below.
This docker was created as there are a few issues both around the latest available precompiled Python version available for the RaspberryPi as well as installing the required Python cryptography and cryptoauthlib libraries. The cryptoauthlib package assumes a Python version <3 and <3.5; at the time of writing the precompiled package available for Raspbian was 3.4.2. This docker includes Python 3.7.2.
Likewise due to issues with the latest version of cryptoauthlib library on a RaspberryPi, the included version at the time of writing is 20190105.
If you wish to install cryptoauthlib directly on a RaspberryPi without Docker, I recommend reviewing all the packages included near the end of the Dockerfile. In some cases it was clear that these packages were required for compilation, but others were more difficult to pin down.
This image uses the Python stretch-slim arm32v7 image as a starting point; QEMU has been added for cross-compilation support.
To use this docker you'll want to make sure that you include access to the RaspberryPi's i2c (cryptoauthlib also includes HAL support but I haven't tested that). This docker is intended such that you can call Python scripts that live on the host system without having to rebuild the docker image. For example:
docker run -it --rm --name atecc_test --device /dev/i2c-1 -v "$PWD":/usr/src -w /usr/src ccamrobertson/atecc_python_pi python some_script.py
I recommend starting with a cryptoauthtools script such as info.py which gives you information about a connected ateccX08 chip. There is one caveat with using the cryptoauthtools scripts - they include a check_if_rpi () function in common.py that is designed to detect whether or not the script is being executed on a RaspberryPi. This script will report a false reading from within the Docker. While it should be possible to modify the docker options such that the running docker will have access to the RaspberryPi model information, I opted to modify the function to always report true given this project is designed solely for a RaspberryPi.
Assuming check_if_rpi() returns true, you should be able to run the following command against cryptoauthtools' info.py script in the current directory (mof course, make sure you also have common.py) - my results are from an unconfigured, unlocked attecc608a:
docker run -it --rm --name atecc_test --device /dev/i2c-1 -v "$PWD":/usr/src -w /usr/src ccamrobertson/atecc_python_pi python info.py --iface i2c --device ecc
Device Part:
ATECC608A
Serial number:
01 23 A5 29 9C 82 50 C8 EE
Configuration Zone:
01 23 A5 29 00 00 60 02 9C 82 50 C8 EE 01 39 00
C0 00 00 00 83 20 87 20 8F 20 C4 8F 8F 8F 8F 8F
9F 8F AF 8F 00 00 00 00 00 00 00 00 00 00 00 00
00 00 AF 8F FF FF FF FF 00 00 00 00 FF FF FF FF
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 55 55 FF FF 00 00 00 00 00 00
33 00 33 00 33 00 1C 00 1C 00 1C 00 1C 00 1C 00
3C 00 3C 00 3C 00 3C 00 3C 00 3C 00 3C 00 1C 00
Check Device Locks
Config Zone is unlocked
Data Zone is unlocked
Done
The cryptoauthtools script config.py allows you to configure a bare ateccX08 with configurations hardcoded into the script. The usage of this command would look something like the following (this example uses the default 0xC0 i2c slave address for the ateccX08):
docker run -it --rm --name atecc_test --device /dev/i2c-1 -v "$PWD":/usr/src -w /usr/src ccamrobertson/atecc_python_pi python config.py --iface i2c --device ecc --i2c 0xC0
Configuring the device with an example configuration
Serial number:
01 23 A5 29 9C 82 50 C8 EE
Reading the Lock Status
Config Zone: Unlocked
Data Zone: Unlocked
Getting the I2C Address
Current Address: C0
Program Configuration
Programming ATECC608A Configuration
Success
Verifying Configuration
Success
Locking Configuration
Locked
Activating Configuration
Activated
Generating New Keys
Key 0 Success:
8F BD 82 8A 2E 32 B7 1F 1B CE 81 E9 DA 0F F4 92
5E 7D 46 AD 77 01 48 3D D6 FA 8C C5 61 7C 20 12
06 7C A6 19 C0 F3 EB 32 55 8E 0C 44 C2 CD DB 03
E6 32 A7 CF 66 C8 99 9D 1D CD 90 05 75 27 37 4C
Key 2 Success:
C3 A8 94 47 13 18 7F AC 37 3C C3 31 D9 9C B5 00
A4 49 A3 BB D3 E1 9A 39 24 9D C3 EE 29 4A A1 D7
53 55 69 E9 42 21 66 9D EB 35 D9 53 54 09 84 65
6B D4 78 B2 69 1C 9F BF 0A C0 4B 19 BE 4B 58 F3
Key 3 Success:
89 5A 97 E9 11 8A 5F 0A FB E2 3D 87 D7 1E F1 1E
E2 A0 50 C2 0D 4E ED C8 47 C0 81 3C 2D ED A8 09
00 10 37 32 08 40 32 DA 83 D8 20 C5 89 60 A1 67
54 6C 5B C2 8A DE E5 4C B6 04 DC 94 12 CA 81 B5
Key 7 Success:
A5 37 54 8D B0 90 5E B8 B0 77 A1 6C D1 3E 41 A5
75 7A 14 29 3E 35 5D 42 03 C0 2C 99 D9 5F 48 0E
47 7E 7A 45 3D 44 98 4F 57 0D 74 86 43 DE 08 3E
1A AB 7E DE 69 66 78 C8 25 E5 A2 D3 5C 5C 0C A9
Device Successfully Configured
Content type
Image
Digest
Size
183.3 MB
Last updated
almost 7 years ago
docker pull ccamrobertson/atecc_python_pi