Skip to content

Commit

Permalink
ctr: implement Clone directly instead of deriving it (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Sep 29, 2022
1 parent 37276dd commit 6532094
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

6 changes: 6 additions & 0 deletions ctr/CHANGELOG.md
Expand Up @@ -5,6 +5,12 @@ 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.9.2 (2022-09-30)
### Changed
- Implement `Clone` directly for `CtrCore`, so it would work with non-`Clone` flavors ([#24])

[#24]: https://github.com/RustCrypto/block-modes/pull/24

## 0.9.1 (2022-02-17)
### Fixed
- Minimal versions build ([#9])
Expand Down
2 changes: 1 addition & 1 deletion ctr/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "ctr"
version = "0.9.1"
version = "0.9.2"
description = "CTR block modes of operation"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand Down
15 changes: 14 additions & 1 deletion ctr/src/ctr_core.rs
Expand Up @@ -10,7 +10,6 @@ use core::fmt;
use cipher::zeroize::ZeroizeOnDrop;

/// Generic CTR block mode instance.
#[derive(Clone)]
pub struct CtrCore<C, F>
where
C: BlockEncryptMut + BlockCipher,
Expand Down Expand Up @@ -118,6 +117,20 @@ where
}
}

impl<C, F> Clone for CtrCore<C, F>
where
C: BlockEncryptMut + BlockCipher + Clone,
F: CtrFlavor<C::BlockSize>,
{
#[inline]
fn clone(&self) -> Self {
Self {
cipher: self.cipher.clone(),
ctr_nonce: self.ctr_nonce.clone(),
}
}
}

impl<C, F> fmt::Debug for CtrCore<C, F>
where
C: BlockEncryptMut + BlockCipher + AlgorithmName,
Expand Down

0 comments on commit 6532094

Please sign in to comment.