#[cfg(feature = "builtin-bcc")] impl Default for BootParams { /// Create a boot params struct from constant data. fn default() -> Self { let data = desktop_test_data::boot::BOOT_PARAM; let data = read_to_value(data).unwrap(); let data = data.as_map().unwrap();
let dice = find_in_cbor_map(data, Value::Integer(DICE_KEY.into())).unwrap(); let dice = DiceHandover::from_cbor_value(dice.clone()).unwrap();
let gsc_boot_params =
find_in_cbor_map(data, Value::Integer(BOOT_PARAM_KEY.into())).unwrap(); let gsc_boot_params = GscBootParams::from_cbor_value(gsc_boot_params.clone()).unwrap();
/// Returns the CDI keypair as a tuple (attest, seal). pubfn get_cdi_keypair(&self) -> Result<(&[u8], &[u8]), Error> {
Ok((&self.dice.cdi_attest, &self.dice.cdi_seal))
}
}
/// Find a value in a CBOR map for the given key. fn find_in_cbor_map(map: &[(Value, Value)], target: Value) -> coset::Result<&Value> { for (key, val) in map.iter() { if *key == target { return Ok(val);
}
}
Err(CoseError::DecodeFailed(CbError::Syntax(0)))
}
/// Find a value in a CBOR map for the given key and attempt to parse it as an int. fn get_cbor_int_from_map<T: std::convert::TryFrom<ciborium::value::Integer>>(
map: &[(Value, Value)],
key: i32,
) -> coset::Result<T> {
find_in_cbor_map(map, Value::Integer(key.into()))?
.as_integer()
.ok_or(CoseError::DecodeFailed(CbError::Syntax(0)))?
.try_into()
.map_err(|_| CoseError::DecodeFailed(CbError::Syntax(0)))
}
/// Find a value in a CBOR map for the given key and attempt to parse it as a map. fn get_cbor_array_from_map(map: &[(Value, Value)], key: i32) -> coset::Result<&Vec<Value>> {
find_in_cbor_map(map, Value::Integer(key.into()))?
.as_array()
.ok_or(CoseError::DecodeFailed(CbError::Syntax(0)))
}
/// Find a value in a CBOR map for the given key and attempt to parse it as a Vec<u8>. fn get_cbor_bytes_from_map(map: &[(Value, Value)], key: i32) -> coset::Result<&Vec<u8>> {
find_in_cbor_map(map, Value::Integer(key.into()))?
.as_bytes()
.ok_or(CoseError::DecodeFailed(CbError::Syntax(0)))
}
/// Find a value in a CBOR map for the given key and attempt to parse it as a str. fn get_cbor_string_from_map(map: &[(Value, Value)], key: i32) -> coset::Result<&str> {
find_in_cbor_map(map, Value::Integer(key.into()))?
.as_text()
.ok_or(CoseError::DecodeFailed(CbError::Syntax(0)))
}
#[cfg(test)] mod tests { usesuper::*; use coset::AsCborValue; use kmr_wire::read_to_value;
test::init!();
#[test] fn boot_params_test() { let data = desktop_test_data::boot::BOOT_PARAM; let data = read_to_value(data).unwrap(); let data = data.as_map().unwrap();
let dice = find_in_cbor_map(data, Value::Integer(DICE_KEY.into())).unwrap(); let _ = DiceHandover::from_cbor_value(dice.clone()).unwrap();
let gsc_boot_params =
find_in_cbor_map(data, Value::Integer(BOOT_PARAM_KEY.into())).unwrap(); let _ = GscBootParams::from_cbor_value(gsc_boot_params.clone()).unwrap();
}
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.10 Sekunden
(vorverarbeitet am 2026-06-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.