Function streambed::encrypt_struct

source ·
pub async fn encrypt_struct<T, U, F, S, SE>(
    ss: &impl SecretStore,
    secret_path: &str,
    serialize: S,
    rng: F,
    t: &T
) -> Option<Vec<u8>>
where T: Serialize, S: FnOnce(&T) -> Result<Vec<u8>, SE>, F: FnOnce() -> U, U: RngCore,
Expand description

Given a secret store, a path to a secret, and a type to be encrypted, serialize and then encrypt it. Returns an encrypted buffer prefixed with a random salt if successful. The secret is expected to reside in a data field named “value” and is encoded as a hex string of 32 characters (16 bytes) is encoded as a hex string. Any non alpha-numeric characters are also filtered out.