Merge "[dice] Remove unnecessary conversion for DiceMode"
diff --git a/libs/dice/src/lib.rs b/libs/dice/src/lib.rs
index 9bbacc6..5332092 100644
--- a/libs/dice/src/lib.rs
+++ b/libs/dice/src/lib.rs
@@ -23,15 +23,12 @@
use core::ptr;
use core::result;
+pub use open_dice_cbor_bindgen::DiceMode;
+
use open_dice_cbor_bindgen::DiceConfigType_kDiceConfigTypeDescriptor as DICE_CONFIG_TYPE_DESCRIPTOR;
use open_dice_cbor_bindgen::DiceConfigType_kDiceConfigTypeInline as DICE_CONFIG_TYPE_INLINE;
use open_dice_cbor_bindgen::DiceHash;
use open_dice_cbor_bindgen::DiceInputValues;
-use open_dice_cbor_bindgen::DiceMode;
-use open_dice_cbor_bindgen::DiceMode_kDiceModeDebug as DICE_MODE_DEBUG;
-use open_dice_cbor_bindgen::DiceMode_kDiceModeMaintenance as DICE_MODE_MAINTENANCE;
-use open_dice_cbor_bindgen::DiceMode_kDiceModeNormal as DICE_MODE_NORMAL;
-use open_dice_cbor_bindgen::DiceMode_kDiceModeNotInitialized as DICE_MODE_NOT_INITIALIZED;
use open_dice_cbor_bindgen::DiceResult;
use open_dice_cbor_bindgen::DiceResult_kDiceResultBufferTooSmall as DICE_RESULT_BUFFER_TOO_SMALL;
use open_dice_cbor_bindgen::DiceResult_kDiceResultInvalidInput as DICE_RESULT_INVALID_INPUT;
@@ -90,26 +87,6 @@
}
}
-/// DICE mode values.
-#[derive(Clone, Copy, Debug)]
-pub enum Mode {
- /// At least one security mechanism has not been configured. Also acts as a catch-all.
- /// Invalid mode values should be treated like this mode.
- NotInitialized = DICE_MODE_NOT_INITIALIZED as _,
- /// Indicates the device is operating normally under secure configuration.
- Normal = DICE_MODE_NORMAL as _,
- /// Indicates at least one criteria for Normal mode is not met.
- Debug = DICE_MODE_DEBUG as _,
- /// Indicates a recovery or maintenance mode of some kind.
- Maintenance = DICE_MODE_MAINTENANCE as _,
-}
-
-impl From<Mode> for DiceMode {
- fn from(mode: Mode) -> Self {
- mode as Self
- }
-}
-
/// DICE configuration input type.
#[derive(Debug)]
pub enum ConfigType<'a> {
@@ -132,7 +109,7 @@
config: &ConfigType,
auth_hash: Option<&Hash>,
auth_descriptor: Option<&[u8]>,
- mode: Mode,
+ mode: DiceMode,
hidden: Option<&Hidden>,
) -> Self {
const ZEROED_INLINE_CONFIG: InlineConfig = [0; INLINE_CONFIG_SIZE];
@@ -157,7 +134,7 @@
authority_hash: auth_hash.map_or([0; mem::size_of::<Hash>()], |h| *h),
authority_descriptor,
authority_descriptor_size,
- mode: mode.into(),
+ mode,
hidden: hidden.map_or([0; mem::size_of::<Hidden>()], |h| *h),
})
}
diff --git a/microdroid_manager/src/dice.rs b/microdroid_manager/src/dice.rs
index 499835f..e740ed4 100644
--- a/microdroid_manager/src/dice.rs
+++ b/microdroid_manager/src/dice.rs
@@ -17,7 +17,7 @@
use anyhow::{bail, Context, Error, Result};
use byteorder::{NativeEndian, ReadBytesExt};
use diced_open_dice_cbor::{
- Config, ContextImpl, InputValuesOwned, Mode, OpenDiceCborContext, CDI_SIZE, HASH_SIZE,
+ Config, ContextImpl, DiceMode, InputValuesOwned, OpenDiceCborContext, CDI_SIZE, HASH_SIZE,
HIDDEN_SIZE,
};
use keystore2_crypto::ZVec;
@@ -148,7 +148,7 @@
Config::Descriptor(config_desc),
authority_hash,
None,
- if debug { Mode::Debug } else { Mode::Normal },
+ if debug { DiceMode::kDiceModeDebug } else { DiceMode::kDiceModeNormal },
hidden,
);
let (cdi_attest, cdi_seal, bcc) = match &self {
diff --git a/pvmfw/src/dice.rs b/pvmfw/src/dice.rs
index d1ea5f0..49218b0 100644
--- a/pvmfw/src/dice.rs
+++ b/pvmfw/src/dice.rs
@@ -20,13 +20,14 @@
use dice::bcc::Handover;
use dice::hash;
use dice::ConfigType;
+use dice::DiceMode;
use dice::InputValues;
use pvmfw_avb::{DebugLevel, Digest, VerifiedBootData};
-fn to_dice_mode(debug_level: DebugLevel) -> dice::Mode {
+fn to_dice_mode(debug_level: DebugLevel) -> DiceMode {
match debug_level {
- DebugLevel::None => dice::Mode::Normal,
- DebugLevel::Full => dice::Mode::Debug,
+ DebugLevel::None => DiceMode::kDiceModeNormal,
+ DebugLevel::Full => DiceMode::kDiceModeDebug,
}
}