module Crypto::Secret::Stateful
Overview
Development guide:
- Create your initialize method and optionally allocate memory
- Create a finalize method to deallocate memory if necessary
- Fill in the missing abstract methods
- Optionally override any included methods (especially wipe_impl if the secret is not held in the provided slice)
- Provide and test a dup method or raise on dup if not possible
When state changes are required (such as using #noaccess) and the buffer is accessed from multiple threads wrap each #readonly/#readwrite block in a lock.
Included Modules
Defined in:
crypto-secret/lib.crcrypto-secret/stateful.cr
Instance Method Summary
- #dup
-
#noaccess : self
Makes a region inaccessible.
-
#readonly(&)
Temporarily make buffer readonly within the block returning to the prior state on exit.
-
#readonly : self
Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only.
-
#readwrite(&)
Temporarily make buffer readwrite within the block returning to the prior state on exit.
-
#readwrite : self
Marks a region allocated as readable and writable WARNING: Not thread safe
- #reset
-
#set_state(new_state : State)
WARNING Not thread safe Kept public for .dup :nodoc:
-
#wipe
WARNING Not thread safe
Instance methods inherited from module Crypto::Secret
==(other : Secret) : Bool==(other : Bytes) : Bool ==, bytesize : Int32 bytesize, copy_from(data : Bytes) : Nil copy_from, dup dup, finalize finalize, hexstring : String hexstring, inspect(io : IO) : Nil inspect, move_from(data : Bytes) : Nil move_from, noaccess : self noaccess, random : self random, readonly : self readonly, readwrite : self readwrite, reset reset, wipe
wipe(&) wipe
Instance Method Detail
Makes a region inaccessible. It cannot be read or written, but the data are preserved.
WARNING Not thread safe
Temporarily make buffer readonly within the block returning to the prior state on exit.
WARNING Not thread safe unless this object is readonly or readwrite
Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only.
WARNING Not thread safe
Temporarily make buffer readwrite within the block returning to the prior state on exit.
WARNING Not thread safe unless this object is readwrite
WARNING Not thread safe Kept public for .dup :nodoc: