This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=2c622bc07510a4503816e936a1e36308d25090c5 commit 2c622bc07510a4503816e936a1e36308d25090c5 Author: Guillem Jover <[email protected]> AuthorDate: Wed Oct 26 19:57:17 2022 +0200 Dpkg::OpenPGP: Add new dearmor() function --- scripts/Dpkg/OpenPGP.pm | 9 +++++++++ scripts/t/Dpkg_OpenPGP.t | 9 ++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/Dpkg/OpenPGP.pm b/scripts/Dpkg/OpenPGP.pm index eb6574a97..fcaf9f3b5 100644 --- a/scripts/Dpkg/OpenPGP.pm +++ b/scripts/Dpkg/OpenPGP.pm @@ -129,6 +129,15 @@ sub armor { return $asc; } +sub dearmor { + my ($type, $asc, $bin) = @_; + + my $armor = file_slurp($asc); + file_dump($bin, _pgp_dearmor_data($type, $armor)); + + return $bin; +} + sub _gpg_exec { my ($opts, $exec, $errmsg) = @_; diff --git a/scripts/t/Dpkg_OpenPGP.t b/scripts/t/Dpkg_OpenPGP.t index 234be750c..e8e727d3a 100644 --- a/scripts/t/Dpkg_OpenPGP.t +++ b/scripts/t/Dpkg_OpenPGP.t @@ -25,7 +25,7 @@ use Dpkg::ErrorHandling; test_needs_command('gpg'); -plan tests => 4; +plan tests => 5; use_ok('Dpkg::OpenPGP'); @@ -47,6 +47,13 @@ $ascfile = "$tmpdir/data-file.asc"; Dpkg::OpenPGP::armor('ARMORED FILE', $binfile, $ascfile); ok(compare($ascfile, $reffile) == 0, 'armor binary file into OpenPGP ASCII Armor'); +$reffile = "$datadir/data-file"; +$ascfile = "$datadir/data-file.asc"; +$binfile = "$tmpdir/data-file"; + +Dpkg::OpenPGP::dearmor('ARMORED FILE', $ascfile, $binfile); +ok(compare($binfile, $reffile) == 0, 'dearmor OpenPGP ASCII Armor into binary file'); + # TODO: Add actual test cases. 1; -- Dpkg.Org's dpkg

