Class: Rnp::Signature
- Inherits:
-
Object
- Object
- Rnp::Signature
- Defined in:
- lib/rnp/signature.rb
Overview
Class that represents a signature.
Instance Method Summary collapse
-
#creation_time ⇒ Time
The time this signature was created at.
-
#hash ⇒ String
The hash algorithm used in the 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).
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 |