aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2021-04-17 21:06:47 -0400
committerJesse Luehrs <doy@tozt.net>2021-04-17 21:06:47 -0400
commitc627737dfa6a30b71e3f7c32cca05675cc7e9b97 (patch)
treebe91d4c3e7fd45c387bdc7b7bf87a7d3068ed3d1
parent828e61a574f484aea575f3cd98322407d3f9aea5 (diff)
downloadrbw-c627737dfa6a30b71e3f7c32cca05675cc7e9b97.tar.gz
rbw-c627737dfa6a30b71e3f7c32cca05675cc7e9b97.zip
clippy
-rw-r--r--src/bin/rbw/sock.rs4
-rw-r--r--src/cipherstring.rs14
-rw-r--r--src/error.rs4
-rw-r--r--src/json.rs6
-rw-r--r--src/lib.rs1
-rw-r--r--src/pwgen.rs20
6 files changed, 24 insertions, 25 deletions
diff --git a/src/bin/rbw/sock.rs b/src/bin/rbw/sock.rs
index f3fe365..1f5f0b2 100644
--- a/src/bin/rbw/sock.rs
+++ b/src/bin/rbw/sock.rs
@@ -34,7 +34,7 @@ impl Sock {
let mut line = String::new();
buf.read_line(&mut line)
.context("failed to read message from agent")?;
- Ok(serde_json::from_str(&line)
- .context("failed to parse message from agent")?)
+ serde_json::from_str(&line)
+ .context("failed to parse message from agent")
}
}
diff --git a/src/cipherstring.rs b/src/cipherstring.rs
index cd1d25b..72681f8 100644
--- a/src/cipherstring.rs
+++ b/src/cipherstring.rs
@@ -184,9 +184,9 @@ impl CipherString {
let pkey = openssl::pkey::PKey::private_key_from_pkcs8(
private_key.private_key(),
)
- .map_err(|source| Error::OpenSSL { source })?;
+ .map_err(|source| Error::OpenSsl { source })?;
let rsa =
- pkey.rsa().map_err(|source| Error::OpenSSL { source })?;
+ pkey.rsa().map_err(|source| Error::OpenSsl { source })?;
let mut res = crate::locked::Vec::new();
res.extend(std::iter::repeat(0).take(rsa.size() as usize));
@@ -197,7 +197,7 @@ impl CipherString {
res.data_mut(),
openssl::rsa::Padding::PKCS1_OAEP,
)
- .map_err(|source| Error::OpenSSL { source })?;
+ .map_err(|source| Error::OpenSsl { source })?;
res.truncate(bytes);
Ok(res)
@@ -221,19 +221,19 @@ fn decrypt_common_symmetric(
if let Some(mac) = mac {
let mut key = hmac::Hmac::<sha2::Sha256>::new_varkey(keys.mac_key())
.map_err(|source| Error::CreateHmac { source })?;
- key.update(&iv);
- key.update(&ciphertext);
+ key.update(iv);
+ key.update(ciphertext);
if key.verify(mac).is_err() {
return Err(Error::InvalidMac);
}
}
- Ok(block_modes::Cbc::<
+ block_modes::Cbc::<
aes::Aes256,
block_modes::block_padding::Pkcs7,
>::new_var(keys.enc_key(), iv)
- .map_err(|source| Error::CreateBlockMode { source })?)
+ .map_err(|source| Error::CreateBlockMode { source })
}
impl std::fmt::Display for CipherString {
diff --git a/src/error.rs b/src/error.rs
index 28f8504..7544e76 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -62,7 +62,7 @@ pub enum Error {
InvalidTwoFactorProvider { ty: String },
#[error("failed to parse JSON")]
- JSON {
+ Json {
source: serde_path_to_error::Error<serde_json::Error>,
},
@@ -103,7 +103,7 @@ pub enum Error {
},
#[error("openssl error")]
- OpenSSL { source: openssl::error::ErrorStack },
+ OpenSsl { source: openssl::error::ErrorStack },
#[error("failed to parse match type {s}")]
ParseMatchType { s: String },
diff --git a/src/json.rs b/src/json.rs
index d6c5328..ce95262 100644
--- a/src/json.rs
+++ b/src/json.rs
@@ -8,7 +8,7 @@ impl DeserializeJsonWithPath for String {
fn json_with_path<T: serde::de::DeserializeOwned>(self) -> Result<T> {
let jd = &mut serde_json::Deserializer::from_str(&self);
serde_path_to_error::deserialize(jd)
- .map_err(|source| Error::JSON { source })
+ .map_err(|source| Error::Json { source })
}
}
@@ -18,7 +18,7 @@ impl DeserializeJsonWithPath for reqwest::blocking::Response {
self.bytes().map_err(|source| Error::Reqwest { source })?;
let jd = &mut serde_json::Deserializer::from_slice(&bytes);
serde_path_to_error::deserialize(jd)
- .map_err(|source| Error::JSON { source })
+ .map_err(|source| Error::Json { source })
}
}
@@ -40,6 +40,6 @@ impl DeserializeJsonWithPathAsync for reqwest::Response {
.map_err(|source| Error::Reqwest { source })?;
let jd = &mut serde_json::Deserializer::from_slice(&bytes);
serde_path_to_error::deserialize(jd)
- .map_err(|source| Error::JSON { source })
+ .map_err(|source| Error::Json { source })
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 5044eb2..f84880f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,6 +5,7 @@
#![allow(clippy::large_enum_variant)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::missing_errors_doc)]
+#![allow(clippy::missing_panics_doc)]
#![allow(clippy::must_use_candidate)]
#![allow(clippy::similar_names)]
#![allow(clippy::single_match)]
diff --git a/src/pwgen.rs b/src/pwgen.rs
index cf63bb2..4d2d497 100644
--- a/src/pwgen.rs
+++ b/src/pwgen.rs
@@ -17,16 +17,6 @@ pub enum Type {
}
pub fn pwgen(ty: Type, len: usize) -> String {
- if ty == Type::Diceware {
- let config = chbs::config::BasicConfig {
- words: len,
- capitalize_first: chbs::probability::Probability::Never,
- capitalize_words: chbs::probability::Probability::Never,
- ..chbs::config::BasicConfig::default()
- };
- return config.to_scheme().generate();
- }
-
let alphabet = match ty {
Type::AllChars => {
let mut v = vec![];
@@ -51,7 +41,15 @@ pub fn pwgen(ty: Type, len: usize) -> String {
v.extend(NONCONFUSABLES.iter().copied());
v
}
- Type::Diceware => unreachable!(),
+ Type::Diceware => {
+ let config = chbs::config::BasicConfig {
+ words: len,
+ capitalize_first: chbs::probability::Probability::Never,
+ capitalize_words: chbs::probability::Probability::Never,
+ ..chbs::config::BasicConfig::default()
+ };
+ return config.to_scheme().generate();
+ }
};
let mut rng = rand::thread_rng();