pub struct IntegrityInformation {
pub root_signature: RootSignature,
pub segment_hash_alg: String,
pub segments: Vec<Segment>,
pub segment_size_default: u64,
pub encrypted_segment_size_default: u64,
}Expand description
Integrity information including segments and root signature
Fields§
§root_signature: RootSignature§segment_hash_alg: String§segments: Vec<Segment>§segment_size_default: u64§encrypted_segment_size_default: u64Implementations§
Source§impl IntegrityInformation
impl IntegrityInformation
Sourcepub fn segment_sizes(&self) -> Vec<(u64, u64)>
pub fn segment_sizes(&self) -> Vec<(u64, u64)>
Resolve every segment’s (plaintext_size, encrypted_size).
Spec (integrity_information.md): segmentSize and
encryptedSegmentSize are optional on a segment and are inferred from
segmentSizeDefault / encryptedSegmentSizeDefault when omitted.
Trait Implementations§
Source§impl Clone for IntegrityInformation
impl Clone for IntegrityInformation
Source§fn clone(&self) -> IntegrityInformation
fn clone(&self) -> IntegrityInformation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for IntegrityInformation
impl Debug for IntegrityInformation
Source§impl Default for IntegrityInformation
impl Default for IntegrityInformation
Source§fn default() -> IntegrityInformation
fn default() -> IntegrityInformation
Source§impl<'de> Deserialize<'de> for IntegrityInformation
impl<'de> Deserialize<'de> for IntegrityInformation
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<IntegrityInformation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<IntegrityInformation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl IntegrityInformationExt for IntegrityInformation
impl IntegrityInformationExt for IntegrityInformation
Source§fn generate_root_signature(
&mut self,
gmac_tags: &[Vec<u8>],
payload_key: &[u8],
) -> Result<(), String>
fn generate_root_signature( &mut self, gmac_tags: &[Vec<u8>], payload_key: &[u8], ) -> Result<(), String>
Generate root signature from GMAC tags using constant-time HMAC
The root signature is calculated as: Base64(HMAC-SHA256(payloadKey, concat(gmac1, gmac2, …)))
This uses the constant-time implementation from opentdf-crypto
to prevent timing attacks.
Source§fn verify_root_signature(
&self,
gmac_tags: &[Vec<u8>],
payload_key: &[u8],
) -> Result<(), String>
fn verify_root_signature( &self, gmac_tags: &[Vec<u8>], payload_key: &[u8], ) -> Result<(), String>
Verify root signature against GMAC tags using constant-time comparison
This validates the integrity of encrypted segments by:
- Concatenating all GMAC tags as raw bytes
- Calculating HMAC-SHA256 over concatenated tags using payload key
- Comparing result with stored root signature in constant time
Returns Ok(()) if signature is valid, Err otherwise.
§Security Note
This uses subtle::ConstantTimeEq from the crypto crate to prevent
timing attacks.
Source§fn verify_segments_and_root_signature(
&self,
gmac_tags: &[Vec<u8>],
payload_key: &[u8],
) -> Result<(), IntegrityError>
fn verify_segments_and_root_signature( &self, gmac_tags: &[Vec<u8>], payload_key: &[u8], ) -> Result<(), IntegrityError>
Verify each manifest segment hash against the GMAC tag computed from the ciphertext, then verify the root signature. Both checks always run.
The root signature alone is not sufficient: it is derived from the tags
the ciphertext actually produced, so it still verifies after an attacker
edits integrityInformation.segments[i].hash. Per
spec/schema/OpenTDF/integrity_information.md the segment hashes
authenticate each segment, so they are compared here too, in constant
time.
Source§fn verify_root_signature_from_rows(
&self,
payload_key: &[u8],
) -> Result<(), IntegrityError>
fn verify_root_signature_from_rows( &self, payload_key: &[u8], ) -> Result<(), IntegrityError>
Recompute HMAC-SHA256(payloadKey, concat(raw 16-byte tags)) from
segments[i].hash and compare it with rootSignature.sig in constant
time. This is the verifying counterpart of
generate_root_signature for a
reader that holds the manifest and the payload key but has not
decrypted the payload.
Success means the segment rows are the ones the key holder signed, in
that order. A random-access reader checks this once at open and then
trusts each row as the expected hash for
TdfEncryption::decrypt_segment_into_verified. Without it, rows and
their members can be reordered, dropped or repeated together, since
every member still passes its own GCM check.
Every row must decode to exactly 16 bytes
(IntegrityError::SegmentHashLength otherwise). The signature is
over the concatenation, which does not record where one tag ends, so
rows of other lengths could re-split the same signed bytes into a
different list of tags. This also means only the GMAC segment hash
encoding this crate writes is accepted.
Like verify_root_signature, this
does not compare the rows with any ciphertext; decrypting a segment
against its row does that.