Skip to content

JDWX DNSQuery RR TSIG

JDW edited this page Jul 17, 2022 · 1 revision

JDWX\DNSQuery\RR\TSIG

TSIG Resource Record - RFC 2845

0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / algorithm / / / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | time signed | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | | fudge | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | mac size | / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / mac / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | original id | error | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | other length | / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ / / other data / +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+

Constants

HMAC_MD5

const HMAC_MD5 = 'hmac-md5.sig-alg.reg.int'

GSS_TSIG

const GSS_TSIG = 'gss-tsig'

HMAC_SHA1

const HMAC_SHA1 = 'hmac-sha1'

HMAC_SHA224

const HMAC_SHA224 = 'hmac-sha224'

HMAC_SHA256

const HMAC_SHA256 = 'hmac-sha256'

HMAC_SHA384

const HMAC_SHA384 = 'hmac-sha384'

HMAC_SHA512

const HMAC_SHA512 = 'hmac-sha512'

Properties

hashAlgorithms

public  hashAlgorithms = [self::HMAC_MD5 => 'md5', self::HMAC_SHA1 => 'sha1', self::HMAC_SHA224 => 'sha224', self::HMAC_SHA256 => 'sha256', self::HMAC_SHA384 => 'sha384', self::HMAC_SHA512 => 'sha512']
  • Visibility: public

algorithm

public  algorithm
  • Visibility: public

timeSigned

public  timeSigned
  • Visibility: public

fudge

public  fudge
  • Visibility: public

macSize

public  macSize
  • Visibility: public

mac

public  mac
  • Visibility: public

originalId

public  originalId
  • Visibility: public

error

public  error
  • Visibility: public

otherLength

public  otherLength
  • Visibility: public

otherData

public  otherData
  • Visibility: public

key

public  key
  • Visibility: public

name

public  name
  • Visibility: public

type

public  type
  • Visibility: public

class

public  class
  • Visibility: public

ttl

public  ttl
  • Visibility: public

rdLength

public  rdLength
  • Visibility: public

rdata

public  rdata = ''
  • Visibility: public

Methods

rrFromString

bool JDWX\DNSQuery\RR\RR::rrFromString(string[] i_rData)

Parse the rdata portion from a standard DNS config line

Arguments

  • i_rData string[] - a string split line of values for the rdata

rrGet

?string JDWX\DNSQuery\RR\RR::rrGet(\JDWX\DNSQuery\Packet\Packet i_packet)

Returns the rdata portion of the RR, advancing the referenced packet offset by the correct size.

Arguments

rrSet

bool JDWX\DNSQuery\RR\RR::rrSet(\JDWX\DNSQuery\Packet\Packet i_packet)

Parse the rdata from the current position of the provided Packet object, advancing the packet's internal offset accordingly.

Arguments

rrToString

string JDWX\DNSQuery\RR\RR::rrToString()

Return the rdata portion of the packet as a string.

This is not the same as the __toString() magic method, which returns the whole RR.

_signHMAC

string JDWX\DNSQuery\RR\TSIG::_signHMAC(string data, string key, string algorithm)

signs the given data with the given key, and returns the result

  • Visibility: private

Arguments

  • data string - the data to sign
  • key string - key to use for signing
  • algorithm string - the algorithm to use; defaults to MD5

__construct

mixed JDWX\DNSQuery\RR\RR::__construct(?\JDWX\DNSQuery\Packet\Packet i_packet, ?array i_rr)

Constructor - builds a new RR object

Arguments

  • i_packet ?\JDWX\DNSQuery\Packet\Packet - a Packet or null to create an empty object
  • i_rr ?array - an array with RR parse values or null to create an empty object

fromString

static JDWX\DNSQuery\RR\RR::fromString(string line)

parses a standard RR format lines, as defined by rfc1035 (kinda)

In our implementation, the domain must be specified- format must be

   <name> [<ttl>] [<class>] <type> <rdata>

or [] []

name, title, class and type are parsed by this function, rdata is passed to the RR specific classes for parsing.

Arguments

  • line string - a standard DNS config line

parse

?\JDWX\DNSQuery\RR\RR JDWX\DNSQuery\RR\RR::parse(\JDWX\DNSQuery\Packet\Packet packet)

parses a binary packet, and returns the appropriate RR object, based on the RR type of the binary content.

Arguments

__toString

string JDWX\DNSQuery\RR\RR::__toString()

magic __toString() method to return the RR object as a string

asArray

array JDWX\DNSQuery\RR\RR::asArray()

return the same data as __toString(), but as an array, so each value can be used without having to parse the string.

cleanString

string JDWX\DNSQuery\RR\RR::cleanString(string i_data)

cleans up some RR data

Arguments

  • i_data string - the text string to clean

get

string JDWX\DNSQuery\RR\RR::get(\JDWX\DNSQuery\Packet\Packet i_packet)

returns a binary packed DNS RR object

Arguments

getPHPRData

array JDWX\DNSQuery\RR\RR::getPHPRData()

Get the rdata in the format used by PHP's dns_get_record() function.

getPHPRecord

array JDWX\DNSQuery\RR\RR::getPHPRecord()

Get the whole record in the format used by PHP's dns_get_record() function.

See the caveats in getPHPRData() about RR-specific data.

set

bool JDWX\DNSQuery\RR\RR::set(\JDWX\DNSQuery\Packet\Packet i_packet, array i_rr)

builds a new RR object

Arguments

  • i_packet JDWX\DNSQuery\Packet\Packet - (output) a Packet or null to create an empty object
  • i_rr array - an array with RR parse values or null to create an empty object

buildString

string[] JDWX\DNSQuery\RR\RR::buildString(string[] i_chunks)

Build an array of strings from an array of chunks of text split by spaces.

Arguments

  • i_chunks string[] - an array of chunks of text split by spaces

formatString

string JDWX\DNSQuery\RR\RR::formatString(string i_str)

return a formatted string; if a string has spaces in it, then return it with double quotes around it, otherwise, return it as it was passed in.

Arguments

  • i_str string - the string to format

rrGetEx

string JDWX\DNSQuery\RR\RR::rrGetEx(\JDWX\DNSQuery\Packet\Packet i_packet)

returns a binary packet DNS RR object and throws an exception if it fails

Arguments

Clone this wiki locally