gpgme 2.0.18 → 2.0.22
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/gpgme/extconf.rb +11 -10
- data/ext/gpgme/gpgme_n.c +457 -454
- data/lib/gpgme/crypto.rb +1 -1
- data/lib/gpgme/ctx.rb +3 -2
- data/lib/gpgme/data.rb +10 -2
- data/lib/gpgme/engine.rb +1 -1
- data/lib/gpgme/key.rb +13 -1
- data/lib/gpgme/version.rb +1 -1
- data/ports/archives/gpgme-1.18.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-2.5.5.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.46.tar.bz2 +0 -0
- data/test/crypto_test.rb +7 -16
- data/test/ctx_test.rb +25 -74
- data/test/files/testkey_pub_invalid.gpg +52 -0
- data/test/key_test.rb +20 -4
- data/test/pinentry +22 -0
- data/test/sub_key_test.rb +5 -2
- data/test/support/resources.rb +30 -0
- data/test/test_helper.rb +6 -0
- metadata +18 -20
- data/ports/archives/gpgme-1.12.0.tar.bz2 +0 -0
- data/ports/archives/gpgme-1.9.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-2.4.3.tar.bz2 +0 -0
- data/ports/archives/libassuan-2.5.1.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.27.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.32.tar.bz2 +0 -0
data/lib/gpgme/crypto.rb
CHANGED
@@ -129,7 +129,7 @@ module GPGME
|
|
129
129
|
# * +:output+ if specified, it will write the output into it. It will
|
130
130
|
# me converted to a {GPGME::Data} object, so it can also be a file,
|
131
131
|
# for example.
|
132
|
-
# * If the file was encrypted with
|
132
|
+
# * If the file was encrypted with symmetric encryption, must provide
|
133
133
|
# a :password option.
|
134
134
|
# * Any other option accepted by {GPGME::Ctx.new}
|
135
135
|
#
|
data/lib/gpgme/ctx.rb
CHANGED
@@ -370,8 +370,8 @@ module GPGME
|
|
370
370
|
#
|
371
371
|
# If passed, the key will be exported to +keydata+, which must be
|
372
372
|
# a {GPGME::Data} object.
|
373
|
-
def export_keys(recipients, keydata = Data.new)
|
374
|
-
err = GPGME::gpgme_op_export(self, recipients,
|
373
|
+
def export_keys(recipients, keydata = Data.new, mode=0)
|
374
|
+
err = GPGME::gpgme_op_export(self, recipients, mode, keydata)
|
375
375
|
exc = GPGME::error_to_exception(err)
|
376
376
|
raise exc if exc
|
377
377
|
keydata
|
@@ -517,6 +517,7 @@ keylist_mode=#{KEYLIST_MODE_NAMES[keylist_mode]}>"
|
|
517
517
|
|
518
518
|
def self.pass_function(pass, uid_hint, passphrase_info, prev_was_bad, fd)
|
519
519
|
io = IO.for_fd(fd, 'w')
|
520
|
+
io.autoclose = false
|
520
521
|
io.puts pass
|
521
522
|
io.flush
|
522
523
|
end
|
data/lib/gpgme/data.rb
CHANGED
@@ -165,8 +165,16 @@ module GPGME
|
|
165
165
|
end
|
166
166
|
|
167
167
|
##
|
168
|
-
# Sets the encoding for this buffer. Accepts only values
|
169
|
-
#
|
168
|
+
# Sets the encoding for this buffer. Accepts only integer values 0 to 7:
|
169
|
+
#
|
170
|
+
# 0 = GPGME_DATA_ENCODING_NONE (Not specified)
|
171
|
+
# 1 = GPGME_DATA_ENCODING_BINARY
|
172
|
+
# 2 = GPGME_DATA_ENCODING_BASE64
|
173
|
+
# 3 = GPGME_DATA_ENCODING_ARMOR (Either PEM or OpenPGP Armor)
|
174
|
+
# 4 = GPGME_DATA_ENCODING_URL (LF delimited URL list)
|
175
|
+
# 5 = GPGME_DATA_ENCODING_URLESC (Ditto, but percent escaped)
|
176
|
+
# 6 = GPGME_DATA_ENCODING_URL0 (Nul delimited URL list)
|
177
|
+
# 7 = GPGME_DATA_ENCODING_MIME (Data is a MIME part)
|
170
178
|
#
|
171
179
|
# @raise [GPGME::Error::InvalidValue] if the value isn't accepted.
|
172
180
|
def encoding=(encoding)
|
data/lib/gpgme/engine.rb
CHANGED
@@ -52,7 +52,7 @@ module GPGME
|
|
52
52
|
# The directory name of the configuration directory.
|
53
53
|
#
|
54
54
|
# @example
|
55
|
-
# GPGME::Engine.
|
55
|
+
# GPGME::Engine.set_info(GPGME::PROTOCOL_OpenPGP, '/usr/local/bin/gpg', home_dir)
|
56
56
|
#
|
57
57
|
def set_info(proto, file_name, home_dir)
|
58
58
|
err = GPGME::gpgme_set_engine_info(proto, file_name, home_dir)
|
data/lib/gpgme/key.rb
CHANGED
@@ -81,6 +81,7 @@ module GPGME
|
|
81
81
|
# @param [Hash] options
|
82
82
|
# * +:output+ specify where to write the key to. It will be converted to
|
83
83
|
# a {GPGME::Data}, so it could be a file, for example.
|
84
|
+
# * +:minimal+ set to true to let the export mode be 'minimal'.
|
84
85
|
# * Any other option accepted by {GPGME::Ctx.new}
|
85
86
|
#
|
86
87
|
# @return [GPGME::Data] the exported key.
|
@@ -94,9 +95,14 @@ module GPGME
|
|
94
95
|
#
|
95
96
|
def export(pattern, options = {})
|
96
97
|
output = Data.new(options[:output])
|
98
|
+
if options.delete(:minimal) == true
|
99
|
+
export_mode = 4
|
100
|
+
else
|
101
|
+
export_mode = 0
|
102
|
+
end
|
97
103
|
|
98
104
|
GPGME::Ctx.new(options) do |ctx|
|
99
|
-
ctx.export_keys(pattern, output)
|
105
|
+
ctx.export_keys(pattern, output, export_mode)
|
100
106
|
end
|
101
107
|
|
102
108
|
output.seek(0)
|
@@ -122,6 +128,12 @@ module GPGME
|
|
122
128
|
ctx.import_result
|
123
129
|
end
|
124
130
|
end
|
131
|
+
|
132
|
+
# Checks if a key is valid
|
133
|
+
def valid?(key)
|
134
|
+
GPGME::Key.import(key).considered == 1
|
135
|
+
end
|
136
|
+
|
125
137
|
end
|
126
138
|
|
127
139
|
##
|
data/lib/gpgme/version.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/test/crypto_test.rb
CHANGED
@@ -128,10 +128,13 @@ describe GPGME::Crypto do
|
|
128
128
|
end
|
129
129
|
|
130
130
|
describe "symmetric encryption/decryption" do
|
131
|
+
before do
|
132
|
+
info = GPGME::Engine.info.first
|
133
|
+
skip if /\A2\.[01]|\A1\./ === info.version
|
134
|
+
end
|
135
|
+
|
131
136
|
it "requires a password to encrypt" do
|
132
|
-
|
133
|
-
GPGME::Crypto.new.encrypt TEXT[:plain], :symmetric => true
|
134
|
-
end
|
137
|
+
GPGME::Crypto.new.encrypt TEXT[:plain], :symmetric => true
|
135
138
|
end
|
136
139
|
|
137
140
|
it "requires a password to decrypt" do
|
@@ -139,9 +142,7 @@ describe GPGME::Crypto do
|
|
139
142
|
encrypted_data = crypto.encrypt TEXT[:plain],
|
140
143
|
:symmetric => true, :password => "gpgme"
|
141
144
|
|
142
|
-
|
143
|
-
crypto.decrypt encrypted_data
|
144
|
-
end
|
145
|
+
crypto.decrypt encrypted_data
|
145
146
|
end
|
146
147
|
|
147
148
|
it "can encrypt and decrypt with the same password" do
|
@@ -151,16 +152,6 @@ describe GPGME::Crypto do
|
|
151
152
|
|
152
153
|
assert_equal "Hi there", plain.read
|
153
154
|
end
|
154
|
-
|
155
|
-
it "but breaks with different ones" do
|
156
|
-
crypto = GPGME::Crypto.new
|
157
|
-
encrypted_data = crypto.encrypt TEXT[:plain],
|
158
|
-
:symmetric => true, :password => "gpgme"
|
159
|
-
|
160
|
-
assert_raises GPGME::Error::DecryptFailed do
|
161
|
-
crypto.decrypt encrypted_data, :password => "wrong one"
|
162
|
-
end
|
163
|
-
end
|
164
155
|
end
|
165
156
|
|
166
157
|
describe :decrypt do
|
data/test/ctx_test.rb
CHANGED
@@ -27,6 +27,11 @@ describe GPGME::Ctx do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
describe :new do
|
30
|
+
before do
|
31
|
+
info = GPGME::Engine.info.first
|
32
|
+
skip if /\A2\.[01]|\A1\./ === info.version
|
33
|
+
end
|
34
|
+
|
30
35
|
# We consider :armor, :protocol, :textmode and :keylist_mode as tested
|
31
36
|
# with the other tests of this file. Here we test the rest
|
32
37
|
|
@@ -51,80 +56,6 @@ describe GPGME::Ctx do
|
|
51
56
|
end
|
52
57
|
end
|
53
58
|
end
|
54
|
-
|
55
|
-
it ":passphrase_callback sets the callback for the password" do
|
56
|
-
def test_pass_func(obj,par2,par3,prev_was_bad,fd)
|
57
|
-
# prev_was_bad is 0 the first time, 1 the rest
|
58
|
-
if @var == 0
|
59
|
-
assert_equal 0, prev_was_bad
|
60
|
-
else
|
61
|
-
assert_equal 1, prev_was_bad
|
62
|
-
end
|
63
|
-
|
64
|
-
@var += 1
|
65
|
-
|
66
|
-
io = IO.for_fd(fd, 'w')
|
67
|
-
io.puts "wrong pasword"
|
68
|
-
io.flush
|
69
|
-
end
|
70
|
-
|
71
|
-
def with_correct_pass_func(obj,par2,par3,prev_was_bad,fd)
|
72
|
-
io = IO.for_fd(fd, 'w')
|
73
|
-
io.puts "gpgme"
|
74
|
-
io.flush
|
75
|
-
end
|
76
|
-
|
77
|
-
with_key PASSWORD_KEY do
|
78
|
-
input = GPGME::Data.new(TEXT[:passwored])
|
79
|
-
output = GPGME::Data.new
|
80
|
-
@var = 0
|
81
|
-
|
82
|
-
assert_raises GPGME::Error::BadPassphrase do
|
83
|
-
GPGME::Ctx.new(:passphrase_callback => method(:test_pass_func)) do |ctx|
|
84
|
-
ctx.decrypt_verify input, output
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
# Since we request the key 3 times, we should've gone through the
|
89
|
-
# callback 3 times.
|
90
|
-
assert_equal 3, @var
|
91
|
-
|
92
|
-
input.seek 0
|
93
|
-
output.seek 0
|
94
|
-
|
95
|
-
# Shouldn't crash
|
96
|
-
GPGME::Ctx.new(:passphrase_callback => method(:with_correct_pass_func)) do |ctx|
|
97
|
-
ctx.decrypt_verify input, output
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it ":passphrase_callback_value passes a value to the callback function" do
|
103
|
-
def checking_value(value,par2,par3,par4,fd)
|
104
|
-
assert_equal "superman", value
|
105
|
-
io = IO.for_fd(fd, 'w')
|
106
|
-
io.puts "gpgme"
|
107
|
-
io.flush
|
108
|
-
end
|
109
|
-
|
110
|
-
with_key PASSWORD_KEY do
|
111
|
-
input = GPGME::Data.new(TEXT[:passwored])
|
112
|
-
output = GPGME::Data.new
|
113
|
-
|
114
|
-
options = {
|
115
|
-
:passphrase_callback => method(:checking_value),
|
116
|
-
:passphrase_callback_value => "superman"
|
117
|
-
}
|
118
|
-
|
119
|
-
GPGME::Ctx.new(options) do |ctx|
|
120
|
-
ctx.decrypt_verify input, output
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
# TODO Don't know how to use them yet
|
126
|
-
# it ":progress_callback"
|
127
|
-
# it ":progress_callback_value"
|
128
59
|
end
|
129
60
|
|
130
61
|
describe :decrypt_result do
|
@@ -399,6 +330,26 @@ RUBY
|
|
399
330
|
import_keys # If the test fails for some reason, it won't break others.
|
400
331
|
end
|
401
332
|
|
333
|
+
it "exports a minimal key if given the mode" do
|
334
|
+
remove_all_keys
|
335
|
+
GPGME::Key.import(KEY_WITH_SIGNATURE[:public])
|
336
|
+
key = GPGME::Key.find(KEY_WITH_SIGNATURE[:sha]).first
|
337
|
+
output_normal = GPGME::Data.new
|
338
|
+
output_minimal = GPGME::Data.new
|
339
|
+
ctx = GPGME::Ctx.new
|
340
|
+
|
341
|
+
ctx.export_keys(key.sha, output_normal)
|
342
|
+
ctx.export_keys(key.sha, output_minimal, 4)
|
343
|
+
|
344
|
+
output_normal.seek(0)
|
345
|
+
output_minimal.seek(0)
|
346
|
+
|
347
|
+
assert_equal output_normal.read.size, 849
|
348
|
+
assert_equal output_minimal.read.size, 668
|
349
|
+
|
350
|
+
import_keys # If the test fails for some reason, it won't break others.
|
351
|
+
end
|
352
|
+
|
402
353
|
it "exports only one key" do
|
403
354
|
original_keys = GPGME::Key.find(:public)
|
404
355
|
key = original_keys.first
|
@@ -0,0 +1,52 @@
|
|
1
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
2
|
+
Version: GnuPG v1.4.11 (Darwin)
|
3
|
+
|
4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
|
48
|
+
Bk3J0Wzp2Ko47Vj8v03hdBozKZT93a4NeyrNZdiIYQQYEQgACQUCTW05ZgIbDAAK
|
49
|
+
CRDLUpBCN9v3ISGmAP0VXwY7BH81NRpwAYp/eeSGP1vxBCdqVAHMc4o3TUoWHAEA
|
50
|
+
vioivJ/Qvnb7nlHwagl5rLNXhiz/H71jmFS9x0x7FLg=
|
51
|
+
=T/Ce
|
52
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
data/test/key_test.rb
CHANGED
@@ -66,13 +66,13 @@ describe GPGME::Key do
|
|
66
66
|
# Testing the lazy way with expectations. I think tests in
|
67
67
|
# the Ctx class are enough.
|
68
68
|
it "exports any key that matches the pattern" do
|
69
|
-
GPGME::Ctx.any_instance.expects(:export_keys).with("", anything)
|
69
|
+
GPGME::Ctx.any_instance.expects(:export_keys).with("", anything, 0)
|
70
70
|
GPGME::Key.export("")
|
71
71
|
end
|
72
72
|
|
73
73
|
it "exports any key that matches the pattern, can specify output" do
|
74
74
|
data = GPGME::Data.new
|
75
|
-
GPGME::Ctx.any_instance.expects(:export_keys).with("wadus", data)
|
75
|
+
GPGME::Ctx.any_instance.expects(:export_keys).with("wadus", data, 0)
|
76
76
|
ret = GPGME::Key.export("wadus", :output => data)
|
77
77
|
assert_equal data, ret
|
78
78
|
end
|
@@ -81,6 +81,11 @@ describe GPGME::Key do
|
|
81
81
|
GPGME::Ctx.expects(:new).with(:armor => true).yields(mock(:export_keys => true))
|
82
82
|
GPGME::Key.export("wadus", :armor => true)
|
83
83
|
end
|
84
|
+
|
85
|
+
it "can export a minimal key" do
|
86
|
+
GPGME::Ctx.any_instance.expects(:export_keys).with("wadus", anything, 4)
|
87
|
+
GPGME::Key.export("wadus", :minimal => true)
|
88
|
+
end
|
84
89
|
end
|
85
90
|
|
86
91
|
describe "#export" do
|
@@ -180,7 +185,7 @@ describe GPGME::Key do
|
|
180
185
|
|
181
186
|
with_key EXPIRED_KEY do
|
182
187
|
key = GPGME::Key.find(:secret, EXPIRED_KEY[:sha]).first
|
183
|
-
assert key.expired
|
188
|
+
assert key.expired if key
|
184
189
|
end
|
185
190
|
end
|
186
191
|
|
@@ -199,6 +204,18 @@ describe GPGME::Key do
|
|
199
204
|
end
|
200
205
|
end
|
201
206
|
|
207
|
+
describe :valid? do
|
208
|
+
it "returns true on a valid key" do
|
209
|
+
valid_key = File.read("test/files/testkey_pub.gpg")
|
210
|
+
assert GPGME::Key.valid?(valid_key)
|
211
|
+
end
|
212
|
+
|
213
|
+
it "returns false on an invalid key" do
|
214
|
+
invalid_key = File.read("test/files/testkey_pub_invalid.gpg")
|
215
|
+
assert !GPGME::Key.valid?(invalid_key)
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
202
219
|
describe :to_s do
|
203
220
|
it "can be coerced into a String" do
|
204
221
|
key = GPGME::Key.find(:secret).first
|
@@ -206,4 +223,3 @@ describe GPGME::Key do
|
|
206
223
|
end
|
207
224
|
end
|
208
225
|
end
|
209
|
-
|
data/test/pinentry
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
#! /bin/bash
|
2
|
+
# Dummy pinentry
|
3
|
+
#
|
4
|
+
# Copyright 2008 g10 Code GmbH
|
5
|
+
#
|
6
|
+
# This file is free software; as a special exception the author gives
|
7
|
+
# unlimited permission to copy and/or distribute it, with or without
|
8
|
+
# modifications, as long as this notice is preserved.
|
9
|
+
#
|
10
|
+
# This file is distributed in the hope that it will be useful, but
|
11
|
+
# WITHOUT ANY WARRANTY, to the extent permitted by law; without even the
|
12
|
+
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
13
|
+
# PURPOSE.
|
14
|
+
|
15
|
+
echo OK Your orders please
|
16
|
+
|
17
|
+
while read cmd; do
|
18
|
+
case $cmd in
|
19
|
+
GETPIN) echo D gpgme; echo OK;;
|
20
|
+
*) echo OK;;
|
21
|
+
esac
|
22
|
+
done
|
data/test/sub_key_test.rb
CHANGED
@@ -26,8 +26,11 @@ describe GPGME::SubKey do
|
|
26
26
|
refute subkey.expired
|
27
27
|
|
28
28
|
with_key EXPIRED_KEY do
|
29
|
-
|
30
|
-
|
29
|
+
key = GPGME::Key.find(:secret, EXPIRED_KEY[:sha]).first
|
30
|
+
if key
|
31
|
+
subkey = key.primary_subkey
|
32
|
+
assert subkey.expired
|
33
|
+
end
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
data/test/support/resources.rb
CHANGED
@@ -386,6 +386,31 @@ HyEbgNA=
|
|
386
386
|
-----END PGP PRIVATE KEY BLOCK-----
|
387
387
|
RUBY
|
388
388
|
|
389
|
+
key_with_signature = <<-RUBY
|
390
|
+
-----BEGIN PGP PUBLIC KEY BLOCK-----
|
391
|
+
|
392
|
+
mI0ETbL4sAEEANBs/WsOxRCLdsW1h8LKGT6eJpAs6omGV/G7TJnMsk92BUIub3oZ
|
393
|
+
9oRC1L0l4EKB6o8/vULziT815dbbVxwQIOyDXEqP4sokRxjSNNkpPb+RuIjdmP6e
|
394
|
+
SJ2NxCxV/GxLhjZZTHG5SPH4Gei3TtdiHMHoar0rwEcVdS693K/6Ww8ZABEBAAG0
|
395
|
+
IVRlc3QgbnVtYmVyIDEgPHRlc3QxQGV4YW1wbGUuY29tPoi4BBMBAgAiBQJNsviw
|
396
|
+
AhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRD7yLd2W11cdyxOA/4gPEK1
|
397
|
+
qF8bp0YJfc91Ob/J70N5gNuO06AeBa8o6MHTUheCp5CMFD8RISDegsiYey3O+Wvk
|
398
|
+
rg+BmIQWqGTglDIDOM8B1Bmc+T+C0sRwIwmHqDo5a9mR2QnlcFqZ3SNV5MdxDUa4
|
399
|
+
GJk4LbUj/JwU2nR8Z4eA7OC1LjOexFKAfLX654izBBABCAAdFiEEVsoxCW7JMuDZ
|
400
|
+
Ydv9OSviynfWZWYFAl1ziQcACgkQOSviynfWZWYScwP/a/shuIWvLCZLllW0YWy8
|
401
|
+
NUPgTZ4TnJogOp4zm9+uNla9GJepM1Wj7+m1ZNzXskqESoAB00k2dYOGwek0hPHp
|
402
|
+
1MwpcMJvAu7m+LrfGVcG6IAkjQWvifsP8QIe05yNW3jsK+qQJpy1dejzgaHt7dLL
|
403
|
+
/rS6ySBxhIvpo5tsfe+C8PO4jQRNsviwAQQAvVKqiSoVA6oQ8nT3zLEGDgNeED3M
|
404
|
+
fHMeYbFMi7GTpvURsTXcPH0SLXzGVn8Aevaa+ConFWMQuWMsTPiqVQR6/kKE8RJ/
|
405
|
+
ynDHbnXuOGNdOBd96GdsIgqTMwrtWVvzhSKFrhDB1y8iFyQ9QlVTJG4jo8EcaN6L
|
406
|
+
T0hoo64XJktD5CUAEQEAAYifBBgBAgAJBQJNsviwAhsMAAoJEPvIt3ZbXVx3X/8E
|
407
|
+
AIiCsyWlIOUvhFN5a/V2TyA2XjXEKSn9iWi7uLhVT7ShrWSGGhdNBwiqJuDh5KxX
|
408
|
+
3VXa9fePMXrfbALdj1fRqCAFfKZAcKrNNls+psSaYLJwLhCUzD8Ht9M+LrGeZDPz
|
409
|
+
wzAqTfgPb5M2Inssarr5Lpdlu1X8y37cfNVHscqBZyfS
|
410
|
+
=KOQt
|
411
|
+
-----END PGP PUBLIC KEY BLOCK-----
|
412
|
+
RUBY
|
413
|
+
|
389
414
|
encrypted_text = <<-RUBY
|
390
415
|
-----BEGIN PGP MESSAGE-----
|
391
416
|
Version: GnuPG v1.4.11 (Darwin)
|
@@ -506,6 +531,11 @@ EXPIRED_KEY = {
|
|
506
531
|
:secret => expired_key_secret
|
507
532
|
}
|
508
533
|
|
534
|
+
KEY_WITH_SIGNATURE = {
|
535
|
+
:sha => 'test1@example.com',
|
536
|
+
:public => key_with_signature
|
537
|
+
}
|
538
|
+
|
509
539
|
TEXT = {
|
510
540
|
:plain => "Hi there",
|
511
541
|
:encrypted => encrypted_text.chomp,
|
data/test/test_helper.rb
CHANGED
@@ -99,11 +99,17 @@ def ensure_keys(proto)
|
|
99
99
|
# We use a different home directory for the keys to not disturb current
|
100
100
|
# installation
|
101
101
|
require 'tmpdir'
|
102
|
+
require 'pathname'
|
102
103
|
|
103
104
|
if DIRS.empty?
|
104
105
|
dir = Dir.mktmpdir
|
105
106
|
GPGME::Engine.home_dir = dir
|
106
107
|
DIRS.push(dir)
|
108
|
+
pinentry = Pathname.new(__FILE__).dirname + 'pinentry'
|
109
|
+
gpg_agent_conf = Pathname.new(dir) + 'gpg-agent.conf'
|
110
|
+
gpg_agent_conf.open('w+') {|io|
|
111
|
+
io.write("pinentry-program #{pinentry}\n")
|
112
|
+
}
|
107
113
|
remove_all_keys
|
108
114
|
import_keys
|
109
115
|
end
|
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpgme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.22
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daiki Ueno
|
8
8
|
- Albert Llop
|
9
|
-
autorequire:
|
9
|
+
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-11-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_portile2
|
@@ -17,14 +17,14 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: '2.
|
20
|
+
version: '2.7'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: '2.
|
27
|
+
version: '2.7'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: mocha
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: 0.9.11
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
71
|
+
name: coveralls_reborn
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - ">="
|
@@ -85,16 +85,16 @@ dependencies:
|
|
85
85
|
name: byebug
|
86
86
|
requirement: !ruby/object:Gem::Requirement
|
87
87
|
requirements:
|
88
|
-
- - "
|
88
|
+
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
93
|
version_requirements: !ruby/object:Gem::Requirement
|
94
94
|
requirements:
|
95
|
-
- - "
|
95
|
+
- - ">="
|
96
96
|
- !ruby/object:Gem::Version
|
97
|
-
version:
|
97
|
+
version: '0'
|
98
98
|
description: |-
|
99
99
|
Ruby-GPGME is a Ruby language binding of GPGME (GnuPG
|
100
100
|
Made Easy). GnuPG Made Easy (GPGME) is a library designed to make access to
|
@@ -131,19 +131,18 @@ files:
|
|
131
131
|
- lib/gpgme/sub_key.rb
|
132
132
|
- lib/gpgme/user_id.rb
|
133
133
|
- lib/gpgme/version.rb
|
134
|
-
- ports/archives/gpgme-1.
|
135
|
-
- ports/archives/
|
136
|
-
- ports/archives/
|
137
|
-
- ports/archives/libassuan-2.5.1.tar.bz2
|
138
|
-
- ports/archives/libgpg-error-1.27.tar.bz2
|
139
|
-
- ports/archives/libgpg-error-1.32.tar.bz2
|
134
|
+
- ports/archives/gpgme-1.18.0.tar.bz2
|
135
|
+
- ports/archives/libassuan-2.5.5.tar.bz2
|
136
|
+
- ports/archives/libgpg-error-1.46.tar.bz2
|
140
137
|
- test/crypto_test.rb
|
141
138
|
- test/ctx_test.rb
|
142
139
|
- test/data_test.rb
|
143
140
|
- test/files/testkey_pub.gpg
|
141
|
+
- test/files/testkey_pub_invalid.gpg
|
144
142
|
- test/files/testkey_sec.gpg
|
145
143
|
- test/gpgme_test.rb
|
146
144
|
- test/key_test.rb
|
145
|
+
- test/pinentry
|
147
146
|
- test/signature_test.rb
|
148
147
|
- test/sub_key_test.rb
|
149
148
|
- test/support/resources.rb
|
@@ -152,7 +151,7 @@ homepage: http://github.com/ueno/ruby-gpgme
|
|
152
151
|
licenses:
|
153
152
|
- LGPL-2.1+
|
154
153
|
metadata: {}
|
155
|
-
post_install_message:
|
154
|
+
post_install_message:
|
156
155
|
rdoc_options: []
|
157
156
|
require_paths:
|
158
157
|
- lib
|
@@ -168,9 +167,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
167
|
- !ruby/object:Gem::Version
|
169
168
|
version: '0'
|
170
169
|
requirements: []
|
171
|
-
|
172
|
-
|
173
|
-
signing_key:
|
170
|
+
rubygems_version: 3.3.7
|
171
|
+
signing_key:
|
174
172
|
specification_version: 4
|
175
173
|
summary: Ruby binding of GPGME.
|
176
174
|
test_files: []
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|