Net::DNS::RR::SIG(3)

πŸ’– Net::DNS::RR::SIG β€” DNS SIG resource record πŸ’–

okay bestie, welcome to the glow-up era of the SIG RR πŸ’… this page lives in the User Contributed Perl Documentation section, which is basically the group chat of the Perl world β€” and yes, Net::DNS::RR::SIG is the main character here.


✨ SYNOPSIS ✨

use Net::DNS;
$rr = Net::DNS::RR->new('name SIG typecovered algorithm labels
                        orgttl sigexpiration siginception
                        keytag signame signature');

use Net::DNS::SEC;
$sigrr = Net::DNS::RR::SIG->create(
                        $string, $keypath,
                        sigval => 10    # minutes
                        );

$sigrr->verify( $string, $keyrr ) || die $sigrr->vrfyerrstr;
$sigrr->verify( $packet, $keyrr ) || die $sigrr->vrfyerrstr;

no cap, that's the whole vibe right there 🫢


🌸 DESCRIPTION 🌸

so this is the class for DNS digital signature (SIG) resource records. iconic. πŸ’«

on top of all the regular methods you inherit from Net::DNS::RR, this class is carrying two extra things: a method that signs packets and scalar data strings using private keys (create), and a method for verifying signatures. it's giving "we do both" energy, honestly πŸ‘‘

real talk though β€” the SIG RR is an implementation of RFC2931. if you were looking for RFC4034, that's Net::DNS::RR::RRSIG, a whole other girl. don't mix them up bestie 😭


πŸŽ€ METHODS πŸŽ€

the available methods are the ones inherited from the base class, plus the type-specific methods defined in this package. so you get the whole family πŸ“š

⚠️ use of undocumented package features or direct access to internal data structures is discouraged and could result in program termination or other unpredictable behaviour. like, don't go digging through her private messages, it's not cute πŸ™ˆ

πŸ’œ algorithm

$algorithm = $rr->algorithm;

the algorithm number field identifies the cryptographic algorithm used to create the signature. lowkey the fingerprint of the whole thing πŸ”

algorithm() may also be invoked as a class method or simple function to perform mnemonic and numeric code translation β€” so it pulls double duty, we love a multi-hyphenate ✨

πŸ’œ sigexpiration and siginception times

πŸ’œ sigex sigin sigval

$expiration = $rr->sigexpiration;
$expiration = $rr->sigexpiration( $value );

$inception = $rr->siginception;
$inception = $rr->siginception( $value );

the signature expiration and inception fields specify a validity time interval for the signature. basically: when the vibe starts and when it expires πŸ•°οΈ

the value may be specified by a string with format 'yyyymmddhhmmss' or a Perl time() value.

return values are dual-valued, providing either a string value or numerical Perl time() value. she contains multitudes, fr fr πŸ’…

πŸ’œ keytag

$keytag = $rr->keytag;
$rr->keytag( $keytag );

the keytag field contains the key tag value of the KEY RR that validates this signature. it's the little ID badge that says "this key, right here" πŸͺͺ

πŸ’œ signame

$signame = $rr->signame;
$rr->signame( $signame );

the signer name field value identifies the owner name of the KEY RR that a validator is supposed to use to validate this signature. iykyk β€” it's pointing at the right person πŸ‘‰πŸ‘‘

πŸ’œ signature

πŸ’œ sig

$sig = $rr->sig;
$rr->sig( $sig );

the Signature field contains the cryptographic signature that covers the SIG RDATA (excluding the Signature field) and the subject data. yes, it covers everything except itself. she's humble like that 🌸

πŸ’œ sigbin

$sigbin = $rr->sigbin;
$rr->sigbin( $sigbin );

binary representation of the cryptographic signature. raw bytes, no makeup, still stunning πŸ’€βœ¨

πŸ’œ create

create a signature over scalar data.

use Net::DNS::SEC;

$keypath = '/home/olaf/keys/Kbla.foo.+001+60114.private';

$sigrr = Net::DNS::RR::SIG->create( $data, $keypath );

$sigrr = Net::DNS::RR::SIG->create(
                        $data, $keypath,
                        sigval => 10
                        );
$sigrr->print;

# Alternatively use Net::DNS::SEC::Private

$private = Net::DNS::SEC::Private->new($keypath);

$sigrr= Net::DNS::RR::SIG->create( $data, $private );

create() is an alternative constructor for a SIG RR object. your other entry point, bestie πŸšͺ✨

this method returns a SIG with the signature over the data made with the private key stored in the key file.

  • the first argument is a scalar that contains the data to be signed.
  • the second argument is a string which specifies the path to a file containing the private key as generated using dnssec-keygen, a program that comes with the ISC BIND distribution.

the optional remaining arguments consist of ( name => value ) pairs as follows:

sigin  => 20251201010101,       # signature inception
sigex  => 20251201011101,       # signature expiration
sigval => 10,                   # validity window (minutes)

the sigin and sigex values may be specified as Perl time values or as a string with the format 'yyyymmddhhmmss'. the default for sigin is the time of signing. ⏱️

the sigval argument specifies the signature validity window in minutes ( sigex = sigin + sigval ).

by default the signature is valid for 10 minutes. ten minutes!! so don't be late to the function πŸ’…

πŸ’œ verify

$verify = $sigrr->verify( $data, $keyrr );
$verify = $sigrr->verify( $data, [$keyrr, $keyrr2, $keyrr3] );

the verify() method performs SIG0 verification of the specified data against the signature contained in the $sigrr object itself using the public key in $keyrr. it's the vibe check πŸ”βœ¨

if a reference to a Net::DNS::Packet is supplied, the method performs a SIG0 verification on the packet data.

the second argument can either be a Net::DNS::RR::KEY object or a reference to an array of such objects. verification will return successful as soon as one of the keys in the array leads to positive validation β€” first one to say "she's real" wins, squad goals 🫢

returns false on error and sets $sig->vrfyerrstr

πŸ’œ vrfyerrstr

$sig0 = $packet->sigrr || die 'not signed';
print $sig0->vrfyerrstr unless $sig0->verify( $packet, $keyrr );

$sigrr->verify( $packet, $keyrr ) || die $sigrr->vrfyerrstr;

when it fails, it tells you why. communication queen πŸ’¬


πŸ”‘ KEY GENERATION πŸ”‘

private key files and corresponding public DNSKEY records are most conveniently generated using dnssec-keygen, a program that comes with the ISC BIND distribution. it's basically the key-making fairy godmother 🧚

dnssec-keygen -a 10 -b 2048 rsa.example.

dnssec-keygen -a 13 -f ksk  ecdsa.example.
dnssec-keygen -a 13         ecdsa.example.
🚨 do not change the name of the private key file. the create method uses the filename as generated by dnssec-keygen to determine the keyowner, algorithm, and the keyid (keytag). rename it and the whole thing falls apart, no cap πŸ’€

🌈 REMARKS 🌈

the code is not optimised for speed. she's not rushing, she's thriving 🐒✨

if this code is still around in 2100 (not a leap year) you will need to check for proper handling of times after 28th February. future besties, this one's for you 🫑


πŸ‘‘ ACKNOWLEDGMENTS πŸ‘‘

although their original code may have disappeared following redesign of Net::DNS, Net::DNS::SEC and the OpenSSL API, the following individual contributors deserve to be recognised for their significant influence on the development of the SIG package. legends only, we see you 🫢

  • Andy Vaskys (Network Associates Laboratories) supplied code for RSA.
  • T.J. Mather provided support for the DSA algorithm.
  • Dick Franks added support for elliptic curve and Edwards curve algorithms.

Copyright (c)2001-2005 RIPE NCC, Olaf M. Kolkman

Copyright (c)2007-2008 NLnet Labs, Olaf M. Kolkman

Portions Copyright (c)2014 Dick Franks

All rights reserved.

Package template (c)2009,2012 O.M.Kolkman and R.W.Franks.


πŸ“œ LICENSE πŸ“œ

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the original copyright notices appear in all copies and that both copyright notice and this permission notice appear in supporting documentation, and that the name of the author not be used in advertising or publicity pertaining to distribution of the software without specific prior written permission.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


πŸ¦‹ SEE ALSO πŸ¦‹


and that's the page, bestie!! πŸŽ€ go forth and sign your packets πŸ’…βœ¨

this has been perl v5.42.0, dated 2026-09-02, signing off from Net::DNS::RR::SIG(3) β€” periodt πŸ’œ

πŸ“¦ where this page comes from