Skip to content

Commit

Permalink
fix: missing_debug_implementations (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanWoollett-Light committed Jun 8, 2023
1 parent 2fa4ca7 commit fb6e81a
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 11 deletions.
27 changes: 23 additions & 4 deletions belt-ctr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,17 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

pub use cipher;

use belt_block::BeltBlock;
use cipher::{
consts::U16, crypto_common::InnerUser, generic_array::GenericArray, BlockDecrypt, BlockEncrypt,
BlockSizeUser, InnerIvInit, Iv, IvSizeUser, IvState, StreamCipherCore, StreamCipherCoreWrapper,
StreamCipherSeekCore, StreamClosure,
consts::U16, crypto_common::InnerUser, generic_array::GenericArray, AlgorithmName,
BlockDecrypt, BlockEncrypt, BlockSizeUser, InnerIvInit, Iv, IvSizeUser, IvState,
StreamCipherCore, StreamCipherCoreWrapper, StreamCipherSeekCore, StreamClosure,
};
use core::fmt;

mod backend;

Expand Down Expand Up @@ -110,3 +111,21 @@ where
t
}
}

impl<C> AlgorithmName for BeltCtrCore<C>
where
C: BlockEncrypt + BlockDecrypt + BlockSizeUser<BlockSize = U16> + AlgorithmName,
{
fn write_alg_name(f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("BeltCtr<")?;
<C as AlgorithmName>::write_alg_name(f)?;
f.write_str(">")
}
}

impl<C: BlockEncrypt + BlockSizeUser<BlockSize = U16>> fmt::Debug for BeltCtrCore<C> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("BeltCtrCore { ... }")
}
}
2 changes: 1 addition & 1 deletion cbc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

mod decrypt;
mod encrypt;
Expand Down
2 changes: 1 addition & 1 deletion cfb-mode/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

mod decrypt;
mod encrypt;
Expand Down
2 changes: 1 addition & 1 deletion cfb8/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

mod decrypt;
mod encrypt;
Expand Down
10 changes: 10 additions & 0 deletions ctr/src/flavors/ctr128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cipher::{
generic_array::{ArrayLength, GenericArray},
typenum::{PartialDiv, PartialQuot, Unsigned, U16},
};
use core::fmt;

#[cfg(feature = "zeroize")]
use cipher::zeroize::{Zeroize, ZeroizeOnDrop};
Expand All @@ -18,6 +19,13 @@ pub struct CtrNonce128<N: ArrayLength<u128>> {
nonce: GenericArray<u128, N>,
}

impl<N: ArrayLength<u128>> fmt::Debug for CtrNonce128<N> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("CtrNonce128 { ... }")
}
}

#[cfg(feature = "zeroize")]
impl<N: ArrayLength<u128>> Drop for CtrNonce128<N> {
fn drop(&mut self) {
Expand All @@ -30,6 +38,7 @@ impl<N: ArrayLength<u128>> Drop for CtrNonce128<N> {
impl<N: ArrayLength<u128>> ZeroizeOnDrop for CtrNonce128<N> {}

/// 128-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr128BE {}

impl<B> CtrFlavor<B> for Ctr128BE
Expand Down Expand Up @@ -94,6 +103,7 @@ where
}

/// 128-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr128LE {}

impl<B> CtrFlavor<B> for Ctr128LE
Expand Down
10 changes: 10 additions & 0 deletions ctr/src/flavors/ctr32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cipher::{
generic_array::{ArrayLength, GenericArray},
typenum::{PartialDiv, PartialQuot, Unsigned, U4},
};
use core::fmt;

#[cfg(feature = "zeroize")]
use cipher::zeroize::{Zeroize, ZeroizeOnDrop};
Expand All @@ -18,6 +19,13 @@ pub struct CtrNonce32<N: ArrayLength<u32>> {
nonce: GenericArray<u32, N>,
}

impl<N: ArrayLength<u32>> fmt::Debug for CtrNonce32<N> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("CtrNonce32 { ... }")
}
}

#[cfg(feature = "zeroize")]
impl<N: ArrayLength<u32>> Drop for CtrNonce32<N> {
fn drop(&mut self) {
Expand All @@ -30,6 +38,7 @@ impl<N: ArrayLength<u32>> Drop for CtrNonce32<N> {
impl<N: ArrayLength<u32>> ZeroizeOnDrop for CtrNonce32<N> {}

/// 32-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr32BE {}

impl<B> CtrFlavor<B> for Ctr32BE
Expand Down Expand Up @@ -94,6 +103,7 @@ where
}

/// 32-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr32LE {}

impl<B> CtrFlavor<B> for Ctr32LE
Expand Down
10 changes: 10 additions & 0 deletions ctr/src/flavors/ctr64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use cipher::{
generic_array::{ArrayLength, GenericArray},
typenum::{PartialDiv, PartialQuot, Unsigned, U8},
};
use core::fmt;

#[cfg(feature = "zeroize")]
use cipher::zeroize::{Zeroize, ZeroizeOnDrop};
Expand All @@ -18,6 +19,13 @@ pub struct CtrNonce64<N: ArrayLength<u64>> {
nonce: GenericArray<u64, N>,
}

impl<N: ArrayLength<u64>> fmt::Debug for CtrNonce64<N> {
#[inline]
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("CtrNonce64 { ... }")
}
}

#[cfg(feature = "zeroize")]
impl<N: ArrayLength<u64>> Drop for CtrNonce64<N> {
fn drop(&mut self) {
Expand All @@ -30,6 +38,7 @@ impl<N: ArrayLength<u64>> Drop for CtrNonce64<N> {
impl<N: ArrayLength<u64>> ZeroizeOnDrop for CtrNonce64<N> {}

/// 64-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr64BE {}

impl<B> CtrFlavor<B> for Ctr64BE
Expand Down Expand Up @@ -94,6 +103,7 @@ where
}

/// 64-bit big endian counter flavor.
#[derive(Debug)]
pub enum Ctr64LE {}

impl<B> CtrFlavor<B> for Ctr64LE
Expand Down
2 changes: 1 addition & 1 deletion ctr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

pub mod flavors;

Expand Down
2 changes: 1 addition & 1 deletion ige/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

mod decrypt;
mod encrypt;
Expand Down
2 changes: 1 addition & 1 deletion ofb/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

pub use cipher;

Expand Down
2 changes: 1 addition & 1 deletion pcbc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![warn(missing_docs, rust_2018_idioms)]
#![warn(missing_debug_implementations, missing_docs, rust_2018_idioms)]

mod decrypt;
mod encrypt;
Expand Down

0 comments on commit fb6e81a

Please sign in to comment.