Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing_debug_implementations #532

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aes-gcm-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! # Usage
//!
Expand Down Expand Up @@ -123,7 +123,7 @@ pub type Aes256GcmSiv = AesGcmSiv<Aes256>;
type Ctr32LE<Aes> = ctr::CtrCore<Aes, ctr::flavors::Ctr32LE>;

/// AES-GCM-SIV: Misuse-Resistant Authenticated Encryption Cipher (RFC 8452).
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct AesGcmSiv<Aes> {
/// Key generating key used to derive AES-GCM-SIV subkeys.
key_generating_key: Aes,
Expand Down
4 changes: 2 additions & 2 deletions aes-gcm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![deny(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! # Usage
//!
Expand Down Expand Up @@ -189,7 +189,7 @@ type Ctr32BE<Aes> = ctr::CtrCore<Aes, ctr::flavors::Ctr32BE>;
/// the default of 128-bits.
///
/// If in doubt, use the built-in [`Aes128Gcm`] and [`Aes256Gcm`] type aliases.
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct AesGcm<Aes, NonceSize, TagSize = U16>
where
TagSize: self::TagSize,
Expand Down
16 changes: 11 additions & 5 deletions aes-siv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![warn(missing_docs, rust_2018_idioms, unused_qualifications)]
#![warn(
missing_debug_implementations,
missing_docs,
rust_2018_idioms,
unused_qualifications
)]

//! # Usage
//!
Expand Down Expand Up @@ -113,6 +118,7 @@ pub type Tag = GenericArray<u8, U16>;
/// The `SivAead` type wraps the more powerful `Siv` interface in a more
/// commonly used Authenticated Encryption with Associated Data (AEAD) API,
/// which accepts a key, nonce, and associated data when encrypting/decrypting.
#[derive(Debug)]
pub struct SivAead<C, M>
where
Self: KeySizeUser,
Expand Down Expand Up @@ -220,7 +226,7 @@ where
// final component -- i.e., the string immediately preceding the
// plaintext in the vector input to S2V -- is used for the nonce."
// https://tools.ietf.org/html/rfc5297#section-3
Siv::<C, M>::new(&self.key).encrypt_in_place(&[associated_data, nonce.as_slice()], buffer)
Siv::<C, M>::new(&self.key).encrypt_in_place([associated_data, nonce.as_slice()], buffer)
}

fn encrypt_in_place_detached(
Expand All @@ -230,7 +236,7 @@ where
buffer: &mut [u8],
) -> Result<GenericArray<u8, Self::TagSize>, Error> {
Siv::<C, M>::new(&self.key)
.encrypt_in_place_detached(&[associated_data, nonce.as_slice()], buffer)
.encrypt_in_place_detached([associated_data, nonce.as_slice()], buffer)
}

fn decrypt_in_place(
Expand All @@ -239,7 +245,7 @@ where
associated_data: &[u8],
buffer: &mut dyn Buffer,
) -> Result<(), Error> {
Siv::<C, M>::new(&self.key).decrypt_in_place(&[associated_data, nonce.as_slice()], buffer)
Siv::<C, M>::new(&self.key).decrypt_in_place([associated_data, nonce.as_slice()], buffer)
}

fn decrypt_in_place_detached(
Expand All @@ -250,7 +256,7 @@ where
tag: &GenericArray<u8, Self::TagSize>,
) -> Result<(), Error> {
Siv::<C, M>::new(&self.key).decrypt_in_place_detached(
&[associated_data, nonce.as_slice()],
[associated_data, nonce.as_slice()],
buffer,
tag,
)
Expand Down
1 change: 1 addition & 0 deletions aes-siv/src/siv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ pub type KeySize<C> = <<C as KeySizeUser>::KeySize as Add>::Output;

/// Synthetic Initialization Vector (SIV) mode, providing misuse-resistant
/// authenticated encryption (MRAE).
#[derive(Debug)]
pub struct Siv<C, M>
where
C: BlockCipher<BlockSize = U16> + BlockEncryptMut + KeyInit + KeySizeUser,
Expand Down
7 changes: 5 additions & 2 deletions ascon-aead/src/asconcore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ pub(crate) trait InternalKey<KS: ArrayLength<u8>>:
fn get_k2(&self) -> u64;
}

#[derive(Clone)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "zeroize", derive(zeroize::Zeroize, zeroize::ZeroizeOnDrop))]
pub(crate) struct InternalKey16(u64, u64);

