Skip to content

Commit

Permalink
Broke out bytes_to_hex()
Browse files Browse the repository at this point in the history
  • Loading branch information
xvzcf committed Aug 1, 2023
1 parent 17fcf8e commit 6e907ae
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 18 deletions.
13 changes: 13 additions & 0 deletions src/jasmin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,16 @@ pub mod x25519;

#[cfg(any(target_os = "linux", target_os = "macos"))]
pub mod kyber_derand;

#[cfg(test)]
mod testing {
use std::fmt::Write;

pub(crate) fn bytes_to_hex(bytes: &[u8]) -> String {
let mut s = String::with_capacity(2 * bytes.len());
for byte in bytes {
write!(s, "{:02x}", byte).unwrap();
}
s
}
}
10 changes: 1 addition & 9 deletions src/jasmin/sha2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,7 @@ pub fn sha256(input: &[u8]) -> Result<Sha256Digest, &'static str> {
#[cfg(test)]
mod tests {
use super::*;
use std::fmt::Write;

fn bytes_to_hex(bytes: &[u8]) -> String {
let mut s = String::with_capacity(2 * bytes.len());
for byte in bytes {
write!(s, "{:02x}", byte).unwrap();
}
s
}
use crate::jasmin::testing::bytes_to_hex;

#[test]
fn test_hash() {
Expand Down
10 changes: 1 addition & 9 deletions src/jasmin/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,7 @@ pub(crate) mod mulx {
#[cfg(test)]
mod tests {
use super::*;
use std::fmt::Write;

fn bytes_to_hex(bytes: &[u8]) -> String {
let mut s = String::with_capacity(2 * bytes.len());
for byte in bytes {
write!(s, "{:02x}", byte).unwrap();
}
s
}
use crate::jasmin::testing::bytes_to_hex;

fn bmi2_and_adx_are_supported() -> bool {
std::arch::is_x86_feature_detected!("bmi2") && std::arch::is_x86_feature_detected!("adx")
Expand Down

0 comments on commit 6e907ae

Please sign in to comment.