class Dnsruby::RR::HIP
Attributes
hit_length[RW]
An 8-bit length for the HIT field
pk_algorithm[RW]
The PK algorithm used :
0 - no key present 1 - DSA key present 2 - RSA key present
pk_length[RW]
An 8-bit length for the Public Key field
rsvs[RW]
An array of Rendezvous Servers
Public Instance Methods
from_hash(hash)
click to toggle source
# File lib/dnsruby/resource/HIP.rb, line 47 def from_hash(hash) @rsvs=[] @hit_length = hash[:hit_length] @pk_algorithm = hash[:pk_algorithm] @pk_length = hash[:pk_length] @hit = hash[:hit] @public_key = hash[:public_key] if (hash[:rsvs]) hash[:rsvs].each {|rsv| @rsvs.push(Name.create(rsv)) } end end
from_string(input)
click to toggle source
# File lib/dnsruby/resource/HIP.rb, line 84 def from_string(input) @rsvs=[] if (input.length > 0) split = input.split(" ") @pk_algorithm = split[0].to_i @hit = hit_from_string(split[1]) @hit_length = @hit.length @public_key = public_key_from_string(split[2]) @pk_length = @public_key.length # Now load in any RSVs there may be count = 3 while (split[count]) @rsvs.push(Name.create(split[count])) count += 1 end end end
hit_from_string(hit_text)
click to toggle source
# File lib/dnsruby/resource/HIP.rb, line 66 def hit_from_string(hit_text) # Decode the hex value hit_text.gsub!(/\n/, "") hit_text.gsub!(/ /, "") return hit_text.unpack("H*")[0] end
hit_string()
click to toggle source
HIT field - stored in binary : client methods should handle base16(hex) encoding
# File lib/dnsruby/resource/HIP.rb, line 62 def hit_string # Return hex value [@hit.to_s].pack("H*").gsub("\n", "") end
public_key_from_string(key_text)
click to toggle source
# File lib/dnsruby/resource/HIP.rb, line 78 def public_key_from_string(key_text) key_text.gsub!(/\n/, "") key_text.gsub!(/ /, "") return key_text.unpack("m*")[0] end
public_key_string()
click to toggle source
Public Key field - presentation format is base64 - public_key methods reused from IPSECKEY
# File lib/dnsruby/resource/HIP.rb, line 74 def public_key_string [@public_key.to_s].pack("m*").gsub("\n", "") end