vitaminc-kms

Crates.iovitaminc-kms
lib.rsvitaminc-kms
version0.1.0-pre2
sourcesrc
created_at2024-09-17 04:23:53.054504
updated_at2024-09-17 04:23:53.054504
descriptionAWS KMS implementation for Vitamin C traits
homepagehttps://cipherstash.com
repositoryhttps://github.com/cipherstash/vitaminc
max_upload_size
id1377120
size11,830
Dan Draper (coderdan)

documentation

https://docs.rs/vitaminc

README

Vitamin C KMS

Crates.io Workflow Status

A MAC implementation using vitaminc that uses AWS KMS to generate HMACs. This implementation is asynchronous and uses the [aws_sdk_kms] crate to interact with AWS KMS.

This crate is part of the Vitamin C framework to make cryptography code healthy.

Example

use aws_sdk_kms::Client;
use vitaminc_protected::Protected;
use vitaminc_traits::Update;
use vitaminc_async_traits::AsyncFixedOutput;
use vitaminc_kms::{AwsKmsHmac, Info};

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    # use aws_sdk_kms::types::{KeySpec, KeyUsageType};
    # let endpoint_url = "http://localhost:4566";
    # let creds = aws_sdk_kms::config::Credentials::new("fake", "fake", None, None, "test");
    use aws_config::{BehaviorVersion, Region};

    let config = aws_sdk_kms::config::Builder::default()
        .behavior_version(BehaviorVersion::v2024_03_28())
        .region(Region::new("us-east-1"))
    #   .credentials_provider(creds)
        .endpoint_url(endpoint_url)
        .build();

    # let key = Client::from_conf(config.clone())
    #   .create_key()
    #   .key_usage(KeyUsageType::GenerateVerifyMac)
    #   .key_spec(KeySpec::Hmac512)
    #   .send()
    #   .await?;
    # let key_id = key.key_metadata().unwrap().key_id().to_owned();
    // `key_id` is the ID or ARN of the KMS key to use
    let tag = AwsKmsHmac::<64>::new(config, key_id)
        .chain(&Protected::new(vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 0]))
        .chain(Info("account_id"))
        .try_finalize_fixed()
        .await?;
    
    Ok(())
}
Commit count: 0

cargo fmt