summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStuart Stock <stuart@int08h.com>2019-01-19 14:21:35 -0600
committerStuart Stock <stuart@int08h.com>2019-01-19 15:12:37 -0600
commitdda66ba5b6ab2fbdee3b9fcd92741b1127f9c597 (patch)
treeb1206f0f45ddb7634b6b0c313d6f63929b98aaa7 /src
parent88f029137b7f519dd842ff745434ffaef4c05f82 (diff)
downloadroughenough-dda66ba5b6ab2fbdee3b9fcd92741b1127f9c597.zip
Rust 2018 edition migration
Diffstat (limited to 'src')
-rw-r--r--src/bin/roughenough-client.rs9
-rw-r--r--src/bin/roughenough-kms.rs6
-rw-r--r--src/bin/roughenough-server.rs11
-rw-r--r--src/config/environment.rs10
-rw-r--r--src/config/file.rs10
-rw-r--r--src/config/memory.rs6
-rw-r--r--src/config/mod.rs7
-rw-r--r--src/error.rs4
-rw-r--r--src/key/longterm.rs10
-rw-r--r--src/key/mod.rs7
-rw-r--r--src/key/online.rs8
-rw-r--r--src/kms/awskms.rs12
-rw-r--r--src/kms/envelope.rs12
-rw-r--r--src/kms/gcpkms.rs5
-rw-r--r--src/kms/mod.rs28
-rw-r--r--src/lib.rs16
-rw-r--r--src/merkle.rs8
-rw-r--r--src/message.rs8
-rw-r--r--src/server.rs10
-rw-r--r--src/sign.rs14
-rw-r--r--src/tag.rs2
21 files changed, 73 insertions, 130 deletions
diff --git a/src/bin/roughenough-client.rs b/src/bin/roughenough-client.rs
index 55831e1..cea1412 100644
--- a/src/bin/roughenough-client.rs
+++ b/src/bin/roughenough-client.rs
@@ -10,14 +10,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate byteorder;
-extern crate chrono;
+// for value_t_or_exit!()
#[macro_use]
extern crate clap;
-extern crate hex;
-extern crate ring;
-extern crate roughenough;
-extern crate time;
use ring::rand;
use ring::rand::SecureRandom;
@@ -280,7 +275,7 @@ fn main() {
for _ in 0..num_requests {
let nonce = create_nonce();
- let mut socket = UdpSocket::bind("0.0.0.0:0").expect("Couldn't open UDP socket");
+ let socket = UdpSocket::bind("0.0.0.0:0").expect("Couldn't open UDP socket");
let request = make_request(&nonce);
if let Some(f) = file.as_mut() {
diff --git a/src/bin/roughenough-kms.rs b/src/bin/roughenough-kms.rs
index d1cc4a6..a42ac50 100644
--- a/src/bin/roughenough-kms.rs
+++ b/src/bin/roughenough-kms.rs
@@ -16,14 +16,8 @@
//! CLI used to encrypt the Roughenough long-term key using one of the KMS implementations
//!
-extern crate clap;
#[macro_use]
extern crate log;
-extern crate hex;
-extern crate ring;
-extern crate roughenough;
-extern crate simple_logger;
-extern crate untrusted;
use clap::{App, Arg};
use roughenough::roughenough_version;
diff --git a/src/bin/roughenough-server.rs b/src/bin/roughenough-server.rs
index 5893f12..1021e7f 100644
--- a/src/bin/roughenough-server.rs
+++ b/src/bin/roughenough-server.rs
@@ -20,19 +20,8 @@
//! [`ServerConfig`](config/trait.ServerConfig.html) for details.
//!
-extern crate byteorder;
-extern crate ctrlc;
-extern crate hex;
#[macro_use]
extern crate log;
-extern crate mio;
-extern crate mio_extras;
-extern crate ring;
-extern crate roughenough;
-extern crate simple_logger;
-extern crate time;
-extern crate untrusted;
-extern crate yaml_rust;
use std::env;
use std::process;
diff --git a/src/config/environment.rs b/src/config/environment.rs
index fa96185..91813ba 100644
--- a/src/config/environment.rs
+++ b/src/config/environment.rs
@@ -12,15 +12,13 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate hex;
-
use std::env;
use std::time::Duration;
-use config::ServerConfig;
-use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
-use key::KmsProtection;
-use Error;
+use crate::config::ServerConfig;
+use crate::config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
+use crate::key::KmsProtection;
+use crate::Error;
///
/// Obtain a Roughenough server configuration ([ServerConfig](trait.ServerConfig.html))
diff --git a/src/config/file.rs b/src/config/file.rs
index d3ec64a..d6853d2 100644
--- a/src/config/file.rs
+++ b/src/config/file.rs
@@ -12,17 +12,15 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate hex;
-
use std::fs::File;
use std::io::Read;
use std::time::Duration;
use yaml_rust::YamlLoader;
-use config::ServerConfig;
-use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
-use key::KmsProtection;
-use Error;
+use crate::config::ServerConfig;
+use crate::config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
+use crate::key::KmsProtection;
+use crate::Error;
///
/// Read a Roughenough server configuration ([ServerConfig](trait.ServerConfig.html))
diff --git a/src/config/memory.rs b/src/config/memory.rs
index e3aae7e..75f5180 100644
--- a/src/config/memory.rs
+++ b/src/config/memory.rs
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use config::ServerConfig;
-use config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
-use key::KmsProtection;
+use crate::config::ServerConfig;
+use crate::config::{DEFAULT_BATCH_SIZE, DEFAULT_STATUS_INTERVAL};
+use crate::key::KmsProtection;
use std::time::Duration;
use hex;
diff --git a/src/config/mod.rs b/src/config/mod.rs
index b73892f..1a3cd15 100644
--- a/src/config/mod.rs
+++ b/src/config/mod.rs
@@ -22,9 +22,6 @@
//! such as files or environment variables.
//!
-extern crate hex;
-extern crate log;
-
use std::net::SocketAddr;
use std::time::Duration;
@@ -37,8 +34,8 @@ pub use self::environment::EnvironmentConfig;
mod memory;
pub use self::memory::MemoryConfig;
-use key::KmsProtection;
-use Error;
+use crate::key::KmsProtection;
+use crate::Error;
/// Maximum number of requests to process in one batch and include the the Merkle tree.
pub const DEFAULT_BATCH_SIZE: u8 = 64;
diff --git a/src/error.rs b/src/error.rs
index e91a340..3e08cc8 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -14,8 +14,8 @@
use std;
-use kms::KmsError;
-use tag::Tag;
+use crate::kms::KmsError;
+use crate::tag::Tag;
/// Error types generated by this implementation
#[derive(Debug)]
diff --git a/src/key/longterm.rs b/src/key/longterm.rs
index ddac6ea..24337f6 100644
--- a/src/key/longterm.rs
+++ b/src/key/longterm.rs
@@ -19,11 +19,11 @@
use std::fmt;
use std::fmt::Formatter;
-use key::OnlineKey;
-use message::RtMessage;
-use sign::Signer;
-use tag::Tag;
-use CERTIFICATE_CONTEXT;
+use crate::key::OnlineKey;
+use crate::message::RtMessage;
+use crate::sign::Signer;
+use crate::tag::Tag;
+use crate::CERTIFICATE_CONTEXT;
///
/// Represents the server's long-term identity.
diff --git a/src/key/mod.rs b/src/key/mod.rs
index 634d252..f9c77ad 100644
--- a/src/key/mod.rs
+++ b/src/key/mod.rs
@@ -16,11 +16,6 @@
//! Representations and management of Roughtime's online and long-term Ed25519 keys
//!
-extern crate hex;
-extern crate log;
-extern crate ring;
-extern crate std;
-
mod longterm;
mod online;
@@ -69,7 +64,7 @@ impl FromStr for KmsProtection {
#[cfg(test)]
mod test {
- use key::KmsProtection;
+ use crate::key::KmsProtection;
use std::str::FromStr;
#[test]
diff --git a/src/key/online.rs b/src/key/online.rs
index 18c8b8f..c22db74 100644
--- a/src/key/online.rs
+++ b/src/key/online.rs
@@ -12,9 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use message::RtMessage;
-use sign::Signer;
-use tag::Tag;
+use crate::message::RtMessage;
+use crate::sign::Signer;
+use crate::tag::Tag;
use time::Timespec;
use byteorder::{LittleEndian, WriteBytesExt};
@@ -22,7 +22,7 @@ use byteorder::{LittleEndian, WriteBytesExt};
use std::fmt;
use std::fmt::Formatter;
-use SIGNED_RESPONSE_CONTEXT;
+use crate::SIGNED_RESPONSE_CONTEXT;
///
/// Represents the delegated Roughtime ephemeral online key.
diff --git a/src/kms/awskms.rs b/src/kms/awskms.rs
index 7ff131a..e51b8e4 100644
--- a/src/kms/awskms.rs
+++ b/src/kms/awskms.rs
@@ -12,14 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate hex;
-extern crate log;
-
#[cfg(feature = "awskms")]
pub mod inner {
- extern crate rusoto_core;
- extern crate rusoto_kms;
-
use std::collections::HashMap;
use std::default::Default;
use std::error::Error;
@@ -27,9 +21,9 @@ pub mod inner {
use std::fmt::Formatter;
use std::str::FromStr;
- use self::rusoto_core::Region;
- use self::rusoto_kms::{DecryptRequest, EncryptRequest, Kms, KmsClient};
- use kms::{EncryptedDEK, KmsError, KmsProvider, PlaintextDEK, AD, DEK_SIZE_BYTES};
+ use rusoto_core::Region;
+ use rusoto_kms::{DecryptRequest, EncryptRequest, Kms, KmsClient};
+ use crate::kms::{EncryptedDEK, KmsError, KmsProvider, PlaintextDEK, AD, DEK_SIZE_BYTES};
/// Amazon Web Services Key Management Service
/// https://aws.amazon.com/kms/
diff --git a/src/kms/envelope.rs b/src/kms/envelope.rs
index 49f8d79..00a33bb 100644
--- a/src/kms/envelope.rs
+++ b/src/kms/envelope.rs
@@ -12,16 +12,14 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate hex;
-
use std::io::{Cursor, Read, Write};
use ring::aead::{open_in_place, seal_in_place, OpeningKey, SealingKey, AES_256_GCM};
use ring::rand::{SecureRandom, SystemRandom};
-use super::super::MIN_SEED_LENGTH;
+use crate::MIN_SEED_LENGTH;
use byteorder::{LittleEndian, ReadBytesExt, WriteBytesExt};
-use kms::{KmsError, KmsProvider, AD, DEK_SIZE_BYTES, NONCE_SIZE_BYTES, TAG_SIZE_BYTES};
+use crate::kms::{KmsError, KmsProvider, AD, DEK_SIZE_BYTES, NONCE_SIZE_BYTES, TAG_SIZE_BYTES};
const DEK_LEN_FIELD: usize = 2;
const NONCE_LEN_FIELD: usize = 2;
@@ -174,9 +172,9 @@ impl EnvelopeEncryption {
#[cfg(test)]
mod test {
- use kms::envelope::{DEK_LEN_FIELD, MIN_PAYLOAD_SIZE, NONCE_LEN_FIELD};
- use kms::EnvelopeEncryption;
- use kms::{KmsError, KmsProvider};
+ use crate::kms::envelope::{DEK_LEN_FIELD, MIN_PAYLOAD_SIZE, NONCE_LEN_FIELD};
+ use crate::kms::EnvelopeEncryption;
+ use crate::kms::{KmsError, KmsProvider};
struct MockKmsProvider {}
diff --git a/src/kms/gcpkms.rs b/src/kms/gcpkms.rs
index 1401925..f7d70a3 100644
--- a/src/kms/gcpkms.rs
+++ b/src/kms/gcpkms.rs
@@ -12,9 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-extern crate hex;
-extern crate log;
-
#[cfg(feature = "gcpkms")]
pub mod inner {
extern crate base64;
@@ -35,7 +32,7 @@ pub mod inner {
use self::hyper_rustls::TlsClient;
use self::oauth2::{ServiceAccountAccess, ServiceAccountKey};
- use kms::{EncryptedDEK, KmsError, KmsProvider, PlaintextDEK, AD};
+ use crate::kms::{EncryptedDEK, KmsError, KmsProvider, PlaintextDEK, AD};
const GOOGLE_APP_CREDS: &str = &"GOOGLE_APPLICATION_CREDENTIALS";
diff --git a/src/kms/mod.rs b/src/kms/mod.rs
index cf1c49c..50cf4c3 100644
--- a/src/kms/mod.rs
+++ b/src/kms/mod.rs
@@ -59,9 +59,9 @@ use base64;
use ring;
use std;
-use config::ServerConfig;
-use error;
-use key::KmsProtection;
+use crate::config::ServerConfig;
+use crate::error;
+use crate::key::KmsProtection;
pub use self::envelope::EnvelopeEncryption;
@@ -129,7 +129,7 @@ pub trait KmsProvider {
mod awskms;
#[cfg(feature = "awskms")]
-pub use kms::awskms::inner::AwsKms;
+pub use crate::kms::awskms::inner::AwsKms;
/// Load the seed value for the long-term key.
///
@@ -145,7 +145,7 @@ pub use kms::awskms::inner::AwsKms;
///
#[cfg(feature = "awskms")]
pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
- use kms::envelope::EnvelopeEncryption;
+ use crate::kms::envelope::EnvelopeEncryption;
match config.kms_protection() {
KmsProtection::Plaintext => Ok(config.seed()),
@@ -165,7 +165,7 @@ pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
mod gcpkms;
#[cfg(feature = "gcpkms")]
-pub use kms::gcpkms::inner::GcpKms;
+pub use crate::kms::gcpkms::inner::GcpKms;
/// Load the seed value for the long-term key.
///
@@ -181,7 +181,7 @@ pub use kms::gcpkms::inner::GcpKms;
///
#[cfg(feature = "gcpkms")]
pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
- use kms::envelope::EnvelopeEncryption;
+ use crate::kms::envelope::EnvelopeEncryption;
match config.kms_protection() {
KmsProtection::Plaintext => Ok(config.seed()),
@@ -199,6 +199,15 @@ pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
/// Load the seed value for the long-term key.
///
+/// ## This build has KMS disabled
+///
+/// *The KMS feature is disabled in this build of Roughenough*.
+///
+/// The only supported `kms_protection` value in this build is `plaintext`. Any
+/// other value will cause a runtime error.
+///
+/// ## Background
+///
/// Loading behavior depends on the value of `config.kms_protection()`:
///
/// * If `config.kms_protection() == Plaintext` then the value returned from `config.seed()`
@@ -209,11 +218,6 @@ pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
/// is parsed as a KMS key id and `EnvelopeEncryption::decrypt_seed` is called to obtain
/// the plaintext seed value.
///
-/// ## KMS Disabled
-///
-/// The KMS feature is *disabled* in this build of Roughenough. The only
-/// supported `kms_protection` value is `plaintext`. Any other value is an error.
-///
#[cfg(not(any(feature = "awskms", feature = "gcpkms")))]
pub fn load_seed(config: &Box<ServerConfig>) -> Result<Vec<u8>, error::Error> {
match config.kms_protection() {
diff --git a/src/lib.rs b/src/lib.rs
index 4c478f1..336f296 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -55,18 +55,8 @@
//!
//!
-extern crate base64;
-extern crate byteorder;
-extern crate core;
-extern crate hex;
-extern crate mio;
-extern crate mio_extras;
-extern crate time;
-extern crate yaml_rust;
-
#[macro_use]
extern crate log;
-extern crate ring;
mod error;
mod message;
@@ -79,9 +69,9 @@ pub mod merkle;
pub mod server;
pub mod sign;
-pub use error::Error;
-pub use message::RtMessage;
-pub use tag::Tag;
+pub use crate::error::Error;
+pub use crate::message::RtMessage;
+pub use crate::tag::Tag;
/// Version of Roughenough
pub const VERSION: &str = "1.1.1";
diff --git a/src/merkle.rs b/src/merkle.rs
index 69e6c00..7bb2db4 100644
--- a/src/merkle.rs
+++ b/src/merkle.rs
@@ -16,9 +16,7 @@
//! Merkle Tree implementation using SHA-512 and the Roughtime leaf and node tweak values.
//!
-extern crate ring;
-
-use self::ring::digest;
+use ring::digest;
use super::{HASH_LENGTH, TREE_LEAF_TWEAK, TREE_NODE_TWEAK};
type Data = Vec<u8>;
@@ -97,7 +95,7 @@ impl MerkleTree {
}
pub fn reset(&mut self) {
- for mut level in &mut self.levels {
+ for level in &mut self.levels {
level.clear();
}
}
@@ -152,7 +150,7 @@ pub fn root_from_paths(mut index: usize, data: &[u8], paths: &[u8]) -> Hash {
#[cfg(test)]
mod test {
- use merkle::*;
+ use crate::merkle::*;
fn test_paths_with_num(num: usize) {
let mut merkle = MerkleTree::new();
diff --git a/src/message.rs b/src/message.rs
index 429a5e5..09ceeae 100644
--- a/src/message.rs
+++ b/src/message.rs
@@ -17,8 +17,8 @@ use std::collections::HashMap;
use std::io::{Cursor, Read, Write};
use std::iter::once;
-use error::Error;
-use tag::Tag;
+use crate::error::Error;
+use crate::tag::Tag;
///
/// A Roughtime protocol message; a map of u32 tags to arbitrary byte-strings.
@@ -289,9 +289,9 @@ impl RtMessage {
#[cfg(test)]
mod test {
use byteorder::{LittleEndian, ReadBytesExt};
- use message::*;
+ use crate::message::*;
use std::io::{Cursor, Read};
- use tag::Tag;
+ use crate::tag::Tag;
#[test]
fn empty_message_size() {
diff --git a/src/server.rs b/src/server.rs
index 755fd4f..3daa571 100644
--- a/src/server.rs
+++ b/src/server.rs
@@ -31,13 +31,13 @@ use mio::net::{TcpListener, UdpSocket};
use mio::{Events, Poll, PollOpt, Ready, Token};
use mio_extras::timer::Timer;
-use config::ServerConfig;
-use key::{LongTermKey, OnlineKey};
-use kms;
-use merkle::MerkleTree;
+use crate::config::ServerConfig;
+use crate::key::{LongTermKey, OnlineKey};
+use crate::kms;
+use crate::merkle::MerkleTree;
use mio::tcp::Shutdown;
use std::io::Write;
-use {Error, RtMessage, Tag, MIN_REQUEST_LENGTH};
+use crate::{Error, RtMessage, Tag, MIN_REQUEST_LENGTH};
macro_rules! check_ctrlc {
($keep_running:expr) => {
diff --git a/src/sign.rs b/src/sign.rs
index 5fca564..2aa0e8a 100644
--- a/src/sign.rs
+++ b/src/sign.rs
@@ -16,16 +16,12 @@
//! A multi-step (init-update-finish) interface for Ed25519 signing and verification
//!
-extern crate hex;
-extern crate ring;
-extern crate untrusted;
+use ring::rand;
+use ring::rand::SecureRandom;
+use ring::signature;
+use ring::signature::Ed25519KeyPair;
-use self::ring::rand;
-use self::ring::rand::SecureRandom;
-use self::ring::signature;
-use self::ring::signature::Ed25519KeyPair;
-
-use self::untrusted::Input;
+use untrusted::Input;
use std::fmt;
use std::fmt::Formatter;
diff --git a/src/tag.rs b/src/tag.rs
index 14d6b04..7705eb7 100644
--- a/src/tag.rs
+++ b/src/tag.rs
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-use error::Error;
+use crate::error::Error;
/// An unsigned 32-bit value (key) that maps to a byte-string (value).
#[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Clone, Copy)]