Skip to content

Commit 654a9e3

Browse files
committed
[docs] Update HSM docs
Update HSM docs with new CA implementation details. Signed-off-by: Miguel Osorio <miguelosorio@google.com>
1 parent 12e85da commit 654a9e3

File tree

3 files changed

+47
-39
lines changed

3 files changed

+47
-39
lines changed

docs/KeyPolicies.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -117,18 +117,15 @@ CKA_VERIFY | True | True
117117
### Intermediate Certificate Authority
118118
119119
Intermediate Certificate Authority. Used to endorse Device Under Test (DUT)
120-
generated payloads. This key is deployed in the SPM HSM.
120+
generated payloads. This key is generated directly in the SPM HSM.
121121
122122
> Note: Use the `hsm_certificate_authority_intermediate` macro to define this
123123
key.
124124
125-
**Wrapping Configuration**
126-
127-
The following wrapping configuration shall be used for private keys.
125+
**Key Generation**
128126
129-
* Recommended mechanism: `VendorThalesAesKwp` or other approved `AesKwp`
130-
mechanism.
131-
* Wrapping key: `Symmetric SKU-Specific Wrapping Key`
127+
The private key is generated directly in the SPM HSM and is not extractable.
128+
The CSR is generated in the SPM HSM and signed by the Root CA in the Offline HSM.
132129
133130
#### Attributes
134131
@@ -140,11 +137,11 @@ provisioning environment.
140137
141138
Attribute | SPM | Offline
142139
----------------|-------|--------
143-
CKA_DECRYPT | False | False
144-
CKA_EXTRACTABLE | False | True
145-
CKA_SENSITIVE | True | True
146-
CKA_SIGN | True | True
147-
CKA_TOKEN | True | True
140+
CKA_DECRYPT | False | N/A
141+
CKA_EXTRACTABLE | False | N/A
142+
CKA_SENSITIVE | True | N/A
143+
CKA_SIGN | True | N/A
144+
CKA_TOKEN | True | N/A
148145
149146
**Public Key**
150147
@@ -154,7 +151,6 @@ CKA_ENCRYPT | False | False
154151
CKA_TOKEN | True | True
155152
CKA_VERIFY | True | True
156153
157-
158154
## Generic Secrets
159155
160156
Generic secrets are used to generate tokens in the SPM HSM.

docs/hsm.md

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,40 @@ sival-token-losec: Low security generic securet used for token generation.
7171
The following sequence diagram shows the end to end SKU provisioning flow
7272
involving `Offline` and `SPM` HSMs.
7373

74-
Each SKU should have three configuration bundles:
74+
Each SKU should have the following configuration bundles:
7575

7676
1. SPM HSM Initialization
7777
2. SKU Initialization (Offline HSM)
7878
3. SKU Export (Offline HSM)
7979
4. SKU Import (SPM HSM)
80+
5. Certificate Authority Operations
81+
82+
### Certificate Authority Operations
83+
84+
The certificate authority operations are split into three main steps:
85+
86+
1. Root CA Certificate Generation (Offline HSM)
87+
2. Intermediate CA CSR Generation (SPM HSM)
88+
3. Intermediate CA CSR Signing (Offline HSM)
89+
90+
```mermaid
91+
sequenceDiagram
92+
participant Offline
93+
participant SPM
94+
participant File
95+
autonumber
96+
97+
note left of Offline: Root CA Certificate Generation
98+
Offline->>File: generate-root-cert(opentitan-ca-root)
99+
100+
note left of SPM: Intermediate CA CSR Generation
101+
SPM->>SPM: ecdsa-generate(sival-dice-key-p256)
102+
SPM->>File: generate-csr(sival-dice-key-p256)
103+
104+
note left of Offline: Intermediate CA CSR Signing
105+
File->>Offline: import-csr(sival-dice-key-p256)
106+
Offline->>File: sign-csr(opentitan-ca-root, sival-dice-key-p256)
107+
```
80108

