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



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

def expired
  return false if @expires == 0
  @expires < Time.now.to_i
end

#expiresObject



14
15
16
# File 'lib/gpgme/sub_key.rb', line 14

def expires
  Time.at(@expires)
end

#inspectObject



38
39
40
41
42
43
44
45
46
47
# File 'lib/gpgme/sub_key.rb', line 38

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

#pubkey_algo_letterObject



34
35
36
# File 'lib/gpgme/sub_key.rb', line 34

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

#shaObject



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

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

#timestampObject



10
11
12
# File 'lib/gpgme/sub_key.rb', line 10

def timestamp
  Time.at(@timestamp)
end

#to_sObject



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

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