Class: GPGME::SubKey

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

Constant Summary collapse

PUBKEY_ALGO_LETTERS =
{
  PK_RSA    => "R",
  PK_ELG_E  => "g",
  PK_ELG    => "G",
  PK_DSA    => "D"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from KeyCommon

#capability, #secret?, #trust, #usable_for?

Instance Attribute Details

#fprObject (readonly) Also known as: fingerprint

Returns the value of attribute fpr.



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

def fpr
  @fpr
end

#keyidObject (readonly)

Returns the value of attribute keyid.



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

def keyid
  @keyid
end

#lengthObject (readonly)

Returns the value of attribute length.



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

def length
  @length
end

#pubkey_algoObject (readonly)

Returns the value of attribute pubkey_algo.



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

def pubkey_algo
  @pubkey_algo
end

Instance Method Details

#expiredObject



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

def expired
  expires? && @expires < Time.now.to_i
end

#expiresObject



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

def expires
  expires? ? Time.at(@expires) : nil
end

#expires?Boolean

Returns:

  • (Boolean)


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

def expires?
  @expires != 0
end

#inspectObject



47
48
49
50
51
52
53
54
55
56
# File 'lib/gpgme/sub_key.rb', line 47

def inspect
  sprintf("#<#{self.class} %s %4d%s/%s %s trust=%s, capability=%s>",
          secret? ? 'ssc' : 'sub',
          length,
          pubkey_algo_letter,
          (@fpr || @keyid)[-8 .. -1],
          timestamp.strftime('%Y-%m-%d'),
          trust.inspect,
          capability.inspect)
end

#pubkey_algo_letterObject



43
44
45
# File 'lib/gpgme/sub_key.rb', line 43

def pubkey_algo_letter
  PUBKEY_ALGO_LETTERS[@pubkey_algo] || "?"
end

#shaObject



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

def sha
  (@fpr || @keyid)[-8 .. -1]
end

#timestampObject



10
11
12
13
14
15
16
17
18
# File 'lib/gpgme/sub_key.rb', line 10

def timestamp
  case @timestamp
  when -1, 0
    # FIXME: add a special value for invalid timestamp, or throw an error
    return nil
  else
    return Time.at(@timestamp)
  end
end

#to_sObject



58
59
60
61
62
63
64
65
# File 'lib/gpgme/sub_key.rb', line 58

def to_s
  sprintf("%s   %4d%s/%s %s\n",
          secret? ? 'ssc' : 'sub',
          length,
          pubkey_algo_letter,
          (@fpr || @keyid)[-8 .. -1],
          timestamp.strftime('%Y-%m-%d'))
end