ChaCha: use slice::copy_within instead of core::ptr::copy.

Use less `unsafe`.
This commit is contained in:
Brian Smith 2020-05-05 16:09:19 -05:00
parent 8d4e283c16
commit 165d0b9b1f

View File

@ -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 {