[dice] Move hash function to the library libdiced_open_dice
This is part of the project of merging the two existing dice
wrapper libraries into one library. The upstream library
libdiced_open_dice will be the merged library.
Test: atest diced_utils_test diced_sample_inputs_test \
diced_test diced_vendor_test diced_open_dice_cbor_test
Test: m pvmfw_img microdroid_manager && atest \
microdroid_manager_test
Bug: 267575445
Change-Id: I43011a5767b5d8547df20290a61c5ff95863980d
diff --git a/diced/src/hal_node.rs b/diced/src/hal_node.rs
index 453b12e..12be4ae 100644
--- a/diced/src/hal_node.rs
+++ b/diced/src/hal_node.rs
@@ -375,22 +375,15 @@
config_name: &CStr,
authority: &str,
) -> Result<BinderInputValues> {
- let mut dice_ctx = dice::OpenDiceCborContext::new();
Ok(BinderInputValues {
- codeHash: dice_ctx
- .hash(code.as_bytes())
- .context("In make_input_values: code hash failed.")?
- .as_slice()
- .try_into()?,
+ codeHash: dice::hash(code.as_bytes())
+ .context("In make_input_values: code hash failed.")?,
config: BinderConfig {
desc: dice::retry_bcc_format_config_descriptor(Some(config_name), None, true)
.context("In make_input_values: Failed to format config descriptor.")?,
},
- authorityHash: dice_ctx
- .hash(authority.as_bytes())
- .context("In make_input_values: authority hash failed.")?
- .as_slice()
- .try_into()?,
+ authorityHash: dice::hash(authority.as_bytes())
+ .context("In make_input_values: authority hash failed.")?,
authorityDescriptor: None,
mode: BinderMode::NORMAL,
hidden: [0; dice::HIDDEN_SIZE],