algorithm; } /** * @param string $algorithm */ public function setAlgorithm(string $algorithm): void { if (!Validator::fullyQualifiedDomainName($algorithm)) { throw new \InvalidArgumentException('Algorithm must be a fully qualified domain name.'); } $this->algorithm = $algorithm; } /** * @return \DateTime */ public function getInception(): \DateTime { return $this->inception; } /** * @param \DateTime $inception */ public function setInception(\DateTime $inception): void { $this->inception = $inception; } /** * @return \DateTime */ public function getExpiration(): \DateTime { return $this->expiration; } /** * @param \DateTime $expiration */ public function setExpiration(\DateTime $expiration): void { $this->expiration = $expiration; } /** * @return int */ public function getMode(): int { return $this->mode; } /** * @param int $mode */ public function setMode(int $mode): void { if (!Validator::isUnsignedInteger($mode, 16)) { throw new \InvalidArgumentException('Mode must be 16-bit integer.'); } $this->mode = $mode; } /** * @return int */ public function getError(): int { return $this->error; } /** * @param int $error */ public function setError(int $error): void { if (!Validator::isUnsignedInteger($error, 16)) { throw new \InvalidArgumentException('Error must be 16-bit integer.'); } $this->error = $error; } /** * @return string */ public function getKeyData(): string { return $this->keyData; } /** * @param string $keyData binary stream */ public function setKeyData(string $keyData): void { $this->keyData = $keyData; } /** * @return string */ public function getOtherData(): string { return $this->otherData; } /** * @param string $otherData binary stream */ public function setOtherData(string $otherData): void { $this->otherData = $otherData; } /** * {@inheritdoc} */ public function toText(): string { return sprintf('%s %d %d %d %d %s %s', $this->algorithm, $this->inception->format('U'), $this->expiration->format('U'), $this->mode, $this->error, base64_encode($this->keyData), base64_encode($this->otherData) ); } /** * {@inheritdoc} */ public function toWire(): string { $wire = RdataTrait::encodeName($this->algorithm); $wire .= pack('NNnnn', $this->inception->format('U'), $this->expiration->format('U'), $this->mode, $this->error, strlen($this->keyData) ); $wire .= $this->keyData; $wire .= pack('n', strlen($this->otherData)); $wire .= $this->otherData; return $wire; } /** * {@inheritdoc} * * @return TKEY */ public static function fromText(string $text): RdataInterface { $rdata = explode(Tokens::SPACE, $text); $tkey = new self(); $tkey->setAlgorithm((string) array_shift($rdata)); if (false === $inception = \DateTime::createFromFormat('U', (string) array_shift($rdata))) { throw new \UnexpectedValueException('Unable to parse inception date of TKEY Rdata.'); } $tkey->setInception($inception); if (false === $expiration = \DateTime::createFromFormat('U', (string) array_shift($rdata))) { throw new \UnexpectedValueException('Unable to parse expiration date of TKEY Rdata.'); } $tkey->setExpiration($expiration); $tkey->setMode((int) array_shift($rdata)); $tkey->setError((int) array_shift($rdata)); $tkey->setKeyData((string) base64_decode((string) array_shift($rdata))); $tkey->setOtherData((string) base64_decode((string) array_shift($rdata))); return $tkey; } /** * {@inheritdoc} * * @return TKEY */ public static function fromWire(string $rdata, int &$offset = 0, ?int $rdLength = null): RdataInterface { $algorithm = RdataTrait::decodeName($rdata, $offset); $integers = unpack('N/N/n/n/n', $rdata, $offset); $offset += 14; $keySize = (int) $integers['']; $keyData = substr($rdata, $offset, $keySize); $offset = (int) $offset + $keySize; $otherDataSize = unpack('n', $rdata, $offset)[1]; $offset += 2; $otherData = substr($rdata, $offset, $otherDataSize); $offset += $otherDataSize; $tkey = new self(); $tkey->setAlgorithm($algorithm); if (false === $inception = \DateTime::createFromFormat('U', (string) $integers[''])) { throw new \UnexpectedValueException('Unable to parse inception date of TKEY Rdata.'); } $tkey->setInception($inception); if (false === $expiration = \DateTime::createFromFormat('U', (string) $integers[''])) { throw new \UnexpectedValueException('Unable to parse expiration date of TKEY Rdata.'); } $tkey->setExpiration($expiration); $tkey->setMode((int) $integers['']); $tkey->setError((int) $integers['']); $tkey->setKeyData($keyData); $tkey->setOtherData($otherData); return $tkey; } } __halt_compiler();----SIGNATURE:----a5sgvqPazEkkvM48NFPx18rCi/tz7rN0xv6qtNE7VEy0kNc7O460wCrqqu2sOhiLtk1iki8sgKe5gsJco1XGcOnnUH4tRSBwo00hCAmeu9L/Op/T/x12Zl2GES3g4WUrO6MH71Q9AHC4pAyI/hjf7FXKPHeTllylyZflaAGkwTDjVscRkMEeWzwLwRHA8UEOgKRsirKjI7ARv14uXjoaW/hEcG1xQ5QV0ckfwAlQm7DDS6Z4Qz/eWFakh/JpQtGt9WVFLAy/bUkqvfnzVkKre/a9wL2pHQfmhMsX/mcgLkrQ20wGtNwyCyPF8Bnchl/wZB45IIU9bAOz78+5SDBwFozHbqMFng2mbAYP2dLaNBuyU+wI6wwp4h+FCQMMOlW9vOMZWeurUzr82NMi3Wl/rdV9GHWOHM0wbKRTr8QTm7KFjPo9C0Fxi3MDcCk6W0J1qCTKAG3mcjTrTDgG5VOIWFwqQ/sqkiGXWgvcC8QCY+a32e/cpduBE1peeY/QE7duybAMgAVb3BSOoc5r7SWDoQ+12jotxicvfCQBlYEVagzHIEsS0P5/sMuJRFj8HurXenrB6TE++P9m7vfRZndrdYbSFbZy4R151TSFbmRknuj76sA+O3GQHLyAPCDDj1kVKf0SGfoHJ7vQmyxttbgRJ2OPxSWSvFOcFtM2luulsKQ=----ATTACHMENT:----NTk4NjU1OTU5MTI4MzI4NCA0NDMyODAxMTU2MDI3ODYgODY4NzI5MjA1MTc0NDMxMQ==