File: 0007-Handle-versions-of-GnuPG-2.2.x-that-report-the-RENC-.patch

package info (click to toggle)
libgnupg-interface-perl 1.04-6
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 824 kB
  • sloc: perl: 3,828; makefile: 6; sh: 5
file content (89 lines) | stat: -rw-r--r-- 3,153 bytes parent folder | download
1
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
From: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
Date: Fri, 24 May 2024 17:07:49 -0400
Subject: Handle versions of GnuPG 2.{2,3,4}.x,
 that misreport the RENC key usage flag

Forwarded: https://github.com/bestpractical/gnupg-interface/pull/14

Some versions of GnuPG 2.2, 2.3, and 2.4 printed an apparently bogus
RENC key usage flag.  Avoid failing the test suite just because those
versions are in use.

---
 t/MyTestSpecific.pm  | 17 +++++++++++++++++
 t/get_public_keys.t  |  2 +-
 t/get_secret_keys.t  |  2 +-
 t/list_secret_keys.t |  6 +++---
 4 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm
index 67af078..609c065 100644
--- a/t/MyTestSpecific.pm
+++ b/t/MyTestSpecific.pm
@@ -167,4 +167,21 @@ sub get_expired_test_sig_params {
     return %sig_params
 }
 
+# determine whether this GnuPG version reports on the "RENC" key usage
+# flag, which was added in 2.3.8 and 2.2.42 (see upstream
+# e4f61df8509e7aff0628971d9ea8fe967cd0f416)
+# and changed again in 2.2.44 (see upstream
+# 1d91252205a21fc1a42e7a55a49421e50bb70f05)
+# and again in 2.4.6 (see upstream
+# a2966c9d894a9a92d7000bdd08ab757ab0060ef3)
+sub get_supported_renc {
+  my $gnupg = shift;
+  my $version = $gnupg->version;
+
+  return ((($gnupg->cmp_version($version, '2.3.8') >= 0) &&
+           ($gnupg->cmp_version($version, '2.4.6') < 0)) ||
+          (($gnupg->cmp_version($version, '2.2.44') < 0) &&
+           ($gnupg->cmp_version($version, '2.2.42') >= 0)));
+}
+
 1;
diff --git a/t/get_public_keys.t b/t/get_public_keys.t
index 8d8eebf..9d56a67 100644
--- a/t/get_public_keys.t
+++ b/t/get_public_keys.t
@@ -181,7 +181,7 @@ TEST
         hex_id                   => 'ADB99D9C2E854A6B',
         creation_date            => 949813119,
         creation_date_string     => '2000-02-06',
-        usage_flags              => $gnupg->cmp_version($gnupg->version, '2.3.8') >= 0 ? 'er' : 'e',
+        usage_flags              => get_supported_renc($gnupg) ? 'er' : 'e',
         pubkey_data              => $subkey_pub_data,
       );
 
diff --git a/t/get_secret_keys.t b/t/get_secret_keys.t
index 5fc2a57..1d8e583 100644
--- a/t/get_secret_keys.t
+++ b/t/get_secret_keys.t
@@ -87,7 +87,7 @@ TEST
         hex_id                   => 'ADB99D9C2E854A6B',
         creation_date            => 949813119,
         creation_date_string     => '2000-02-06',
-        usage_flags              => $gnupg->cmp_version($gnupg->version, '2.3.8') >= 0 ? 'er' : 'e',
+        usage_flags              => get_supported_renc($gnupg) ? 'er' : 'e',
         pubkey_data              => $subkey_pub_data,
       };
 
diff --git a/t/list_secret_keys.t b/t/list_secret_keys.t
index 44af61f..dcd0b97 100644
--- a/t/list_secret_keys.t
+++ b/t/list_secret_keys.t
@@ -51,11 +51,11 @@ TEST
     elsif ( $gnupg->cmp_version( $gnupg->version, '2.1.11' ) <= 0 ) {
         $keylist = '1';
     }
-    elsif ( $gnupg->cmp_version( $gnupg->version, '2.3.8' ) < 0 ) {
-        $keylist = '2.2';
+    elsif ( get_supported_renc( $gnupg ) ) {
+        $keylist = '2';
     }
     else {
-        $keylist = '2';
+        $keylist = '2.2';
     }