Class: GPGME::SubKey
- Inherits:
-
Object
show all
- Includes:
- KeyCommon
- Defined in:
- lib/gpgme/sub_key.rb,
lib/gpgme/ffi/sub_key.rb
Constant Summary
collapse
- PUBKEY_ALGO_LETTERS =
{
PK_RSA => "R",
PK_ELG_E => "g",
PK_ELG => "G",
PK_DSA => "D"
}
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from KeyCommon
#capability, #secret?, #trust, #usable_for?
Instance Attribute Details
#fpr ⇒ Object
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
|
#keyid ⇒ Object
Returns the value of attribute keyid.
5
6
7
|
# File 'lib/gpgme/sub_key.rb', line 5
def keyid
@keyid
end
|
#length ⇒ Object
Returns the value of attribute length.
5
6
7
|
# File 'lib/gpgme/sub_key.rb', line 5
def length
@length
end
|
#pubkey_algo ⇒ Object
Returns the value of attribute pubkey_algo.
5
6
7
|
# File 'lib/gpgme/sub_key.rb', line 5
def pubkey_algo
@pubkey_algo
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
|
# File 'lib/gpgme/ffi/sub_key.rb', line 3
def self.new_from_struct(struct)
instance = allocate
instance.instance_exec do
@revoked = (struct[:flags] >> 0) & 1
@expired = (struct[:flags] >> 1) & 1
@disabled = (struct[:flags] >> 2) & 1
@invalid = (struct[:flags] >> 3) & 1
@can_encrypt = (struct[:flags] >> 4) & 1
@can_sign = (struct[:flags] >> 5) & 1
@can_certify = (struct[:flags] >> 6) & 1
@secret = (struct[:flags] >> 7) & 1
@can_authenticate = (struct[:flags] >> 8) & 1
@pubkey_algo = struct[:pubkey_algo]
@length = struct[:length]
@keyid = struct[:keyid]
@fpr = struct[:fpr]
@timestamp = struct[:timestamp]
@expires = struct[:expires]
end
instance
end
|
Instance Method Details
#expired ⇒ Object
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
|
#expires ⇒ Object
14
15
16
|
# File 'lib/gpgme/sub_key.rb', line 14
def expires
Time.at(@expires)
end
|
#inspect ⇒ Object
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_letter ⇒ Object
34
35
36
|
# File 'lib/gpgme/sub_key.rb', line 34
def pubkey_algo_letter
PUBKEY_ALGO_LETTERS[@pubkey_algo] || "?"
end
|
#sha ⇒ Object
23
24
25
|
# File 'lib/gpgme/sub_key.rb', line 23
def sha
(@fingerprint || @keyid)[-8 .. -1]
end
|
#timestamp ⇒ Object
10
11
12
|
# File 'lib/gpgme/sub_key.rb', line 10
def timestamp
Time.at(@timestamp)
end
|
#to_s ⇒ Object
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
|