1Crypt::OpenSSL::DSA(3)User Contributed Perl DocumentationCrypt::OpenSSL::DSA(3)
2
3
4

NAME

6       Crypt::OpenSSL::DSA - Digital Signature Algorithm using OpenSSL
7

SYNOPSIS

9         use Crypt::OpenSSL::DSA;
10
11         # generate keys and write out to PEM files
12         my $dsa = Crypt::OpenSSL::DSA->generate_parameters( 512 );
13         $dsa->generate_key;
14         $dsa->write_pub_key( $filename );
15         $dsa->write_priv_key( $filename );
16
17         # using keys from PEM files
18         my $dsa_priv = Crypt::OpenSSL::DSA->read_priv_key( $filename );
19         my $sig      = $dsa_priv->sign($message);
20         my $dsa_pub  = Crypt::OpenSSL::DSA->read_pub_key( $filename );
21         my $valid    = $dsa_pub->verify($message, $sig);
22
23         # using keys from PEM strings
24         my $dsa_priv = Crypt::OpenSSL::DSA->read_priv_key_str( $key_string );
25         my $sig      = $dsa_priv->sign($message);
26         my $dsa_pub  = Crypt::OpenSSL::DSA->read_pub_key_str( $key_string );
27         my $valid    = $dsa_pub->verify($message, $sig);
28

DESCRIPTION

30       Crypt::OpenSSL::DSA implements the DSA (Digital Signature Algorithm)
31       signature verification system.
32
33       It is a thin XS wrapper to the DSA functions contained in the OpenSSL
34       crypto library, located at http://www.openssl.org
35

CLASS METHODS

37       $dsa = Crypt::OpenSSL::DSA->generate_parameters( $bits, $seed );
38           Returns a new DSA object and generates the p, q and g parameters
39           necessary to generate keys.
40
41           bits is the length of the prime to be generated; the DSS allows a
42           maximum of 1024 bits.
43
44       $dsa = Crypt::OpenSSL::DSA->read_params( $filename );
45           Reads in a parameter PEM file and returns a new DSA object with the
46           p, q and g parameters necessary to generate keys.
47
48       $dsa = Crypt::OpenSSL::DSA->read_pub_key( $filename );
49           Reads in a public key PEM file and returns a new DSA object that
50           can be used to verify DSA signatures.
51
52       $dsa = Crypt::OpenSSL::DSA->read_priv_key( $filename );
53           Reads in a private key PEM file and returns a new DSA object that
54           can be used to sign messages.
55
56       $dsa = Crypt::OpenSSL::DSA->read_pub_key_str( $key_string );
57           Reads in a public key PEM string and returns a new DSA object that
58           can be used to verify DSA signatures.  The string should include
59           the -----BEGIN...----- and -----END...----- lines.
60
61       $dsa = Crypt::OpenSSL::DSA->read_priv_key_str( $key_string );
62           Reads in a private key PEM string and returns a new DSA object that
63           can be used to sign messages.  The string should include the
64           -----BEGIN...----- and -----END...----- lines.
65

OBJECT METHODS

67       $dsa->generate_key;
68           Generates private and public keys, assuming that $dsa is the return
69           value of generate_parameters.
70
71       $sig = $dsa->sign( $message );
72           Signs $message, returning the signature.  Note that $meesage cannot
73           exceed 20 characters in length.
74
75           $dsa is the signer's private key.
76
77       $sig_obj = $dsa->do_sign( $message );
78           Similar to "sign", but returns a Crypt::OpenSSL::DSA::Signature
79           object.
80
81       $valid = $dsa->verify( $message, $sig );
82           Verifies that the $sig signature for $message is valid.
83
84           $dsa is the signer's public key.
85
86           Note: it croaks if the underlying library call returns error (-1).
87
88       $valid = $dsa->do_verify( $message, $sig_obj );
89           Similar to "verify", but uses a Crypt::OpenSSL::DSA::Signature
90           object.
91
92           Note: it croaks if the underlying library call returns error (-1).
93
94       $dsa->write_params( $filename );
95           Writes the parameters into a PEM file.
96
97       $dsa->write_pub_key( $filename );
98           Writes the public key into a PEM file.
99
100       $dsa->write_priv_key( $filename );
101           Writes the private key into a PEM file.
102
103       $p = $dsa->get_p, $dsa->set_p($p)
104           Gets/sets the prime number in binary format.
105
106       $q = $dsa->get_q, $dsa->set_q($q)
107           Gets/sets the subprime number (q | p-1) in binary format.
108
109       $g = $dsa->get_g, $dsa->set_g($g)
110           Gets/sets the generator of subgroup in binary format.
111
112       $pub_key = $dsa->get_pub_key, $dsa->set_pub_key($pub_key)
113           Gets/sets the public key (y = g^x) in binary format.
114
115       $priv_key = $dsa->get_priv_key, $dsa->set_priv_key($priv_key)
116           Gets/sets the private key in binary format.
117

NOTES

119       Crpyt::DSA is a more mature Perl DSA module, but can be difficult to
120       install, because of the Math::Pari requirement.
121
122       Comments, suggestions, and patches welcome.
123

AUTHOR

125       T.J. Mather, <tjmather@maxmind.com>
126
128       Copyright (c) 2002 T.J. Mather.  Crypt::OpenSSL::DSA is free software;
129       you may redistribute it and/or modify it under the same terms as Perl
130       itself.
131
132       Paid support is available directly from the author of this package.
133       Please see <http://www.maxmind.com/app/opensourceservices> for more
134       details.
135

SEE ALSO

137       Crypt::OpenSSL::DSA::Signature
138
139       Crypt::DSA, Crypt::OpenSSL::RSA
140
141       Net::DNS::SEC
142
143
144
145perl v5.32.1                      2021-01-27            Crypt::OpenSSL::DSA(3)
Impressum