Class: Dnsruby::RR::NSEC3PARAM

Inherits:
Dnsruby::RR show all
Defined in:
lib/Dnsruby/resource/NSEC3PARAM.rb

Overview

The NSEC3PARAM RR contains the NSEC3 parameters (hash algorithm, flags, iterations and salt) needed by authoritative servers to calculate hashed owner names. 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 RRs for negative responses. The NSEC3PARAM RR is not used by validators or resolvers.

Constant Summary collapse

ClassValue =

:nodoc: all

nil
TypeValue =

:nodoc: all

Types::NSEC3PARAM

Constants inherited from Dnsruby::RR

ClassInsensitiveTypes

Instance Attribute Summary collapse

Attributes inherited from Dnsruby::RR

#klass, #name, #rdata, #ttl, #type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Dnsruby::RR

#==, create, #eql?, #from_hash, get_class, get_num, #hash, implemented_rrs, #init_defaults, new_from_data, new_from_hash, new_from_string, #rdlength, #sameRRset, #to_s

Instance Attribute Details

#flagsObject

The Flags field contains 8 one-bit flags that can be used to indicate different processing. All undefined flags must be zero. The only flag defined by the NSEC3 specification is the Opt-Out flag.



35
36
37
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 35

def flags
  @flags
end

#hash_algObject

The Hash Algorithm field identifies the cryptographic hash algorithm used to construct the hash-value.



31
32
33
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 31

def hash_alg
  @hash_alg
end

#iterationsObject

The Iterations field defines the number of additional times the hash function has been performed.



38
39
40
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 38

def iterations
  @iterations
end

#saltObject

The Salt field is appended to the original owner name before hashing in order to defend against pre-calculated dictionary attacks.



44
45
46
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 44

def salt
  @salt
end

#salt_lengthObject

The Salt Length field defines the length of the Salt field in octets, ranging in value from 0 to 255.



41
42
43
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 41

def salt_length
  @salt_length
end

Class Method Details

.decode_rdata(msg) ⇒ Object

:nodoc: all



112
113
114
115
116
117
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 112

def self.decode_rdata(msg) #:nodoc: all
  hash_alg, flags, iterations, salt_length = msg.get_unpack("ccnc")
  salt = msg.get_bytes(salt_length)
  return self.new(
    [hash_alg, flags, iterations, salt_length, salt])
end

Instance Method Details

#encode_rdata(msg, canonical = false) ⇒ Object

:nodoc: all



107
108
109
110
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 107

def encode_rdata(msg, canonical=false) #:nodoc: all
  msg.put_pack("ccnc", @hash_alg.code, @flags, @iterations, @salt_length)
  msg.put_bytes(@salt)
end

#from_data(data) ⇒ Object

:nodoc: all



79
80
81
82
83
84
85
86
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 79

def from_data(data) #:nodoc: all
  hash_alg, flags, iterations, salt_length, salt = data
  self.hash_alg=(hash_alg)
  self.flags=(flags)
  self.iterations=(iterations)
  self.salt_length=(salt_length)
  self.salt=(salt)
end

#from_string(input) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 88

def from_string(input)
  if (input.length > 0)
    data = input.split(" ")
    self.hash_alg=(data[0]).to_i
    self.flags=(data[1]).to_i
    self.iterations=(data[2]).to_i
    self.salt=(data[3])
    self.salt_length=(data[3].length)
  end
end

#rdata_to_stringObject

:nodoc: all



99
100
101
102
103
104
105
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 99

def rdata_to_string #:nodoc: all
  if (@next_hashed!=nil)
    return "#{@hash_alg.code} #{@flags} #{@iterations} #{@salt}"
  else
    return ""
  end
end

#types=(t) ⇒ Object



60
61
62
# File 'lib/Dnsruby/resource/NSEC3PARAM.rb', line 60

def types=(t)
  @types = NSEC.get_types(t)
end