kata-security-coordinator::fakeimpl: construct unique bundle id's

Fake bundle id's are now "fake.X" where X is the CPtr for the package
contents' CNode (which is known unique).

While here fix some whitespace bogons.

Change-Id: I84c586e11f56c416d9bad667cae8e4cecba5dca2
GitOrigin-RevId: 0cec9e3308d9f3fe019af666dea583f92b3735b4
This commit is contained in:
Sam Leffler 2022-06-08 21:35:22 +00:00
parent 066d37db24
commit ae3de25663

View File

@ -1,6 +1,7 @@
//! Kata OS security coordinator fake support
extern crate alloc;
use alloc::fmt;
use alloc::string::{String, ToString};
use hashbrown::HashMap;
use kata_memory_interface::ObjDescBundle;
@ -22,16 +23,16 @@ impl BundleData {
pkg_size: size,
manifest: String::from(
"# Comments like this
[Manifest]
BundleId=com.google.cerebra.hw.HelloWorld
[Manifest]
BundleId=com.google.cerebra.hw.HelloWorld
[Binaries]
App=HelloWorldBin
Model=NeuralNetworkName
[Binaries]
App=HelloWorldBin
Model=NeuralNetworkName
[Storage]
Required=1
",
[Storage]
Required=1
",
),
keys: HashMap::with_capacity(2),
}
@ -78,7 +79,9 @@ pub type KataSecurityCoordinatorInterface = FakeSecurityCoordinator;
impl SecurityCoordinatorInterface for FakeSecurityCoordinator {
fn install(&mut self, pkg_contents: &ObjDescBundle) -> Result<String, SecurityRequestError> {
let bundle_id = "fubar".to_string(); // XXX
// TODO(sleffler): get bundle_id from the manifest; for now use the
// cnode's CPtr since it is unique wrt all installed packages
let bundle_id = fmt::format(format_args!("fake.{}", pkg_contents.cnode));
if self.bundles.contains_key(&bundle_id) {
return Err(SecurityRequestError::SreDeleteFirst);
}