class Sodium::SecretBuffer
Attributes
size[R]
to_ptr[R]
Public Class Methods
new(size)
click to toggle source
# File lib/sodium/secret_buffer.rb, line 13 def initialize(size) @size = Integer(size) @to_ptr = Sodium.malloc(@size) ObjectSpace.define_finalizer(@to_ptr, self.class.free(@to_ptr.address)) end
Private Class Methods
free(address)
click to toggle source
# File lib/sodium/secret_buffer.rb, line 42 def self.free(address) ->(obj_id) do ptr = FFI::Pointer.new(address) Sodium::Mprotect.readonly(ptr) Sodium.free(ptr) true end end
Public Instance Methods
free()
click to toggle source
# File lib/sodium/secret_buffer.rb, line 19 def free Sodium::Mprotect.readonly(@to_ptr) Sodium.free(@to_ptr) ObjectSpace.undefine_finalizer @to_ptr remove_instance_variable(:@size) remove_instance_variable(:@to_ptr) true end
noaccess()
click to toggle source
# File lib/sodium/secret_buffer.rb, line 28 def noaccess Sodium::Mprotect.noaccess(@to_ptr) end
readonly()
click to toggle source
# File lib/sodium/secret_buffer.rb, line 32 def readonly Sodium::Mprotect.readonly(@to_ptr) end
readwrite()
click to toggle source
# File lib/sodium/secret_buffer.rb, line 36 def readwrite Sodium::Mprotect.readwrite(@to_ptr) end