Skip to content

Commit 4da176e

Browse files
authored
block-padding: remove unsafe code (#1222)
1 parent 014d8f0 commit 4da176e

File tree

3 files changed

+57
-57
lines changed

3 files changed

+57
-57
lines changed

Cargo.lock

Lines changed: 53 additions & 51 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

block-padding/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ categories = ["cryptography", "no-std"]
1313
readme = "README.md"
1414

1515
[dependencies]
16-
hybrid-array = "0.4"
16+
hybrid-array = "0.4.3"

block-padding/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg",
99
html_favicon_url = "https://raw.githubusercontent.com/RustCrypto/media/6ee8e381/logo.svg"
1010
)]
11+
#![deny(unsafe_code)]
1112
#![warn(missing_docs)]
1213

1314
pub use hybrid_array as array;
@@ -78,11 +79,8 @@ pub trait Padding {
7879
(None, PadType::Ambiguous) => 0,
7980
(None, PadType::Reversible) => return Err(UnpadError),
8081
};
81-
// SAFETY: `res_len` is always smaller or equal to `bs * blocks.len()`
82-
Ok(unsafe {
83-
let p = blocks.as_ptr() as *const u8;
84-
core::slice::from_raw_parts(p, res_len)
85-
})
82+
let data = Array::slice_as_flattened(blocks);
83+
Ok(&data[..res_len])
8684
}
8785
}
8886

0 commit comments

Comments
 (0)