Skip to content

Commit

Permalink
fix clippy warnings for SPAKE2
Browse files Browse the repository at this point in the history
  • Loading branch information
brxken128 committed Aug 14, 2023
1 parent 8d3f2fd commit 8f400ba
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 26 deletions.
5 changes: 3 additions & 2 deletions aucpace/examples/key_agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ macro_rules! recv {

fn main() -> Result<()> {
// example username and password, never user these...
const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";

// the server socket address to bind to
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);
Expand Down Expand Up @@ -286,6 +286,7 @@ struct TcpChannelIdentifier {
}

impl TcpChannelIdentifier {
#[allow(clippy::unused_io_amount)]
fn new(src: SocketAddr, dst: SocketAddr) -> std::io::Result<Self> {
let mut id = vec![];

Expand Down
6 changes: 3 additions & 3 deletions aucpace/examples/key_agreement_no_std.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ macro_rules! recv {

fn main() -> Result<()> {
// example username and password, never user these...
const USERNAME: &'static [u8] = b"adira.tal";
const PASSWORD: &'static [u8] = b"4d1rA_aND-Gr4Y_aRe_tH3-b3sT <3";
const USERNAME: &[u8] = b"adira.tal";
const PASSWORD: &[u8] = b"4d1rA_aND-Gr4Y_aRe_tH3-b3sT <3";

// register the user in the database
let mut base_server = Server::new(OsRng);
Expand Down Expand Up @@ -148,7 +148,7 @@ fn main() -> Result<()> {

// ===== CPace substep =====
// first generate the server's public key and send it
const CI: &'static str = "channel_identifier";
const CI: &str = "channel_identifier";
let (server, message) = server.generate_public_key(CI);
let bytes_sent = send!(server_buf, message);
server_bytes_sent += bytes_sent;
Expand Down
7 changes: 4 additions & 3 deletions aucpace/examples/key_agreement_partial_aug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ macro_rules! recv {

fn main() -> Result<()> {
// example username and password, never user these...
const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";

// the server socket address to bind to
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);
Expand Down Expand Up @@ -297,7 +297,7 @@ impl PartialAugDatabase for SingleUserDatabase {
username: &[u8],
) -> Option<(Self::PrivateKey, Self::PublicKey)> {
match &self.user {
Some(stored_user) if stored_user == username => self.long_term_keypair.clone(),
Some(stored_user) if stored_user == username => self.long_term_keypair,
_ => None,
}
}
Expand Down Expand Up @@ -325,6 +325,7 @@ struct TcpChannelIdentifier {
}

impl TcpChannelIdentifier {
#[allow(clippy::unused_io_amount)]
fn new(src: SocketAddr, dst: SocketAddr) -> std::io::Result<Self> {
let mut id = vec![];

Expand Down
5 changes: 3 additions & 2 deletions aucpace/examples/key_agreement_strong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ macro_rules! recv {

fn main() -> Result<()> {
// example username and password, never user these...
const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";

// the server socket address to bind to
let server_socket: SocketAddr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25519);
Expand Down Expand Up @@ -291,6 +291,7 @@ struct TcpChannelIdentifier {
}

impl TcpChannelIdentifier {
#[allow(clippy::unused_io_amount)]
fn new(src: SocketAddr, dst: SocketAddr) -> std::io::Result<Self> {
let mut id = vec![];

Expand Down
4 changes: 2 additions & 2 deletions aucpace/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,7 +745,7 @@ mod tests {
}

#[test]
#[cfg(all(feature = "sha2"))]
#[cfg(feature = "sha2")]
fn test_server_doesnt_accept_invalid_pubkey() {
use crate::utils::H0;
use curve25519_dalek::traits::Identity;
Expand All @@ -762,7 +762,7 @@ mod tests {
}

#[test]
#[cfg(all(feature = "sha2"))]
#[cfg(feature = "sha2")]
fn test_server_doesnt_accept_invalid_pubkey_implicit_auth() {
use crate::utils::H0;
use curve25519_dalek::traits::Identity;
Expand Down
2 changes: 1 addition & 1 deletion aucpace/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ pub(crate) mod serde_saltstring {
}
}

#[cfg(any(feature = "serde"))]
#[cfg(feature = "serde")]
pub(crate) mod serde_paramsstring {
use core::fmt;
use password_hash::ParamsString;
Expand Down
4 changes: 2 additions & 2 deletions aucpace/tests/test_key_agreement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use rand_core::OsRng;
use scrypt::{Params, Scrypt};
use sha2::Sha512;

const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";
const CI: &[u8] = b"test_channel_identifier";
const PRE_SSID: &[u8] = b"bestest_ssid_ever_i_promise";
const K1: usize = 16;
Expand Down
6 changes: 3 additions & 3 deletions aucpace/tests/test_key_agreement_partial_aug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rand_core::OsRng;
use scrypt::{Params, Scrypt};
use sha2::Sha512;

const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";
const CI: &[u8] = b"test_channel_identifier";
const PRE_SSID: &[u8] = b"bestest_ssid_ever_i_promise";
const K1: usize = 16;
Expand Down Expand Up @@ -58,7 +58,7 @@ impl PartialAugDatabase for SingleUserDatabase {
username: &[u8],
) -> Option<(Self::PrivateKey, Self::PublicKey)> {
match &self.user {
Some(stored_user) if stored_user == username => self.long_term_keypair.clone(),
Some(stored_user) if stored_user == username => self.long_term_keypair,
_ => None,
}
}
Expand Down
4 changes: 2 additions & 2 deletions aucpace/tests/test_key_agreement_strong.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use rand_core::OsRng;
use scrypt::{Params, Scrypt};
use sha2::Sha512;

const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";
const CI: &[u8] = b"test_channel_identifier";
const PRE_SSID: &[u8] = b"bestest_ssid_ever_i_promise";
const K1: usize = 16;
Expand Down
6 changes: 3 additions & 3 deletions aucpace/tests/test_key_agreement_strong_partial_aug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ use rand_core::OsRng;
use scrypt::{Params, Scrypt};
use sha2::Sha512;

const USERNAME: &'static [u8] = b"jlpicard_1701";
const PASSWORD: &'static [u8] = b"g04tEd_c4pT41N";
const USERNAME: &[u8] = b"jlpicard_1701";
const PASSWORD: &[u8] = b"g04tEd_c4pT41N";
const CI: &[u8] = b"test_channel_identifier";
const PRE_SSID: &[u8] = b"bestest_ssid_ever_i_promise";
const K1: usize = 16;
Expand Down Expand Up @@ -59,7 +59,7 @@ impl PartialAugDatabase for SingleUserDatabase {
username: &[u8],
) -> Option<(Self::PrivateKey, Self::PublicKey)> {
match &self.user {
Some(stored_user) if stored_user == username => self.long_term_keypair.clone(),
Some(stored_user) if stored_user == username => self.long_term_keypair,
_ => None,
}
}
Expand Down
1 change: 1 addition & 0 deletions spake2/tests/spake2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ fn test_reflected_message() {
}

#[test]
#[allow(clippy::slow_vector_initialization)]
fn test_bad_length() {
let (s1, msg1) = Spake2::<Ed25519Group>::start_a(
&Password::new(b"password"),
Expand Down
6 changes: 3 additions & 3 deletions srp/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ pub fn compute_m1<D: Digest>(a_pub: &[u8], b_pub: &[u8], key: &[u8]) -> Output<D
// M2 = H(A, M1, K)
pub fn compute_m2<D: Digest>(a_pub: &[u8], m1: &Output<D>, key: &[u8]) -> Output<D> {
let mut d = D::new();
d.update(&a_pub);
d.update(&m1);
d.update(&key);
d.update(a_pub);
d.update(m1);
d.update(key);
d.finalize()
}

0 comments on commit 8f400ba

Please sign in to comment.