gpgme 2.0.24 → 2.0.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/gpgme/extconf.rb +29 -6
- data/ext/gpgme/gpgme_n.c +629 -16
- data/lib/gpgme/constants.rb +138 -31
- data/lib/gpgme/crypto.rb +56 -1
- data/lib/gpgme/ctx.rb +69 -8
- data/lib/gpgme/io_callbacks.rb +6 -1
- data/lib/gpgme/key.rb +4 -3
- data/lib/gpgme/version.rb +1 -1
- data/lib/gpgme.rb +56 -1
- data/ports/archives/gpgme-2.0.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-3.0.2.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.55.tar.bz2 +0 -0
- data/test/crypto_test.rb +2 -2
- data/test/ctx_test.rb +1 -4
- data/test/data_test.rb +2 -2
- data/test/encryption_flags_test.rb +65 -0
- data/test/io_callbacks_test.rb +169 -0
- metadata +8 -9
- data/ports/archives/gpgme-1.21.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-2.5.6.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.47.tar.bz2 +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
require 'test_helper'
|
|
3
|
+
require 'stringio'
|
|
4
|
+
|
|
5
|
+
describe GPGME::IOCallbacks do
|
|
6
|
+
describe "encoding handling" do
|
|
7
|
+
it "writes binary data to binary IO without error" do
|
|
8
|
+
io = StringIO.new
|
|
9
|
+
io.set_encoding(Encoding::ASCII_8BIT)
|
|
10
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
11
|
+
|
|
12
|
+
# Binary data with bytes that aren't valid UTF-8
|
|
13
|
+
binary_data = "\xC3\x28".b # Invalid UTF-8 sequence
|
|
14
|
+
|
|
15
|
+
callbacks.write(nil, binary_data, binary_data.bytesize)
|
|
16
|
+
io.rewind
|
|
17
|
+
assert_equal binary_data, io.read
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
it "writes UTF-8 data to UTF-8 IO without error" do
|
|
21
|
+
io = StringIO.new
|
|
22
|
+
io.set_encoding(Encoding::UTF_8)
|
|
23
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
24
|
+
|
|
25
|
+
utf8_data = "Héllo Wörld! 日本語"
|
|
26
|
+
|
|
27
|
+
callbacks.write(nil, utf8_data.encode(Encoding::UTF_8), utf8_data.bytesize)
|
|
28
|
+
io.rewind
|
|
29
|
+
assert_equal utf8_data, io.read
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it "handles encoding conversion when IO has different encoding" do
|
|
33
|
+
io = StringIO.new
|
|
34
|
+
io.set_encoding(Encoding::UTF_8)
|
|
35
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
36
|
+
|
|
37
|
+
# ASCII-8BIT string with valid UTF-8 bytes
|
|
38
|
+
data = "Hello World".b
|
|
39
|
+
|
|
40
|
+
# Should not raise Encoding::UndefinedConversionError
|
|
41
|
+
callbacks.write(nil, data, data.bytesize)
|
|
42
|
+
io.rewind
|
|
43
|
+
assert_equal "Hello World", io.read
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "replaces invalid characters when converting encodings" do
|
|
47
|
+
io = StringIO.new
|
|
48
|
+
io.set_encoding(Encoding::UTF_8)
|
|
49
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
50
|
+
|
|
51
|
+
# Invalid UTF-8 sequence in ASCII-8BIT string
|
|
52
|
+
invalid_data = "Hello\xC3\x28World".b
|
|
53
|
+
|
|
54
|
+
# Should not raise, should replace invalid chars
|
|
55
|
+
callbacks.write(nil, invalid_data, invalid_data.bytesize)
|
|
56
|
+
io.rewind
|
|
57
|
+
result = io.read
|
|
58
|
+
# The invalid sequence should be replaced
|
|
59
|
+
refute_nil result
|
|
60
|
+
assert result.valid_encoding?
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
it "reads data from IO" do
|
|
64
|
+
io = StringIO.new("test data")
|
|
65
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
66
|
+
|
|
67
|
+
result = callbacks.read(nil, 9)
|
|
68
|
+
assert_equal "test data", result
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
it "seeks in IO" do
|
|
72
|
+
io = StringIO.new("test data")
|
|
73
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
74
|
+
|
|
75
|
+
callbacks.read(nil, 4) # read "test"
|
|
76
|
+
pos = callbacks.seek(nil, 0, IO::SEEK_SET)
|
|
77
|
+
assert_equal 0, pos
|
|
78
|
+
|
|
79
|
+
result = callbacks.read(nil, 4)
|
|
80
|
+
assert_equal "test", result
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
it "returns current position for seek with offset 0 and SEEK_CUR" do
|
|
84
|
+
io = StringIO.new("test data")
|
|
85
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
86
|
+
|
|
87
|
+
callbacks.read(nil, 5) # read "test "
|
|
88
|
+
pos = callbacks.seek(nil, 0, IO::SEEK_CUR)
|
|
89
|
+
assert_equal 5, pos
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
describe "integration with GPGME signing" do
|
|
94
|
+
before do
|
|
95
|
+
skip unless ensure_keys GPGME::PROTOCOL_OpenPGP
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "clearsigns UTF-8 data without encoding errors" do
|
|
99
|
+
utf8_text = "Héllo Wörld! Ünïcödé tëxt 日本語"
|
|
100
|
+
|
|
101
|
+
crypto = GPGME::Crypto.new
|
|
102
|
+
output = StringIO.new
|
|
103
|
+
output.set_encoding(Encoding::UTF_8)
|
|
104
|
+
|
|
105
|
+
# This should not raise Encoding::UndefinedConversionError
|
|
106
|
+
crypto.sign(utf8_text, mode: GPGME::SIG_MODE_CLEAR, output: output)
|
|
107
|
+
|
|
108
|
+
output.rewind
|
|
109
|
+
result = output.read
|
|
110
|
+
refute_empty result
|
|
111
|
+
assert result.include?("BEGIN PGP SIGNED MESSAGE")
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
it "signs UTF-8 data and outputs to default buffer without errors" do
|
|
115
|
+
utf8_text = "Ünïcödé tëxt: äöü ÄÖÜ ß"
|
|
116
|
+
|
|
117
|
+
crypto = GPGME::Crypto.new
|
|
118
|
+
signed = crypto.sign(utf8_text)
|
|
119
|
+
|
|
120
|
+
result = signed.read
|
|
121
|
+
refute_empty result
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
it "encrypts and decrypts UTF-8 data correctly" do
|
|
125
|
+
utf8_text = "Sëcrét mëssägé with spëcïäl chäräctërs: 日本語"
|
|
126
|
+
|
|
127
|
+
crypto = GPGME::Crypto.new(always_trust: true)
|
|
128
|
+
encrypted = crypto.encrypt(utf8_text, recipients: KEYS.first[:sha])
|
|
129
|
+
decrypted = crypto.decrypt(encrypted)
|
|
130
|
+
|
|
131
|
+
result = decrypted.read
|
|
132
|
+
# Force UTF-8 encoding since GPGME returns binary data
|
|
133
|
+
result.force_encoding(Encoding::UTF_8)
|
|
134
|
+
assert_equal utf8_text, result
|
|
135
|
+
end
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
describe "default internal encoding support" do
|
|
139
|
+
it "respects Encoding.default_internal when set" do
|
|
140
|
+
# Save original setting
|
|
141
|
+
original_internal = Encoding.default_internal
|
|
142
|
+
original_verbose = $VERBOSE
|
|
143
|
+
|
|
144
|
+
begin
|
|
145
|
+
# Suppress warning about setting Encoding.default_internal
|
|
146
|
+
$VERBOSE = nil
|
|
147
|
+
Encoding.default_internal = Encoding::UTF_8
|
|
148
|
+
$VERBOSE = original_verbose
|
|
149
|
+
|
|
150
|
+
io = StringIO.new
|
|
151
|
+
io.set_encoding(Encoding::UTF_8)
|
|
152
|
+
callbacks = GPGME::IOCallbacks.new(io)
|
|
153
|
+
|
|
154
|
+
# Valid UTF-8 data
|
|
155
|
+
utf8_data = "Tëst dätä"
|
|
156
|
+
callbacks.write(nil, utf8_data, utf8_data.bytesize)
|
|
157
|
+
|
|
158
|
+
io.rewind
|
|
159
|
+
result = io.read
|
|
160
|
+
assert_equal utf8_data, result
|
|
161
|
+
ensure
|
|
162
|
+
# Restore original settings
|
|
163
|
+
$VERBOSE = nil
|
|
164
|
+
Encoding.default_internal = original_internal
|
|
165
|
+
$VERBOSE = original_verbose
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
end
|
|
169
|
+
end
|
metadata
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
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.26
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daiki Ueno
|
|
8
8
|
- Albert Llop
|
|
9
|
-
autorequire:
|
|
10
9
|
bindir: bin
|
|
11
10
|
cert_chain: []
|
|
12
|
-
date:
|
|
11
|
+
date: 2025-07-26 00:00:00.000000000 Z
|
|
13
12
|
dependencies:
|
|
14
13
|
- !ruby/object:Gem::Dependency
|
|
15
14
|
name: mini_portile2
|
|
@@ -131,16 +130,18 @@ files:
|
|
|
131
130
|
- lib/gpgme/sub_key.rb
|
|
132
131
|
- lib/gpgme/user_id.rb
|
|
133
132
|
- lib/gpgme/version.rb
|
|
134
|
-
- ports/archives/gpgme-
|
|
135
|
-
- ports/archives/libassuan-
|
|
136
|
-
- ports/archives/libgpg-error-1.
|
|
133
|
+
- ports/archives/gpgme-2.0.0.tar.bz2
|
|
134
|
+
- ports/archives/libassuan-3.0.2.tar.bz2
|
|
135
|
+
- ports/archives/libgpg-error-1.55.tar.bz2
|
|
137
136
|
- test/crypto_test.rb
|
|
138
137
|
- test/ctx_test.rb
|
|
139
138
|
- test/data_test.rb
|
|
139
|
+
- test/encryption_flags_test.rb
|
|
140
140
|
- test/files/testkey_pub.gpg
|
|
141
141
|
- test/files/testkey_pub_invalid.gpg
|
|
142
142
|
- test/files/testkey_sec.gpg
|
|
143
143
|
- test/gpgme_test.rb
|
|
144
|
+
- test/io_callbacks_test.rb
|
|
144
145
|
- test/key_test.rb
|
|
145
146
|
- test/pinentry
|
|
146
147
|
- test/signature_test.rb
|
|
@@ -151,7 +152,6 @@ homepage: http://github.com/ueno/ruby-gpgme
|
|
|
151
152
|
licenses:
|
|
152
153
|
- LGPL-2.1+
|
|
153
154
|
metadata: {}
|
|
154
|
-
post_install_message:
|
|
155
155
|
rdoc_options: []
|
|
156
156
|
require_paths:
|
|
157
157
|
- lib
|
|
@@ -167,8 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
167
167
|
- !ruby/object:Gem::Version
|
|
168
168
|
version: '0'
|
|
169
169
|
requirements: []
|
|
170
|
-
rubygems_version: 3.
|
|
171
|
-
signing_key:
|
|
170
|
+
rubygems_version: 3.7.2
|
|
172
171
|
specification_version: 4
|
|
173
172
|
summary: Ruby binding of GPGME.
|
|
174
173
|
test_files: []
|
|
Binary file
|
|
Binary file
|
|
Binary file
|