Crates.io | kms-aead |
lib.rs | kms-aead |
version | 0.19.2 |
source | src |
created_at | 2022-07-22 11:48:42.682811 |
updated_at | 2024-07-20 09:21:08.29681 |
description | KMS/AEAD envelope encryption for GCP/AWS KMS and Ring AEAD encryption |
homepage | https://github.com/abdolence/kms-aead-rs |
repository | https://github.com/abdolence/kms-aead-rs |
max_upload_size | |
id | 630692 |
size | 134,368 |
Features:
Available KMS providers:
Cargo.toml:
[dependencies]
kms-aead = { version = "0.19", features=["..."] }
See security consideration below about versioning.
gcp-kms-encryption
for Google KMS envelope encryption supportaws-kms-encryption
for Amazon KMS envelope encryption supportring-aead-encryption
using API for Ring AEAD only without any KMS envelope encryption let kms_ref = kms_aead::providers::AwsKmsKeyRef::new(aws_account_id, aws_key_id);
let encryption: KmsAeadRingEnvelopeEncryption<AwsKmsProvider> =
kms_aead::KmsAeadRingEnvelopeEncryption::new(providers::AwsKmsProvider::new(&kms_ref).await?)
.await?;
let secret_value = SecretValue::from("test-secret");
let test_aad = "test-aad".to_string();
let cipher_text = encryption.encrypt_value(&test_aad, &secret_value).await?;
let secret_value: SecretValue = encryption
.decrypt_value(&test_aad, &cipher_text)
.await?;
All examples available at examples directory.
To use GCP/AWS KMS API for secure random generator you should enable it using options.
For AWS:
providers::AwsKmsProvider::with_options(
&kms_ref,
AwsKmsProviderOptions::new().with_use_kms_random_gen(true),
).await?
For GCP:
providers::GcpKmsProvider::with_options(
&kms_ref,
GcpKmsProviderOptions::new().with_use_kms_random_gen(true),
).await?
Open source code is created through voluntary collaboration of software developers. The original authors license the code so that anyone can see it, modify it, and distribute new versions of it. You should manage all OSS using the same procedures and tools that you use for commercial products. As always, train your employees on cyber security best practices that can help them securely use and manage software products. You should not solely rely on individuals, especially on the projects like this reading sensitive information.
Please don't use broad version dependency management not to include a new version of dependency automatically without auditing the changes.
The library uses 96 bit nonces and ChaCha20-Poly1305 algorithm by default.
Nonces generates as (depends on options):
This is the example how to configure nonces and algorithm for GCP KMS:
let encryption = kms_aead::KmsAeadRingEnvelopeEncryption::with_algorithm_options(
kms_aead::providers::GcpKmsProvider::new(&kms_ref).await?,
&ring::aead::CHACHA20_POLY1305,
KmsAeadRingEnvelopeEncryptionOptions::new().with_encryption_options(
kms_aead::ring_encryption::RingAeadEncryptionOptions::new().with_nonce_kind(
kms_aead::ring_encryption::RingAeadEncryptionNonceKind::Random
)
)
)
.await?;
Apache Software License (ASL)
Abdulla Abdurakhmanov