gpgme 2.0.2 → 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cee9137e390ab8ba123ecac6b939c97bcc503f41
4
+ data.tar.gz: dd2d64bdc427465e8700d6088406c5007cb0d386
5
+ SHA512:
6
+ metadata.gz: e200b2c41ea564fa46d2415699f86f6c9d04e1b2aabbdae4f2cf684712720ac3520ebd7d6cfa27a3ab8b7eb596563f153d126ca7293b6740a47108083093cdf4
7
+ data.tar.gz: d179bae893e54223e758fc49b2d6dbec6f5e5ddd084ebb02835fc65ade34768bd4893e356fa6836bafb4f892b8e674ccaea9b5904e14c861ce270512d4cbc1d0
@@ -1,58 +1,206 @@
1
1
  require 'mkmf'
2
2
 
3
- BUILD = Dir::pwd
4
- SRC = File.expand_path(File.dirname(__FILE__))
5
- PREFIX = "#{BUILD}/dst"
3
+ # Available options:
4
+ #
5
+ # --enable-clean (default)
6
+ # --disable-clean
7
+ #
8
+ # This file is largely based on Nokogiri's extconf.rb.
6
9
 
7
- def sys(*cmd)
8
- puts " -- #{cmd.join(' ')}"
10
+ ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
9
11
 
10
- unless ret = xsystem(cmd.join(' '))
11
- raise "#{cmd.join(' ')} failed!"
12
+ if arg_config('--clean')
13
+ require 'pathname'
14
+ require 'fileutils'
15
+
16
+ root = Pathname(ROOT)
17
+ pwd = Pathname(Dir.pwd)
18
+
19
+ # Skip if this is a development work tree
20
+ unless (root + '.git').exist?
21
+ message "Cleaning files only used during build.\n"
22
+
23
+ # (root + 'tmp') cannot be removed at this stage because
24
+ # gpgme_n.so is yet to be copied to lib.
25
+
26
+ # clean the ports build directory
27
+ Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
28
+ FileUtils.rm_rf(dir, { :verbose => true })
29
+ FileUtils.rmdir(dir.parent, { :parents => true, :verbose => true })
30
+ }
31
+
32
+ # ports installation can be safely removed if statically linked.
33
+ FileUtils.rm_rf(root + 'ports', { :verbose => true })
12
34
  end
13
35
 
14
- ret
36
+ exit
15
37
  end
16
38
 
17
- def build(tgz, *flags)
18
- sys("tar xjvf #{tgz}")
39
+ if arg_config('--use-system-libraries', ENV['RUBY_GPGME_USE_SYSTEM_LIBRARIES'])
40
+ unless find_executable('gpgme-config')
41
+ $stderr.puts("gpgme-config not found")
42
+ exit(1)
43
+ end
19
44
 
20
- Dir.chdir(File.basename(tgz, '.tar.bz2')) do
21
- sys("./configure --prefix=#{PREFIX} --libdir=#{PREFIX}/lib --disable-shared --enable-static --with-pic", *flags)
22
- sys("make")
23
- sys("make install")
45
+ $CFLAGS += ' ' << `gpgme-config --cflags`.chomp
46
+ $libs += ' ' << `gpgme-config --libs`.chomp
47
+ else
48
+ def message!(important_message)
49
+ message important_message
50
+ if !$stdout.tty? && File.chardev?('/dev/tty')
51
+ File.open('/dev/tty', 'w') { |tty|
52
+ tty.print important_message
53
+ }
54
+ end
24
55
  end
25
- end
26
56
 
27
- libgpg_error_tgz = File.join(SRC, 'libgpg-error-1.11.tar.bz2')
28
- libassuan_tgz = File.join(SRC, 'libassuan-2.1.0.tar.bz2')
29
- gpgme_tgz = File.join(SRC, 'gpgme-1.4.0.tar.bz2')
57
+ message! <<-'EOS'
58
+ ************************************************************************
59
+ IMPORTANT! gpgme gem uses locally built versions of required C libraries,
60
+ namely libgpg-error, libassuan, and gpgme.
61
+
62
+ If this is a concern for you and you want to use the system library
63
+ instead, abort this installation process and reinstall gpgme gem as
64
+ follows:
65
+
66
+ gem install gpgme -- --use-system-libraries
67
+
68
+ ************************************************************************
69
+ EOS
70
+
71
+ require 'rubygems'
72
+ require 'mini_portile'
73
+
74
+ libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.12').tap do |recipe|
75
+ recipe.target = File.join(ROOT, "ports")
76
+ recipe.files = ["ftp://ftp.gnupg.org/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2"]
77
+ recipe.configure_options = [
78
+ '--disable-shared',
79
+ '--enable-static',
80
+ '--disable-nls',
81
+ "CFLAGS='-fPIC #{ENV["CFLAGS"]}'",
82
+ ]
83
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
84
+ unless File.exist?(checkpoint)
85
+ recipe.cook
86
+ FileUtils.touch checkpoint
87
+ end
88
+ recipe.activate
89
+ end
30
90
 
