Class: Rnp::Verify

Inherits:
Object
  • Object
show all
Defined in:
lib/rnp/op/verify.rb

Overview

Verification operation

Defined Under Namespace

Classes: Signature

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(ptr) ⇒ Verify

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Verify.

Raises:


18
19
20
21
22
# File 'lib/rnp/op/verify.rb', line 18

def initialize(ptr)
  raise Rnp::Error, 'NULL pointer' if ptr.null?
  @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy))
  @signatures = nil
end

Instance Attribute Details

#ptrObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


15
16
17
# File 'lib/rnp/op/verify.rb', line 15

def ptr
  @ptr
end

Class Method Details

.destroy(ptr) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.


25
26
27
# File 'lib/rnp/op/verify.rb', line 25

def self.destroy(ptr)
  LibRnp.rnp_op_verify_destroy(ptr)
end

Instance Method Details

#executevoid

This method returns an undefined value.

Execute the operation.

This should only be called once.

Raises:


40
41
42
# File 'lib/rnp/op/verify.rb', line 40

def execute
  Rnp.call_ffi(:rnp_op_verify_execute, @ptr)
end

#good?Boolean

Check if all signatures are good.

Returns:

  • (Boolean)

    true if all signatures are valid and not expired.


47
48
49
50
# File 'lib/rnp/op/verify.rb', line 47

def good?
  sigs = signatures
  sigs.size && sigs.all?(&:good?)
end

#inspectObject


29
30
31
# File 'lib/rnp/op/verify.rb', line 29

def inspect
  Rnp.inspect_ptr(self)
end

#signaturesArray<Signature>

Get a list of the checked signatures.

Returns:


55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rnp/op/verify.rb', line 55

def signatures
  return @signatures unless @signatures.nil?
  @signatures = []
  pptr = FFI::MemoryPointer.new(:pointer)
  (0...signature_count).each do |i|
    Rnp.call_ffi(:rnp_op_verify_get_signature_at, @ptr, i, pptr)
    psig = pptr.read_pointer
    @signatures << Signature.new(psig)
  end
  @signatures
end