summaryrefslogtreecommitdiff
path: root/src/key/mod.rs
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2018-10-09 20:54:49 -0500
committerStuart Stock <stuart@int08h.com>2018-10-09 20:54:49 -0500
commitc66513b606f6aacf61bab1434c1f512c24981b2b (patch)
tree8f5374f9163366bfd845cd796c087f68f9f9baf2 /src/key/mod.rs
parentbab728c1c5eea847e06e13400dc40a522f2b4d25 (diff)
downloadroughenough-c66513b606f6aacf61bab1434c1f512c24981b2b.zip
continue work on kms
Diffstat (limited to 'src/key/mod.rs')
-rw-r--r--src/key/mod.rs22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/key/mod.rs b/src/key/mod.rs
index 62c37a9..7ae2198 100644
--- a/src/key/mod.rs
+++ b/src/key/mod.rs
@@ -26,6 +26,7 @@ mod longterm;
mod online;
use std::error::Error;
+use std::str::FromStr;
pub use self::envelope::EnvelopeEncryption;
pub use self::longterm::LongTermKey;
@@ -39,11 +40,24 @@ pub enum KeyProtection {
/// No protection, seed is in plaintext
Plaintext,
- /// Envelope encryption with Key-Encrypting-Key (KEK) from AWS Key Management Service
- AwsKmsEnvelope,
+ /// Envelope encryption using AWS Key Management Service
+ AwsKmsEnvelope(String),
- /// Envelope encryption with Key-Encrypting-Key (KEK) from Google Cloud Key Management Service
- GoogleKmsEnvelope,
+ /// Envelope encryption using Google Cloud Key Management Service
+ GoogleKmsEnvelope(String),
+}
+
+impl FromStr for KeyProtection {
+ type Err = ();
+
+ fn from_str(s: &str) -> Result<KeyProtection, ()> {
+ match s {
+ "plaintext" => Ok(KeyProtection::Plaintext),
+ s if s.starts_with("arn") => Ok(KeyProtection::AwsKmsEnvelope(s.to_string())),
+ s if s.starts_with("gcp") => Ok(KeyProtection::GoogleKmsEnvelope(s.to_string())),
+ _ => Err(())
+ }
+ }
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Clone)]