ruby_gpg2 0.1.0.pre.2 → 0.1.0.pre.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/ruby_gpg2/colon_output.rb +22 -0
- data/lib/ruby_gpg2/colon_record.rb +280 -0
- data/lib/ruby_gpg2/version.rb +1 -1
- data/lib/ruby_gpg2.rb +1 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9d840f9c3019500c8efe2d72f3a92076657d3084739380d8218ccc1eeadf24fe
|
4
|
+
data.tar.gz: 5c791b3c7ecb325cd46ccc64b3c6cb0eee59597602ca00af0f7e3bdbb3ef929b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cec3bc2eaaf7d77fbda1f15d0b2b9e17c3c6d96d7088349d4e3975219db3068ee41160d57e523ad65f4038ffd910c5f98258247bf5291783254f97d12367dc03
|
7
|
+
data.tar.gz: ee8b8a8b70d2899a94a53c6222fb808ce23a2f09137ee6ab8a6717f0495c823e254c2fdc473d9d783778b875cba00d2a7d05a3432e8f5b783aa154645f1117fc
|
data/Gemfile.lock
CHANGED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative './colon_record'
|
2
|
+
|
3
|
+
module RubyGPG2
|
4
|
+
class ColonOutput
|
5
|
+
def self.parse(records)
|
6
|
+
new(records
|
7
|
+
.strip
|
8
|
+
.split("\n")
|
9
|
+
.collect { |record| KeyListRecord.parse(record) })
|
10
|
+
end
|
11
|
+
|
12
|
+
include Enumerable
|
13
|
+
|
14
|
+
def initialize(records)
|
15
|
+
@records = records
|
16
|
+
end
|
17
|
+
|
18
|
+
def each(&block)
|
19
|
+
@records.each(&block)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,280 @@
|
|
1
|
+
module RubyGPG2
|
2
|
+
class ColonRecord
|
3
|
+
TYPES = {
|
4
|
+
'pub' => :public_key,
|
5
|
+
'crt' => :x509_certificate,
|
6
|
+
'crs' => :x509_certificate_and_private_key,
|
7
|
+
'sub' => :sub_key,
|
8
|
+
'sec' => :secret_key,
|
9
|
+
'ssb' => :secret_sub_key,
|
10
|
+
'uid' => :user_id,
|
11
|
+
'uat' => :user_attribute,
|
12
|
+
'sig' => :signature,
|
13
|
+
'rev' => :revocation_signature,
|
14
|
+
'rvs' => :standalone_revocation_signature,
|
15
|
+
'fpr' => :fingerprint,
|
16
|
+
'pkd' => :public_key_data,
|
17
|
+
'grp' => :key_grip,
|
18
|
+
'rvk' => :revocation_key,
|
19
|
+
'tfs' => :tofu_statistics,
|
20
|
+
'tru' => :trust_database_information,
|
21
|
+
'spk' => :signature_sub_packet,
|
22
|
+
'cfg' => :configuration_data
|
23
|
+
}
|
24
|
+
|
25
|
+
TRUST_MODELS = {
|
26
|
+
'0' => :classic,
|
27
|
+
'1' => :pgp
|
28
|
+
}
|
29
|
+
|
30
|
+
VALIDITIES = {
|
31
|
+
'o' => :unknown_new_key,
|
32
|
+
'i' => :invalid,
|
33
|
+
'd' => :disabled,
|
34
|
+
'r' => :revoked,
|
35
|
+
'e' => :expired,
|
36
|
+
'-' => :unknown,
|
37
|
+
'q' => :undefined,
|
38
|
+
'n' => :never,
|
39
|
+
'm' => :marginal,
|
40
|
+
'f' => :full,
|
41
|
+
'u' => :ultimate,
|
42
|
+
'w' => :well_known_private,
|
43
|
+
's' => :special
|
44
|
+
}
|
45
|
+
|
46
|
+
KEY_ALGORITHMS = {
|
47
|
+
'1' => :rsa_encrypt_or_sign,
|
48
|
+
'2' => :rsa_encrypt_only,
|
49
|
+
'3' => :rsa_sign_only,
|
50
|
+
'16' => :elgamal_encrypt_only,
|
51
|
+
'17' => :dsa,
|
52
|
+
'18' => :ecdh,
|
53
|
+
'19' => :ecdsa,
|
54
|
+
}
|
55
|
+
|
56
|
+
TRUSTS = {
|
57
|
+
'-' => :unknown,
|
58
|
+
'n' => :never,
|
59
|
+
'm' => :marginal,
|
60
|
+
'f' => :full,
|
61
|
+
'u' => :ultimate,
|
62
|
+
}
|
63
|
+
|
64
|
+
KEY_CAPABILITIES = {
|
65
|
+
'e' => :encrypt,
|
66
|
+
's' => :sign,
|
67
|
+
'c' => :certify,
|
68
|
+
'E' => :primary_encrypt,
|
69
|
+
'S' => :primary_sign,
|
70
|
+
'C' => :primary_certify
|
71
|
+
}
|
72
|
+
|
73
|
+
COMPLIANCE_MODES = {
|
74
|
+
'8' => :rfc_4880bis,
|
75
|
+
'23' => :de_vs
|
76
|
+
}
|
77
|
+
|
78
|
+
def self.parse(record)
|
79
|
+
fields = record.split(':', 22)
|
80
|
+
type = type(fields[0])
|
81
|
+
case type
|
82
|
+
when :trust_database_information
|
83
|
+
new(
|
84
|
+
raw: record,
|
85
|
+
type: type,
|
86
|
+
trust_model: trust_model(fields[2]),
|
87
|
+
creation_date: creation_date(fields[3]),
|
88
|
+
expiration_date: expiration_date(fields[4]),
|
89
|
+
new_key_signer_marginal_count:
|
90
|
+
new_key_signer_marginal_count(fields[5]),
|
91
|
+
new_key_signer_complete_count:
|
92
|
+
new_key_signer_complete_count(fields[6]),
|
93
|
+
maximum_certificate_chain_depth:
|
94
|
+
maximum_certificate_chain_depth(fields[7]))
|
95
|
+
else
|
96
|
+
new(
|
97
|
+
raw: record,
|
98
|
+
type: type,
|
99
|
+
validity: validity(fields[1]),
|
100
|
+
key_length: key_length(fields[2]),
|
101
|
+
key_algorithm: key_algorithm(fields[3]),
|
102
|
+
key_id: key_id(fields[4]),
|
103
|
+
creation_date: creation_date(fields[5]),
|
104
|
+
expiration_date: expiration_date(fields[6]),
|
105
|
+
user_id_hash: user_id_hash(type, fields[7]),
|
106
|
+
owner_trust: owner_trust(fields[8]),
|
107
|
+
fingerprint: fingerprint(type, fields[9]),
|
108
|
+
user_id: user_id(type, fields[9]),
|
109
|
+
signature_class: signature_class(fields[10]),
|
110
|
+
key_capabilities: key_capabilities(fields[11]),
|
111
|
+
compliance_modes: compliance_modes(fields[17]),
|
112
|
+
last_update: last_update(fields[18]),
|
113
|
+
origin: origin(fields[19]))
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
attr_reader(
|
118
|
+
:raw,
|
119
|
+
:type,
|
120
|
+
:trust_model,
|
121
|
+
:validity,
|
122
|
+
:key_length,
|
123
|
+
:key_algorithm,
|
124
|
+
:key_id,
|
125
|
+
:creation_date,
|
126
|
+
:expiration_date,
|
127
|
+
:user_id_hash,
|
128
|
+
:owner_trust,
|
129
|
+
:fingerprint,
|
130
|
+
:user_id,
|
131
|
+
:signature_class,
|
132
|
+
:key_capabilities,
|
133
|
+
:compliance_modes,
|
134
|
+
:last_update,
|
135
|
+
:origin,
|
136
|
+
:new_key_signer_marginal_count,
|
137
|
+
:new_key_signer_complete_count,
|
138
|
+
:maximum_certificate_chain_depth)
|
139
|
+
|
140
|
+
def initialize(opts)
|
141
|
+
@raw = opts[:raw]
|
142
|
+
@type = opts[:type]
|
143
|
+
@trust_model = opts[:trust_model]
|
144
|
+
@validity = opts[:validity]
|
145
|
+
@key_length = opts[:key_length]
|
146
|
+
@key_algorithm = opts[:key_algorithm]
|
147
|
+
@key_id = opts[:key_id]
|
148
|
+
@creation_date = opts[:creation_date]
|
149
|
+
@expiration_date = opts[:expiration_date]
|
150
|
+
@user_id_hash = opts[:user_id_hash]
|
151
|
+
@owner_trust = opts[:owner_trust]
|
152
|
+
@fingerprint = opts[:fingerprint]
|
153
|
+
@user_id = opts[:user_id]
|
154
|
+
@signature_class = opts[:signature_class]
|
155
|
+
@key_capabilities = opts[:key_capabilities]
|
156
|
+
@compliance_modes = opts[:compliance_modes]
|
157
|
+
@last_update = opts[:last_update]
|
158
|
+
@origin = opts[:origin]
|
159
|
+
@new_key_signer_marginal_count = opts[:new_key_signer_marginal_count]
|
160
|
+
@new_key_signer_complete_count = opts[:new_key_signer_complete_count]
|
161
|
+
@maximum_certificate_chain_depth = opts[:maximum_certificate_chain_depth]
|
162
|
+
end
|
163
|
+
|
164
|
+
def ==(other)
|
165
|
+
other.class == self.class && other.state == state
|
166
|
+
end
|
167
|
+
|
168
|
+
protected
|
169
|
+
|
170
|
+
def state
|
171
|
+
[
|
172
|
+
@raw,
|
173
|
+
@type,
|
174
|
+
@trust_model,
|
175
|
+
@validity,
|
176
|
+
@key_length,
|
177
|
+
@key_algorithm,
|
178
|
+
@key_id,
|
179
|
+
@creation_date,
|
180
|
+
@expiration_date,
|
181
|
+
@user_id_hash,
|
182
|
+
@owner_trust,
|
183
|
+
@fingerprint,
|
184
|
+
@user_id,
|
185
|
+
@signature_class,
|
186
|
+
@key_capabilities,
|
187
|
+
@compliance_modes,
|
188
|
+
@last_update,
|
189
|
+
@origin,
|
190
|
+
@new_key_signer_marginal_count,
|
191
|
+
@new_key_signer_complete_count,
|
192
|
+
@maximum_certificate_chain_depth
|
193
|
+
]
|
194
|
+
end
|
195
|
+
|
196
|
+
private
|
197
|
+
|
198
|
+
def self.type(value)
|
199
|
+
TYPES[value]
|
200
|
+
end
|
201
|
+
|
202
|
+
def self.trust_model(value)
|
203
|
+
TRUST_MODELS[value]
|
204
|
+
end
|
205
|
+
|
206
|
+
def self.validity(value)
|
207
|
+
VALIDITIES[value]
|
208
|
+
end
|
209
|
+
|
210
|
+
def self.key_length(value)
|
211
|
+
value =~ /\d+/ ? value.to_s.to_i : nil
|
212
|
+
end
|
213
|
+
|
214
|
+
def self.key_algorithm(value)
|
215
|
+
KEY_ALGORITHMS[value]
|
216
|
+
end
|
217
|
+
|
218
|
+
def self.key_id(value)
|
219
|
+
value =~ /.+/ ? value : nil
|
220
|
+
end
|
221
|
+
|
222
|
+
def self.creation_date(value)
|
223
|
+
value =~ /\d+/ ? DateTime.strptime(value, '%s') : nil
|
224
|
+
end
|
225
|
+
|
226
|
+
def self.expiration_date(value)
|
227
|
+
value =~ /\d+/ ? DateTime.strptime(value, '%s') : nil
|
228
|
+
end
|
229
|
+
|
230
|
+
def self.user_id_hash(type, value)
|
231
|
+
type == :user_id ? value : nil
|
232
|
+
end
|
233
|
+
|
234
|
+
def self.owner_trust(value)
|
235
|
+
TRUSTS[value]
|
236
|
+
end
|
237
|
+
|
238
|
+
def self.fingerprint(type, value)
|
239
|
+
type == :fingerprint ? value : nil
|
240
|
+
end
|
241
|
+
|
242
|
+
def self.user_id(type, value)
|
243
|
+
unless type == :fingerprint
|
244
|
+
value =~ /.+/ ? value : nil
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
def self.signature_class(value)
|
249
|
+
value =~ /.+/ ? value : nil
|
250
|
+
end
|
251
|
+
|
252
|
+
def self.key_capabilities(value)
|
253
|
+
value =~ /.+/ ? value.chars.map { |c| KEY_CAPABILITIES[c] } : nil
|
254
|
+
end
|
255
|
+
|
256
|
+
def self.compliance_modes(value)
|
257
|
+
value =~ /.+/ ? value.split(' ').map { |m| COMPLIANCE_MODES[m] } : nil
|
258
|
+
end
|
259
|
+
|
260
|
+
def self.last_update(value)
|
261
|
+
value =~ /\d+/ ? DateTime.strptime(value, '%s') : nil
|
262
|
+
end
|
263
|
+
|
264
|
+
def self.origin(value)
|
265
|
+
value
|
266
|
+
end
|
267
|
+
|
268
|
+
def self.new_key_signer_marginal_count(value)
|
269
|
+
value =~ /\d+/ ? value.to_i : nil
|
270
|
+
end
|
271
|
+
|
272
|
+
def self.new_key_signer_complete_count(value)
|
273
|
+
value =~ /\d+/ ? value.to_i : nil
|
274
|
+
end
|
275
|
+
|
276
|
+
def self.maximum_certificate_chain_depth(value)
|
277
|
+
value =~ /\d+/ ? value.to_i : nil
|
278
|
+
end
|
279
|
+
end
|
280
|
+
end
|
data/lib/ruby_gpg2/version.rb
CHANGED
data/lib/ruby_gpg2.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_gpg2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.pre.
|
4
|
+
version: 0.1.0.pre.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Toby Clemson
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-04-
|
11
|
+
date: 2020-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lino
|
@@ -159,6 +159,8 @@ files:
|
|
159
159
|
- config/secrets/rubygems/credentials
|
160
160
|
- go
|
161
161
|
- lib/ruby_gpg2.rb
|
162
|
+
- lib/ruby_gpg2/colon_output.rb
|
163
|
+
- lib/ruby_gpg2/colon_record.rb
|
162
164
|
- lib/ruby_gpg2/commands.rb
|
163
165
|
- lib/ruby_gpg2/commands/base.rb
|
164
166
|
- lib/ruby_gpg2/commands/generate_key.rb
|