rgpg 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/rgpg +3 -2
- data/lib/rgpg/gem_info.rb +2 -2
- data/lib/rgpg/gpg_helper.rb +11 -11
- metadata +9 -3
data/bin/rgpg
CHANGED
@@ -24,12 +24,13 @@ elsif ARGV[0] == '--encrypt'
|
|
24
24
|
Rgpg::GpgHelper.encrypt_file(public_key_file_name, input_file_name, output_file_name)
|
25
25
|
exit 0
|
26
26
|
elsif ARGV[0] == '--decrypt'
|
27
|
-
raise RuntimeError.new(DECRYPT_USAGE) unless ARGV.size == 5
|
27
|
+
raise RuntimeError.new(DECRYPT_USAGE) unless ARGV.size == 5 || ARGV.size == 6
|
28
28
|
public_key_file_name = ARGV[1]
|
29
29
|
private_key_file_name = ARGV[2]
|
30
30
|
input_file_name = ARGV[3]
|
31
31
|
output_file_name = ARGV[4]
|
32
|
-
|
32
|
+
ARGV.size == 6 ? passphrase = ARGV[5] : passphrase = nil
|
33
|
+
Rgpg::GpgHelper.decrypt_file(public_key_file_name, private_key_file_name, input_file_name, output_file_name, passphrase)
|
33
34
|
exit 0
|
34
35
|
else
|
35
36
|
$stderr.puts "Unsupported command \"#{ARGV[0]}\"" unless ARGV[0].nil? || ARGV[0].size == 0
|
data/lib/rgpg/gem_info.rb
CHANGED
data/lib/rgpg/gpg_helper.rb
CHANGED
@@ -39,22 +39,22 @@ module Rgpg
|
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
|
-
def self.decrypt_file(public_key_file_name, private_key_file_name, input_file_name, output_file_name)
|
42
|
+
def self.decrypt_file(public_key_file_name, private_key_file_name, input_file_name, output_file_name, passphrase=nil)
|
43
43
|
raise ArgumentError.new("Public key file \"#{public_key_file_name}\" does not exist") unless File.exist?(public_key_file_name)
|
44
44
|
raise ArgumentError.new("Private key file \"#{public_key_file_name}\" does not exist") unless File.exist?(private_key_file_name)
|
45
45
|
raise ArgumentError.new("Input file \"#{input_file_name}\" does not exist") unless File.exist?(input_file_name)
|
46
46
|
|
47
47
|
recipient = get_recipient(private_key_file_name)
|
48
48
|
with_temporary_decrypt_keyrings(public_key_file_name, private_key_file_name) do |keyring_file_name, secret_keyring_file_name|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
)
|
49
|
+
args = '--keyring', keyring_file_name,
|
50
|
+
'--secret-keyring', secret_keyring_file_name,
|
51
|
+
'--output', output_file_name,
|
52
|
+
'--decrypt',
|
53
|
+
'--yes',
|
54
|
+
'--trust-model', 'always',
|
55
|
+
input_file_name
|
56
|
+
args.unshift '--passphrase', passphrase unless passphrase.nil?
|
57
|
+
run_gpg_capture(*args)
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -126,7 +126,7 @@ module Rgpg
|
|
126
126
|
|
127
127
|
def self.get_recipient(key_file_name)
|
128
128
|
lines = run_gpg_capture(key_file_name)
|
129
|
-
result = lines.detect { |line| line =~ /^(pub|sec)\s+\d+D\/([0-9a-fA-F]{8}).+<(.+)>/ }
|
129
|
+
result = lines.detect { |line| line =~ /^(pub|sec)\s+\d+(D|R)\/([0-9a-fA-F]{8}).+<(.+)>/ }
|
130
130
|
raise RuntimeError.new('Invalid output') unless result
|
131
131
|
key_id = $2
|
132
132
|
recipient = $3
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rgpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-09 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Simple Ruby wrapper around "gpg" command for file encryption
|
15
15
|
email: rcook@rcook.org
|
@@ -36,15 +36,21 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
36
36
|
- - ! '>='
|
37
37
|
- !ruby/object:Gem::Version
|
38
38
|
version: '0'
|
39
|
+
segments:
|
40
|
+
- 0
|
41
|
+
hash: 4505311354280034693
|
39
42
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
43
|
none: false
|
41
44
|
requirements:
|
42
45
|
- - ! '>='
|
43
46
|
- !ruby/object:Gem::Version
|
44
47
|
version: '0'
|
48
|
+
segments:
|
49
|
+
- 0
|
50
|
+
hash: 4505311354280034693
|
45
51
|
requirements: []
|
46
52
|
rubyforge_project:
|
47
|
-
rubygems_version: 1.8.
|
53
|
+
rubygems_version: 1.8.24
|
48
54
|
signing_key:
|
49
55
|
specification_version: 3
|
50
56
|
summary: rgpg
|