Skip to content

Commit

Permalink
stream-cipher: remove NewBlockCipher bound on FromBlockCipher
Browse files Browse the repository at this point in the history
Note: breaking change.

As far as I can tell this was an oversight: `FromBlockCipher` never
needs to instantiate a new block cipher (isn't that the point?),
making this bound needlessly limiting.

The rationale for it in the first place appears to be for the blanket
impl of `NewStreamCipher` for `C: FromBlockCipher` which needs it, but
we can add the bound to the blanket impl, rather than (needlessly)
sticking it on the trait.
  • Loading branch information
tarcieri committed Oct 14, 2020
1 parent 1524ac4 commit 7c7a0db
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stream-cipher/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ impl<C: SyncStreamCipher> SyncStreamCipher for &mut C {
#[cfg_attr(docsrs, doc(cfg(feature = "block-cipher")))]
pub trait FromBlockCipher {
/// Block cipher
type BlockCipher: BlockCipher + NewBlockCipher;
type BlockCipher: BlockCipher;
/// Nonce size in bytes
type NonceSize: ArrayLength<u8>;

Expand All @@ -188,6 +188,7 @@ pub trait FromBlockCipher {
impl<C> NewStreamCipher for C
where
C: FromBlockCipher,
C::BlockCipher: NewBlockCipher,
{
type KeySize = <<Self as FromBlockCipher>::BlockCipher as NewBlockCipher>::KeySize;
type NonceSize = <Self as FromBlockCipher>::NonceSize;
Expand Down

0 comments on commit 7c7a0db

Please sign in to comment.