Class: Rnp::Signature

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

Overview

Class that represents a signature.

Instance Method Summary collapse

Instance Method Details

#creation_timeTime

The time this signature was created at.

Returns:

  • (Time)


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

#hashString

The hash algorithm used in the signature.

Returns:

  • (String)


42
43
44
# File 'lib/rnp/signature.rb', line 42

def hash
  string_property(:rnp_signature_get_hash_alg)
end

#inspectObject



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).

Parameters:

  • mpi (Boolean) (defaults to: false)

    if true then MPIs will be included

  • raw (Boolean) (defaults to: false)

    if true then raw data will be included

  • grip (Boolean) (defaults to: false)

    if true then grips will be included

Returns:

  • (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

#keyidString

The signer’s key id.

Returns:

  • (String)


49
50
51
# File 'lib/rnp/signature.rb', line 49

def keyid
  string_property(:rnp_signature_get_keyid)
end

#signerKey

The signer’s key.

Returns:



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

#typeString

The type of the signing key (RSA, etc).

Returns:

  • (String)


35
36
37
# File 'lib/rnp/signature.rb', line 35

def type
  string_property(:rnp_signature_get_alg)
end