KeydbSource::host_certs() — the keydb's second data type, for DriveCredentials

This commit is contained in:
MattJackson
2026-06-04 16:04:06 -07:00
parent c6f1ec1fcc
commit 309621ac45
+12 -1
View File
@@ -15,7 +15,7 @@
use std::path::PathBuf;
use libfreemkv::aacs::KeyDb;
use libfreemkv::aacs::{HostCert, KeyDb};
use libfreemkv::{DiscInputs, Key, KeySource, Result};
/// A [`KeySource`] backed by a local `keydb.cfg` file.
@@ -29,6 +29,17 @@ impl KeydbSource {
Self { path: path.into() }
}
/// The host certificate(s) in this keydb — the second kind of data the one
/// keydb file holds (alongside decryption keys). The app passes these to the
/// live-drive scan as `DriveCredentials` for the AACS handshake. Empty if
/// the keydb is missing/unreadable or carries no host cert.
pub fn host_certs(&self) -> Vec<HostCert> {
match KeyDb::load(&self.path) {
Ok(db) => db.host_certs,
Err(_) => Vec::new(),
}
}
/// Build the ordered candidate list from a parsed keydb. Pure (no I/O), so
/// it is unit-testable without a file on disk.
fn candidates_from(db: &KeyDb, inputs: &DiscInputs) -> Vec<Key> {