[dice] Create libdiced_open_dice[_nostd] to reuse dice in nostd
Test: atest diced_utils_test diced_sample_inputs_test \
diced_test diced_vendor_test
Bug: 267575445
Change-Id: I3cf1b818938a6b1496657f9391424f2a351148fe
diff --git a/diced/src/sample_inputs.rs b/diced/src/sample_inputs.rs
index bab296a..14e0efa 100644
--- a/diced/src/sample_inputs.rs
+++ b/diced/src/sample_inputs.rs
@@ -121,13 +121,13 @@
}
fn make_input_values(
- code_hash: &[u8; dice::HASH_SIZE],
- authority_hash: &[u8; dice::HASH_SIZE],
+ code_hash: &dice::Hash,
+ authority_hash: &dice::Hash,
config_name: &str,
config_version: u64,
config_resettable: bool,
mode: Mode,
- hidden: &[u8; dice::HIDDEN_SIZE],
+ hidden: &dice::Hidden,
) -> Result<BinderInputValues> {
Ok(BinderInputValues {
codeHash: *code_hash,
diff --git a/diced/src/utils.rs b/diced/src/utils.rs
index da39f8f..05702ad 100644
--- a/diced/src/utils.rs
+++ b/diced/src/utils.rs
@@ -19,7 +19,7 @@
Mode::Mode as BinderMode,
};
use anyhow::{Context, Result};
-use dice::{ContextImpl, DiceMode};
+use dice::{ContextImpl, DiceMode, Hash, Hidden};
use diced_open_dice_cbor as dice;
use keystore2_crypto::ZVec;
use std::convert::TryInto;
@@ -47,7 +47,7 @@
}
impl dice::InputValues for InputValues<'_> {
- fn code_hash(&self) -> &[u8; dice::HASH_SIZE] {
+ fn code_hash(&self) -> &Hash {
&self.0.codeHash
}
@@ -55,7 +55,7 @@
dice::Config::Descriptor(self.0.config.desc.as_slice())
}
- fn authority_hash(&self) -> &[u8; dice::HASH_SIZE] {
+ fn authority_hash(&self) -> &Hash {
&self.0.authorityHash
}
@@ -73,7 +73,7 @@
}
}
- fn hidden(&self) -> &[u8; dice::HIDDEN_SIZE] {
+ fn hidden(&self) -> &Hidden {
// If `self` was created using try_from the length was checked and this cannot panic.
&self.0.hidden
}