1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::{EncryptedSecretValue, EncryptedSessionKey, KmsAeadResult};
use async_trait::*;
use secret_vault_value::SecretValue;
#[async_trait]
pub trait KmsAeadEncryption<Aad> {
async fn encrypt_value(
&self,
aad: Aad,
secret_value: &SecretValue,
) -> KmsAeadResult<EncryptedSecretValue>;
async fn decrypt_value(
&self,
aad: Aad,
secret_value: &EncryptedSecretValue,
) -> KmsAeadResult<SecretValue>;
}
#[async_trait]
pub trait KmsAeadEnvelopeEncryption<Aad> {
async fn encrypt_value(
&self,
aad: &Aad,
secret_value: &SecretValue,
) -> KmsAeadResult<(EncryptedSecretValue, EncryptedSessionKey)>;
async fn decrypt_value(
&self,
aad: &Aad,
encrypted_value: &EncryptedSecretValue,
) -> KmsAeadResult<(SecretValue, EncryptedSessionKey)>;
async fn decrypt_value_with_session_key(
&self,
aad: &Aad,
encrypted_value: &EncryptedSecretValue,
encrypted_session_key: &EncryptedSessionKey,
) -> KmsAeadResult<SecretValue>;
async fn rotate_session_key(&self)
-> KmsAeadResult<(EncryptedSessionKey, EncryptedSessionKey)>;
}