diff --git a/src/base_functions.jl b/src/base_functions.jl index afa4482988989..f318144beab09 100644 --- a/src/base_functions.jl +++ b/src/base_functions.jl @@ -12,29 +12,29 @@ rrot(b,x,width) = ((x >> b) | (x << (width - b))) lrot(b,x,width) = ((x << b) | (x >> (width - b))) # Shift-right (used in SHA-256, SHA-384, and SHA-512): -R(b,x) = (x >> b) +R(b,x) = (x >> b) # 32-bit Rotate-right (used in SHA-256): -S32(b,x) = rrot(b,x,32) +S32(b,x) = rrot(b,x,32) # 64-bit Rotate-right (used in SHA-384 and SHA-512): -S64(b,x) = rrot(b,x,64) +S64(b,x) = rrot(b,x,64) # 64-bit Rotate-left (used in SHA3) -L64(b,x) = lrot(b,x,64) +L64(b,x) = lrot(b,x,64) # Two of six logical functions used in SHA-256, SHA-384, and SHA-512: Ch(x,y,z) = ((x & y) ⊻ (~x & z)) Maj(x,y,z) = ((x & y) ⊻ (x & z) ⊻ (y & z)) # Four of six logical functions used in SHA-256: -Sigma0_256(x) = (S32(2, UInt32(x)) ⊻ S32(13, UInt32(x)) ⊻ S32(22, UInt32(x))) -Sigma1_256(x) = (S32(6, UInt32(x)) ⊻ S32(11, UInt32(x)) ⊻ S32(25, UInt32(x))) -sigma0_256(x) = (S32(7, UInt32(x)) ⊻ S32(18, UInt32(x)) ⊻ R(3 , UInt32(x))) -sigma1_256(x) = (S32(17, UInt32(x)) ⊻ S32(19, UInt32(x)) ⊻ R(10, UInt32(x))) +Sigma0_256(x) = (S32(2, UInt32(x)) ⊻ S32(13, UInt32(x)) ⊻ S32(22, UInt32(x))) +Sigma1_256(x) = (S32(6, UInt32(x)) ⊻ S32(11, UInt32(x)) ⊻ S32(25, UInt32(x))) +sigma0_256(x) = (S32(7, UInt32(x)) ⊻ S32(18, UInt32(x)) ⊻ R(3 , UInt32(x))) +sigma1_256(x) = (S32(17, UInt32(x)) ⊻ S32(19, UInt32(x)) ⊻ R(10, UInt32(x))) # Four of six logical functions used in SHA-384 and SHA-512: -Sigma0_512(x) = (S64(28, UInt64(x)) ⊻ S64(34, UInt64(x)) ⊻ S64(39, UInt64(x))) -Sigma1_512(x) = (S64(14, UInt64(x)) ⊻ S64(18, UInt64(x)) ⊻ S64(41, UInt64(x))) -sigma0_512(x) = (S64( 1, UInt64(x)) ⊻ S64( 8, UInt64(x)) ⊻ R( 7, UInt64(x))) -sigma1_512(x) = (S64(19, UInt64(x)) ⊻ S64(61, UInt64(x)) ⊻ R( 6, UInt64(x))) +Sigma0_512(x) = (S64(28, UInt64(x)) ⊻ S64(34, UInt64(x)) ⊻ S64(39, UInt64(x))) +Sigma1_512(x) = (S64(14, UInt64(x)) ⊻ S64(18, UInt64(x)) ⊻ S64(41, UInt64(x))) +sigma0_512(x) = (S64( 1, UInt64(x)) ⊻ S64( 8, UInt64(x)) ⊻ R( 7, UInt64(x))) +sigma1_512(x) = (S64(19, UInt64(x)) ⊻ S64(61, UInt64(x)) ⊻ R( 6, UInt64(x))) # Let's be able to bswap arrays of these types as well bswap!(x::Vector{<:Integer}) = map!(bswap, x, x)