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

NAME

6       Crypt::DSA - DSA Signatures and Key Generation
7

SYNOPSIS

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

DESCRIPTION

30       Crypt::DSA is an implementation of the DSA (Digital Signature Algo‐
31       rithm) signature verification system. The implementation itself is pure
32       Perl, although the heavy-duty mathematics underneath are provided by
33       the Math::Pari library.
34
35       This package provides DSA signing, signature verification, and key gen‐
36       eration.
37

USAGE

39       The Crypt::DSA public interface is similar to that of Crypt::RSA. This
40       was done intentionally.
41
42       Crypt::DSA->new
43
44       Constructs a new Crypt::DSA object. At the moment this isn't particu‐
45       larly useful in itself, other than being the object you need to do much
46       else in the system.
47
48       Returns the new object.
49
50       $key = $dsa->keygen(%arg)
51
52       Generates a new set of DSA keys, including both the public and private
53       portions of the key.
54
55       %arg can contain:
56
57       * Size
58           The size in bits of the p value to generate. The q and g values are
59           always 160 bits each.
60
61           This argument is mandatory.
62
63       * Seed
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           Should be either 0 or 1. A value of 1 will give you a progress
73           meter during p and q generation--this can be useful, since the
74           process can be relatively long.
75
76           The default is 0.
77
78       $signature = $dsa->sign(%arg)
79
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           A digest to be signed. The digest should be 20 bytes in length or
89           less.
90
91           You must provide either this argument or Message (see below).
92
93       * Key
94           The Crypt::DSA::Key object with which the signature will be gener‐
95           ated. Should contain a private key attribute (priv_key).
96
97           This argument is required.
98
99       * Message
100           A plaintext message to be signed. If you provide this argument,
101           sign will first produce a SHA1 digest of the plaintext, then use
102           that as the digest to sign. Thus writing
103
104               my $sign = $dsa->sign(Message => $message, ... );
105
106           is a shorter way of writing
107
108               use Digest::SHA1 qw( sha1 );
109               my $sig = $dsa->sign(Digest => sha1( $message ), ... );
110
111       $verified = $dsa->verify(%arg)
112
113       Verifies a signature generated with sign. Returns a true value on suc‐
114       cess and false on failure.
115
116       %arg can contain:
117
118       * Key
119           Key of the signer of the message; a Crypt::DSA::Key object.  The
120           public portion of the key is used to verify the signature.
121
122           This argument is required.
123
124       * Signature
125           The signature itself. Should be in the same format as returned from
126           sign, a Crypt::DSA::Signature object.
127
128           This argument is required.
129
130       * Digest
131           The original signed digest whose length is less than or equal to 20
132           bytes.
133
134           Either this argument or Message (see below) must be present.
135
136       * Message
137           As above in sign, the plaintext message that was signed, a string
138           of arbitrary length. A SHA1 digest of this message will be created
139           and used in the verification process.
140

AUTHOR

142       Benjamin Trott, ben@sixapart.com
143
145       Except where otherwise noted, Crypt::DSA is Copyright 2006 Benjamin
146       Trott. All rights reserved. Crypt::DSA is free software; you may redis‐
147       tribute it and/or modify it under the same terms as Perl itself.
148
149
150
151perl v5.8.8                       2004-12-31                     Crypt::DSA(3)
Impressum