diff --git a/.travis.yml b/.travis.yml index 742ea16cd1f3c..7e81c450af4ca 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,6 @@ os: - linux - osx julia: - - 0.3 - 0.4 - 0.5 - nightly diff --git a/REQUIRE b/REQUIRE index 704369f897397..8e8c5c7842e3a 100644 --- a/REQUIRE +++ b/REQUIRE @@ -1,2 +1,2 @@ -julia 0.3 +julia 0.4 Compat 0.9.4 diff --git a/src/base_functions.jl b/src/base_functions.jl index 97a540bb3b800..b52c08931c51e 100644 --- a/src/base_functions.jl +++ b/src/base_functions.jl @@ -25,16 +25,16 @@ 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, @compat(UInt32(x))) ⊻ S32(13, @compat(UInt32(x))) ⊻ S32(22, @compat(UInt32(x)))) -Sigma1_256(x) = (S32(6, @compat(UInt32(x))) ⊻ S32(11, @compat(UInt32(x))) ⊻ S32(25, @compat(UInt32(x)))) -sigma0_256(x) = (S32(7, @compat(UInt32(x))) ⊻ S32(18, @compat(UInt32(x))) ⊻ R(3 , @compat(UInt32(x)))) -sigma1_256(x) = (S32(17, @compat(UInt32(x))) ⊻ S32(19, @compat(UInt32(x))) ⊻ R(10, @compat(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, @compat(UInt64(x))) ⊻ S64(34, @compat(UInt64(x))) ⊻ S64(39, @compat(UInt64(x)))) -Sigma1_512(x) = (S64(14, @compat(UInt64(x))) ⊻ S64(18, @compat(UInt64(x))) ⊻ S64(41, @compat(UInt64(x)))) -sigma0_512(x) = (S64( 1, @compat(UInt64(x))) ⊻ S64( 8, @compat(UInt64(x))) ⊻ R( 7, @compat(UInt64(x)))) -sigma1_512(x) = (S64(19, @compat(UInt64(x))) ⊻ S64(61, @compat(UInt64(x))) ⊻ R( 6, @compat(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!{T<:Integer}(x::Vector{T}) = map!(bswap, x) diff --git a/src/common.jl b/src/common.jl index 0cc58a783e67e..7107342243b84 100644 --- a/src/common.jl +++ b/src/common.jl @@ -2,7 +2,7 @@ # update! takes in variable-length data, buffering it into blocklen()-sized pieces, # calling transform!() when necessary to update the internal hash state. -function update!{T<:@compat(Union{SHA1_CTX,SHA2_CTX,SHA3_CTX})}(context::T, data::Array{UInt8,1}) +function update!{T<:Union{SHA1_CTX,SHA2_CTX,SHA3_CTX}}(context::T, data::Array{UInt8,1}) # We need to do all our arithmetic in the proper bitwidth UIntXXX = typeof(context.bytecount) @@ -33,7 +33,7 @@ end # Clear out any saved data in the buffer, append total bitlength, and return our precious hash! -function digest!{T<:@compat(Union{SHA1_CTX,SHA2_CTX})}(context::T) +function digest!{T<:Union{SHA1_CTX,SHA2_CTX}}(context::T) usedspace = context.bytecount % blocklen(T) # If we have anything in the buffer still, pad and transform that data if usedspace > 0 diff --git a/src/sha1.jl b/src/sha1.jl index 7b2a9bf7996e7..a3bdbf7a4fa29 100644 --- a/src/sha1.jl +++ b/src/sha1.jl @@ -1,14 +1,14 @@ # Nonlinear functions, in order to encourage inlining, these sadly are not an array of lambdas function Round0(b,c,d) - return @compat(UInt32((b & c) | (~b & d))) + return UInt32((b & c) | (~b & d)) end function Round1And3(b,c,d) - return @compat(UInt32(b ⊻ c ⊻ d)) + return UInt32(b ⊻ c ⊻ d) end function Round2(b,c,d) - return @compat(UInt32((b & c) | (b & d) | (c & d))) + return UInt32((b & c) | (b & d) | (c & d)) end function transform!(context::SHA1_CTX) @@ -43,7 +43,7 @@ function transform!(context::SHA1_CTX) # really kills performance and causes a huge number of allocations, so we make it easy on the compiler for i = 1:20 @inbounds begin - temp = @compat(UInt32(lrot(5, a, 32) + Round0(b,c,d) + e + context.W[i] + K1[1])) + temp = UInt32(lrot(5, a, 32) + Round0(b,c,d) + e + context.W[i] + K1[1]) e = d d = c c = lrot(30, b, 32) @@ -54,7 +54,7 @@ function transform!(context::SHA1_CTX) for i = 21:40 @inbounds begin - temp = @compat(UInt32(lrot(5, a, 32) + Round1And3(b,c,d) + e + context.W[i] + K1[2])) + temp = UInt32(lrot(5, a, 32) + Round1And3(b,c,d) + e + context.W[i] + K1[2]) e = d d = c c = lrot(30, b, 32) @@ -65,7 +65,7 @@ function transform!(context::SHA1_CTX) for i = 41:60 @inbounds begin - temp = @compat(UInt32(lrot(5, a, 32) + Round2(b,c,d) + e + context.W[i] + K1[3])) + temp = UInt32(lrot(5, a, 32) + Round2(b,c,d) + e + context.W[i] + K1[3]) e = d d = c c = lrot(30, b, 32) @@ -76,7 +76,7 @@ function transform!(context::SHA1_CTX) for i = 61:80 @inbounds begin - temp = @compat(UInt32(lrot(5, a, 32) + Round1And3(b,c,d) + e + context.W[i] + K1[4])) + temp = UInt32(lrot(5, a, 32) + Round1And3(b,c,d) + e + context.W[i] + K1[4]) e = d d = c c = lrot(30, b, 32) diff --git a/src/sha2.jl b/src/sha2.jl index 13fa5abb675cf..6b6a821205290 100644 --- a/src/sha2.jl +++ b/src/sha2.jl @@ -1,4 +1,4 @@ -function transform!{T<:@compat(Union{SHA2_224_CTX,SHA2_256_CTX})}(context::T) +function transform!{T<:Union{SHA2_224_CTX,SHA2_256_CTX}}(context::T) buffer = reinterpret(eltype(context.state), context.buffer) # Initialize registers with the previous intermediate values (our state) a = context.state[1] @@ -22,11 +22,11 @@ function transform!{T<:@compat(Union{SHA2_224_CTX,SHA2_256_CTX})}(context::T) h = g g = f f = e - e = @compat UInt32(d + T1) + e = UInt32(d + T1) d = c c = b b = a - a = @compat UInt32(T1 + T2) + a = UInt32(T1 + T2) end end @@ -45,11 +45,11 @@ function transform!{T<:@compat(Union{SHA2_224_CTX,SHA2_256_CTX})}(context::T) h = g g = f f = e - e = @compat UInt32(d + T1) + e = UInt32(d + T1) d = c c = b b = a - a = @compat UInt32(T1 + T2) + a = UInt32(T1 + T2) end end @@ -65,7 +65,7 @@ function transform!{T<:@compat(Union{SHA2_224_CTX,SHA2_256_CTX})}(context::T) end -function transform!(context::@compat(Union{SHA2_384_CTX,SHA2_512_CTX})) +function transform!(context::Union{SHA2_384_CTX,SHA2_512_CTX}) buffer = reinterpret(eltype(context.state), context.buffer) # Initialize registers with the prev. intermediate value a = context.state[1] diff --git a/src/types.jl b/src/types.jl index a116885fd3c43..0cfc61d487a9c 100644 --- a/src/types.jl +++ b/src/types.jl @@ -89,20 +89,20 @@ state_type(::Type{SHA2_384_CTX}) = UInt64 state_type(::Type{SHA2_512_CTX}) = UInt64 # blocklen is the number of bytes of data processed by the transform!() function at once -blocklen(::Type{SHA1_CTX}) = @compat UInt64(64) -blocklen(::Type{SHA2_224_CTX}) = @compat UInt64(64) -blocklen(::Type{SHA2_256_CTX}) = @compat UInt64(64) -blocklen(::Type{SHA2_384_CTX}) = @compat UInt64(128) -blocklen(::Type{SHA2_512_CTX}) = @compat UInt64(128) +blocklen(::Type{SHA1_CTX}) = UInt64(64) +blocklen(::Type{SHA2_224_CTX}) = UInt64(64) +blocklen(::Type{SHA2_256_CTX}) = UInt64(64) +blocklen(::Type{SHA2_384_CTX}) = UInt64(128) +blocklen(::Type{SHA2_512_CTX}) = UInt64(128) -blocklen(::Type{SHA3_224_CTX}) = @compat UInt64(25*8 - 2*digestlen(SHA3_224_CTX)) -blocklen(::Type{SHA3_256_CTX}) = @compat UInt64(25*8 - 2*digestlen(SHA3_256_CTX)) -blocklen(::Type{SHA3_384_CTX}) = @compat UInt64(25*8 - 2*digestlen(SHA3_384_CTX)) -blocklen(::Type{SHA3_512_CTX}) = @compat UInt64(25*8 - 2*digestlen(SHA3_512_CTX)) +blocklen(::Type{SHA3_224_CTX}) = UInt64(25*8 - 2*digestlen(SHA3_224_CTX)) +blocklen(::Type{SHA3_256_CTX}) = UInt64(25*8 - 2*digestlen(SHA3_256_CTX)) +blocklen(::Type{SHA3_384_CTX}) = UInt64(25*8 - 2*digestlen(SHA3_384_CTX)) +blocklen(::Type{SHA3_512_CTX}) = UInt64(25*8 - 2*digestlen(SHA3_512_CTX)) # short_blocklen is the size of a block minus the width of bytecount -short_blocklen{T<:@compat(Union{SHA1_CTX,SHA2_CTX})}(::Type{T}) = blocklen(T) - 2*sizeof(state_type(T)) +short_blocklen{T<:Union{SHA1_CTX,SHA2_CTX}}(::Type{T}) = blocklen(T) - 2*sizeof(state_type(T)) # Once the "blocklen" methods are defined, we can define our outer constructors for SHA types: SHA2_224_CTX() = SHA2_224_CTX(copy(SHA2_224_initial_hash_value), 0, zeros(UInt8, blocklen(SHA2_224_CTX))) diff --git a/test/runtests.jl b/test/runtests.jl index 4a929e815e111..0174639428d33 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -12,7 +12,7 @@ data = Any["", "test", lorem, file, so_many_as] # Descriptions of the data, the SHA functions we'll run on the data, etc... data_desc = ["the empty string", "the string \"test\"", "lorem ipsum", "0 file", "one million a's"] -sha_types = @compat Dict(sha1 => SHA.SHA1_CTX, +sha_types = Dict(sha1 => SHA.SHA1_CTX, sha2_224 => SHA.SHA2_224_CTX, sha2_256 => SHA.SHA2_256_CTX, sha2_384 => SHA.SHA2_384_CTX, sha2_512 => SHA.SHA2_512_CTX, sha3_224 => SHA.SHA3_224_CTX, sha3_256 => SHA.SHA3_256_CTX, sha3_384 => SHA.SHA3_384_CTX, sha3_512 => SHA.SHA3_512_CTX) sha_funcs = [sha1, @@ -25,7 +25,7 @@ shws = ["SHA1 hash state", "SHA2 224-bit hash state", "SHA2 256-bit hash state", "SHA2 384-bit hash state", "SHA2 512-bit hash state", "SHA3 224-bit hash state", "SHA3 256-bit hash state", "SHA3 384-bit hash state", "SHA3 512-bit hash state"] -answers = @compat Dict( +answers = Dict( sha1 => [ "da39a3ee5e6b4b0d3255bfef95601890afd80709", "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",