openpgp 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +1 -2
- data/CONTRIBUTORS +1 -0
- data/README +45 -13
- data/VERSION +1 -1
- data/lib/openpgp.rb +17 -3
- data/lib/openpgp/algorithm.rb +1 -0
- data/lib/openpgp/armor.rb +37 -9
- data/lib/openpgp/buffer.rb +57 -8
- data/lib/openpgp/cipher.rb +34 -3
- data/lib/openpgp/client/gnupg.rb +230 -20
- data/lib/openpgp/digest.rb +19 -0
- data/lib/openpgp/digest/md5.rb +1 -0
- data/lib/openpgp/digest/rmd160.rb +1 -0
- data/lib/openpgp/digest/sha1.rb +1 -0
- data/lib/openpgp/digest/sha2.rb +4 -0
- data/lib/openpgp/engine.rb +17 -0
- data/lib/openpgp/engine/gnupg.rb +58 -1
- data/lib/openpgp/engine/openssl.rb +13 -1
- data/lib/openpgp/message.rb +32 -2
- data/lib/openpgp/packet.rb +31 -11
- data/lib/openpgp/random.rb +14 -2
- data/lib/openpgp/s2k.rb +70 -2
- data/lib/openpgp/util.rb +14 -10
- data/lib/openpgp/version.rb +12 -4
- metadata +50 -20
- data/Rakefile +0 -5
data/lib/openpgp/client/gnupg.rb
CHANGED
@@ -24,6 +24,8 @@ module OpenPGP module Client
|
|
24
24
|
|
25
25
|
##
|
26
26
|
# Prints the program version and licensing information.
|
27
|
+
#
|
28
|
+
# @return [void]
|
27
29
|
def version
|
28
30
|
puts "gpg.rb (GnuPG compatible) #{VERSION}"
|
29
31
|
puts
|
@@ -36,17 +38,24 @@ module OpenPGP module Client
|
|
36
38
|
end
|
37
39
|
|
38
40
|
##
|
39
|
-
# Prints a usage message summarizing the most useful command-line
|
41
|
+
# Prints a usage message summarizing the most useful command-line
|
42
|
+
# options.
|
43
|
+
#
|
44
|
+
# @return [void]
|
40
45
|
def help() end
|
41
46
|
|
42
47
|
##
|
43
48
|
# Prints warranty information.
|
49
|
+
#
|
50
|
+
# @return [void]
|
44
51
|
def warranty
|
45
52
|
raise NotImplementedError
|
46
53
|
end
|
47
54
|
|
48
55
|
##
|
49
56
|
# Prints a list of all available options and commands.
|
57
|
+
#
|
58
|
+
# @return [void]
|
50
59
|
def dump_options
|
51
60
|
self.class.public_instance_methods(false).each do |command|
|
52
61
|
if command =~ /^[\w\d_]+$/
|
@@ -60,30 +69,41 @@ module OpenPGP module Client
|
|
60
69
|
|
61
70
|
##
|
62
71
|
# Makes a signature.
|
72
|
+
#
|
73
|
+
# @return [void]
|
63
74
|
def sign
|
64
75
|
raise NotImplementedError # TODO
|
65
76
|
end
|
66
77
|
|
67
78
|
##
|
68
79
|
# Makes a clear text signature.
|
80
|
+
#
|
81
|
+
# @return [void]
|
69
82
|
def clearsign
|
70
83
|
raise NotImplementedError # TODO
|
71
84
|
end
|
72
85
|
|
73
86
|
##
|
74
87
|
# Makes a detached signature.
|
88
|
+
#
|
89
|
+
# @return [void]
|
75
90
|
def detach_sign
|
76
91
|
raise NotImplementedError # TODO
|
77
92
|
end
|
78
93
|
|
79
94
|
##
|
80
95
|
# Encrypts data.
|
96
|
+
#
|
97
|
+
# @return [void]
|
81
98
|
def encrypt
|
82
99
|
raise NotImplementedError # TODO
|
83
100
|
end
|
84
101
|
|
85
102
|
##
|
86
103
|
# Encrypts with a symmetric cipher using a passphrase.
|
104
|
+
#
|
105
|
+
# @param [String, #to_s] file
|
106
|
+
# @return [void]
|
87
107
|
def symmetric(file)
|
88
108
|
print OpenPGP.encrypt(File.read(file), {
|
89
109
|
:symmetric => true,
|
@@ -96,6 +116,9 @@ module OpenPGP module Client
|
|
96
116
|
|
97
117
|
##
|
98
118
|
# Stores only (make a simple RFC1991 literal data packet).
|
119
|
+
#
|
120
|
+
# @param [String, #to_s] file
|
121
|
+
# @return [void]
|
99
122
|
def store(file)
|
100
123
|
Message.write(stdout) do |msg|
|
101
124
|
msg << Packet::LiteralData.new({
|
@@ -109,32 +132,47 @@ module OpenPGP module Client
|
|
109
132
|
|
110
133
|
##
|
111
134
|
# Decrypts data.
|
135
|
+
#
|
136
|
+
# @param [String, #to_s] file
|
137
|
+
# @return [void]
|
112
138
|
def decrypt(file)
|
113
139
|
raise NotImplementedError # TODO
|
114
140
|
end
|
115
141
|
|
116
142
|
##
|
117
143
|
# Verifies data.
|
144
|
+
#
|
145
|
+
# @param [String, #to_s] file
|
146
|
+
# @return [void]
|
118
147
|
def verify(file)
|
119
148
|
raise NotImplementedError # TODO
|
120
149
|
end
|
121
150
|
|
122
151
|
##
|
123
|
-
# Identical to
|
152
|
+
# Identical to `--multifile --verify`.
|
153
|
+
#
|
154
|
+
# @param [Array<String>] files
|
155
|
+
# @return [void]
|
124
156
|
def verify_files(*files)
|
125
157
|
options[:multifile] = true
|
126
158
|
files.each { |file| verify(file) }
|
127
159
|
end
|
128
160
|
|
129
161
|
##
|
130
|
-
# Identical to
|
162
|
+
# Identical to `--multifile --encrypt`.
|
163
|
+
#
|
164
|
+
# @param [Array<String>] files
|
165
|
+
# @return [void]
|
131
166
|
def encrypt_files(*files)
|
132
167
|
options[:multifile] = true
|
133
168
|
files.each { |file| encrypt(file) }
|
134
169
|
end
|
135
170
|
|
136
171
|
##
|
137
|
-
# Identical to
|
172
|
+
# Identical to `--multifile --decrypt`.
|
173
|
+
#
|
174
|
+
# @param [Array<String>] files
|
175
|
+
# @return [void]
|
138
176
|
def decrypt_files(*files)
|
139
177
|
options[:multifile] = true
|
140
178
|
files.each { |file| decrypt(file) }
|
@@ -142,12 +180,18 @@ module OpenPGP module Client
|
|
142
180
|
|
143
181
|
##
|
144
182
|
# Lists keys from the public keyrings.
|
183
|
+
#
|
184
|
+
# @param [Array<String>] keys
|
185
|
+
# @return [void]
|
145
186
|
def list_keys(*keys)
|
146
187
|
list_public_keys(*keys)
|
147
188
|
end
|
148
189
|
|
149
190
|
##
|
150
191
|
# Lists keys from the public keyrings.
|
192
|
+
#
|
193
|
+
# @param [Array<String>] keys
|
194
|
+
# @return [void]
|
151
195
|
def list_public_keys(*keys)
|
152
196
|
public_keyrings.each do |keyring_filename, keyring|
|
153
197
|
puts (keyring_filename = File.expand_path(keyring_filename))
|
@@ -168,6 +212,9 @@ module OpenPGP module Client
|
|
168
212
|
|
169
213
|
##
|
170
214
|
# Lists keys from the secret keyrings.
|
215
|
+
#
|
216
|
+
# @param [Array<String>] keys
|
217
|
+
# @return [void]
|
171
218
|
def list_secret_keys(*keys)
|
172
219
|
secret_keyrings.each do |keyring_filename, keyring|
|
173
220
|
puts (keyring_filename = File.expand_path(keyring_filename))
|
@@ -187,19 +234,26 @@ module OpenPGP module Client
|
|
187
234
|
end
|
188
235
|
|
189
236
|
##
|
190
|
-
# Same as
|
237
|
+
# Same as {#list_keys}, but the signatures are listed too.
|
238
|
+
#
|
239
|
+
# @return [void]
|
191
240
|
def list_sigs
|
192
241
|
raise NotImplementedError # TODO
|
193
242
|
end
|
194
243
|
|
195
244
|
##
|
196
|
-
# Same as
|
245
|
+
# Same as {#list_sigs}, but the signatures are verified.
|
246
|
+
#
|
247
|
+
# @return [void]
|
197
248
|
def check_sigs
|
198
249
|
raise NotImplementedError # TODO
|
199
250
|
end
|
200
251
|
|
201
252
|
##
|
202
253
|
# Lists all keys (or the specified ones) along with their fingerprints.
|
254
|
+
#
|
255
|
+
# @param [Array<String>] keys
|
256
|
+
# @return [void]
|
203
257
|
def fingerprint(*keys)
|
204
258
|
options[:fingerprint] = true
|
205
259
|
list_keys(*keys)
|
@@ -207,102 +261,149 @@ module OpenPGP module Client
|
|
207
261
|
|
208
262
|
##
|
209
263
|
# Lists only the sequence of packets.
|
264
|
+
#
|
265
|
+
# @return [void]
|
210
266
|
def list_packets
|
211
267
|
raise NotImplementedError # TODO
|
212
268
|
end
|
213
269
|
|
214
270
|
##
|
215
271
|
# Presents a menu to work with a smartcard.
|
272
|
+
#
|
273
|
+
# @return [void]
|
216
274
|
def card_edit
|
217
275
|
raise NotImplementedError # TODO
|
218
276
|
end
|
219
277
|
|
220
278
|
##
|
221
279
|
# Shows the content of the smart card.
|
280
|
+
#
|
281
|
+
# @return [void]
|
222
282
|
def card_status
|
223
283
|
raise NotImplementedError # TODO
|
224
284
|
end
|
225
285
|
|
226
286
|
##
|
227
287
|
# Presents a menu to allow changing the PIN of a smartcard.
|
288
|
+
#
|
289
|
+
# @return [void]
|
228
290
|
def change_pin
|
229
291
|
raise NotImplementedError # TODO
|
230
292
|
end
|
231
293
|
|
232
294
|
##
|
233
295
|
# Removes key from the public keyring.
|
296
|
+
#
|
297
|
+
# @param [String, #to_s] name
|
298
|
+
# @return [void]
|
234
299
|
def delete_key(name)
|
235
300
|
raise NotImplementedError # TODO
|
236
301
|
end
|
237
302
|
|
238
303
|
##
|
239
304
|
# Removes key from the secret and public keyring.
|
305
|
+
#
|
306
|
+
# @param [String, #to_s] name
|
307
|
+
# @return [void]
|
240
308
|
def delete_secret_key(name)
|
241
309
|
raise NotImplementedError # TODO
|
242
310
|
end
|
243
311
|
|
244
312
|
##
|
245
|
-
# Removes key from the secret and public keyring. If a secret key
|
313
|
+
# Removes key from the secret and public keyring. If a secret key
|
314
|
+
# exists, it will be removed first.
|
315
|
+
#
|
316
|
+
# @param [String, #to_s] name
|
317
|
+
# @return [void]
|
246
318
|
def delete_secret_and_public_key(name)
|
247
319
|
raise NotImplementedError # TODO
|
248
320
|
end
|
249
321
|
|
250
322
|
##
|
251
323
|
# Exports keys from the public keyring.
|
324
|
+
#
|
325
|
+
# @param [Array<String>] keys
|
326
|
+
# @return [void]
|
252
327
|
def export(*keys)
|
253
328
|
raise NotImplementedError # TODO
|
254
329
|
end
|
255
330
|
|
256
331
|
##
|
257
332
|
# Sends keys to a keyserver.
|
333
|
+
#
|
334
|
+
# @param [Array<String>] keys
|
335
|
+
# @return [void]
|
258
336
|
def send_keys(*keys)
|
259
337
|
raise NotImplementedError # TODO
|
260
338
|
end
|
261
339
|
|
262
340
|
##
|
263
341
|
# Exports the secret keys.
|
342
|
+
#
|
343
|
+
# @return [void]
|
264
344
|
def export_secret_keys
|
265
345
|
raise NotImplementedError # TODO
|
266
346
|
end
|
267
347
|
|
268
348
|
##
|
269
349
|
# Exports the secret subkeys.
|
350
|
+
#
|
351
|
+
# @return [void]
|
270
352
|
def export_secret_subkeys
|
271
353
|
raise NotImplementedError # TODO
|
272
354
|
end
|
273
355
|
|
274
356
|
##
|
275
|
-
# Imports/merges keys, adding the given keys to the keyring.
|
357
|
+
# Imports/merges keys, adding the given `keys` to the keyring.
|
358
|
+
#
|
359
|
+
# @param [Array<String>] keys
|
360
|
+
# @return [void]
|
276
361
|
def import(*keys)
|
277
362
|
raise NotImplementedError # TODO
|
278
363
|
end
|
279
364
|
|
280
365
|
##
|
281
|
-
# Alias for
|
366
|
+
# Alias for {#import}.
|
367
|
+
#
|
368
|
+
# @param [Array<String>] keys
|
369
|
+
# @return [void]
|
282
370
|
def fast_import(*keys)
|
283
371
|
import(*keys)
|
284
372
|
end
|
285
373
|
|
286
374
|
##
|
287
|
-
# Imports the keys with the given key IDs from a keyserver.
|
375
|
+
# Imports the `keys` with the given key IDs from a keyserver.
|
376
|
+
#
|
377
|
+
# @param [Array<String>] keys
|
378
|
+
# @return [void]
|
288
379
|
def recv_keys(*keys)
|
289
380
|
raise NotImplementedError # TODO
|
290
381
|
end
|
291
382
|
|
292
383
|
##
|
293
|
-
# Requests updates from a keyserver for keys that already exist on the
|
384
|
+
# Requests updates from a keyserver for keys that already exist on the
|
385
|
+
# local keyring.
|
386
|
+
#
|
387
|
+
# @param [Array<String>] keys
|
388
|
+
# @return [void]
|
294
389
|
def refresh_keys(*keys)
|
295
390
|
raise NotImplementedError # TODO
|
296
391
|
end
|
297
392
|
|
298
393
|
##
|
299
|
-
# Searches the keyserver for the given names
|
394
|
+
# Searches the keyserver for the given `names`.
|
395
|
+
#
|
396
|
+
# @param [Array<String>] names
|
397
|
+
# @return [void]
|
300
398
|
def search_keys(*names)
|
301
399
|
raise NotImplementedError # TODO
|
302
400
|
end
|
303
401
|
|
304
402
|
##
|
305
403
|
# Retrieves keys located at the specified URIs.
|
404
|
+
#
|
405
|
+
# @param [Array<String>] uris
|
406
|
+
# @return [void]
|
306
407
|
def fetch_keys(*uris)
|
307
408
|
require 'open-uri'
|
308
409
|
raise NotImplementedError # TODO
|
@@ -310,36 +411,53 @@ module OpenPGP module Client
|
|
310
411
|
|
311
412
|
##
|
312
413
|
# Does trust database maintenance.
|
414
|
+
#
|
415
|
+
# @return [void]
|
313
416
|
def update_trustdb
|
314
417
|
raise NotImplementedError # TODO
|
315
418
|
end
|
316
419
|
|
317
420
|
##
|
318
421
|
# Does trust database maintenance without user interaction.
|
422
|
+
#
|
423
|
+
# @return [void]
|
319
424
|
def check_trustdb
|
320
425
|
raise NotImplementedError # TODO
|
321
426
|
end
|
322
427
|
|
323
428
|
##
|
324
|
-
# Sends the ownertrust values to stdout
|
429
|
+
# Sends the ownertrust values to `stdout`.
|
430
|
+
#
|
431
|
+
# @return [void]
|
325
432
|
def export_ownertrust
|
326
433
|
raise NotImplementedError # TODO
|
327
434
|
end
|
328
435
|
|
329
436
|
##
|
330
|
-
# Updates the trustdb with the ownertrust values stored in
|
437
|
+
# Updates the trustdb with the ownertrust values stored in `files` or
|
438
|
+
# `stdin`.
|
439
|
+
#
|
440
|
+
# @param [Array<String>] files
|
441
|
+
# @return [void]
|
331
442
|
def import_ownertrust(*files)
|
332
443
|
raise NotImplementedError # TODO
|
333
444
|
end
|
334
445
|
|
335
446
|
##
|
336
447
|
# Creates signature caches in the keyring.
|
448
|
+
#
|
449
|
+
# @return [void]
|
337
450
|
def rebuild_keydb_caches
|
338
451
|
raise NotImplementedError # TODO
|
339
452
|
end
|
340
453
|
|
341
454
|
##
|
342
|
-
# Prints message digest of algorithm
|
455
|
+
# Prints message digest of algorithm `algo` for all given `files` or
|
456
|
+
# `stdin`.
|
457
|
+
#
|
458
|
+
# @param [String, #to_s] algo
|
459
|
+
# @param [Array<String>] files
|
460
|
+
# @return [void]
|
343
461
|
def print_md(algo, *files)
|
344
462
|
unless digest_algorithms.include?(algorithm = algo.to_s.upcase.to_sym)
|
345
463
|
abort "gpg: invalid hash algorithm `#{algo}'"
|
@@ -353,7 +471,11 @@ module OpenPGP module Client
|
|
353
471
|
end
|
354
472
|
|
355
473
|
##
|
356
|
-
# Prints message digests of all available algorithms for all given
|
474
|
+
# Prints message digests of all available algorithms for all given
|
475
|
+
# `files` or `stdin`.
|
476
|
+
#
|
477
|
+
# @param [Array<String>] files
|
478
|
+
# @return [void]
|
357
479
|
def print_mds(*files)
|
358
480
|
files.each do |file|
|
359
481
|
digest_algorithms.each do |algorithm|
|
@@ -366,7 +488,11 @@ module OpenPGP module Client
|
|
366
488
|
end
|
367
489
|
|
368
490
|
##
|
369
|
-
# Emits
|
491
|
+
# Emits `count` random bytes of the given quality level.
|
492
|
+
#
|
493
|
+
# @param [Integer, #to_i] level
|
494
|
+
# @param [Integer, #to_i] count
|
495
|
+
# @return [void]
|
370
496
|
def gen_random(level = 0, count = nil)
|
371
497
|
wrong_args "--gen-random 0|1|2 [count]" unless (0..2).include?(level)
|
372
498
|
|
@@ -384,6 +510,11 @@ module OpenPGP module Client
|
|
384
510
|
|
385
511
|
##
|
386
512
|
# Generates a prime number.
|
513
|
+
#
|
514
|
+
# @param [Integer, #to_i] mode
|
515
|
+
# @param [Integer, #to_i] bits
|
516
|
+
# @param [Integer, #to_i] qbits
|
517
|
+
# @return [void]
|
387
518
|
def gen_prime(mode, bits, qbits = nil)
|
388
519
|
case mode.to_i
|
389
520
|
when 1..4
|
@@ -395,6 +526,9 @@ module OpenPGP module Client
|
|
395
526
|
|
396
527
|
##
|
397
528
|
# Packs an arbitrary input into an OpenPGP ASCII armor.
|
529
|
+
#
|
530
|
+
# @param [String, #to_s] file
|
531
|
+
# @return [void]
|
398
532
|
def enarmor(file)
|
399
533
|
text = OpenPGP.enarmor(File.read(file), :armored_file, :comment => 'Use "gpg --dearmor" for unpacking', :line_length => 64)
|
400
534
|
puts text # FIXME
|
@@ -402,6 +536,9 @@ module OpenPGP module Client
|
|
402
536
|
|
403
537
|
##
|
404
538
|
# Unpacks an arbitrary input from an OpenPGP ASCII armor.
|
539
|
+
#
|
540
|
+
# @param [String, #to_s] file
|
541
|
+
# @return [void]
|
405
542
|
def dearmor(file)
|
406
543
|
data = OpenPGP.dearmor(File.read(file))
|
407
544
|
puts data # FIXME
|
@@ -411,46 +548,75 @@ module OpenPGP module Client
|
|
411
548
|
|
412
549
|
##
|
413
550
|
# Generates a new key pair.
|
551
|
+
#
|
552
|
+
# @return [void]
|
414
553
|
def gen_key
|
415
554
|
raise NotImplementedError # TODO
|
416
555
|
end
|
417
556
|
|
418
557
|
##
|
419
558
|
# Generates a revocation certificate for the complete key.
|
559
|
+
#
|
560
|
+
# @param [String, #to_s] name
|
561
|
+
# @return [void]
|
420
562
|
def gen_revoke(name)
|
421
563
|
raise NotImplementedError # TODO
|
422
564
|
end
|
423
565
|
|
424
566
|
##
|
425
567
|
# Generates a designated revocation certificate for a key.
|
568
|
+
#
|
569
|
+
# @param [String, #to_s] name
|
570
|
+
# @return [void]
|
426
571
|
def desig_revoke(name)
|
427
572
|
raise NotImplementedError # TODO
|
428
573
|
end
|
429
574
|
|
430
575
|
##
|
431
|
-
#
|
576
|
+
# Presents a menu which enables you to do most of the key management
|
577
|
+
# related tasks.
|
578
|
+
#
|
579
|
+
# @param [String, #to_s] key
|
580
|
+
# @return [void]
|
432
581
|
def edit_key(key)
|
433
582
|
raise NotImplementedError # TODO
|
434
583
|
end
|
435
584
|
|
436
585
|
##
|
437
586
|
# Signs a public key with your secret key.
|
587
|
+
#
|
588
|
+
# @param [String, #to_s] name
|
589
|
+
# @return [void]
|
438
590
|
def sign_key(name)
|
439
591
|
raise NotImplementedError # TODO
|
440
592
|
end
|
441
593
|
|
442
594
|
##
|
443
|
-
# Signs a public key with your secret key but marks it as
|
595
|
+
# Signs a public key with your secret key but marks it as
|
596
|
+
# non-exportable.
|
597
|
+
#
|
598
|
+
# @param [String, #to_s] name
|
599
|
+
# @return [void]
|
444
600
|
def lsign_key(name)
|
445
601
|
raise NotImplementedError # TODO
|
446
602
|
end
|
447
603
|
|
448
604
|
protected
|
449
605
|
|
606
|
+
##
|
607
|
+
# @return [IO]
|
450
608
|
def stdin() $stdin end
|
609
|
+
|
610
|
+
##
|
611
|
+
# @return [IO]
|
451
612
|
def stdout() $stdout end
|
613
|
+
|
614
|
+
##
|
615
|
+
# @return [IO]
|
452
616
|
def stderr() $stdout end
|
453
617
|
|
618
|
+
##
|
619
|
+
# @return [String]
|
454
620
|
def read_passphrase
|
455
621
|
if options[:passphrase]
|
456
622
|
options[:passphrase]
|
@@ -459,30 +625,47 @@ module OpenPGP module Client
|
|
459
625
|
end
|
460
626
|
end
|
461
627
|
|
628
|
+
##
|
629
|
+
# @return [Hash]
|
462
630
|
def public_keyrings
|
463
631
|
{public_keyring_file => keyring(public_keyring_file)} # FIXME
|
464
632
|
end
|
465
633
|
|
634
|
+
##
|
635
|
+
# @return [Hash]
|
466
636
|
def secret_keyrings
|
467
637
|
{secret_keyring_file => keyring(secret_keyring_file)} # FIXME
|
468
638
|
end
|
469
639
|
|
640
|
+
##
|
641
|
+
# @param [String, #to_s] file
|
642
|
+
# @return [Message]
|
470
643
|
def keyring(file)
|
471
644
|
OpenPGP::Message.parse(File.read(File.expand_path(file)))
|
472
645
|
end
|
473
646
|
|
647
|
+
##
|
648
|
+
# @return [String]
|
474
649
|
def public_keyring_file
|
475
650
|
File.join(options[:homedir], 'pubring.gpg')
|
476
651
|
end
|
477
652
|
|
653
|
+
##
|
654
|
+
# @return [String]
|
478
655
|
def secret_keyring_file
|
479
656
|
File.join(options[:homedir], 'secring.gpg')
|
480
657
|
end
|
481
658
|
|
659
|
+
##
|
660
|
+
# @return [String]
|
482
661
|
def trustdb_file
|
483
662
|
File.join(options[:homedir], 'trustdb.gpg')
|
484
663
|
end
|
485
664
|
|
665
|
+
##
|
666
|
+
# @param [Packet] packet
|
667
|
+
# @param [Symbol, #to_sym] type
|
668
|
+
# @return [void]
|
486
669
|
def print_key_listing(packet, type)
|
487
670
|
puts unless (is_sub_key = [:sub, :ssb].include?(type))
|
488
671
|
puts "#{type} #{format_keyspec(packet)} #{Time.at(packet.timestamp).strftime('%Y-%m-%d')}"
|
@@ -491,14 +674,24 @@ module OpenPGP module Client
|
|
491
674
|
end
|
492
675
|
end
|
493
676
|
|
677
|
+
##
|
678
|
+
# @param [Packet, #to_s] packet
|
679
|
+
# @return [void]
|
494
680
|
def print_uid_listing(packet)
|
495
681
|
puts "uid" + (' ' * 18) + packet.to_s
|
496
682
|
end
|
497
683
|
|
684
|
+
##
|
685
|
+
# @param [Packet] key
|
686
|
+
# @return [String]
|
498
687
|
def format_keyspec(key)
|
499
688
|
"____?/#{key.key_id}" # TODO
|
500
689
|
end
|
501
690
|
|
691
|
+
##
|
692
|
+
# @param [String] input
|
693
|
+
# @param [Integer] column
|
694
|
+
# @return [String]
|
502
695
|
def format_fingerprint(input, column = 0)
|
503
696
|
group_size = case input.size
|
504
697
|
when 32 then 2 # MD5
|
@@ -526,10 +719,15 @@ module OpenPGP module Client
|
|
526
719
|
return output
|
527
720
|
end
|
528
721
|
|
722
|
+
##
|
723
|
+
# @param [String, #to_s] file
|
724
|
+
# @return [void]
|
529
725
|
def parse_options_file(file)
|
530
726
|
# TODO
|
531
727
|
end
|
532
728
|
|
729
|
+
##
|
730
|
+
# @return [Symbol]
|
533
731
|
def cipher_algorithm
|
534
732
|
unless options[:cipher_algo]
|
535
733
|
Cipher::CAST5 # this is the default cipher
|
@@ -542,14 +740,20 @@ module OpenPGP module Client
|
|
542
740
|
end
|
543
741
|
end
|
544
742
|
|
743
|
+
##
|
744
|
+
# @return [Symbol]
|
545
745
|
def digest_algorithm
|
546
746
|
options[:digest_algo]
|
547
747
|
end
|
548
748
|
|
749
|
+
##
|
750
|
+
# @return [Symbol]
|
549
751
|
def compress_algorithm
|
550
752
|
options[:compress_algo]
|
551
753
|
end
|
552
754
|
|
755
|
+
##
|
756
|
+
# @return [Hash]
|
553
757
|
def cipher_algorithms
|
554
758
|
{
|
555
759
|
:"3DES" => Cipher::TripleDES,
|
@@ -562,10 +766,14 @@ module OpenPGP module Client
|
|
562
766
|
}
|
563
767
|
end
|
564
768
|
|
769
|
+
##
|
770
|
+
# @return [Array]
|
565
771
|
def digest_algorithms
|
566
772
|
[:MD5, :SHA1, :RIPEMD160, :SHA256, :SHA384, :SHA512]
|
567
773
|
end
|
568
774
|
|
775
|
+
##
|
776
|
+
# @return [Hash]
|
569
777
|
def compress_algorithms
|
570
778
|
{
|
571
779
|
:none => nil,
|
@@ -575,9 +783,11 @@ module OpenPGP module Client
|
|
575
783
|
}
|
576
784
|
end
|
577
785
|
|
786
|
+
##
|
787
|
+
# @param [String, #to_s] usage
|
788
|
+
# @return [void]
|
578
789
|
def wrong_args(usage)
|
579
790
|
abort "usage: gpg.rb [options] #{usage}"
|
580
791
|
end
|
581
792
|
end
|
582
|
-
|
583
793
|
end end
|