Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remvoe all getproperty funcs #99

Merged
merged 1 commit into from
Apr 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading