Skip to content

Commit

Permalink
Add task named 'attest' that acts as the root of trust for reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
flihp committed Jun 22, 2023
1 parent 32bb50e commit 2fb10de
Show file tree
Hide file tree
Showing 18 changed files with 526 additions and 13 deletions.
34 changes: 34 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions app/lpc55xpresso/app-sprot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,14 @@ pins = [
{ name = "SP_RESET", pin = { port = 1, pin = 5}, alt = 0, direction = "input"},
]

[tasks.attest]
name = "task-attest"
priority = 5
max-sizes = {flash = 12256, ram = 16384}
stacksize = 9000
start = true
extern-regions = ["dice_alias", "dice_certs"]

[signing.certs]
signing-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
root-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
Expand Down
8 changes: 8 additions & 0 deletions app/lpc55xpresso/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ task-slots = ["jefe"]
stacksize = 1200
extern-regions = ["sram2"]

[tasks.attest]
name = "task-attest"
priority = 5
max-sizes = {flash = 12256, ram = 16384}
stacksize = 9000
start = true
extern-regions = ["dice_alias", "dice_certs"]

[signing.certs]
signing-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
root-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
Expand Down
10 changes: 9 additions & 1 deletion app/oxide-rot-1/app-dev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = 0

[kernel]
name = "oxide-rot-1"
requires = {flash = 52384, ram = 4096}
requires = {flash = 52512, ram = 4096}
features = ["dice-self"]

[caboose]
Expand Down Expand Up @@ -155,6 +155,14 @@ stacksize = 2048
[tasks.sp_measure.config]
binary_path = "../../target/gimlet-c/dist/default/final.bin"

[tasks.attest]
name = "task-attest"
priority = 5
max-sizes = {flash = 12256, ram = 16384}
stacksize = 9000
start = true
extern-regions = ["dice_alias", "dice_certs"]

[signing.certs]
signing-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
root-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
Expand Down
10 changes: 9 additions & 1 deletion app/oxide-rot-1/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ version = 0

[kernel]
name = "oxide-rot-1"
requires = {flash = 59840, ram = 2528}
requires = {flash = 59840, ram = 2696}
features = ["dice-mfg"]

[caboose]
Expand Down Expand Up @@ -134,6 +134,14 @@ start = true
stacksize = 2600
task-slots = ["swd"]

[tasks.attest]
name = "task-attest"
priority = 5
max-sizes = {flash = 12256, ram = 16384}
stacksize = 9000
start = true
extern-regions = ["dice_alias", "dice_certs"]

[signing.certs]
signing-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
root-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
Expand Down
8 changes: 8 additions & 0 deletions app/rot-carrier/app.toml
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,14 @@ stacksize = 2048
[tasks.sp_measure.config]
binary_path = "../../target/gemini-bu/dist/final.bin"

[tasks.attest]
name = "task-attest"
priority = 5
max-sizes = {flash = 12256, ram = 16384}
stacksize = 9000
start = true
extern-regions = ["dice_alias", "dice_certs"]

[signing.certs]
signing-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
root-certs = ["../../support/fake_certs/fake_certificate.der.crt"]
Expand Down
8 changes: 0 additions & 8 deletions chips/lpc55/chip.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ size = 4096

# this is the start of the USB SRAM AHB peripheral (0x4000 bytes total)
# we appropriate this SRAM for passing DICE artifacts
[dice_certs]
address = 0x40100000
size = 0xa00

[dice_alias]
address = 0x40100a00
size = 0x800

[dice_spmeasure]
address = 0x40101200
size = 0x800
Expand Down
34 changes: 34 additions & 0 deletions chips/lpc55/memory.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,37 @@ write = false
execute = false
dma = true

# RAM region used to hand common part of DICE certificate chain forward to
# Hubris tasks
[[dice_certs]]
name = "a"
address = 0x40100000
size = 0xa00
read = true
write = false
execute = false

[[dice_certs]]
name = "b"
address = 0x40100000
size = 0xa00
read = true
write = false
execute = false

# RAM region used to hand DICE artifacts forward to the attestation responder
[[dice_alias]]
name = "a"
address = 0x40100a00
size = 0x800
read = true
write = true
execute = false

