gpgme 2.0.22 → 2.0.24

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4dc4765cd73bfd27c0ebdfff8749106341f2dd7a6c0118a4e3307798b753e84
4
- data.tar.gz: 6b929a3f84144a4fdcc40382129bd6ad409e9a819c956f33941a8d650000c70c
3
+ metadata.gz: 8d1c8d00babf6af92b5889c2c96abc06a9a3c7d9da0b8201012970778919ea20
4
+ data.tar.gz: 841d821ead85e9e51ef7b239701acba33bb4d4129dc043af8f47ef0470ab6032
5
5
  SHA512:
6
- metadata.gz: 387806727ae8b6d8da14fc23ce7c9a24c58373b52f79b4bce8ca1f7de2337e715c488c7af65e30ac8e6e73a18c8d31589b00f80c682f0dcbcce1f4d234cc58a3
7
- data.tar.gz: bbfa653feac228f87c430fa61524625d373ff6dd0a33d5c824c50d94db59233ab6161d8ac1b6e475db21ce9908f22b45bce17fff5c6cba92f9bb959b49b297b8
6
+ metadata.gz: 6610600eac90798c4904825fe94c125ddf0605ce964ba6412a182e1a1817bfc5656b1090cb478ae3da6f5d0f42554bf543b02027dc25252e3dc21961869bcd3d
7
+ data.tar.gz: e9c9a21ffc43bb7cfe123a0055c79a556528c553c53fd6c5fa09cc3a91791633f8b0f1efa43a2782c8846da4cc8888934ff3bb533145b244e4a617c33c5856e2
data/ext/gpgme/extconf.rb CHANGED
@@ -25,25 +25,28 @@ if arg_config('--clean')
25
25
 
26
26
  # clean the ports build directory
27
27
  Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
28
- FileUtils.rm_rf(dir, { :verbose => true })
29
- FileUtils.rmdir(dir.parent, { :parents => true, :verbose => true })
28
+ FileUtils.rm_rf(dir, verbose: true)
29
+ FileUtils.rmdir(dir.parent, parents: true, verbose: true)
30
30
  }
31
31
 
32
32
  # ports installation can be safely removed if statically linked.
33
- FileUtils.rm_rf(root + 'ports', { :verbose => true })
33
+ FileUtils.rm_rf(root + 'ports', verbose: true)
34
34
  end
35
35
 
36
36
  exit
37
37
  end
38
38
 
39
39
  if arg_config('--use-system-libraries', ENV['RUBY_GPGME_USE_SYSTEM_LIBRARIES'])
40
- unless find_executable('pkg-config')
41
- $stderr.puts("pkg-config not found")
40
+ if find_executable('pkg-config') && system('pkg-config gpgme --exists')
41
+ $CFLAGS += ' ' << `pkg-config --cflags gpgme`.chomp
42
+ $libs += ' ' << `pkg-config --libs gpgme`.chomp
43
+ elsif find_executable('gpgme-config')
44
+ $CFLAGS += ' ' << `gpgme-config --cflags`.chomp
45
+ $libs += ' ' << `gpgme-config --libs`.chomp
46
+ else
47
+ $stderr.puts("pkg-config with gpgme.pc and gpgme-config not found")
42
48
  exit(1)
43
49
  end
44
-
45
- $CFLAGS += ' ' << `pkg-config --cflags gpgme`.chomp
46
- $libs += ' ' << `pkg-config --libs gpgme`.chomp
47
50
  else
48
51
  message <<-'EOS'
49
52
  ************************************************************************
@@ -62,11 +65,11 @@ EOS
62
65
  require 'rubygems'
63
66
  require 'mini_portile2'
64
67
 
65
- libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.46').tap do |recipe|
68
+ libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.47').tap do |recipe|
66
69
  recipe.target = File.join(ROOT, "ports")
67
70
  recipe.files = [{
68
71
  :url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
69
- :sha256 => 'b7e11a64246bbe5ef37748de43b245abd72cfcd53c9ae5e7fc5ca59f1c81268d'
72
+ :sha256 => '9e3c670966b96ecc746c28c2c419541e3bcb787d1a73930f5e5f5e1bcbbb9bdb'
70
73
  }]
71
74
  recipe.configure_options = [
72
75
  '--enable-install-gpg-error-config',
@@ -83,11 +86,11 @@ EOS
83
86
  recipe.activate
84
87
  end
85
88
 
86
- libassuan_recipe = MiniPortile.new('libassuan', '2.5.5').tap do |recipe|
89
+ libassuan_recipe = MiniPortile.new('libassuan', '2.5.6').tap do |recipe|
87
90
  recipe.target = File.join(ROOT, "ports")
88
91
  recipe.files = [{
89
92
  :url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
90
- :sha256 => '8e8c2fcc982f9ca67dcbb1d95e2dc746b1739a4668bc20b3a3c5be632edb34e4'
93
+ :sha256 => 'e9fd27218d5394904e4e39788f9b1742711c3e6b41689a31aa3380bd5aa4f426'
91
94
  }]
92
95
  recipe.configure_options = [
93
96
  '--disable-shared',
@@ -103,11 +106,11 @@ EOS
103
106
  recipe.activate
104
107
  end
105
108
 
106
- gpgme_recipe = MiniPortile.new('gpgme', '1.18.0').tap do |recipe|
109
+ gpgme_recipe = MiniPortile.new('gpgme', '1.21.0').tap do |recipe|
107
110
  recipe.target = File.join(ROOT, "ports")
108
111
  recipe.files = [{
109
112
  :url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
110
- :sha256 => '361d4eae47ce925dba0ea569af40e7b52c645c4ae2e65e5621bf1b6cdd8b0e9e'
113
+ :sha256 => '416e174e165734d84806253f8c96bda2993fd07f258c3aad5f053a6efd463e88'
111
114
  }]
112
115
  recipe.configure_options = [
113
116
  '--disable-shared',
@@ -123,7 +126,7 @@ EOS
123
126
  '--disable-g13-test',
124
127
  # We only need the C API.
125
128
  '--disable-languages',
126
- "CFLAGS=-fPIC #{ENV["CFLAGS"]}",
129
+ "CFLAGS=-D_LARGEFILE64_SOURCE -fPIC #{ENV["CFLAGS"]}",
127
130
  ]
128
131
  checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
129
132
  unless File.exist?(checkpoint)
data/ext/gpgme/gpgme_n.c CHANGED
@@ -514,6 +514,46 @@ rb_s_gpgme_release (VALUE dummy, VALUE vctx)
514
514
  return Qnil;
515
515
  }
516
516
 
517
+ static VALUE
518
+ rb_s_gpgme_set_ctx_flag (VALUE dummy, VALUE vctx, VALUE vname, VALUE vstr)
519
+ {
520
+ gpgme_ctx_t ctx;
521
+ gpgme_error_t err;
522
+ char* name;
523
+ char* str;
524
+
525
+ name = StringValueCStr(vname);
526
+ str = StringValueCStr(vstr);
527
+
528
+ UNWRAP_GPGME_CTX(vctx, ctx);
529
+ if (!ctx)
530
+ rb_raise (rb_eArgError, "released ctx");
531
+
532
+ err = gpgme_set_ctx_flag(ctx, name, str);
533
+ return LONG2NUM(err);
534
+ }
535
+
536
+ static VALUE
537
+ rb_s_gpgme_get_ctx_flag (VALUE dummy, VALUE vctx, VALUE vname)
538
+ {
539
+ gpgme_ctx_t ctx;
540
+ const char* name;
541
+ int yes;
542
+
543
+ name = StringValueCStr(vname);
544
+
545
+ UNWRAP_GPGME_CTX(vctx, ctx);
546
+ if (!ctx)
547
+ rb_raise (rb_eArgError, "released ctx");
548
+
549
+ const char* result;
550
+ result = gpgme_get_ctx_flag(ctx, name);
551
+ if (result == NULL)
552
+ rb_raise (rb_eArgError, "incorrect ctx flag name");
553
+
554
+ return rb_str_new_cstr(result);
555
+ }
556
+
517
557
  static VALUE
518
558
  rb_s_gpgme_set_protocol (VALUE dummy, VALUE vctx, VALUE vproto)
519
559
  {
@@ -566,6 +606,42 @@ rb_s_gpgme_get_armor (VALUE dummy, VALUE vctx)
566
606
  return INT2FIX(yes);
567
607
  }
568
608
 
609
+ static VALUE
610
+ rb_s_gpgme_set_ignore_mdc_error (VALUE dummy, VALUE vctx, VALUE vyes)
611
+ {
612
+ gpgme_ctx_t ctx;
613
+ gpgme_error_t err;
614
+ int yes;
615
+
616
+ yes = NUM2INT(vyes);
617
+
618
+ UNWRAP_GPGME_CTX(vctx, ctx);
619
+ if (!ctx)
620
+ rb_raise (rb_eArgError, "released ctx");
621
+
622
+ err = gpgme_set_ctx_flag(ctx, "ignore-mdc-error", yes ? "1" : "");
623
+ return LONG2NUM(err);
624
+ }
625
+
626
+ static VALUE
627
+ rb_s_gpgme_get_ignore_mdc_error (VALUE dummy, VALUE vctx)
628
+ {
629
+ gpgme_ctx_t ctx;
630
+ int yes;
631
+
632
+ UNWRAP_GPGME_CTX(vctx, ctx);
633
+ if (!ctx)
634
+ rb_raise (rb_eArgError, "released ctx");
635
+
636
+ const char* result;
637
+ result = gpgme_get_ctx_flag(ctx, "ignore-mdc-error");
638
+ if (result == NULL)
639
+ rb_raise (rb_eArgError, "incorrect ctx flag name");
640
+
641
+ yes = (result && *result)? !!atoi (result) : 0;
642
+ return INT2FIX(yes);
643
+ }
644
+
569
645
  static VALUE
570
646
  rb_s_gpgme_set_textmode (VALUE dummy, VALUE vctx, VALUE vyes)
571
647
  {
@@ -876,6 +952,7 @@ rb_s_gpgme_op_keylist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
876
952
  return LONG2NUM(err);
877
953
  }
878
954
 
955
+ // https://github.com/rwinlib/gpgme/blob/v1.16.0/include/gpgme.h#L2013-L2015
879
956
  static VALUE
880
957
  rb_s_gpgme_op_keylist_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
881
958
  VALUE vsecret_only)
