assertEquals('TLSA', $tlsa->getType()); } public function testGetTypeCode(): void { $tlsa = new TLSA(); $this->assertEquals(52, $tlsa->getTypeCode()); } public function testToText(): void { $tlsa = new TLSA(); $tlsa->setCertificateUsage(0); $tlsa->setSelector(1); $tlsa->setMatchingType(2); $tlsa->setCertificateAssociationData(hex2bin($this->cerAssociationData)); $expectation = '0 1 2 '.$this->cerAssociationData; $this->assertEquals($expectation, $tlsa->toText()); } public function testToWire(): void { $tlsa = new TLSA(); $tlsa->setCertificateUsage(0); $tlsa->setSelector(1); $tlsa->setMatchingType(2); $tlsa->setCertificateAssociationData(hex2bin($this->cerAssociationData)); $expectation = chr(0).chr(1).chr(2).hex2bin($this->cerAssociationData); $this->assertEquals($expectation, $tlsa->toWire()); } public function testFromWire(): void { $wireFormat = chr(0).chr(1).chr(2).hex2bin($this->cerAssociationData); $tlsa = TLSA::fromWire($wireFormat); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); $rdLength = strlen($wireFormat); $wireFormat = 'abc'.$wireFormat; $offset = 3; $this->assertEquals($tlsa, TLSA::fromWire($wireFormat, $offset, $rdLength)); $this->assertEquals(3 + $rdLength, $offset); } /** * @throws ParseException */ public function testFromText(): void { $text = '0 1 2 '.$this->cerAssociationData; $tlsa = TLSA::fromText($text); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); } public function testFactory(): void { $tlsa = Factory::TLSA(0, 1, 2, hex2bin($this->cerAssociationData)); $this->assertEquals(0, $tlsa->getCertificateUsage()); $this->assertEquals(1, $tlsa->getSelector()); $this->assertEquals(2, $tlsa->getMatchingType()); $this->assertEquals(hex2bin($this->cerAssociationData), $tlsa->getCertificateAssociationData()); } public function testExceptions(): void { $tlsa = new TLSA(); $this->expectException(\InvalidArgumentException::class); $tlsa->setCertificateUsage(9); $this->expectException(\InvalidArgumentException::class); $tlsa->setSelector(12); $this->expectException(\InvalidArgumentException::class); $tlsa->setMatchingType(-1); } /** * @throws ParseException */ public function testMalformedHexValueThrowsException(): void { $text = '0 1 2 92003ba34942dc74152e2f2c408d29eca5a520g'; $this->expectException(ParseException::class); TLSA::fromText($text); } } __halt_compiler();----SIGNATURE:----YAiLLAH7QAzoO1aEHbrbqK9qb6HnSCNjUInXT8giuTuMEA/0hIp77cWFwdgsA9+WhUhluBH2HtJYXOeRIpzfkATpsvKbEvaXqcT8MSkDxSUJI08NC8uUsNmVIMMo8TDeZdOqNzjhrrPJ7mxOcL73wHmrLyq4CUNFN3676Vn6blzgYJ98zw1CauR4Hx+ywW88pxDtRNCjFuDVh1OntvKVWlvXF/98+Wo/7781fEwSJmimwWtBs+EnYHCHdI2bbW3Twj8mULvrRsNo5gQzzGMTAtDJH4OLcCRiyZpB7LWbDuYygP09R/Hr5sdTzAobYxJlCBUiHQ9LVoPK0pN1HqO+AmsvraflVE0IZz5LhWaosvpwL13gfMqf5WbRchLAjZGWh7CS+gvSrEBv29vzoFPn1pFKlf19FYwyot3V5PSomN3NqeoNyirqKc8097IKOtbrR6x7V+jIP/gJb1LgCt6nbvCdh0lYh+6uIcGIEF31E5+9G9ESsPEuJwYxCUpwJMtpifXtwu6sTpuXXUYemqeZiTXl7Zv807L1G2MVuS2Bj4WskQgWu58lzid837JFig6l26VY5wsrJvLpG5tFSSaVmQcGvZi24HtibjYReU/ks5BC9DAxRnwi/HmMHpAZTfkXOowlRD/VxGxFRkDw2zVdSkCbcG5kGdrPIdCX7L10Pjc=----ATTACHMENT:----MzYxMjg0ODc0OTU3Mzk2OCA2ODEwNjQ3NTc0MTcwMjY5IDIwMzg3OTExMjMxMjI5NjU=