Skip to content

Commit

Permalink
audit: return the payload used in the hash computation
Browse files Browse the repository at this point in the history
  • Loading branch information
baloo committed Jul 19, 2024
1 parent 64473fc commit 631134e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/audit/commands/get_log_entries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,17 @@ pub struct LogEntry {
pub digest: LogDigest,
}

impl LogEntry {
/// The payload used to rebuild the hash of the log entry.
pub fn digest_payload(&self) -> Result<Box<[u8]>, serialization::Error> {
let mut out = serialize(self)?;

// Strip out the digest
out.resize(out.len() - LOG_DIGEST_SIZE, 0);
Ok(out.into_boxed_slice())
}
}

/// Size of a truncated digest in the log
pub const LOG_DIGEST_SIZE: usize = 16;

Expand Down

0 comments on commit 631134e

Please sign in to comment.