@@ -2372,6 +2449,10 @@ Init_gpgme_n (void)
2372
2449
  rb_s_gpgme_release, 1);
2373
2450
 
2374
2451
  /* Context Attributes */
2452
+ rb_define_module_function (mGPGME, "gpgme_set_ctx_flag",
2453
+ rb_s_gpgme_set_ctx_flag, 3);
2454
+ rb_define_module_function (mGPGME, "gpgme_get_ctx_flag",
2455
+ rb_s_gpgme_get_ctx_flag, 2);
2375
2456
  rb_define_module_function (mGPGME, "gpgme_set_protocol",
2376
2457
  rb_s_gpgme_set_protocol, 2);
2377
2458
  rb_define_module_function (mGPGME, "gpgme_get_protocol",
@@ -2380,6 +2461,10 @@ Init_gpgme_n (void)
2380
2461
  rb_s_gpgme_set_armor, 2);
2381
2462
  rb_define_module_function (mGPGME, "gpgme_get_armor",
2382
2463
  rb_s_gpgme_get_armor, 1);
2464
+ rb_define_module_function (mGPGME, "gpgme_set_ignore_mdc_error",
2465
+ rb_s_gpgme_set_ignore_mdc_error, 2);
2466
+ rb_define_module_function (mGPGME, "gpgme_get_ignore_mdc_error",
2467
+ rb_s_gpgme_get_ignore_mdc_error, 1);
2383
2468
  rb_define_module_function (mGPGME, "gpgme_set_textmode",
2384
2469
  rb_s_gpgme_set_textmode, 2);
2385
2470
  rb_define_module_function (mGPGME, "gpgme_get_textmode",
@@ -2423,7 +2508,7 @@ Init_gpgme_n (void)
2423
2508
  rb_define_module_function (mGPGME, "gpgme_op_keylist_start",
2424
2509
  rb_s_gpgme_op_keylist_start, 3);
2425
2510
  rb_define_module_function (mGPGME, "gpgme_op_keylist_ext_start",
2426
- rb_s_gpgme_op_keylist_ext_start, 4);
2511
+ rb_s_gpgme_op_keylist_ext_start, 3);
2427
2512
  rb_define_module_function (mGPGME, "gpgme_op_keylist_next",
2428
2513
  rb_s_gpgme_op_keylist_next, 2);
