{
    "mode": "perldoc",
    "parameter": "Crypt::DSA",
    "section": "",
    "url": "https://www.chedong.com/phpMan.php/perldoc/Crypt%3A%3ADSA/json",
    "generated": "2026-06-12T09:50:15Z",
    "synopsis": "use Crypt::DSA;\nmy $dsa = Crypt::DSA->new;\nmy $key = $dsa->keygen(\nSize      => 512,\nSeed      => $seed,\nVerbosity => 1\n);\nmy $sig = $dsa->sign(\nMessage   => \"foo bar\",\nKey       => $key\n);\nmy $verified = $dsa->verify(\nMessage   => \"foo bar\",\nSignature => $sig,\nKey       => $key,\n);",
    "sections": {
        "NAME": {
            "content": "Crypt::DSA - DSA Signatures and Key Generation\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "use Crypt::DSA;\nmy $dsa = Crypt::DSA->new;\n\nmy $key = $dsa->keygen(\nSize      => 512,\nSeed      => $seed,\nVerbosity => 1\n);\n\nmy $sig = $dsa->sign(\nMessage   => \"foo bar\",\nKey       => $key\n);\n\nmy $verified = $dsa->verify(\nMessage   => \"foo bar\",\nSignature => $sig,\nKey       => $key,\n);\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "*Crypt::DSA* is an implementation of the DSA (Digital Signature Algorithm) signature\nverification system. The implementation itself is pure Perl, although the heavy-duty mathematics\nunderneath are provided by the *Math::Pari* library.\n\nThis package provides DSA signing, signature verification, and key generation.\n",
            "subsections": []
        },
        "USAGE": {
            "content": "The *Crypt::DSA* public interface is similar to that of *Crypt::RSA*. This was done\nintentionally.\n\nCrypt::DSA->new\nConstructs a new *Crypt::DSA* object. At the moment this isn't particularly useful in itself,\nother than being the object you need to do much else in the system.\n\nReturns the new object.\n\n$key = $dsa->keygen(%arg)\nGenerates a new set of DSA keys, including both the public and private portions of the key.\n\n*%arg* can contain:\n\n*   Size\n\nThe size in bits of the *p* value to generate. The *q* and *g* values are always 160 bits\neach.\n\nThis argument is mandatory.\n\n*   Seed\n\nA seed with which *q* generation will begin. If this seed does not lead to a suitable prime,\nit will be discarded, and a new random seed chosen in its place, until a suitable prime can\nbe found.\n\nThis is entirely optional, and if not provided a random seed will be generated\nautomatically.\n\n*   Verbosity\n\nShould be either 0 or 1. A value of 1 will give you a progress meter during *p* and *q*\ngeneration--this can be useful, since the process can be relatively long.\n\nThe default is 0.\n\n$signature = $dsa->sign(%arg)\nSigns a message (or the digest of a message) using the private portion of the DSA key and\nreturns the signature.\n\nThe return value--the signature--is a *Crypt::DSA::Signature* object.\n\n*%arg* can include:\n\n*   Digest\n\nA digest to be signed. The digest should be 20 bytes in length or less.\n\nYou must provide either this argument or *Message* (see below).\n\n*   Key\n\nThe *Crypt::DSA::Key* object with which the signature will be generated. Should contain a\nprivate key attribute (*privkey*).\n\nThis argument is required.\n\n*   Message\n\nA plaintext message to be signed. If you provide this argument, *sign* will first produce a\nSHA1 digest of the plaintext, then use that as the digest to sign. Thus writing\n\nmy $sign = $dsa->sign(Message => $message, ... );\n\nis a shorter way of writing\n\nuse Digest::SHA qw( sha1 );\nmy $sig = $dsa->sign(Digest => sha1( $message ), ... );\n\n$verified = $dsa->verify(%arg)\nVerifies a signature generated with *sign*. Returns a true value on success and false on\nfailure.\n\n*%arg* can contain:\n\n*   Key\n\nKey of the signer of the message; a *Crypt::DSA::Key* object. The public portion of the key\nis used to verify the signature.\n\nThis argument is required.\n\n*   Signature\n\nThe signature itself. Should be in the same format as returned from *sign*, a\n*Crypt::DSA::Signature* object.\n\nThis argument is required.\n\n*   Digest\n\nThe original signed digest whose length is less than or equal to 20 bytes.\n\nEither this argument or *Message* (see below) must be present.\n\n*   Message\n\nAs above in *sign*, the plaintext message that was signed, a string of arbitrary length. A\nSHA1 digest of this message will be created and used in the verification process.\n",
            "subsections": []
        },
        "TODO": {
            "content": "Add ability to munge format of keys. For example, read/write keys from/to key files (SSH key\nfiles, etc.), and also write them in other formats.\n",
            "subsections": []
        },
        "SUPPORT": {
            "content": "Bugs should be reported via the CPAN bug tracker at\n\n<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA>\n\nFor other issues, contact the author.\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "Benjamin Trott <ben@sixapart.com>\n",
            "subsections": []
        },
        "COPYRIGHT": {
            "content": "Except where otherwise noted, Crypt::DSA is Copyright 2006 - 2011 Benjamin Trott.\n\nCrypt::DSA is free software; you may redistribute it and/or modify it under the same terms as\nPerl itself.\n",
            "subsections": []
        }
    },
    "summary": "Crypt::DSA - DSA Signatures and Key Generation",
    "flags": [],
    "examples": [],
    "see_also": []
}