10b3fd2d3SAndreas Gohr<?php 20b3fd2d3SAndreas Gohr/** 30b3fd2d3SAndreas Gohr * This file is part of the FreeDSx ASN1 package. 40b3fd2d3SAndreas Gohr * 50b3fd2d3SAndreas Gohr * (c) Chad Sikorra <Chad.Sikorra@gmail.com> 60b3fd2d3SAndreas Gohr * 70b3fd2d3SAndreas Gohr * For the full copyright and license information, please view the LICENSE 80b3fd2d3SAndreas Gohr * file that was distributed with this source code. 90b3fd2d3SAndreas Gohr */ 100b3fd2d3SAndreas Gohr 110b3fd2d3SAndreas Gohrnamespace FreeDSx\Asn1\Encoder; 120b3fd2d3SAndreas Gohr 130b3fd2d3SAndreas Gohruse FreeDSx\Asn1\Exception\EncoderException; 140b3fd2d3SAndreas Gohruse FreeDSx\Asn1\Exception\PartialPduException; 150b3fd2d3SAndreas Gohruse FreeDSx\Asn1\Type\AbstractType; 160b3fd2d3SAndreas Gohruse FreeDSx\Asn1\Type\IncompleteType; 170b3fd2d3SAndreas Gohr 180b3fd2d3SAndreas Gohr/** 190b3fd2d3SAndreas Gohr * The ASN1 encoder interface. 200b3fd2d3SAndreas Gohr * 210b3fd2d3SAndreas Gohr * @author Chad Sikorra <Chad.Sikorra@gmail.com> 220b3fd2d3SAndreas Gohr */ 230b3fd2d3SAndreas Gohrinterface EncoderInterface 240b3fd2d3SAndreas Gohr{ 250b3fd2d3SAndreas Gohr /** 260b3fd2d3SAndreas Gohr * Encode a type to its binary form. 270b3fd2d3SAndreas Gohr * 280b3fd2d3SAndreas Gohr * @param AbstractType $type 290b3fd2d3SAndreas Gohr * @return string 300b3fd2d3SAndreas Gohr * @throws EncoderException 310b3fd2d3SAndreas Gohr */ 320b3fd2d3SAndreas Gohr public function encode(AbstractType $type): string; 330b3fd2d3SAndreas Gohr 340b3fd2d3SAndreas Gohr /** 350b3fd2d3SAndreas Gohr * Decodes (completes) an incomplete type to a specific universal tag type object. 360b3fd2d3SAndreas Gohr * 370b3fd2d3SAndreas Gohr * @param IncompleteType $type 380b3fd2d3SAndreas Gohr * @param int $tagType 390b3fd2d3SAndreas Gohr * @param array $tagMap 40*fd0855ecSAndreas Gohr * @return AbstractType 410b3fd2d3SAndreas Gohr * @throws EncoderException 420b3fd2d3SAndreas Gohr */ 430b3fd2d3SAndreas Gohr public function complete(IncompleteType $type, int $tagType, array $tagMap = []): AbstractType; 440b3fd2d3SAndreas Gohr 450b3fd2d3SAndreas Gohr /** 460b3fd2d3SAndreas Gohr * Decode binary data to its ASN1 object representation. 470b3fd2d3SAndreas Gohr * 480b3fd2d3SAndreas Gohr * @param string $binary 490b3fd2d3SAndreas Gohr * @param array $tagMap 500b3fd2d3SAndreas Gohr * @return AbstractType 510b3fd2d3SAndreas Gohr * @throws EncoderException 520b3fd2d3SAndreas Gohr * @throws PartialPduException 530b3fd2d3SAndreas Gohr */ 540b3fd2d3SAndreas Gohr public function decode($binary, array $tagMap = []): AbstractType; 550b3fd2d3SAndreas Gohr 560b3fd2d3SAndreas Gohr /** 570b3fd2d3SAndreas Gohr * Get the last position of the binary byte stream after a decode operation. 580b3fd2d3SAndreas Gohr * 590b3fd2d3SAndreas Gohr * @return int|null 600b3fd2d3SAndreas Gohr */ 610b3fd2d3SAndreas Gohr public function getLastPosition(): ?int; 620b3fd2d3SAndreas Gohr} 63