Class: Rnp::Verify::Signature
- Inherits:
-
Object
- Object
- Rnp::Verify::Signature
- Defined in:
- lib/rnp/op/verify.rb
Overview
Class representing an individual signature.
Instance Attribute Summary collapse
-
#creation_time ⇒ Time
readonly
The creation time of the signature.
-
#expiration_time ⇒ Integer
readonly
The expiration (as the number of seconds after #creation_time).
-
#hash ⇒ String
readonly
The hash algorithm used for the signature.
-
#key ⇒ Key
readonly
The key that created the signature.
- #status ⇒ Object readonly private
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Check if this signature is expired.
-
#good? ⇒ Boolean
Check if this signature is good.
-
#initialize(ptr) ⇒ Signature
constructor
private
A new instance of Signature.
-
#valid? ⇒ Boolean
Check if this signature is valid.
Constructor Details
#initialize(ptr) ⇒ Signature
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 Signature.
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rnp/op/verify.rb', line 85 def initialize(ptr) # status @status = LibRnp.rnp_op_verify_signature_get_status(ptr) pptr = FFI::MemoryPointer.new(:pointer) # creation and expiration pcreation_time = FFI::MemoryPointer.new(:uint32) pexpiration_time = FFI::MemoryPointer.new(:uint32) Rnp.call_ffi(:rnp_op_verify_signature_get_times, ptr, pcreation_time, pexpiration_time) @creation_time = Time.at(pcreation_time.read(:uint32)) @expiration_time = pexpiration_time.read(:uint32) # hash Rnp.call_ffi(:rnp_op_verify_signature_get_hash, ptr, pptr) begin phash = pptr.read_pointer @hash = phash.read_string unless phash.null? ensure LibRnp.rnp_buffer_destroy(phash) end # key Rnp.call_ffi(:rnp_op_verify_signature_get_key, ptr, pptr) pkey = pptr.read_pointer @key = Key.new(pkey) unless pkey.null? end |
Instance Attribute Details
#creation_time ⇒ Time (readonly)
The creation time of the signature
79 80 81 |
# File 'lib/rnp/op/verify.rb', line 79 def creation_time @creation_time end |
#expiration_time ⇒ Integer (readonly)
The expiration (as the number of seconds after #creation_time)
82 83 84 |
# File 'lib/rnp/op/verify.rb', line 82 def expiration_time @expiration_time end |
#hash ⇒ String (readonly)
The hash algorithm used for the signature
73 74 75 |
# File 'lib/rnp/op/verify.rb', line 73 def hash @hash end |
#key ⇒ Key (readonly)
The key that created the signature
76 77 78 |
# File 'lib/rnp/op/verify.rb', line 76 def key @key end |
#status ⇒ Object (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.
70 71 72 |
# File 'lib/rnp/op/verify.rb', line 70 def status @status end |
Instance Method Details
#expired? ⇒ Boolean
Check if this signature is expired.
133 134 135 |
# File 'lib/rnp/op/verify.rb', line 133 def expired? @status == LibRnp::RNP_ERROR_SIGNATURE_EXPIRED end |
#good? ⇒ Boolean
Check if this signature is good.
116 117 118 |
# File 'lib/rnp/op/verify.rb', line 116 def good? @status == LibRnp::RNP_SUCCESS end |
#valid? ⇒ Boolean
A valid signature may also be expired.
Check if this signature is valid.
125 126 127 128 |
# File 'lib/rnp/op/verify.rb', line 125 def valid? @status == LibRnp::RNP_SUCCESS || @status == LibRnp::RNP_ERROR_SIGNATURE_EXPIRED end |