|
@@ -68,7 +68,7 @@ pub const SIGNATURE: [u8; 384] = [
|
|
|
];
|
|
|
|
|
|
/// The key of the parent of test blocks.
|
|
|
-pub(crate) static PARENT_KEY: SymKey = {
|
|
|
+pub static PARENT_KEY: SymKey = {
|
|
|
let key = [
|
|
|
0x35, 0x3D, 0x8C, 0x95, 0x6C, 0x8D, 0xE6, 0xC0, 0xB0, 0xD5, 0x1C, 0xE9, 0x94, 0xB0, 0x58,
|
|
|
0xD3, 0x80, 0x46, 0x12, 0x1C, 0xF3, 0x9B, 0x8A, 0xEC, 0x38, 0xD5, 0x8B, 0x05, 0x92, 0x8D,
|
|
@@ -88,7 +88,7 @@ lazy_static! {
|
|
|
}
|
|
|
|
|
|
/// The key used to encrypt test blocks.
|
|
|
-pub(crate) static BLOCK_KEY: SymKey = {
|
|
|
+pub static BLOCK_KEY: SymKey = {
|
|
|
let key = [
|
|
|
0xB2, 0xB3, 0xDA, 0x5A, 0x1A, 0xF6, 0xB3, 0x78, 0x30, 0xAB, 0x1D, 0x33, 0x33, 0xE7, 0xE3,
|
|
|
0x5B, 0xBB, 0xF9, 0xFE, 0xD0, 0xC1, 0xF7, 0x90, 0x34, 0x69, 0xB7, 0xE7, 0xC6, 0x1C, 0x46,
|
|
@@ -113,11 +113,11 @@ fn convert_err<E: Display>(err: E) -> Error {
|
|
|
Error::Message(err.to_string())
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_principal() -> Principal {
|
|
|
+pub fn make_principal() -> Principal {
|
|
|
Principal(VarHash::Sha2_256(PRINCIPAL.into()))
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_path_with_root(root: Principal, rel_components: Vec<&str>) -> BlockPath {
|
|
|
+pub fn make_path_with_root(root: Principal, rel_components: Vec<&str>) -> BlockPath {
|
|
|
let mut components = Vec::with_capacity(rel_components.len() + 1);
|
|
|
components.push(root.0.to_string());
|
|
|
for component in rel_components {
|
|
@@ -126,11 +126,11 @@ pub(crate) fn make_path_with_root(root: Principal, rel_components: Vec<&str>) ->
|
|
|
BlockPath::new(root, components)
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_path(rel_components: Vec<&str>) -> BlockPath {
|
|
|
+pub fn make_path(rel_components: Vec<&str>) -> BlockPath {
|
|
|
make_path_with_root(make_principal(), rel_components)
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_writecap_and_creds(rel_components: Vec<&str>) -> (Writecap, impl Creds) {
|
|
|
+pub fn make_writecap_and_creds(rel_components: Vec<&str>) -> (Writecap, impl Creds) {
|
|
|
let (root_writecap, root_key) = make_self_signed_writecap();
|
|
|
let issued_to = Principal(VarHash::Sha2_256(PRINCIPAL.into()));
|
|
|
(
|
|
@@ -139,12 +139,12 @@ pub(crate) fn make_writecap_and_creds(rel_components: Vec<&str>) -> (Writecap, i
|
|
|
)
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_writecap(rel_components: Vec<&str>) -> Writecap {
|
|
|
+pub fn make_writecap(rel_components: Vec<&str>) -> Writecap {
|
|
|
let (writecap, ..) = make_writecap_and_creds(rel_components);
|
|
|
writecap
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_writecap_trusted_by<C: Creds>(
|
|
|
+pub fn make_writecap_trusted_by<C: Creds>(
|
|
|
next: Writecap,
|
|
|
trusting_creds: &C,
|
|
|
issued_to: Principal,
|
|
@@ -168,16 +168,16 @@ pub(crate) fn make_writecap_trusted_by<C: Creds>(
|
|
|
writecap
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_key_pair() -> impl Creds {
|
|
|
+pub fn make_key_pair() -> impl Creds {
|
|
|
ROOT_CREDS.clone()
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_self_signed_writecap() -> (Writecap, impl Creds) {
|
|
|
+pub fn make_self_signed_writecap() -> (Writecap, impl Creds) {
|
|
|
let key = make_key_pair();
|
|
|
(make_self_signed_writecap_with(&key), key)
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_self_signed_writecap_with<C: Creds>(key: &C) -> Writecap {
|
|
|
+pub fn make_self_signed_writecap_with<C: Creds>(key: &C) -> Writecap {
|
|
|
let root_principal = key.principal();
|
|
|
let hour_hence = Epoch::now() + Duration::from_secs(3600);
|
|
|
let mut writecap = Writecap {
|
|
@@ -196,7 +196,7 @@ pub(crate) fn make_self_signed_writecap_with<C: Creds>(key: &C) -> Writecap {
|
|
|
writecap
|
|
|
}
|
|
|
|
|
|
-pub(crate) fn make_block_with<C: CredsPub>(creds: &C) -> Box<dyn Block> {
|
|
|
+pub fn make_block_with<C: CredsPub>(creds: &C) -> Box<dyn Block> {
|
|
|
let block_key = SymKey::generate(SymKeyKind::default()).unwrap();
|
|
|
let mut readcaps = BTreeMap::new();
|
|
|
readcaps.insert(creds.principal(), creds.ser_encrypt(&block_key).unwrap());
|
|
@@ -409,7 +409,7 @@ pub struct BtCursor<T: FromVec> {
|
|
|
}
|
|
|
|
|
|
impl<T: FromVec> BtCursor<T> {
|
|
|
- pub(crate) fn new(inner: T) -> BtCursor<T> {
|
|
|
+ pub fn new(inner: T) -> BtCursor<T> {
|
|
|
BtCursor {
|
|
|
cursor: RefCell::new(Cursor::new(inner)),
|
|
|
}
|
|
@@ -727,12 +727,12 @@ impl DbusBlocker {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-pub(crate) struct SwtpmHarness {
|
|
|
+pub struct SwtpmHarness {
|
|
|
dir: TempDir,
|
|
|
- port: u16,
|
|
|
state_path: PathBuf,
|
|
|
pid_path: PathBuf,
|
|
|
tabrmd: Child,
|
|
|
+ tabrmd_config: String,
|
|
|
}
|
|
|
|
|
|
impl SwtpmHarness {
|
|
@@ -748,7 +748,7 @@ impl SwtpmHarness {
|
|
|
format!("com.intel.tss2.Tabrmd.{port_str}")
|
|
|
}
|
|
|
|
|
|
- pub(crate) fn new() -> crypto::Result<SwtpmHarness> {
|
|
|
+ pub fn new() -> crypto::Result<SwtpmHarness> {
|
|
|
static PORT: AtomicU16 = AtomicU16::new(21901);
|
|
|
let port = PORT.fetch_add(2, Ordering::SeqCst);
|
|
|
let ctrl_port = port + 1;
|
|
@@ -811,24 +811,27 @@ active_pcr_banks = sha256
|
|
|
blocker.block(Duration::from_secs(5))?;
|
|
|
Ok(SwtpmHarness {
|
|
|
dir,
|
|
|
- port,
|
|
|
state_path,
|
|
|
pid_path,
|
|
|
tabrmd,
|
|
|
+ tabrmd_config: format!("bus_name={},bus_type=session", Self::dbus_name(port)),
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- pub(crate) fn context(&self) -> crypto::Result<Context> {
|
|
|
- let config_string = format!("bus_name={},bus_type=session", Self::dbus_name(self.port));
|
|
|
- let config = TabrmdConfig::from_str(config_string.as_str())?;
|
|
|
+ pub fn tabrmd_config(&self) -> &str {
|
|
|
+ &self.tabrmd_config
|
|
|
+ }
|
|
|
+
|
|
|
+ pub fn context(&self) -> crypto::Result<Context> {
|
|
|
+ let config = TabrmdConfig::from_str(self.tabrmd_config())?;
|
|
|
Ok(Context::new(TctiNameConf::Tabrmd(config))?)
|
|
|
}
|
|
|
|
|
|
- pub(crate) fn dir_path(&self) -> &std::path::Path {
|
|
|
+ pub fn dir_path(&self) -> &std::path::Path {
|
|
|
self.dir.path()
|
|
|
}
|
|
|
|
|
|
- pub(crate) fn state_path(&self) -> &std::path::Path {
|
|
|
+ pub fn state_path(&self) -> &std::path::Path {
|
|
|
&self.state_path
|
|
|
}
|
|
|
}
|