Class: Rnp::Signature
- Inherits:
-
Object
- Object
- Rnp::Signature
- Defined in:
- lib/rnp/signature.rb
Overview
Class that represents a signature.
Instance Attribute Summary collapse
- #ptr ⇒ Object readonly private
Class Method Summary collapse
- .destroy(ptr) ⇒ Object private
Instance Method Summary collapse
-
#creation_time ⇒ Time
The time this signature was created at.
-
#hash ⇒ String
The hash algorithm used in the signature.
-
#initialize(ptr) ⇒ Signature
constructor
private
A new instance of Signature.
- #inspect ⇒ Object
-
#json(mpi: false, raw: false, grip: false) ⇒ Hash
JSON representation of this signature (as a Hash).
-
#keyid ⇒ String
The signer’s key id.
-
#signer ⇒ Key
The signer’s key.
-
#type ⇒ String
The type of the signing key (RSA, etc).
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.
18 19 20 21 |
# File 'lib/rnp/signature.rb', line 18 def initialize(ptr) raise Rnp::Error, 'NULL pointer' if ptr.null? @ptr = FFI::AutoPointer.new(ptr, self.class.method(:destroy)) end |
Instance Attribute Details
#ptr ⇒ 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.
15 16 17 |
# File 'lib/rnp/signature.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.
24 25 26 |
# File 'lib/rnp/signature.rb', line 24 def self.destroy(ptr) LibRnp.rnp_signature_handle_destroy(ptr) end |
Instance Method Details
#creation_time ⇒ Time
The time this signature was created at.
56 57 58 59 60 |
# File 'lib/rnp/signature.rb', line 56 def creation_time pcreation = FFI::MemoryPointer.new(:uint32) Rnp.call_ffi(:rnp_signature_get_creation, @ptr, pcreation) Time.at(pcreation.read(:uint32)) end |
#hash ⇒ String
The hash algorithm used in the signature.
42 43 44 |
# File 'lib/rnp/signature.rb', line 42 def hash string_property(:rnp_signature_get_hash_alg) end |
#inspect ⇒ Object
28 29 30 |
# File 'lib/rnp/signature.rb', line 28 def inspect Rnp.inspect_ptr(self) end |
#json(mpi: false, raw: false, grip: false) ⇒ Hash
JSON representation of this signature (as a Hash).
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rnp/signature.rb', line 78 def json(mpi: false, raw: false, grip: false) flags = 0 flags |= LibRnp::RNP_JSON_DUMP_MPI if mpi flags |= LibRnp::RNP_JSON_DUMP_RAW if raw flags |= LibRnp::RNP_JSON_DUMP_GRIP if grip pptr = FFI::MemoryPointer.new(:pointer) Rnp.call_ffi(:rnp_signature_packet_to_json, @ptr, flags, pptr) begin pvalue = pptr.read_pointer JSON.parse(pvalue.read_string) unless pvalue.null? ensure LibRnp.rnp_buffer_destroy(pvalue) end end |
#keyid ⇒ String
The signer’s key id.
49 50 51 |
# File 'lib/rnp/signature.rb', line 49 def keyid string_property(:rnp_signature_get_keyid) end |
#signer ⇒ Key
The signer’s key.
65 66 67 68 69 70 |
# File 'lib/rnp/signature.rb', line 65 def signer pptr = FFI::MemoryPointer.new(:pointer) Rnp.call_ffi(:rnp_signature_get_signer, @ptr, pptr) pkey = pptr.read_pointer Key.new(pkey) unless pkey.null? end |
#type ⇒ String
The type of the signing key (RSA, etc).
35 36 37 |
# File 'lib/rnp/signature.rb', line 35 def type string_property(:rnp_signature_get_alg) end |