Commit 27f7bfe1 authored by Jean-Luc Cooke's avatar Jean-Luc Cooke Committed by Hideaki Yoshifuji

[CRYPTO]: Help gcc optimize sha256/sha512 better.

parent 01477f1c
......@@ -34,12 +34,12 @@ struct sha256_ctx {
static inline u32 Ch(u32 x, u32 y, u32 z)
{
return ((x & y) ^ (~x & z));
return z ^ (x & (y ^ z));
}
static inline u32 Maj(u32 x, u32 y, u32 z)
{
return ((x & y) ^ (x & z) ^ (y & z));
return (x & y) | (z & (x | y));
}
static inline u32 RORu32(u32 x, u32 y)
......
......@@ -34,12 +34,12 @@ struct sha512_ctx {
static inline u64 Ch(u64 x, u64 y, u64 z)
{
return ((x & y) ^ (~x & z));
return z ^ (x & (y ^ z));
}
static inline u64 Maj(u64 x, u64 y, u64 z)
{
return ((x & y) ^ (x & z) ^ (y & z));
return (x & y) | (z & (x | y));
}
static inline u64 RORu64(u64 x, u64 y)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment