pvmfw: Prepare rand.rs for move
Prepare the module to be publicly exported by a library by adding
documentation.
Remove the TODO addressed by the following commit, to limit that to a
move.
Test: TH
Change-Id: I478e6e9943c7e4c35e0387cc7c4070a519001ba4
diff --git a/pvmfw/src/hvc.rs b/pvmfw/src/hvc.rs
index e03c9d3..9a5e716 100644
--- a/pvmfw/src/hvc.rs
+++ b/pvmfw/src/hvc.rs
@@ -21,7 +21,6 @@
hvc64,
};
-// TODO(b/272226230): Move all the trng functions to trng module
const ARM_SMCCC_TRNG_VERSION: u32 = 0x8400_0050;
#[allow(dead_code)]
const ARM_SMCCC_TRNG_FEATURES: u32 = 0x8400_0051;
diff --git a/pvmfw/src/rand.rs b/pvmfw/src/rand.rs
index b45538a..00567b8 100644
--- a/pvmfw/src/rand.rs
+++ b/pvmfw/src/rand.rs
@@ -12,10 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
+//! Functions and drivers for obtaining true entropy.
+
use crate::hvc;
use core::fmt;
use core::mem::size_of;
+/// Error type for rand operations.
pub enum Error {
/// Error during SMCCC TRNG call.
Trng(hvc::trng::Error),
@@ -29,6 +32,7 @@
}
}
+/// Result type for rand operations.
pub type Result<T> = core::result::Result<T, Error>;
impl fmt::Display for Error {
@@ -96,6 +100,7 @@
}
}
+/// Generate an array of fixed-size initialized with true-random bytes.
pub fn random_array<const N: usize>() -> Result<[u8; N]> {
let mut arr = [0; N];
fill_with_entropy(&mut arr)?;