Device freeze on device unlock #68
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Board: rpi Pico
pico-hsm version: 5.0
Here are the steps to reproduce the issue:
On step 3, the green light starts blinking rapidly, and no further action occurs.
Is it reproducible with pico-hsm-tool?
Hi,
No, because the pico-hsm-tool requires a keyring, and I'm on Linux, which doesn't have a compatible keyring. Instead, I use a slightly modified version of the SecureLock2 class :
The main difference here is that the key is provided as a variable during initialization, rather than being retrieved from a keyring.
I use the following function to initialize the device:
And device_config.HSM_ACCESS_KEY derivation function is
HSM_ACCESS_KEY = secrets.token_bytes(32)According to tests, key freeze on line
It seems like something had changed in firmware, because works fine with version 3.6.
Sounds strange. Which board?
@polhenarejos RPI Pico
@polhenarejos I just ran a sequence of tests (manually disconnecting the device when it froze), and in some cases (approximately 10-20%), it did not freeze.
Here is log from
pcsdthis is a log of init + unlock procedure until the freeze
Here's the problem:
You are sending an encrypted key of 48 bytes, but it must be 32 bytes. I guess that
HSM_ACCESS_KEY = secrets.token_bytes(32)does not return 32 bytes, but 48. Check it.@polhenarejos
According to specs and tests it returns exactly 32 bytes
https://docs.python.org/3/library/secrets.html
I might be mistaken, but it’s unclear how the ciphertext could be 32 bytes, considering the encryption process involves an IV as shown in this section of the code.
There was a buffer overflow in the code and it has been fixed.
You can test it tomorrow with nightly development build or build it yourself.
@polhenarejos
Many thanks! By the way, which versions should be set to build from the nightly with this command
?
Nightly builds are built automatically during the midnight. So you can wait until tomorrow and download a fresh built.
If you prefer not waiting, then you can build it.
developmentbranch uses Pico SDK 2.1.0.@polhenarejos Thanks. Just tested: initialization with SecureLock and unlock works smoothly. But there is problem with further use. I created a new ticket https://github.com/polhenarejos/pico-hsm/issues/69