in reply to How to Make Crypt::DSA use a your key to sign something

I don't have it all setup to test, but from the errors you are getting, and the perldoc for Crypt::DSA, it seems you are telling the program that your key is a hash or hashref, instead of the key. Try this:
# change # $sig = $dsa->sign(Message=>$sig_msg, Key => $key); # to $sig = $dsa->sign(Message=>$sig_msg, Key => $key->{'p'} );

I'm not really a human, but I play one on earth. flash japh

Replies are listed 'Best First'.
Re^2: How to Make Crypt::DSA use a your key to sign something
by xorl (Deacon) on Feb 23, 2006 at 20:10 UTC
    Thanks but it still says...

    Can't call method "q" without a package or object reference at /usr/lib/perl5/site_perl/5.8.0/Crypt/DSA.pm line 45.

    perldoc for Crypt::DSA says about the Key in sign...

  • Key
    The Crypt::DSA::Key object with which the signature will be gener-
    ated. Should contain a private key attribute (priv_key).

    This argument is required.
  • So I think I somehow need to make $key be an object like what I had in the first script. I just don't see a way to do that right now. I'm sure it must be possible.
      Yeah, I just got all the pre-requisites installed, and see the problem in my testing....sorry if I led you off track. After a groups.google.search for the problem, it has been asked before on the newsgroups. What it seems to come down to, is that you cannot just take the Dump
      $key{"priv_key"} = "864936564936746739711078786791024560681741810216";
      and use that as a private key. The "key" must be a Crypt::DSA::Key object. From the looks of things, you need to save your key to a file, like
      $key->write( Type => 'PEM', Filename => $keyfile);
      then when you want to import that file
      $key = Crypt::DSA::Key->new(Type => 'PEM', Filename => $keyfile);
      Now whether you can read that into a scalar value, I don't know. But the PEM key should look like
      -----BEGIN DSA PRIVATE KEY----- MIH3AgEAAkEAuu/8bF0QtFaU8Eo3XzJzyuwyfIEoCvYxzcx5dGkTa7przkVGPaJp n6uEPIueBQEP21+SmfebPpkbKF98gw+MSwIVAMGFQpGtsAWNedBzQ85p0CkTuKYZ AkBLciRf48J8u/LYz2FejmaPs88sKPt/mNLLfzOUz6LO0HqjXOq6vD0WzGcek0Z6 VK9JD3r9eyclPNvsArZ7v/LaAkBxM58UjEqschS9r7Je28kCQ4eYC4lhkRq+pAot /kh86LBlohQZ6A6zgCyPiKNLT5VQ29vKW49f36XjYrIDUk21AhQdRFsMvKVp+W5C 7L7i0FLp3tYb6w== -----END DSA PRIVATE KEY-----
      and NOT the number string you originaly had. I will post an example if I can get it to work. :-)

      I'm not really a human, but I play one on earth. flash japh

        Ah this does work. I should have check the newsgroups a bit more.

        I wish the perldoc for Crypt::DSA had mentioned that there is a write function.

        Thanks!