compatibility check perl script pgp/gpg

Mark Hofstetter mark.hofstetter@univie.ac.at
Wed Apr 4 15:35:07 2001


Hi everybody,

I've written a small perl-script to test compatibility between pgp 
clearsigned mails ang gpg - it doesn't strive for ellegance but it works ...
perl, pgp and gpg have to be installed and keys have to be exchanged

@bau  contains the fragments of which the text which is to be signed is 
composed
additionally a random ASCII character is inserted

-> both programs work together quite well but tab-character (ASCII 9) leeds 
to to "bad signature" if signed with pgp and checked with gpg an vice versa

Regards

Mark


#!/usr/bin/perl

@bau=("hallo  ", "hallo  ", 
"hallo  ","hallo  ","hallo  ","hallo  \t","hallo  ","hallo","hallo 
","hallo  ","hallo  ","hallo  ","hallo  ","hal lo","hallo  ","\r\n", "\n");
$k=0;


for ($i=1; $i<=255; $i++)
{
open (STDERR, ">ausgabe.txt");

open (FH, ">text");
$a="";
for ($z=0; $z<=30; $z++)
         {

         $zuf=int(rand ($#bau));
         $a.=$bau[$zuf];

         if ($z==15)
         {
         $zeichen=int(rand 255);
         $var=pack "c", $i;
         $a.=$var;
         }


         }
print FH $a;
close FH;

$pgp=`pgp +force -z test -sta text`;

system("cat text.asc");
open (AFH, "<text.asc");
@all=<AFH>;
close AFH;

$aus=join(/""/, @all);

#$aus=s///g;

open (AFH, ">text.asc");
print AFH $aus;
close AFH;

$gpg=`gpg --verify text.asc`;

#system("cat text.asc");

open (AFH, "<ausgabe.txt");
@all=<AFH>;
close AFH;

$aus=join(/""/, @all);

if ($aus=~/Good signature/)
         {
                 print "OK\n";
         }
         else
         {
                 print "BAD - $i\n";
                 $fn="fehler".$k;
                 open (BFH, ">$fn");
                 print BFH $a;
                 #print BFH "BAD - $i $var\n";
                 $k++;
                 close BFH;
         }
}



--
Mag. Mark Hofstetter
Vienna University Computer Center
mh.zid@univie.ac.at