MCPcopy Create free account
hub / github.com/cloud-hypervisor/cloud-hypervisor / sha256_reader

Method sha256_reader

vmm/src/sev.rs:77–91  ·  view source on GitHub ↗
(mut reader: R)

Source from the content-addressed store, hash-verified

75 }
76
77 fn sha256_reader<R: Read>(mut reader: R) -> Result<[u8; 32]> {
78 let mut hasher = Sha256::new();
79 let mut chunk = [0u8; 8192];
80 loop {
81 let bytes_read = reader
82 .read(&mut chunk)
83 .map_err(|e| Self::measured_boot_io(&e))?;
84 if bytes_read == 0 {
85 break;
86 }
87 hasher.update(&chunk[..bytes_read]);
88 }
89
90 Ok(hasher.finalize().into())
91 }
92
93 pub fn build_hash_block(&self) -> Result<[u8; SEV_HASH_BLOCK_SIZE]> {
94 // Current tooling appends a NUL byte at the end of cmdlines:

Callers

nothing calls this directly

Calls 4

newFunction · 0.85
finalizeMethod · 0.80
readMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected