.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Crypt::DSA 3pm" .TH Crypt::DSA 3pm "2022-06-12" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Crypt::DSA \- DSA Signatures and Key Generation .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Crypt::DSA; \& my $dsa = Crypt::DSA\->new; \& \& my $key = $dsa\->keygen( \& Size => 512, \& Seed => $seed, \& Verbosity => 1 \& ); \& \& my $sig = $dsa\->sign( \& Message => "foo bar", \& Key => $key \& ); \& \& my $verified = $dsa\->verify( \& Message => "foo bar", \& Signature => $sig, \& Key => $key, \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\fICrypt::DSA\fR is an implementation of the \s-1DSA\s0 (Digital Signature Algorithm) signature verification system. The implementation itself is pure Perl, although the heavy-duty mathematics underneath are provided by the \fIMath::Pari\fR library. .PP This package provides \s-1DSA\s0 signing, signature verification, and key generation. .SH "USAGE" .IX Header "USAGE" The \fICrypt::DSA\fR public interface is similar to that of \&\fICrypt::RSA\fR. This was done intentionally. .SS "Crypt::DSA\->new" .IX Subsection "Crypt::DSA->new" Constructs a new \fICrypt::DSA\fR object. At the moment this isn't particularly useful in itself, other than being the object you need to do much else in the system. .PP Returns the new object. .ie n .SS "$key = $dsa\->keygen(%arg)" .el .SS "\f(CW$key\fP = \f(CW$dsa\fP\->keygen(%arg)" .IX Subsection "$key = $dsa->keygen(%arg)" Generates a new set of \s-1DSA\s0 keys, including both the public and private portions of the key. .PP \&\fI\f(CI%arg\fI\fR can contain: .IP "\(bu" 4 Size .Sp The size in bits of the \fIp\fR value to generate. The \fIq\fR and \&\fIg\fR values are always 160 bits each. .Sp This argument is mandatory. .IP "\(bu" 4 Seed .Sp A seed with which \fIq\fR generation will begin. If this seed does not lead to a suitable prime, it will be discarded, and a new random seed chosen in its place, until a suitable prime can be found. .Sp This is entirely optional, and if not provided a random seed will be generated automatically. .IP "\(bu" 4 Verbosity .Sp Should be either 0 or 1. A value of 1 will give you a progress meter during \fIp\fR and \fIq\fR generation\*(--this can be useful, since the process can be relatively long. .Sp The default is 0. .ie n .SS "$signature = $dsa\->sign(%arg)" .el .SS "\f(CW$signature\fP = \f(CW$dsa\fP\->sign(%arg)" .IX Subsection "$signature = $dsa->sign(%arg)" Signs a message (or the digest of a message) using the private portion of the \s-1DSA\s0 key and returns the signature. .PP The return value\*(--the signature\*(--is a \fICrypt::DSA::Signature\fR object. .PP \&\fI\f(CI%arg\fI\fR can include: .IP "\(bu" 4 Digest .Sp A digest to be signed. The digest should be 20 bytes in length or less. .Sp You must provide either this argument or \fIMessage\fR (see below). .IP "\(bu" 4 Key .Sp The \fICrypt::DSA::Key\fR object with which the signature will be generated. Should contain a private key attribute (\fIpriv_key\fR). .Sp This argument is required. .IP "\(bu" 4 Message .Sp A plaintext message to be signed. If you provide this argument, \&\fIsign\fR will first produce a \s-1SHA1\s0 digest of the plaintext, then use that as the digest to sign. Thus writing .Sp .Vb 1 \& my $sign = $dsa\->sign(Message => $message, ... ); .Ve .Sp is a shorter way of writing .Sp .Vb 2 \& use Digest::SHA qw( sha1 ); \& my $sig = $dsa\->sign(Digest => sha1( $message ), ... ); .Ve .ie n .SS "$verified = $dsa\->verify(%arg)" .el .SS "\f(CW$verified\fP = \f(CW$dsa\fP\->verify(%arg)" .IX Subsection "$verified = $dsa->verify(%arg)" Verifies a signature generated with \fIsign\fR. Returns a true value on success and false on failure. .PP \&\fI\f(CI%arg\fI\fR can contain: .IP "\(bu" 4 Key .Sp Key of the signer of the message; a \fICrypt::DSA::Key\fR object. The public portion of the key is used to verify the signature. .Sp This argument is required. .IP "\(bu" 4 Signature .Sp The signature itself. Should be in the same format as returned from \fIsign\fR, a \fICrypt::DSA::Signature\fR object. .Sp This argument is required. .IP "\(bu" 4 Digest .Sp The original signed digest whose length is less than or equal to 20 bytes. .Sp Either this argument or \fIMessage\fR (see below) must be present. .IP "\(bu" 4 Message .Sp As above in \fIsign\fR, the plaintext message that was signed, a string of arbitrary length. A \s-1SHA1\s0 digest of this message will be created and used in the verification process. .SH "TODO" .IX Header "TODO" Add ability to munge format of keys. For example, read/write keys from/to key files (\s-1SSH\s0 key files, etc.), and also write them in other formats. .SH "SUPPORT" .IX Header "SUPPORT" Bugs should be reported via the \s-1CPAN\s0 bug tracker at .PP .PP For other issues, contact the author. .SH "AUTHOR" .IX Header "AUTHOR" Benjamin Trott .SH "COPYRIGHT" .IX Header "COPYRIGHT" Except where otherwise noted, Crypt::DSA is Copyright 2006 \- 2011 Benjamin Trott. .PP Crypt::DSA is free software; you may redistribute it and/or modify it under the same terms as Perl itself.