pvmfw: Panic on fill_with_entropy error for BSSL
Panic instead of silently ignoring the returned error and returning
potentially invalid (or incomplete) entropy to the BSSL caller of
CRYPTO_sysrand.
Test: TH
Bug: 288384378
Change-Id: I046f921608445586e899467eef31eb4699990a8f
diff --git a/pvmfw/src/rand.rs b/pvmfw/src/rand.rs
index bf0edd5..b45538a 100644
--- a/pvmfw/src/rand.rs
+++ b/pvmfw/src/rand.rs
@@ -42,6 +42,12 @@
}
}
+impl fmt::Debug for Error {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ write!(f, "{self}")
+ }
+}
+
/// Configure the source of entropy.
pub fn init() -> Result<()> {
match hvc::trng_version()? {
@@ -105,5 +111,5 @@
extern "C" fn CRYPTO_sysrand(out: *mut u8, req: usize) {
// SAFETY - We need to assume that out points to valid memory of size req.
let s = unsafe { core::slice::from_raw_parts_mut(out, req) };
- let _ = fill_with_entropy(s);
+ fill_with_entropy(s).unwrap()
}