31
- # build deps
91
+ libassuan_recipe = MiniPortile.new('libassuan', '2.1.1').tap do |recipe|
92
+ recipe.target = File.join(ROOT, "ports")
93
+ recipe.files = ["ftp://ftp.gnupg.org/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2"]
94
+ recipe.configure_options = [
95
+ '--disable-shared',
96
+ '--enable-static',
97
+ "--with-gpg-error-prefix=#{libgpg_error_recipe.path}",
98
+ "CFLAGS='-fPIC #{ENV["CFLAGS"]}'",
99
+ ]
100
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
101
+ unless File.exist?(checkpoint)
102
+ recipe.cook
103
+ FileUtils.touch checkpoint
104
+ end
105
+ recipe.activate
106
+ end
32
107
 
33
- build(libgpg_error_tgz, "--disable-nls")
34
- build(libassuan_tgz, "--with-gpg-error-prefix=#{PREFIX}")
35
- build(gpgme_tgz, "--with-gpg-error-prefix=#{PREFIX}", "--with-libassuan-prefix=#{PREFIX}")
108
+ gpgme_recipe = MiniPortile.new('gpgme', '1.4.3').tap do |recipe|
109
+ recipe.target = File.join(ROOT, "ports")
110
+ recipe.files = ["ftp://ftp.gnupg.org/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2"]
111
+ recipe.configure_options = [
112
+ '--disable-shared',
113
+ '--enable-static',
114
+ "--with-gpg-error-prefix=#{libgpg_error_recipe.path}",
115
+ "--with-libassuan-prefix=#{libassuan_recipe.path}",
116
+ "CFLAGS='-fPIC #{ENV["CFLAGS"]}'",
117
+ ]
118
+ checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
119
+ unless File.exist?(checkpoint)
120
+ recipe.cook
121
+ FileUtils.touch checkpoint
122
+ end
123
+ recipe.activate
124
+ end
36
125
 
37
- # copy gpgme
126
+ # special treatment to link with static libraries
127
+ $libs = $libs.shellsplit.tap {|libs|
128
+ File.join(gpgme_recipe.path, "bin", "gpgme-config").tap {|config|
129
+ # call config scripts explicit with 'sh' for compat with Windows
130
+ $CPPFLAGS = `sh #{config} --cflags`.strip << ' ' << $CPPFLAGS
131
+ `sh #{config} --libs`.strip.shellsplit.each {|arg|
132
+ case arg
133
+ when /\A-L(.+)\z/
134
+ lpath=$1
135
+ # Prioritize ports' directories
136
+ if lpath.start_with?(ROOT + '/')
137
+ $LIBPATH = [lpath] | $LIBPATH
138
+ else
139
+ $LIBPATH = $LIBPATH | [lpath]
140
+ end
141
+ when /\A-l./
142
+ libs.push(arg)
143
+ else
144
+ $LDFLAGS << ' ' << arg.shellescape
145
+ end
146
+ }
147
+ }
148
+ }.shelljoin
149
+
150
+ message 'checking for linker flags for static linking... '
151
+ case
152
+ when try_link('int main(void) { return 0; }',
153
+ ['-Wl,-Bstatic', '-lgpgme', '-Wl,-Bdynamic'].shelljoin)
154
+ message "-Wl,-Bstatic\n"
155
+
156
+ $libs = $libs.shellsplit.map {|arg|
157
+ case arg
158
+ when '-lgpgme', '-lassuan', '-lgpg-error'
159
+ ['-Wl,-Bstatic', arg, '-Wl,-Bdynamic']
160
+ else
161
+ arg
162
+ end
163
+ }.flatten.shelljoin
164
+ else
165
+ message "NONE\n"
166
+ end
38
167
 
