|
| 1 | + |
| 2 | +# rpifwcrypto |
| 3 | + |
| 4 | +The Raspberry Pi Firmware Cryptography service is a mailbox based API |
| 5 | +that allows a limited set of cryptographic operations to be performed |
| 6 | +by the firmware without exposing private keys to userspace. |
| 7 | + |
| 8 | +The initial implementation is designed to support PiConnect and |
| 9 | +provides an ECDSA P-256 SHA256 signature API. |
| 10 | + |
| 11 | +A SHA256 HMAC API is provided to provide basic support for derived keys |
| 12 | +instead of using the raw device unique private key |
| 13 | +e.g. HMAC(serial-number + EMMC CID) could be used for a LUKS passphrase. |
| 14 | + |
| 15 | +Although this service can be used via raw vcmailbox commands the |
| 16 | +recommended API is either the command line rpi-fw-crypto application |
| 17 | +or the librpifwcrypto.so shared library. |
| 18 | + |
| 19 | +**Build Instructions** |
| 20 | +Install prerequisites with "sudo apt install cmake libgnutls28-dev"" - you need at least version 3.10. |
| 21 | + |
| 22 | + - *mkdir build* |
| 23 | + - *cd build* |
| 24 | + - *cmake ..* |
| 25 | + - *make* |
| 26 | + - *sudo make install* |
| 27 | + |
| 28 | +**Usage** |
| 29 | + |
| 30 | +* rpi-fw-crypto -h (Displays usage instructions for all operations) |
| 31 | +* rpi-fw-crypto get-num-otp-keys (Returns the number of OTP key slots) |
| 32 | +* rpi-fw-crypto sign --in message.bin --key-id 1 --alg ec --out sig.bin (Signs message.bin with the device unique OTP key (id 1)) |
| 33 | +* rpi-fw-crypto get-key-status 1 (Gets the status of key-id 1) |
| 34 | +* rpi-fw-crypto set-key-status 1 LOCKED (Blocks the raw OTP read API on this key until the device is rebooted) |
| 35 | +* rpi-fw-crypto hmac --in message.bin --key-id 1 --out hmac.bin (Generates the SHA256 HMAC of message.bin and OTP key id 1) |
| 36 | + |
| 37 | +** Notes ** |
| 38 | +The device unique private key can be provisioned with the `rpi-otp-private-key` utility. |
| 39 | +This MUST be a raw ECDSA P-256 key and not just a random number. |
| 40 | + |
| 41 | +This service is not a hardware security module and the current implementation |
| 42 | +does not protect the key and/or OTP from being accessed directly with root level privileges. |
| 43 | +It just removes the need to expose the key to userspace (e.g. initramfs) scripts. |
0 commit comments