I'm helping a friend intergrate Movable Type into his current login system. Since MT uses the TypeKey API for commenter auth, I figured I'd make a few changes to his login to behave like a TypeKey system.

Now according to Six Apart this sounds really simple. Once you validate the user, just take what MT submitted, process it, and return it to the URL specified.

So anyway my problem right now is with Crypt::DSA. I created a key with the following script:

#!/usr/bin/perl 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 $k . "=" . $key->$k . " "; }
Ok no problem there, it created the key. Now in my actual script I need to use that key. I've tried a couple of ways to assign the key, but none of them work. How do I do this?
my %key; $key{"priv_key"} = "864936564936746739711078786791024560681741810216"; $key{"p"} = "103389578900933505962259092511631192256092079077336779855 +585334041474848850089585441001014183922540716749810264398731049494647 +20186311018367111795638927603"; $key{"g"} = "295468312836227549163017971559304985039133262378345815627 +315465892672058916494919915988882646491840732863667119568864913013161 +2326212886632087281832722137"; $key{"q"} = "1001831165198829652697436093010198645746872403487"; $key{"pub_key"} = "132346092772099461807044872757466388868899357571508 +126750807181863604967004471330240874757885029643259002077192969991245 +2512506924349344334420749206004502"; $sig = $dsa->sign(Message=>$sig_msg, Key => %key);
That fails with the error:
Can't locate object method "q" via package "p" (perhaps you forgot to load "p"?) at /usr/lib/perl5/site_perl/5.8.0/Crypt/DSA.pm line 45.

So maybe I don't understand how to assign the key var correctly. In the keygen script it doesn't have a % in front of it so lets try this:

my $key; $key->{"priv_key"} = "864936564936746739711078786791024560681741810216 +"; $key->{"p"} = "1033895789009335059622590925116311922560920790773367798 +555853340414748488500895854410010141839225407167498102643987310494946 +4720186311018367111795638927603"; $key->{"g"} = "2954683128362275491630179715593049850391332623783458156 +273154658926720589164949199159888826464918407328636671195688649130131 +612326212886632087281832722137"; $key->{"q"} = "1001831165198829652697436093010198645746872403487"; $key->{"pub_key"} = "1323460927720994618070448727574663888688993575715 +081267508071818636049670044713302408747578850296432590020771929699912 +452512506924349344334420749206004502"; $sig = $dsa->sign(Message=>$sig_msg, Key => $key);
Can't call method "q" on unblessed reference at /usr/lib/perl5/site_perl/5.8.0/Crypt/DSA.pm line 45.

Ok that helped so much that I'm pretty sure I'm over my head. So what am I doing wrong here?

Actually, if anyone has already implemented a typekey server, that would be really cool and more useful.


In reply to How to Make Crypt::DSA use a your key to sign something by xorl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.