2429
2514
  rb_define_module_function (mGPGME, "gpgme_op_keylist_end",
data/lib/gpgme/ctx.rb CHANGED
@@ -49,12 +49,13 @@ module GPGME
49
49
  raise exc if exc
50
50
  ctx = rctx[0]
51
51
 
52
- ctx.protocol = options[:protocol] if options[:protocol]
53
- ctx.armor = options[:armor] if options[:armor]
54
- ctx.textmode = options[:textmode] if options[:textmode]
55
- ctx.keylist_mode = options[:keylist_mode] if options[:keylist_mode]
56
- ctx.pinentry_mode = options[:pinentry_mode] if options[:pinentry_mode]
57
- ctx.offline = options[:offline] if options[:offline]
52
+ ctx.protocol = options[:protocol] if options[:protocol]
53
+ ctx.armor = options[:armor] if options[:armor]
54
+ ctx.textmode = options[:textmode] if options[:textmode]
55
+ ctx.keylist_mode = options[:keylist_mode] if options[:keylist_mode]
56
+ ctx.pinentry_mode = options[:pinentry_mode] if options[:pinentry_mode]
57
+ ctx.offline = options[:offline] if options[:offline]
58
+ ctx.ignore_mdc_error = options[:ignore_mdc_error] if options[:ignore_mdc_error]
58
59
 
59
60
  if options[:password]
60
61
  ctx.set_passphrase_callback GPGME::Ctx.method(:pass_function),
@@ -103,6 +104,43 @@ module GPGME
103
104
  # Getters and setters
104
105
  ##
105
106
 
107
+ # Get the value of the Ctx flag with the given name.
108
+ #
109
+ # Allowed flag names may include:
110
+ # - 'redraw'
111
+ # - 'full-status'
112
+ # - 'raw-description'
113
+ # - 'export-session-key'
114
+ # - 'override-session-key'
115
+ # - 'include-key-block'
116
+ # - 'auto-key-import'
117
+ # - 'auto-key-retrieve'
118
+ # - 'request-origin'
119
+ # - 'no-symkey-cache'
120
+ # - 'ignore-mdc-error'
121
+ # - 'auto-key-locate'
122
+ # - 'trust-model'
123
+ # - 'extended-edit'
124
+ # - 'cert-expire'
125
+ # - 'key-origin'
126
+ # - 'import-filter'
127
+ # - 'no-auto-check-trustdb'
128
+ #
129
+ # Please consult the GPGPME documentation for more details
130
+ #
131
+ def get_ctx_flag(flag_name)
132
+ GPGME::gpgme_get_ctx_flag(self, flag_name.to_s)
133
+ end
134
+
135
+ # Set the Ctx flag with the given name
136
+ # to the given value.
137
+ def set_ctx_flag(flag_name, val)
138
+ err = GPGME::gpgme_set_ctx_flag(self, flag_name.to_s, val.to_s)
139
+ exc = GPGME::error_to_exception(err)
140
+ raise exc if exc
141
+ val
142
+ end
143
+
106
144
  # Set the +protocol+ used within this context. See {GPGME::Ctx.new} for
107
145
  # possible values.
108
146
  def protocol=(proto)
@@ -128,6 +166,22 @@ module GPGME
128
166
  GPGME::gpgme_get_armor(self) == 1 ? true : false
129
167
  end
130
168
 
169
+ # This option ignores a MDC integrity protection failure.
170
+ # It is required to decrypt old messages which did not use an MDC.
171
+ # It may also be useful if a message is partially garbled,
172
+ # but it is necessary to get as much data as possible out of that garbled message.
173
+ # Be aware that a missing or failed MDC can be an indication of an attack.
174
+ # Use with great caution.
175
+ def ignore_mdc_error=(yes)
176
+ GPGME::gpgme_set_ignore_mdc_error(self, yes ? 1 : 0)
177
+ yes
178
+ end
179
+
180
+ # Return true if the MDC integrity protection is disabled.
181
+ def ignore_mdc_error
182
+ GPGME::gpgme_get_ignore_mdc_error(self) == 1 ? true : false
183
+ end
184
+
131
185
  # Tell whether canonical text mode should be used.
132
186
  def textmode=(yes)
133
187
  GPGME::gpgme_set_textmode(self, yes ? 1 : 0)
data/lib/gpgme/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module GPGME
2
2
  # The version of GPGME ruby binding you are using
3
- VERSION = "2.0.22"
3
+ VERSION = "2.0.24"
4
4
  end
data/lib/gpgme.rb CHANGED
@@ -1,5 +1,3 @@
1
- $:.push File.expand_path("../..", __FILE__) # C extension is in the root
2
-
3
1
  require 'gpgme_n'
4
2
 
5
3
  # TODO without this call one can't GPGME::Ctx.new, find out why
Binary file
data/test/ctx_test.rb CHANGED
@@ -81,6 +81,70 @@ describe GPGME::Ctx do
81
81
  end
82
82
  end
83
83
 
84
+ describe :get_ctx_flag do
85
+ it "reads flags with getters and setters" do
86
+ ctx = GPGME::Ctx.new
87
+
88
+ refute ctx.ignore_mdc_error
89
+ assert_equal "", ctx.get_ctx_flag("ignore-mdc-error")
90
+
91
+ ctx.ignore_mdc_error = true
92
+
93
+ assert ctx.ignore_mdc_error
94
+ assert_equal "1", ctx.get_ctx_flag("ignore-mdc-error")
95
+ end
96
+
97
+ it "can get flags without getters and setters" do
98
+ ctx = GPGME::Ctx.new
99
+
100
+ assert_equal "", ctx.get_ctx_flag("auto-key-locate")
101
+ ctx.set_ctx_flag("auto-key-locate", "cert")
102
+ assert_equal "cert", ctx.get_ctx_flag("auto-key-locate")
103
+ end
104
+
105
+ it "raises an error when a flag doesn't exist" do
106
+ ctx = GPGME::Ctx.new
107
+
108
+ assert_raises ArgumentError do
109
+ ctx.get_ctx_flag("foo")
110
+ end
111
+ end
112
+ end
113
+
114
+ describe :set_ctx_flag do
115
+ it "sets the value for a flag with a getter" do
116
+ ctx = GPGME::Ctx.new
117
+ refute ctx.ignore_mdc_error
118
+
119
+ ctx.set_ctx_flag("ignore-mdc-error", "1")
120
+ assert ctx.ignore_mdc_error
121
+ end
122
+
123
+ it "unsets the value for a flag with a getter" do
124
+ ctx = GPGME::Ctx.new(ignore_mdc_error: true)
125
+ assert ctx.ignore_mdc_error
126
+
127
+ ctx.set_ctx_flag("ignore-mdc-error", "0")
128
+ refute ctx.ignore_mdc_error
129
+ end
130
+
131
+ it "can set flags without getters and setters" do
132
+ ctx = GPGME::Ctx.new
133
+
134
+ assert_equal "", ctx.get_ctx_flag("auto-key-locate")
135
+ ctx.set_ctx_flag("auto-key-locate", "cert")
136
+ assert_equal "cert", ctx.get_ctx_flag("auto-key-locate")
137
+ end
138
+
139
+ it "raises an error when a flag doesn't exist" do
140
+ ctx = GPGME::Ctx.new
141
+
142
+ assert_raises GPGME::Error do
143
+ ctx.set_ctx_flag("foo", "bar")
144
+ end
145
+ end
146
+ end
147
+
84
148
  describe :armor do
85
149
  it "sets false by default" do
86
150
  ctx = GPGME::Ctx.new
@@ -101,6 +165,36 @@ describe GPGME::Ctx do
101
165
  end
102
166
  end
103
167
 
168
+ describe :ignore_mdc_error do
169
+ it "sets false by default" do
170
+ ctx = GPGME::Ctx.new
171
+ refute ctx.ignore_mdc_error
172
+ end
173
+
174
+ it "can set" do
175
+ ctx = GPGME::Ctx.new
176
+
177
+ ctx.ignore_mdc_error = true
178
+ assert ctx.ignore_mdc_error
179
+ end
180
+
181
+ it "can unset" do
182
+ ctx = GPGME::Ctx.new(ignore_mdc_error: true)
183
+ assert ctx.ignore_mdc_error
184
+
185
+ ctx.ignore_mdc_error = false
186
+ refute ctx.ignore_mdc_error
187
+ end
188
+
189
+ it "can set and get in constructor" do
190
+ ctx = GPGME::Ctx.new(:ignore_mdc_error => false)
191
+ refute ctx.ignore_mdc_error
192
+
193
+ ctx = GPGME::Ctx.new(:ignore_mdc_error => true)
194
+ assert ctx.ignore_mdc_error
195
+ end
196
+ end
197
+
104
198
  describe :protocol do
105
199
  it "sets 0 by default" do
106
200
  ctx = GPGME::Ctx.new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpgme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.22
4
+ version: 2.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daiki Ueno
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-11-25 00:00:00.000000000 Z
12
+ date: 2024-01-31 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_portile2
@@ -131,9 +131,9 @@ 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.18.0.tar.bz2
135
- - ports/archives/libassuan-2.5.5.tar.bz2
136
- - ports/archives/libgpg-error-1.46.tar.bz2
134
+ - ports/archives/gpgme-1.21.0.tar.bz2
135
+ - ports/archives/libassuan-2.5.6.tar.bz2
136
+ - ports/archives/libgpg-error-1.47.tar.bz2
137
137
  - test/crypto_test.rb
138
138
  - test/ctx_test.rb
139
139
  - test/data_test.rb
@@ -167,7 +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.3.7
170
+ rubygems_version: 3.4.10
171
171
  signing_key:
172
172
  specification_version: 4
173
173
  summary: Ruby binding of GPGME.
Binary file
Binary file