Skip to content

Commit

Permalink
Remvoe all getproperty funcs (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
inkydragon authored Apr 23, 2024
1 parent 4eee84f commit da351bb
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,6 @@ mutable struct SHA2_512_256_CTX <: SHA2_CTX
used::Bool
end

function Base.getproperty(ctx::SHA2_CTX, fieldname::Symbol)
if fieldname === :state
return getfield(ctx, :state)::Union{Vector{UInt32},Vector{UInt64}}
elseif fieldname === :bytecount
return getfield(ctx, :bytecount)::Union{UInt64,UInt128}
elseif fieldname === :buffer
return getfield(ctx, :buffer)::Vector{UInt8}
elseif fieldname === :used
return getfield(ctx, :used)::Bool
else
error("type ", typeof(ctx), " has no field ", fieldname)
end
end


# Typealias common nicknames for SHA2 family of functions
const SHA224_CTX = SHA2_224_CTX
Expand Down Expand Up @@ -111,22 +97,6 @@ mutable struct SHA3_512_CTX <: SHA3_CTX
used::Bool
end

function Base.getproperty(ctx::SHA3_CTX, fieldname::Symbol)
if fieldname === :state
return getfield(ctx, :state)::Vector{UInt64}
elseif fieldname === :bytecount
return getfield(ctx, :bytecount)::UInt128
elseif fieldname === :buffer
return getfield(ctx, :buffer)::Vector{UInt8}
elseif fieldname === :bc
return getfield(ctx, :bc)::Vector{UInt64}
elseif fieldname === :used
return getfield(ctx, :used)::Bool
else
error("type ", typeof(ctx), " has no field ", fieldname)
end
end

# Define constants via functions so as not to bloat context objects. Yay dispatch!

# Digest lengths for SHA1, SHA2 and SHA3. This is easy to figure out from the typename
Expand Down

0 comments on commit da351bb

Please sign in to comment.