Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

remove unsafe keyword from from_bytes_unchecked #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Message {
///
/// There is no guarantee the provided bytes will be the product of a cryptographically secure
/// hash. Using insecure messages might compromise the security of the signature.
pub unsafe fn from_bytes_unchecked(bytes: [u8; Self::LEN]) -> Self {
pub fn from_bytes_unchecked(bytes: [u8; Self::LEN]) -> Self {
Salka1988 marked this conversation as resolved.
Show resolved Hide resolved
Self(bytes.into())
}

Expand Down Expand Up @@ -86,14 +86,14 @@ impl From<Message> for [u8; Message::LEN] {
impl From<&Hasher> for Message {
fn from(hasher: &Hasher) -> Self {
// Safety: `Hasher` is a cryptographic hash
unsafe { Self::from_bytes_unchecked(*hasher.digest()) }
Self::from_bytes_unchecked(*hasher.digest())
}
}

impl From<Hasher> for Message {
fn from(hasher: Hasher) -> Self {
// Safety: `Hasher` is a cryptographic hash
unsafe { Self::from_bytes_unchecked(*hasher.finalize()) }
Self::from_bytes_unchecked(*hasher.finalize())
}
}

Expand Down