mirror of
https://github.com/BLAKE3-team/BLAKE3
synced 2024-05-09 07:36:06 +02:00
Compare commits
3 Commits
1210c26c2e
...
7c3e12aa5a
Author | SHA1 | Date | |
---|---|---|---|
Billy Batista | 7c3e12aa5a | ||
Javier Blazquez | 0816badf3a | ||
William Batista | ee310314cd |
|
@ -89,7 +89,7 @@ no_neon = []
|
|||
|
||||
[package.metadata.docs.rs]
|
||||
# Document the rayon/mmap methods and the Serialize/Deserialize/Zeroize impls on docs.rs.
|
||||
features = ["mmap", "rayon", "serde", "zeroize"]
|
||||
features = ["mmap", "rayon", "serde", "zeroize", "rkyv"]
|
||||
|
||||
[dependencies]
|
||||
arrayref = "0.3.5"
|
||||
|
@ -101,6 +101,7 @@ memmap2 = { version = "0.9", optional = true }
|
|||
rayon = { version = "1.2.1", optional = true }
|
||||
serde = { version = "1.0", default-features = false, features = ["derive"], optional = true }
|
||||
zeroize = { version = "1", default-features = false, features = ["zeroize_derive"], optional = true }
|
||||
rkyv = { version = "0.7", features = ["validation"], optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
hmac = "0.12.0"
|
||||
|
|
|
@ -4,9 +4,12 @@
|
|||
|
||||
#include "blake3_impl.h"
|
||||
|
||||
#if defined(IS_X86)
|
||||
#if defined(_MSC_VER)
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(IS_X86)
|
||||
#if defined(_MSC_VER)
|
||||
#include <intrin.h>
|
||||
#elif defined(__GNUC__)
|
||||
#include <immintrin.h>
|
||||
|
|
|
@ -28,7 +28,7 @@ enum blake3_flags {
|
|||
#define INLINE static inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#if (defined(__x86_64__) || defined(_M_X64)) && !defined(_M_ARM64EC)
|
||||
#define IS_X86
|
||||
#define IS_X86_64
|
||||
#endif
|
||||
|
@ -38,7 +38,7 @@ enum blake3_flags {
|
|||
#define IS_X86_32
|
||||
#endif
|
||||
|
||||
#if defined(__aarch64__) || defined(_M_ARM64)
|
||||
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
|
||||
#define IS_AARCH64
|
||||
#endif
|
||||
|
||||
|
|
44
src/lib.rs
44
src/lib.rs
|
@ -218,6 +218,11 @@ fn counter_high(counter: u64) -> u32 {
|
|||
/// [`FromStr`]: https://doc.rust-lang.org/std/str/trait.FromStr.html
|
||||
#[cfg_attr(feature = "zeroize", derive(zeroize::Zeroize))]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
#[cfg_attr(
|
||||
feature = "rkyv",
|
||||
derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize)
|
||||
)]
|
||||
#[cfg_attr(feature = "rkyv", archive(check_bytes))]
|
||||
#[derive(Clone, Copy, Hash)]
|
||||
pub struct Hash([u8; OUT_LEN]);
|
||||
|
||||
|
@ -355,6 +360,45 @@ impl PartialEq<[u8]> for Hash {
|
|||
|
||||
impl Eq for Hash {}
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
/// This implementation is constant-time.
|
||||
impl PartialEq for ArchivedHash {
|
||||
#[inline]
|
||||
fn eq(&self, other: &ArchivedHash) -> bool {
|
||||
constant_time_eq::constant_time_eq_32(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
/// This implementation is constant-time.
|
||||
impl PartialEq<[u8; OUT_LEN]> for ArchivedHash {
|
||||
#[inline]
|
||||
fn eq(&self, other: &[u8; OUT_LEN]) -> bool {
|
||||
constant_time_eq::constant_time_eq_32(&self.0, other)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
/// This implementation is constant-time if the target is 32 bytes long.
|
||||
impl PartialEq<[u8]> for ArchivedHash {
|
||||
#[inline]
|
||||
fn eq(&self, other: &[u8]) -> bool {
|
||||
constant_time_eq::constant_time_eq(&self.0, other)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
/// This implementation is constant-time if the target is 32 bytes long.
|
||||
impl PartialEq<Hash> for ArchivedHash {
|
||||
#[inline]
|
||||
fn eq(&self, other: &Hash) -> bool {
|
||||
constant_time_eq::constant_time_eq(&self.0, &other.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "rkyv")]
|
||||
impl Eq for ArchivedHash {}
|
||||
|
||||
impl fmt::Display for Hash {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
// Formatting field as `&str` to reduce code size since the `Debug`
|
||||
|
|
Loading…
Reference in New Issue