Crypt::DSA(3)
๐ Crypt::DSA โ DSA Signatures and Key Generation ๐
okay bestie, sit down, grab a boba, because we're talking about Crypt::DSA โ the Perl module that does the DSA (Digital Signature Algorithm) thing. it's giving "your crypto bestie from 2006 who still texts you" and i'm obsessed. this page lives in the User Contributed Perl Documentation section, section 3 (aka library calls, iykyk).
โจ SYNOPSIS โจ
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,
);
look at that. four lines of setup and you're signing and verifying like a whole main character. no cap. ๐
๐ธ DESCRIPTION ๐ธ
so Crypt::DSA is a whole implementation of the DSA (Digital Signature Algorithm) signature verification system. the implementation itself? pure Perl, bestie. hand-rolled. artisanal. but the heavy-duty mathematics underneath come from the Math::Pari library, because some math is just built different. ๐งฎโจ
this package gives you three things and it eats every time:
- DSA signing โ๏ธ
- signature verification โ
- key generation ๐
๐จ SECURITY ๐จ
okay this is the part where i need you to lock in, because it's serious and i'm not being dramatic (well, a little dramatic, but the facts are the facts).
DSA (Digital Signature Algorithm) signatures are no longer considered to be adequate for security.
so like, this module should only be used for verifying old signatures, and it should not be used for new signatures. periodt. ๐
that being said โ and this is the wild part โ some technologies still require DSA signatures even in 2024. so consider using other solutions, or explicitly not using DSA signatures. the vibes are complicated but the warning is clear. ๐
๐ฆ USAGE ๐ฆ
the Crypt::DSA public interface is similar to that of Crypt::RSA. and no, that's not a coincidence, it was done intentionally. consistency slay. ๐
๐ Crypt::DSA->new
constructs a new Crypt::DSA object. ngl, at the moment this isn't particularly useful in itself โ it's just the object you need to do literally everything else in the system. it's the friend who drives everyone to the party. ๐
returns the new object.
๐ $key = $dsa->keygen(%arg)
generates a whole new set of DSA keys, including both the public and private portions. both! the full set! ๐
%arg can contain:
Sizeโ the size in bits of thepvalue to generate. theqandgvalues are always160bits each, no matter what. this argument is mandatory, bestie, you cannot skip it.Seedโ a seed with whichqgeneration will begin. if this seed doesn't lead to a suitable prime, it gets discarded and a brand new random seed is chosen in its place, over and over, until a suitable prime can be found. it's giving persistence. this is entirely optional, and if you don't provide one, a random seed gets generated automatically for you. ๐Verbosityโ should be either0or1. a value of1gives you a progress meter duringpandqgeneration โ which is genuinely useful, because the process can be relatively long. the default is0.
๐ $signature = $dsa->sign(%arg)
signs a message (or the digest of a message) using the private portion of the DSA key, and returns the signature. โ๏ธโจ
the return value โ the signature โ is a Crypt::DSA::Signature object.
%arg can include:
Digestโ a digest to be signed. the digest should be20bytes in length or less. you must provide either this argument orMessage(see below). pick one, bestie.Keyโ the Crypt::DSA::Key object with which the signature will be generated. it should contain a private key attribute (priv_key). this argument is required.Messageโ a plaintext message to be signed. if you provide this argument,signwill first produce a SHA1 digest of the plaintext, then use that as the digest to sign. so writing
my $sign = $dsa->sign(Message => $message, ... );
is a shorter way of writing
use Digest::SHA qw( sha1 );
my $sig = $dsa->sign(Digest => sha1( $message ), ... );
same energy, less typing. we love a shortcut. ๐
๐ $verified = $dsa->verify(%arg)
verifies a signature generated with sign. returns a true value on success and false on failure. the moment of truth. ๐ซถ
%arg can contain:
Keyโ key of the signer of the message; a Crypt::DSA::Key object. the public portion of the key is used to verify the signature. this argument is required.Signatureโ the signature itself. should be in the same format as returned fromsign, a Crypt::DSA::Signature object. this argument is required.Digestโ the original signed digest whose length is less than or equal to20bytes. either this argument orMessage(see below) must be present.Messageโ as above insign, the plaintext message that was signed, a string of arbitrary length. a SHA1 digest of this message will be created and used in the verification process.
๐ TODO ๐
add ability to munge format of keys. for example, read/write keys from/to key files (SSH key files, etc.), and also write them in other formats. it's on the vision board. ๐
๐ SUPPORT ๐
bugs should be reported via the CPAN bug tracker at
<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Crypt-DSA>
for other issues, contact the author. they're lovely, i promise. ๐ซถ
๐ AUTHOR ๐
Benjamin Trott <ben@sixapart.com>
๐ COPYRIGHT ๐
except where otherwise noted, Crypt::DSA is Copyright 2006 - 2011 Benjamin Trott.
Crypt::DSA is free software; you may redistribute it and/or modify it under the same terms as Perl itself. ๐ฉท
and that's the whole page, bestie!! ๐โจ this documentation ships with perl v5.42.2 and was dated 2026-07-03 โ so if you're reading it from the future, hey, you look amazing, go verify those old signatures responsibly and never generate new DSA ones. mwah. ๐๐ฆ๐
๐ฆ where this page comes from
- fedora 43: perl-Crypt-DSA 1.22-1.fc43 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- fedora 44: perl-Crypt-DSA 1.22-1.fc44 ยท GPL-1.0-or-later OR Artistic-1.0-Perl
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms