Skip to content

Commit

Permalink
ChaCha: use slice::copy_within instead of core::ptr::copy.
Browse files Browse the repository at this point in the history
Use less `unsafe`.
  • Loading branch information
briansmith committed Jun 19, 2020
1 parent 8d4e283 commit 165d0b9
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions src/aead/chacha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ impl Key {
// https://rt.openssl.org/Ticket/Display.html?id=4362
let len = in_out.len() - in_prefix_len;
if cfg!(any(target_arch = "arm", target_arch = "x86")) && in_prefix_len != 0 {
// TODO: replace with `in_out.copy_within(in_prefix_len.., 0)`
// See https://github.com/rust-lang/rust/issues/54236.
unsafe {
core::ptr::copy(in_out[in_prefix_len..].as_ptr(), in_out.as_mut_ptr(), len);
}
in_out.copy_within(in_prefix_len.., 0);
self.encrypt_in_place(counter, &mut in_out[..len]);
} else {
unsafe {
Expand Down

0 comments on commit 165d0b9

Please sign in to comment.