Module: GPGME::KeyCommon

Included in:
Key, SubKey
Defined in:
lib/gpgme/key_common.rb

Instance Method Summary collapse

Instance Method Details

#capabilityObject

Array of capabilities for this key. It can contain any combination of :encrypt, :sign, :certify or :authenticate


17
18
19
20
21
22
23
24
# File 'lib/gpgme/key_common.rb', line 17

def capability
  caps = []
  caps << :encrypt if @can_encrypt
  caps << :sign if @can_sign
  caps << :certify if @can_certify
  caps << :authenticate if @can_authenticate
  caps
end

#secret?Boolean

Returns:

  • (Boolean)

39
40
41
# File 'lib/gpgme/key_common.rb', line 39

def secret?
  @secret == 1
end

#trustObject

Returns nil if the trust is valid. Returns one of :revoked, :expired, :disabled, :invalid


7
8
9
10
11
12
# File 'lib/gpgme/key_common.rb', line 7

def trust
  return :revoked if @revoked == 1
  return :expired if @expired == 1
  return :disabled if @disabled == 1
  return :invalid if @invalid == 1
end

#usable_for?(purposes) ⇒ Boolean

Checks if the key is capable of all of these actions. If empty array is passed then will return true.

Returns false if the keys trust has been invalidated.

Returns:

  • (Boolean)

31
32
33
34
35
36
37
# File 'lib/gpgme/key_common.rb', line 31

def usable_for?(purposes)
  unless purposes.kind_of? Array
    purposes = [purposes]
  end
  return false if [:revoked, :expired, :disabled, :invalid].include? trust
  return (purposes - capability).empty?
end