Struct aws_manager::kms::Manager
source · [−]pub struct Manager { /* private fields */ }
Expand description
Implements AWS KMS manager.
Implementations
sourceimpl Manager
impl Manager
pub fn new(shared_config: &AwsSdkConfig) -> Self
pub fn client(&self) -> Client
sourcepub async fn create_key(&self, key_desc: &str) -> Result<Key>
pub async fn create_key(&self, key_desc: &str) -> Result<Key>
Creates an AWS KMS CMK.
sourcepub async fn schedule_to_delete(&self, key_id: &str) -> Result<()>
pub async fn schedule_to_delete(&self, key_id: &str) -> Result<()>
Schedules to delete a KMS CMK.
sourcepub async fn encrypt(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
plaintext: Vec<u8>
) -> Result<Vec<u8>>
pub async fn encrypt(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
plaintext: Vec<u8>
) -> Result<Vec<u8>>
Encrypts data. The maximum size of the data KMS can encrypt is 4096 bytes for “SYMMETRIC_DEFAULT” encryption algorithm. To specify a KMS key, use its key ID, key ARN, alias name, or alias ARN. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_Encrypt.html
sourcepub async fn decrypt(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
ciphertext: Vec<u8>
) -> Result<Vec<u8>>
pub async fn decrypt(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
ciphertext: Vec<u8>
) -> Result<Vec<u8>>
Decrypts data. The maximum length of “ciphertext” is 6144 bytes. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_Decrypt.html
sourcepub async fn encrypt_file(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
src_file: &str,
dst_file: &str
) -> Result<()>
pub async fn encrypt_file(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
src_file: &str,
dst_file: &str
) -> Result<()>
Encrypts data from a file and save the ciphertext to the other file.
sourcepub async fn decrypt_file(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
src_file: &str,
dst_file: &str
) -> Result<()>
pub async fn decrypt_file(
&self,
key_id: &str,
spec: Option<EncryptionAlgorithmSpec>,
src_file: &str,
dst_file: &str
) -> Result<()>
Decrypts data from a file and save the plaintext to the other file.
sourcepub async fn generate_data_key(
&self,
key_id: &str,
spec: Option<DataKeySpec>
) -> Result<DEK>
pub async fn generate_data_key(
&self,
key_id: &str,
spec: Option<DataKeySpec>
) -> Result<DEK>
Generates a data-encryption key. The default key spec is AES_256 generate a 256-bit symmetric key. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_GenerateDataKey.html