Class: GPGME::Signature
- Inherits:
-
Object
- Object
- GPGME::Signature
- Defined in:
- lib/gpgme/signature.rb,
lib/gpgme/ffi/signature.rb
Instance Attribute Summary collapse
-
#fpr ⇒ Object
(also: #fingerprint)
readonly
Returns the value of attribute fpr.
-
#notations ⇒ Object
readonly
Returns the value of attribute notations.
-
#pka_address ⇒ Object
readonly
Returns the value of attribute pka_address.
-
#pka_trust ⇒ Object
readonly
Returns the value of attribute pka_trust.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#summary ⇒ Object
readonly
Returns the value of attribute summary.
-
#validity ⇒ Object
readonly
Returns the value of attribute validity.
-
#validity_reason ⇒ Object
readonly
Returns the value of attribute validity_reason.
-
#wrong_key_usage ⇒ Object
readonly
Returns the value of attribute wrong_key_usage.
Class Method Summary collapse
Instance Method Summary collapse
- #bad? ⇒ Boolean
- #exp_timestamp ⇒ Object
- #expired_key? ⇒ Boolean
- #expired_signature? ⇒ Boolean
- #from ⇒ Object
- #key ⇒ Object
- #no_key? ⇒ Boolean
- #revoked_key? ⇒ Boolean
- #status_code ⇒ Object
- #timestamp ⇒ Object
- #to_s ⇒ Object
-
#valid? ⇒ Boolean
Returns true if the signature is correct.
Instance Attribute Details
#fpr ⇒ Object (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 |
#notations ⇒ Object (readonly)
Returns the value of attribute notations.
5 6 7 |
# File 'lib/gpgme/signature.rb', line 5 def notations @notations end |
#pka_address ⇒ Object (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_trust ⇒ Object (readonly)
Returns the value of attribute pka_trust.
7 8 9 |
# File 'lib/gpgme/signature.rb', line 7 def pka_trust @pka_trust end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/gpgme/signature.rb', line 5 def status @status end |
#summary ⇒ Object (readonly)
Returns the value of attribute summary.
5 6 7 |
# File 'lib/gpgme/signature.rb', line 5 def summary @summary end |
#validity ⇒ Object (readonly)
Returns the value of attribute validity.
6 7 8 |
# File 'lib/gpgme/signature.rb', line 6 def validity @validity end |
#validity_reason ⇒ Object (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_usage ⇒ Object (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 |
Class Method Details
.new_from_struct(struct) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/gpgme/ffi/signature.rb', line 3 def self.new_from_struct(struct) instance = allocate instance.instance_exec do @summary = struct[:summary] @fpr = struct[:fpr] @status = struct[:status] @notations = [] pointer = struct[:notations] until pointer.null? notation = Library::SigNotation.new pointer @notations << SigNotation.new_from_struct(notation) pointer = notation[:next] end @timestamp = struct[:timestamp] @exp_timestamp = struct[:exp_timestamp] @wrong_key_usage = (struct[:flags] >> 0) & 1 @pka_trust = (struct[:flags] >> 1) & 3 @chain_model = (struct[:flags] >> 3) & 1 @validity = struct[:validity] @validity_reason = struct[:validity_reason] @pka_address = struct[:pka_address] end instance end |
Instance Method Details
#bad? ⇒ Boolean
28 29 30 |
# File 'lib/gpgme/signature.rb', line 28 def bad? status_code == GPGME::GPG_ERR_BAD_SIGNATURE end |
#exp_timestamp ⇒ Object
64 65 66 |
# File 'lib/gpgme/signature.rb', line 64 def Time.at(@exp_timestamp) end |
#expired_key? ⇒ 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
16 17 18 |
# File 'lib/gpgme/signature.rb', line 16 def expired_signature? status_code == GPGME::GPG_ERR_SIG_EXPIRED end |
#from ⇒ Object
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 |
#key ⇒ Object
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
32 33 34 |
# File 'lib/gpgme/signature.rb', line 32 def no_key? status_code == GPGME::GPG_ERR_NO_PUBKEY end |
#revoked_key? ⇒ Boolean
24 25 26 |
# File 'lib/gpgme/signature.rb', line 24 def revoked_key? status_code == GPGME::GPG_ERR_CERT_REVOKED end |
#status_code ⇒ Object
36 37 38 |
# File 'lib/gpgme/signature.rb', line 36 def status_code GPGME::gpgme_err_code(status) end |
#timestamp ⇒ Object
60 61 62 |
# File 'lib/gpgme/signature.rb', line 60 def Time.at(@timestamp) end |
#to_s ⇒ Object
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
12 13 14 |
# File 'lib/gpgme/signature.rb', line 12 def valid? status_code == GPGME::GPG_ERR_NO_ERROR end |