#!/usr/bin/perl use lib '/home/httpd/typekey/perl/share/perl/5.8.4'; # this is where Crypt::DSA is use Crypt::DSA; my $dsa = Crypt::DSA->new; my $key = $dsa->keygen(Size => 512, Verbosity => 1); print ref $key; foreach my $k (keys %{$key}) { print "\n\n" . $k . " ==> " . $key->$k . "\n\n"; } $key->write(Type => PEM, Filename => "./pem.txt"); #### p=9724775026368841139769569722722225282105265311660245784262884339839777409021984194339477808838650259129119291111023685540287919864767243825053675926821009 g=2287671994688384782344874533763258286273033538675213553369081285149300964884679721477594029701967288779349370846813565354155329221817904945538359260835488 q=859065163383488309172119698913578680476929548109 pub_key=1616405844372248768017175081725715819467794476481165111247020697523189539662748575903031056357249848381157178400231796838322469179029084738638486691222852 #### -----BEGIN DSA PRIVATE KEY----- MIH3AgEAAkEAua21zY9vkrbyBe4b+XeGCLBEPCinaRsDidZnYcXznjiE25KWzaez 27m/CYaM3jEZPsP8InkmmCsWixz6R4uYkQIVAJZ50HBdIVUFssSLwqpyOa3cut9N AkArrehkdlnDRs1EFomRowMUuZX/52nsY56+RZAtrmuhJ1Qp5cZzDBQcF7oLZE9J tbUzTuCf0ufn0v9ZG+ZD/26gAkAe3NPCjj9sycSdcpYBkFH6+6PmPh+ZucgGExNa 7KUGtG3hs9RMkZeEKN4WSbi9AgMFuiYzvO814AusboSImZVEAhQ0kb43UjYzfSug ByFFsKZhRyay1g== -----END DSA PRIVATE KEY----- #### priv_key ==> 300117698295761934718759909833610346650914960086 #### #!/usr/bin/perl use strict; use lib '/home/httpd/typekey/perl/share/perl/5.8.4'; # this is where Crypt::DSA is use Crypt::DSA; use CGI; use Crypt::DSA::Key; # found on random google group use MIME::Base64; my ($t, $need_email, $_return, $v, $email, $name, $nick) = @ARGV; # $t is the site token, should be passed from logon.php # $need_email, should be 1 and should be passed from logon.php # $_return, is the base URL to append the other parameters to. NOTE: It already has a ? and a number of other parameters # $v, typekey version should be 1.1 and passed from logon.php # $email, user's email logon.php got this from the database # $name, user's userid. logon.php got this from the database # $nick, user's display name logon.php got this from the database my($ts, $sig); # $ts, timestamp # $sig the sig of the message before we break out r & s $ts = time; my $sig_msg = "$email::$name::$nick::$ts::$t"; # this is the message to be signed. my $dsa = Crypt::DSA->new; my $key = Crypt::DSA::Key->new( Type => 'PEM', Filename => '/home/httpd/typekey/pem.txt'); $sig = $dsa->sign(Message=>$sig_msg, Key => $key); # my $sig_typekey = $sig->r . ":" . $sig->s; my $sig_typekey = encode_base64($sig->r, "") . ":" . encode_base64($sig->s, ""); my $full_url = $_return . "&email=" . CGI::escape($email) . "&name=" . CGI::escape($name) . "&nick=" . CGI::escape($nick) . "&ts=" . CGI::escape($ts) . "&sig=" . CGI::escape($sig_typekey); print $full_url; #print the new URL so logon.php can pick it up and redirect to it.