Crypt::DSA::Key(3)
π Crypt::DSA::Key β the DSA key glow-up π
okay bestie, this is a page from the User Contributed Perl Documentation, and it's all about Crypt::DSA::Key, which is literally just... a DSA key. no cap. let's get into it π«Ά
β¨ NAME β¨
Crypt::DSA::Key β a DSA key, fr fr π
πΈ SYNOPSIS πΈ
use Crypt::DSA::Key;
my $key = Crypt::DSA::Key->new;
$key->p($p);
like. that's it. that's the whole vibe check. π
π¦ DESCRIPTION π¦
So Crypt::DSA::Key holds a DSA key β and not just part of it, bestie, it's got the public portion and the private portion. both. the whole thing. π
Subclasses of Crypt::DSA::Key are the ones that bring the read and write methods to the party, so you can save your DSA keys to disk and then read them back into your application later. it's giving persistence. it's giving main character energy. πΎβ¨
π USAGE π
Every single key attribute is reachable through a combo get/set method β like, you call the method with an argument to set it, and you call it with nothing to get it back. iconic behaviour honestly.
The key attributes are: p, q, g, priv_key, and pub_key.
For example:
$key->p($p);
my $p2 = $key->p;
see how that works?? first line sets p, second line gets it back. obsessed. π
π $key = Crypt::DSA::Key->new(%arg) π
Makes you a brand new (empty) key object. every single attribute starts out at 0. an empty little baby key. π₯Ί
OR β plot twist β if you hand over the Filename parameter (peep below for the deets), the key gets read in from disk instead. And if you pass the Type parameter (mandatory if you're giving a Filename, okay, don't forget it), heads up: your key doesn't stay a plain Crypt::DSA::Key, it actually gets blessed into a subclass of Crypt::DSA::Key. specifically, it becomes whatever class implements the read functionality for that type, e.g. Crypt::DSA::Key::PEM.
Returns the key when it works, "undef" when it doesn't. (and yes, Password is one whole reason why new might come back with "undef" β see below.)
%arg can contain:
Typeβ the type of file where the key is stored. rn the only option isPEM, which means a PEM file (optionally encrypted, ASN.1-encoded object). the read/write support for PEM files comes fromConvert::PEM, so if you don't have that module installed, thenewmethod will literally die. π
This argument is mandatory if you're either reading the file from disk (i.e. you provided a Filename argument) or you've specified the Content argument.
Filenameβ where the file lives that you wanna read the key from. needs aTypeargument so the decoder knows what kind of file it's looking at. and you can't specifyContentandFilenameat the same time. pick a lane bestie πContentβ the serialized version of the key. also needs aTypeargument so the decoder knows how to decode it. and again: you can't specifyContentandFilenameat the same time. same rule, no exceptions.Passwordβ if your key file is encrypted, you'll need to supply a passphrase to decrypt it, and this is where you do that. π
and if your passphrase is wrong? new will return "undef". that's the one we warned you about earlier. π
π« $key->write(%arg) π«
Writes a key (optionally) to disk, using whatever format you define with the Type parameter.
Here's the tea: if your $key object has a defined priv_key (that's the private key portion), the key gets written as a DSA private key object. otherwise it gets written out as a public key. and ngl, not every serialization mechanism can produce public keys in this version β currently, only PEM public keys are supported. so like. keep that in mind. π₯
%arg can include:
Typeβ the type of file format you wanna write.PEMis one example (and honestly, currently, it's the only example).
This argument is mandatory β unless your $key object is already blessed into a subclass (e.g. Crypt::DSA::Key::PEM) and you want to write the file using that same subclass. then you're already set. slay. β¨
Filenameβ the location on disk where you want the key file to be written.Passwordβ if you want the key file to be encrypted, pass this argument, and the ASN.1-encoded string will be encrypted using the passphrase as a key. π
π $key->size π
Returns the size of the key, in bits.
technically it's the number of bits in the large prime p. so like, that's the number you're actually getting. iykyk. π§
π AUTHOR & COPYRIGHTS π
Please see the Crypt::DSA manpage for author, copyright, and license information. (yeah, they outsourced that part to the parent page β go peek over there, bestie π«Ά)
and that's the whole page!! mwah π this doc shipped with perl v5.42.2, dated 2026-07-03 β so go forth and handle your DSA keys responsibly, no cap. ππ
π¦ 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