168
+ unless have_header 'gpgme.h'
169
+ abort <<-EOS
170
+ ************************************************************************
171
+ ERROR! Cannot locate 'gpgme.h'.
172
+ ************************************************************************
173
+ EOS
174
+ end
175
+ end
39
176
 
40
- %w[ libassuan libgpg-error libgpgme ].each do |lib|
41
- FileUtils.cp "#{PREFIX}/lib/#{lib}.a", "#{BUILD}/#{lib}_ext.a"
177
+ checking_for('gpgme >= 1.1.3') do
178
+ if try_run(<<'End')
179
+ #include <gpgme.h>
180
+ #include <stdlib.h>
181
+ int main (void) {
182
+ return gpgme_check_version ("1.1.3") == NULL;
183
+ }
184
+ End
185
+ true
186
+ else
187
+ $CFLAGS += ' -DRUBY_GPGME_NEED_WORKAROUND_KEYLIST_NEXT'
188
+ false
189
+ end
42
190
  end
43
191
 
44
- $INCFLAGS[0,0] = " -I#{PREFIX}/include "
45
- #$LDFLAGS << " -L#{PREFIX}/lib "
46
- $CFLAGS << " -fPIC "
192
+ have_func('gpgme_op_export_keys')
47
193
 
48
- # build gpgme extension
194
+ create_makefile ('gpgme_n')
49
195
 
50
- unless have_library 'gpg-error_ext' and have_library 'assuan_ext' and have_library 'gpgme_ext' and have_header 'gpgme.h'
51
- STDERR.puts "\n\n"
52
- STDERR.puts "*********************************************************"
53
- STDERR.puts "********* error compiling and linking libgpgme. *********"
54
- STDERR.puts "*********************************************************"
55
- exit(1)
56
- end
196
+ if enable_config('clean', true)
197
+ # Do not clean if run in a development work tree.
198
+ File.open('Makefile', 'a') { |mk|
199
+ mk.print <<EOF
200
+ all: clean-ports
57
201
 
58
- create_makefile ('gpgme_n')
202
+ clean-ports: $(DLLIB)
203
+ -$(Q)$(RUBY) $(srcdir)/extconf.rb --clean
204
+ EOF
205
+ }
206
+ end
@@ -37,6 +37,9 @@
37
37
  cases) for that. */
38
38
 
39
39
  #include "ruby.h"
40
+ #ifdef HAVE_RUBY_ENCODING_H
41
+ #include "ruby/encoding.h"
42
+ #endif
40
43
  #include "gpgme.h"
41
44
  #include <errno.h>
42
45
 
@@ -121,6 +124,7 @@ static VALUE cEngineInfo,
121
124
  cSignature,
122
125
  cSigNotation,
123
126
  cTrustItem,
127
+ cRecipient,
124
128
  cDecryptResult,
125
129
  cVerifyResult,
126
130
  cSignResult,
@@ -666,6 +670,36 @@ rb_s_gpgme_set_locale (VALUE dummy, VALUE vctx, VALUE vcategory, VALUE vvalue)
666
670
  return LONG2NUM(err);
667
671
  }
668
672
 
673
+ #if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010400
674
+ static VALUE
675
+ rb_s_gpgme_set_pinentry_mode (VALUE dummy, VALUE vctx, VALUE vmode)
676
+ {
677
+ gpgme_ctx_t ctx;
678
+ gpgme_error_t err;
679
+
680
+ UNWRAP_GPGME_CTX(vctx, ctx);
681
+ if (!ctx)
682
+ rb_raise (rb_eArgError, "released ctx");
683
+
684
+ err = gpgme_set_pinentry_mode (ctx, NUM2INT(vmode));
685
+ return LONG2NUM(err);
686
+ }
687
+
688
+ static VALUE
689
+ rb_s_gpgme_get_pinentry_mode (VALUE dummy, VALUE vctx)
690
+ {
691
+ gpgme_ctx_t ctx;
692
+ gpgme_pinentry_mode_t mode;
693
+
694
+ UNWRAP_GPGME_CTX(vctx, ctx);
695
+ if (!ctx)
696
+ rb_raise (rb_eArgError, "released ctx");
697
+
698
+ mode = gpgme_get_pinentry_mode (ctx);
699
+ return INT2FIX(mode);
700
+ }
701
+ #endif
702
+
669
703
  static VALUE
670
704
  rb_s_gpgme_op_keylist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
671
705
  VALUE vsecret_only)
