Net::DNS::RR::NSEC3PARAM - DNS NSEC3PARAM resource record


Net-DNS-SEC documentation Contained in the Net-DNS-SEC distribution.

Index


Code Index:

NAME

Top

Net::DNS::RR::NSEC3PARAM - DNS NSEC3PARAM resource record

SYNOPSIS

Top

use Net::DNS::RR;

DESCRIPTION

Top

Class for DNS Address (NSEC3PARAM) resource records.

The NSEC3PARAM RR contains the NSEC3 parameters (hash algorithm, flags, iterations and salt) needed to calculate hashed ownernames. The presence of an NSEC3PARAM RR at a zone apex indicates that the specified parameters may be used by authoritative servers to choose an appropriate set of NSEC3 records for negative responses.

METHODS

Top

hashalgo

Reads and sets the hashalgo (hash algorithm) attribute.

flags

Reads and sets the flag field. Check the IANA registry for valid values. At the time of code release the only defined value was 0x00

iterations

Reads and sets the iterations field

salt

Reads and sets the salt value. Accepts and returns a string with a number in hexadecimal notation.

COPYRIGHT

Top

SEE ALSO

Top

http://www.net-dns.org/ http://tools.ietf.org/wg/dnsext/draft-ietf-dnsext-nsec3 Net::DNS::RR::NSEC3,

perl(1), Net::DNS, Net::DNS::Resolver, Net::DNS::Packet, Net::DNS::Header, Net::DNS::Question, Net::DNS::RR, RFC4033, RFC4034, RFC4035, RFC 5155


Net-DNS-SEC documentation Contained in the Net-DNS-SEC distribution.

package Net::DNS::RR::NSEC3PARAM;

# $Id: NSEC3.pm 602 2006-07-24 14:23:15Z olaf $

use strict;
use vars qw(@ISA $VERSION);
use Carp;
use bytes;

use Net::DNS;
use Net::DNS::SEC;
use Net::DNS::Packet;
use Net::DNS::RR::NSEC;
use Data::Dumper;

use Carp qw(cluck);


# To be removed when finalized


@ISA     = qw(Net::DNS::RR Net::DNS::RR::NSEC3);



$VERSION = do { my @r=(q$Revision: 510 $=~/\d+/g); sprintf "%d."."%03d"x$#r,@r };

sub new {
    my ($class, $self, $data, $offset) = @_;


    if ($self->{"rdlength"} > 0) {


	#                        1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 3 3
	#    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
	#   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	#   | Hash Alg.     |  Flags Field  |         Iterations            |
	#   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	#   |  Salt Length  |                     Salt                      /
	#   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
	#
	#   Hash Algorithm is a single octet.
	#
	#   Flags Field is a single octet.
	#
	#   Iterations is represented as a 16-bit integer, with the most
	#   significant bit first.
	#
	#   Salt Length represents the length of the following Salt field in
	#   octets.  If the value is zero, the Salt field is omitted.


      my $offsettoflag=$offset+1;
      my $offsettoits=$offset+2;
      my $offesttosaltlength=$offset+4;
      my $offsettosalt=$offset+5;

      $self->{"hashalgo"}=unpack("C",substr($$data,$offset,1));
      $self->{"flags"}=unpack("C",substr($$data,$offsettoflag,1));
      $self->{"iterations"}= unpack("n",substr($$data,$offsettoits,2));
      $self->{"saltlength"}=unpack("C",substr($$data,$offesttosaltlength,1));


      $self->{"saltbin"}=substr($$data,$offsettosalt,$self->{"saltlength"});
      $self->{"salt"}= unpack("H*",$self->{"saltbin"});

    }


    
    bless $self, $class;
    return $self;
}




sub new_from_string {
    my ($class, $self, $string) = @_;
    bless $self, $class;

    if ($string) {
      $string =~ tr/()//d;
      $string =~ s/;.*$//mg;
      $string =~ s/\n//mg;

      my ($hashalgo,$flags,$iterations,$salt)= 
	$string =~ /^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S*)\s*$/;


      # This assumes that the digest type allocations follow the assignments as used for DS...
      defined($self->{'hashalgo'}=Net::DNS::SEC->digtype($hashalgo)) || 
		    return undef;
      defined($self->{'iterations'}=$iterations) || return undef;

      defined($self->{'flags'}=$flags) || return undef;
      
      defined($self->{"salt"}=$self->salt($salt)) || return undef;
      $self->{"saltbin"}=pack("H*",$salt) || return undef;
      $self->{saltlength}=length $self->{saltbin}; 

      
    }
    return $self;
}


sub rdatastr 
{
   my $self = shift;
   my $rdatastr;
   if (exists $self->{hashalgo}) 
   {
      $rdatastr .= $self->{hashalgo} ." ";
      $rdatastr .= $self->{flags}." ";
      $rdatastr .= $self->{iterations}. " ";
      $rdatastr .=   $self->salt()." \n";

   }
   else 
   {
      $rdatastr = "; no data"
   }
   $rdatastr
}

sub rr_rdata {
    my ($self, $packet, $offset) = @_;



    my $rdata = "" ;

    if (exists $self->{'hashalgo'}) {

      $rdata = pack("C",$self->{'hashalgo'});
      $rdata .= pack("C",$self->{'flags'});
      $rdata .= pack("n",$self->{'iterations'});
      unless( exists  $self->{"saltbin"}) {      
	if ($self->{"salt"} eq "-"){
	  $self->{"saltbin"}="";
	}else{
	  $self->{"saltbin"}=pack("H*",$self->{"salt"}) 

	}
      }
      $rdata .= pack("C",length($self->{'saltbin'}));
      $rdata .= $self->{'saltbin'};

    }
    
    return $rdata;
}





1;