81109
### Build SKU
82110

@@ -158,11 +186,6 @@ sequenceDiagram
158186
159187
note left of Offline: Offline - HSM SKU Keygen
160188
Offline->>Offline: rsa-generate(sku-rsa-rma)
161-
162-
loop all <application> endorsement certs
163-
Offline->>Offline: ecdsa-generate(sku-endorse-cert-<application>-key)
164-
end
165-
166189
Offline->>Offline: generic-secret-generate(sku-token-hisec)
167190
Offline->>Offline: generic-secret-generate(sku-token-losec)
168191
```
@@ -194,11 +217,6 @@ sequenceDiagram
194217
note left of Offline: Offline - SKU Key Export
195218
File->>Offline: rsa-import(spm-rsa-wrap)
196219
Offline->File: wrap(spm-rsa-wrap, sku-aes-wrap)
197-
198-
loop left all <application> endorsement certs
199-
Offline->>File: wrap(sku-aes-wrap, sku-endorse-cert-<application>-key)
200-
end
201-
202220
Offline->>File: wrap(sku-aes-wrap, sku-token-hisec)
203221
Offline->>File: wrap(sku-aes-wrap, sku-token-losec)
204222
```
@@ -243,12 +261,9 @@ sequenceDiagram
243261
244262
note left of File: SPM SKU Initialization
245263
File->>SPM: unwrap(spm-rsa-unwrap, sku-aes-wrap)
246-
loop all <application> endorsement certs
247-
File->>SPM: unwrap(sku-aes-wrap, sku-endorse-cert-<application>-key)
248-
end
249-
264+
SPM->>SPM: ecdsa-generate(sival-dice-key-p256)
250265
File->>SPM: unwrap(sku-aes-wrap, sku-token-hisec)
251-
File->>SPM: unwrap(spm-rsa-wrap, sku-aes-wrap)
266+
File->>SPM: unwrap(sku-aes-wrap, sku-token-losec)
252267
```
253268

254269
1. Expand the contents of `sival_sku_release.tar.gz`.
@@ -257,15 +272,9 @@ sequenceDiagram
257272
$ tar vxf sival_sku_release.tar.gz
258273
```
259274

260-
2. Run SKU export scripts.
275+
2. Run scripts
261276

262-
```shell
263-
$ ./spm_sku_init.bash \
264-
-m "${HSMTOOL_MODULE}" \
265-
-t "${SPM_HSM_TOKEN_SPM}" \
266-
-p "${HSMTOOL_PIN}" \
267-
-i offline_export_sival_sku.tar.gz
268-
```
277+
See `token_init.sh` script for examples.
269278

270279
## Troubleshooting
271280

rules/scripts/hsm_ca_sign.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ certgen () {
206206
CERT_FILE="${OUTDIR_CA}/${ca_key}.pem"
207207

208208

209-
209+
210210
if [[ "${FLAGS_SIGN_ONLY}" == false ]]; then
211211
# Generate a CSR for the CA key. This can be either a root CA or an
212212
# intermediate CA.
@@ -219,7 +219,7 @@ certgen () {
219219
else
220220
# Running in sign only mode means that the CSR is already present in the
221221
# input tarball and/or ca directory. Only need to check if the CSR file
222-
# exists.
222+
# exists.
223223
if [[ ! -f "${CSR_FILE}" ]]; then
224224
echo "Error: CSR file ${CSR_FILE} does not exist."
225225
exit 1
@@ -266,6 +266,9 @@ certgen () {
266266
-CAkeyform engine \
267267
-CAkey "${ENDORSING_KEY}"
268268
fi
269+
270+
echo "Converting certificate for ${ca_key} to DER"
271+
openssl x509 -in "${CERT_FILE}" -outform DER -out "${OUTDIR_CA}/${ca_key}.der"
269272
}
270273

271274
for i in "${!CERTGEN_TEMPLATES[@]}"; do

0 commit comments

Comments
 (0)