Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
This module provides a thin python ctypes layer to evaluate the cryptoauthlib interface to Microchip CryptoAuthentication devices.
Code examples for python are available on github as part of CryptoAuthTools under the python/examples directory
pip install cryptoauthlib
pip install -U cryptoauthlib
pip uninstall cryptoauthlib
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
The family of devices supported currently are:
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.
from cryptoauthlib import *
load_cryptoauthlib()
assert ATCA_SUCCESS == atcab_init(cfg_ateccx08a_kithid_default())
Call library APIs of your choice
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.
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
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 for python are available on github as part of CryptoAuthTools under the python/examples directory
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.
See Release Notes
FAQs
Python Wrapper Library for Microchip Security Products
We found that cryptoauthlib demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.