-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[provisioning] enable SIVAL cert endorsement with Nitrokeys
The DICE CA key is stored on a Nitrokey, which can be used in a benchtop provisioning flow to endorse DICE certificates. Signed-off-by: Tim Trippel <[email protected]>
- Loading branch information
1 parent
d6a9b03
commit 24ddaf3
Showing
14 changed files
with
154 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright lowRISC contributors (OpenTitan project). | ||
# Licensed under the Apache License, Version 2.0, see LICENSE for details. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
package(default_visibility = ["//visibility:public"]) | ||
|
||
exports_files(glob(["**"])) | ||
|
||
filegroup( | ||
name = "ca_data", | ||
srcs = [ | ||
":ca_config.json", | ||
":dice_ca.pem", | ||
"//sw/device/silicon_creator/manuf/keys/fake:rma_unlock_enc_rsa3072.pub.der", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# CA Endorsement Keys | ||
|
||
Certificate Authority endorsement keys are are used to endorse the following | ||
certificate chains during personalization: | ||
1. DICE attestation certificate chains, and | ||
2. SKU specific certificate chains. | ||
|
||
The real (private) keys used for the SIVAL SKU are stored on offline HSMs. The | ||
matching public keys and certificates are checked into the repository. | ||
|
||
To use the private keys to endorse the certificates in benchtop provisioning | ||
flow, one must set the following envars: | ||
- `PKCS11_MODULE_PATH`: to point to the PKCS#11 shared library for the | ||
hardware token they are using, and | ||
- `PKCS11_TOKEN_PIN`: to the PIN used for hardware token authentication. | ||
|
||
For example, if the SIVAL private keys are stored on a Nitrokey, and you wanted | ||
to test the SIVAL FT provisioning flow, you would issue the following Bazel | ||
command: | ||
```sh | ||
bazel test --test_output=streamed \ | ||
//sw/device/silicon_creator/manuf/base:ft_provision_sival_fpga_hyper310_rom_with_fake_keys \ | ||
--action_env=PKCS11_MODULE_PATH=/opt/nitrokey/lib/libsc-hsm-pkcs11.so \ | ||
--action_env=PKCS11_TOKEN_PIN=<pin> | ||
``` | ||
|
||
## Generating a Root CA Certificate from a Token Held ECDSA Key | ||
|
||
To generate a Root CA certificate from a public key held on a hardware token, | ||
e.g., Nitrokey, you may use the CSR (Certificate Signing Request) configuration | ||
file checked in to this repo (`dice_ca.conf`) as in input to the following | ||
commands: | ||
```sh | ||
# Set the PKCS11_MODULE_PATH envar to point to the shared library for the | ||
# hardware token you are using, e.g.: | ||
export PKCS11_MODULE_PATH=/opt/nitrokey/lib/libsc-hsm-pkcs11.so | ||
|
||
# Generate the CSR: | ||
openssl req -new -engine pkcs11 -keyform engine -config ../dice_ca.conf -out dice_ca.csr \ | ||
-key "pkcs11:pin-value=<pin>;object=sv00-earlgrey-a1-ca-dice-0" | ||
|
||
# Generate the X.509 certificate in PEM format: | ||
openssl x509 -req -engine pkcs11 -keyform engine -in dice_ca.csr -out dice_ca.pem \ | ||
-days 3650 -extfile ../dice_ca.conf -extensions v3_ca \ | ||
-signkey "pkcs11:pin-value=694201;object=sv00-earlgrey-a1-ca-dice-0" | ||
|
||
# Examine the generated certificate: | ||
openssl x509 -in dice_ca.pem -text | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"dice": { | ||
"certificate": "sw/device/silicon_creator/manuf/keys/sival/dice_ca.pem", | ||
"key_id": "0x5398A4F090F2A95C3D52FC98DEB9F2F9AF042F6E", | ||
"key_type": "Token", | ||
"key": "sv00-earlgrey-a1-ca-dice-0" | ||
}, | ||
"ext": { | ||
"certificate": "sw/device/silicon_creator/manuf/keys/sival/dice_ca.pem", | ||
"key_id": "0x5398A4F090F2A95C3D52FC98DEB9F2F9AF042F6E", | ||
"key_type": "Token", | ||
"key": "sv00-earlgrey-a1-ca-dice-0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
MIIBHjCBxAIBADBiMQswCQYDVQQGEwJVUzELMAkGA1UECAwCQ0ExDzANBgNVBAoM | ||
Bkdvb2dsZTEUMBIGA1UECwwLRW5naW5lZXJpbmcxHzAdBgNVBAMMFkdvb2dsZSBF | ||
bmdpbmVlcmluZyBJQ0EwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAATu4HkgAzRX | ||
PJAhMw9E/qXZzoQ+Kx3awtKAPk29herxqr7d/bEYWVjKBpMg9QzTjQHQBswmU/H3 | ||
GTr5FCjfas2foAAwCgYIKoZIzj0EAwIDSQAwRgIhAP14uGJ6C2g2lAl06oRrODme | ||
yjQviuSdqIaszMxFknHtAiEAszHbVPKgTtSnSggw0jFkIx8pZnUJD4cOFJ5EUGOV | ||
Sk4= | ||
-----END CERTIFICATE REQUEST----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIICqDCCAk+gAwIBAgIUFDAsPzL14w6/jKAtysPUTcGRgM4wCgYIKoZIzj0EAwIw | ||
YjELMAkGA1UEBhMCVVMxCzAJBgNVBAgMAkNBMQ8wDQYDVQQKDAZHb29nbGUxFDAS | ||
BgNVBAsMC0VuZ2luZWVyaW5nMR8wHQYDVQQDDBZHb29nbGUgRW5naW5lZXJpbmcg | ||
SUNBMB4XDTI0MTIwNDAzNTgwOFoXDTM0MTIwMjAzNTgwOFowYjELMAkGA1UEBhMC | ||
VVMxCzAJBgNVBAgMAkNBMQ8wDQYDVQQKDAZHb29nbGUxFDASBgNVBAsMC0VuZ2lu | ||
ZWVyaW5nMR8wHQYDVQQDDBZHb29nbGUgRW5naW5lZXJpbmcgSUNBMFkwEwYHKoZI | ||
zj0CAQYIKoZIzj0DAQcDQgAE7uB5IAM0VzyQITMPRP6l2c6EPisd2sLSgD5NvYXq | ||
8aq+3f2xGFlYygaTIPUM040B0AbMJlPx9xk6+RQo32rNn6OB4jCB3zAdBgNVHQ4E | ||
FgQUU5ik8JDyqVw9UvyY3rny+a8EL24wgZ8GA1UdIwSBlzCBlIAUU5ik8JDyqVw9 | ||
UvyY3rny+a8EL26hZqRkMGIxCzAJBgNVBAYTAlVTMQswCQYDVQQIDAJDQTEPMA0G | ||
A1UECgwGR29vZ2xlMRQwEgYDVQQLDAtFbmdpbmVlcmluZzEfMB0GA1UEAwwWR29v | ||
Z2xlIEVuZ2luZWVyaW5nIElDQYIUFDAsPzL14w6/jKAtysPUTcGRgM4wDwYDVR0T | ||
AQH/BAUwAwEB/zALBgNVHQ8EBAMCAYYwCgYIKoZIzj0EAwIDRwAwRAIgQmIdM2Mv | ||
KI70Huk3zWbukclONM9dAJ8n9qiD0HFnypICIBeaUmZZ1FQtsa0i0KNb7+KH5EvV | ||
g3u7GESPQU2jEnCj | ||
-----END CERTIFICATE----- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters