Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[protocol] Finish fully separating protocol::cerberus and protocol::spdm. #148

Merged
merged 6 commits into from
Jan 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
336 changes: 168 additions & 168 deletions .github/workflows/fuzz.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions e2e/src/support/rot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ use manticore::mem::Arena;
use manticore::mem::BumpArena;
use manticore::net;
use manticore::protocol;
use manticore::protocol::capabilities;
use manticore::protocol::cerberus;
use manticore::protocol::device_id::DeviceIdentifier;
use manticore::protocol::cerberus::capabilities;
use manticore::protocol::cerberus::device_id::DeviceIdentifier;
use manticore::protocol::spdm;
use manticore::server;
use manticore::server::pa_rot::PaRot;
Expand Down
20 changes: 9 additions & 11 deletions e2e/src/tests/challenge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ use manticore::crypto::sig::Ciphers as _;
use manticore::io::Cursor;
use manticore::mem::Arena as _;
use manticore::mem::BumpArena;
use manticore::protocol::cerberus::*;
use manticore::protocol::wire::ToWire;
use manticore::protocol::Req;
use manticore::protocol::Resp;
use manticore::session;
use manticore::session::Session as _;
use testutil::data::keys;
Expand All @@ -25,11 +28,6 @@ use crate::support::rot;

#[test]
fn challenge() {
use manticore::protocol::challenge::*;
use manticore::protocol::get_cert::*;
use manticore::protocol::get_digests::*;
use manticore::protocol::key_exchange::*;

let mut h = ring::hash::Engine::new();
let virt = rot::Virtual::spawn(&rot::Options {
cert_chain: vec![
Expand All @@ -47,9 +45,9 @@ fn challenge() {
let mut arena = BumpArena::new(vec![0; 1024]);
let resp = virt
.send_cerberus::<GetDigests>(
GetDigestsRequest {
Req::<GetDigests> {
slot: 0,
key_exchange: KeyExchangeAlgo::Ecdh,
key_exchange: get_digests::KeyExchangeAlgo::Ecdh,
},
&arena,
)
Expand All @@ -72,7 +70,7 @@ fn challenge() {
loop {
let resp = virt
.send_cerberus::<GetCert>(
GetCertRequest {
Req::<GetCert> {
slot: 0,
cert_number: i as u8,
offset: cert.len() as u16,
Expand Down Expand Up @@ -111,7 +109,7 @@ fn challenge() {
.unwrap();

// Issue a challenge.
let req = ChallengeRequest {
let req = Req::<Challenge> {
slot: 0,
nonce: &[99; 32],
};
Expand Down Expand Up @@ -144,7 +142,7 @@ fn challenge() {
let pk_len = session.begin_ecdh(&mut pk_req).unwrap();
let pk_req = &pk_req[..pk_len];

let req = KeyExchangeRequest::SessionKey {
let req = Req::<KeyExchange>::SessionKey {
hmac_algorithm: hash::Algo::Sha256,
pk_req,
};
Expand All @@ -153,7 +151,7 @@ fn challenge() {
.unwrap()
.unwrap();
let (pk_resp, pk_sig, alias_hmac) = match resp {
KeyExchangeResponse::SessionKey {
Resp::<KeyExchange>::SessionKey {
pk_resp,
signature,
alias_cert_hmac,
Expand Down
22 changes: 8 additions & 14 deletions e2e/src/tests/device_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@
//! Tests for device-interrogation messages.

use manticore::mem::BumpArena;
use manticore::protocol::cerberus::*;
use manticore::protocol::Req;

use crate::support::rot;

#[test]
fn firmware_version() {
use manticore::protocol::firmware_version::*;

let virt = rot::Virtual::spawn(&rot::Options {
firmware_version: b"my cool e2e test".to_vec(),
..Default::default()
});

let arena = BumpArena::new([0; 64]);
let resp = virt.send_cerberus::<FirmwareVersion>(
FirmwareVersionRequest { index: 0 },
Req::<FirmwareVersion> { index: 0 },
&arena,
);

Expand All @@ -29,8 +29,6 @@ fn firmware_version() {

#[test]
fn vendor_firmware_version() {
use manticore::protocol::firmware_version::*;

let virt = rot::Virtual::spawn(&rot::Options {
vendor_firmware_versions: vec![
(1, b"my version".to_vec()),
Expand All @@ -41,7 +39,7 @@ fn vendor_firmware_version() {

let arena = BumpArena::new([0; 64]);
let resp = virt.send_cerberus::<FirmwareVersion>(
FirmwareVersionRequest { index: 1 },
Req::<FirmwareVersion> { index: 1 },
&arena,
);

Expand All @@ -51,8 +49,6 @@ fn vendor_firmware_version() {

#[test]
fn vendor_firmware_version_out_of_range() {
use manticore::protocol::firmware_version::*;

let virt = rot::Virtual::spawn(&rot::Options {
vendor_firmware_versions: vec![
(1, b"my version".to_vec()),
Expand All @@ -63,7 +59,7 @@ fn vendor_firmware_version_out_of_range() {

let arena = BumpArena::new([0; 64]);
let resp = virt.send_cerberus::<FirmwareVersion>(
FirmwareVersionRequest { index: 2 },
Req::<FirmwareVersion> { index: 2 },
&arena,
);

Expand All @@ -72,10 +68,8 @@ fn vendor_firmware_version_out_of_range() {

#[test]
fn device_id() {
use manticore::protocol::device_id::*;

let virt = rot::Virtual::spawn(&rot::Options {
device_id: DeviceIdentifier {
device_id: device_id::DeviceIdentifier {
vendor_id: 0xc020,
device_id: 0x0001,
subsys_vendor_id: 0xffff,
Expand All @@ -85,10 +79,10 @@ fn device_id() {
});

let arena = BumpArena::new([0; 64]);
let resp = virt.send_cerberus::<DeviceId>(DeviceIdRequest {}, &arena);
let resp = virt.send_cerberus::<DeviceId>(Req::<DeviceId> {}, &arena);
assert_eq!(
resp.unwrap().unwrap().id,
DeviceIdentifier {
device_id::DeviceIdentifier {
vendor_id: 0xc020,
device_id: 0x0001,
subsys_vendor_id: 0xffff,
Expand Down
Loading