gpgme 2.0.23 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4d6acceab7f41eb6f3921f566fc2bf394658cd2a0a42e84024e3dda8ce19c9a6
4
- data.tar.gz: a2e3adb3405cecfa249173693a12a552ed5b13eaeb09c5b4ef45c7fca8af2699
3
+ metadata.gz: 8d1c8d00babf6af92b5889c2c96abc06a9a3c7d9da0b8201012970778919ea20
4
+ data.tar.gz: 841d821ead85e9e51ef7b239701acba33bb4d4129dc043af8f47ef0470ab6032
5
5
  SHA512:
6
- metadata.gz: 7ec1990d20648deeaed5c10d1eff1737b96a3b8f9d7dbb7001c21efb8f78ead507429d7e34d1219db2556f0f2fd584bb18362a42fadeaca47fc340153a304261
7
- data.tar.gz: ccd721826ffe1077351628f083ece7894fe03c4a754f53eddab814dc4c1642a314dddfeb7157fc0117d9b5ea8f1fc2aad7aba447d377eb755201c625825f92a8
6
+ metadata.gz: 6610600eac90798c4904825fe94c125ddf0605ce964ba6412a182e1a1817bfc5656b1090cb478ae3da6f5d0f42554bf543b02027dc25252e3dc21961869bcd3d
7
+ data.tar.gz: e9c9a21ffc43bb7cfe123a0055c79a556528c553c53fd6c5fa09cc3a91791633f8b0f1efa43a2782c8846da4cc8888934ff3bb533145b244e4a617c33c5856e2
data/ext/gpgme/extconf.rb CHANGED
@@ -25,12 +25,12 @@ 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
@@ -126,7 +126,7 @@ EOS
126
126
  '--disable-g13-test',
127
127
  # We only need the C API.
128
128
  '--disable-languages',
129
- "CFLAGS=-fPIC #{ENV["CFLAGS"]}",
129
+ "CFLAGS=-D_LARGEFILE64_SOURCE -fPIC #{ENV["CFLAGS"]}",
130
130
  ]
131
131
  checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
132
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
  {
@@ -2373,6 +2449,10 @@ Init_gpgme_n (void)
2373
2449
  rb_s_gpgme_release, 1);
2374
2450
 
2375
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);
2376
2456
  rb_define_module_function (mGPGME, "gpgme_set_protocol",
2377
2457
  rb_s_gpgme_set_protocol, 2);
2378
2458
  rb_define_module_function (mGPGME, "gpgme_get_protocol",
@@ -2381,6 +2461,10 @@ Init_gpgme_n (void)
2381
2461
  rb_s_gpgme_set_armor, 2);
2382
2462
  rb_define_module_function (mGPGME, "gpgme_get_armor",
2383
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);
2384
2468
  rb_define_module_function (mGPGME, "gpgme_set_textmode",
2385
2469
  rb_s_gpgme_set_textmode, 2);
2386
2470
  rb_define_module_function (mGPGME, "gpgme_get_textmode",
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.23"
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
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.23
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: 2023-08-16 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