Skip to content

Commit

Permalink
pcbc: tweak code to help with codegen (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
newpavlov committed Mar 24, 2022
1 parent 5781d3f commit a1e06f2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 15 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 pcbc/CHANGELOG.md
Original file line number Diff line number Diff line change
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.1.2 (2022-03-24)
### Changed
- Minor code tweaks to help compiler with codegen ([#16])

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

## 0.1.1 (2022-02-17)
### Fixed
- Minimal versions build ([#9])
Expand Down
2 changes: 1 addition & 1 deletion pcbc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pcbc"
version = "0.1.1" # Also update html_root_url in lib.rs when bumping this
version = "0.1.2" # Also update html_root_url in lib.rs when bumping this
description = "Propagating Cipher Block Chaining (PCBC) block cipher mode of operation"
authors = ["RustCrypto Developers"]
license = "MIT OR Apache-2.0"
Expand Down
13 changes: 7 additions & 6 deletions pcbc/src/decrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ where
{
#[inline(always)]
fn proc_block(&mut self, mut block: InOut<'_, '_, Block<Self>>) {
let t = self.iv.clone();
*self.iv = block.clone_in();
self.backend.proc_block(block.reborrow());
let res = block.get_out();
xor(res, &t);
xor(self.iv, res);
let mut t1 = block.clone_in();
let mut t2 = block.clone_in();
self.backend.proc_block((&mut t1).into());
xor(&mut t1, self.iv);
xor(&mut t2, &t1);
*self.iv = t2;
*block.get_out() = t1;
}
}
13 changes: 7 additions & 6 deletions pcbc/src/encrypt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,12 @@ where
{
#[inline(always)]
fn proc_block(&mut self, mut block: InOut<'_, '_, Block<Self>>) {
let mut t = block.clone_in();
xor(&mut t, self.iv);
*self.iv = block.clone_in();
let b = (&t, block.get_out()).into();
self.backend.proc_block(b);
xor(self.iv, block.get_out());
let mut t1 = block.clone_in();
let mut t2 = block.clone_in();
xor(&mut t1, self.iv);
self.backend.proc_block((&mut t1).into());
xor(&mut t2, &t1);
*block.get_out() = t1;
*self.iv = t2;
}
}
2 changes: 1 addition & 1 deletion pcbc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
#![doc(
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg",
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/26acc39f/logo.svg",
html_root_url = "https://docs.rs/pcbc/0.1.1"
html_root_url = "https://docs.rs/pcbc/0.1.2"
)]
#![forbid(unsafe_code)]
#![cfg_attr(docsrs, feature(doc_cfg))]
Expand Down

0 comments on commit a1e06f2

Please sign in to comment.