gpgme 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gpgme'
3
+
4
+ GPGME.list_keys(ARGV.shift) do |key|
5
+ puts(key)
6
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gpgme'
3
+
4
+ # If you do not have gpg-agent installed, comment out the following
5
+ # and set it as :passphrase_callback.
6
+ #
7
+ # def passfunc(hook, uid_hint, passphrase_info, prev_was_bad, fd)
8
+ # $stderr.write("Passphrase for #{uid_hint}: ")
9
+ # $stderr.flush
10
+ # begin
11
+ # system('stty -echo')
12
+ # io = IO.for_fd(fd, 'w')
13
+ # io.puts(gets)
14
+ # io.flush
15
+ # ensure
16
+ # (0 ... $_.length).each do |i| $_[i] = ?0 end if $_
17
+ # system('stty echo')
18
+ # end
19
+ # $stderr.puts
20
+ # end
21
+
22
+ unless ENV['GPG_AGENT_INFO']
23
+ $stderr.puts("gpg-agent is not running. See the comment in #{$0}.")
24
+ exit(1)
25
+ end
26
+
27
+ plain = 'test test test'
28
+ puts("Plaintext:\n#{plain}")
29
+
30
+ # Perform symmetric encryption on PLAIN.
31
+ cipher = GPGME::encrypt(nil, plain, {:armor => true,
32
+ # :passphrase_callback => method(:passfunc)
33
+ })
34
+ puts("Ciphertext:\n#{cipher}")
35
+
36
+ plain = GPGME::decrypt(cipher, {
37
+ # :passphrase_callback => method(:passfunc)
38
+ })
39
+ puts("Plaintext:\n#{plain}")
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gpgme'
3
+
4
+ # If you do not have gpg-agent installed, comment out the following
5
+ # and set it as :passphrase_callback.
6
+ #
7
+ # def passfunc(hook, uid_hint, passphrase_info, prev_was_bad, fd)
8
+ # $stderr.write("Passphrase for #{uid_hint}: ")
9
+ # $stderr.flush
10
+ # begin
11
+ # system('stty -echo')
12
+ # io = IO.for_fd(fd, 'w')
13
+ # io.puts(gets)
14
+ # io.flush
15
+ # ensure
16
+ # (0 ... $_.length).each do |i| $_[i] = ?0 end if $_
17
+ # system('stty echo')
18
+ # end
19
+ # $stderr.puts
20
+ # end
21
+
22
+ unless ENV['GPG_AGENT_INFO']
23
+ $stderr.puts("gpg-agent is not running. See the comment in #{$0}.")
24
+ exit(1)
25
+ end
26
+
27
+ puts GPGME::clearsign('test test test', {
28
+ # :passphrase_callback => method(:passfunc)
29
+ })
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gpgme'
3
+
4
+ GPGME::verify(ARGF.read, nil, $stdout) do |signature|
5
+ puts(signature.to_s)
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'mkmf'
2
+
3
+ unless find_executable('gpgme-config')
4
+ $stderr.puts("gpgme-config not found")
5
+ exit(1)
6
+ end
7
+
8
+ $CFLAGS += ' ' << `gpgme-config --cflags`.chomp
9
+ $libs += ' ' << `gpgme-config --libs`.chomp
10
+
11
+ checking_for('gpgme >= 1.1.3') do
12
+ if try_run(<<'End')
13
+ #include <gpgme.h>
14
+ #include <stdlib.h>
15
+ int main (void) {
16
+ return gpgme_check_version ("1.1.3") == NULL;
17
+ }
18
+ End
19
+ true
20
+ else
21
+ $CFLAGS += ' -DRUBY_GPGME_NEED_WORKAROUND_KEYLIST_NEXT'
22
+ false
23
+ end
24
+ end
25
+ have_func('gpgme_op_export_keys')
26
+ create_makefile ('gpgme_n')
@@ -0,0 +1,2622 @@
1
+ /* gpgme_n.c -- low level interface to GPGME
2
+ Copyright (C) 2003,2006,2007,2008,2009 Daiki Ueno
3
+
4
+ This file is a part of Ruby-GPGME.
5
+
6
+ This library is free software; you can redistribute it and/or
7
+ modify it under the terms of the GNU Lesser General Public
8
+ License as published by the Free Software Foundation; either
9
+ version 2.1 of the License, or (at your option) any later version.
10
+
11
+ This library is distributed in the hope that it will be useful,
12
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
13
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
+ Lesser General Public License for more details.
15
+
16
+ You should have received a copy of the GNU Lesser General Public
17
+ License along with this library; if not, write to the Free Software
18
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
+ 02110-1301 USA */
20
+
21
+ /* While this file was written by hand, it is (semi) automatically
22
+ generated. High-level functions are written in Ruby instead of C
23
+ (See "lib/gpgme.rb"). If you are about to edit this file, you may
24
+ want to check out the translation rules:
25
+
26
+ 1. Each symbol defined in this file is either a class, a module
27
+ function, or a constant. _No instance methods are defined here_.
28
+
29
+ 2. Each symbol defined in this file follows the same naming convention
30
+ as the GPGME API. That is, symbol names are followed by `gpgme_'
31
+ for functions, and `GPGME_' or `GPG_' for constants.
32
+
33
+ 3. Output arguments are wrapped in arrays. For example, the first
34
+ argument of `gpgme_data_new' has the type `gpgme_data_t *', and to
35
+ be used to hold a newly created gpgme_data_t object. The
36
+ corresponding Ruby interface expects an array (empty for typical
37
+ cases) for that. */
38
+
39
+ #include "ruby.h"
40
+ #include "gpgme.h"
41
+ #include <errno.h>
42
+
43
+ /* Define this if you use GPGME 1.1.2 and earlier.
44
+ https://bugs.g10code.com/gnupg/issue715 */
45
+ #ifdef RUBY_GPGME_NEED_WORKAROUND_KEYLIST_NEXT
46
+ #define CHECK_KEYLIST_IN_PROGRESS(vctx) \
47
+ if (rb_iv_get (vctx, "ruby_gpgme_keylist_in_progress") != Qtrue) \
48
+ return LONG2NUM(gpgme_error (GPG_ERR_INV_STATE))
49
+ #define CHECK_KEYLIST_NOT_IN_PROGRESS(vctx) \
50
+ if (rb_iv_get (vctx, "ruby_gpgme_keylist_in_progress") == Qtrue) \
51
+ return LONG2NUM(gpgme_error (GPG_ERR_INV_STATE))
52
+ #define SET_KEYLIST_IN_PROGRESS(vctx) \
53
+ rb_iv_set (vctx, "ruby_gpgme_keylist_in_progress", Qtrue)
54
+ #define RESET_KEYLIST_IN_PROGRESS(vctx) \
55
+ rb_iv_set (vctx, "ruby_gpgme_keylist_in_progress", Qfalse)
56
+ #else
57
+ #define CHECK_KEYLIST_IN_PROGRESS(vctx)
58
+ #define CHECK_KEYLIST_NOT_IN_PROGRESS(vctx)
59
+ #define SET_KEYLIST_IN_PROGRESS(vctx)
60
+ #define RESET_KEYLIST_IN_PROGRESS(vctx)
61
+ #endif
62
+
63
+ /* StringValuePtr is not available in 1.6. */
64
+ #ifndef StringValuePtr
65
+ #define StringValuePtr(str) RSTRING(str)->ptr
66
+ #endif
67
+
68
+ /* STR2CSTR is obsoleted in 1.8. */
69
+ #ifndef StringValueCStr
70
+ #define StringValueCStr STR2CSTR
71
+ #endif
72
+
73
+ /* RARRAY_LEN is not available in 1.8. */
74
+ #ifndef RARRAY_LEN
75
+ #define RARRAY_LEN(a) RARRAY(a)->len
76
+ #endif
77
+
78
+ /* RARRAY_PTR is not available in 1.8. */
79
+ #ifndef RARRAY_PTR
80
+ #define RARRAY_PTR(a) RARRAY(a)->ptr
81
+ #endif
82
+
83
+ /* RSTRING_LEN is not available in 1.8.5. */
84
+ #ifndef RSTRING_LEN
85
+ #define RSTRING_LEN(a) RSTRING(a)->len
86
+ #endif
87
+
88
+ #define WRAP_GPGME_DATA(dh) \
89
+ Data_Wrap_Struct(cData, 0, gpgme_data_release, dh)
90
+ /* `gpgme_data_t' is typedef'ed as `struct gpgme_data *'. */
91
+ #define UNWRAP_GPGME_DATA(vdh, dh) \
92
+ Data_Get_Struct(vdh, struct gpgme_data, dh);
93
+
94
+ #define WRAP_GPGME_CTX(ctx) \
95
+ Data_Wrap_Struct(cCtx, 0, gpgme_release, ctx)
96
+ /* `gpgme_ctx_t' is typedef'ed as `struct gpgme_context *'. */
97
+ #define UNWRAP_GPGME_CTX(vctx, ctx) \
98
+ Data_Get_Struct(vctx, struct gpgme_context, ctx)
99
+
100
+ #define WRAP_GPGME_KEY(key) \
101
+ Data_Wrap_Struct(cKey, 0, gpgme_key_unref, key)
102
+ /* `gpgme_key_t' is typedef'ed as `struct _gpgme_key *'. */
103
+ #define UNWRAP_GPGME_KEY(vkey, key) \
104
+ Data_Get_Struct(vkey, struct _gpgme_key, key)
105
+
106
+ #define WRAP_GPGME_TRUST_ITEM(item) \
107
+ Data_Wrap_Struct(cTrustItem, 0, gpgme_trust_item_unref, item)
108
+ /* `gpgme_trust_item_t' is typedef'ed as `struct _gpgme_trust_item *'. */
109
+ #define UNWRAP_GPGME_TRUST_ITEM(vitem, item) \
110
+ Data_Get_Struct(vitem, struct _gpgme_trust_item, item)
111
+
112
+ static VALUE cEngineInfo,
113
+ cCtx,
114
+ cData,
115
+ cKey,
116
+ cSubKey,
117
+ cUserID,
118
+ cKeySig,
119
+ cInvalidKey,
120
+ cNewSignature,
121
+ cSignature,
122
+ cSigNotation,
123
+ cTrustItem,
124
+ cDecryptResult,
125
+ cVerifyResult,
126
+ cSignResult,
127
+ cEncryptResult,
128
+ cImportStatus,
129
+ cImportResult;
130
+
131
+ static VALUE
132
+ rb_s_gpgme_check_version (VALUE dummy, VALUE vreq)
133
+ {
134
+ const char *result = gpgme_check_version (NIL_P(vreq) ? NULL :
135
+ StringValueCStr(vreq));
136
+ return result ? rb_str_new2 (result) : Qnil;
137
+ }
138
+
139
+ static VALUE
140
+ rb_s_gpgme_engine_check_version (VALUE dummy, VALUE vproto)
141
+ {
142
+ gpgme_error_t err = gpgme_engine_check_version (NUM2INT(vproto));
143
+ return LONG2NUM(err);
144
+ }
145
+
146
+ static VALUE
147
+ rb_s_gpgme_get_engine_info (VALUE dummy, VALUE rinfo)
148
+ {
149
+ gpgme_engine_info_t info;
150
+ gpgme_error_t err;
151
+ long idx;
152
+
153
+ err = gpgme_get_engine_info (&info);
154
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
155
+ {
156
+ for (idx = 0; info; info = info->next, idx++)
157
+ {
158
+ VALUE vinfo = rb_class_new_instance (0, NULL, cEngineInfo);
159
+ rb_iv_set (vinfo, "@protocol", INT2FIX(info->protocol));
160
+ if (info->file_name)
161
+ rb_iv_set (vinfo, "@file_name", rb_str_new2 (info->file_name));
162
+ if (info->version)
163
+ rb_iv_set (vinfo, "@version", rb_str_new2 (info->version));
164
+ if (info->req_version)
165
+ rb_iv_set (vinfo, "@req_version", rb_str_new2 (info->req_version));
166
+ if (info->home_dir)
167
+ rb_iv_set (vinfo, "@home_dir", rb_str_new2 (info->home_dir));
168
+ rb_ary_store (rinfo, idx, vinfo);
169
+ }
170
+ }
171
+ return LONG2NUM(err);
172
+ }
173
+
174
+ static VALUE
175
+ rb_s_gpgme_set_engine_info (VALUE dummy, VALUE vproto, VALUE vfile_name,
176
+ VALUE vhome_dir)
177
+ {
178
+ gpgme_error_t err = gpgme_set_engine_info (NUM2INT(vproto),
179
+ NIL_P(vfile_name) ? NULL :
180
+ StringValueCStr(vfile_name),
181
+ NIL_P(vhome_dir) ? NULL :
182
+ StringValueCStr(vhome_dir));
183
+ return LONG2NUM(err);
184
+ }
185
+
186
+ static VALUE
187
+ rb_s_gpgme_pubkey_algo_name (VALUE dummy, VALUE valgo)
188
+ {
189
+ const char *name = gpgme_pubkey_algo_name (NUM2INT(valgo));
190
+ if (name)
191
+ return rb_str_new2 (name);
192
+ return Qnil;
193
+ }
194
+
195
+ static VALUE
196
+ rb_s_gpgme_hash_algo_name (VALUE dummy, VALUE valgo)
197
+ {
198
+ const char *name = gpgme_hash_algo_name (NUM2INT(valgo));
199
+ if (name)
200
+ return rb_str_new2 (name);
201
+ return Qnil;
202
+ }
203
+
204
+ static VALUE
205
+ rb_s_gpgme_err_code (VALUE dummy, VALUE verr)
206
+ {
207
+ return INT2FIX(gpgme_err_code (NUM2LONG(verr)));
208
+ }
209
+
210
+ static VALUE
211
+ rb_s_gpgme_err_source (VALUE dummy, VALUE verr)
212
+ {
213
+ return INT2FIX(gpgme_err_source (NUM2LONG(verr)));
214
+ }
215
+
216
+ static VALUE
217
+ rb_s_gpgme_strerror (VALUE dummy, VALUE verr)
218
+ {
219
+ return rb_str_new2 (gpgme_strerror (NUM2LONG(verr)));
220
+ }
221
+
222
+ static VALUE
223
+ rb_s_gpgme_data_new (VALUE dummy, VALUE rdh)
224
+ {
225
+ gpgme_data_t dh;
226
+ gpgme_error_t err = gpgme_data_new (&dh);
227
+
228
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
229
+ rb_ary_store (rdh, 0, WRAP_GPGME_DATA(dh));
230
+ return LONG2NUM(err);
231
+ }
232
+
233
+ static VALUE
234
+ rb_s_gpgme_data_new_from_mem (VALUE dummy, VALUE rdh, VALUE vbuffer,
235
+ VALUE vsize)
236
+ {
237
+ gpgme_data_t dh;
238
+ VALUE vdh;
239
+ size_t size = NUM2UINT(vsize);
240
+ gpgme_error_t err;
241
+
242
+ if (RSTRING_LEN(vbuffer) < size)
243
+ rb_raise (rb_eArgError, "argument out of range");
244
+
245
+ err = gpgme_data_new_from_mem (&dh, StringValuePtr(vbuffer), size, 1);
246
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
247
+ {
248
+ vdh = WRAP_GPGME_DATA(dh);
249
+ rb_ary_store (rdh, 0, vdh);
250
+ }
251
+ return LONG2NUM(err);
252
+ }
253
+
254
+ static VALUE
255
+ rb_s_gpgme_data_new_from_fd (VALUE dummy, VALUE rdh, VALUE vfd)
256
+ {
257
+ gpgme_data_t dh;
258
+ gpgme_error_t err = gpgme_data_new_from_fd (&dh, NUM2INT(vfd));
259
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
260
+ rb_ary_store (rdh, 0, WRAP_GPGME_DATA(dh));
261
+ return LONG2NUM(err);
262
+ }
263
+
264
+ static ssize_t
265
+ read_cb (void *handle, void *buffer, size_t size)
266
+ {
267
+ VALUE vcb = (VALUE)handle, vcbs, vhook_value, vbuffer;
268
+
269
+ vcbs = RARRAY_PTR(vcb)[0];
270
+ vhook_value = RARRAY_PTR(vcb)[1];
271
+
272
+ vbuffer = rb_funcall (vcbs, rb_intern ("read"), 2, vhook_value,
273
+ LONG2NUM(size));
274
+ if (NIL_P(vbuffer))
275
+ return 0;
276
+ memcpy (buffer, StringValuePtr(vbuffer), RSTRING_LEN(vbuffer));
277
+ return RSTRING_LEN(vbuffer);
278
+ }
279
+
280
+ static ssize_t
281
+ write_cb (void *handle, const void *buffer, size_t size)
282
+ {
283
+ VALUE vcb = (VALUE)handle, vcbs, vhook_value, vbuffer, vnwrite;
284
+
285
+ vcbs = RARRAY_PTR(vcb)[0];
286
+ vhook_value = RARRAY_PTR(vcb)[1];
287
+ vbuffer = rb_str_new (buffer, size);
288
+
289
+ vnwrite = rb_funcall (vcbs, rb_intern ("write"), 3,
290
+ vhook_value, vbuffer, LONG2NUM(size));
291
+ return NUM2LONG(vnwrite);
292
+ }
293
+
294
+ static off_t
295
+ seek_cb (void *handle, off_t offset, int whence)
296
+ {
297
+ VALUE vcb = (VALUE)handle, vcbs, vhook_value, vpos;
298
+ ID id_seek = rb_intern ("seek");
299
+
300
+ vcbs = RARRAY_PTR(vcb)[0];
301
+ vhook_value = RARRAY_PTR(vcb)[1];
302
+
303
+ if (rb_respond_to (vcbs, id_seek))
304
+ {
305
+ vpos = rb_funcall (vcbs, id_seek, 3,
306
+ vhook_value, LONG2NUM(offset), INT2FIX(whence));
307
+ return NUM2LONG(vpos);
308
+ }
309
+ errno = ENOSYS;
310
+ return -1;
311
+ }
312
+
313
+ static struct gpgme_data_cbs cbs =
314
+ {
315
+ .read = read_cb,
316
+ .write = write_cb,
317
+ .seek = seek_cb,
318
+ .release = NULL
319
+ };
320
+
321
+ static VALUE
322
+ rb_s_gpgme_data_new_from_cbs (VALUE dummy, VALUE rdh, VALUE vcbs,
323
+ VALUE vhandle)
324
+ {
325
+ gpgme_data_t dh;
326
+ gpgme_error_t err;
327
+ VALUE vcbs_handle = rb_ary_new ();
328
+
329
+ rb_ary_push (vcbs_handle, vcbs);
330
+ rb_ary_push (vcbs_handle, vhandle);
331
+
332
+ err = gpgme_data_new_from_cbs (&dh, &cbs, (void*)vcbs_handle);
333
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
334
+ {
335
+ VALUE vdh = WRAP_GPGME_DATA(dh);
336
+ /* Keep a reference to avoid GC. */
337
+ rb_iv_set (vdh, "@cbs_handle", vcbs_handle);
338
+ rb_ary_store (rdh, 0, vdh);
339
+ }
340
+ return LONG2NUM(err);
341
+ }
342
+
343
+ static VALUE
344
+ rb_s_gpgme_data_read (VALUE dummy, VALUE vdh, VALUE vlength)
345
+ {
346
+ gpgme_data_t dh;
347
+ ssize_t length = NUM2LONG(vlength), nread;
348
+ void *buffer;
349
+ VALUE vbuffer = Qnil;
350
+
351
+ UNWRAP_GPGME_DATA(vdh, dh);
352
+
353
+ buffer = ALLOC_N (char, length);
354
+ nread = gpgme_data_read (dh, buffer, length);
355
+ if (nread > 0)
356
+ vbuffer = rb_str_new (buffer, nread);
357
+ xfree (buffer);
358
+ if (nread < 0)
359
+ rb_sys_fail ("rb_s_gpgme_data_read");
360
+ return vbuffer;
361
+ }
362
+
363
+ static VALUE
364
+ rb_s_gpgme_data_seek (VALUE dummy, VALUE vdh, VALUE voffset, VALUE vwhence)
365
+ {
366
+ gpgme_data_t dh;
367
+ off_t pos;
368
+
369
+ UNWRAP_GPGME_DATA(vdh, dh);
370
+ pos = gpgme_data_seek (dh, NUM2LONG(voffset), NUM2INT(vwhence));
371
+ if (pos < 0)
372
+ rb_sys_fail ("rb_s_gpgme_data_seek");
373
+ return LONG2NUM(pos);
374
+ }
375
+
376
+ static VALUE
377
+ rb_s_gpgme_data_write (VALUE dummy, VALUE vdh, VALUE vbuf, VALUE vlen)
378
+ {
379
+ gpgme_data_t dh;
380
+ ssize_t nwrite;
381
+
382
+ UNWRAP_GPGME_DATA(vdh, dh);
383
+ nwrite = gpgme_data_write (dh, StringValuePtr(vbuf), NUM2UINT(vlen));
384
+ if (nwrite < 0)
385
+ rb_sys_fail ("rb_s_gpgme_data_write");
386
+ return LONG2NUM(nwrite);
387
+ }
388
+
389
+ static VALUE
390
+ rb_s_gpgme_data_get_encoding (VALUE dummy, VALUE vdh)
391
+ {
392
+ gpgme_data_t dh;
393
+ gpgme_error_t err;
394
+
395
+ UNWRAP_GPGME_DATA(vdh, dh);
396
+ err = gpgme_data_get_encoding (dh);
397
+ return LONG2NUM(err);
398
+ }
399
+
400
+ static VALUE
401
+ rb_s_gpgme_data_set_encoding (VALUE dummy, VALUE vdh, VALUE venc)
402
+ {
403
+ gpgme_data_t dh;
404
+ gpgme_error_t err;
405
+
406
+ UNWRAP_GPGME_DATA(vdh, dh);
407
+ err = gpgme_data_set_encoding (dh, NUM2INT(venc));
408
+ return LONG2NUM(err);
409
+ }
410
+
411
+ static VALUE
412
+ rb_s_gpgme_new (VALUE dummy, VALUE rctx)
413
+ {
414
+ gpgme_ctx_t ctx;
415
+ gpgme_error_t err = gpgme_new (&ctx);
416
+
417
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
418
+ rb_ary_store (rctx, 0, WRAP_GPGME_CTX(ctx));
419
+ return LONG2NUM(err);
420
+ }
421
+
422
+ static VALUE
423
+ rb_s_gpgme_release (VALUE dummy, VALUE vctx)
424
+ {
425
+ gpgme_ctx_t ctx;
426
+
427
+ UNWRAP_GPGME_CTX(vctx, ctx);
428
+ if (!ctx)
429
+ rb_raise (rb_eArgError, "released ctx");
430
+ gpgme_release (ctx);
431
+ DATA_PTR(vctx) = NULL;
432
+ return Qnil;
433
+ }
434
+
435
+ static VALUE
436
+ rb_s_gpgme_set_protocol (VALUE dummy, VALUE vctx, VALUE vproto)
437
+ {
438
+ gpgme_ctx_t ctx;
439
+ gpgme_error_t err;
440
+
441
+ UNWRAP_GPGME_CTX(vctx, ctx);
442
+ if (!ctx)
443
+ rb_raise (rb_eArgError, "released ctx");
444
+ err = gpgme_set_protocol (ctx, NUM2INT(vproto));
445
+ return LONG2NUM(err);
446
+ }
447
+
448
+ static VALUE
449
+ rb_s_gpgme_get_protocol (VALUE dummy, VALUE vctx)
450
+ {
451
+ gpgme_ctx_t ctx;
452
+ gpgme_protocol_t proto;
453
+
454
+ UNWRAP_GPGME_CTX(vctx, ctx);
455
+ if (!ctx)
456
+ rb_raise (rb_eArgError, "released ctx");
457
+ proto = gpgme_get_protocol (ctx);
458
+ return INT2FIX(proto);
459
+ }
460
+
461
+ static VALUE
462
+ rb_s_gpgme_set_armor (VALUE dummy, VALUE vctx, VALUE vyes)
463
+ {
464
+ gpgme_ctx_t ctx;
465
+
466
+ UNWRAP_GPGME_CTX(vctx, ctx);
467
+ if (!ctx)
468
+ rb_raise (rb_eArgError, "released ctx");
469
+ gpgme_set_armor (ctx, NUM2INT(vyes));
470
+
471
+ return Qnil;
472
+ }
473
+
474
+ static VALUE
475
+ rb_s_gpgme_get_armor (VALUE dummy, VALUE vctx)
476
+ {
477
+ gpgme_ctx_t ctx;
478
+ int yes;
479
+
480
+ UNWRAP_GPGME_CTX(vctx, ctx);
481
+ if (!ctx)
482
+ rb_raise (rb_eArgError, "released ctx");
483
+ yes = gpgme_get_armor (ctx);
484
+ return INT2FIX(yes);
485
+ }
486
+
487
+ static VALUE
488
+ rb_s_gpgme_set_textmode (VALUE dummy, VALUE vctx, VALUE vyes)
489
+ {
490
+ gpgme_ctx_t ctx;
491
+
492
+ UNWRAP_GPGME_CTX(vctx, ctx);
493
+ if (!ctx)
494
+ rb_raise (rb_eArgError, "released ctx");
495
+ gpgme_set_textmode (ctx, NUM2INT(vyes));
496
+ return Qnil;
497
+ }
498
+
499
+ static VALUE
500
+ rb_s_gpgme_get_textmode (VALUE dummy, VALUE vctx)
501
+ {
502
+ gpgme_ctx_t ctx;
503
+ int yes;
504
+
505
+ UNWRAP_GPGME_CTX(vctx, ctx);
506
+ if (!ctx)
507
+ rb_raise (rb_eArgError, "released ctx");
508
+ yes = gpgme_get_textmode (ctx);
509
+ return INT2FIX(yes);
510
+ }
511
+
512
+ static VALUE
513
+ rb_s_gpgme_set_include_certs (VALUE dummy, VALUE vctx, VALUE vnr_of_certs)
514
+ {
515
+ gpgme_ctx_t ctx;
516
+
517
+ UNWRAP_GPGME_CTX(vctx, ctx);
518
+ if (!ctx)
519
+ rb_raise (rb_eArgError, "released ctx");
520
+ gpgme_set_include_certs (ctx, NUM2INT(vnr_of_certs));
521
+ return Qnil;
522
+ }
523
+
524
+ static VALUE
525
+ rb_s_gpgme_get_include_certs (VALUE dummy, VALUE vctx)
526
+ {
527
+ gpgme_ctx_t ctx;
528
+ gpgme_error_t err;
529
+
530
+ UNWRAP_GPGME_CTX(vctx, ctx);
531
+ if (!ctx)
532
+ rb_raise (rb_eArgError, "released ctx");
533
+ err = gpgme_get_include_certs (ctx);
534
+ return LONG2NUM(err);
535
+ }
536
+
537
+ static VALUE
538
+ rb_s_gpgme_set_keylist_mode (VALUE dummy, VALUE vctx, VALUE vmode)
539
+ {
540
+ gpgme_ctx_t ctx;
541
+ gpgme_error_t err;
542
+
543
+ UNWRAP_GPGME_CTX(vctx, ctx);
544
+ if (!ctx)
545
+ rb_raise (rb_eArgError, "released ctx");
546
+ err = gpgme_set_keylist_mode (ctx, NUM2INT(vmode));
547
+ return LONG2NUM(err);
548
+ }
549
+
550
+ static VALUE
551
+ rb_s_gpgme_get_keylist_mode (VALUE dummy, VALUE vctx)
552
+ {
553
+ gpgme_ctx_t ctx;
554
+ int mode;
555
+
556
+ UNWRAP_GPGME_CTX(vctx, ctx);
557
+ if (!ctx)
558
+ rb_raise (rb_eArgError, "released ctx");
559
+ mode = gpgme_get_keylist_mode (ctx);
560
+ return INT2FIX(mode);
561
+ }
562
+
563
+ static gpgme_error_t
564
+ passphrase_cb (void *hook, const char *uid_hint, const char *passphrase_info,
565
+ int prev_was_bad, int fd)
566
+ {
567
+ VALUE vcb = (VALUE)hook, vpassfunc, vhook_value;
568
+
569
+ vpassfunc = RARRAY_PTR(vcb)[0];
570
+ vhook_value = RARRAY_PTR(vcb)[1];
571
+
572
+ rb_funcall (vpassfunc, rb_intern ("call"), 5,
573
+ vhook_value,
574
+ uid_hint ? rb_str_new2 (uid_hint) : Qnil,
575
+ passphrase_info ? rb_str_new2 (passphrase_info) : Qnil,
576
+ INT2FIX(prev_was_bad),
577
+ INT2NUM(fd));
578
+ return gpgme_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_NO_ERROR);
579
+ }
580
+
581
+ static VALUE
582
+ rb_s_gpgme_set_passphrase_cb (VALUE dummy, VALUE vctx, VALUE vpassfunc,
583
+ VALUE vhook_value)
584
+ {
585
+ gpgme_ctx_t ctx;
586
+ VALUE vcb = rb_ary_new ();
587
+
588
+ rb_ary_push (vcb, vpassfunc);
589
+ rb_ary_push (vcb, vhook_value);
590
+ /* Keep a reference to avoid GC. */
591
+ rb_iv_set (vctx, "@passphrase_cb", vcb);
592
+
593
+ UNWRAP_GPGME_CTX(vctx, ctx);
594
+ if (!ctx)
595
+ rb_raise (rb_eArgError, "released ctx");
596
+ gpgme_set_passphrase_cb (ctx, passphrase_cb, (void*)vcb);
597
+ return Qnil;
598
+ }
599
+
600
+ static VALUE
601
+ rb_s_gpgme_get_passphrase_cb (VALUE dummy, VALUE vctx, VALUE rpassfunc,
602
+ VALUE rhook_value)
603
+ {
604
+ VALUE vcb = rb_iv_get (vctx, "@passphrase_cb");
605
+
606
+ /* No need to call gpgme_get_passphrase_cb. */
607
+ rb_ary_store (rpassfunc, 0, RARRAY_PTR(vcb)[0]);
608
+ rb_ary_store (rhook_value, 0, RARRAY_PTR(vcb)[1]);
609
+ return Qnil;
610
+ }
611
+
612
+ static void
613
+ progress_cb (void *hook, const char *what, int type, int current, int total)
614
+ {
615
+ VALUE vcb = (VALUE)hook, vprogfunc, vhook_value;
616
+
617
+ vprogfunc = RARRAY_PTR(vcb)[0];
618
+ vhook_value = RARRAY_PTR(vcb)[1];
619
+
620
+ rb_funcall (vprogfunc, rb_intern ("call"), 5, vhook_value,
621
+ rb_str_new2 (what), INT2NUM(type), INT2NUM(current),
622
+ INT2NUM(total));
623
+ }
624
+
625
+ static VALUE
626
+ rb_s_gpgme_set_progress_cb (VALUE dummy, VALUE vctx, VALUE vprogfunc,
627
+ VALUE vhook_value)
628
+ {
629
+ gpgme_ctx_t ctx;
630
+ VALUE vcb = rb_ary_new ();
631
+
632
+ rb_ary_push (vcb, vprogfunc);
633
+ rb_ary_push (vcb, vhook_value);
634
+ /* Keep a reference to avoid GC. */
635
+ rb_iv_set (vctx, "@progress_cb", vcb);
636
+
637
+ UNWRAP_GPGME_CTX(vctx, ctx);
638
+ if (!ctx)
639
+ rb_raise (rb_eArgError, "released ctx");
640
+ gpgme_set_progress_cb (ctx, progress_cb, (void*)vcb);
641
+
642
+ return Qnil;
643
+ }
644
+
645
+ static VALUE
646
+ rb_s_gpgme_get_progress_cb (VALUE dummy, VALUE vctx, VALUE rprogfunc,
647
+ VALUE rhook_value)
648
+ {
649
+ VALUE vcb = rb_iv_get (vctx, "@progress_cb");
650
+ rb_ary_store (rprogfunc, 0, RARRAY_PTR(vcb)[0]);
651
+ rb_ary_store (rhook_value, 0, RARRAY_PTR(vcb)[1]);
652
+ return Qnil;
653
+ }
654
+
655
+ static VALUE
656
+ rb_s_gpgme_set_locale (VALUE dummy, VALUE vctx, VALUE vcategory, VALUE vvalue)
657
+ {
658
+ gpgme_ctx_t ctx;
659
+ gpgme_error_t err;
660
+
661
+ UNWRAP_GPGME_CTX(vctx, ctx);
662
+ if (!ctx)
663
+ rb_raise (rb_eArgError, "released ctx");
664
+
665
+ err = gpgme_set_locale (ctx, NUM2INT(vcategory), StringValueCStr(vvalue));
666
+ return LONG2NUM(err);
667
+ }
668
+
669
+ static VALUE
670
+ rb_s_gpgme_op_keylist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
671
+ VALUE vsecret_only)
672
+ {
673
+ gpgme_ctx_t ctx;
674
+ gpgme_error_t err;
675
+
676
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
677
+
678
+ UNWRAP_GPGME_CTX(vctx, ctx);
679
+ if (!ctx)
680
+ rb_raise (rb_eArgError, "released ctx");
681
+
682
+ err = gpgme_op_keylist_start (ctx, NIL_P(vpattern) ? NULL :
683
+ StringValueCStr(vpattern),
684
+ NUM2INT(vsecret_only));
685
+ if (gpgme_err_code (err) == GPG_ERR_NO_ERROR)
686
+ SET_KEYLIST_IN_PROGRESS(vctx);
687
+ return LONG2NUM(err);
688
+ }
689
+
690
+ static VALUE
691
+ rb_s_gpgme_op_keylist_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
692
+ VALUE vsecret_only)
693
+ {
694
+ gpgme_ctx_t ctx;
695
+ const char **pattern = NULL;
696
+ int i, err;
697
+
698
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
699
+
700
+ UNWRAP_GPGME_CTX(vctx, ctx);
701
+ if (!ctx)
702
+ rb_raise (rb_eArgError, "released ctx");
703
+
704
+ if (!NIL_P(vpattern))
705
+ {
706
+ /* Convert RARRAY into `const char *' array. */
707
+ pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern) + 1);
708
+ for (i = 0; i<RARRAY_LEN(vpattern); i++)
709
+ pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
710
+ pattern[RARRAY_LEN(vpattern)] = NULL;
711
+ }
712
+
713
+ err = gpgme_op_keylist_ext_start (ctx, pattern, NUM2INT(vsecret_only), 0);
714
+ if (gpgme_err_code (err) == GPG_ERR_NO_ERROR)
715
+ SET_KEYLIST_IN_PROGRESS(vctx);
716
+ if (pattern)
717
+ xfree (pattern);
718
+ return LONG2NUM(err);
719
+ }
720
+
721
+ static VALUE
722
+ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
723
+ {
724
+ VALUE vsubkeys, vuids;
725
+ gpgme_subkey_t subkey;
726
+ gpgme_user_id_t user_id;
727
+
728
+ rb_iv_set (vkey, "@keylist_mode", INT2FIX(key->keylist_mode));
729
+ rb_iv_set (vkey, "@revoked", INT2FIX(key->revoked));
730
+ rb_iv_set (vkey, "@expired", INT2FIX(key->expired));
731
+ rb_iv_set (vkey, "@disabled", INT2FIX(key->disabled));
732
+ rb_iv_set (vkey, "@invalid", INT2FIX(key->invalid));
733
+ rb_iv_set (vkey, "@can_encrypt", INT2FIX(key->can_encrypt));
734
+ rb_iv_set (vkey, "@can_sign", INT2FIX(key->can_sign));
735
+ rb_iv_set (vkey, "@can_certify", INT2FIX(key->can_certify));
736
+ rb_iv_set (vkey, "@can_authenticate", INT2FIX(key->can_authenticate));
737
+ rb_iv_set (vkey, "@secret", INT2FIX(key->secret));
738
+ rb_iv_set (vkey, "@protocol", INT2FIX(key->protocol));
739
+ if (key->issuer_serial)
740
+ rb_iv_set (vkey, "@issuer_serial", rb_str_new2 (key->issuer_serial));
741
+ if (key->issuer_name)
742
+ rb_iv_set (vkey, "@issuer_name", rb_str_new2 (key->issuer_name));
743
+ if (key->chain_id)
744
+ rb_iv_set (vkey, "@chain_id", rb_str_new2 (key->chain_id));
745
+ rb_iv_set (vkey, "@owner_trust", INT2FIX(key->owner_trust));
746
+ vsubkeys = rb_ary_new ();
747
+ rb_iv_set (vkey, "@subkeys", vsubkeys);
748
+ for (subkey = key->subkeys; subkey; subkey = subkey->next)
749
+ {
750
+ VALUE vsubkey = rb_class_new_instance(0, NULL, cSubKey);
751
+ rb_iv_set (vsubkey, "@revoked", INT2FIX(subkey->revoked));
752
+ rb_iv_set (vsubkey, "@expired", INT2FIX(subkey->expired));
753
+ rb_iv_set (vsubkey, "@disabled", INT2FIX(subkey->disabled));
754
+ rb_iv_set (vsubkey, "@invalid", INT2FIX(subkey->invalid));
755
+ rb_iv_set (vsubkey, "@can_encrypt", INT2FIX(subkey->can_encrypt));
756
+ rb_iv_set (vsubkey, "@can_sign", INT2FIX(subkey->can_sign));
757
+ rb_iv_set (vsubkey, "@can_certify", INT2FIX(subkey->can_certify));
758
+ rb_iv_set (vsubkey, "@can_authenticate",
759
+ INT2FIX(subkey->can_authenticate));
760
+ rb_iv_set (vsubkey, "@secret", INT2FIX(subkey->secret));
761
+ rb_iv_set (vsubkey, "@pubkey_algo", INT2FIX(subkey->pubkey_algo));
762
+ rb_iv_set (vsubkey, "@length", UINT2NUM(subkey->length));
763
+ rb_iv_set (vsubkey, "@keyid", rb_str_new2 (subkey->keyid));
764
+ if (subkey->fpr)
765
+ rb_iv_set (vsubkey, "@fpr", rb_str_new2 (subkey->fpr));
766
+ rb_iv_set (vsubkey, "@timestamp", LONG2NUM(subkey->timestamp));
767
+ rb_iv_set (vsubkey, "@expires", LONG2NUM(subkey->expires));
768
+ rb_ary_push (vsubkeys, vsubkey);
769
+ }
770
+ vuids = rb_ary_new ();
771
+ rb_iv_set (vkey, "@uids", vuids);
772
+ for (user_id = key->uids; user_id; user_id = user_id->next)
773
+ {
774
+ VALUE vuser_id = rb_class_new_instance(0, NULL, cUserID), vsignatures;
775
+ rb_iv_set (vuser_id, "@revoked", INT2FIX(user_id->revoked));
776
+ rb_iv_set (vuser_id, "@invalid", INT2FIX(user_id->invalid));
777
+ 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));
782
+
783
+ vsignatures = rb_ary_new ();
784
+ rb_iv_set (vuser_id, "@signatures", vsignatures);
785
+ gpgme_key_sig_t key_sig;
786
+ for (key_sig = user_id->signatures; key_sig; key_sig = key_sig->next)
787
+ {
788
+ VALUE vkey_sig = rb_class_new_instance(0, NULL, cKeySig);
789
+ rb_iv_set (vkey_sig, "@revoked", INT2FIX(key_sig->revoked));
790
+ rb_iv_set (vkey_sig, "@expired", INT2FIX(key_sig->expired));
791
+ rb_iv_set (vkey_sig, "@invalid", INT2FIX(key_sig->invalid));
792
+ rb_iv_set (vkey_sig, "@exportable", INT2FIX(key_sig->exportable));
793
+ rb_iv_set (vkey_sig, "@pubkey_algo", INT2FIX(key_sig->pubkey_algo));
794
+ rb_iv_set (vkey_sig, "@keyid", rb_str_new2 (key_sig->keyid));
795
+ rb_iv_set (vkey_sig, "@timestamp", LONG2NUM(key_sig->timestamp));
796
+ rb_iv_set (vkey_sig, "@expires", LONG2NUM(key_sig->expires));
797
+ rb_ary_push (vsignatures, vkey_sig);
798
+ }
799
+ rb_ary_push (vuids, vuser_id);
800
+ }
801
+ return vkey;
802
+ }
803
+
804
+ static VALUE
805
+ rb_s_gpgme_op_keylist_next (VALUE dummy, VALUE vctx, VALUE rkey)
806
+ {
807
+ gpgme_ctx_t ctx;
808
+ gpgme_key_t key;
809
+ gpgme_error_t err;
810
+
811
+ CHECK_KEYLIST_IN_PROGRESS(vctx);
812
+
813
+ UNWRAP_GPGME_CTX(vctx, ctx);
814
+ if (!ctx)
815
+ rb_raise (rb_eArgError, "released ctx");
816
+
817
+ err = gpgme_op_keylist_next (ctx, &key);
818
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
819
+ {
820
+ VALUE vkey = WRAP_GPGME_KEY(key);
821
+ save_gpgme_key_attrs (vkey, key);
822
+ rb_ary_store (rkey, 0, vkey);
823
+ }
824
+ return LONG2NUM(err);
825
+ }
826
+
827
+ static VALUE
828
+ rb_s_gpgme_op_keylist_end (VALUE dummy, VALUE vctx)
829
+ {
830
+ gpgme_ctx_t ctx;
831
+ gpgme_error_t err;
832
+
833
+ CHECK_KEYLIST_IN_PROGRESS(vctx);
834
+
835
+ UNWRAP_GPGME_CTX(vctx, ctx);
836
+ if (!ctx)
837
+ rb_raise (rb_eArgError, "released ctx");
838
+
839
+ err = gpgme_op_keylist_end (ctx);
840
+ RESET_KEYLIST_IN_PROGRESS(vctx);
841
+ return LONG2NUM(err);
842
+ }
843
+
844
+ static VALUE
845
+ rb_s_gpgme_get_key (VALUE dummy, VALUE vctx, VALUE vfpr, VALUE rkey,
846
+ VALUE vsecret)
847
+ {
848
+ gpgme_ctx_t ctx;
849
+ gpgme_error_t err;
850
+ gpgme_key_t key;
851
+
852
+ UNWRAP_GPGME_CTX(vctx, ctx);
853
+ if (!ctx)
854
+ rb_raise (rb_eArgError, "released ctx");
855
+ err = gpgme_get_key (ctx, StringValueCStr(vfpr), &key, NUM2INT(vsecret));
856
+
857
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
858
+ {
859
+ VALUE vkey = WRAP_GPGME_KEY(key);
860
+ save_gpgme_key_attrs (vkey, key);
861
+ rb_ary_store (rkey, 0, vkey);
862
+ }
863
+ return LONG2NUM(err);
864
+ }
865
+
866
+ static VALUE
867
+ rb_s_gpgme_op_genkey (VALUE dummy, VALUE vctx, VALUE vparms, VALUE vpubkey,
868
+ VALUE vseckey)
869
+ {
870
+ gpgme_ctx_t ctx;
871
+ gpgme_data_t pubkey = NULL, seckey = NULL;
872
+ gpgme_error_t err;
873
+
874
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
875
+
876
+ UNWRAP_GPGME_CTX(vctx, ctx);
877
+ if (!ctx)
878
+ rb_raise (rb_eArgError, "released ctx");
879
+ if (!NIL_P(vpubkey))
880
+ UNWRAP_GPGME_DATA(vpubkey, pubkey);
881
+ if (!NIL_P(vseckey))
882
+ UNWRAP_GPGME_DATA(vseckey, seckey);
883
+
884
+ err = gpgme_op_genkey (ctx, StringValueCStr(vparms), pubkey, seckey);
885
+ return LONG2NUM(err);
886
+ }
887
+
888
+ static VALUE
889
+ rb_s_gpgme_op_genkey_start (VALUE dummy, VALUE vctx, VALUE vparms,
890
+ VALUE vpubkey, VALUE vseckey)
891
+ {
892
+ gpgme_ctx_t ctx;
893
+ gpgme_data_t pubkey = NULL, seckey = NULL;
894
+ gpgme_error_t err;
895
+
896
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
897
+
898
+ UNWRAP_GPGME_CTX(vctx, ctx);
899
+ if (!ctx)
900
+ rb_raise (rb_eArgError, "released ctx");
901
+ if (!NIL_P(vpubkey))
902
+ UNWRAP_GPGME_DATA(vpubkey, pubkey);
903
+ if (!NIL_P(vseckey))
904
+ UNWRAP_GPGME_DATA(vseckey, seckey);
905
+
906
+ err = gpgme_op_genkey_start (ctx, StringValueCStr(vparms), pubkey, seckey);
907
+ return LONG2NUM(err);
908
+ }
909
+
910
+ static VALUE
911
+ rb_s_gpgme_op_export (VALUE dummy, VALUE vctx, VALUE vpattern, VALUE vmode,
912
+ VALUE vkeydata)
913
+ {
914
+ gpgme_ctx_t ctx;
915
+ gpgme_data_t keydata;
916
+ gpgme_error_t err;
917
+
918
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
919
+
920
+ UNWRAP_GPGME_CTX(vctx, ctx);
921
+ if (!ctx)
922
+ rb_raise (rb_eArgError, "released ctx");
923
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
924
+
925
+ err = gpgme_op_export (ctx, StringValueCStr(vpattern), NUM2UINT(vmode),
926
+ keydata);
927
+ return LONG2NUM(err);
928
+ }
929
+
930
+ static VALUE
931
+ rb_s_gpgme_op_export_start (VALUE dummy, VALUE vctx, VALUE vpattern,
932
+ VALUE vmode, VALUE vkeydata)
933
+ {
934
+ gpgme_ctx_t ctx;
935
+ gpgme_data_t keydata;
936
+ gpgme_error_t err;
937
+
938
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
939
+
940
+ UNWRAP_GPGME_CTX(vctx, ctx);
941
+ if (!ctx)
942
+ rb_raise (rb_eArgError, "released ctx");
943
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
944
+
945
+ err = gpgme_op_export_start (ctx, StringValueCStr(vpattern),
946
+ NUM2UINT(vmode), keydata);
947
+ return LONG2NUM(err);
948
+ }
949
+
950
+ static VALUE
951
+ rb_s_gpgme_op_export_ext (VALUE dummy, VALUE vctx, VALUE vpattern, VALUE vmode,
952
+ VALUE vkeydata)
953
+ {
954
+ gpgme_ctx_t ctx;
955
+ gpgme_data_t keydata;
956
+ gpgme_error_t err;
957
+ const char **pattern;
958
+ int i;
959
+
960
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
961
+
962
+ UNWRAP_GPGME_CTX(vctx, ctx);
963
+ if (!ctx)
964
+ rb_raise (rb_eArgError, "released ctx");
965
+ pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern));
966
+ for (i = 0; i < RARRAY_LEN(vpattern); i++)
967
+ pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
968
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
969
+
970
+ err = gpgme_op_export_ext (ctx, pattern, NUM2UINT(vmode), keydata);
971
+ return LONG2NUM(err);
972
+ }
973
+
974
+ static VALUE
975
+ rb_s_gpgme_op_export_ext_start (VALUE dummy, VALUE vctx, VALUE vpattern,
976
+ VALUE vmode, VALUE vkeydata)
977
+ {
978
+ gpgme_ctx_t ctx;
979
+ gpgme_data_t keydata;
980
+ gpgme_error_t err;
981
+ const char **pattern;
982
+ int i;
983
+
984
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
985
+
986
+ UNWRAP_GPGME_CTX(vctx, ctx);
987
+ if (!ctx)
988
+ rb_raise (rb_eArgError, "released ctx");
989
+ pattern = ALLOC_N(const char *, RARRAY_LEN(vpattern));
990
+ for (i = 0; i < RARRAY_LEN(vpattern); i++)
991
+ pattern[i] = StringValueCStr(RARRAY_PTR(vpattern)[i]);
992
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
993
+
994
+ err = gpgme_op_export_ext_start (ctx, pattern, NUM2UINT(vmode), keydata);
995
+ return LONG2NUM(err);
996
+ }
997
+
998
+ #ifdef HAVE_GPGME_OP_EXPORT_KEYS
999
+ static VALUE
1000
+ rb_s_gpgme_op_export_keys (VALUE dummy, VALUE vctx, VALUE vkeys,
1001
+ VALUE vmode, VALUE vkeydata)
1002
+ {
1003
+ gpgme_ctx_t ctx;
1004
+ gpgme_key_t *keys;
1005
+ gpgme_data_t keydata;
1006
+ gpgme_error_t err;
1007
+ int i;
1008
+
1009
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1010
+
1011
+ UNWRAP_GPGME_CTX(vctx, ctx);
1012
+ if (!ctx)
1013
+ rb_raise (rb_eArgError, "released ctx");
1014
+
1015
+ keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
1016
+ for (i = 0; i < RARRAY_LEN(vkeys); i++)
1017
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
1018
+
1019
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
1020
+
1021
+ err = gpgme_op_export_keys (ctx, keys, NUM2UINT(vmode), keydata);
1022
+ return LONG2NUM(err);
1023
+ }
1024
+
1025
+ static VALUE
1026
+ rb_s_gpgme_op_export_keys_start (VALUE dummy, VALUE vctx, VALUE vkeys,
1027
+ VALUE vmode, VALUE vkeydata)
1028
+ {
1029
+ gpgme_ctx_t ctx;
1030
+ gpgme_key_t *keys;
1031
+ gpgme_data_t keydata;
1032
+ gpgme_error_t err;
1033
+ int i;
1034
+
1035
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1036
+
1037
+ UNWRAP_GPGME_CTX(vctx, ctx);
1038
+ if (!ctx)
1039
+ rb_raise (rb_eArgError, "released ctx");
1040
+
1041
+ keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
1042
+ for (i = 0; i < RARRAY_LEN(vkeys); i++)
1043
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
1044
+
1045
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
1046
+
1047
+ err = gpgme_op_export_keys_start (ctx, keys, NUM2UINT(vmode), keydata);
1048
+ return LONG2NUM(err);
1049
+ }
1050
+ #endif /*HAVE_GPGME_OP_EXPORT_KEYS*/
1051
+
1052
+ static VALUE
1053
+ rb_s_gpgme_op_import (VALUE dummy, VALUE vctx, VALUE vkeydata)
1054
+ {
1055
+ gpgme_ctx_t ctx;
1056
+ gpgme_data_t keydata;
1057
+ gpgme_error_t err;
1058
+
1059
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1060
+
1061
+ UNWRAP_GPGME_CTX(vctx, ctx);
1062
+ if (!ctx)
1063
+ rb_raise (rb_eArgError, "released ctx");
1064
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
1065
+
1066
+ err = gpgme_op_import (ctx, keydata);
1067
+ return LONG2NUM(err);
1068
+ }
1069
+
1070
+ static VALUE
1071
+ rb_s_gpgme_op_import_start (VALUE dummy, VALUE vctx, VALUE vkeydata)
1072
+ {
1073
+ gpgme_ctx_t ctx;
1074
+ gpgme_data_t keydata;
1075
+ gpgme_error_t err;
1076
+
1077
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1078
+
1079
+ UNWRAP_GPGME_CTX(vctx, ctx);
1080
+ if (!ctx)
1081
+ rb_raise (rb_eArgError, "released ctx");
1082
+ UNWRAP_GPGME_DATA(vkeydata, keydata);
1083
+
1084
+ err = gpgme_op_import_start (ctx, keydata);
1085
+ return LONG2NUM(err);
1086
+ }
1087
+
1088
+ #ifdef HAVE_GPGME_OP_EXPORT_KEYS
1089
+ static VALUE
1090
+ rb_s_gpgme_op_import_keys (VALUE dummy, VALUE vctx, VALUE vkeys)
1091
+ {
1092
+ gpgme_ctx_t ctx;
1093
+ gpgme_key_t *keys;
1094
+ gpgme_error_t err;
1095
+ int i;
1096
+
1097
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1098
+
1099
+ UNWRAP_GPGME_CTX(vctx, ctx);
1100
+ if (!ctx)
1101
+ rb_raise (rb_eArgError, "released ctx");
1102
+
1103
+ keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
1104
+ for (i = 0; i < RARRAY_LEN(vkeys); i++)
1105
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
1106
+ keys[i] = NULL;
1107
+
1108
+ err = gpgme_op_import_keys (ctx, keys);
1109
+ return LONG2NUM(err);
1110
+ }
1111
+
1112
+ static VALUE
1113
+ rb_s_gpgme_op_import_keys_start (VALUE dummy, VALUE vctx, VALUE vkeys)
1114
+ {
1115
+ gpgme_ctx_t ctx;
1116
+ gpgme_key_t *keys;
1117
+ gpgme_error_t err;
1118
+ int i;
1119
+
1120
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1121
+
1122
+ UNWRAP_GPGME_CTX(vctx, ctx);
1123
+ if (!ctx)
1124
+ rb_raise (rb_eArgError, "released ctx");
1125
+
1126
+ keys = ALLOC_N(gpgme_key_t, RARRAY_LEN(vkeys) + 1);
1127
+ for (i = 0; i < RARRAY_LEN(vkeys); i++)
1128
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vkeys)[i], keys[i]);
1129
+ keys[i] = NULL;
1130
+
1131
+ err = gpgme_op_import_keys_start (ctx, keys);
1132
+ return LONG2NUM(err);
1133
+ }
1134
+ #endif /*HAVE_GPGME_OP_EXPORT_KEYS*/
1135
+
1136
+ static VALUE
1137
+ rb_s_gpgme_op_import_result (VALUE dummy, VALUE vctx)
1138
+ {
1139
+ gpgme_ctx_t ctx;
1140
+ gpgme_import_result_t result;
1141
+ gpgme_import_status_t status;
1142
+ VALUE vresult, vimports;
1143
+
1144
+ UNWRAP_GPGME_CTX(vctx, ctx);
1145
+ if (!ctx)
1146
+ rb_raise (rb_eArgError, "released ctx");
1147
+
1148
+ result = gpgme_op_import_result (ctx);
1149
+ vresult = rb_class_new_instance (0, NULL, cImportResult);
1150
+ rb_iv_set (vresult, "@considered", INT2NUM(result->considered));
1151
+ rb_iv_set (vresult, "@no_user_id", INT2NUM(result->no_user_id));
1152
+ rb_iv_set (vresult, "@imported", INT2NUM(result->imported));
1153
+ rb_iv_set (vresult, "@imported_rsa", INT2NUM(result->imported_rsa));
1154
+ rb_iv_set (vresult, "@unchanged", INT2NUM(result->unchanged));
1155
+ rb_iv_set (vresult, "@new_user_ids", INT2NUM(result->new_user_ids));
1156
+ rb_iv_set (vresult, "@new_sub_keys", INT2NUM(result->new_sub_keys));
1157
+ rb_iv_set (vresult, "@new_signatures", INT2NUM(result->new_signatures));
1158
+ rb_iv_set (vresult, "@new_revocations", INT2NUM(result->new_revocations));
1159
+ rb_iv_set (vresult, "@secret_read", INT2NUM(result->secret_read));
1160
+ rb_iv_set (vresult, "@secret_imported", INT2NUM(result->secret_imported));
1161
+ rb_iv_set (vresult, "@secret_unchanged", INT2NUM(result->secret_unchanged));
1162
+ rb_iv_set (vresult, "@not_imported", INT2NUM(result->not_imported));
1163
+ vimports = rb_ary_new ();
1164
+ rb_iv_set (vresult, "@imports", vimports);
1165
+ for (status = result->imports; status;
1166
+ status = status->next)
1167
+ {
1168
+ VALUE vstatus =
1169
+ rb_class_new_instance (0, NULL, cImportStatus);
1170
+ rb_iv_set (vstatus, "@fpr", rb_str_new2 (status->fpr));
1171
+ rb_iv_set (vstatus, "@result", LONG2NUM(status->result));
1172
+ rb_iv_set (vstatus, "@status", UINT2NUM(status->status));
1173
+ rb_ary_push (vimports, vstatus);
1174
+ }
1175
+ return vresult;
1176
+ }
1177
+
1178
+ static VALUE
1179
+ rb_s_gpgme_op_delete (VALUE dummy, VALUE vctx, VALUE vkey, VALUE vallow_secret)
1180
+ {
1181
+ gpgme_ctx_t ctx;
1182
+ gpgme_key_t key;
1183
+ gpgme_error_t err;
1184
+
1185
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1186
+
1187
+ UNWRAP_GPGME_CTX(vctx, ctx);
1188
+ if (!ctx)
1189
+ rb_raise (rb_eArgError, "released ctx");
1190
+ UNWRAP_GPGME_KEY(vkey, key);
1191
+
1192
+ err = gpgme_op_delete (ctx, key, NUM2INT(vallow_secret));
1193
+ return LONG2NUM(err);
1194
+ }
1195
+
1196
+ static VALUE
1197
+ rb_s_gpgme_op_delete_start (VALUE dummy, VALUE vctx, VALUE vkey,
1198
+ VALUE vallow_secret)
1199
+ {
1200
+ gpgme_ctx_t ctx;
1201
+ gpgme_key_t key;
1202
+ gpgme_error_t err;
1203
+
1204
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1205
+
1206
+ UNWRAP_GPGME_CTX(vctx, ctx);
1207
+ if (!ctx)
1208
+ rb_raise (rb_eArgError, "released ctx");
1209
+ UNWRAP_GPGME_KEY(vkey, key);
1210
+
1211
+ err = gpgme_op_delete_start (ctx, key, NUM2INT(vallow_secret));
1212
+ return LONG2NUM(err);
1213
+ }
1214
+
1215
+ static gpgme_error_t
1216
+ edit_cb (void *hook, gpgme_status_code_t status, const char *args, int fd)
1217
+ {
1218
+ VALUE vcb = (VALUE)hook, veditfunc, vhook_value;
1219
+
1220
+
1221
+ veditfunc = RARRAY_PTR(vcb)[0];
1222
+ vhook_value = RARRAY_PTR(vcb)[1];
1223
+
1224
+ rb_funcall (veditfunc, rb_intern ("call"), 4, vhook_value, INT2FIX(status),
1225
+ rb_str_new2 (args), INT2NUM(fd));
1226
+ return gpgme_err_make (GPG_ERR_SOURCE_USER_1, GPG_ERR_NO_ERROR);
1227
+ }
1228
+
1229
+ static VALUE
1230
+ rb_s_gpgme_op_edit (VALUE dummy, VALUE vctx, VALUE vkey,
1231
+ VALUE veditfunc, VALUE vhook_value, VALUE vout)
1232
+ {
1233
+ gpgme_ctx_t ctx;
1234
+ gpgme_key_t key;
1235
+ gpgme_data_t out = NULL;
1236
+ VALUE vcb;
1237
+ gpgme_error_t err;
1238
+
1239
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1240
+
1241
+ UNWRAP_GPGME_CTX(vctx, ctx);
1242
+ if (!ctx)
1243
+ rb_raise (rb_eArgError, "released ctx");
1244
+ UNWRAP_GPGME_KEY(vkey, key);
1245
+ if (!NIL_P(vout))
1246
+ UNWRAP_GPGME_DATA(vout, out);
1247
+
1248
+ vcb = rb_ary_new ();
1249
+ rb_ary_push (vcb, veditfunc);
1250
+ rb_ary_push (vcb, vhook_value);
1251
+ /* Keep a reference to avoid GC. */
1252
+ rb_iv_set (vctx, "@edit_cb", vcb);
1253
+
1254
+ err = gpgme_op_edit (ctx, key, edit_cb, (void *)vcb, out);
1255
+ return LONG2NUM(err);
1256
+ }
1257
+
1258
+ static VALUE
1259
+ rb_s_gpgme_op_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
1260
+ VALUE veditfunc, VALUE vhook_value, VALUE vout)
1261
+ {
1262
+ gpgme_ctx_t ctx;
1263
+ gpgme_key_t key;
1264
+ gpgme_data_t out = NULL;
1265
+ VALUE vcb;
1266
+ gpgme_error_t err;
1267
+
1268
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1269
+
1270
+ UNWRAP_GPGME_CTX(vctx, ctx);
1271
+ if (!ctx)
1272
+ rb_raise (rb_eArgError, "released ctx");
1273
+ UNWRAP_GPGME_KEY(vkey, key);
1274
+ if (!NIL_P(vout))
1275
+ UNWRAP_GPGME_DATA(vout, out);
1276
+
1277
+ vcb = rb_ary_new ();
1278
+ rb_ary_push (vcb, veditfunc);
1279
+ rb_ary_push (vcb, vhook_value);
1280
+ /* Keep a reference to avoid GC. */
1281
+ rb_iv_set (vctx, "@edit_cb", vcb);
1282
+
1283
+ err = gpgme_op_edit_start (ctx, key, edit_cb, (void *)vcb, out);
1284
+ return LONG2NUM(err);
1285
+ }
1286
+
1287
+ static VALUE
1288
+ rb_s_gpgme_op_card_edit (VALUE dummy, VALUE vctx, VALUE vkey,
1289
+ VALUE veditfunc, VALUE vhook_value, VALUE vout)
1290
+ {
1291
+ gpgme_ctx_t ctx;
1292
+ gpgme_key_t key;
1293
+ gpgme_data_t out = NULL;
1294
+ VALUE vcb;
1295
+ gpgme_error_t err;
1296
+
1297
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1298
+
1299
+ UNWRAP_GPGME_CTX(vctx, ctx);
1300
+ if (!ctx)
1301
+ rb_raise (rb_eArgError, "released ctx");
1302
+ UNWRAP_GPGME_KEY(vkey, key);
1303
+ if (!NIL_P(vout))
1304
+ UNWRAP_GPGME_DATA(vout, out);
1305
+
1306
+ vcb = rb_ary_new ();
1307
+ rb_ary_push (vcb, veditfunc);
1308
+ rb_ary_push (vcb, vhook_value);
1309
+ /* Keep a reference to avoid GC. */
1310
+ rb_iv_set (vctx, "@card_edit_cb", vcb);
1311
+
1312
+ err = gpgme_op_card_edit (ctx, key, edit_cb, (void *)vcb, out);
1313
+ return LONG2NUM(err);
1314
+ }
1315
+
1316
+ static VALUE
1317
+ rb_s_gpgme_op_card_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
1318
+ VALUE veditfunc, VALUE vhook_value, VALUE vout)
1319
+ {
1320
+ gpgme_ctx_t ctx;
1321
+ gpgme_key_t key;
1322
+ gpgme_data_t out = NULL;
1323
+ VALUE vcb;
1324
+ gpgme_error_t err;
1325
+
1326
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1327
+
1328
+ UNWRAP_GPGME_CTX(vctx, ctx);
1329
+ if (!ctx)
1330
+ rb_raise (rb_eArgError, "released ctx");
1331
+ UNWRAP_GPGME_KEY(vkey, key);
1332
+ if (!NIL_P(vout))
1333
+ UNWRAP_GPGME_DATA(vout, out);
1334
+
1335
+ vcb = rb_ary_new ();
1336
+ rb_ary_push (vcb, veditfunc);
1337
+ rb_ary_push (vcb, vhook_value);
1338
+ /* Keep a reference to avoid GC. */
1339
+ rb_iv_set (vctx, "@card_edit_cb", vcb);
1340
+
1341
+ err = gpgme_op_card_edit_start (ctx, key, edit_cb, (void *)vcb, out);
1342
+ return LONG2NUM(err);
1343
+ }
1344
+
1345
+ static VALUE
1346
+ rb_s_gpgme_op_trustlist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
1347
+ VALUE vmax_level)
1348
+ {
1349
+ gpgme_ctx_t ctx;
1350
+ gpgme_error_t err;
1351
+
1352
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1353
+
1354
+ UNWRAP_GPGME_CTX(vctx, ctx);
1355
+ if (!ctx)
1356
+ rb_raise (rb_eArgError, "released ctx");
1357
+ err = gpgme_op_trustlist_start (ctx, StringValueCStr(vpattern),
1358
+ NUM2INT(vmax_level));
1359
+ return LONG2NUM(err);
1360
+ }
1361
+
1362
+ static VALUE
1363
+ rb_s_gpgme_op_trustlist_next (VALUE dummy, VALUE vctx, VALUE ritem)
1364
+ {
1365
+ gpgme_ctx_t ctx;
1366
+ gpgme_trust_item_t item;
1367
+ gpgme_error_t err;
1368
+ VALUE vitem;
1369
+
1370
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1371
+
1372
+ UNWRAP_GPGME_CTX(vctx, ctx);
1373
+ if (!ctx)
1374
+ rb_raise (rb_eArgError, "released ctx");
1375
+
1376
+ err = gpgme_op_trustlist_next (ctx, &item);
1377
+ if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
1378
+ {
1379
+ vitem = WRAP_GPGME_TRUST_ITEM(item);
1380
+ rb_iv_set (vitem, "@keyid", rb_str_new2 (item->keyid));
1381
+ rb_iv_set (vitem, "@type", INT2FIX(item->type));
1382
+ rb_iv_set (vitem, "@level", INT2FIX(item->level));
1383
+ if (item->owner_trust)
1384
+ rb_iv_set (vitem, "@owner_trust", rb_str_new2 (item->owner_trust));
1385
+ rb_iv_set (vitem, "@validity", rb_str_new2 (item->validity));
1386
+ if (item->name)
1387
+ rb_iv_set (vitem, "@name", rb_str_new2 (item->name));
1388
+ rb_ary_store (ritem, 0, vitem);
1389
+ }
1390
+ return LONG2NUM(err);
1391
+ }
1392
+
1393
+ static VALUE
1394
+ rb_s_gpgme_op_trustlist_end (VALUE dummy, VALUE vctx)
1395
+ {
1396
+ gpgme_ctx_t ctx;
1397
+ gpgme_error_t err;
1398
+
1399
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1400
+
1401
+ UNWRAP_GPGME_CTX(vctx, ctx);
1402
+ if (!ctx)
1403
+ rb_raise (rb_eArgError, "released ctx");
1404
+
1405
+ err = gpgme_op_trustlist_end (ctx);
1406
+ return LONG2NUM(err);
1407
+ }
1408
+
1409
+ static VALUE
1410
+ rb_s_gpgme_op_decrypt (VALUE dummy, VALUE vctx, VALUE vcipher, VALUE vplain)
1411
+ {
1412
+ gpgme_ctx_t ctx;
1413
+ gpgme_data_t cipher, plain;
1414
+ gpgme_error_t err;
1415
+
1416
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1417
+
1418
+ UNWRAP_GPGME_CTX(vctx, ctx);
1419
+ if (!ctx)
1420
+ rb_raise (rb_eArgError, "released ctx");
1421
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1422
+ UNWRAP_GPGME_DATA(vplain, plain);
1423
+
1424
+ err = gpgme_op_decrypt (ctx, cipher, plain);
1425
+ return LONG2NUM(err);
1426
+ }
1427
+
1428
+ static VALUE
1429
+ rb_s_gpgme_op_decrypt_start (VALUE dummy, VALUE vctx, VALUE vcipher,
1430
+ VALUE vplain)
1431
+ {
1432
+ gpgme_ctx_t ctx;
1433
+ gpgme_data_t cipher, plain;
1434
+ gpgme_error_t err;
1435
+
1436
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1437
+
1438
+ UNWRAP_GPGME_CTX(vctx, ctx);
1439
+ if (!ctx)
1440
+ rb_raise (rb_eArgError, "released ctx");
1441
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1442
+ UNWRAP_GPGME_DATA(vplain, plain);
1443
+
1444
+ err = gpgme_op_decrypt_start (ctx, cipher, plain);
1445
+ return LONG2NUM(err);
1446
+ }
1447
+
1448
+ static VALUE
1449
+ rb_s_gpgme_op_decrypt_result (VALUE dummy, VALUE vctx)
1450
+ {
1451
+ gpgme_ctx_t ctx;
1452
+ gpgme_decrypt_result_t result;
1453
+ VALUE vresult;
1454
+
1455
+ UNWRAP_GPGME_CTX(vctx, ctx);
1456
+ if (!ctx)
1457
+ rb_raise (rb_eArgError, "released ctx");
1458
+
1459
+ result = gpgme_op_decrypt_result (ctx);
1460
+ vresult = rb_class_new_instance (0, NULL, cDecryptResult);
1461
+ if (result->unsupported_algorithm)
1462
+ rb_iv_set (vresult, "@unsupported_algorithm",
1463
+ rb_str_new2 (result->unsupported_algorithm));
1464
+ rb_iv_set (vresult, "@wrong_key_usage", INT2FIX(result->wrong_key_usage));
1465
+ return vresult;
1466
+ }
1467
+
1468
+ static VALUE
1469
+ rb_s_gpgme_op_verify (VALUE dummy, VALUE vctx, VALUE vsig, VALUE vsigned_text,
1470
+ VALUE vplain)
1471
+ {
1472
+ gpgme_ctx_t ctx;
1473
+ gpgme_data_t sig, signed_text = NULL, plain = NULL;
1474
+ gpgme_error_t err;
1475
+
1476
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1477
+
1478
+ UNWRAP_GPGME_CTX(vctx, ctx);
1479
+ if (!ctx)
1480
+ rb_raise (rb_eArgError, "released ctx");
1481
+ UNWRAP_GPGME_DATA(vsig, sig);
1482
+ if (!NIL_P(vsigned_text))
1483
+ UNWRAP_GPGME_DATA(vsigned_text, signed_text);
1484
+ if (!NIL_P(vplain))
1485
+ UNWRAP_GPGME_DATA(vplain, plain);
1486
+
1487
+ err = gpgme_op_verify (ctx, sig, signed_text, plain);
1488
+ return LONG2NUM(err);
1489
+ }
1490
+
1491
+ static VALUE
1492
+ rb_s_gpgme_op_verify_start (VALUE dummy, VALUE vctx, VALUE vsig,
1493
+ VALUE vsigned_text, VALUE vplain)
1494
+ {
1495
+ gpgme_ctx_t ctx;
1496
+ gpgme_data_t sig, signed_text = NULL, plain = NULL;
1497
+ gpgme_error_t err;
1498
+
1499
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1500
+
1501
+ UNWRAP_GPGME_CTX(vctx, ctx);
1502
+ if (!ctx)
1503
+ rb_raise (rb_eArgError, "released ctx");
1504
+ UNWRAP_GPGME_DATA(vsig, sig);
1505
+ if (!NIL_P(vsigned_text))
1506
+ UNWRAP_GPGME_DATA(vsigned_text, signed_text);
1507
+ if (!NIL_P(vplain))
1508
+ UNWRAP_GPGME_DATA(vplain, plain);
1509
+
1510
+ err = gpgme_op_verify_start (ctx, sig, signed_text, plain);
1511
+ return LONG2NUM(err);
1512
+ }
1513
+
1514
+ static VALUE
1515
+ rb_s_gpgme_op_verify_result (VALUE dummy, VALUE vctx)
1516
+ {
1517
+ gpgme_ctx_t ctx;
1518
+ gpgme_verify_result_t verify_result;
1519
+ gpgme_signature_t signature;
1520
+ VALUE vverify_result, vsignatures = rb_ary_new ();
1521
+
1522
+ UNWRAP_GPGME_CTX(vctx, ctx);
1523
+ if (!ctx)
1524
+ rb_raise (rb_eArgError, "released ctx");
1525
+
1526
+ verify_result = gpgme_op_verify_result (ctx);
1527
+ vverify_result = rb_class_new_instance(0, NULL, cVerifyResult);
1528
+ rb_iv_set (vverify_result, "@signatures", vsignatures);
1529
+ for (signature = verify_result->signatures; signature;
1530
+ signature = signature->next)
1531
+ {
1532
+ VALUE vsignature = rb_class_new_instance(0, NULL, cSignature),
1533
+ vnotations = rb_ary_new ();
1534
+ gpgme_sig_notation_t notation;
1535
+ rb_iv_set (vsignature, "@summary", INT2FIX(signature->summary));
1536
+ rb_iv_set (vsignature, "@fpr", rb_str_new2 (signature->fpr));
1537
+ rb_iv_set (vsignature, "@status", LONG2NUM(signature->status));
1538
+ rb_iv_set (vsignature, "@notations", vnotations);
1539
+ for (notation = signature->notations; notation;
1540
+ notation = notation->next)
1541
+ {
1542
+ VALUE vnotation = rb_class_new_instance(0, NULL, cSigNotation);
1543
+ rb_iv_set (vnotation, "@name", rb_str_new2 (notation->name));
1544
+ rb_iv_set (vnotation, "@value", rb_str_new2 (notation->value));
1545
+ rb_ary_push (vnotations, vnotation);
1546
+ }
1547
+ rb_iv_set (vsignature, "@timestamp", ULONG2NUM(signature->timestamp));
1548
+ rb_iv_set (vsignature, "@exp_timestamp",
1549
+ ULONG2NUM(signature->exp_timestamp));
1550
+ rb_iv_set (vsignature, "@wrong_key_usage",
1551
+ INT2FIX(signature->wrong_key_usage));
1552
+ rb_iv_set (vsignature, "@validity", INT2FIX(signature->validity));
1553
+ rb_iv_set (vsignature, "@validity_reason",
1554
+ LONG2NUM(signature->validity_reason));
1555
+ /* PKA related fields were added in 1.1.1. */
1556
+ #ifdef GPGME_STATUS_PKA_TRUST_BAD
1557
+ rb_iv_set (vsignature, "@pka_trust", INT2FIX(signature->pka_trust));
1558
+ rb_iv_set (vsignature, "@pka_address",
1559
+ rb_str_new2 (signature->pka_address));
1560
+ #endif
1561
+ rb_ary_push (vsignatures, vsignature);
1562
+ }
1563
+ return vverify_result;
1564
+ }
1565
+
1566
+ static VALUE
1567
+ rb_s_gpgme_op_decrypt_verify (VALUE dummy, VALUE vctx, VALUE vcipher,
1568
+ VALUE vplain)
1569
+ {
1570
+ gpgme_ctx_t ctx;
1571
+ gpgme_data_t cipher, plain;
1572
+ gpgme_error_t err;
1573
+
1574
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1575
+
1576
+ UNWRAP_GPGME_CTX(vctx, ctx);
1577
+ if (!ctx)
1578
+ rb_raise (rb_eArgError, "released ctx");
1579
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1580
+ UNWRAP_GPGME_DATA(vplain, plain);
1581
+
1582
+ err = gpgme_op_decrypt_verify (ctx, cipher, plain);
1583
+ return LONG2NUM(err);
1584
+ }
1585
+
1586
+ static VALUE
1587
+ rb_s_gpgme_op_decrypt_verify_start (VALUE dummy, VALUE vctx, VALUE vcipher,
1588
+ VALUE vplain)
1589
+ {
1590
+ gpgme_ctx_t ctx;
1591
+ gpgme_data_t cipher, plain;
1592
+ gpgme_error_t err;
1593
+
1594
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1595
+
1596
+ UNWRAP_GPGME_CTX(vctx, ctx);
1597
+ if (!ctx)
1598
+ rb_raise (rb_eArgError, "released ctx");
1599
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1600
+ UNWRAP_GPGME_DATA(vplain, plain);
1601
+
1602
+ err = gpgme_op_decrypt_verify_start (ctx, cipher, plain);
1603
+ return LONG2NUM(err);
1604
+ }
1605
+
1606
+ static VALUE
1607
+ rb_s_gpgme_signers_clear (VALUE dummy, VALUE vctx)
1608
+ {
1609
+ gpgme_ctx_t ctx;
1610
+
1611
+ UNWRAP_GPGME_CTX(vctx, ctx);
1612
+ if (!ctx)
1613
+ rb_raise (rb_eArgError, "released ctx");
1614
+ gpgme_signers_clear (ctx);
1615
+ return Qnil;
1616
+ }
1617
+
1618
+ static VALUE
1619
+ rb_s_gpgme_signers_add (VALUE dummy, VALUE vctx, VALUE vkey)
1620
+ {
1621
+ gpgme_ctx_t ctx;
1622
+ gpgme_key_t key;
1623
+ gpgme_error_t err;
1624
+
1625
+ UNWRAP_GPGME_CTX(vctx, ctx);
1626
+ if (!ctx)
1627
+ rb_raise (rb_eArgError, "released ctx");
1628
+ UNWRAP_GPGME_KEY(vkey, key);
1629
+
1630
+ err = gpgme_signers_add (ctx, key);
1631
+ return LONG2NUM(err);
1632
+ }
1633
+
1634
+ static VALUE
1635
+ rb_s_gpgme_signers_enum (VALUE dummy, VALUE vctx, VALUE vseq)
1636
+ {
1637
+ gpgme_ctx_t ctx;
1638
+ gpgme_key_t key;
1639
+
1640
+ UNWRAP_GPGME_CTX(vctx, ctx);
1641
+ if (!ctx)
1642
+ rb_raise (rb_eArgError, "released ctx");
1643
+
1644
+ key = gpgme_signers_enum (ctx, NUM2INT(vseq));
1645
+ if (!key)
1646
+ return Qnil;
1647
+ return WRAP_GPGME_KEY(key);
1648
+ }
1649
+
1650
+ static VALUE
1651
+ rb_s_gpgme_op_sign (VALUE dummy, VALUE vctx, VALUE vplain, VALUE vsig,
1652
+ VALUE vmode)
1653
+ {
1654
+ gpgme_ctx_t ctx;
1655
+ gpgme_data_t plain, sig;
1656
+ gpgme_error_t err;
1657
+
1658
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1659
+
1660
+ UNWRAP_GPGME_CTX(vctx, ctx);
1661
+ if (!ctx)
1662
+ rb_raise (rb_eArgError, "released ctx");
1663
+ UNWRAP_GPGME_DATA(vplain, plain);
1664
+ UNWRAP_GPGME_DATA(vsig, sig);
1665
+
1666
+ err = gpgme_op_sign (ctx, plain, sig, NUM2INT(vmode));
1667
+ return LONG2NUM(err);
1668
+ }
1669
+
1670
+ static VALUE
1671
+ rb_s_gpgme_op_sign_start (VALUE dummy, VALUE vctx, VALUE vplain, VALUE vsig,
1672
+ VALUE vmode)
1673
+ {
1674
+ gpgme_ctx_t ctx;
1675
+ gpgme_data_t plain, sig;
1676
+ gpgme_error_t err;
1677
+
1678
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1679
+
1680
+ UNWRAP_GPGME_CTX(vctx, ctx);
1681
+ if (!ctx)
1682
+ rb_raise (rb_eArgError, "released ctx");
1683
+ UNWRAP_GPGME_DATA(vplain, plain);
1684
+ UNWRAP_GPGME_DATA(vsig, sig);
1685
+
1686
+ err = gpgme_op_sign_start (ctx, plain, sig, NUM2INT(vmode));
1687
+ return LONG2NUM(err);
1688
+ }
1689
+
1690
+ static VALUE
1691
+ rb_s_gpgme_op_sign_result (VALUE dummy, VALUE vctx)
1692
+ {
1693
+ gpgme_ctx_t ctx;
1694
+ gpgme_sign_result_t result;
1695
+ gpgme_invalid_key_t invalid_key;
1696
+ gpgme_new_signature_t new_signature;
1697
+ VALUE vresult, vinvalid_signers, vsignatures;
1698
+
1699
+ UNWRAP_GPGME_CTX(vctx, ctx);
1700
+ if (!ctx)
1701
+ rb_raise (rb_eArgError, "released ctx");
1702
+
1703
+ result = gpgme_op_sign_result (ctx);
1704
+ vresult = rb_class_new_instance (0, NULL, cSignResult);
1705
+ vinvalid_signers = rb_ary_new ();
1706
+ rb_iv_set (vresult, "@invalid_signers", vinvalid_signers);
1707
+ for (invalid_key = result->invalid_signers; invalid_key;
1708
+ invalid_key = invalid_key->next)
1709
+ {
1710
+ VALUE vinvalid_key =
1711
+ rb_class_new_instance (0, NULL, cInvalidKey);
1712
+ rb_iv_set (vinvalid_key, "@fpr", rb_str_new2 (invalid_key->fpr));
1713
+ rb_iv_set (vinvalid_key, "@reason", LONG2NUM(invalid_key->reason));
1714
+ rb_ary_push (vinvalid_signers, vinvalid_key);
1715
+ }
1716
+ vsignatures = rb_ary_new ();
1717
+ rb_iv_set (vresult, "@signatures", vsignatures);
1718
+ for (new_signature = result->signatures; new_signature;
1719
+ new_signature = new_signature->next)
1720
+ {
1721
+ VALUE vnew_signature =
1722
+ rb_class_new_instance (0, NULL, cNewSignature);
1723
+ rb_iv_set (vnew_signature, "@type", INT2FIX(new_signature->type));
1724
+ rb_iv_set (vnew_signature, "@pubkey_algo",
1725
+ INT2FIX(new_signature->pubkey_algo));
1726
+ rb_iv_set (vnew_signature, "@hash_algo",
1727
+ INT2FIX(new_signature->hash_algo));
1728
+ rb_iv_set (vnew_signature, "@sig_class",
1729
+ UINT2NUM(new_signature->sig_class));
1730
+ rb_iv_set (vnew_signature, "@timestamp",
1731
+ LONG2NUM(new_signature->timestamp));
1732
+ rb_iv_set (vnew_signature, "@fpr", rb_str_new2 (new_signature->fpr));
1733
+ rb_ary_push (vsignatures, vnew_signature);
1734
+ }
1735
+ return vresult;
1736
+ }
1737
+
1738
+ static VALUE
1739
+ rb_s_gpgme_op_encrypt (VALUE dummy, VALUE vctx, VALUE vrecp, VALUE vflags,
1740
+ VALUE vplain, VALUE vcipher)
1741
+ {
1742
+ gpgme_ctx_t ctx;
1743
+ gpgme_key_t *recp = NULL;
1744
+ gpgme_data_t plain, cipher;
1745
+ gpgme_error_t err;
1746
+
1747
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1748
+
1749
+ UNWRAP_GPGME_CTX(vctx, ctx);
1750
+ if (!ctx)
1751
+ rb_raise (rb_eArgError, "released ctx");
1752
+ /* If RECP is `NULL', symmetric rather than public key encryption is
1753
+ performed. */
1754
+ if (!NIL_P(vrecp))
1755
+ {
1756
+ int i;
1757
+ recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
1758
+ for (i = 0; i < RARRAY_LEN(vrecp); i++)
1759
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
1760
+ recp[i] = NULL;
1761
+ }
1762
+ UNWRAP_GPGME_DATA(vplain, plain);
1763
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1764
+
1765
+ err = gpgme_op_encrypt (ctx, recp, NUM2INT(vflags), plain, cipher);
1766
+ if (recp)
1767
+ xfree (recp);
1768
+ return LONG2NUM(err);
1769
+ }
1770
+
1771
+ static VALUE
1772
+ rb_s_gpgme_op_encrypt_start (VALUE dummy, VALUE vctx, VALUE vrecp,
1773
+ VALUE vflags, VALUE vplain, VALUE vcipher)
1774
+ {
1775
+ gpgme_ctx_t ctx;
1776
+ gpgme_key_t *recp = NULL;
1777
+ gpgme_data_t plain, cipher;
1778
+ gpgme_error_t err;
1779
+
1780
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1781
+
1782
+ UNWRAP_GPGME_CTX(vctx, ctx);
1783
+ if (!ctx)
1784
+ rb_raise (rb_eArgError, "released ctx");
1785
+ /* If RECP is `NULL', symmetric rather than public key encryption is
1786
+ performed. */
1787
+ if (!NIL_P(vrecp))
1788
+ {
1789
+ int i;
1790
+ recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
1791
+ for (i = 0; i < RARRAY_LEN(vrecp); i++)
1792
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
1793
+ recp[i] = NULL;
1794
+ }
1795
+ UNWRAP_GPGME_DATA(vplain, plain);
1796
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1797
+
1798
+ err = gpgme_op_encrypt_start (ctx, recp, NUM2INT(vflags), plain, cipher);
1799
+ if (recp)
1800
+ xfree (recp);
1801
+ return LONG2NUM(err);
1802
+ }
1803
+
1804
+ static VALUE
1805
+ rb_s_gpgme_op_encrypt_result (VALUE dummy, VALUE vctx)
1806
+ {
1807
+ gpgme_ctx_t ctx;
1808
+ gpgme_encrypt_result_t result;
1809
+ gpgme_invalid_key_t invalid_key;
1810
+ VALUE vresult, vinvalid_recipients;
1811
+
1812
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1813
+
1814
+ UNWRAP_GPGME_CTX(vctx, ctx);
1815
+ if (!ctx)
1816
+ rb_raise (rb_eArgError, "released ctx");
1817
+
1818
+ result = gpgme_op_encrypt_result (ctx);
1819
+ vresult = rb_class_new_instance (0, NULL, cEncryptResult);
1820
+ vinvalid_recipients = rb_ary_new ();
1821
+ rb_iv_set (vresult, "@invalid_recipients", vinvalid_recipients);
1822
+ for (invalid_key = result->invalid_recipients; invalid_key;
1823
+ invalid_key = invalid_key->next)
1824
+ {
1825
+ VALUE vinvalid_key =
1826
+ rb_class_new_instance (0, NULL, cInvalidKey);
1827
+ rb_iv_set (vinvalid_key, "@fpr", rb_str_new2 (invalid_key->fpr));
1828
+ rb_iv_set (vinvalid_key, "@reason", LONG2NUM(invalid_key->reason));
1829
+ rb_ary_push (vinvalid_recipients, vinvalid_key);
1830
+ }
1831
+ return vresult;
1832
+ }
1833
+
1834
+ static VALUE
1835
+ rb_s_gpgme_op_encrypt_sign (VALUE dummy, VALUE vctx, VALUE vrecp, VALUE vflags,
1836
+ VALUE vplain, VALUE vcipher)
1837
+ {
1838
+ gpgme_ctx_t ctx;
1839
+ gpgme_key_t *recp = NULL;
1840
+ gpgme_data_t plain, cipher;
1841
+ gpgme_error_t err;
1842
+
1843
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1844
+
1845
+ UNWRAP_GPGME_CTX(vctx, ctx);
1846
+ if (!ctx)
1847
+ rb_raise (rb_eArgError, "released ctx");
1848
+ /* If RECP is `NULL', symmetric rather than public key encryption is
1849
+ performed. */
1850
+ if (!NIL_P(vrecp))
1851
+ {
1852
+ int i;
1853
+ recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
1854
+ for (i = 0; i < RARRAY_LEN(vrecp); i++)
1855
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
1856
+ recp[i] = NULL;
1857
+ }
1858
+ UNWRAP_GPGME_DATA(vplain, plain);
1859
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1860
+
1861
+ err = gpgme_op_encrypt_sign (ctx, recp, NUM2INT(vflags), plain, cipher);
1862
+ if (recp)
1863
+ xfree (recp);
1864
+ return LONG2NUM(err);
1865
+ }
1866
+
1867
+ static VALUE
1868
+ rb_s_gpgme_op_encrypt_sign_start (VALUE dummy, VALUE vctx, VALUE vrecp,
1869
+ VALUE vflags, VALUE vplain, VALUE vcipher)
1870
+ {
1871
+ gpgme_ctx_t ctx;
1872
+ gpgme_key_t *recp = NULL;
1873
+ gpgme_data_t plain, cipher;
1874
+ gpgme_error_t err;
1875
+
1876
+ CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
1877
+
1878
+ UNWRAP_GPGME_CTX(vctx, ctx);
1879
+ if (!ctx)
1880
+ rb_raise (rb_eArgError, "released ctx");
1881
+ /* If RECP is `NULL', symmetric rather than public key encryption is
1882
+ performed. */
1883
+ if (!NIL_P(vrecp))
1884
+ {
1885
+ int i;
1886
+ recp = ALLOC_N(gpgme_key_t, RARRAY_LEN(vrecp) + 1);
1887
+ for (i = 0; i < RARRAY_LEN(vrecp); i++)
1888
+ UNWRAP_GPGME_KEY(RARRAY_PTR(vrecp)[i], recp[i]);
1889
+ recp[i] = NULL;
1890
+ }
1891
+ UNWRAP_GPGME_DATA(vplain, plain);
1892
+ UNWRAP_GPGME_DATA(vcipher, cipher);
1893
+
1894
+ err = gpgme_op_encrypt_sign_start (ctx, recp, NUM2INT(vflags), plain,
1895
+ cipher);
1896
+ if (recp)
1897
+ xfree (recp);
1898
+ return LONG2NUM(err);
1899
+ }
1900
+
1901
+ static VALUE
1902
+ rb_s_gpgme_wait (VALUE dummy, VALUE vctx, VALUE rstatus, VALUE vhang)
1903
+ {
1904
+ gpgme_ctx_t ctx = NULL, ret;
1905
+ gpgme_error_t status;
1906
+
1907
+ /* The CTX argument can be `NULL'. In that case, `gpgme_wait' waits
1908
+ for any context to complete its operation. */
1909
+ if (!NIL_P(vctx))
1910
+ {
1911
+ UNWRAP_GPGME_CTX(vctx, ctx);
1912
+ if (!ctx)
1913
+ rb_raise (rb_eArgError, "released ctx");
1914
+ }
1915
+
1916
+ ret = gpgme_wait (ctx, &status, NUM2INT(vhang));
1917
+ if (ret)
1918
+ {
1919
+ rb_ary_store (rstatus, 0, INT2NUM(status));
1920
+ if (ret != ctx)
1921
+ vctx = WRAP_GPGME_CTX(ret);
1922
+ return vctx;
1923
+ }
1924
+ return Qnil;
1925
+ }
1926
+
1927
+ void
1928
+ Init_gpgme_n (void)
1929
+ {
1930
+ VALUE mGPGME;
1931
+
1932
+ mGPGME = rb_define_module ("GPGME");
1933
+
1934
+ rb_define_module_function (mGPGME, "gpgme_check_version",
1935
+ rb_s_gpgme_check_version, 1);
1936
+ rb_define_module_function (mGPGME, "gpgme_engine_check_version",
1937
+ rb_s_gpgme_engine_check_version, 1);
1938
+ rb_define_module_function (mGPGME, "gpgme_get_engine_info",
1939
+ rb_s_gpgme_get_engine_info, 1);
1940
+ rb_define_module_function (mGPGME, "gpgme_set_engine_info",
1941
+ rb_s_gpgme_set_engine_info, 3);
1942
+
1943
+ rb_define_module_function (mGPGME, "gpgme_pubkey_algo_name",
1944
+ rb_s_gpgme_pubkey_algo_name, 1);
1945
+ rb_define_module_function (mGPGME, "gpgme_hash_algo_name",
1946
+ rb_s_gpgme_hash_algo_name, 1);
1947
+
1948
+ rb_define_module_function (mGPGME, "gpgme_err_code",
1949
+ rb_s_gpgme_err_code, 1);
1950
+ rb_define_module_function (mGPGME, "gpgme_err_source",
1951
+ rb_s_gpgme_err_source, 1);
1952
+ rb_define_module_function (mGPGME, "gpgme_strerror",
1953
+ rb_s_gpgme_strerror, 1);
1954
+
1955
+ cEngineInfo =
1956
+ rb_define_class_under (mGPGME, "EngineInfo", rb_cObject);
1957
+ cCtx =
1958
+ rb_define_class_under (mGPGME, "Ctx", rb_cObject);
1959
+ cData =
1960
+ rb_define_class_under (mGPGME, "Data", rb_cObject);
1961
+ cKey =
1962
+ rb_define_class_under (mGPGME, "Key", rb_cObject);
1963
+ cSubKey =
1964
+ rb_define_class_under (mGPGME, "SubKey", rb_cObject);
1965
+ cUserID =
1966
+ rb_define_class_under (mGPGME, "UserID", rb_cObject);
1967
+ cKeySig =
1968
+ rb_define_class_under (mGPGME, "KeySig", rb_cObject);
1969
+ cDecryptResult =
1970
+ rb_define_class_under (mGPGME, "DecryptResult", rb_cObject);
1971
+ cVerifyResult =
1972
+ rb_define_class_under (mGPGME, "VerifyResult", rb_cObject);
1973
+ cSignResult =
1974
+ rb_define_class_under (mGPGME, "SignResult", rb_cObject);
1975
+ cEncryptResult =
1976
+ rb_define_class_under (mGPGME, "EncryptResult", rb_cObject);
1977
+ cSignature =
1978
+ rb_define_class_under (mGPGME, "Signature", rb_cObject);
1979
+ cSigNotation =
1980
+ rb_define_class_under (mGPGME, "SigNotation", rb_cObject);
1981
+ cTrustItem =
1982
+ rb_define_class_under (mGPGME, "TrustItem", rb_cObject);
1983
+ cInvalidKey =
1984
+ rb_define_class_under (mGPGME, "InvalidKey", rb_cObject);
1985
+ cNewSignature =
1986
+ rb_define_class_under (mGPGME, "NewSignature", rb_cObject);
1987
+ cImportResult =
1988
+ rb_define_class_under (mGPGME, "ImportResult", rb_cObject);
1989
+ cImportStatus =
1990
+ rb_define_class_under (mGPGME, "ImportStatus", rb_cObject);
1991
+
1992
+ /* Creating Data Buffers
1993
+ *
1994
+ * gpgme_data_new_from_filepart is not currently supported.
1995
+ */
1996
+ rb_define_module_function (mGPGME, "gpgme_data_new",
1997
+ rb_s_gpgme_data_new, 1);
1998
+ rb_define_module_function (mGPGME, "gpgme_data_new_from_mem",
1999
+ rb_s_gpgme_data_new_from_mem, 3);
2000
+ rb_define_module_function (mGPGME, "gpgme_data_new_from_fd",
2001
+ rb_s_gpgme_data_new_from_fd, 2);
2002
+ rb_define_module_function (mGPGME, "gpgme_data_new_from_cbs",
2003
+ rb_s_gpgme_data_new_from_cbs, 3);
2004
+
2005
+ /* Manipulating Data Buffers */
2006
+ rb_define_module_function (mGPGME, "gpgme_data_read",
2007
+ rb_s_gpgme_data_read, 2);
2008
+ rb_define_module_function (mGPGME, "gpgme_data_seek",
2009
+ rb_s_gpgme_data_seek, 3);
2010
+ rb_define_module_function (mGPGME, "gpgme_data_write",
2011
+ rb_s_gpgme_data_write, 3);
2012
+ rb_define_module_function (mGPGME, "gpgme_data_get_encoding",
2013
+ rb_s_gpgme_data_get_encoding, 1);
2014
+ rb_define_module_function (mGPGME, "gpgme_data_set_encoding",
2015
+ rb_s_gpgme_data_set_encoding, 2);
2016
+
2017
+ /* Creating Contexts */
2018
+ rb_define_module_function (mGPGME, "gpgme_new",
2019
+ rb_s_gpgme_new, 1);
2020
+ rb_define_module_function (mGPGME, "gpgme_release",
2021
+ rb_s_gpgme_release, 1);
2022
+
2023
+ /* Context Attributes */
2024
+ rb_define_module_function (mGPGME, "gpgme_set_protocol",
2025
+ rb_s_gpgme_set_protocol, 2);
2026
+ rb_define_module_function (mGPGME, "gpgme_get_protocol",
2027
+ rb_s_gpgme_get_protocol, 1);
2028
+ rb_define_module_function (mGPGME, "gpgme_set_armor",
2029
+ rb_s_gpgme_set_armor, 2);
2030
+ rb_define_module_function (mGPGME, "gpgme_get_armor",
2031
+ rb_s_gpgme_get_armor, 1);
2032
+ rb_define_module_function (mGPGME, "gpgme_set_textmode",
2033
+ rb_s_gpgme_set_textmode, 2);
2034
+ rb_define_module_function (mGPGME, "gpgme_get_textmode",
2035
+ rb_s_gpgme_get_textmode, 1);
2036
+ rb_define_module_function (mGPGME, "gpgme_set_include_certs",
2037
+ rb_s_gpgme_set_include_certs, 2);
2038
+ rb_define_module_function (mGPGME, "gpgme_get_include_certs",
2039
+ rb_s_gpgme_get_include_certs, 1);
2040
+ rb_define_module_function (mGPGME, "gpgme_set_keylist_mode",
2041
+ rb_s_gpgme_set_keylist_mode, 2);
2042
+ rb_define_module_function (mGPGME, "gpgme_get_keylist_mode",
2043
+ rb_s_gpgme_get_keylist_mode, 1);
2044
+ rb_define_module_function (mGPGME, "gpgme_set_passphrase_cb",
2045
+ rb_s_gpgme_set_passphrase_cb, 3);
2046
+ rb_define_module_function (mGPGME, "gpgme_get_passphrase_cb",
2047
+ rb_s_gpgme_get_passphrase_cb, 3);
2048
+ rb_define_module_function (mGPGME, "gpgme_set_progress_cb",
2049
+ rb_s_gpgme_set_progress_cb, 3);
2050
+ rb_define_module_function (mGPGME, "gpgme_get_progress_cb",
2051
+ rb_s_gpgme_get_progress_cb, 3);
2052
+ rb_define_module_function (mGPGME, "gpgme_set_locale",
2053
+ rb_s_gpgme_set_locale, 3);
2054
+
2055
+ /* Key Management */
2056
+ rb_define_module_function (mGPGME, "gpgme_op_keylist_start",
2057
+ rb_s_gpgme_op_keylist_start, 3);
2058
+ rb_define_module_function (mGPGME, "gpgme_op_keylist_ext_start",
2059
+ rb_s_gpgme_op_keylist_ext_start, 4);
2060
+ rb_define_module_function (mGPGME, "gpgme_op_keylist_next",
2061
+ rb_s_gpgme_op_keylist_next, 2);
2062
+ rb_define_module_function (mGPGME, "gpgme_op_keylist_end",
2063
+ rb_s_gpgme_op_keylist_end, 1);
2064
+ rb_define_module_function (mGPGME, "gpgme_get_key",
2065
+ rb_s_gpgme_get_key, 4);
2066
+ rb_define_module_function (mGPGME, "gpgme_op_genkey",
2067
+ rb_s_gpgme_op_genkey, 4);
2068
+ rb_define_module_function (mGPGME, "gpgme_op_genkey_start",
2069
+ rb_s_gpgme_op_genkey_start, 4);
2070
+ rb_define_module_function (mGPGME, "gpgme_op_export",
2071
+ rb_s_gpgme_op_export, 4);
2072
+ rb_define_module_function (mGPGME, "gpgme_op_export_start",
2073
+ rb_s_gpgme_op_export_start, 4);
2074
+ rb_define_module_function (mGPGME, "gpgme_op_export_ext",
2075
+ rb_s_gpgme_op_export_ext, 4);
2076
+ rb_define_module_function (mGPGME, "gpgme_op_export_ext_start",
2077
+ rb_s_gpgme_op_export_ext_start, 4);
2078
+ #ifdef HAVE_GPGME_OP_EXPORT_KEYS
2079
+ rb_define_module_function (mGPGME, "gpgme_op_export_keys",
2080
+ rb_s_gpgme_op_export_keys, 4);
2081
+ rb_define_module_function (mGPGME, "gpgme_op_export_keys_start",
2082
+ rb_s_gpgme_op_export_keys_start, 4);
2083
+ #endif
2084
+ rb_define_module_function (mGPGME, "gpgme_op_import",
2085
+ rb_s_gpgme_op_import, 2);
2086
+ rb_define_module_function (mGPGME, "gpgme_op_import_start",
2087
+ rb_s_gpgme_op_import_start, 2);
2088
+ #ifdef HAVE_GPGME_OP_EXPORT_KEYS
2089
+ rb_define_module_function (mGPGME, "gpgme_op_import_keys",
2090
+ rb_s_gpgme_op_import_keys, 2);
2091
+ rb_define_module_function (mGPGME, "gpgme_op_import_keys_start",
2092
+ rb_s_gpgme_op_import_keys_start, 2);
2093
+ #endif
2094
+ rb_define_module_function (mGPGME, "gpgme_op_import_result",
2095
+ rb_s_gpgme_op_import_result, 1);
2096
+ rb_define_module_function (mGPGME, "gpgme_op_delete",
2097
+ rb_s_gpgme_op_delete, 3);
2098
+ rb_define_module_function (mGPGME, "gpgme_op_delete_start",
2099
+ rb_s_gpgme_op_delete_start, 3);
2100
+ rb_define_module_function (mGPGME, "gpgme_op_edit",
2101
+ rb_s_gpgme_op_edit, 5);
2102
+ rb_define_module_function (mGPGME, "gpgme_op_edit_start",
2103
+ rb_s_gpgme_op_edit_start, 5);
2104
+ rb_define_module_function (mGPGME, "gpgme_op_card_edit",
2105
+ rb_s_gpgme_op_card_edit, 5);
2106
+ rb_define_module_function (mGPGME, "gpgme_op_card_edit_start",
2107
+ rb_s_gpgme_op_card_edit_start, 5);
2108
+
2109
+ /* Trust Item Management */
2110
+ rb_define_module_function (mGPGME, "gpgme_op_trustlist_start",
2111
+ rb_s_gpgme_op_trustlist_start, 3);
2112
+ rb_define_module_function (mGPGME, "gpgme_op_trustlist_next",
2113
+ rb_s_gpgme_op_trustlist_next, 2);
2114
+ rb_define_module_function (mGPGME, "gpgme_op_trustlist_end",
2115
+ rb_s_gpgme_op_trustlist_end, 1);
2116
+
2117
+ /* Decrypt */
2118
+ rb_define_module_function (mGPGME, "gpgme_op_decrypt",
2119
+ rb_s_gpgme_op_decrypt, 3);
2120
+ rb_define_module_function (mGPGME, "gpgme_op_decrypt_start",
2121
+ rb_s_gpgme_op_decrypt_start, 3);
2122
+ rb_define_module_function (mGPGME, "gpgme_op_decrypt_result",
2123
+ rb_s_gpgme_op_decrypt_result, 1);
2124
+
2125
+ /* Verify */
2126
+ rb_define_module_function (mGPGME, "gpgme_op_verify",
2127
+ rb_s_gpgme_op_verify, 4);
2128
+ rb_define_module_function (mGPGME, "gpgme_op_verify_start",
2129
+ rb_s_gpgme_op_verify_start, 4);
2130
+ rb_define_module_function (mGPGME, "gpgme_op_verify_result",
2131
+ rb_s_gpgme_op_verify_result, 1);
2132
+
2133
+ /* Decrypt and Verify */
2134
+ rb_define_module_function (mGPGME, "gpgme_op_decrypt_verify",
2135
+ rb_s_gpgme_op_decrypt_verify, 3);
2136
+ rb_define_module_function (mGPGME, "gpgme_op_decrypt_verify_start",
2137
+ rb_s_gpgme_op_decrypt_verify_start, 3);
2138
+
2139
+ /* Sign */
2140
+ rb_define_module_function (mGPGME, "gpgme_signers_clear",
2141
+ rb_s_gpgme_signers_clear, 1);
2142
+ rb_define_module_function (mGPGME, "gpgme_signers_add",
2143
+ rb_s_gpgme_signers_add, 2);
2144
+ rb_define_module_function (mGPGME, "gpgme_signers_enum",
2145
+ rb_s_gpgme_signers_enum, 2);
2146
+ rb_define_module_function (mGPGME, "gpgme_op_sign",
2147
+ rb_s_gpgme_op_sign, 4);
2148
+ rb_define_module_function (mGPGME, "gpgme_op_sign_start",
2149
+ rb_s_gpgme_op_sign_start, 4);
2150
+ rb_define_module_function (mGPGME, "gpgme_op_sign_result",
2151
+ rb_s_gpgme_op_sign_result, 1);
2152
+
2153
+ /* Encrypt */
2154
+ rb_define_module_function (mGPGME, "gpgme_op_encrypt",
2155
+ rb_s_gpgme_op_encrypt, 5);
2156
+ rb_define_module_function (mGPGME, "gpgme_op_encrypt_start",
2157
+ rb_s_gpgme_op_encrypt_start, 5);
2158
+ rb_define_module_function (mGPGME, "gpgme_op_encrypt_result",
2159
+ rb_s_gpgme_op_encrypt_result, 1);
2160
+ rb_define_module_function (mGPGME, "gpgme_op_encrypt_sign",
2161
+ rb_s_gpgme_op_encrypt_sign, 5);
2162
+ rb_define_module_function (mGPGME, "gpgme_op_encrypt_sign_start",
2163
+ rb_s_gpgme_op_encrypt_sign_start, 5);
2164
+
2165
+ /* Run Control */
2166
+ rb_define_module_function (mGPGME, "gpgme_wait",
2167
+ rb_s_gpgme_wait, 3);
2168
+
2169
+ /* gpgme_pubkey_algo_t */
2170
+ rb_define_const (mGPGME, "GPGME_PK_RSA", INT2FIX(GPGME_PK_RSA));
2171
+ rb_define_const (mGPGME, "GPGME_PK_DSA", INT2FIX(GPGME_PK_DSA));
2172
+ rb_define_const (mGPGME, "GPGME_PK_ELG", INT2FIX(GPGME_PK_ELG));
2173
+ rb_define_const (mGPGME, "GPGME_PK_ELG_E", INT2FIX(GPGME_PK_ELG_E));
2174
+
2175
+ /* gpgme_hash_algo_t */
2176
+ rb_define_const (mGPGME, "GPGME_MD_MD5", INT2FIX(GPGME_MD_MD5));
2177
+ rb_define_const (mGPGME, "GPGME_MD_SHA1", INT2FIX(GPGME_MD_SHA1));
2178
+ rb_define_const (mGPGME, "GPGME_MD_RMD160", INT2FIX(GPGME_MD_RMD160));
2179
+ rb_define_const (mGPGME, "GPGME_MD_MD2", INT2FIX(GPGME_MD_MD2));
2180
+ rb_define_const (mGPGME, "GPGME_MD_TIGER", INT2FIX(GPGME_MD_TIGER));
2181
+ rb_define_const (mGPGME, "GPGME_MD_HAVAL", INT2FIX(GPGME_MD_HAVAL));
2182
+ rb_define_const (mGPGME, "GPGME_MD_SHA256", INT2FIX(GPGME_MD_SHA256));
2183
+ rb_define_const (mGPGME, "GPGME_MD_SHA384", INT2FIX(GPGME_MD_SHA384));
2184
+ rb_define_const (mGPGME, "GPGME_MD_SHA512", INT2FIX(GPGME_MD_SHA512));
2185
+ rb_define_const (mGPGME, "GPGME_MD_MD4", INT2FIX(GPGME_MD_MD4));
2186
+ rb_define_const (mGPGME, "GPGME_MD_CRC32", INT2FIX(GPGME_MD_CRC32));
2187
+ rb_define_const (mGPGME, "GPGME_MD_CRC32_RFC1510",
2188
+ INT2FIX(GPGME_MD_CRC32_RFC1510));
2189
+ rb_define_const (mGPGME, "GPGME_MD_CRC24_RFC2440",
2190
+ INT2FIX(GPGME_MD_CRC24_RFC2440));
2191
+
2192
+ /* gpgme_err_code_t */
2193
+ rb_define_const (mGPGME, "GPG_ERR_EOF",
2194
+ INT2FIX(GPG_ERR_EOF));
2195
+ rb_define_const (mGPGME, "GPG_ERR_NO_ERROR",
2196
+ INT2FIX(GPG_ERR_NO_ERROR));
2197
+ rb_define_const (mGPGME, "GPG_ERR_GENERAL",
2198
+ INT2FIX(GPG_ERR_GENERAL));
2199
+ rb_define_const (mGPGME, "GPG_ERR_ENOMEM",
2200
+ INT2FIX(GPG_ERR_ENOMEM));
2201
+ rb_define_const (mGPGME, "GPG_ERR_INV_VALUE",
2202
+ INT2FIX(GPG_ERR_INV_VALUE));
2203
+ rb_define_const (mGPGME, "GPG_ERR_UNUSABLE_PUBKEY",
2204
+ INT2FIX(GPG_ERR_UNUSABLE_PUBKEY));
2205
+ rb_define_const (mGPGME, "GPG_ERR_UNUSABLE_SECKEY",
2206
+ INT2FIX(GPG_ERR_UNUSABLE_SECKEY));
2207
+ rb_define_const (mGPGME, "GPG_ERR_NO_DATA",
2208
+ INT2FIX(GPG_ERR_NO_DATA));
2209
+ rb_define_const (mGPGME, "GPG_ERR_CONFLICT",
2210
+ INT2FIX(GPG_ERR_CONFLICT));
2211
+ rb_define_const (mGPGME, "GPG_ERR_NOT_IMPLEMENTED",
2212
+ INT2FIX(GPG_ERR_NOT_IMPLEMENTED));
2213
+ rb_define_const (mGPGME, "GPG_ERR_DECRYPT_FAILED",
2214
+ INT2FIX(GPG_ERR_DECRYPT_FAILED));
2215
+ rb_define_const (mGPGME, "GPG_ERR_BAD_PASSPHRASE",
2216
+ INT2FIX(GPG_ERR_BAD_PASSPHRASE));
2217
+ rb_define_const (mGPGME, "GPG_ERR_KEY_EXPIRED",
2218
+ INT2FIX(GPG_ERR_KEY_EXPIRED));
2219
+ rb_define_const (mGPGME, "GPG_ERR_SIG_EXPIRED",
2220
+ INT2FIX(GPG_ERR_SIG_EXPIRED));
2221
+ rb_define_const (mGPGME, "GPG_ERR_CANCELED",
2222
+ INT2FIX(GPG_ERR_CANCELED));
2223
+ rb_define_const (mGPGME, "GPG_ERR_INV_ENGINE",
2224
+ INT2FIX(GPG_ERR_INV_ENGINE));
2225
+ rb_define_const (mGPGME, "GPG_ERR_AMBIGUOUS_NAME",
2226
+ INT2FIX(GPG_ERR_AMBIGUOUS_NAME));
2227
+ rb_define_const (mGPGME, "GPG_ERR_WRONG_KEY_USAGE",
2228
+ INT2FIX(GPG_ERR_WRONG_KEY_USAGE));
2229
+ rb_define_const (mGPGME, "GPG_ERR_CERT_REVOKED",
2230
+ INT2FIX(GPG_ERR_CERT_REVOKED));
2231
+ rb_define_const (mGPGME, "GPG_ERR_CERT_EXPIRED",
2232
+ INT2FIX(GPG_ERR_CERT_EXPIRED));
2233
+ rb_define_const (mGPGME, "GPG_ERR_NO_CRL_KNOWN",
2234
+ INT2FIX(GPG_ERR_NO_CRL_KNOWN));
2235
+ rb_define_const (mGPGME, "GPG_ERR_NO_POLICY_MATCH",
2236
+ INT2FIX(GPG_ERR_NO_POLICY_MATCH));
2237
+ rb_define_const (mGPGME, "GPG_ERR_NO_SECKEY",
2238
+ INT2FIX(GPG_ERR_NO_SECKEY));
2239
+ rb_define_const (mGPGME, "GPG_ERR_MISSING_CERT",
2240
+ INT2FIX(GPG_ERR_MISSING_CERT));
2241
+ rb_define_const (mGPGME, "GPG_ERR_BAD_CERT_CHAIN",
2242
+ INT2FIX(GPG_ERR_BAD_CERT_CHAIN));
2243
+ rb_define_const (mGPGME, "GPG_ERR_UNSUPPORTED_ALGORITHM",
2244
+ INT2FIX(GPG_ERR_UNSUPPORTED_ALGORITHM));
2245
+ rb_define_const (mGPGME, "GPG_ERR_BAD_SIGNATURE",
2246
+ INT2FIX(GPG_ERR_BAD_SIGNATURE));
2247
+ rb_define_const (mGPGME, "GPG_ERR_NO_PUBKEY",
2248
+ INT2FIX(GPG_ERR_NO_PUBKEY));
2249
+
2250
+ /* gpgme_err_source_t */
2251
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_UNKNOWN",
2252
+ INT2FIX(GPG_ERR_SOURCE_UNKNOWN));
2253
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_GPGME",
2254
+ INT2FIX(GPG_ERR_SOURCE_GPGME));
2255
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_GPG",
2256
+ INT2FIX(GPG_ERR_SOURCE_GPG));
2257
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_GPGSM",
2258
+ INT2FIX(GPG_ERR_SOURCE_GPGSM));
2259
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_GCRYPT",
2260
+ INT2FIX(GPG_ERR_SOURCE_GCRYPT));
2261
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_GPGAGENT",
2262
+ INT2FIX(GPG_ERR_SOURCE_GPGAGENT));
2263
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_PINENTRY",
2264
+ INT2FIX(GPG_ERR_SOURCE_PINENTRY));
2265
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_SCD",
2266
+ INT2FIX(GPG_ERR_SOURCE_SCD));
2267
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_KEYBOX",
2268
+ INT2FIX(GPG_ERR_SOURCE_KEYBOX));
2269
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_USER_1",
2270
+ INT2FIX(GPG_ERR_SOURCE_USER_1));
2271
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_USER_2",
2272
+ INT2FIX(GPG_ERR_SOURCE_USER_2));
2273
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_USER_3",
2274
+ INT2FIX(GPG_ERR_SOURCE_USER_3));
2275
+ rb_define_const (mGPGME, "GPG_ERR_SOURCE_USER_4",
2276
+ INT2FIX(GPG_ERR_SOURCE_USER_4));
2277
+
2278
+ /* gpgme_data_encoding_t */
2279
+ rb_define_const (mGPGME, "GPGME_DATA_ENCODING_NONE",
2280
+ INT2FIX(GPGME_DATA_ENCODING_NONE));
2281
+ rb_define_const (mGPGME, "GPGME_DATA_ENCODING_BINARY",
2282
+ INT2FIX(GPGME_DATA_ENCODING_BINARY));
2283
+ rb_define_const (mGPGME, "GPGME_DATA_ENCODING_BASE64",
2284
+ INT2FIX(GPGME_DATA_ENCODING_BASE64));
2285
+ rb_define_const (mGPGME, "GPGME_DATA_ENCODING_ARMOR",
2286
+ INT2FIX(GPGME_DATA_ENCODING_ARMOR));
2287
+
2288
+ /* gpgme_sig_stat_t */
2289
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_NONE",
2290
+ INT2FIX(GPGME_SIG_STAT_NONE));
2291
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_GOOD",
2292
+ INT2FIX(GPGME_SIG_STAT_GOOD));
2293
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_BAD",
2294
+ INT2FIX(GPGME_SIG_STAT_BAD));
2295
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_NOKEY",
2296
+ INT2FIX(GPGME_SIG_STAT_NOKEY));
2297
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_NOSIG",
2298
+ INT2FIX(GPGME_SIG_STAT_NOSIG));
2299
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_ERROR",
2300
+ INT2FIX(GPGME_SIG_STAT_ERROR));
2301
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_DIFF",
2302
+ INT2FIX(GPGME_SIG_STAT_DIFF));
2303
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_GOOD_EXP",
2304
+ INT2FIX(GPGME_SIG_STAT_GOOD_EXP));
2305
+ rb_define_const (mGPGME, "GPGME_SIG_STAT_GOOD_EXPKEY",
2306
+ INT2FIX(GPGME_SIG_STAT_GOOD_EXPKEY));
2307
+
2308
+ /* gpgme_sigsum_t */
2309
+ rb_define_const (mGPGME, "GPGME_SIGSUM_VALID",
2310
+ INT2FIX(GPGME_SIGSUM_VALID));
2311
+ rb_define_const (mGPGME, "GPGME_SIGSUM_GREEN",
2312
+ INT2FIX(GPGME_SIGSUM_GREEN));
2313
+ rb_define_const (mGPGME, "GPGME_SIGSUM_RED",
2314
+ INT2FIX(GPGME_SIGSUM_RED));
2315
+ rb_define_const (mGPGME, "GPGME_SIGSUM_KEY_REVOKED",
2316
+ INT2FIX(GPGME_SIGSUM_KEY_REVOKED));
2317
+ rb_define_const (mGPGME, "GPGME_SIGSUM_KEY_EXPIRED",
2318
+ INT2FIX(GPGME_SIGSUM_KEY_EXPIRED));
2319
+ rb_define_const (mGPGME, "GPGME_SIGSUM_SIG_EXPIRED",
2320
+ INT2FIX(GPGME_SIGSUM_SIG_EXPIRED));
2321
+ rb_define_const (mGPGME, "GPGME_SIGSUM_KEY_MISSING",
2322
+ INT2FIX(GPGME_SIGSUM_KEY_MISSING));
2323
+ rb_define_const (mGPGME, "GPGME_SIGSUM_CRL_MISSING",
2324
+ INT2FIX(GPGME_SIGSUM_CRL_MISSING));
2325
+ rb_define_const (mGPGME, "GPGME_SIGSUM_CRL_TOO_OLD",
2326
+ INT2FIX(GPGME_SIGSUM_CRL_TOO_OLD));
2327
+ rb_define_const (mGPGME, "GPGME_SIGSUM_BAD_POLICY",
2328
+ INT2FIX(GPGME_SIGSUM_BAD_POLICY));
2329
+ rb_define_const (mGPGME, "GPGME_SIGSUM_SYS_ERROR",
2330
+ INT2FIX(GPGME_SIGSUM_SYS_ERROR));
2331
+
2332
+ /* gpgme_sig_mode_t */
2333
+ rb_define_const (mGPGME, "GPGME_SIG_MODE_NORMAL",
2334
+ INT2FIX(GPGME_SIG_MODE_NORMAL));
2335
+ rb_define_const (mGPGME, "GPGME_SIG_MODE_DETACH",
2336
+ INT2FIX(GPGME_SIG_MODE_DETACH));
2337
+ rb_define_const (mGPGME, "GPGME_SIG_MODE_CLEAR",
2338
+ INT2FIX(GPGME_SIG_MODE_CLEAR));
2339
+
2340
+ /* gpgme_attr_t */
2341
+ rb_define_const (mGPGME, "GPGME_ATTR_KEYID",
2342
+ INT2FIX(GPGME_ATTR_KEYID));
2343
+ rb_define_const (mGPGME, "GPGME_ATTR_FPR",
2344
+ INT2FIX(GPGME_ATTR_FPR));
2345
+ rb_define_const (mGPGME, "GPGME_ATTR_ALGO",
2346
+ INT2FIX(GPGME_ATTR_ALGO));
2347
+ rb_define_const (mGPGME, "GPGME_ATTR_LEN",
2348
+ INT2FIX(GPGME_ATTR_LEN));
2349
+ rb_define_const (mGPGME, "GPGME_ATTR_CREATED",
2350
+ INT2FIX(GPGME_ATTR_CREATED));
2351
+ rb_define_const (mGPGME, "GPGME_ATTR_EXPIRE",
2352
+ INT2FIX(GPGME_ATTR_EXPIRE));
2353
+ rb_define_const (mGPGME, "GPGME_ATTR_OTRUST",
2354
+ INT2FIX(GPGME_ATTR_OTRUST));
2355
+ rb_define_const (mGPGME, "GPGME_ATTR_USERID",
2356
+ INT2FIX(GPGME_ATTR_USERID));
2357
+ rb_define_const (mGPGME, "GPGME_ATTR_NAME",
2358
+ INT2FIX(GPGME_ATTR_NAME));
2359
+ rb_define_const (mGPGME, "GPGME_ATTR_EMAIL",
2360
+ INT2FIX(GPGME_ATTR_EMAIL));
2361
+ rb_define_const (mGPGME, "GPGME_ATTR_COMMENT",
2362
+ INT2FIX(GPGME_ATTR_COMMENT));
2363
+ rb_define_const (mGPGME, "GPGME_ATTR_VALIDITY",
2364
+ INT2FIX(GPGME_ATTR_VALIDITY));
2365
+ rb_define_const (mGPGME, "GPGME_ATTR_LEVEL",
2366
+ INT2FIX(GPGME_ATTR_LEVEL));
2367
+ rb_define_const (mGPGME, "GPGME_ATTR_TYPE",
2368
+ INT2FIX(GPGME_ATTR_TYPE));
2369
+ rb_define_const (mGPGME, "GPGME_ATTR_IS_SECRET",
2370
+ INT2FIX(GPGME_ATTR_IS_SECRET));
2371
+ rb_define_const (mGPGME, "GPGME_ATTR_KEY_REVOKED",
2372
+ INT2FIX(GPGME_ATTR_KEY_REVOKED));
2373
+ rb_define_const (mGPGME, "GPGME_ATTR_KEY_INVALID",
2374
+ INT2FIX(GPGME_ATTR_KEY_INVALID));
2375
+ rb_define_const (mGPGME, "GPGME_ATTR_UID_REVOKED",
2376
+ INT2FIX(GPGME_ATTR_UID_REVOKED));
2377
+ rb_define_const (mGPGME, "GPGME_ATTR_UID_INVALID",
2378
+ INT2FIX(GPGME_ATTR_UID_INVALID));
2379
+ rb_define_const (mGPGME, "GPGME_ATTR_KEY_CAPS",
2380
+ INT2FIX(GPGME_ATTR_KEY_CAPS));
2381
+ rb_define_const (mGPGME, "GPGME_ATTR_CAN_ENCRYPT",
2382
+ INT2FIX(GPGME_ATTR_CAN_ENCRYPT));
2383
+ rb_define_const (mGPGME, "GPGME_ATTR_CAN_SIGN",
2384
+ INT2FIX(GPGME_ATTR_CAN_SIGN));
2385
+ rb_define_const (mGPGME, "GPGME_ATTR_CAN_CERTIFY",
2386
+ INT2FIX(GPGME_ATTR_CAN_CERTIFY));
2387
+ rb_define_const (mGPGME, "GPGME_ATTR_KEY_EXPIRED",
2388
+ INT2FIX(GPGME_ATTR_KEY_EXPIRED));
2389
+ rb_define_const (mGPGME, "GPGME_ATTR_KEY_DISABLED",
2390
+ INT2FIX(GPGME_ATTR_KEY_DISABLED));
2391
+ rb_define_const (mGPGME, "GPGME_ATTR_SERIAL",
2392
+ INT2FIX(GPGME_ATTR_SERIAL));
2393
+ rb_define_const (mGPGME, "GPGME_ATTR_ISSUER",
2394
+ INT2FIX(GPGME_ATTR_ISSUER));
2395
+ rb_define_const (mGPGME, "GPGME_ATTR_CHAINID",
2396
+ INT2FIX(GPGME_ATTR_CHAINID));
2397
+ rb_define_const (mGPGME, "GPGME_ATTR_SIG_STATUS",
2398
+ INT2FIX(GPGME_ATTR_SIG_STATUS));
2399
+ rb_define_const (mGPGME, "GPGME_ATTR_ERRTOK",
2400
+ INT2FIX(GPGME_ATTR_ERRTOK));
2401
+ rb_define_const (mGPGME, "GPGME_ATTR_SIG_SUMMARY",
2402
+ INT2FIX(GPGME_ATTR_SIG_SUMMARY));
2403
+
2404
+ /* gpgme_validity_t */
2405
+ rb_define_const (mGPGME, "GPGME_VALIDITY_UNKNOWN",
2406
+ INT2FIX(GPGME_VALIDITY_UNKNOWN));
2407
+ rb_define_const (mGPGME, "GPGME_VALIDITY_UNDEFINED",
2408
+ INT2FIX(GPGME_VALIDITY_UNDEFINED));
2409
+ rb_define_const (mGPGME, "GPGME_VALIDITY_NEVER",
2410
+ INT2FIX(GPGME_VALIDITY_NEVER));
2411
+ rb_define_const (mGPGME, "GPGME_VALIDITY_MARGINAL",
2412
+ INT2FIX(GPGME_VALIDITY_MARGINAL));
2413
+ rb_define_const (mGPGME, "GPGME_VALIDITY_FULL",
2414
+ INT2FIX(GPGME_VALIDITY_FULL));
2415
+ rb_define_const (mGPGME, "GPGME_VALIDITY_ULTIMATE",
2416
+ INT2FIX(GPGME_VALIDITY_ULTIMATE));
2417
+
2418
+ /* gpgme_protocol_t */
2419
+ rb_define_const (mGPGME, "GPGME_PROTOCOL_OpenPGP",
2420
+ INT2FIX(GPGME_PROTOCOL_OpenPGP));
2421
+ rb_define_const (mGPGME, "GPGME_PROTOCOL_CMS",
2422
+ INT2FIX(GPGME_PROTOCOL_CMS));
2423
+ /* This protocol was added in 1.2.0. */
2424
+ #ifdef GPGME_PROTOCOL_ASSUAN
2425
+ rb_define_const (mGPGME, "GPGME_PROTOCOL_ASSUAN",
2426
+ INT2FIX(GPGME_PROTOCOL_ASSUAN))
2427
+ #endif
2428
+
2429
+ /* gpgme_status_code_t */
2430
+ rb_define_const (mGPGME, "GPGME_STATUS_EOF",
2431
+ INT2FIX(GPGME_STATUS_EOF));
2432
+ /* mkstatus starts here */
2433
+ rb_define_const (mGPGME, "GPGME_STATUS_ENTER",
2434
+ INT2FIX(GPGME_STATUS_ENTER));
2435
+ rb_define_const (mGPGME, "GPGME_STATUS_LEAVE",
2436
+ INT2FIX(GPGME_STATUS_LEAVE));
2437
+ rb_define_const (mGPGME, "GPGME_STATUS_ABORT",
2438
+ INT2FIX(GPGME_STATUS_ABORT));
2439
+
2440
+ rb_define_const (mGPGME, "GPGME_STATUS_GOODSIG",
2441
+ INT2FIX(GPGME_STATUS_GOODSIG));
2442
+ rb_define_const (mGPGME, "GPGME_STATUS_BADSIG",
2443
+ INT2FIX(GPGME_STATUS_BADSIG));
2444
+ rb_define_const (mGPGME, "GPGME_STATUS_ERRSIG",
2445
+ INT2FIX(GPGME_STATUS_ERRSIG));
2446
+
2447
+ rb_define_const (mGPGME, "GPGME_STATUS_BADARMOR",
2448
+ INT2FIX(GPGME_STATUS_BADARMOR));
2449
+
2450
+ rb_define_const (mGPGME, "GPGME_STATUS_RSA_OR_IDEA",
2451
+ INT2FIX(GPGME_STATUS_RSA_OR_IDEA));
2452
+ rb_define_const (mGPGME, "GPGME_STATUS_KEYEXPIRED",
2453
+ INT2FIX(GPGME_STATUS_KEYEXPIRED));
2454
+ rb_define_const (mGPGME, "GPGME_STATUS_KEYREVOKED",
2455
+ INT2FIX(GPGME_STATUS_KEYREVOKED));
2456
+
2457
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUST_UNDEFINED",
2458
+ INT2FIX(GPGME_STATUS_TRUST_UNDEFINED));
2459
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUST_NEVER",
2460
+ INT2FIX(GPGME_STATUS_TRUST_NEVER));
2461
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUST_MARGINAL",
2462
+ INT2FIX(GPGME_STATUS_TRUST_MARGINAL));
2463
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUST_FULLY",
2464
+ INT2FIX(GPGME_STATUS_TRUST_FULLY));
2465
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUST_ULTIMATE",
2466
+ INT2FIX(GPGME_STATUS_TRUST_ULTIMATE));
2467
+
2468
+ rb_define_const (mGPGME, "GPGME_STATUS_SHM_INFO",
2469
+ INT2FIX(GPGME_STATUS_SHM_INFO));
2470
+ rb_define_const (mGPGME, "GPGME_STATUS_SHM_GET",
2471
+ INT2FIX(GPGME_STATUS_SHM_GET));
2472
+ rb_define_const (mGPGME, "GPGME_STATUS_SHM_GET_BOOL",
2473
+ INT2FIX(GPGME_STATUS_SHM_GET_BOOL));
2474
+ rb_define_const (mGPGME, "GPGME_STATUS_SHM_GET_HIDDEN",
2475
+ INT2FIX(GPGME_STATUS_SHM_GET_HIDDEN));
2476
+
2477
+ rb_define_const (mGPGME, "GPGME_STATUS_NEED_PASSPHRASE",
2478
+ INT2FIX(GPGME_STATUS_NEED_PASSPHRASE));
2479
+ rb_define_const (mGPGME, "GPGME_STATUS_VALIDSIG",
2480
+ INT2FIX(GPGME_STATUS_VALIDSIG));
2481
+ rb_define_const (mGPGME, "GPGME_STATUS_SIG_ID",
2482
+ INT2FIX(GPGME_STATUS_SIG_ID));
2483
+ rb_define_const (mGPGME, "GPGME_STATUS_ENC_TO",
2484
+ INT2FIX(GPGME_STATUS_ENC_TO));
2485
+ rb_define_const (mGPGME, "GPGME_STATUS_NODATA",
2486
+ INT2FIX(GPGME_STATUS_NODATA));
2487
+ rb_define_const (mGPGME, "GPGME_STATUS_BAD_PASSPHRASE",
2488
+ INT2FIX(GPGME_STATUS_BAD_PASSPHRASE));
2489
+ rb_define_const (mGPGME, "GPGME_STATUS_NO_PUBKEY",
2490
+ INT2FIX(GPGME_STATUS_NO_PUBKEY));
2491
+ rb_define_const (mGPGME, "GPGME_STATUS_NO_SECKEY",
2492
+ INT2FIX(GPGME_STATUS_NO_SECKEY));
2493
+ rb_define_const (mGPGME, "GPGME_STATUS_NEED_PASSPHRASE_SYM",
2494
+ INT2FIX(GPGME_STATUS_NEED_PASSPHRASE_SYM));
2495
+ rb_define_const (mGPGME, "GPGME_STATUS_DECRYPTION_FAILED",
2496
+ INT2FIX(GPGME_STATUS_DECRYPTION_FAILED));
2497
+ rb_define_const (mGPGME, "GPGME_STATUS_DECRYPTION_OKAY",
2498
+ INT2FIX(GPGME_STATUS_DECRYPTION_OKAY));
2499
+ rb_define_const (mGPGME, "GPGME_STATUS_MISSING_PASSPHRASE",
2500
+ INT2FIX(GPGME_STATUS_MISSING_PASSPHRASE));
2501
+ rb_define_const (mGPGME, "GPGME_STATUS_GOOD_PASSPHRASE",
2502
+ INT2FIX(GPGME_STATUS_GOOD_PASSPHRASE));
2503
+ rb_define_const (mGPGME, "GPGME_STATUS_GOODMDC",
2504
+ INT2FIX(GPGME_STATUS_GOODMDC));
2505
+ rb_define_const (mGPGME, "GPGME_STATUS_BADMDC",
2506
+ INT2FIX(GPGME_STATUS_BADMDC));
2507
+ rb_define_const (mGPGME, "GPGME_STATUS_ERRMDC",
2508
+ INT2FIX(GPGME_STATUS_ERRMDC));
2509
+ rb_define_const (mGPGME, "GPGME_STATUS_IMPORTED",
2510
+ INT2FIX(GPGME_STATUS_IMPORTED));
2511
+ rb_define_const (mGPGME, "GPGME_STATUS_IMPORT_RES",
2512
+ INT2FIX(GPGME_STATUS_IMPORT_RES));
2513
+ rb_define_const (mGPGME, "GPGME_STATUS_FILE_START",
2514
+ INT2FIX(GPGME_STATUS_FILE_START));
2515
+ rb_define_const (mGPGME, "GPGME_STATUS_FILE_DONE",
2516
+ INT2FIX(GPGME_STATUS_FILE_DONE));
2517
+ rb_define_const (mGPGME, "GPGME_STATUS_FILE_ERROR",
2518
+ INT2FIX(GPGME_STATUS_FILE_ERROR));
2519
+
2520
+ rb_define_const (mGPGME, "GPGME_STATUS_BEGIN_DECRYPTION",
2521
+ INT2FIX(GPGME_STATUS_BEGIN_DECRYPTION));
2522
+ rb_define_const (mGPGME, "GPGME_STATUS_END_DECRYPTION",
2523
+ INT2FIX(GPGME_STATUS_END_DECRYPTION));
2524
+ rb_define_const (mGPGME, "GPGME_STATUS_BEGIN_ENCRYPTION",
2525
+ INT2FIX(GPGME_STATUS_BEGIN_ENCRYPTION));
2526
+ rb_define_const (mGPGME, "GPGME_STATUS_END_ENCRYPTION",
2527
+ INT2FIX(GPGME_STATUS_END_ENCRYPTION));
2528
+
2529
+ rb_define_const (mGPGME, "GPGME_STATUS_DELETE_PROBLEM",
2530
+ INT2FIX(GPGME_STATUS_DELETE_PROBLEM));
2531
+ rb_define_const (mGPGME, "GPGME_STATUS_GET_BOOL",
2532
+ INT2FIX(GPGME_STATUS_GET_BOOL));
2533
+ rb_define_const (mGPGME, "GPGME_STATUS_GET_LINE",
2534
+ INT2FIX(GPGME_STATUS_GET_LINE));
2535
+ rb_define_const (mGPGME, "GPGME_STATUS_GET_HIDDEN",
2536
+ INT2FIX(GPGME_STATUS_GET_HIDDEN));
2537
+ rb_define_const (mGPGME, "GPGME_STATUS_GOT_IT",
2538
+ INT2FIX(GPGME_STATUS_GOT_IT));
2539
+ rb_define_const (mGPGME, "GPGME_STATUS_PROGRESS",
2540
+ INT2FIX(GPGME_STATUS_PROGRESS));
2541
+ rb_define_const (mGPGME, "GPGME_STATUS_SIG_CREATED",
2542
+ INT2FIX(GPGME_STATUS_SIG_CREATED));
2543
+ rb_define_const (mGPGME, "GPGME_STATUS_SESSION_KEY",
2544
+ INT2FIX(GPGME_STATUS_SESSION_KEY));
2545
+ rb_define_const (mGPGME, "GPGME_STATUS_NOTATION_NAME",
2546
+ INT2FIX(GPGME_STATUS_NOTATION_NAME));
2547
+ rb_define_const (mGPGME, "GPGME_STATUS_NOTATION_DATA",
2548
+ INT2FIX(GPGME_STATUS_NOTATION_DATA));
2549
+ rb_define_const (mGPGME, "GPGME_STATUS_POLICY_URL",
2550
+ INT2FIX(GPGME_STATUS_POLICY_URL));
2551
+ rb_define_const (mGPGME, "GPGME_STATUS_BEGIN_STREAM",
2552
+ INT2FIX(GPGME_STATUS_BEGIN_STREAM));
2553
+ rb_define_const (mGPGME, "GPGME_STATUS_END_STREAM",
2554
+ INT2FIX(GPGME_STATUS_END_STREAM));
2555
+ rb_define_const (mGPGME, "GPGME_STATUS_KEY_CREATED",
2556
+ INT2FIX(GPGME_STATUS_KEY_CREATED));
2557
+ rb_define_const (mGPGME, "GPGME_STATUS_USERID_HINT",
2558
+ INT2FIX(GPGME_STATUS_USERID_HINT));
2559
+ rb_define_const (mGPGME, "GPGME_STATUS_UNEXPECTED",
2560
+ INT2FIX(GPGME_STATUS_UNEXPECTED));
2561
+ rb_define_const (mGPGME, "GPGME_STATUS_INV_RECP",
2562
+ INT2FIX(GPGME_STATUS_INV_RECP));
2563
+ rb_define_const (mGPGME, "GPGME_STATUS_NO_RECP",
2564
+ INT2FIX(GPGME_STATUS_NO_RECP));
2565
+ rb_define_const (mGPGME, "GPGME_STATUS_ALREADY_SIGNED",
2566
+ INT2FIX(GPGME_STATUS_ALREADY_SIGNED));
2567
+ rb_define_const (mGPGME, "GPGME_STATUS_SIGEXPIRED",
2568
+ INT2FIX(GPGME_STATUS_SIGEXPIRED));
2569
+ rb_define_const (mGPGME, "GPGME_STATUS_EXPSIG",
2570
+ INT2FIX(GPGME_STATUS_EXPSIG));
2571
+ rb_define_const (mGPGME, "GPGME_STATUS_EXPKEYSIG",
2572
+ INT2FIX(GPGME_STATUS_EXPKEYSIG));
2573
+ rb_define_const (mGPGME, "GPGME_STATUS_TRUNCATED",
2574
+ INT2FIX(GPGME_STATUS_TRUNCATED));
2575
+ rb_define_const (mGPGME, "GPGME_STATUS_ERROR",
2576
+ INT2FIX(GPGME_STATUS_ERROR));
2577
+ /* These status codes have been available since 1.1.1. */
2578
+ #ifdef GPGME_STATUS_PKA_TRUST_BAD
2579
+ rb_define_const (mGPGME, "GPGME_STATUS_PKA_TRUST_BAD",
2580
+ INT2FIX(GPGME_STATUS_PKA_TRUST_BAD));
2581
+ rb_define_const (mGPGME, "GPGME_STATUS_PKA_TRUST_GOOD",
2582
+ INT2FIX(GPGME_STATUS_PKA_TRUST_GOOD));
2583
+ #endif
2584
+
2585
+ /* The available keylist mode flags. */
2586
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_LOCAL",
2587
+ INT2FIX(GPGME_KEYLIST_MODE_LOCAL));
2588
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_EXTERN",
2589
+ INT2FIX(GPGME_KEYLIST_MODE_EXTERN));
2590
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_SIGS",
2591
+ INT2FIX(GPGME_KEYLIST_MODE_SIGS));
2592
+ /* This flag was added in 1.1.1. */
2593
+ #ifdef GPGME_KEYLIST_MODE_SIG_NOTATIONS
2594
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_SIG_NOTATIONS",
2595
+ INT2FIX(GPGME_KEYLIST_MODE_SIG_NOTATIONS));
2596
+ #endif
2597
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_VALIDATE",
2598
+ INT2FIX(GPGME_KEYLIST_MODE_VALIDATE));
2599
+ /* This flag was added in 1.2.0. */
2600
+ #ifdef GPGME_KEYLIST_MODE_EPHEMERAL
2601
+ rb_define_const (mGPGME, "GPGME_KEYLIST_MODE_EPHEMERAL",
2602
+ INT2FIX(GPGME_KEYLIST_MODE_EPHEMERAL));
2603
+ #endif
2604
+
2605
+ /* The available flags for status field of gpgme_import_status_t. */
2606
+ rb_define_const (mGPGME, "GPGME_IMPORT_NEW", INT2FIX(GPGME_IMPORT_NEW));
2607
+ rb_define_const (mGPGME, "GPGME_IMPORT_UID", INT2FIX(GPGME_IMPORT_UID));
2608
+ rb_define_const (mGPGME, "GPGME_IMPORT_SIG", INT2FIX(GPGME_IMPORT_SIG));
2609
+ rb_define_const (mGPGME, "GPGME_IMPORT_SUBKEY",
2610
+ INT2FIX(GPGME_IMPORT_SUBKEY));
2611
+ rb_define_const (mGPGME, "GPGME_IMPORT_SECRET",
2612
+ INT2FIX(GPGME_IMPORT_SECRET));
2613
+
2614
+ /* The available flags for gpgme_op_encrypt. */
2615
+ rb_define_const (mGPGME, "GPGME_ENCRYPT_ALWAYS_TRUST",
2616
+ INT2FIX(GPGME_ENCRYPT_ALWAYS_TRUST));
2617
+ /* This flag was added in 1.2.0. */
2618
+ #ifdef GPGME_ENCRYPT_NO_ENCRYPT_TO
2619
+ rb_define_const (mGPGME, "GPGME_ENCRYPT_NO_ENCRYPT_TO",
2620
+ INT2FIX(GPGME_ENCRYPT_NO_ENCRYPT_TO));
2621
+ #endif
2622
+ }