1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/security/nss/cmd/signver/examples/1/signedForm.pl Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,60 @@ 1.4 +#! /usr/bin/perl 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 + 1.9 + 1.10 + 1.11 +sub decode { 1.12 + read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); 1.13 + @pairs = split(/&/, $buffer); 1.14 + foreach $pair (@pairs) 1.15 + { 1.16 + ($name, $value) = split(/=/, $pair); 1.17 + $value =~tr/+/ /; 1.18 + $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; 1.19 + $FORM{$name} = $value; 1.20 +# print "name=$name value=$value<BR>\n"; 1.21 + } 1.22 +} 1.23 + 1.24 +print "Content-type: text/html\n\n"; 1.25 + 1.26 +&decode(); 1.27 + 1.28 +$dataSignature = $FORM{'dataSignature'}; 1.29 +$dataToSign = $FORM{'dataToSign'}; 1.30 + 1.31 +unlink("signature"); 1.32 +open(FILE1,">signature") || die("Cannot open file for writing\n"); 1.33 + 1.34 +print FILE1 "$dataSignature"; 1.35 + 1.36 +close(FILE1); 1.37 + 1.38 + 1.39 +unlink("data"); 1.40 +open(FILE2,">data") || die("Cannot open file for writing\n"); 1.41 + 1.42 +print FILE2 "$dataToSign"; 1.43 + 1.44 +close(FILE2); 1.45 + 1.46 + 1.47 +print "<BR><B>Signed Data:</B><BR>", "$dataToSign", "<BR>"; 1.48 + 1.49 +print "<BR><b>Verification Info:</b><BR>"; 1.50 + 1.51 +$verInfo = `./signver -D . -s signature -d data -v`; 1.52 +print "<font color=red><b>$verInfo</b></font><BR>"; 1.53 + 1.54 +print "<BR><B>Signature Data:</B><BR>", "$dataSignature", "<BR>"; 1.55 + 1.56 +print "<BR><b>Signature Info:</b><BR>"; 1.57 + 1.58 +foreach $line (`./signver -s signature -A`) { 1.59 + print "$line<BR>\n"; 1.60 +} 1.61 + 1.62 +print "<b>End of Info</b><BR>"; 1.63 +