pub trait CompositeEncryptable<Ids: KeyIds, Key: KeyId, Output> {
// Required method
fn encrypt_composite(
&self,
ctx: &mut KeyStoreContext<'_, Ids>,
key: Key,
) -> Result<Output, CryptoError>;
}Expand description
An encryption operation that takes the input value and encrypts the fields on it recursively. Implementations should generally consist of calling PrimitiveEncryptable::encrypt for all the fields of the type. Sometimes, it is necessary to call CompositeEncryptable::encrypt_composite, if the object is not a flat struct.
Required Methods§
Sourcefn encrypt_composite(
&self,
ctx: &mut KeyStoreContext<'_, Ids>,
key: Key,
) -> Result<Output, CryptoError>
fn encrypt_composite( &self, ctx: &mut KeyStoreContext<'_, Ids>, key: Key, ) -> Result<Output, CryptoError>
§⚠️ IMPORTANT NOTE ⚠️
This is not intended to be used for new designs, and only meant to support old designs.
Composite encryption does not provide integrity over the entire document, just individual
parts of it and is subject to specific tampering attacks where fields can be rearranged
or replaced with fields from other documents. Use crate::safe::DataEnvelope instead!
For a struct made up of many small encstrings, such as a cipher, this takes the struct and recursively encrypts all the fields / sub-structs.