1Crypt::DSA(3) User Contributed Perl Documentation Crypt::DSA(3)
2
3
4
6 Crypt::DSA - DSA Signatures and Key Generation
7
9 use Crypt::DSA;
10 my $dsa = Crypt::DSA->new;
11
12 my $key = $dsa->keygen(
13 Size => 512,
14 Seed => $seed,
15 Verbosity => 1
16 );
17
18 my $sig = $dsa->sign(
19 Message => "foo bar",
20 Key => $key
21 );
22
23 my $verified = $dsa->verify(
24 Message => "foo bar",
25 Signature => $sig,
26 Key => $key,
27 );
28
30 Crypt::DSA is an implementation of the DSA (Digital Signature
31 Algorithm) signature verification system. The implementation itself is
32 pure Perl, although the heavy-duty mathematics underneath are provided
33 by the Math::Pari library.
34
35 This package provides DSA signing, signature verification, and key
36 generation.
37
39 The Crypt::DSA public interface is similar to that of Crypt::RSA. This
40 was done intentionally.
41
42 Crypt::DSA->new
43 Constructs a new Crypt::DSA object. At the moment this isn't
44 particularly useful in itself, other than being the object you need to
45 do much else in the system.
46
47 Returns the new object.
48
49 $key = $dsa->keygen(%arg)
50 Generates a new set of DSA keys, including both the public and private
51 portions of the key.
52
53 %arg can contain:
54
55 · Size
56
57 The size in bits of the p value to generate. The q and g values are
58 always 160 bits each.
59
60 This argument is mandatory.
61
62 · Seed
63
64 A seed with which q generation will begin. If this seed does not
65 lead to a suitable prime, it will be discarded, and a new random
66 seed chosen in its place, until a suitable prime can be found.
67
68 This is entirely optional, and if not provided a random seed will
69 be generated automatically.
70
71 · Verbosity
72
73 Should be either 0 or 1. A value of 1 will give you a progress
74 meter during p and q generation--this can be useful, since the
75 process can be relatively long.
76
77 The default is 0.
78
79 $signature = $dsa->sign(%arg)
80 Signs a message (or the digest of a message) using the private portion
81 of the DSA key and returns the signature.
82
83 The return value--the signature--is a Crypt::DSA::Signature object.
84
85 %arg can include:
86
87 · Digest
88
89 A digest to be signed. The digest should be 20 bytes in length or
90 less.
91
92 You must provide either this argument or Message (see below).
93
94 · Key
95
96 The Crypt::DSA::Key object with which the signature will be
97 generated. Should contain a private key attribute (priv_key).
98
99 This argument is required.
100
101 · Message
102
103 A plaintext message to be signed. If you provide this argument,
104 sign will first produce a SHA1 digest of the plaintext, then use
105 that as the digest to sign. Thus writing
106
107 my $sign = $dsa->sign(Message => $message, ... );
108
109 is a shorter way of writing
110
111 use Digest::SHA1 qw( sha1 );
112 my $sig = $dsa->sign(Digest => sha1( $message ), ... );
113
114 $verified = $dsa->verify(%arg)
115 Verifies a signature generated with sign. Returns a true value on
116 success and false on failure.
117
118 %arg can contain:
119
120 · Key
121
122 Key of the signer of the message; a Crypt::DSA::Key object. The
123 public portion of the key is used to verify the signature.
124
125 This argument is required.
126
127 · Signature
128
129 The signature itself. Should be in the same format as returned from
130 sign, a Crypt::DSA::Signature object.
131
132 This argument is required.
133
134 · Digest
135
136 The original signed digest whose length is less than or equal to 20
137 bytes.
138
139 Either this argument or Message (see below) must be present.
140
141 · Message
142
143 As above in sign, the plaintext message that was signed, a string
144 of arbitrary length. A SHA1 digest of this message will be created
145 and used in the verification process.
146
148 Add ability to munge format of keys. For example, read/write keys
149 from/to key files (SSH key files, etc.), and also write them in other
150 formats.
151
153 Bugs should be reported via the CPAN bug tracker at
154
155 http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA
156 <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA>
157
158 For other issues, contact the author.
159
161 Benjamin Trott <ben@sixapart.com>
162
164 Except where otherwise noted, Crypt::DSA is Copyright 2006 - 2009
165 Benjamin Trott.
166
167 Crypt::DSA is free software; you may redistribute it and/or modify it
168 under the same terms as Perl itself.
169
170
171
172perl v5.12.0 2009-09-11 Crypt::DSA(3)