Struct aws_manager::kms::Manager
source · pub struct Manager { /* private fields */ }Expand description
Implements AWS KMS manager.
Implementations§
source§impl Manager
impl Manager
pub fn new(shared_config: &AwsSdkConfig) -> Self
pub fn client(&self) -> Client
sourcepub async fn create_key(
&self,
name: &str,
key_spec: KeySpec,
key_usage: KeyUsageType
) -> Result<Key>
pub async fn create_key(
&self,
name: &str,
key_spec: KeySpec,
key_usage: KeyUsageType
) -> Result<Key>
Creates an AWS KMS CMK. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html
sourcepub async fn create_symmetric_default_key(&self, name: &str) -> Result<Key>
pub async fn create_symmetric_default_key(&self, name: &str) -> Result<Key>
Creates a default symmetric AWS KMS CMK. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_CreateKey.html
sourcepub async fn sign_digest_secp256k1_ecdsa_sha256(
&self,
key_id: &str,
digest: &[u8]
) -> Result<Vec<u8>>
pub async fn sign_digest_secp256k1_ecdsa_sha256(
&self,
key_id: &str,
digest: &[u8]
) -> Result<Vec<u8>>
Signs the 32-byte SHA256 output message with the ECDSA private key and the recoverable code using AWS KMS CMK. ref. https://docs.aws.amazon.com/kms/latest/APIReference/API_Sign.html
sourcepub async fn schedule_to_delete(
&self,
key_arn: &str,
pending_window_in_days: i32
) -> Result<()>
pub async fn schedule_to_delete(
&self,
key_arn: &str,
pending_window_in_days: i32
) -> Result<()>
Schedules to delete a KMS CMK. Pass either CMK Id or Arn. The minimum pending window days are 7.
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