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

Add verification library code. #17

Merged
merged 1 commit into from
Mar 6, 2023
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
19 changes: 18 additions & 1 deletion dpe/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,12 @@ impl TryFrom<&[u8]> for CommandHdr {
cmd_id: u32::from_le_bytes(raw[4..8].try_into().unwrap()),
profile: u32::from_le_bytes(raw[8..12].try_into().unwrap()),
};
if header.magic != Self::DPE_COMMAND_MAGIC || header.profile != DPE_PROFILE as u32 {
if header.magic != Self::DPE_COMMAND_MAGIC {
return Err(DpeErrorCode::InvalidCommand);
}
// The client doesn't know what profile is implemented when calling the `GetProfile`
// command. But, all other commands should be directed towards the correct profile.
if header.cmd_id != Command::GET_PROFILE && header.profile != DPE_PROFILE as u32 {
return Err(DpeErrorCode::InvalidCommand);
}
Ok(header)
Expand Down Expand Up @@ -257,17 +262,29 @@ mod tests {
#[cfg(feature = "dpe_profile_p384_sha384")]
let wrong_profile = DpeProfile::P256Sha256 as u32;

// All commands should check the profile except GetProfile.
assert_eq!(
invalid_command,
CommandHdr::try_from(
Vec::<u8>::from(CommandHdr {
profile: wrong_profile,
cmd_id: Command::INITIALIZE_CONTEXT,
..DEFAULT_COMMAND
})
.as_slice()
)
);

// Make sure GetProfile doesn't care.
assert!(CommandHdr::try_from(
Vec::<u8>::from(CommandHdr {
profile: wrong_profile,
..DEFAULT_COMMAND
})
.as_slice()
)
.is_ok());

// Test correct command. Using random command ID to check endianness and consistency.
const GOOD_HEADER: CommandHdr = CommandHdr {
cmd_id: 0x8765_4321,
Expand Down
10 changes: 5 additions & 5 deletions dpe/src/dpe_instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ impl Default for TciMeasurement {

#[derive(Default)]
pub struct Support {
simulation: bool,
extend_tci: bool,
auto_init: bool,
tagging: bool,
rotate_context: bool,
pub simulation: bool,
pub extend_tci: bool,
pub auto_init: bool,
pub tagging: bool,
pub rotate_context: bool,
}

impl Support {
Expand Down
195 changes: 195 additions & 0 deletions simulator/Cargo.lock

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

1 change: 1 addition & 0 deletions simulator/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ edition = "2021"
[dependencies]
ctrlc = { version = "3.0", features = ["termination"] }
openssl = "0.10"
clap = { version = "4.1.8", features = ["derive"] }
dpe = { path = "../dpe" }
Loading