@@ -718,6 +752,16 @@ rb_s_gpgme_op_keylist_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
718
752
  return LONG2NUM(err);
719
753
  }
720
754
 
755
+ static VALUE
756
+ utf8_str_new (const char *data)
757
+ {
758
+ VALUE string = rb_str_new2 (data);
759
+ #ifdef HAVE_RUBY_ENCODING_H
760
+ rb_enc_associate_index (string, rb_enc_find_index ("UTF-8"));
761
+ #endif
762
+ return string;
763
+ }
764
+
721
765
  static VALUE
722
766
  save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
723
767
  {
@@ -739,7 +783,7 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
739
783
  if (key->issuer_serial)
740
784
  rb_iv_set (vkey, "@issuer_serial", rb_str_new2 (key->issuer_serial));
741
785
  if (key->issuer_name)
742
- rb_iv_set (vkey, "@issuer_name", rb_str_new2 (key->issuer_name));
786
+ rb_iv_set (vkey, "@issuer_name", utf8_str_new (key->issuer_name));
743
787
  if (key->chain_id)
744
788
  rb_iv_set (vkey, "@chain_id", rb_str_new2 (key->chain_id));
745
789
  rb_iv_set (vkey, "@owner_trust", INT2FIX(key->owner_trust));
@@ -771,18 +815,20 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
771
815
  rb_iv_set (vkey, "@uids", vuids);
772
816
  for (user_id = key->uids; user_id; user_id = user_id->next)
773
817
  {
774
- VALUE vuser_id = rb_class_new_instance(0, NULL, cUserID), vsignatures;
818
+ VALUE vuser_id, vsignatures;
819
+ gpgme_key_sig_t key_sig;
820
+
821
+ vuser_id = rb_class_new_instance(0, NULL, cUserID);
775
822
  rb_iv_set (vuser_id, "@revoked", INT2FIX(user_id->revoked));
776
823
  rb_iv_set (vuser_id, "@invalid", INT2FIX(user_id->invalid));
777
824
  rb_iv_set (vuser_id, "@validity", INT2FIX(user_id->validity));
778
- rb_iv_set (vuser_id, "@uid", rb_str_new2 (user_id->uid));
779
- rb_iv_set (vuser_id, "@name", rb_str_new2 (user_id->name));
780
- rb_iv_set (vuser_id, "@comment", rb_str_new2 (user_id->comment));
781
- rb_iv_set (vuser_id, "@email", rb_str_new2 (user_id->email));
825
+ rb_iv_set (vuser_id, "@name", utf8_str_new (user_id->name));
826
+ rb_iv_set (vuser_id, "@uid", utf8_str_new (user_id->uid));
827
+ rb_iv_set (vuser_id, "@comment", utf8_str_new (user_id->comment));
828
+ rb_iv_set (vuser_id, "@email", utf8_str_new (user_id->email));
782
829
 
783
830
  vsignatures = rb_ary_new ();
784
831
  rb_iv_set (vuser_id, "@signatures", vsignatures);
785
- gpgme_key_sig_t key_sig;
786
832
  for (key_sig = user_id->signatures; key_sig; key_sig = key_sig->next)
787
833
  {
788
834
  VALUE vkey_sig = rb_class_new_instance(0, NULL, cKeySig);
@@ -1450,7 +1496,8 @@ rb_s_gpgme_op_decrypt_result (VALUE dummy, VALUE vctx)
1450
1496
  {
1451
1497
  gpgme_ctx_t ctx;
1452
1498
  gpgme_decrypt_result_t result;
1453
- VALUE vresult;
1499
+ gpgme_recipient_t recipient;
1500
+ VALUE vresult, vrecipients;
1454
1501
 
1455
1502
  UNWRAP_GPGME_CTX(vctx, ctx);
1456
1503
  if (!ctx)
@@ -1462,6 +1509,17 @@ rb_s_gpgme_op_decrypt_result (VALUE dummy, VALUE vctx)
1462
1509
  rb_iv_set (vresult, "@unsupported_algorithm",
1463
1510
  rb_str_new2 (result->unsupported_algorithm));
1464
1511
  rb_iv_set (vresult, "@wrong_key_usage", INT2FIX(result->wrong_key_usage));
1512
+ vrecipients = rb_ary_new ();
1513
+ rb_iv_set (vresult, "@recipients", vrecipients);
1514
+ for (recipient = result->recipients; recipient; recipient = recipient->next)
1515
+ {
1516
+ VALUE vrecipient = rb_class_new_instance (0, NULL, cRecipient);
1517
+ rb_iv_set (vrecipient, "@pubkey_algo", INT2FIX(recipient->pubkey_algo));
1518
+ rb_iv_set (vrecipient, "@keyid", rb_str_new2 (recipient->keyid));
1519
+ rb_iv_set (vrecipient, "@status", UINT2NUM(recipient->status));
1520
+ rb_ary_push (vrecipients, vrecipient);
1521
+ }
1522
+ rb_iv_set (vresult, "@file_name", rb_str_new2 (result->file_name));
1465
1523
  return vresult;
1466
1524
  }
1467
1525
 
@@ -1972,6 +2030,8 @@ Init_gpgme_n (void)
1972
2030
  rb_define_class_under (mGPGME, "UserID", rb_cObject);
1973
2031
  cKeySig =
1974
2032
  rb_define_class_under (mGPGME, "KeySig", rb_cObject);
2033
+ cRecipient =
2034
+ rb_define_class_under (mGPGME, "Recipient", rb_cObject);
1975
2035
  cDecryptResult =
1976
2036
  rb_define_class_under (mGPGME, "DecryptResult", rb_cObject);
1977
2037
  cVerifyResult =
@@ -2047,6 +2107,12 @@ Init_gpgme_n (void)
2047
2107
  rb_s_gpgme_set_keylist_mode, 2);
2048
2108
  rb_define_module_function (mGPGME, "gpgme_get_keylist_mode",
2049
2109
  rb_s_gpgme_get_keylist_mode, 1);
2110
+ #if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010400
2111
+ rb_define_module_function (mGPGME, "gpgme_set_pinentry_mode",
2112
+ rb_s_gpgme_set_pinentry_mode, 2);
2113
+ rb_define_module_function (mGPGME, "gpgme_get_pinentry_mode",
2114
+ rb_s_gpgme_get_pinentry_mode, 1);
2115
+ #endif
2050
2116
  rb_define_module_function (mGPGME, "gpgme_set_passphrase_cb",
2051
2117
  rb_s_gpgme_set_passphrase_cb, 3);
2052
2118
  rb_define_module_function (mGPGME, "gpgme_get_passphrase_cb",
@@ -2625,4 +2691,18 @@ Init_gpgme_n (void)
2625
2691
  rb_define_const (mGPGME, "GPGME_ENCRYPT_NO_ENCRYPT_TO",
2626
2692
  INT2FIX(GPGME_ENCRYPT_NO_ENCRYPT_TO));
2627
2693
  #endif
2694
+
2695
+ /* These flags were added in 1.4.0. */
2696
+ #if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010400
2697
+ rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_DEFAULT",
2698
+ INT2FIX(GPGME_PINENTRY_MODE_DEFAULT));
2699
+ rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_ASK",
2700
+ INT2FIX(GPGME_PINENTRY_MODE_ASK));
2701
+ rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_CANCEL",
2702
+ INT2FIX(GPGME_PINENTRY_MODE_CANCEL));
2703
+ rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_ERROR",
2704
+ INT2FIX(GPGME_PINENTRY_MODE_ERROR));
2705
+ rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_LOOPBACK",
2706
+ INT2FIX(GPGME_PINENTRY_MODE_LOOPBACK));
2707
+ #endif
2628
2708
  }
