Comments (4)
MKEK is a random AES-256 secret key that is salted by your hashed PIN. Despite it has billions of possibilities, the input to that system is your PIN. So, the larger is the better protection offers.
If your flash gets dumped offline it can be cracked by brute-force by introducing PIN values. Doing a quick calculus, using 4 RTX 3090 Ti, they could perform 512 x 10^6 hashes per second. For a 8-bytes PIN length in plain text (ASCII number 0-9) in few seconds would be cracked. If you use 8-bytes PIN length in HEX it will require thousands of years. However, HEX mode depends on client implementation (opensc I think uses ASCII mode).
For this reason, we provide alternative methods:
- PKA: Public Key Authentication uses the certificate of a secondary HSM to identify. It adds an additional layer but at the end the ultimate HSM device will depend on a PIN, otherwise you will create a circular identification.
- Secure lock: it relies on a private key that resides in the keychain of your OS. In that case, the inputs to unlock the MKEY is the PIN and that private key. It adds a significant robustness but then your HSM gets tied to your computer. You must unlock the HSM at every boot and introduce your PIN as usual. Secure lock can be enabled/disabled/unlocked via
pico-hsm-tool.py
.
These are not the optimal solutions, but this is due to Raspberry Pico, which is not designed as an homologated secure hardware device. We can add as many layers of security as we can, but at the end the flash memory can be always dumped, which is not a good deal for high security standards.
from pico-hsm.
Thanks
I think you should put a warning on pin security limitation.
I look at the code
double_hash_pin of pin are saved in a file
double_hash_pin of sopin are saved in a file
hash_multi of pin encrypt the mkek
hash_multi of sopin encrypt the mkek
hash_multi is based on sha256 with serial injection and 256 input len (pin is repeated several time)
double_hash_pin is hash_multi * 2 and pin xor
What is the purpose of 256 iter in hash_multi ?
What is the purpose of pin xor in double_hash_pin ?
Both pin and sopin need to be good to keep mkek secret
What are the specification of pin and sopin in sc-hsm protocol ?
https://github.com/OpenSC/OpenSC/wiki/SmartCardHSM#initialize-the-device
For sopin, opensc want a 16 hexadecimal and convert it to 8 bytes binary
for pin, it want a max len of 16 and driver send it as raw. But it don't know if there is other limitation. Numeric only on opensc side, need to checked.
from pico-hsm.
These are legacy functions defined by OpenPGP. The purpose of xor'ng pin in double_hash_pin is to change the input of second hash_multi.
sc-hsm is not a protocol, but a vendor solution from CardContact. PKCS11 interface defines PIN authorization but is up to implementation how is encoded. As you noted, so-pin expects 16 HEX string, but there is no limitation on PIN length (like 8 or 10 bytes). It is sent as ASCII, so if you pass --pin 0123
it will be sent as 30313233
. I never tried but it should work with symbol characters too (!@#$).
from pico-hsm.
MKEK is a random AES-256 secret key that is salted by your hashed PIN. Despite it has billions of possibilities, the input to that system is your PIN. So, the larger is the better protection offers.
If your flash gets dumped offline it can be cracked by brute-force by introducing PIN values. Doing a quick calculus, using 4 RTX 3090 Ti, they could perform 512 x 10^6 hashes per second. For a 8-bytes PIN length in plain text (ASCII number 0-9) in few seconds would be cracked. If you use 8-bytes PIN length in HEX it will require thousands of years. However, HEX mode depends on client implementation (opensc I think uses ASCII mode).
For this reason, we provide alternative methods:
- PKA: Public Key Authentication uses the certificate of a secondary HSM to identify. It adds an additional layer but at the end the ultimate HSM device will depend on a PIN, otherwise you will create a circular identification.
- Secure lock: it relies on a private key that resides in the keychain of your OS. In that case, the inputs to unlock the MKEY is the PIN and that private key. It adds a significant robustness but then your HSM gets tied to your computer. You must unlock the HSM at every boot and introduce your PIN as usual. Secure lock can be enabled/disabled/unlocked via
pico-hsm-tool.py
.These are not the optimal solutions, but this is due to Raspberry Pico, which is not designed as an homologated secure hardware device. We can add as many layers of security as we can, but at the end the flash memory can be always dumped, which is not a good deal for high security standards.
@polhenarejos Is it better to state this situation in readme? The current description in readme is slightly misleading.
If the Pico is stolen the contents of private and secret keys cannot be read without the PIN, even if the flash memory is dumped.
People who are not familiar with the project may easily mistaken that even if the pico hsm is lost, their keys are still very secure.
from pico-hsm.
Related Issues (20)
- Are there plans to add support for ed25519? HOT 5
- Response time issue HOT 2
- Error importing dkek in development branch HOT 3
- Unable to initialize a new Pico-HSM HOT 4
- Usage in Python HOT 5
- AES Encrypt / Decrypt HOT 13
- Usage on MacOS and Windows with Microsoft CCID driver HOT 8
- ERROR - common.h missing HOT 1
- ECDH derived key is missing one byte compared with openssl-pkeyutl HOT 3
- EC Key Creation HOT 4
- urllib.error.HTTPError: HTTP Error 500: Internal Server Error in "pico-hsm-tool.py" initialize command HOT 5
- mistake in pico-hsm-tool.py HOT 3
- Strange behaviours betwwen Windows 10 & 11 HOT 4
- How to list pkcs11 url of the private key? HOT 1
- Support for YD-RP2040 by VCC-GND Studio ? HOT 2
- USB IDs HOT 1
- waveshare zero build fails. HOT 11
- pico-hsm-tool urllib.error.HTTPError: HTTP Error 500: Internal Server Error HOT 2
- HTTP server error on initialization HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pico-hsm.