signedForm.pl (1394B)
1 #! /usr/bin/perl 2 # This Source Code Form is subject to the terms of the Mozilla Public 3 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 5 6 7 8 sub decode { 9 read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 10 @pairs = split(/&/, $buffer); 11 foreach $pair (@pairs) 12 { 13 ($name, $value) = split(/=/, $pair); 14 $value =~tr/+/ /; 15 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 16 $FORM{$name} = $value; 17 # print "name=$name value=$value<BR>\n"; 18 } 19 } 20 21 print "Content-type: text/html\n\n"; 22 23 &decode(); 24 25 $dataSignature = $FORM{'dataSignature'}; 26 $dataToSign = $FORM{'dataToSign'}; 27 28 unlink("signature"); 29 open(FILE1,">signature") || die("Cannot open file for writing\n"); 30 31 print FILE1 "$dataSignature"; 32 33 close(FILE1); 34 35 36 unlink("data"); 37 open(FILE2,">data") || die("Cannot open file for writing\n"); 38 39 print FILE2 "$dataToSign"; 40 41 close(FILE2); 42 43 44 print "<BR><B>Signed Data:</B><BR>", "$dataToSign", "<BR>"; 45 46 print "<BR><b>Verification Info:</b><BR>"; 47 48 $verInfo = `./signver -D . -s signature -d data -v`; 49 print "<font color=red><b>$verInfo</b></font><BR>"; 50 51 print "<BR><B>Signature Data:</B><BR>", "$dataSignature", "<BR>"; 52 53 print "<BR><b>Signature Info:</b><BR>"; 54 55 foreach $line (`./signver -s signature -A`) { 56 print "$line<BR>\n"; 57 } 58 59 print "<b>End of Info</b><BR>";