@@ -58,6 +58,11 @@ module GPGME
58
58
  MD_SHA384 = GPGME_MD_SHA384
59
59
  MD_SHA512 = GPGME_MD_SHA512
60
60
  MD_TIGER = GPGME_MD_TIGER
61
+ PINENTRY_MODE_DEFAULT = GPGME_PINENTRY_MODE_DEFAULT
62
+ PINENTRY_MODE_ASK = GPGME_PINENTRY_MODE_ASK
63
+ PINENTRY_MODE_CANCEL = GPGME_PINENTRY_MODE_CANCEL
64
+ PINENTRY_MODE_ERROR = GPGME_PINENTRY_MODE_ERROR
65
+ PINENTRY_MODE_LOOPBACK = GPGME_PINENTRY_MODE_LOOPBACK
61
66
  PK_DSA = GPGME_PK_DSA
62
67
  PK_ELG = GPGME_PK_ELG
63
68
  PK_ELG_E = GPGME_PK_ELG_E
@@ -184,4 +189,11 @@ module GPGME
184
189
  VALIDITY_ULTIMATE => :ultimate
185
190
  }
186
191
 
192
+ PINENTRY_MODE_NAMES = {
193
+ PINENTRY_MODE_DEFAULT => :default,
194
+ PINENTRY_MODE_ASK => :ask,
195
+ PINENTRY_MODE_CANCEL => :cancel,
196
+ PINENTRY_MODE_ERROR => :error,
197
+ PINENTRY_MODE_LOOPBACK => :loopback
198
+ }
187
199
  end
