Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ctr: implement Clone directly instead of deriving it #24

Merged
merged 1 commit into from Sep 29, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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