gpgme 2.0.23 → 2.0.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/gpgme/extconf.rb +20 -10
- data/ext/gpgme/gpgme_n.c +228 -4
- data/lib/gpgme/constants.rb +120 -31
- data/lib/gpgme/ctx.rb +104 -8
- data/lib/gpgme/key.rb +4 -3
- data/lib/gpgme/version.rb +1 -1
- data/lib/gpgme.rb +0 -2
- data/ports/archives/gpgme-2.0.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-3.0.2.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.55.tar.bz2 +0 -0
- data/test/crypto_test.rb +2 -2
- data/test/ctx_test.rb +94 -0
- data/test/data_test.rb +2 -2
- metadata +6 -6
- data/ports/archives/gpgme-1.21.0.tar.bz2 +0 -0
- data/ports/archives/libassuan-2.5.6.tar.bz2 +0 -0
- data/ports/archives/libgpg-error-1.47.tar.bz2 +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c7d5f64ee6914eb120fbd884d55f5f7d9decfadc4c4ca86deb663696190517a
|
4
|
+
data.tar.gz: c58815644c21156c37333b27cc0de594a330f34aa040f3533f44aa8b9706b83b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0775b291a09719b998107266313e0aa2185ebc6b337e4f038464440ff742df705dd23097f7041ad674a0cdac87400c45427d0b3094c96491002192a2f179a4ca
|
7
|
+
data.tar.gz: 335c6520b7362f7f0e382ac852564065abde3a82367d299133a87c97cde3940cfb65fd37c4ff36c470b1d2c4123128f281aab14a45efdabe719828435ccd5761
|
data/ext/gpgme/extconf.rb
CHANGED
@@ -25,12 +25,12 @@ if arg_config('--clean')
|
|
25
25
|
|
26
26
|
# clean the ports build directory
|
27
27
|
Pathname.glob(pwd.join('tmp', '*', 'ports')) { |dir|
|
28
|
-
FileUtils.rm_rf(dir,
|
29
|
-
FileUtils.rmdir(dir.parent,
|
28
|
+
FileUtils.rm_rf(dir, verbose: true)
|
29
|
+
FileUtils.rmdir(dir.parent, parents: true, verbose: true)
|
30
30
|
}
|
31
31
|
|
32
32
|
# ports installation can be safely removed if statically linked.
|
33
|
-
FileUtils.rm_rf(root + 'ports',
|
33
|
+
FileUtils.rm_rf(root + 'ports', verbose: true)
|
34
34
|
end
|
35
35
|
|
36
36
|
exit
|
@@ -65,11 +65,11 @@ EOS
|
|
65
65
|
require 'rubygems'
|
66
66
|
require 'mini_portile2'
|
67
67
|
|
68
|
-
libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.
|
68
|
+
libgpg_error_recipe = MiniPortile.new('libgpg-error', '1.55').tap do |recipe|
|
69
69
|
recipe.target = File.join(ROOT, "ports")
|
70
70
|
recipe.files = [{
|
71
71
|
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
|
72
|
-
:sha256 => '
|
72
|
+
:sha256 => '95b178148863f07d45df0cea67e880a79b9ef71f5d230baddc0071128516ef78'
|
73
73
|
}]
|
74
74
|
recipe.configure_options = [
|
75
75
|
'--enable-install-gpg-error-config',
|
@@ -86,11 +86,11 @@ EOS
|
|
86
86
|
recipe.activate
|
87
87
|
end
|
88
88
|
|
89
|
-
libassuan_recipe = MiniPortile.new('libassuan', '
|
89
|
+
libassuan_recipe = MiniPortile.new('libassuan', '3.0.2').tap do |recipe|
|
90
90
|
recipe.target = File.join(ROOT, "ports")
|
91
91
|
recipe.files = [{
|
92
92
|
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
|
93
|
-
:sha256 => '
|
93
|
+
:sha256 => 'd2931cdad266e633510f9970e1a2f346055e351bb19f9b78912475b8074c36f6'
|
94
94
|
}]
|
95
95
|
recipe.configure_options = [
|
96
96
|
'--disable-shared',
|
@@ -106,11 +106,21 @@ EOS
|
|
106
106
|
recipe.activate
|
107
107
|
end
|
108
108
|
|
109
|
-
|
109
|
+
pkg_config_paths = [
|
110
|
+
File.join(libgpg_error_recipe.lib_path, 'pkgconfig'),
|
111
|
+
File.join(libassuan_recipe.lib_path, 'pkgconfig'),
|
112
|
+
]
|
113
|
+
|
114
|
+
# Ensure that the locally-built libraries take precedence. gpgme runs
|
115
|
+
# `gpgrt-config libassuan` and could pull in the system libassuan
|
116
|
+
# if PKG_CONFIG_PATH is not set properly.
|
117
|
+
ENV["PKG_CONFIG_PATH"] = [*pkg_config_paths, ENV["PKG_CONFIG_PATH"]].compact.join(File::PATH_SEPARATOR)
|
118
|
+
|
119
|
+
gpgme_recipe = MiniPortile.new('gpgme', '2.0.0').tap do |recipe|
|
110
120
|
recipe.target = File.join(ROOT, "ports")
|
111
121
|
recipe.files = [{
|
112
122
|
:url => "https://www.gnupg.org/ftp/gcrypt/#{recipe.name}/#{recipe.name}-#{recipe.version}.tar.bz2",
|
113
|
-
:sha256 => '
|
123
|
+
:sha256 => 'ddf161d3c41ff6a3fcbaf4be6c6e305ca4ef1cc3f1ecdfce0c8c2a167c0cc36d'
|
114
124
|
}]
|
115
125
|
recipe.configure_options = [
|
116
126
|
'--disable-shared',
|
@@ -126,7 +136,7 @@ EOS
|
|
126
136
|
'--disable-g13-test',
|
127
137
|
# We only need the C API.
|
128
138
|
'--disable-languages',
|
129
|
-
"CFLAGS=-fPIC #{ENV["CFLAGS"]}",
|
139
|
+
"CFLAGS=-D_LARGEFILE64_SOURCE -fPIC #{ENV["CFLAGS"]}",
|
130
140
|
]
|
131
141
|
checkpoint = "#{recipe.target}/#{recipe.name}-#{recipe.version}-#{recipe.host}.installed"
|
132
142
|
unless File.exist?(checkpoint)
|
data/ext/gpgme/gpgme_n.c
CHANGED
@@ -106,11 +106,13 @@
|
|
106
106
|
#define UNWRAP_GPGME_KEY(vkey, key) \
|
107
107
|
Data_Get_Struct(vkey, struct _gpgme_key, key)
|
108
108
|
|
109
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
109
110
|
#define WRAP_GPGME_TRUST_ITEM(item) \
|
110
111
|
Data_Wrap_Struct(cTrustItem, 0, gpgme_trust_item_unref, item)
|
111
112
|
/* `gpgme_trust_item_t' is typedef'ed as `struct _gpgme_trust_item *'. */
|
112
113
|
#define UNWRAP_GPGME_TRUST_ITEM(vitem, item) \
|
113
114
|
Data_Get_Struct(vitem, struct _gpgme_trust_item, item)
|
115
|
+
#endif
|
114
116
|
|
115
117
|
static VALUE cEngineInfo,
|
116
118
|
cCtx,
|
@@ -123,7 +125,9 @@ static VALUE cEngineInfo,
|
|
123
125
|
cNewSignature,
|
124
126
|
cSignature,
|
125
127
|
cSigNotation,
|
128
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
126
129
|
cTrustItem,
|
130
|
+
#endif
|
127
131
|
cRecipient,
|
128
132
|
cDecryptResult,
|
129
133
|
cVerifyResult,
|
@@ -264,19 +268,19 @@ rb_s_gpgme_hash_algo_name (VALUE dummy, VALUE valgo)
|
|
264
268
|
static VALUE
|
265
269
|
rb_s_gpgme_err_code (VALUE dummy, VALUE verr)
|
266
270
|
{
|
267
|
-
return INT2FIX(gpgme_err_code (
|
271
|
+
return INT2FIX(gpgme_err_code (NUM2UINT(verr)));
|
268
272
|
}
|
269
273
|
|
270
274
|
static VALUE
|
271
275
|
rb_s_gpgme_err_source (VALUE dummy, VALUE verr)
|
272
276
|
{
|
273
|
-
return INT2FIX(gpgme_err_source (
|
277
|
+
return INT2FIX(gpgme_err_source (NUM2UINT(verr)));
|
274
278
|
}
|
275
279
|
|
276
280
|
static VALUE
|
277
281
|
rb_s_gpgme_strerror (VALUE dummy, VALUE verr)
|
278
282
|
{
|
279
|
-
return rb_str_new2 (gpgme_strerror (
|
283
|
+
return rb_str_new2 (gpgme_strerror (NUM2UINT(verr)));
|
280
284
|
}
|
281
285
|
|
282
286
|
static VALUE
|
@@ -299,7 +303,7 @@ rb_s_gpgme_data_new_from_mem (VALUE dummy, VALUE rdh, VALUE vbuffer,
|
|
299
303
|
size_t size = NUM2UINT(vsize);
|
300
304
|
gpgme_error_t err;
|
301
305
|
|
302
|
-
if (RSTRING_LEN(vbuffer) < size)
|
306
|
+
if ((size_t)RSTRING_LEN(vbuffer) < size)
|
303
307
|
rb_raise (rb_eArgError, "argument out of range");
|
304
308
|
|
305
309
|
err = gpgme_data_new_from_mem (&dh, StringValuePtr(vbuffer), size, 1);
|
@@ -514,6 +518,45 @@ rb_s_gpgme_release (VALUE dummy, VALUE vctx)
|
|
514
518
|
return Qnil;
|
515
519
|
}
|
516
520
|
|
521
|
+
static VALUE
|
522
|
+
rb_s_gpgme_set_ctx_flag (VALUE dummy, VALUE vctx, VALUE vname, VALUE vstr)
|
523
|
+
{
|
524
|
+
gpgme_ctx_t ctx;
|
525
|
+
gpgme_error_t err;
|
526
|
+
char* name;
|
527
|
+
char* str;
|
528
|
+
|
529
|
+
name = StringValueCStr(vname);
|
530
|
+
str = StringValueCStr(vstr);
|
531
|
+
|
532
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
533
|
+
if (!ctx)
|
534
|
+
rb_raise (rb_eArgError, "released ctx");
|
535
|
+
|
536
|
+
err = gpgme_set_ctx_flag(ctx, name, str);
|
537
|
+
return LONG2NUM(err);
|
538
|
+
}
|
539
|
+
|
540
|
+
static VALUE
|
541
|
+
rb_s_gpgme_get_ctx_flag (VALUE dummy, VALUE vctx, VALUE vname)
|
542
|
+
{
|
543
|
+
gpgme_ctx_t ctx;
|
544
|
+
const char* name;
|
545
|
+
|
546
|
+
name = StringValueCStr(vname);
|
547
|
+
|
548
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
549
|
+
if (!ctx)
|
550
|
+
rb_raise (rb_eArgError, "released ctx");
|
551
|
+
|
552
|
+
const char* result;
|
553
|
+
result = gpgme_get_ctx_flag(ctx, name);
|
554
|
+
if (result == NULL)
|
555
|
+
rb_raise (rb_eArgError, "incorrect ctx flag name");
|
556
|
+
|
557
|
+
return rb_str_new_cstr(result);
|
558
|
+
}
|
559
|
+
|
517
560
|
static VALUE
|
518
561
|
rb_s_gpgme_set_protocol (VALUE dummy, VALUE vctx, VALUE vproto)
|
519
562
|
{
|
@@ -566,6 +609,42 @@ rb_s_gpgme_get_armor (VALUE dummy, VALUE vctx)
|
|
566
609
|
return INT2FIX(yes);
|
567
610
|
}
|
568
611
|
|
612
|
+
static VALUE
|
613
|
+
rb_s_gpgme_set_ignore_mdc_error (VALUE dummy, VALUE vctx, VALUE vyes)
|
614
|
+
{
|
615
|
+
gpgme_ctx_t ctx;
|
616
|
+
gpgme_error_t err;
|
617
|
+
int yes;
|
618
|
+
|
619
|
+
yes = NUM2INT(vyes);
|
620
|
+
|
621
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
622
|
+
if (!ctx)
|
623
|
+
rb_raise (rb_eArgError, "released ctx");
|
624
|
+
|
625
|
+
err = gpgme_set_ctx_flag(ctx, "ignore-mdc-error", yes ? "1" : "");
|
626
|
+
return LONG2NUM(err);
|
627
|
+
}
|
628
|
+
|
629
|
+
static VALUE
|
630
|
+
rb_s_gpgme_get_ignore_mdc_error (VALUE dummy, VALUE vctx)
|
631
|
+
{
|
632
|
+
gpgme_ctx_t ctx;
|
633
|
+
int yes;
|
634
|
+
|
635
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
636
|
+
if (!ctx)
|
637
|
+
rb_raise (rb_eArgError, "released ctx");
|
638
|
+
|
639
|
+
const char* result;
|
640
|
+
result = gpgme_get_ctx_flag(ctx, "ignore-mdc-error");
|
641
|
+
if (result == NULL)
|
642
|
+
rb_raise (rb_eArgError, "incorrect ctx flag name");
|
643
|
+
|
644
|
+
yes = (result && *result)? !!atoi (result) : 0;
|
645
|
+
return INT2FIX(yes);
|
646
|
+
}
|
647
|
+
|
569
648
|
static VALUE
|
570
649
|
rb_s_gpgme_set_textmode (VALUE dummy, VALUE vctx, VALUE vyes)
|
571
650
|
{
|
@@ -969,11 +1048,19 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
|
|
969
1048
|
rb_iv_set (vsubkey, "@keyid", rb_str_new2 (subkey->keyid));
|
970
1049
|
if (subkey->fpr)
|
971
1050
|
rb_iv_set (vsubkey, "@fpr", rb_str_new2 (subkey->fpr));
|
1051
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
1052
|
+
rb_iv_set (vsubkey, "@timestamp", ULONG2NUM(subkey->timestamp));
|
1053
|
+
rb_iv_set (vsubkey, "@expires", ULONG2NUM(subkey->expires));
|
1054
|
+
#else
|
972
1055
|
rb_iv_set (vsubkey, "@timestamp", LONG2NUM(subkey->timestamp));
|
973
1056
|
rb_iv_set (vsubkey, "@expires", LONG2NUM(subkey->expires));
|
1057
|
+
#endif
|
974
1058
|
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010500
|
975
1059
|
if (subkey->curve)
|
976
1060
|
rb_iv_set (vsubkey, "@curve", rb_str_new2 (subkey->curve));
|
1061
|
+
#endif
|
1062
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
1063
|
+
rb_iv_set (vsubkey, "@subkey_match", INT2FIX(subkey->subkey_match));
|
977
1064
|
#endif
|
978
1065
|
rb_ary_push (vsubkeys, vsubkey);
|
979
1066
|
}
|
@@ -1004,8 +1091,13 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
|
|
1004
1091
|
rb_iv_set (vkey_sig, "@exportable", INT2FIX(key_sig->exportable));
|
1005
1092
|
rb_iv_set (vkey_sig, "@pubkey_algo", INT2FIX(key_sig->pubkey_algo));
|
1006
1093
|
rb_iv_set (vkey_sig, "@keyid", rb_str_new2 (key_sig->keyid));
|
1094
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
1095
|
+
rb_iv_set (vkey_sig, "@timestamp", ULONG2NUM(key_sig->timestamp));
|
1096
|
+
rb_iv_set (vkey_sig, "@expires", ULONG2NUM(key_sig->expires));
|
1097
|
+
#else
|
1007
1098
|
rb_iv_set (vkey_sig, "@timestamp", LONG2NUM(key_sig->timestamp));
|
1008
1099
|
rb_iv_set (vkey_sig, "@expires", LONG2NUM(key_sig->expires));
|
1100
|
+
#endif
|
1009
1101
|
rb_ary_push (vsignatures, vkey_sig);
|
1010
1102
|
}
|
1011
1103
|
rb_ary_push (vuids, vuser_id);
|
@@ -1408,6 +1500,27 @@ rb_s_gpgme_op_delete (VALUE dummy, VALUE vctx, VALUE vkey, VALUE vallow_secret)
|
|
1408
1500
|
return LONG2NUM(err);
|
1409
1501
|
}
|
1410
1502
|
|
1503
|
+
/* This method was added in 1.9.1. */
|
1504
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010901
|
1505
|
+
static VALUE
|
1506
|
+
rb_s_gpgme_op_delete_ext (VALUE dummy, VALUE vctx, VALUE vkey, VALUE vflags)
|
1507
|
+
{
|
1508
|
+
gpgme_ctx_t ctx;
|
1509
|
+
gpgme_key_t key;
|
1510
|
+
gpgme_error_t err;
|
1511
|
+
|
1512
|
+
CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
|
1513
|
+
|
1514
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
1515
|
+
if (!ctx)
|
1516
|
+
rb_raise (rb_eArgError, "released ctx");
|
1517
|
+
UNWRAP_GPGME_KEY(vkey, key);
|
1518
|
+
|
1519
|
+
err = gpgme_op_delete_ext (ctx, key, NUM2INT(vflags));
|
1520
|
+
return LONG2NUM(err);
|
1521
|
+
}
|
1522
|
+
#endif
|
1523
|
+
|
1411
1524
|
static VALUE
|
1412
1525
|
rb_s_gpgme_op_delete_start (VALUE dummy, VALUE vctx, VALUE vkey,
|
1413
1526
|
VALUE vallow_secret)
|
@@ -1557,6 +1670,7 @@ rb_s_gpgme_op_card_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
|
|
1557
1670
|
return LONG2NUM(err);
|
1558
1671
|
}
|
1559
1672
|
|
1673
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
1560
1674
|
static VALUE
|
1561
1675
|
rb_s_gpgme_op_trustlist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
|
1562
1676
|
VALUE vmax_level)
|
@@ -1620,6 +1734,7 @@ rb_s_gpgme_op_trustlist_end (VALUE dummy, VALUE vctx)
|
|
1620
1734
|
err = gpgme_op_trustlist_end (ctx);
|
1621
1735
|
return LONG2NUM(err);
|
1622
1736
|
}
|
1737
|
+
#endif
|
1623
1738
|
|
1624
1739
|
static VALUE
|
1625
1740
|
rb_s_gpgme_op_decrypt (VALUE dummy, VALUE vctx, VALUE vcipher, VALUE vplain)
|
@@ -1970,8 +2085,13 @@ rb_s_gpgme_op_sign_result (VALUE dummy, VALUE vctx)
|
|
1970
2085
|
INT2FIX(new_signature->hash_algo));
|
1971
2086
|
rb_iv_set (vnew_signature, "@sig_class",
|
1972
2087
|
UINT2NUM(new_signature->sig_class));
|
2088
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
2089
|
+
rb_iv_set (vnew_signature, "@timestamp",
|
2090
|
+
ULONG2NUM(new_signature->timestamp));
|
2091
|
+
#else
|
1973
2092
|
rb_iv_set (vnew_signature, "@timestamp",
|
1974
2093
|
LONG2NUM(new_signature->timestamp));
|
2094
|
+
#endif
|
1975
2095
|
rb_iv_set (vnew_signature, "@fpr", rb_str_new2 (new_signature->fpr));
|
1976
2096
|
rb_ary_push (vsignatures, vnew_signature);
|
1977
2097
|
}
|
@@ -2260,6 +2380,57 @@ rb_s_gpgme_op_spawn (VALUE dummy, VALUE vctx, VALUE vfile,
|
|
2260
2380
|
}
|
2261
2381
|
#endif
|
2262
2382
|
|
2383
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
2384
|
+
static VALUE
|
2385
|
+
rb_s_gpgme_op_random_bytes (VALUE dummy, VALUE vctx, VALUE vsize, VALUE vmode)
|
2386
|
+
{
|
2387
|
+
gpgme_ctx_t ctx;
|
2388
|
+
gpgme_error_t err;
|
2389
|
+
size_t size;
|
2390
|
+
char *buffer;
|
2391
|
+
VALUE result;
|
2392
|
+
|
2393
|
+
CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
|
2394
|
+
|
2395
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
2396
|
+
if (!ctx)
|
2397
|
+
rb_raise (rb_eArgError, "released ctx");
|
2398
|
+
|
2399
|
+
size = NUM2SIZET(vsize);
|
2400
|
+
buffer = ALLOC_N(char, size);
|
2401
|
+
|
2402
|
+
err = gpgme_op_random_bytes (ctx, NUM2INT(vmode), buffer, size);
|
2403
|
+
if (err) {
|
2404
|
+
xfree(buffer);
|
2405
|
+
return LONG2NUM(err);
|
2406
|
+
}
|
2407
|
+
|
2408
|
+
result = rb_str_new(buffer, size);
|
2409
|
+
xfree(buffer);
|
2410
|
+
return result;
|
2411
|
+
}
|
2412
|
+
|
2413
|
+
static VALUE
|
2414
|
+
rb_s_gpgme_op_random_value (VALUE dummy, VALUE vctx, VALUE vlimit)
|
2415
|
+
{
|
2416
|
+
gpgme_ctx_t ctx;
|
2417
|
+
size_t limit, result;
|
2418
|
+
gpgme_error_t err;
|
2419
|
+
|
2420
|
+
CHECK_KEYLIST_NOT_IN_PROGRESS(vctx);
|
2421
|
+
|
2422
|
+
UNWRAP_GPGME_CTX(vctx, ctx);
|
2423
|
+
if (!ctx)
|
2424
|
+
rb_raise (rb_eArgError, "released ctx");
|
2425
|
+
|
2426
|
+
limit = NUM2SIZET(vlimit);
|
2427
|
+
err = gpgme_op_random_value (ctx, limit, &result);
|
2428
|
+
if (gpgme_err_code(err) == GPG_ERR_NO_ERROR)
|
2429
|
+
return SIZET2NUM(result);
|
2430
|
+
return LONG2NUM(err);
|
2431
|
+
}
|
2432
|
+
#endif
|
2433
|
+
|
2263
2434
|
void
|
2264
2435
|
Init_gpgme_n (void)
|
2265
2436
|
{
|
@@ -2326,8 +2497,10 @@ Init_gpgme_n (void)
|
|
2326
2497
|
rb_define_class_under (mGPGME, "Signature", rb_cObject);
|
2327
2498
|
cSigNotation =
|
2328
2499
|
rb_define_class_under (mGPGME, "SigNotation", rb_cObject);
|
2500
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2329
2501
|
cTrustItem =
|
2330
2502
|
rb_define_class_under (mGPGME, "TrustItem", rb_cObject);
|
2503
|
+
#endif
|
2331
2504
|
cInvalidKey =
|
2332
2505
|
rb_define_class_under (mGPGME, "InvalidKey", rb_cObject);
|
2333
2506
|
cNewSignature =
|
@@ -2373,6 +2546,10 @@ Init_gpgme_n (void)
|
|
2373
2546
|
rb_s_gpgme_release, 1);
|
2374
2547
|
|
2375
2548
|
/* Context Attributes */
|
2549
|
+
rb_define_module_function (mGPGME, "gpgme_set_ctx_flag",
|
2550
|
+
rb_s_gpgme_set_ctx_flag, 3);
|
2551
|
+
rb_define_module_function (mGPGME, "gpgme_get_ctx_flag",
|
2552
|
+
rb_s_gpgme_get_ctx_flag, 2);
|
2376
2553
|
rb_define_module_function (mGPGME, "gpgme_set_protocol",
|
2377
2554
|
rb_s_gpgme_set_protocol, 2);
|
2378
2555
|
rb_define_module_function (mGPGME, "gpgme_get_protocol",
|
@@ -2381,6 +2558,10 @@ Init_gpgme_n (void)
|
|
2381
2558
|
rb_s_gpgme_set_armor, 2);
|
2382
2559
|
rb_define_module_function (mGPGME, "gpgme_get_armor",
|
2383
2560
|
rb_s_gpgme_get_armor, 1);
|
2561
|
+
rb_define_module_function (mGPGME, "gpgme_set_ignore_mdc_error",
|
2562
|
+
rb_s_gpgme_set_ignore_mdc_error, 2);
|
2563
|
+
rb_define_module_function (mGPGME, "gpgme_get_ignore_mdc_error",
|
2564
|
+
rb_s_gpgme_get_ignore_mdc_error, 1);
|
2384
2565
|
rb_define_module_function (mGPGME, "gpgme_set_textmode",
|
2385
2566
|
rb_s_gpgme_set_textmode, 2);
|
2386
2567
|
rb_define_module_function (mGPGME, "gpgme_get_textmode",
|
@@ -2463,6 +2644,8 @@ Init_gpgme_n (void)
|
|
2463
2644
|
rb_s_gpgme_op_import_result, 1);
|
2464
2645
|
rb_define_module_function (mGPGME, "gpgme_op_delete",
|
2465
2646
|
rb_s_gpgme_op_delete, 3);
|
2647
|
+
rb_define_module_function (mGPGME, "gpgme_op_delete_ext",
|
2648
|
+
rb_s_gpgme_op_delete_ext, 3);
|
2466
2649
|
rb_define_module_function (mGPGME, "gpgme_op_delete_start",
|
2467
2650
|
rb_s_gpgme_op_delete_start, 3);
|
2468
2651
|
rb_define_module_function (mGPGME, "gpgme_op_edit",
|
@@ -2475,12 +2658,14 @@ Init_gpgme_n (void)
|
|
2475
2658
|
rb_s_gpgme_op_card_edit_start, 5);
|
2476
2659
|
|
2477
2660
|
/* Trust Item Management */
|
2661
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2478
2662
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_start",
|
2479
2663
|
rb_s_gpgme_op_trustlist_start, 3);
|
2480
2664
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_next",
|
2481
2665
|
rb_s_gpgme_op_trustlist_next, 2);
|
2482
2666
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_end",
|
2483
2667
|
rb_s_gpgme_op_trustlist_end, 1);
|
2668
|
+
#endif
|
2484
2669
|
|
2485
2670
|
/* Decrypt */
|
2486
2671
|
rb_define_module_function (mGPGME, "gpgme_op_decrypt",
|
@@ -2542,6 +2727,14 @@ Init_gpgme_n (void)
|
|
2542
2727
|
rb_s_gpgme_op_spawn_start, 7);
|
2543
2728
|
#endif
|
2544
2729
|
|
2730
|
+
/* Random Number Generation */
|
2731
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
2732
|
+
rb_define_module_function (mGPGME, "gpgme_op_random_bytes",
|
2733
|
+
rb_s_gpgme_op_random_bytes, 3);
|
2734
|
+
rb_define_module_function (mGPGME, "gpgme_op_random_value",
|
2735
|
+
rb_s_gpgme_op_random_value, 2);
|
2736
|
+
#endif
|
2737
|
+
|
2545
2738
|
/* gpgme_pubkey_algo_t */
|
2546
2739
|
rb_define_const (mGPGME, "GPGME_PK_RSA", INT2FIX(GPGME_PK_RSA));
|
2547
2740
|
rb_define_const (mGPGME, "GPGME_PK_DSA", INT2FIX(GPGME_PK_DSA));
|
@@ -2722,6 +2915,7 @@ Init_gpgme_n (void)
|
|
2722
2915
|
INT2FIX(GPGME_SIG_MODE_CLEAR));
|
2723
2916
|
|
2724
2917
|
/* gpgme_attr_t */
|
2918
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2725
2919
|
rb_define_const (mGPGME, "GPGME_ATTR_KEYID",
|
2726
2920
|
INT2FIX(GPGME_ATTR_KEYID));
|
2727
2921
|
rb_define_const (mGPGME, "GPGME_ATTR_FPR",
|
@@ -2784,6 +2978,7 @@ Init_gpgme_n (void)
|
|
2784
2978
|
INT2FIX(GPGME_ATTR_ERRTOK));
|
2785
2979
|
rb_define_const (mGPGME, "GPGME_ATTR_SIG_SUMMARY",
|
2786
2980
|
INT2FIX(GPGME_ATTR_SIG_SUMMARY));
|
2981
|
+
#endif
|
2787
2982
|
|
2788
2983
|
/* gpgme_validity_t */
|
2789
2984
|
rb_define_const (mGPGME, "GPGME_VALIDITY_UNKNOWN",
|
@@ -3029,6 +3224,26 @@ Init_gpgme_n (void)
|
|
3029
3224
|
INT2FIX(GPGME_ENCRYPT_NO_ENCRYPT_TO));
|
3030
3225
|
#endif
|
3031
3226
|
|
3227
|
+
/* Random number generation mode flags added in 2.0.0 */
|
3228
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
3229
|
+
rb_define_const (mGPGME, "GPGME_RANDOM_MODE_NORMAL",
|
3230
|
+
INT2FIX(GPGME_RANDOM_MODE_NORMAL));
|
3231
|
+
rb_define_const (mGPGME, "GPGME_RANDOM_MODE_ZBASE32",
|
3232
|
+
INT2FIX(GPGME_RANDOM_MODE_ZBASE32));
|
3233
|
+
#endif
|
3234
|
+
|
3235
|
+
/* Decrypt flags added in 2.0.0 */
|
3236
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
3237
|
+
rb_define_const (mGPGME, "GPGME_DECRYPT_LISTONLY",
|
3238
|
+
INT2FIX(GPGME_DECRYPT_LISTONLY));
|
3239
|
+
#endif
|
3240
|
+
|
3241
|
+
/* Key generation flags added in 2.0.0 */
|
3242
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x020000
|
3243
|
+
rb_define_const (mGPGME, "GPGME_CREATE_GROUP",
|
3244
|
+
INT2FIX(GPGME_CREATE_GROUP));
|
3245
|
+
#endif
|
3246
|
+
|
3032
3247
|
/* These flags were added in 1.4.0. */
|
3033
3248
|
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010400
|
3034
3249
|
rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_DEFAULT",
|
@@ -3072,4 +3287,13 @@ Init_gpgme_n (void)
|
|
3072
3287
|
rb_define_const (mGPGME, "GPGME_EXPORT_MODE_PKCS12",
|
3073
3288
|
INT2FIX(GPGME_EXPORT_MODE_PKCS12));
|
3074
3289
|
#endif
|
3290
|
+
|
3291
|
+
/* These flags were added in 1.9.1. */
|
3292
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010901
|
3293
|
+
rb_define_const (mGPGME, "GPGME_DELETE_ALLOW_SECRET",
|
3294
|
+
INT2FIX(GPGME_DELETE_ALLOW_SECRET));
|
3295
|
+
rb_define_const (mGPGME, "GPGME_DELETE_FORCE",
|
3296
|
+
INT2FIX(GPGME_DELETE_FORCE));
|
3297
|
+
#endif
|
3075
3298
|
}
|
3299
|
+
|
data/lib/gpgme/constants.rb
CHANGED
@@ -1,36 +1,98 @@
|
|
1
1
|
module GPGME
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
3
|
+
if defined?(GPGME_ATTR_ALGO)
|
4
|
+
ATTR_ALGO = GPGME_ATTR_ALGO
|
5
|
+
end
|
6
|
+
if defined?(GPGME_ATTR_CAN_CERTIFY)
|
7
|
+
ATTR_CAN_CERTIFY = GPGME_ATTR_CAN_CERTIFY
|
8
|
+
end
|
9
|
+
if defined?(GPGME_ATTR_CAN_ENCRYPT)
|
10
|
+
ATTR_CAN_ENCRYPT = GPGME_ATTR_CAN_ENCRYPT
|
11
|
+
end
|
12
|
+
if defined?(GPGME_ATTR_CAN_SIGN)
|
13
|
+
ATTR_CAN_SIGN = GPGME_ATTR_CAN_SIGN
|
14
|
+
end
|
15
|
+
if defined?(GPGME_ATTR_CHAINID)
|
16
|
+
ATTR_CHAINID = GPGME_ATTR_CHAINID
|
17
|
+
end
|
18
|
+
if defined?(GPGME_ATTR_COMMENT)
|
19
|
+
ATTR_COMMENT = GPGME_ATTR_COMMENT
|
20
|
+
end
|
21
|
+
if defined?(GPGME_ATTR_CREATED)
|
22
|
+
ATTR_CREATED = GPGME_ATTR_CREATED
|
23
|
+
end
|
24
|
+
if defined?(GPGME_ATTR_EMAIL)
|
25
|
+
ATTR_EMAIL = GPGME_ATTR_EMAIL
|
26
|
+
end
|
27
|
+
if defined?(GPGME_ATTR_ERRTOK)
|
28
|
+
ATTR_ERRTOK = GPGME_ATTR_ERRTOK
|
29
|
+
end
|
30
|
+
if defined?(GPGME_ATTR_EXPIRE)
|
31
|
+
ATTR_EXPIRE = GPGME_ATTR_EXPIRE
|
32
|
+
end
|
33
|
+
if defined?(GPGME_ATTR_FPR)
|
34
|
+
ATTR_FPR = GPGME_ATTR_FPR
|
35
|
+
end
|
36
|
+
if defined?(GPGME_ATTR_ISSUER)
|
37
|
+
ATTR_ISSUER = GPGME_ATTR_ISSUER
|
38
|
+
end
|
39
|
+
if defined?(GPGME_ATTR_IS_SECRET)
|
40
|
+
ATTR_IS_SECRET = GPGME_ATTR_IS_SECRET
|
41
|
+
end
|
42
|
+
if defined?(GPGME_ATTR_KEYID)
|
43
|
+
ATTR_KEYID = GPGME_ATTR_KEYID
|
44
|
+
end
|
45
|
+
if defined?(GPGME_ATTR_KEY_CAPS)
|
46
|
+
ATTR_KEY_CAPS = GPGME_ATTR_KEY_CAPS
|
47
|
+
end
|
48
|
+
if defined?(GPGME_ATTR_KEY_DISABLED)
|
49
|
+
ATTR_KEY_DISABLED = GPGME_ATTR_KEY_DISABLED
|
50
|
+
end
|
51
|
+
if defined?(GPGME_ATTR_KEY_EXPIRED)
|
52
|
+
ATTR_KEY_EXPIRED = GPGME_ATTR_KEY_EXPIRED
|
53
|
+
end
|
54
|
+
if defined?(GPGME_ATTR_KEY_INVALID)
|
55
|
+
ATTR_KEY_INVALID = GPGME_ATTR_KEY_INVALID
|
56
|
+
end
|
57
|
+
if defined?(GPGME_ATTR_KEY_REVOKED)
|
58
|
+
ATTR_KEY_REVOKED = GPGME_ATTR_KEY_REVOKED
|
59
|
+
end
|
60
|
+
if defined?(GPGME_ATTR_LEN)
|
61
|
+
ATTR_LEN = GPGME_ATTR_LEN
|
62
|
+
end
|
63
|
+
if defined?(GPGME_ATTR_LEVEL)
|
64
|
+
ATTR_LEVEL = GPGME_ATTR_LEVEL
|
65
|
+
end
|
66
|
+
if defined?(GPGME_ATTR_NAME)
|
67
|
+
ATTR_NAME = GPGME_ATTR_NAME
|
68
|
+
end
|
69
|
+
if defined?(GPGME_ATTR_OTRUST)
|
70
|
+
ATTR_OTRUST = GPGME_ATTR_OTRUST
|
71
|
+
end
|
72
|
+
if defined?(GPGME_ATTR_SERIAL)
|
73
|
+
ATTR_SERIAL = GPGME_ATTR_SERIAL
|
74
|
+
end
|
75
|
+
if defined?(GPGME_ATTR_SIG_STATUS)
|
76
|
+
ATTR_SIG_STATUS = GPGME_ATTR_SIG_STATUS
|
77
|
+
end
|
78
|
+
if defined?(GPGME_ATTR_SIG_SUMMARY)
|
79
|
+
ATTR_SIG_SUMMARY = GPGME_ATTR_SIG_SUMMARY
|
80
|
+
end
|
81
|
+
if defined?(GPGME_ATTR_TYPE)
|
82
|
+
ATTR_TYPE = GPGME_ATTR_TYPE
|
83
|
+
end
|
84
|
+
if defined?(GPGME_ATTR_UID_INVALID)
|
85
|
+
ATTR_UID_INVALID = GPGME_ATTR_UID_INVALID
|
86
|
+
end
|
87
|
+
if defined?(GPGME_ATTR_UID_REVOKED)
|
88
|
+
ATTR_UID_REVOKED = GPGME_ATTR_UID_REVOKED
|
89
|
+
end
|
90
|
+
if defined?(GPGME_ATTR_USERID)
|
91
|
+
ATTR_USERID = GPGME_ATTR_USERID
|
92
|
+
end
|
93
|
+
if defined?(GPGME_ATTR_VALIDITY)
|
94
|
+
ATTR_VALIDITY = GPGME_ATTR_VALIDITY
|
95
|
+
end
|
34
96
|
DATA_ENCODING_ARMOR = GPGME_DATA_ENCODING_ARMOR
|
35
97
|
DATA_ENCODING_BASE64 = GPGME_DATA_ENCODING_BASE64
|
36
98
|
DATA_ENCODING_BINARY = GPGME_DATA_ENCODING_BINARY
|
@@ -265,4 +327,31 @@ module GPGME
|
|
265
327
|
VALIDITY_FULL => :full,
|
266
328
|
VALIDITY_ULTIMATE => :ultimate
|
267
329
|
}
|
330
|
+
|
331
|
+
if defined?(GPGME_DELETE_ALLOW_SECRET)
|
332
|
+
DELETE_ALLOW_SECRET = GPGME_DELETE_ALLOW_SECRET
|
333
|
+
end
|
334
|
+
|
335
|
+
if defined?(GPGME_DELETE_FORCE)
|
336
|
+
DELETE_FORCE = GPGME_DELETE_FORCE
|
337
|
+
end
|
338
|
+
|
339
|
+
# Random number generation mode flags added in 2.0.0
|
340
|
+
if defined?(GPGME_RANDOM_MODE_NORMAL)
|
341
|
+
RANDOM_MODE_NORMAL = GPGME_RANDOM_MODE_NORMAL
|
342
|
+
end
|
343
|
+
|
344
|
+
if defined?(GPGME_RANDOM_MODE_ZBASE32)
|
345
|
+
RANDOM_MODE_ZBASE32 = GPGME_RANDOM_MODE_ZBASE32
|
346
|
+
end
|
347
|
+
|
348
|
+
# Decrypt flags added in 2.0.0
|
349
|
+
if defined?(GPGME_DECRYPT_LISTONLY)
|
350
|
+
DECRYPT_LISTONLY = GPGME_DECRYPT_LISTONLY
|
351
|
+
end
|
352
|
+
|
353
|
+
# Key generation flags added in 2.0.0
|
354
|
+
if defined?(GPGME_CREATE_GROUP)
|
355
|
+
CREATE_GROUP = GPGME_CREATE_GROUP
|
356
|
+
end
|
268
357
|
end
|
data/lib/gpgme/ctx.rb
CHANGED
@@ -49,12 +49,13 @@ module GPGME
|
|
49
49
|
raise exc if exc
|
50
50
|
ctx = rctx[0]
|
51
51
|
|
52
|
-
ctx.protocol
|
53
|
-
ctx.armor
|
54
|
-
ctx.textmode
|
55
|
-
ctx.keylist_mode
|
56
|
-
ctx.pinentry_mode
|
57
|
-
ctx.offline
|
52
|
+
ctx.protocol = options[:protocol] if options[:protocol]
|
53
|
+
ctx.armor = options[:armor] if options[:armor]
|
54
|
+
ctx.textmode = options[:textmode] if options[:textmode]
|
55
|
+
ctx.keylist_mode = options[:keylist_mode] if options[:keylist_mode]
|
56
|
+
ctx.pinentry_mode = options[:pinentry_mode] if options[:pinentry_mode]
|
57
|
+
ctx.offline = options[:offline] if options[:offline]
|
58
|
+
ctx.ignore_mdc_error = options[:ignore_mdc_error] if options[:ignore_mdc_error]
|
58
59
|
|
59
60
|
if options[:password]
|
60
61
|
ctx.set_passphrase_callback GPGME::Ctx.method(:pass_function),
|
@@ -103,6 +104,43 @@ module GPGME
|
|
103
104
|
# Getters and setters
|
104
105
|
##
|
105
106
|
|
107
|
+
# Get the value of the Ctx flag with the given name.
|
108
|
+
#
|
109
|
+
# Allowed flag names may include:
|
110
|
+
# - 'redraw'
|
111
|
+
# - 'full-status'
|
112
|
+
# - 'raw-description'
|
113
|
+
# - 'export-session-key'
|
114
|
+
# - 'override-session-key'
|
115
|
+
# - 'include-key-block'
|
116
|
+
# - 'auto-key-import'
|
117
|
+
# - 'auto-key-retrieve'
|
118
|
+
# - 'request-origin'
|
119
|
+
# - 'no-symkey-cache'
|
120
|
+
# - 'ignore-mdc-error'
|
121
|
+
# - 'auto-key-locate'
|
122
|
+
# - 'trust-model'
|
123
|
+
# - 'extended-edit'
|
124
|
+
# - 'cert-expire'
|
125
|
+
# - 'key-origin'
|
126
|
+
# - 'import-filter'
|
127
|
+
# - 'no-auto-check-trustdb'
|
128
|
+
#
|
129
|
+
# Please consult the GPGPME documentation for more details
|
130
|
+
#
|
131
|
+
def get_ctx_flag(flag_name)
|
132
|
+
GPGME::gpgme_get_ctx_flag(self, flag_name.to_s)
|
133
|
+
end
|
134
|
+
|
135
|
+
# Set the Ctx flag with the given name
|
136
|
+
# to the given value.
|
137
|
+
def set_ctx_flag(flag_name, val)
|
138
|
+
err = GPGME::gpgme_set_ctx_flag(self, flag_name.to_s, val.to_s)
|
139
|
+
exc = GPGME::error_to_exception(err)
|
140
|
+
raise exc if exc
|
141
|
+
val
|
142
|
+
end
|
143
|
+
|
106
144
|
# Set the +protocol+ used within this context. See {GPGME::Ctx.new} for
|
107
145
|
# possible values.
|
108
146
|
def protocol=(proto)
|
@@ -128,6 +166,22 @@ module GPGME
|
|
128
166
|
GPGME::gpgme_get_armor(self) == 1 ? true : false
|
129
167
|
end
|
130
168
|
|
169
|
+
# This option ignores a MDC integrity protection failure.
|
170
|
+
# It is required to decrypt old messages which did not use an MDC.
|
171
|
+
# It may also be useful if a message is partially garbled,
|
172
|
+
# but it is necessary to get as much data as possible out of that garbled message.
|
173
|
+
# Be aware that a missing or failed MDC can be an indication of an attack.
|
174
|
+
# Use with great caution.
|
175
|
+
def ignore_mdc_error=(yes)
|
176
|
+
GPGME::gpgme_set_ignore_mdc_error(self, yes ? 1 : 0)
|
177
|
+
yes
|
178
|
+
end
|
179
|
+
|
180
|
+
# Return true if the MDC integrity protection is disabled.
|
181
|
+
def ignore_mdc_error
|
182
|
+
GPGME::gpgme_get_ignore_mdc_error(self) == 1 ? true : false
|
183
|
+
end
|
184
|
+
|
131
185
|
# Tell whether canonical text mode should be used.
|
132
186
|
def textmode=(yes)
|
133
187
|
GPGME::gpgme_set_textmode(self, yes ? 1 : 0)
|
@@ -393,8 +447,17 @@ module GPGME
|
|
393
447
|
# Delete the key from the key ring.
|
394
448
|
# If allow_secret is false, only public keys are deleted,
|
395
449
|
# otherwise secret keys are deleted as well.
|
396
|
-
|
397
|
-
|
450
|
+
# If force is true, the confirmation dialog will not be displayed.
|
451
|
+
def delete_key(key, allow_secret = false, force = false)
|
452
|
+
err = nil
|
453
|
+
if defined?(GPGME::gpgme_op_delete_ext)
|
454
|
+
flag = 0
|
455
|
+
flag ^= GPGME::DELETE_ALLOW_SECRET if allow_secret
|
456
|
+
flag ^= GPGME::DELETE_FORCE if force
|
457
|
+
err = GPGME::gpgme_op_delete_ext(self, key, flag)
|
458
|
+
else
|
459
|
+
err = GPGME::gpgme_op_delete(self, key, allow_secret ? 1 : 0)
|
460
|
+
end
|
398
461
|
exc = GPGME::error_to_exception(err)
|
399
462
|
raise exc if exc
|
400
463
|
end
|
@@ -507,6 +570,39 @@ module GPGME
|
|
507
570
|
raise exc if exc
|
508
571
|
end
|
509
572
|
|
573
|
+
# Generate cryptographically strong random bytes.
|
574
|
+
# Available since GPGME 2.0.0.
|
575
|
+
#
|
576
|
+
# @param [Integer] size Number of bytes to generate
|
577
|
+
# @param [Integer] mode Random generation mode (RANDOM_MODE_NORMAL or RANDOM_MODE_ZBASE32)
|
578
|
+
# @return [String] Random bytes as a binary string
|
579
|
+
def random_bytes(size, mode = GPGME::RANDOM_MODE_NORMAL)
|
580
|
+
result = GPGME::gpgme_op_random_bytes(self, size, mode)
|
581
|
+
if result.is_a?(String)
|
582
|
+
result
|
583
|
+
else
|
584
|
+
exc = GPGME::error_to_exception(result)
|
585
|
+
raise exc if exc
|
586
|
+
result
|
587
|
+
end
|
588
|
+
end
|
589
|
+
|
590
|
+
# Generate a cryptographically strong random unsigned integer value.
|
591
|
+
# Available since GPGME 2.0.0.
|
592
|
+
#
|
593
|
+
# @param [Integer] limit Upper limit for the random value (exclusive)
|
594
|
+
# @return [Integer] Random unsigned integer value in range [0, limit)
|
595
|
+
def random_value(limit)
|
596
|
+
result = GPGME::gpgme_op_random_value(self, limit)
|
597
|
+
if result.is_a?(Integer) && result >= 0
|
598
|
+
result
|
599
|
+
else
|
600
|
+
exc = GPGME::error_to_exception(result)
|
601
|
+
raise exc if exc
|
602
|
+
result
|
603
|
+
end
|
604
|
+
end
|
605
|
+
|
510
606
|
def inspect
|
511
607
|
"#<#{self.class} protocol=#{PROTOCOL_NAMES[protocol] || protocol}, \
|
512
608
|
armor=#{armor}, textmode=#{textmode}, \
|
data/lib/gpgme/key.rb
CHANGED
@@ -156,10 +156,11 @@ module GPGME
|
|
156
156
|
|
157
157
|
##
|
158
158
|
# Delete this key. If it's public, and has a secret one it will fail unless
|
159
|
-
# +allow_secret+ is specified as true.
|
160
|
-
|
159
|
+
# +allow_secret+ is specified as true. Suppress the confirmation dialog, if
|
160
|
+
# +force+ is specified as true.
|
161
|
+
def delete!(allow_secret = false, force = false)
|
161
162
|
GPGME::Ctx.new do |ctx|
|
162
|
-
ctx.delete_key self, allow_secret
|
163
|
+
ctx.delete_key self, allow_secret, force
|
163
164
|
end
|
164
165
|
end
|
165
166
|
|
data/lib/gpgme/version.rb
CHANGED
data/lib/gpgme.rb
CHANGED
Binary file
|
Binary file
|
Binary file
|
data/test/crypto_test.rb
CHANGED
@@ -90,7 +90,7 @@ describe GPGME::Crypto do
|
|
90
90
|
encrypted = crypto.encrypt TEXT[:plain], :sign => true
|
91
91
|
signatures = 0
|
92
92
|
|
93
|
-
crypto.
|
93
|
+
crypto.decrypt(encrypted) do |signature|
|
94
94
|
assert_instance_of GPGME::Signature, signature
|
95
95
|
signatures += 1
|
96
96
|
end
|
@@ -103,7 +103,7 @@ describe GPGME::Crypto do
|
|
103
103
|
encrypted = crypto.encrypt TEXT[:plain], :sign => true, :signers => KEYS.map{|k| k[:sha]}
|
104
104
|
signatures = 0
|
105
105
|
|
106
|
-
crypto.
|
106
|
+
crypto.decrypt(encrypted) do |signature|
|
107
107
|
assert_instance_of GPGME::Signature, signature
|
108
108
|
signatures += 1
|
109
109
|
end
|
data/test/ctx_test.rb
CHANGED
@@ -81,6 +81,70 @@ describe GPGME::Ctx do
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
+
describe :get_ctx_flag do
|
85
|
+
it "reads flags with getters and setters" do
|
86
|
+
ctx = GPGME::Ctx.new
|
87
|
+
|
88
|
+
refute ctx.ignore_mdc_error
|
89
|
+
assert_equal "", ctx.get_ctx_flag("ignore-mdc-error")
|
90
|
+
|
91
|
+
ctx.ignore_mdc_error = true
|
92
|
+
|
93
|
+
assert ctx.ignore_mdc_error
|
94
|
+
assert_equal "1", ctx.get_ctx_flag("ignore-mdc-error")
|
95
|
+
end
|
96
|
+
|
97
|
+
it "can get flags without getters and setters" do
|
98
|
+
ctx = GPGME::Ctx.new
|
99
|
+
|
100
|
+
assert_equal "", ctx.get_ctx_flag("auto-key-locate")
|
101
|
+
ctx.set_ctx_flag("auto-key-locate", "cert")
|
102
|
+
assert_equal "cert", ctx.get_ctx_flag("auto-key-locate")
|
103
|
+
end
|
104
|
+
|
105
|
+
it "raises an error when a flag doesn't exist" do
|
106
|
+
ctx = GPGME::Ctx.new
|
107
|
+
|
108
|
+
assert_raises ArgumentError do
|
109
|
+
ctx.get_ctx_flag("foo")
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
describe :set_ctx_flag do
|
115
|
+
it "sets the value for a flag with a getter" do
|
116
|
+
ctx = GPGME::Ctx.new
|
117
|
+
refute ctx.ignore_mdc_error
|
118
|
+
|
119
|
+
ctx.set_ctx_flag("ignore-mdc-error", "1")
|
120
|
+
assert ctx.ignore_mdc_error
|
121
|
+
end
|
122
|
+
|
123
|
+
it "unsets the value for a flag with a getter" do
|
124
|
+
ctx = GPGME::Ctx.new(ignore_mdc_error: true)
|
125
|
+
assert ctx.ignore_mdc_error
|
126
|
+
|
127
|
+
ctx.set_ctx_flag("ignore-mdc-error", "0")
|
128
|
+
refute ctx.ignore_mdc_error
|
129
|
+
end
|
130
|
+
|
131
|
+
it "can set flags without getters and setters" do
|
132
|
+
ctx = GPGME::Ctx.new
|
133
|
+
|
134
|
+
assert_equal "", ctx.get_ctx_flag("auto-key-locate")
|
135
|
+
ctx.set_ctx_flag("auto-key-locate", "cert")
|
136
|
+
assert_equal "cert", ctx.get_ctx_flag("auto-key-locate")
|
137
|
+
end
|
138
|
+
|
139
|
+
it "raises an error when a flag doesn't exist" do
|
140
|
+
ctx = GPGME::Ctx.new
|
141
|
+
|
142
|
+
assert_raises GPGME::Error do
|
143
|
+
ctx.set_ctx_flag("foo", "bar")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
84
148
|
describe :armor do
|
85
149
|
it "sets false by default" do
|
86
150
|
ctx = GPGME::Ctx.new
|
@@ -101,6 +165,36 @@ describe GPGME::Ctx do
|
|
101
165
|
end
|
102
166
|
end
|
103
167
|
|
168
|
+
describe :ignore_mdc_error do
|
169
|
+
it "sets false by default" do
|
170
|
+
ctx = GPGME::Ctx.new
|
171
|
+
refute ctx.ignore_mdc_error
|
172
|
+
end
|
173
|
+
|
174
|
+
it "can set" do
|
175
|
+
ctx = GPGME::Ctx.new
|
176
|
+
|
177
|
+
ctx.ignore_mdc_error = true
|
178
|
+
assert ctx.ignore_mdc_error
|
179
|
+
end
|
180
|
+
|
181
|
+
it "can unset" do
|
182
|
+
ctx = GPGME::Ctx.new(ignore_mdc_error: true)
|
183
|
+
assert ctx.ignore_mdc_error
|
184
|
+
|
185
|
+
ctx.ignore_mdc_error = false
|
186
|
+
refute ctx.ignore_mdc_error
|
187
|
+
end
|
188
|
+
|
189
|
+
it "can set and get in constructor" do
|
190
|
+
ctx = GPGME::Ctx.new(:ignore_mdc_error => false)
|
191
|
+
refute ctx.ignore_mdc_error
|
192
|
+
|
193
|
+
ctx = GPGME::Ctx.new(:ignore_mdc_error => true)
|
194
|
+
assert ctx.ignore_mdc_error
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
104
198
|
describe :protocol do
|
105
199
|
it "sets 0 by default" do
|
106
200
|
ctx = GPGME::Ctx.new
|
data/test/data_test.rb
CHANGED
@@ -25,14 +25,14 @@ describe GPGME::Data do
|
|
25
25
|
it "creates a data from a file" do
|
26
26
|
# magic fromfile
|
27
27
|
data = GPGME::Data.new(File.open(__FILE__))
|
28
|
-
assert_match
|
28
|
+
assert_match(/magic fromfile/, data.read)
|
29
29
|
end
|
30
30
|
|
31
31
|
it "creates a data from file descriptor" do
|
32
32
|
# magic filedescriptor
|
33
33
|
File.open(__FILE__) do |f|
|
34
34
|
data = GPGME::Data.new(f.fileno)
|
35
|
-
assert_match
|
35
|
+
assert_match(/magic filedescriptor/, data.read)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gpgme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daiki Ueno
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2025-07-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mini_portile2
|
@@ -131,9 +131,9 @@ files:
|
|
131
131
|
- lib/gpgme/sub_key.rb
|
132
132
|
- lib/gpgme/user_id.rb
|
133
133
|
- lib/gpgme/version.rb
|
134
|
-
- ports/archives/gpgme-
|
135
|
-
- ports/archives/libassuan-
|
136
|
-
- ports/archives/libgpg-error-1.
|
134
|
+
- ports/archives/gpgme-2.0.0.tar.bz2
|
135
|
+
- ports/archives/libassuan-3.0.2.tar.bz2
|
136
|
+
- ports/archives/libgpg-error-1.55.tar.bz2
|
137
137
|
- test/crypto_test.rb
|
138
138
|
- test/ctx_test.rb
|
139
139
|
- test/data_test.rb
|
@@ -167,7 +167,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
167
|
- !ruby/object:Gem::Version
|
168
168
|
version: '0'
|
169
169
|
requirements: []
|
170
|
-
rubygems_version: 3.
|
170
|
+
rubygems_version: 3.5.22
|
171
171
|
signing_key:
|
172
172
|
specification_version: 4
|
173
173
|
summary: Ruby binding of GPGME.
|
Binary file
|
Binary file
|
Binary file
|