@@ -20,6 +20,9 @@ module GPGME
20
20
  # * +:textmode+ if +true+, inform the recipient that the input is text.
21
21
  # * +:keylist_mode+ One of: +KEYLIST_MODE_LOCAL+, +KEYLIST_MODE_EXTERN+,
22
22
  # +KEYLIST_MODE_SIGS+ or +KEYLIST_MODE_VALIDATE+.
23
+ # * +:pinentry_mode+ One of: +PINENTRY_MODE_DEFAULT+,
24
+ # +PINENTRY_MODE_ASK+, +PINENTRY_MODE_CANCEL+,
25
+ # +PINENTRY_MODE_ERROR+, or +PINENTRY_MODE_LOOPBACK+.
23
26
  # * +:password+ password of the passphrased password being used.
24
27
  # * +:passphrase_callback+ A callback function. See {#set_passphrase_callback}.
25
28
  # * +:passphrase_callback_value+ An object passed to passphrase_callback.
@@ -43,10 +46,11 @@ module GPGME
43
46
  raise exc if exc
44
47
  ctx = rctx[0]
45
48
 
46
- ctx.protocol = options[:protocol] if options[:protocol]
47
- ctx.armor = options[:armor] if options[:armor]
48
- ctx.textmode = options[:textmode] if options[:textmode]
49
- ctx.keylist_mode = options[:keylist_mode] if options[:keylist_mode]
49
+ ctx.protocol = options[:protocol] if options[:protocol]
50
+ ctx.armor = options[:armor] if options[:armor]
51
+ ctx.textmode = options[:textmode] if options[:textmode]
52
+ ctx.keylist_mode = options[:keylist_mode] if options[:keylist_mode]
53
+ ctx.pinentry_mode = options[:pinentry_mode] if options[:pinentry_mode]
50
54
 
51
55
  if options[:password]
52
56
  ctx.set_passphrase_callback GPGME::Ctx.method(:pass_function),
@@ -138,6 +142,17 @@ module GPGME
138
142
  GPGME::gpgme_get_keylist_mode(self)
139
143
  end
140
144
 
145
+ # Change the default behaviour of the pinentry invocation.
146
+ def pinentry_mode=(mode)
147
+ GPGME::gpgme_set_pinentry_mode(self, mode)
148
+ mode
149
+ end
150
+
151
+ # Return the current pinentry mode.
152
+ def pinentry_mode
153
+ GPGME::gpgme_get_pinentry_mode(self)
154
+ end
155
+
141
156
  ##
142
157
  # Passphrase and progress callbacks
143
158
  ##
@@ -184,6 +199,10 @@ module GPGME
184
199
  # $stderr.puts
185
200
  # end
186
201
  #
202
+ # Note that this function doesn't work with GnuPG 2.0. You can
203
+ # use either GnuPG 1.x, which can be installed in parallel with
204
+ # GnuPG 2.0, or GnuPG 2.1, which has loopback pinentry feature (see
205
+ # {#pinentry_mode}).
187
206
  def set_passphrase_callback(passfunc, hook_value = nil)
188
207
  GPGME::gpgme_set_passphrase_cb(self, passfunc, hook_value)
189
208
  end
@@ -68,7 +68,7 @@ module GPGME
68
68
  # Create a new instance with internal buffer.
69
69
  def from_str(string)
70
70
  rdh = []
71
- err = GPGME::gpgme_data_new_from_mem(rdh, string, string.length)
71
+ err = GPGME::gpgme_data_new_from_mem(rdh, string, string.bytesize)
72
72
  exc = GPGME::error_to_exception(err)
73
73
  raise exc if exc
74
74
  rdh.first
@@ -12,10 +12,17 @@ module GPGME
12
12
  attr_reader :signatures
13
13
  end
14
14
 
