Skip to main content

IntegrityInformation

Struct IntegrityInformation 

Source
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: u64

Implementations§

Source§

impl IntegrityInformation

Source

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

Source§

fn clone(&self) -> IntegrityInformation

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IntegrityInformation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for IntegrityInformation

Source§

fn default() -> IntegrityInformation

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for IntegrityInformation

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<IntegrityInformation, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl IntegrityInformationExt for IntegrityInformation

Source§

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>

Verify root signature against GMAC tags using constant-time comparison

This validates the integrity of encrypted segments by:

  1. Concatenating all GMAC tags as raw bytes
  2. Calculating HMAC-SHA256 over concatenated tags using payload key
  3. 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>

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>

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.

Source§

impl Serialize for IntegrityInformation

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more