From a025b5cabc43cfd017284d3e8caf7e449ac5c630 Mon Sep 17 00:00:00 2001 From: Alexander Danilov Date: Fri, 5 Dec 2025 15:46:23 +0200 Subject: [PATCH] AlgorithmIdentifier - new getParamters method --- src/CMS/AlgorithmIdentifier.php | 10 ++++++++++ tests/CMS/AlgorithmIdentifierTest.php | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/src/CMS/AlgorithmIdentifier.php b/src/CMS/AlgorithmIdentifier.php index 9b97565..32a0c8f 100644 --- a/src/CMS/AlgorithmIdentifier.php +++ b/src/CMS/AlgorithmIdentifier.php @@ -12,6 +12,7 @@ use Adapik\CMS\Exception\FormatException; use Adapik\CMS\Interfaces\CMSInterface; +use FG\ASN1\ASN1Object; use FG\ASN1\Universal\Sequence; /** @@ -39,4 +40,13 @@ public function getAlgorithmOid(): string { return $this->object->getChildren()[0]->__toString(); } + + /** + * @return ASN1Object|null + */ + public function getParameters(): ?ASN1Object + { + $children = $this->object->getChildren(); + return $children[1] ?? null; + } } diff --git a/tests/CMS/AlgorithmIdentifierTest.php b/tests/CMS/AlgorithmIdentifierTest.php index f30f5b1..ca974d0 100644 --- a/tests/CMS/AlgorithmIdentifierTest.php +++ b/tests/CMS/AlgorithmIdentifierTest.php @@ -15,6 +15,7 @@ use Adapik\CMS\AlgorithmIdentifier; use Adapik\CMS\Exception\FormatException; use Adapik\CMS\SignedData; +use FG\ASN1\ASN1Object; use PHPUnit\Framework\TestCase; class AlgorithmIdentifierTest extends TestCase @@ -40,4 +41,21 @@ public function testBase() self::assertEquals($binary, $newSA->getBinary()); } } + + /** + * @throws FormatException + */ + public function testGetParameters() + { + $binary = base64_decode(file_get_contents(__DIR__ . '/../fixtures/pull_request.cms')); + $signedData = SignedData::createFromContent($binary); + + foreach ($signedData->getSignedDataContent()->getCertificateSet() as $certificate) { + $signatureAlgorithm = $certificate->getSignatureAlgorithm(); + + $parameters = $signatureAlgorithm->getParameters(); + + self::assertInstanceOf(ASN1Object::class, $parameters); + } + } }