15
+ class Recipient
16
+ private_class_method :new
17
+
18
+ attr_reader :pubkey_algo, :keyid, :status
19
+ end
20
+
15
21
  class DecryptResult
16
22
  private_class_method :new
17
23
 
18
24
  attr_reader :unsupported_algorithm, :wrong_key_usage
25
+ attr_reader :recipients, :file_name
19
26
  end
20
27
 
21
28
  class SignResult
@@ -37,10 +37,18 @@ describe GPGME::Ctx do
37
37
 
38
38
  GPGME::Ctx.new(:password => 'gpgme') do |ctx|
39
39
  ctx.decrypt_verify input, output
40
- end
41
40
 
42
- output.seek 0
43
- assert_equal "Hi there", output.read.chomp
41
+ output.seek 0
42
+ assert_equal "Hi there", output.read.chomp
43
+
44
+ recipients = ctx.decrypt_result.recipients
45
+ assert_equal 1, recipients.size
46
+
47
+ recipient_key = ctx.get_key(recipients.first.keyid)
48
+ key = ctx.get_key(PASSWORD_KEY[:sha])
49
+
50
+ assert_equal recipient_key, key
51
+ end
44
52
  end
45
53
  end
46
54
 
@@ -314,7 +322,7 @@ Key-Type: DSA
314
322
  Key-Length: 1024
315
323
  Subkey-Type: ELG-E
316
324
  Subkey-Length: 1024
317
- Name-Real: Key Tester
325
+ Name-Real: Key Testér
318
326
  Name-Comment: with some comments
319
327
  Name-Email: test_generation@example.com
320
328
  Expire-Date: 0
@@ -322,6 +330,10 @@ Passphrase: wadus
322
330
  </GnupgKeyParms>
323
331
  RUBY
324
332
 
333
+ if RUBY_VERSION > "1.9"
334
+ assert_equal key.encoding, Encoding::UTF_8
335
+ end
336
+
325
337
  keys_amount = GPGME::Key.find(:public).size
326
338
  GPGME::Ctx.new do |ctx|
327
339
  ctx.generate_key(key.chomp)
@@ -330,6 +342,12 @@ RUBY
330
342
  assert_equal keys_amount + 1, GPGME::Key.find(:public).size
331
343
 
332
344
  GPGME::Key.find(:public, "test_generation@example.com").each do |k|
345
+
346
+ if RUBY_VERSION > "1.9"
347
+ # Make sure UTF-8 in and UTF-8 out.
348
+ assert_equal "Key Testér", k.name
349
+ assert_equal k.name.encoding, Encoding::UTF_8
350
+ end
333
351
  k.delete!(true)
334
352
  end
335
353
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gpgme
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
5
- prerelease:
4
+ version: 2.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Daiki Ueno
@@ -10,12 +9,25 @@ authors:
10
9
  autorequire:
11
10
  bindir: bin
12
11
  cert_chain: []
13
- date: 2013-03-05 00:00:00.000000000 Z
12
+ date: 2014-03-13 00:00:00.000000000 Z
14
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: mini_portile
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ~>
19
+ - !ruby/object:Gem::Version
20
+ version: 0.5.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ version: 0.5.0
15
28
  - !ruby/object:Gem::Dependency
16
29
  name: mocha
17
30
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
31
  requirements:
20
32
  - - ~>
21
33
  - !ruby/object:Gem::Version
@@ -23,7 +35,6 @@ dependencies:
23
35
  type: :development
24
36
  prerelease: false
25
37
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
38
  requirements:
28
39
  - - ~>
29
40
  - !ruby/object:Gem::Version
@@ -31,7 +42,6 @@ dependencies:
31
42
  - !ruby/object:Gem::Dependency
32
43
  name: minitest
33
44
  requirement: !ruby/object:Gem::Requirement
34
- none: false
35
45
  requirements:
36
46
  - - ~>
37
47
  - !ruby/object:Gem::Version
@@ -39,7 +49,6 @@ dependencies:
39
49
  type: :development
40
50
  prerelease: false
41
51
  version_requirements: !ruby/object:Gem::Requirement
42
- none: false
43
52
  requirements:
44
53
  - - ~>
45
54
  - !ruby/object:Gem::Version
@@ -47,7 +56,6 @@ dependencies:
47
56
  - !ruby/object:Gem::Dependency
48
57
  name: yard
49
58
  requirement: !ruby/object:Gem::Requirement
50
- none: false
51
59
  requirements:
52
60
  - - ~>
53
61
  - !ruby/object:Gem::Version
@@ -55,7 +63,6 @@ dependencies:
55
63
  type: :development
56
64
  prerelease: false
57
65
  version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
66
  requirements:
60
67
  - - ~>
61
68
  - !ruby/object:Gem::Version
@@ -63,7 +70,6 @@ dependencies:
63
70
  - !ruby/object:Gem::Dependency
64
71
  name: rcov
65
72
  requirement: !ruby/object:Gem::Requirement
66
- none: false
67
73
  requirements:
68
74
  - - ~>
69
75
  - !ruby/object:Gem::Version
@@ -71,34 +77,29 @@ dependencies:
71
77
  type: :development
72
78
  prerelease: false
73
79
  version_requirements: !ruby/object:Gem::Requirement
74
- none: false
75
80
  requirements:
76
81
  - - ~>
77
82
  - !ruby/object:Gem::Version
78
83
  version: 0.9.9
79
84
  - !ruby/object:Gem::Dependency
80
- name: ruby-debug19
85
+ name: debugger
81
86
  requirement: !ruby/object:Gem::Requirement
82
- none: false
83
87
  requirements:
84
88
  - - ~>
85
89
  - !ruby/object:Gem::Version
86
- version: 0.11.6
90
+ version: 1.6.6
87
91
  type: :development
88
92
  prerelease: false
89
93
  version_requirements: !ruby/object:Gem::Requirement
90
- none: false
91
94
  requirements:
92
95
  - - ~>
93
96
  - !ruby/object:Gem::Version
94
- version: 0.11.6
95
- description: ! 'Ruby-GPGME is a Ruby language binding of GPGME (GnuPG
96
-
97
+ version: 1.6.6
98
+ description: |-
99
+ Ruby-GPGME is a Ruby language binding of GPGME (GnuPG
97
100
  Made Easy). GnuPG Made Easy (GPGME) is a library designed to make access to
98
-
99
101
  GnuPG easier for applications. It provides a High-Level Crypto API for
100
-
101
- encryption, decryption, signing, signature verification and key management.'
102
+ encryption, decryption, signing, signature verification and key management.
102
103
  email: ueno@gnu.org
103
104
  executables: []
104
105
  extensions:
@@ -122,12 +123,8 @@ files:
122
123
  - lib/gpgme/ctx.rb
123
124
  - lib/gpgme/crypto.rb
124
125
  - lib/gpgme/user_id.rb
125
- - ext/gpgme/libassuan-2.1.0.tar.bz2
126
126
  - ext/gpgme/gpgme_n.c
127
127
  - ext/gpgme/extconf.rb
128
- - ext/gpgme/libgpg-error-1.11.tar.gz
129
- - ext/gpgme/libgpg-error-1.11.tar.bz2
130
- - ext/gpgme/gpgme-1.4.0.tar.bz2
131
128
  - test/key_test.rb
132
129
  - test/sub_key_test.rb
133
130
  - test/test_helper.rb
@@ -145,29 +142,33 @@ files:
145
142
  - examples/genkey.rb
146
143
  - examples/keylist.rb
147
144
  - examples/edit.rb
145
+ - ports/archives/libgpg-error-1.12.tar.bz2
146
+ - ports/archives/gpgme-1.4.3.tar.bz2
147
+ - ports/archives/libassuan-2.1.1.tar.bz2
148
148
  homepage: http://github.com/ueno/ruby-gpgme
149
- licenses: []
149
+ licenses:
150
+ - LGPL-2.1+
151
+ metadata: {}
150
152
  post_install_message:
151
153
  rdoc_options: []
152
154
  require_paths:
153
155
  - lib
154
156
  - ext
155
157
  required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
158
  requirements:
158
- - - ! '>='
159
+ - - '>='
159
160
  - !ruby/object:Gem::Version
160
161
  version: '0'
161
162
  required_rubygems_version: !ruby/object:Gem::Requirement
162
- none: false
163
163
  requirements:
164
- - - ! '>='
164
+ - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  requirements: []
168
168
  rubyforge_project: ruby-gpgme
169
- rubygems_version: 1.8.25
169
+ rubygems_version: 2.1.11
170
170
  signing_key:
171
- specification_version: 3
171
+ specification_version: 4
172
172
  summary: Ruby binding of GPGME.
173
173
  test_files: []
174
+ has_rdoc: true