readwrite/readonly/noaccess return self

This commit is contained in:
Didactic Drunk 2021-06-16 15:16:51 -07:00
parent 1cbb5c7b90
commit 70a1dfe2c4
2 changed files with 9 additions and 6 deletions

View File

@ -30,7 +30,7 @@ module Crypto::Secret
# Marks a region allocated as readable and writable # Marks a region allocated as readable and writable
# WARNING: Not thread safe # WARNING: Not thread safe
def readwrite def readwrite : self
raise Error::KeyWiped.new if @state == State::Wiped raise Error::KeyWiped.new if @state == State::Wiped
readwrite_impl readwrite_impl
@state = State::Readwrite @state = State::Readwrite
@ -49,7 +49,7 @@ module Crypto::Secret
# Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only. # Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only.
# WARNING: Not thread safe # WARNING: Not thread safe
def readonly def readonly : self
raise Error::KeyWiped.new if @state == State::Wiped raise Error::KeyWiped.new if @state == State::Wiped
readonly_impl readonly_impl
@state = State::Readonly @state = State::Readonly
@ -58,7 +58,7 @@ module Crypto::Secret
# Makes a region inaccessible. It cannot be read or written, but the data are preserved. # Makes a region inaccessible. It cannot be read or written, but the data are preserved.
# WARNING: Not thread safe # WARNING: Not thread safe
def noaccess def noaccess : self
raise Error::KeyWiped.new if @state == State::Wiped raise Error::KeyWiped.new if @state == State::Wiped
noaccess_impl noaccess_impl
@state = State::Noaccess @state = State::Noaccess

View File

@ -11,7 +11,8 @@ module Crypto::Secret::Stateless
end end
# Not thread safe # Not thread safe
def readwrite def readwrite : self
self
end end
# Yields a Slice that is readable and writable # Yields a Slice that is readable and writable
@ -26,7 +27,8 @@ module Crypto::Secret::Stateless
end end
# Not thread safe # Not thread safe
def readonly def readonly : self
self
end end
# Yields a Slice that is readable possibly writable depending on the prior protection level and underlying implementation # Yields a Slice that is readable possibly writable depending on the prior protection level and underlying implementation
@ -40,7 +42,8 @@ module Crypto::Secret::Stateless
end end
# Not thread safe # Not thread safe
def noaccess def noaccess : self
self
end end
# Not thread safe # Not thread safe