[[dice_alias]]
name = "b"
address = 0x40100a00
size = 0x800
read = true
write = true
execute = false
45 changes: 45 additions & 0 deletions idl/attest.idol
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// Interface to 'attest' task.

Interface(
name: "Attest",
ops: {
"cert_chain_len": (
doc: "Get the number of certs in the attestation cert chain",
args: {},
reply: Result(
ok: "u32",
err: Complex("AttestError"),
),
encoding: Hubpack,
idempotent: true,
),
"cert": (
doc: "Get a cert from the RoT-R",
args: {
"index" : "u32",
"offset" : "u32",
},
leases: {
"dest": (type: "[u8]", write: true),
},
reply: Result(
ok: "()",
err: Complex("AttestError"),
),
encoding: Hubpack,
idempotent: true,
),
"cert_len": (
doc: "Get length of a cert in the cert chain",
args: {
"index" : "u32",
},
reply: Result(
ok: "u32",
err: Complex("AttestError"),
),
encoding: Hubpack,
idempotent: true,
)
}
)
4 changes: 2 additions & 2 deletions lib/dice/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ impl RngSeed {
}

#[derive(Deserialize, Serialize, SerializedSize)]
pub struct PersistIdCert(SizedBlob);
pub struct PersistIdCert(pub SizedBlob);

#[derive(Deserialize, Serialize, SerializedSize)]
pub struct IntermediateCert(SizedBlob);
pub struct IntermediateCert(pub SizedBlob);
2 changes: 1 addition & 1 deletion lib/stage0-handoff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const_assert!(DICE_RANGE.end <= UPDATE_RANGE.start);
const_assert!(UPDATE_RANGE.end <= MEM_RANGE.end);
/// The error returned when `HandoffData::load` fails.
#[derive(
Debug, Clone, PartialEq, Eq, Deserialize, Serialize, SerializedSize,
Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize, SerializedSize,
)]
pub enum HandoffDataLoadError {
Deserialize,
Expand Down
21 changes: 21 additions & 0 deletions task/attest-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[package]
name = "attest-api"
version = "0.1.0"
edition = "2021"

[dependencies]
derive-idol-err = { path = "../../lib/derive-idol-err" }
hubpack = { workspace = true }
idol-runtime = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
zerocopy = { workspace = true }

[build-dependencies]
idol = { workspace = true }
serde = { workspace = true }

[lib]
test = false
bench = false
11 changes: 11 additions & 0 deletions task/attest-api/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use idol::client;
use std::error::Error;

fn main() -> Result<(), Box<dyn Error + Send + Sync>> {
client::build_client_stub("../../idl/attest.idol", "client_stub.rs")?;
Ok(())
}
23 changes: 23 additions & 0 deletions task/attest-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

//! API crate for the 'attest' task.

#![no_std]

use hubpack::SerializedSize;
use serde::{Deserialize, Serialize};
use userlib::sys_send;

#[derive(
Copy, Clone, Debug, Deserialize, Eq, PartialEq, Serialize, SerializedSize,
)]
pub enum AttestError {
CertTooBig,
InvalidCertIndex,
NoCerts,
OutOfRange,
}

include!(concat!(env!("OUT_DIR"), "/client_stub.rs"));
29 changes: 29 additions & 0 deletions task/attest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "task-attest"
version = "0.1.0"
edition = "2021"

[dependencies]
lib-dice = { path = "../../lib/dice" }
hubpack = { workspace = true }
idol-runtime = { workspace = true }
num-traits = { workspace = true }
ringbuf = { path = "../../lib/ringbuf" }
serde = { workspace = true }
stage0-handoff = { path = "../../lib/stage0-handoff" }
attest-api = { path = "../attest-api" }
unwrap-lite = { path = "../../lib/unwrap-lite" }
userlib = { path = "../../sys/userlib", features = ["panic-messages"] }
zerocopy = { workspace = true }

[build-dependencies]
anyhow.workspace = true
idol.workspace = true
serde.workspace = true

build-util = { path = "../../build/util" }

[[bin]]
name = "task-attest"
test = false
bench = false
Loading

0 comments on commit 2fb10de

Please sign in to comment.