State checking fix
parent
8fb32f3d82
commit
d104b75296
|
@ -113,11 +113,11 @@ module Crypto::Secret
|
|||
# Makes a region allocated inaccessible depending on implementation. It cannot be read or written, but the data are preserved.
|
||||
abstract def noaccess : self
|
||||
|
||||
protected abstract def to_slice(& : Bytes -> Nil)
|
||||
protected abstract def to_slice(& : Bytes -> U) forall U
|
||||
abstract def bytesize : Int32
|
||||
|
||||
macro delegate_to_slice(to object)
|
||||
def to_slice(& : Bytes -> Nil)
|
||||
def to_slice(& : Bytes -> U) forall U
|
||||
yield {{object.id}}.to_slice
|
||||
end
|
||||
end
|
||||
|
|
|
@ -81,10 +81,12 @@ module Crypto::Secret
|
|||
return if @state == new_state
|
||||
|
||||
case new_state
|
||||
in State::Readwrite; readwrite
|
||||
in State::Readonly ; readonly
|
||||
in State::Noaccess ; noaccess
|
||||
in State::Wiped ; raise Error::KeyWiped.new
|
||||
when State::Readwrite; readwrite
|
||||
when State::Readonly ; readonly
|
||||
when State::Noaccess ; noaccess
|
||||
when State::Wiped ; raise Error::KeyWiped.new
|
||||
else
|
||||
raise Error::InvalidStateTransition.new("can't change to #{new_state}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue