Package: libgnupg-interface-perl
Version: 1.04-1
Severity: important
X-Debbugs-Cc: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Control: forwarded -1 https://github.com/bestpractical/gnupg-interface/pull/14
Control: tags -1 + patch
Control: affects -1 + src:gnupg2

The GnuPG::Interface test suite fails with GnuPG 2.2.43 (currently in
unstable).  This appears to be because of GnuPG upstream backporting
support something called the RENC key usage flag, which i confess i
still don't really understand, though it is also associated with "ADSK".

See https://dev.gnupg.org/rGe4f61df8509e7aff0628971d9ea8fe967cd0f416 for
some kind of hints from upstream about what this is about.

The attached patch should fix the brittle test suite to accept yet
another variation in GnuPG's output, which the module attempts to parse
or at least compare.

    --dkg

-- System Information:
Debian Release: trixie/sid
  APT prefers testing-debug
  APT policy: (500, 'testing-debug'), (500, 'testing'), (500, 'stable'), (500, 
'oldstable'), (200, 'unstable-debug'), (200, 'unstable'), (1, 
'experimental-debug'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.7.12-amd64 (SMP w/4 CPU threads; PREEMPT)
Kernel taint flags: TAINT_FIRMWARE_WORKAROUND
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages libgnupg-interface-perl depends on:
ii  gnupg                       2.2.43-6
ii  gnupg1                      1.4.23-2
ii  libmath-bigint-perl         2.003002-1
ii  libmoo-perl                 2.005005-1
ii  libmoox-handlesvia-perl     0.001009-2
ii  libmoox-late-perl           0.100-2
ii  perl [libmath-bigint-perl]  5.38.2-4

libgnupg-interface-perl recommends no packages.

libgnupg-interface-perl suggests no packages.

-- no debconf information

From c64b499e627b74c76197b4682eb183c648622b4b Mon Sep 17 00:00:00 2001
From: Daniel Kahn Gillmor <d...@fifthhorseman.net>
Date: Fri, 24 May 2024 17:07:49 -0400
Subject: [PATCH 1/1] Handle versions of GnuPG 2.2.x that report the RENC key
 usage flag

GnuPG Upstream has apparently backported work on the putative "RENC"
flag to the 2.2.x branch, i think as of 2.2.42.

This means that the output of key listings that have this flag set
will change.  That breaks the fairly britle parser we have here.
---
 t/MyTestSpecific.pm  | 12 ++++++++++++
 t/get_public_keys.t  |  2 +-
 t/get_secret_keys.t  |  2 +-
 t/list_secret_keys.t |  6 +++---
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/t/MyTestSpecific.pm b/t/MyTestSpecific.pm
index 67af078..2b7c91c 100644
--- a/t/MyTestSpecific.pm
+++ b/t/MyTestSpecific.pm
@@ -167,4 +167,16 @@ 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)
+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.3') < 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';
     }
 
 
-- 
2.43.0

Attachment: signature.asc
Description: PGP signature

Reply via email to