Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/CMS/AlgorithmIdentifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Adapik\CMS\Exception\FormatException;
use Adapik\CMS\Interfaces\CMSInterface;
use FG\ASN1\ASN1Object;
use FG\ASN1\Universal\Sequence;

/**
Expand Down Expand Up @@ -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;
}
}
18 changes: 18 additions & 0 deletions tests/CMS/AlgorithmIdentifierTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}
}
}