Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upUse little-endian encoding for Blake2 hashing on all architectures #38960
Conversation
rust-highfive
assigned
michaelwoerister
Jan 10, 2017
michaelwoerister
reviewed
Jan 10, 2017
|
Thanks for the fix! |
| if cfg!(target_endian = "big") { | ||
| for word in &mut m[..] { | ||
| *word = word.to_be(); | ||
| *word = u64::from_le(*word); |
This comment has been minimized.
This comment has been minimized.
| let m: &mut [u64; 16] = unsafe { | ||
| let b: &mut [u8; 128] = &mut ctx.b; | ||
| ::std::mem::transmute(b) | ||
| }; | ||
|
|
||
| // It's OK to modify the buffer in place since this is the last time | ||
| // this data will be accessed before it's overwritten |
This comment has been minimized.
This comment has been minimized.
| // Re-interpret the input buffer in the state as u64s | ||
| // Re-interpret the input buffer in the state as | ||
| // an array of big-endian u64s, converting them | ||
| // to machine endianness. |
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Jan 10, 2017
Contributor
Isn't it the other way round: We always make sure that this buffer is little-endian and now we are making sure to convert it to machine endianess?
arielb1
force-pushed the
arielb1:blake-endian
branch
from
2489791
to
bccd756
Jan 10, 2017
This comment has been minimized.
This comment has been minimized.
|
Fixed nits.
Blake2b is a standard bytestream hasher. It should not do anything weird with its Hasher impl. @bors r=michaelwoerister |
This comment has been minimized.
This comment has been minimized.
|
|
arielb1
added
the
beta-nominated
label
Jan 10, 2017
arielb1
changed the title
Use big-endian encoding for Blake2 hashing on all architectures
Use little-endian encoding for Blake2 hashing on all architectures
Jan 10, 2017
arielb1
force-pushed the
arielb1:blake-endian
branch
from
bccd756
to
a89475d
Jan 10, 2017
This comment has been minimized.
This comment has been minimized.
|
@bors r=michaelwoerister |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors rollup |
This comment has been minimized.
This comment has been minimized.
|
@bors rollup- |
This comment has been minimized.
This comment has been minimized.
|
@bors p=1
|
nikomatsakis
added
the
beta-accepted
label
Jan 11, 2017
This comment has been minimized.
This comment has been minimized.
|
Accepting for beta. Small patch, regression. cc @rust-lang/compiler |
nikomatsakis
referenced this pull request
Jan 11, 2017
Closed
ppc64/s390x `assertion failed: eps.windows(2).all(|w| w[0].cmp(self, &w[1]) != Ordering::Greater)` #38891
This comment has been minimized.
This comment has been minimized.
bors
added a commit
that referenced
this pull request
Jan 11, 2017
This comment has been minimized.
This comment has been minimized.
|
|
arielb1 commentedJan 10, 2017
•
edited
Like many hash functions, the blake2 hash is mathematically defined on
a sequence of 64-bit words. As Rust's hash interface operates on
sequences of octets, some encoding must be used to bridge that
difference.
The Blake2 RFC (RFC 7693) specifies that:
So use that encoding consistently.
Fixes #38891.
Beta-nominating since this is a regression since 1.15.
r? @michaelwoerister