diff options
author | Stuart Stock <stuart@int08h.com> | 2018-10-06 22:40:12 -0500 |
---|---|---|
committer | Stuart Stock <stuart@int08h.com> | 2018-10-07 15:48:23 -0500 |
commit | 0b924cc92418f9a210a6b78cef56e427dc9c9d1d (patch) | |
tree | a7bb33d3a344d973684e6f0de3e35f956de803db /src/bin/kms.rs | |
parent | b43bcb27ad303afd56cfe1d767e95c10cf3d1cb2 (diff) | |
download | roughenough-0b924cc92418f9a210a6b78cef56e427dc9c9d1d.zip |
Land KMS support, yay!
AWS KMS for now, work-in-progress
Diffstat (limited to 'src/bin/kms.rs')
-rw-r--r-- | src/bin/kms.rs | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/bin/kms.rs b/src/bin/kms.rs new file mode 100644 index 0000000..311fbb5 --- /dev/null +++ b/src/bin/kms.rs @@ -0,0 +1,64 @@ +// Copyright 2017-2018 int08h LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! +//! Work with Roughenough long-term key +//! + +#[macro_use] +extern crate clap; +#[macro_use] +extern crate log; +extern crate ring; +extern crate roughenough; +extern crate simple_logger; +extern crate untrusted; + +#[cfg(feature = "kms")] +use roughenough::key::awskms::AwsKms; + +use std::default::Default; + +use clap::{App, Arg}; +use roughenough::VERSION; + +pub fn main() { + use log::Level; + + simple_logger::init_with_level(Level::Info).unwrap(); + + let matches = App::new("Roughenough key management") + .version(VERSION) + .arg( + Arg::with_name("operation") + .required(true) + .help("The operation to perform") + .takes_value(true), + ).get_matches(); + + if cfg!(feature = "kms") { + info!("KMS feature enabled"); + let client = AwsKms::from_uri( + // your key here + ).unwrap(); + + let ciphertext = client.encrypt("This is a test".as_ref()).unwrap(); + info!("Ciphertext: {:?}", ciphertext); + + let plaintext = String::from_utf8(client.decrypt(ciphertext.as_ref()).unwrap()).unwrap(); + info!("Plaintext : {:?}", plaintext); + } + + info!("Done"); +} |