Skip to content

Commit

Permalink
crypto-common: rename serializable_state module to hazmat (#1487)
Browse files Browse the repository at this point in the history
Also removes the toplevel re-exports for the traits, forcing users to go
through the now `pub hazmat` module.

There's a lot of misuse potential with these traits, which are intended
to make it possible to serialize/deserialize the internal state of hash
functions. However previously they were presented side-by-side with
other traits, which made that unclear.

This commit deliberately doesn't make other changes to the file so git
will preserve its history:

    diff --git a/crypto-common/src/serializable_state.rs b/crypto-common/src/hazmat.rs
    similarity index 100%
    rename from crypto-common/src/serializable_state.rs
    rename to crypto-common/src/hazmat.rs

It would be very good for a followup commit to massively expand the
documentation around both the module and the traits, especially to spell
out the various ways they can be misused.
  • Loading branch information
tarcieri authored Jan 27, 2024
1 parent 1568df8 commit d622f97
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 45 deletions.
43 changes: 10 additions & 33 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ members = [
]

[patch.crates-io]
crypto-common = { path = "./crypto-common" }
digest = { path = "./digest" }
signature = { path = "./signature" }
File renamed without changes.
9 changes: 3 additions & 6 deletions crypto-common/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
#[cfg(feature = "std")]
extern crate std;

/// Hazardous materials.
pub mod hazmat;

#[cfg(feature = "getrandom")]
pub use getrandom;
#[cfg(feature = "rand_core")]
Expand All @@ -29,12 +32,6 @@ use hybrid_array::{
#[cfg(feature = "rand_core")]
use rand_core::CryptoRngCore;

mod serializable_state;
pub use serializable_state::{
AddSerializedStateSize, DeserializeStateError, SerializableState, SerializedState,
SubSerializedStateSize,
};

/// Block on which [`BlockSizeUser`] implementors operate.
pub type Block<B> = Array<u8, <B as BlockSizeUser>::BlockSize>;

Expand Down
4 changes: 2 additions & 2 deletions digest/src/core_api/ct_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ use core::{
};
use crypto_common::{
array::{Array, ArraySize},
hazmat::{DeserializeStateError, SerializableState, SerializedState, SubSerializedStateSize},
typenum::{IsLess, IsLessOrEqual, Le, LeEq, NonZero, Sum, U1, U256},
Block, BlockSizeUser, DeserializeStateError, OutputSizeUser, SerializableState,
SerializedState, SubSerializedStateSize,
Block, BlockSizeUser, OutputSizeUser,
};

/// Dummy type used with [`CtVariableCoreWrapper`] in cases when
Expand Down
4 changes: 2 additions & 2 deletions digest/src/core_api/rt_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ use core::{
fmt,
ops::{Add, Sub},
};
use crypto_common::SubSerializedStateSize;
use crypto_common::{
array::{Array, ArraySize},
hazmat::{DeserializeStateError, SerializableState, SerializedState, SubSerializedStateSize},
typenum::{Diff, IsLess, Le, NonZero, Sum, Unsigned, U1, U256},
AddBlockSize, DeserializeStateError, SerializableState, SerializedState, SubBlockSize,
AddBlockSize, SubBlockSize,
};
#[cfg(feature = "zeroize")]
use zeroize::ZeroizeOnDrop;
Expand Down
4 changes: 2 additions & 2 deletions digest/src/core_api/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ use core::{
};
use crypto_common::{
array::{Array, ArraySize},
hazmat::{DeserializeStateError, SerializableState, SerializedState, SubSerializedStateSize},
typenum::{Diff, IsLess, Le, NonZero, Sum, U1, U256},
BlockSizeUser, DeserializeStateError, InvalidLength, Key, KeyInit, KeySizeUser, Output,
SerializableState, SerializedState, SubSerializedStateSize,
BlockSizeUser, InvalidLength, Key, KeyInit, KeySizeUser, Output,
};

#[cfg(feature = "mac")]
Expand Down

0 comments on commit d622f97

Please sign in to comment.