Skip to content

Commit

Permalink
Merge branch 'main' into derivechild_support
Browse files Browse the repository at this point in the history
  • Loading branch information
hpya93 authored Nov 28, 2023
2 parents 58b6d39 + ac339f6 commit 9795b8b
Show file tree
Hide file tree
Showing 32 changed files with 2,290 additions and 536 deletions.
1,224 changes: 1,224 additions & 0 deletions Cargo.lock

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Licensed under the Apache-2.0 license

[workspace]

members = [
"dpe",
"crypto",
"platform",
"simulator",
"tools",
]
8 changes: 7 additions & 1 deletion crypto/src/openssl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl From<ErrorStack> for CryptoError {
fn from(e: ErrorStack) -> Self {
// Just return the top error on the stack
let s = e.errors();
let e_code = if s.len() > 0 {
let e_code = if !s.is_empty() {
s[0].code().try_into().unwrap_or(0u32)
} else {
0u32
Expand Down Expand Up @@ -99,6 +99,12 @@ impl OpensslCrypto {
}
}

impl Default for OpensslCrypto {
fn default() -> Self {
Self::new()
}
}

type OpensslCdi = Vec<u8>;

type OpensslPrivKey = CryptoBuf;
Expand Down
2 changes: 0 additions & 2 deletions dpe/fuzz/src/fuzz_target_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ fn harness(data: &[u8]) {
Response::Sign(ref res) => res.resp_hdr.status,
Response::DestroyCtx(ref resp_hdr) => resp_hdr.status,
Response::ExtendTci(ref res) => res.resp_hdr.status,
Response::TagTci(ref res) => res.resp_hdr.status,
Response::GetTaggedTci(ref res) => res.resp_hdr.status,
Response::GetCertificateChain(ref res) => res.resp_hdr.status,
Response::Error(ref resp_hdr) => resp_hdr.status,
};
Expand Down
3 changes: 1 addition & 2 deletions dpe/src/commands/destroy_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use crate::{
};

#[repr(C)]
#[derive(Debug, PartialEq, Eq, zerocopy::FromBytes)]
#[cfg_attr(test, derive(zerocopy::AsBytes))]
#[derive(Debug, PartialEq, Eq, zerocopy::FromBytes, zerocopy::AsBytes)]
pub struct DestroyCtxCmd {
pub handle: ContextHandle,
}
Expand Down
41 changes: 0 additions & 41 deletions dpe/src/commands/get_tagged_tci.rs

This file was deleted.

14 changes: 1 addition & 13 deletions dpe/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,15 @@ Abstract:
DPE Commands and deserialization.
--*/
pub use self::derive_child::{DeriveChildCmd, DeriveChildFlags};
pub(crate) use self::destroy_context::DestroyCtxCmd;
pub use self::destroy_context::DestroyCtxCmd;
pub use self::get_certificate_chain::GetCertificateChainCmd;
pub use self::initialize_context::InitCtxCmd;

pub use self::certify_key::{CertifyKeyCmd, CertifyKeyFlags};

use self::extend_tci::ExtendTciCmd;
use self::get_tagged_tci::GetTaggedTciCmd;
pub use self::rotate_context::{RotateCtxCmd, RotateCtxFlags};
pub use self::sign::{SignCmd, SignFlags};
use self::tag_tci::TagTciCmd;

use crate::{
dpe_instance::{DpeEnv, DpeInstance, DpeTypes},
Expand All @@ -30,11 +28,9 @@ mod derive_child;
mod destroy_context;
mod extend_tci;
mod get_certificate_chain;
mod get_tagged_tci;
mod initialize_context;
mod rotate_context;
mod sign;
mod tag_tci;

#[derive(Debug, PartialEq, Eq)]
pub enum Command {
Expand All @@ -46,8 +42,6 @@ pub enum Command {
RotateCtx(RotateCtxCmd),
DestroyCtx(DestroyCtxCmd),
ExtendTci(ExtendTciCmd),
TagTci(TagTciCmd),
GetTaggedTci(GetTaggedTciCmd),
GetCertificateChain(GetCertificateChainCmd),
}

Expand All @@ -61,8 +55,6 @@ impl Command {
pub const DESTROY_CONTEXT: u32 = 0x0f;
pub const GET_CERTIFICATE_CHAIN: u32 = 0x80;
pub const EXTEND_TCI: u32 = 0x81;
pub const TAG_TCI: u32 = 0x82;
pub const GET_TAGGED_TCI: u32 = 0x83;

/// Returns the command with its parameters given a slice of bytes.
///
Expand All @@ -85,8 +77,6 @@ impl Command {
Self::parse_command(Command::GetCertificateChain, bytes)
}
Command::EXTEND_TCI => Self::parse_command(Command::ExtendTci, bytes),
Command::TAG_TCI => Self::parse_command(Command::TagTci, bytes),
Command::GET_TAGGED_TCI => Self::parse_command(Command::GetTaggedTci, bytes),
_ => Err(DpeErrorCode::InvalidCommand),
}
}
Expand All @@ -112,8 +102,6 @@ impl From<Command> for u32 {
Command::RotateCtx(_) => Command::ROTATE_CONTEXT_HANDLE,
Command::DestroyCtx(_) => Command::DESTROY_CONTEXT,
Command::ExtendTci(_) => Command::EXTEND_TCI,
Command::TagTci(_) => Command::TAG_TCI,
Command::GetTaggedTci(_) => Command::GET_TAGGED_TCI,
Command::GetCertificateChain(_) => Command::GET_CERTIFICATE_CHAIN,
}
}
Expand Down
6 changes: 3 additions & 3 deletions dpe/src/commands/sign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub struct SignFlags(u32);

bitflags! {
impl SignFlags: u32 {
const IS_SYMMETRIC = 1u32 << 31;
const IS_SYMMETRIC = 1u32 << 30;
}
}

Expand Down Expand Up @@ -83,7 +83,7 @@ impl CommandExecution for SignCmd {
) -> Result<Response, DpeErrorCode> {
// Make sure the operation is supported.
if !dpe.support.is_symmetric() && self.uses_symmetric() {
return Err(DpeErrorCode::InvalidArgument);
return Err(DpeErrorCode::ArgumentNotSupported);
}

let idx = dpe.get_active_context_pos(&self.handle, locality)?;
Expand Down Expand Up @@ -190,7 +190,7 @@ mod tests {

// Bad argument
assert_eq!(
Err(DpeErrorCode::InvalidArgument),
Err(DpeErrorCode::ArgumentNotSupported),
SignCmd {
handle: ContextHandle([0xff; ContextHandle::SIZE]),
label: TEST_LABEL,
Expand Down
197 changes: 0 additions & 197 deletions dpe/src/commands/tag_tci.rs

This file was deleted.

Loading

0 comments on commit 9795b8b

Please sign in to comment.