summaryrefslogtreecommitdiff
path: root/src/key
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2018-10-27 13:22:53 -0500
committerStuart Stock <stuart@int08h.com>2018-10-27 13:22:53 -0500
commitf84d4d7907e49294a04e3cf8ca14fe0e15382c0d (patch)
tree19c6a6d031872f94d75dc6ac05bf988dda0aeaa9 /src/key
parent388976db0419127384055810ba54f0610d1069b9 (diff)
downloadroughenough-f84d4d7907e49294a04e3cf8ca14fe0e15382c0d.zip
Additional documentation; rustfmt pass; extract stress test loop
Diffstat (limited to 'src/key')
-rw-r--r--src/key/mod.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/key/mod.rs b/src/key/mod.rs
index 5ce0296..634d252 100644
--- a/src/key/mod.rs
+++ b/src/key/mod.rs
@@ -33,7 +33,7 @@ pub use self::online::OnlineKey;
/// Methods for protecting the server's long-term identity
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Clone)]
-pub enum KeyProtection {
+pub enum KmsProtection {
/// No protection, seed is in plaintext
Plaintext,
@@ -44,32 +44,32 @@ pub enum KeyProtection {
GoogleKmsEnvelope(String),
}
-impl Display for KeyProtection {
+impl Display for KmsProtection {
fn fmt(&self, f: &mut Formatter) -> Result<(), std::fmt::Error> {
match self {
- KeyProtection::Plaintext => write!(f, "Plaintext"),
- KeyProtection::AwsKmsEnvelope(key_id) => write!(f, "AwsKms({})", key_id),
- KeyProtection::GoogleKmsEnvelope(key_id) => write!(f, "GoogleKms({})", key_id),
+ KmsProtection::Plaintext => write!(f, "Plaintext"),
+ KmsProtection::AwsKmsEnvelope(key_id) => write!(f, "AwsKms({})", key_id),
+ KmsProtection::GoogleKmsEnvelope(key_id) => write!(f, "GoogleKms({})", key_id),
}
}
}
-impl FromStr for KeyProtection {
+impl FromStr for KmsProtection {
type Err = String;
- fn from_str(s: &str) -> Result<KeyProtection, String> {
+ fn from_str(s: &str) -> Result<KmsProtection, String> {
match s {
- "plaintext" => Ok(KeyProtection::Plaintext),
- s if s.starts_with("arn:") => Ok(KeyProtection::AwsKmsEnvelope(s.to_string())),
- s if s.starts_with("projects/") => Ok(KeyProtection::GoogleKmsEnvelope(s.to_string())),
- s => Err(format!("unknown KeyProtection '{}'", s)),
+ "plaintext" => Ok(KmsProtection::Plaintext),
+ s if s.starts_with("arn:") => Ok(KmsProtection::AwsKmsEnvelope(s.to_string())),
+ s if s.starts_with("projects/") => Ok(KmsProtection::GoogleKmsEnvelope(s.to_string())),
+ s => Err(format!("unknown KmsProtection '{}'", s)),
}
}
}
#[cfg(test)]
mod test {
- use key::KeyProtection;
+ use key::KmsProtection;
use std::str::FromStr;
#[test]
@@ -79,20 +79,20 @@ mod test {
let resource_id =
"projects/key-project/locations/global/keyRings/key-ring/cryptoKeys/my-key";
- match KeyProtection::from_str("plaintext") {
- Ok(KeyProtection::Plaintext) => (),
+ match KmsProtection::from_str("plaintext") {
+ Ok(KmsProtection::Plaintext) => (),
e => panic!("unexpected result {:?}", e),
};
- match KeyProtection::from_str(arn) {
- Ok(KeyProtection::AwsKmsEnvelope(msg)) => assert_eq!(msg, arn),
+ match KmsProtection::from_str(arn) {
+ Ok(KmsProtection::AwsKmsEnvelope(msg)) => assert_eq!(msg, arn),
e => panic!("unexpected result {:?}", e),
}
- match KeyProtection::from_str(resource_id) {
- Ok(KeyProtection::GoogleKmsEnvelope(msg)) => assert_eq!(msg, resource_id),
+ match KmsProtection::from_str(resource_id) {
+ Ok(KmsProtection::GoogleKmsEnvelope(msg)) => assert_eq!(msg, resource_id),
e => panic!("unexpected result {:?}", e),
}
- match KeyProtection::from_str("frobble") {
- Err(msg) => assert!(msg.contains("unknown KeyProtection")),
+ match KmsProtection::from_str("frobble") {
+ Err(msg) => assert!(msg.contains("unknown KmsProtection")),
e => panic!("unexpected result {:?}", e),
}
}