Class: GPGME::Signature

Inherits:
Object
  • Object
show all
Defined in:
lib/gpgme/signature.rb,
ext/gpgme/gpgme_n.c

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#fprObject (readonly) Also known as: fingerprint

Returns the value of attribute fpr.



5
6
7
# File 'lib/gpgme/signature.rb', line 5

def fpr
  @fpr
end

#notationsObject (readonly)

Returns the value of attribute notations.



5
6
7
# File 'lib/gpgme/signature.rb', line 5

def notations
  @notations
end

#pka_addressObject (readonly)

Returns the value of attribute pka_address.



7
8
9
# File 'lib/gpgme/signature.rb', line 7

def pka_address
  @pka_address
end

#pka_trustObject (readonly)

Returns the value of attribute pka_trust.



7
8
9
# File 'lib/gpgme/signature.rb', line 7

def pka_trust
  @pka_trust
end

#statusObject (readonly)

Returns the value of attribute status.



5
6
7
# File 'lib/gpgme/signature.rb', line 5

def status
  @status
end

#summaryObject (readonly)

Returns the value of attribute summary.



5
6
7
# File 'lib/gpgme/signature.rb', line 5

def summary
  @summary
end

#validityObject (readonly)

Returns the value of attribute validity.



6
7
8
# File 'lib/gpgme/signature.rb', line 6

def validity
  @validity
end

#validity_reasonObject (readonly)

Returns the value of attribute validity_reason.



6
7
8
# File 'lib/gpgme/signature.rb', line 6

def validity_reason
  @validity_reason
end

#wrong_key_usageObject (readonly)

Returns the value of attribute wrong_key_usage.



5
6
7
# File 'lib/gpgme/signature.rb', line 5

def wrong_key_usage
  @wrong_key_usage
end

Instance Method Details

#bad?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/gpgme/signature.rb', line 28

def bad?
  status_code == GPGME::GPG_ERR_BAD_SIGNATURE
end

#exp_timestampObject



64
65
66
# File 'lib/gpgme/signature.rb', line 64

def exp_timestamp
  Time.at(@exp_timestamp)
end

#expired_key?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/gpgme/signature.rb', line 20

def expired_key?
  status_code == GPGME::GPG_ERR_KEY_EXPIRED
end

#expired_signature?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/gpgme/signature.rb', line 16

def expired_signature?
  status_code == GPGME::GPG_ERR_SIG_EXPIRED
end

#fromObject



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/gpgme/signature.rb', line 40

def from
  @from ||= begin
    Ctx.new do |ctx|
      if from_key = ctx.get_key(fingerprint)
        "#{from_key.subkeys[0].keyid} #{from_key.uids[0].uid}"
      else
        fingerprint
      end
    end
  end
end

#keyObject



52
53
54
55
56
57
58
# File 'lib/gpgme/signature.rb', line 52

def key
  @key ||= begin
    Ctx.new do |ctx|
      @key = ctx.get_key(fingerprint)
    end
  end
end

#no_key?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/gpgme/signature.rb', line 32

def no_key?
  status_code == GPGME::GPG_ERR_NO_PUBKEY
end

#revoked_key?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/gpgme/signature.rb', line 24

def revoked_key?
  status_code == GPGME::GPG_ERR_CERT_REVOKED
end

#status_codeObject



36
37
38
# File 'lib/gpgme/signature.rb', line 36

def status_code
  GPGME::gpgme_err_code(status)
end

#timestampObject



60
61
62
# File 'lib/gpgme/signature.rb', line 60

def timestamp
  Time.at(@timestamp)
end

#to_sObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/gpgme/signature.rb', line 68

def to_s
  case status_code
  when GPGME::GPG_ERR_NO_ERROR
    "Good signature from #{from}"
  when GPGME::GPG_ERR_SIG_EXPIRED
    "Expired signature from #{from}"
  when GPGME::GPG_ERR_KEY_EXPIRED
    "Signature made from expired key #{from}"
  when GPGME::GPG_ERR_CERT_REVOKED
    "Signature made from revoked key #{from}"
  when GPGME::GPG_ERR_BAD_SIGNATURE
    "Bad signature from #{from}"
  when GPGME::GPG_ERR_NO_PUBKEY
    "No public key for #{from}"
  end
end

#valid?Boolean

Returns true if the signature is correct

Returns:

  • (Boolean)


12
13
14
# File 'lib/gpgme/signature.rb', line 12

def valid?
  status_code == GPGME::GPG_ERR_NO_ERROR
end