module

Crypto::Secret::Stateful

Inherits Crypto::Secret

Development guide:

  1. Create your initialize method and optionally allocate memory
  2. Create a finalize method to deallocate memory if necessary
  3. Fill in the missing abstract methods
  4. Optionally override any included methods (especially wipe_impl if the secret is not held in the provided slice)
  5. 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.

Instance methods

noaccess

Makes a region inaccessible. It cannot be read or written, but the data are preserved. WARNING: Not thread safe

Source
readonly

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

Source
readonly

Marks a region allocated using sodium_malloc() or sodium_allocarray() as read-only. WARNING: Not thread safe

Source
readwrite

Temporarily make buffer readwrite within the block returning to the prior state on exit. WARNING: Not thread safe unless this object is readwrite

Source
readwrite

Marks a region allocated as readable and writable WARNING: Not thread safe

Source
reset
Source
set_state(new_state : State)

WARNING: Not thread safe Kept public for .dup :nodoc:

Source
wipe

WARNING: Not thread safe

Source