Skip to content

Commit 490f520

Browse files
committed
Get randomness
1 parent 4fa6830 commit 490f520

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

fortanix-vme/nsm/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,14 @@ impl Nsm {
214214
pub fn describe(&self) -> Result<Description, Error> {
215215
nsm_driver::nsm_process_request(self.0, Request::DescribeNSM).try_into()
216216
}
217+
218+
pub fn get_random(&self) -> Result<Vec<u8>, Error> {
219+
match nsm_driver::nsm_process_request(self.0, Request::GetRandom) {
220+
Response::GetRandom{ random } => Ok(random),
221+
Response::Error(code) => Err(code.into()),
222+
_ => Err(Error::InvalidResponse),
223+
}
224+
}
217225
}
218226

219227
impl Drop for Nsm {

fortanix-vme/tests/nsm-test/src/main.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,5 @@ fn main() {
5353
assert_eq!(description.max_pcrs, 32);
5454
assert_eq!(description.locked_pcrs.iter().count(), 18);
5555
assert_eq!(description.digest, Digest::SHA384);
56+
assert!(nsm.get_random().is_ok());
5657
}

0 commit comments

Comments
 (0)