-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
180c27d
commit 191d9f8
Showing
18 changed files
with
197 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<?php | ||
/** | ||
* Signature | ||
* | ||
* @author Nurlan Mukhanov <nurike@gmail.com> | ||
* @copyright 2020 Nurlan Mukhanov | ||
* @license https://en.wikipedia.org/wiki/MIT_License MIT License | ||
* @link https://github.com/Falseclock/AdvancedCMS | ||
*/ | ||
|
||
namespace Falseclock\AdvancedCMS\Maps; | ||
|
||
use Adapik\CMS\Maps\AlgorithmIdentifier; | ||
use Adapik\CMS\Maps\Certificate; | ||
use FG\ASN1\Identifier; | ||
|
||
abstract class Signature | ||
{ | ||
/** | ||
* Signature ::= SEQUENCE { | ||
* signatureAlgorithm AlgorithmIdentifier, | ||
* signature BIT STRING, | ||
* certs [0] EXPLICIT SEQUENCE OF Certificate OPTIONAL | ||
* } | ||
*/ | ||
const MAP = [ | ||
'type' => Identifier::SEQUENCE, | ||
'children' => [ | ||
'signatureAlgorithm' => AlgorithmIdentifier::MAP, | ||
'signature' => ['type' => Identifier::BITSTRING], | ||
'certs' => [ | ||
'constant' => 0, | ||
'explicit' => true, | ||
'optional' => true, | ||
'min' => 1, | ||
'max' => -1, | ||
'type' => Identifier::SEQUENCE, | ||
'children' => Certificate::MAP | ||
], | ||
], | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?php | ||
/** | ||
* Signature | ||
* | ||
* @author Nurlan Mukhanov <nurike@gmail.com> | ||
* @copyright 2020 Nurlan Mukhanov | ||
* @license https://en.wikipedia.org/wiki/MIT_License MIT License | ||
* @link https://github.com/Falseclock/AdvancedCMS | ||
*/ | ||
|
||
namespace Falseclock\AdvancedCMS; | ||
|
||
use Adapik\CMS\AlgorithmIdentifier; | ||
use Adapik\CMS\Certificate; | ||
use Adapik\CMS\CMSBase; | ||
use Adapik\CMS\Exception\FormatException; | ||
use FG\ASN1\Exception\ParserException; | ||
use FG\ASN1\ExplicitlyTaggedObject; | ||
use FG\ASN1\Universal\BitString; | ||
use FG\ASN1\Universal\Sequence; | ||
|
||
/** | ||
* Class Signature | ||
* | ||
* @see Maps\Signature | ||
* @package Adapik\CMS | ||
*/ | ||
class Signature extends CMSBase | ||
{ | ||
/** | ||
* @var Sequence | ||
*/ | ||
protected $object; | ||
|
||
/** | ||
* @param string $content | ||
* @return Signature | ||
* @throws FormatException | ||
*/ | ||
public static function createFromContent(string $content): CMSBase | ||
{ | ||
return new self(self::makeFromContent($content, Maps\Signature::class, Sequence::class)); | ||
} | ||
|
||
/** | ||
* @return AlgorithmIdentifier | ||
*/ | ||
public function getSignatureAlgorithm(): AlgorithmIdentifier | ||
{ | ||
$signatureAlgorithm = $this->object->getChildren()[0]; | ||
|
||
return new AlgorithmIdentifier($signatureAlgorithm); | ||
} | ||
|
||
/** | ||
* @return BitString | ||
* @throws ParserException | ||
*/ | ||
public function getSignature(): BitString | ||
{ | ||
$binary = $this->object->getChildren()[1]->getBinary(); | ||
|
||
return BitString::fromBinary($binary); | ||
} | ||
|
||
/** | ||
* @return Certificate[] | ||
*/ | ||
public function getCerts(): array | ||
{ | ||
$certificates = []; | ||
|
||
if (count($this->object->getChildren()) == 3) { | ||
/** @var ExplicitlyTaggedObject $certs */ | ||
$certs = $this->object->getChildren()[2]; | ||
|
||
foreach ($certs->getChildren() as $cert) { | ||
$certificates[] = new Certificate($cert->getChildren()[0]); | ||
} | ||
} | ||
return $certificates; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
MIIHfzCCBWegAwIBAgIUNXb1sxtaaCGhb++rEhLJTZONx+4wDQYJKoZIhvcNAQELBQAwgaIxRTBDBgNVBAMMPNCd0JXQk9CG0JfQk9CGINCa0KPTmNCb0JDQndCU0KvQoNCj0KjQqyDQntCg0KLQkNCb0KvSmiAoUlNBKTFMMEoGA1UECgxD0KDQnNCaIMKr0JzQldCc0JvQldCa0JXQotCi0IbQmiDQotCV0KXQndCY0JrQkNCb0KvSmiDSmtCr0JfQnNCV0KLCuzELMAkGA1UEBhMCS1owHhcNMTgwODA4MDQyNjM2WhcNMjUwNjI1MDQyNjM2WjBSMQswCQYDVQQGEwJLWjFDMEEGA1UEAww60rDQm9Ci0KLQq9KaINCa0KPTmNCb0JDQndCU0KvQoNCj0KjQqyDQntCg0KLQkNCb0KvSmiAoUlNBKTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAK5bzHPV9MZLVWM/05m2xSs5DZ1+WQ6kTe+PMY2hOb/527+ep9IdvlAxtzQlvbr6Q6I8Jg9FYOWFQddQEqMoeipsaT8vb7F569VIp4M3BLs91+L1xJVhRholgonWrjd9n3N06pEvgiXOD2BxlWpPInxVNvTLRIuDjsO65KOeyZeBzLnPhUaELG9TcPnvZt9doucaC88caS9RFRNRDm03yfuB+LJE+5nuX+sycMVLkAKI0AHu4Icdl6DikqP2l/MB3BScnQ7CzzTCKn5puq6R06VuOV9ELhCab8JSF2vzr4eQuHAHLXz61/LN22vFINGMGb8LsS4SkCAz/30sYnTCsDlcAMiQi2Fd9HbcBMHElXwQsoN/5OWlqH4CtmR55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