gpgme 2.0.24 → 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 +16 -6
- data/ext/gpgme/gpgme_n.c +145 -5
- data/lib/gpgme/constants.rb +120 -31
- data/lib/gpgme/ctx.rb +44 -2
- data/lib/gpgme/key.rb +4 -3
- data/lib/gpgme/version.rb +1 -1
- 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/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
@@ -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',
|
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);
|
@@ -538,7 +542,6 @@ rb_s_gpgme_get_ctx_flag (VALUE dummy, VALUE vctx, VALUE vname)
|
|
538
542
|
{
|
539
543
|
gpgme_ctx_t ctx;
|
540
544
|
const char* name;
|
541
|
-
int yes;
|
542
545
|
|
543
546
|
name = StringValueCStr(vname);
|
544
547
|
|
@@ -1045,11 +1048,19 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
|
|
1045
1048
|
rb_iv_set (vsubkey, "@keyid", rb_str_new2 (subkey->keyid));
|
1046
1049
|
if (subkey->fpr)
|
1047
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
|
1048
1055
|
rb_iv_set (vsubkey, "@timestamp", LONG2NUM(subkey->timestamp));
|
1049
1056
|
rb_iv_set (vsubkey, "@expires", LONG2NUM(subkey->expires));
|
1057
|
+
#endif
|
1050
1058
|
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010500
|
1051
1059
|
if (subkey->curve)
|
1052
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));
|
1053
1064
|
#endif
|
1054
1065
|
rb_ary_push (vsubkeys, vsubkey);
|
1055
1066
|
}
|
@@ -1080,8 +1091,13 @@ save_gpgme_key_attrs (VALUE vkey, gpgme_key_t key)
|
|
1080
1091
|
rb_iv_set (vkey_sig, "@exportable", INT2FIX(key_sig->exportable));
|
1081
1092
|
rb_iv_set (vkey_sig, "@pubkey_algo", INT2FIX(key_sig->pubkey_algo));
|
1082
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
|
1083
1098
|
rb_iv_set (vkey_sig, "@timestamp", LONG2NUM(key_sig->timestamp));
|
1084
1099
|
rb_iv_set (vkey_sig, "@expires", LONG2NUM(key_sig->expires));
|
1100
|
+
#endif
|
1085
1101
|
rb_ary_push (vsignatures, vkey_sig);
|
1086
1102
|
}
|
1087
1103
|
rb_ary_push (vuids, vuser_id);
|
@@ -1484,6 +1500,27 @@ rb_s_gpgme_op_delete (VALUE dummy, VALUE vctx, VALUE vkey, VALUE vallow_secret)
|
|
1484
1500
|
return LONG2NUM(err);
|
1485
1501
|
}
|
1486
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
|
+
|
1487
1524
|
static VALUE
|
1488
1525
|
rb_s_gpgme_op_delete_start (VALUE dummy, VALUE vctx, VALUE vkey,
|
1489
1526
|
VALUE vallow_secret)
|
@@ -1633,6 +1670,7 @@ rb_s_gpgme_op_card_edit_start (VALUE dummy, VALUE vctx, VALUE vkey,
|
|
1633
1670
|
return LONG2NUM(err);
|
1634
1671
|
}
|
1635
1672
|
|
1673
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
1636
1674
|
static VALUE
|
1637
1675
|
rb_s_gpgme_op_trustlist_start (VALUE dummy, VALUE vctx, VALUE vpattern,
|
1638
1676
|
VALUE vmax_level)
|
@@ -1696,6 +1734,7 @@ rb_s_gpgme_op_trustlist_end (VALUE dummy, VALUE vctx)
|
|
1696
1734
|
err = gpgme_op_trustlist_end (ctx);
|
1697
1735
|
return LONG2NUM(err);
|
1698
1736
|
}
|
1737
|
+
#endif
|
1699
1738
|
|
1700
1739
|
static VALUE
|
1701
1740
|
rb_s_gpgme_op_decrypt (VALUE dummy, VALUE vctx, VALUE vcipher, VALUE vplain)
|
@@ -2046,8 +2085,13 @@ rb_s_gpgme_op_sign_result (VALUE dummy, VALUE vctx)
|
|
2046
2085
|
INT2FIX(new_signature->hash_algo));
|
2047
2086
|
rb_iv_set (vnew_signature, "@sig_class",
|
2048
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
|
2049
2092
|
rb_iv_set (vnew_signature, "@timestamp",
|
2050
2093
|
LONG2NUM(new_signature->timestamp));
|
2094
|
+
#endif
|
2051
2095
|
rb_iv_set (vnew_signature, "@fpr", rb_str_new2 (new_signature->fpr));
|
2052
2096
|
rb_ary_push (vsignatures, vnew_signature);
|
2053
2097
|
}
|
@@ -2336,6 +2380,57 @@ rb_s_gpgme_op_spawn (VALUE dummy, VALUE vctx, VALUE vfile,
|
|
2336
2380
|
}
|
2337
2381
|
#endif
|
2338
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
|
+
|
2339
2434
|
void
|
2340
2435
|
Init_gpgme_n (void)
|
2341
2436
|
{
|
@@ -2402,8 +2497,10 @@ Init_gpgme_n (void)
|
|
2402
2497
|
rb_define_class_under (mGPGME, "Signature", rb_cObject);
|
2403
2498
|
cSigNotation =
|
2404
2499
|
rb_define_class_under (mGPGME, "SigNotation", rb_cObject);
|
2500
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2405
2501
|
cTrustItem =
|
2406
2502
|
rb_define_class_under (mGPGME, "TrustItem", rb_cObject);
|
2503
|
+
#endif
|
2407
2504
|
cInvalidKey =
|
2408
2505
|
rb_define_class_under (mGPGME, "InvalidKey", rb_cObject);
|
2409
2506
|
cNewSignature =
|
@@ -2547,6 +2644,8 @@ Init_gpgme_n (void)
|
|
2547
2644
|
rb_s_gpgme_op_import_result, 1);
|
2548
2645
|
rb_define_module_function (mGPGME, "gpgme_op_delete",
|
2549
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);
|
2550
2649
|
rb_define_module_function (mGPGME, "gpgme_op_delete_start",
|
2551
2650
|
rb_s_gpgme_op_delete_start, 3);
|
2552
2651
|
rb_define_module_function (mGPGME, "gpgme_op_edit",
|
@@ -2559,12 +2658,14 @@ Init_gpgme_n (void)
|
|
2559
2658
|
rb_s_gpgme_op_card_edit_start, 5);
|
2560
2659
|
|
2561
2660
|
/* Trust Item Management */
|
2661
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2562
2662
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_start",
|
2563
2663
|
rb_s_gpgme_op_trustlist_start, 3);
|
2564
2664
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_next",
|
2565
2665
|
rb_s_gpgme_op_trustlist_next, 2);
|
2566
2666
|
rb_define_module_function (mGPGME, "gpgme_op_trustlist_end",
|
2567
2667
|
rb_s_gpgme_op_trustlist_end, 1);
|
2668
|
+
#endif
|
2568
2669
|
|
2569
2670
|
/* Decrypt */
|
2570
2671
|
rb_define_module_function (mGPGME, "gpgme_op_decrypt",
|
@@ -2626,6 +2727,14 @@ Init_gpgme_n (void)
|
|
2626
2727
|
rb_s_gpgme_op_spawn_start, 7);
|
2627
2728
|
#endif
|
2628
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
|
+
|
2629
2738
|
/* gpgme_pubkey_algo_t */
|
2630
2739
|
rb_define_const (mGPGME, "GPGME_PK_RSA", INT2FIX(GPGME_PK_RSA));
|
2631
2740
|
rb_define_const (mGPGME, "GPGME_PK_DSA", INT2FIX(GPGME_PK_DSA));
|
@@ -2806,6 +2915,7 @@ Init_gpgme_n (void)
|
|
2806
2915
|
INT2FIX(GPGME_SIG_MODE_CLEAR));
|
2807
2916
|
|
2808
2917
|
/* gpgme_attr_t */
|
2918
|
+
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER < 0x020000
|
2809
2919
|
rb_define_const (mGPGME, "GPGME_ATTR_KEYID",
|
2810
2920
|
INT2FIX(GPGME_ATTR_KEYID));
|
2811
2921
|
rb_define_const (mGPGME, "GPGME_ATTR_FPR",
|
@@ -2868,6 +2978,7 @@ Init_gpgme_n (void)
|
|
2868
2978
|
INT2FIX(GPGME_ATTR_ERRTOK));
|
2869
2979
|
rb_define_const (mGPGME, "GPGME_ATTR_SIG_SUMMARY",
|
2870
2980
|
INT2FIX(GPGME_ATTR_SIG_SUMMARY));
|
2981
|
+
#endif
|
2871
2982
|
|
2872
2983
|
/* gpgme_validity_t */
|
2873
2984
|
rb_define_const (mGPGME, "GPGME_VALIDITY_UNKNOWN",
|
@@ -3113,6 +3224,26 @@ Init_gpgme_n (void)
|
|
3113
3224
|
INT2FIX(GPGME_ENCRYPT_NO_ENCRYPT_TO));
|
3114
3225
|
#endif
|
3115
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
|
+
|
3116
3247
|
/* These flags were added in 1.4.0. */
|
3117
3248
|
#if defined(GPGME_VERSION_NUMBER) && GPGME_VERSION_NUMBER >= 0x010400
|
3118
3249
|
rb_define_const (mGPGME, "GPGME_PINENTRY_MODE_DEFAULT",
|
@@ -3156,4 +3287,13 @@ Init_gpgme_n (void)
|
|
3156
3287
|
rb_define_const (mGPGME, "GPGME_EXPORT_MODE_PKCS12",
|
3157
3288
|
INT2FIX(GPGME_EXPORT_MODE_PKCS12));
|
3158
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
|
3159
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
@@ -447,8 +447,17 @@ module GPGME
|
|
447
447
|
# Delete the key from the key ring.
|
448
448
|
# If allow_secret is false, only public keys are deleted,
|
449
449
|
# otherwise secret keys are deleted as well.
|
450
|
-
|
451
|
-
|
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
|
452
461
|
exc = GPGME::error_to_exception(err)
|
453
462
|
raise exc if exc
|
454
463
|
end
|
@@ -561,6 +570,39 @@ module GPGME
|
|
561
570
|
raise exc if exc
|
562
571
|
end
|
563
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
|
+
|
564
606
|
def inspect
|
565
607
|
"#<#{self.class} protocol=#{PROTOCOL_NAMES[protocol] || protocol}, \
|
566
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
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/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
|