From 82d778e02f309987aa70ff6efda3f7e237ccb968 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Mon, 7 Jul 2003 01:52:23 +0000 Subject: [PATCH] A simple program to sign control messages with News::Article so that pgpverify can be checked for compatibility. --- tests/sign-newsart | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100755 tests/sign-newsart diff --git a/tests/sign-newsart b/tests/sign-newsart new file mode 100755 index 0000000..5caa2a9 --- /dev/null +++ b/tests/sign-newsart @@ -0,0 +1,53 @@ +#! /usr/bin/perl -w +$ID = q$ID$; +# +# sign-newsart -- Simple wrapper to sign a control message with News::Article. +# +# Written by Russ Allbery +# This work is hereby placed in the public domain by its author. +# +# This program is used to test that pgpverify can correctly verify signatures +# made by News::Article. It generates two signed messages, signed.pgp and +# signed.gpg, in the current directory from the file given on the command +# line. + +use strict; +use vars qw($ID); + +use News::Article; +use PGP::Sign (); + +# Find a program on the user's path. +sub find_program { + my ($program) = @_; + my @path = split (/:/, $ENV{PATH}); + for (@path) { + return "$_/$program" if -x "$_/$program"; + } + return $program; +} + +my $article = News::Article->new ($ARGV[0]); +open (PASS, 'keyring/passphrase') + or die "Can't open keyring/passphrase: $!\n"; +my $passphrase = ; +chomp $passphrase; +close PASS; +$PGP::Sign::PGPPATH = 'keyring'; +$PGP::Sign::PGPSTYLE = 'PGP2'; +$PGP::Sign::PGPS = find_program ('pgp'); +$PGP::Sign::PGPV = $PGP::Sign::PGPS; +my $error = $article->sign_control ('testing', $passphrase); +die "$error\n" if $error; +open (PGP, '> signed.pgp') or die "Can't create signed.pgp: $!\n"; +$article->write (\*PGP); +close PGP; +$PGP::Sign::PGPSTYLE = 'GPG'; +$PGP::Sign::PGPS = find_program ('gpg'); +$PGP::Sign::PGPV = find_program ('gpgv'); +$error = $article->sign_control ('testing', $passphrase); +die "$error\n" if $error; +open (PGP, '> signed.gpg') or die "Can't create signed.gpg: $!\n"; +$article->write (\*PGP); +close PGP; +exit 0;