forked from chipsalliance/caliptra-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- FMC modfied to generate a self signed FMC Alias CSR test upon cold boot. - Persistent driver modified to add persistent memory for the FMC Alias CSR - Runtime modified to expose an API to retrieve it. - Test case created to verify the self signed FMC Alias CSR. - Test case created to verify the RT Alias Certificate with the pub key of the FMC Alias CSR.
- Loading branch information
Showing
12 changed files
with
203 additions
and
74 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
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
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,51 @@ | ||
// Licensed under the Apache-2.0 license | ||
|
||
use crate::Drivers; | ||
|
||
use caliptra_cfi_derive_git::cfi_impl_fn; | ||
use caliptra_cfi_lib_git::cfi_launder; | ||
|
||
use caliptra_common::{ | ||
cprintln, | ||
mailbox_api::{GetFmcAliasCsrReq, GetFmcAliasCsrResp, MailboxResp, MailboxRespHeader}, | ||
}; | ||
use caliptra_error::{CaliptraError, CaliptraResult}; | ||
|
||
use caliptra_drivers::{FmcAliasCsr, IdevIdCsr}; | ||
|
||
use zerocopy::{AsBytes, FromBytes}; | ||
|
||
pub struct GetFmcAliasCsrCmd; | ||
impl GetFmcAliasCsrCmd { | ||
// #[cfg_attr(not(feature = "no-cfi"), cfi_impl_fn)] | ||
#[inline(never)] | ||
pub(crate) fn execute(drivers: &mut Drivers, cmd_args: &[u8]) -> CaliptraResult<MailboxResp> { | ||
let csr_persistent_mem = &drivers.persistent_data.get().fmc_alias_csr; | ||
|
||
match csr_persistent_mem.get_csr_len() { | ||
FmcAliasCsr::UNPROVISIONED_CSR => Err(CaliptraError::RUNTIME_GET_FMC_CSR_UNPROVISIONED), | ||
len => { | ||
let mut resp = GetFmcAliasCsrResp { | ||
data_size: len, | ||
..Default::default() | ||
}; | ||
|
||
let csr = csr_persistent_mem | ||
.get() | ||
.ok_or(CaliptraError::RUNTIME_GET_FMC_CSR_UNPROVISIONED)?; | ||
|
||
// NOTE: This code will not panic. | ||
// | ||
// csr is guranteed to be the same size as `len`, and therefore | ||
// `resp.data_size` by the `FmcAliasCsr::get` API. | ||
// | ||
// A valid `IDevIDCsr` cannot be larger than `MAX_CSR_SIZE`, which is the max | ||
// size of the buffer in `GetIdevCsrResp` | ||
resp.data[..resp.data_size as usize].copy_from_slice(csr); | ||
|
||
Ok(MailboxResp::GetFmcAliasCsr(resp)) | ||
} | ||
_ => Err(CaliptraError::RUNTIME_INTERNAL), | ||
} | ||
} | ||
} |
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
Binary file added
BIN
+447 Bytes
runtime/tests/runtime_integration_tests/test_data/fmc_alias_csr.der
Binary file not shown.
33 changes: 33 additions & 0 deletions
33
runtime/tests/runtime_integration_tests/test_data/fmc_alias_csr.txt
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,33 @@ | ||
Certificate Request: | ||
Data: | ||
Version: 1 (0x0) | ||
Subject: CN=Caliptra 1.0 FMC Alias/serialNumber=65F6BB3FAE445D0D0DB36F3DC84999B60B059CF63D3E25FE00C47B239857F3BB | ||
Subject Public Key Info: | ||
Public Key Algorithm: id-ecPublicKey | ||
Public-Key: (384 bit) | ||
pub: | ||
04:cb:0e:91:9a:d7:5f:9e:02:f2:39:8a:28:a9:3f: | ||
6d:f3:01:36:37:c8:5c:d3:26:26:77:71:88:93:5c: | ||
6c:e8:3a:c5:c4:bb:df:05:db:15:c1:38:97:f0:f5: | ||
ca:e3:44:76:b4:e8:c5:b8:28:b9:82:8d:11:db:ca: | ||
79:92:4f:8c:1b:09:37:cb:d2:f5:3c:47:b9:dd:26: | ||
78:5b:d5:d8:11:96:52:6f:b7:d7:31:8f:9a:9f:e1: | ||
cf:9d:95:b0:64:d5:39 | ||
ASN1 OID: secp384r1 | ||
NIST CURVE: P-384 | ||
Attributes: | ||
Requested Extensions: | ||
X509v3 Basic Constraints: critical | ||
CA:TRUE, pathlen:5 | ||
X509v3 Key Usage: critical | ||
Certificate Sign | ||
2.23.133.5.4.4: | ||
0.................... | ||
Signature Algorithm: ecdsa-with-SHA384 | ||
Signature Value: | ||
30:65:02:31:00:cf:f3:d2:d8:30:86:5a:f7:f9:d4:3d:63:d3: | ||
eb:c2:1e:16:f5:d1:3b:1e:98:38:ca:3d:8f:da:ed:9d:44:8f: | ||
d5:f6:41:35:73:8a:14:05:91:63:17:58:94:4f:56:df:ea:02: | ||
30:4f:db:4a:2e:26:f2:aa:ec:74:41:e4:7e:c2:6a:c5:07:e9: | ||
b3:50:52:bb:5c:68:4b:83:ea:07:33:09:84:0b:a1:b9:8a:9f: | ||
d8:57:73:b0:3b:76:62:f3:4e:7f:32:9f:4f |
Oops, something went wrong.