Crypt::OpenSSL::DSA - Digital Signature Algorithm using OpenSSL
use Crypt::OpenSSL::DSA; # generate keys and write out to PEM files my $dsa = Crypt::OpenSSL::DSA->generate_parameters( 512 ); $dsa->generate_key; $dsa->write_pub_key( $filename ); $dsa->write_priv_key( $filename ); # using keys from PEM files my $dsa_priv = Crypt::OpenSSL::DSA->read_priv_key( $filename ); my $sig = $dsa_priv->sign($message); my $dsa_pub = Crypt::OpenSSL::DSA->read_pub_key( $filename ); my $valid = $dsa_pub->verify($message, $sig); # using keys from PEM strings my $dsa_priv = Crypt::OpenSSL::DSA->read_priv_key_str( $key_string ); my $sig = $dsa_priv->sign($message); my $dsa_pub = Crypt::OpenSSL::DSA->read_pub_key_str( $key_string ); my $valid = $dsa_pub->verify($message, $sig);
Crypt::OpenSSL::DSA implements the DSA (Digital Signature Algorithm) signature verification system.
It is a thin XS wrapper to the DSA functions contained in the OpenSSL crypto library, located at http://www.openssl.org
Returns a new DSA object and generates the p, q and g parameters necessary to generate keys.
bits is the length of the prime to be generated; the DSS allows a maximum of 1024 bits.
Reads in a parameter PEM file and returns a new DSA object with the p, q and g parameters necessary to generate keys.
Reads in a public key PEM file and returns a new DSA object that can be used to verify DSA signatures.
Reads in a private key PEM file and returns a new DSA object that can be used to sign messages.
Reads in a public key PEM string and returns a new DSA object that can be used to verify DSA signatures. The string should include the -----BEGIN...----- and -----END...----- lines.
Reads in a private key PEM string and returns a new DSA object that can be used to sign messages. The string should include the -----BEGIN...----- and -----END...----- lines.
Generates private and public keys, assuming that $dsa is the return value of generate_parameters.
Signs $message, returning the signature. Note that $meesage cannot exceed 20 characters in length.
$dsa is the signer's private key.
Similar to sign, but returns a Crypt::OpenSSL::DSA::Signature object.
sign
Verifies that the $sig signature for $message is valid.
$dsa is the signer's public key.
Note: it croaks if the underlying library call returns error (-1).
Similar to verify, but uses a Crypt::OpenSSL::DSA::Signature object.
verify
Writes the parameters into a PEM file.
Writes the public key into a PEM file.
Writes the private key into a PEM file.
Gets/sets the prime number in binary format.
Gets/sets the subprime number (q | p-1) in binary format.
Gets/sets the generator of subgroup in binary format.
Gets/sets the public key (y = g^x) in binary format.
Gets/sets the private key in binary format.
Crpyt::DSA is a more mature Perl DSA module, but can be difficult to install, because of the Math::Pari requirement.
Comments, suggestions, and patches welcome.
T.J. Mather, <tjmather@maxmind.com>
Copyright (c) 2002 T.J. Mather. Crypt::OpenSSL::DSA is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
Paid support is available directly from the author of this package. Please see http://www.maxmind.com/app/opensourceservices for more details.
Crypt::OpenSSL::DSA::Signature
Crypt::DSA, Crypt::OpenSSL::RSA
Net::DNS::SEC
To install Crypt::OpenSSL::DSA, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Crypt::OpenSSL::DSA
CPAN shell
perl -MCPAN -e shell install Crypt::OpenSSL::DSA
For more information on module installation, please visit the detailed CPAN module installation guide.