Expand All @@ -83,7 +83,7 @@ impl From<&GenericArray<u8, U16>> for InternalKey16 {
}
}

#[derive(Clone)]
#[derive(Debug, Clone)]
#[cfg_attr(feature = "zeroize", derive(zeroize::Zeroize, zeroize::ZeroizeOnDrop))]
pub(crate) struct InternalKey20(u64, u64, u32);

Expand Down Expand Up @@ -134,6 +134,7 @@ pub(crate) trait Parameters {
}

/// Parameters for Ascon-128
#[derive(Debug)]
pub(crate) struct Parameters128;

impl Parameters for Parameters128 {
Expand All @@ -145,6 +146,7 @@ impl Parameters for Parameters128 {
}

/// Parameters for Ascon-128a
#[derive(Debug)]
pub(crate) struct Parameters128a;

impl Parameters for Parameters128a {
Expand All @@ -156,6 +158,7 @@ impl Parameters for Parameters128a {
}

/// Parameters for Ascon-80pq
#[derive(Debug)]
pub(crate) struct Parameters80pq;

impl Parameters for Parameters80pq {
Expand Down
7 changes: 5 additions & 2 deletions ascon-aead/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![warn(missing_docs)]
#![warn(missing_debug_implementations, missing_docs)]

//! ## Usage
//!
Expand Down Expand Up @@ -112,7 +112,7 @@ use asconcore::{AsconCore, Parameters, Parameters128, Parameters128a, Parameters
///
/// This type is generic to support substituting various Ascon parameter sets. It is not intended to
/// be uses directly. Use the [`Ascon128`], [`Ascon128a`], [`Ascon80pq`] type aliases instead.
#[derive(Clone)]
#[derive(Debug, Clone)]
struct Ascon<P: Parameters> {
key: P::InternalKey,
}
Expand Down Expand Up @@ -173,6 +173,7 @@ impl<P: Parameters> AeadInPlace for Ascon<P> {
}

/// Ascon-128
#[derive(Debug)]
pub struct Ascon128(Ascon<Parameters128>);
/// Key for Ascon-128
pub type Ascon128Key = Key<Ascon128>;
Expand Down Expand Up @@ -223,6 +224,7 @@ impl AeadInPlace for Ascon128 {
}

/// Ascon-128a
#[derive(Debug)]
pub struct Ascon128a(Ascon<Parameters128a>);

/// Key for Ascon-128a
Expand Down Expand Up @@ -274,6 +276,7 @@ impl AeadInPlace for Ascon128a {
}

/// Ascon-80pq
#[derive(Debug)]
pub struct Ascon80pq(Ascon<Parameters80pq>);
/// Key for Ascon-80pq
pub type Ascon80pqKey = Key<Ascon80pq>;
Expand Down
4 changes: 2 additions & 2 deletions ccm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![deny(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! # Usage
//!
Expand Down Expand Up @@ -91,7 +91,7 @@ impl<T: private::SealedNonce> NonceSize for T {}
/// [`U7`][consts::U7], [`U8`][consts::U8], [`U9`][consts::U9],
/// [`U10`][consts::U10], [`U11`][consts::U11], [`U12`][consts::U12],
/// [`U13`][consts::U13].
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Ccm<C, M, N>
where
C: BlockCipher + BlockSizeUser<BlockSize = U16> + BlockEncrypt,
Expand Down
4 changes: 2 additions & 2 deletions chacha20poly1305/src/cipher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ where
pub(crate) fn new(mut cipher: C) -> Self {
// Derive Poly1305 key from the first 32-bytes of the ChaCha20 keystream
let mut mac_key = poly1305::Key::default();
cipher.apply_keystream(&mut *mac_key);
cipher.apply_keystream(&mut mac_key);

let mac = Poly1305::new(GenericArray::from_slice(&*mac_key));
let mac = Poly1305::new(GenericArray::from_slice(&mac_key));
mac_key.zeroize();

// Set ChaCha20 counter to 1
Expand Down
3 changes: 2 additions & 1 deletion chacha20poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! ## Supported Algorithms
//!
Expand Down Expand Up @@ -211,6 +211,7 @@ pub type XChaCha12Poly1305 = ChaChaPoly1305<XChaCha12, U24>;
/// Generic ChaCha+Poly1305 Authenticated Encryption with Additional Data (AEAD) construction.
///
/// See the [toplevel documentation](index.html) for a usage example.
#[derive(Debug)]
pub struct ChaChaPoly1305<C, N: ArrayLength<u8> = U12> {
/// Secret key.
key: Key,
Expand Down
2 changes: 2 additions & 0 deletions deoxys/src/deoxys_bc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ const RCON: [[u8; 16]; 17] = [
];

/// Implementation of the Deoxys-BC256 block cipher
#[derive(Debug)]
pub struct DeoxysBc256;

/// Implementation of the Deoxys-BC384 block cipher
#[derive(Debug)]
pub struct DeoxysBc384;

pub trait DeoxysBcInternal {
Expand Down
3 changes: 2 additions & 1 deletion deoxys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! # Usage
//!
Expand Down Expand Up @@ -223,6 +223,7 @@ pub trait DeoxysBcType: deoxys_bc::DeoxysBcInternal {
/// Generic Deoxys implementation.
///
/// This type is generic to support multiple Deoxys modes(namely Deoxys-I and Deoxys-II) and key size.
#[derive(Debug)]
pub struct Deoxys<M, B>
where
M: DeoxysMode<B>,
Expand Down
2 changes: 2 additions & 0 deletions deoxys/src/modes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ const TWEAK_M_LAST: u8 = 0x40;
const TWEAK_CHKSUM: u8 = 0x50;

/// Implementation of the Deoxys-I mode of operation.
#[derive(Debug)]
pub struct DeoxysI<B> {
_ptr: PhantomData<B>,
}

/// Implementation of the Deoxys-II mode of operation.
#[allow(clippy::upper_case_acronyms)]
#[derive(Debug)]
pub struct DeoxysII<B> {
_ptr: PhantomData<B>,
}
Expand Down
4 changes: 2 additions & 2 deletions eax/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/meta/master/logo.svg"
)]
#![deny(unsafe_code)]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

//! # Usage
//!
Expand Down Expand Up @@ -166,7 +166,7 @@ type Ctr128BE<C> = ctr::CtrCore<C, ctr::flavors::Ctr128BE>;
/// ## Type parameters
/// - `Cipher`: block cipher.
/// - `M`: size of MAC tag, valid values: up to `U16`.
#[derive(Clone)]
#[derive(Debug, Clone)]
pub struct Eax<Cipher, M = U16>
where
Cipher: BlockCipher<BlockSize = U16> + BlockEncrypt + Clone + KeyInit,
Expand Down
4 changes: 4 additions & 0 deletions eax/src/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,12 @@ pub use Eax as EaxOnline;
pub trait CipherOp {}

/// Marker struct for EAX stream used in encryption mode.
#[derive(Debug)]
pub struct Encrypt;
impl CipherOp for Encrypt {}

/// Marker struct for EAX stream used in decryption mode.
#[derive(Debug)]
pub struct Decrypt;
impl CipherOp for Decrypt {}

Expand Down Expand Up @@ -148,6 +150,7 @@ impl CipherOp for Decrypt {}
/// [`Eax`]: ../struct.Eax.html
/// [`Decrypt`]: struct.Decrypt.html
/// [`finish`]: #method.finish
#[derive(Debug)]
pub struct Eax<Cipher, Op, M = U16>
where
Cipher: BlockCipher<BlockSize = U16> + BlockEncrypt + Clone + KeyInit,
Expand Down Expand Up @@ -263,6 +266,7 @@ where
/// Main reason behind extracting the logic to a single, separate type is to
/// facilitate testing of the internal logic.
#[doc(hidden)]
#[derive(Debug)]
struct EaxImpl<Cipher, M>
where
Cipher: BlockCipher<BlockSize = U16> + BlockEncrypt + Clone + KeyInit,
Expand Down
4 changes: 2 additions & 2 deletions xsalsa20poly1305/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,8 @@ where
pub(crate) fn new(mut cipher: C) -> Self {
// Derive Poly1305 key from the first 32-bytes of the Salsa20 keystream
let mut mac_key = poly1305::Key::default();
cipher.apply_keystream(&mut *mac_key);
let mac = Poly1305::new(GenericArray::from_slice(&*mac_key));
cipher.apply_keystream(&mut mac_key);
let mac = Poly1305::new(GenericArray::from_slice(&mac_key));
mac_key.zeroize();

Self { cipher, mac }
Expand Down