Skip to content
Merged
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
14 changes: 14 additions & 0 deletions belt-ctr/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,19 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.2.0 (UNRELEASED)
## Added
- `GenericBeltCtr` and `GenericBeltCtrCore` types ([#112])

## Changed
- Bump `cipher` from `0.4` to `0.5` ([#56])
- Edition changed to 2024 and MSRV bumped to 1.85 ([#76])
- Relax MSRV policy and allow MSRV bumps in patch releases
- Use type aliases instead of type defaults to define default `belt-block` implementation ([#112])

[#56]: https://github.com/RustCrypto/block-modes/pull/56
[#76]: https://github.com/RustCrypto/block-modes/pull/76
[#112]: https://github.com/RustCrypto/block-modes/pull/112

## 0.1.0 (2023-04-02)
- Initial release
2 changes: 1 addition & 1 deletion belt-ctr/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ let ciphertext: &[u8; 34] = &hex!(
"7D1B"
);

let mut cipher: BeltCtr = BeltCtr::new_from_slices(key, iv).unwrap();
let mut cipher = BeltCtr::new_from_slices(key, iv).unwrap();

// encrypt in-place
let mut buf = plaintext.clone();
Expand Down
32 changes: 18 additions & 14 deletions belt-ctr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ use core::fmt;
use cipher::zeroize::{Zeroize, ZeroizeOnDrop};

/// Byte-level BelT CTR
pub type BeltCtr<C = BeltBlock> = StreamCipherCoreWrapper<BeltCtrCore<C>>;

pub type BeltCtr = GenericBeltCtr<BeltBlock>;
/// Block-level BelT CTR
pub struct BeltCtrCore<C = BeltBlock>
pub type BeltCtrCore = GenericBeltCtrCore<BeltBlock>;
/// Byte-level BelT CTR generic over block cipher implementation
pub type GenericBeltCtr<C> = StreamCipherCoreWrapper<GenericBeltCtrCore<C>>;

/// Block-level BelT CTR generic over block cipher implementation
pub struct GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
Expand All @@ -33,7 +37,7 @@ where
s_init: u128,
}

impl<C> StreamCipherCore for BeltCtrCore<C>
impl<C> StreamCipherCore for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
Expand Down Expand Up @@ -65,7 +69,7 @@ where
}
}

impl<C> StreamCipherSeekCore for BeltCtrCore<C>
impl<C> StreamCipherSeekCore for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
Expand All @@ -80,28 +84,28 @@ where
}
}

impl<C> BlockSizeUser for BeltCtrCore<C>
impl<C> BlockSizeUser for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
type BlockSize = C::BlockSize;
}

impl<C> IvSizeUser for BeltCtrCore<C>
impl<C> IvSizeUser for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
type IvSize = C::BlockSize;
}

impl<C> InnerUser for BeltCtrCore<C>
impl<C> InnerUser for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
type Inner = C;
}

impl<C> InnerIvInit for BeltCtrCore<C>
impl<C> InnerIvInit for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
Expand All @@ -118,7 +122,7 @@ where
}
}

impl<C> IvState for BeltCtrCore<C>
impl<C> IvState for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockCipherDecrypt + BlockSizeUser<BlockSize = U16>,
{
Expand All @@ -129,7 +133,7 @@ where
}
}

impl<C> AlgorithmName for BeltCtrCore<C>
impl<C> AlgorithmName for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16> + AlgorithmName,
{
Expand All @@ -140,7 +144,7 @@ where
}
}

impl<C> fmt::Debug for BeltCtrCore<C>
impl<C> fmt::Debug for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16> + AlgorithmName,
{
Expand All @@ -152,7 +156,7 @@ where
}
}

impl<C: BlockCipherEncrypt> Drop for BeltCtrCore<C>
impl<C: BlockCipherEncrypt> Drop for GenericBeltCtrCore<C>
where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16>,
{
Expand All @@ -166,7 +170,7 @@ where
}

#[cfg(feature = "zeroize")]
impl<C> ZeroizeOnDrop for BeltCtrCore<C> where
impl<C> ZeroizeOnDrop for GenericBeltCtrCore<C> where
C: BlockCipherEncrypt + BlockSizeUser<BlockSize = U16> + ZeroizeOnDrop
{
}
Expand Down
Loading