@@ -11,19 +11,19 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class AuthenticationInfoAttributeValue extends SvceAuthInfo |
| 13 | 13 | { |
| 14 | - const OID = "1.3.6.1.5.5.7.10.1"; |
|
| 14 | + const OID = "1.3.6.1.5.5.7.10.1"; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param GeneralName $service |
|
| 20 | - * @param GeneralName $ident |
|
| 21 | - * @param string|null $auth_info |
|
| 22 | - */ |
|
| 23 | - public function __construct(GeneralName $service, GeneralName $ident, |
|
| 24 | - $auth_info = null) |
|
| 25 | - { |
|
| 26 | - parent::__construct($service, $ident, $auth_info); |
|
| 27 | - $this->_oid = self::OID; |
|
| 28 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param GeneralName $service |
|
| 20 | + * @param GeneralName $ident |
|
| 21 | + * @param string|null $auth_info |
|
| 22 | + */ |
|
| 23 | + public function __construct(GeneralName $service, GeneralName $ident, |
|
| 24 | + $auth_info = null) |
|
| 25 | + { |
|
| 26 | + parent::__construct($service, $ident, $auth_info); |
|
| 27 | + $this->_oid = self::OID; |
|
| 28 | + } |
|
| 29 | 29 | } |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class ChargingIdentityAttributeValue extends IetfAttrSyntax |
| 11 | 11 | { |
| 12 | - const OID = "1.3.6.1.5.5.7.10.3"; |
|
| 12 | + const OID = "1.3.6.1.5.5.7.10.3"; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param IetfAttrValue ...$values |
|
| 18 | - */ |
|
| 19 | - public function __construct(IetfAttrValue ...$values) |
|
| 20 | - { |
|
| 21 | - parent::__construct(...$values); |
|
| 22 | - $this->_oid = self::OID; |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param IetfAttrValue ...$values |
|
| 18 | + */ |
|
| 19 | + public function __construct(IetfAttrValue ...$values) |
|
| 20 | + { |
|
| 21 | + parent::__construct(...$values); |
|
| 22 | + $this->_oid = self::OID; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -11,17 +11,17 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class AccessIdentityAttributeValue extends SvceAuthInfo |
| 13 | 13 | { |
| 14 | - const OID = "1.3.6.1.5.5.7.10.2"; |
|
| 14 | + const OID = "1.3.6.1.5.5.7.10.2"; |
|
| 15 | 15 | |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param GeneralName $service |
|
| 20 | - * @param GeneralName $ident |
|
| 21 | - */ |
|
| 22 | - public function __construct(GeneralName $service, GeneralName $ident) |
|
| 23 | - { |
|
| 24 | - parent::__construct($service, $ident, null); |
|
| 25 | - $this->_oid = self::OID; |
|
| 26 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param GeneralName $service |
|
| 20 | + * @param GeneralName $ident |
|
| 21 | + */ |
|
| 22 | + public function __construct(GeneralName $service, GeneralName $ident) |
|
| 23 | + { |
|
| 24 | + parent::__construct($service, $ident, null); |
|
| 25 | + $this->_oid = self::OID; |
|
| 26 | + } |
|
| 27 | 27 | } |
@@ -9,16 +9,16 @@ |
||
| 9 | 9 | */ |
| 10 | 10 | class GroupAttributeValue extends IetfAttrSyntax |
| 11 | 11 | { |
| 12 | - const OID = "1.3.6.1.5.5.7.10.4"; |
|
| 12 | + const OID = "1.3.6.1.5.5.7.10.4"; |
|
| 13 | 13 | |
| 14 | - /** |
|
| 15 | - * Constructor. |
|
| 16 | - * |
|
| 17 | - * @param IetfAttrValue ...$values |
|
| 18 | - */ |
|
| 19 | - public function __construct(IetfAttrValue ...$values) |
|
| 20 | - { |
|
| 21 | - parent::__construct(...$values); |
|
| 22 | - $this->_oid = self::OID; |
|
| 23 | - } |
|
| 14 | + /** |
|
| 15 | + * Constructor. |
|
| 16 | + * |
|
| 17 | + * @param IetfAttrValue ...$values |
|
| 18 | + */ |
|
| 19 | + public function __construct(IetfAttrValue ...$values) |
|
| 20 | + { |
|
| 21 | + parent::__construct(...$values); |
|
| 22 | + $this->_oid = self::OID; |
|
| 23 | + } |
|
| 24 | 24 | } |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | // load RSA private key from PEM |
| 22 | 22 | $private_key_info = PrivateKeyInfo::fromPEM( |
| 23 | - PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem")); |
|
| 23 | + PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem")); |
|
| 24 | 24 | // extract public key from private key |
| 25 | 25 | $public_key_info = $private_key_info->publicKeyInfo(); |
| 26 | 26 | // DN of the certification authority |
@@ -30,12 +30,12 @@ discard block |
||
| 30 | 30 | // create "to be signed" certificate object with extensions |
| 31 | 31 | $tbs_cert = new TBSCertificate($name, $public_key_info, $name, $validity); |
| 32 | 32 | $tbs_cert = $tbs_cert->withRandomSerialNumber()->withAdditionalExtensions( |
| 33 | - new BasicConstraintsExtension(true, true), |
|
| 34 | - new SubjectKeyIdentifierExtension(false, $public_key_info->keyIdentifier()), |
|
| 35 | - new KeyUsageExtension(true, |
|
| 36 | - KeyUsageExtension::DIGITAL_SIGNATURE | KeyUsageExtension::KEY_CERT_SIGN)); |
|
| 33 | + new BasicConstraintsExtension(true, true), |
|
| 34 | + new SubjectKeyIdentifierExtension(false, $public_key_info->keyIdentifier()), |
|
| 35 | + new KeyUsageExtension(true, |
|
| 36 | + KeyUsageExtension::DIGITAL_SIGNATURE | KeyUsageExtension::KEY_CERT_SIGN)); |
|
| 37 | 37 | // sign certificate with private key |
| 38 | 38 | $algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto( |
| 39 | - $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier()); |
|
| 39 | + $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier()); |
|
| 40 | 40 | $cert = $tbs_cert->sign($algo, $private_key_info); |
| 41 | 41 | echo $cert; |
@@ -25,27 +25,27 @@ |
||
| 25 | 25 | $csr = CertificationRequest::fromPEM(PEM::fromFile($argv[2])); |
| 26 | 26 | // verify CSR |
| 27 | 27 | if (!$csr->verify()) { |
| 28 | - echo "Failed to verify certification request signature.\n"; |
|
| 29 | - exit(1); |
|
| 28 | + echo "Failed to verify certification request signature.\n"; |
|
| 29 | + exit(1); |
|
| 30 | 30 | } |
| 31 | 31 | // load CA's private key from PEM |
| 32 | 32 | $private_key_info = PrivateKeyInfo::fromPEM( |
| 33 | - PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem")); |
|
| 33 | + PEM::fromFile(dirname(__DIR__) . "/test/assets/rsa/private_key.pem")); |
|
| 34 | 34 | // initialize certificate from CSR and issuer's certificate |
| 35 | 35 | $tbs_cert = TBSCertificate::fromCSR($csr)->withIssuerCertificate($issuer_cert); |
| 36 | 36 | // set random serial number |
| 37 | 37 | $tbs_cert = $tbs_cert->withRandomSerialNumber(); |
| 38 | 38 | // set validity period |
| 39 | 39 | $tbs_cert = $tbs_cert->withValidity( |
| 40 | - Validity::fromStrings("now", "now + 3 months")); |
|
| 40 | + Validity::fromStrings("now", "now + 3 months")); |
|
| 41 | 41 | // add extensions |
| 42 | 42 | $tbs_cert = $tbs_cert->withAdditionalExtensions( |
| 43 | - new KeyUsageExtension(true, |
|
| 44 | - KeyUsageExtension::DIGITAL_SIGNATURE | |
|
| 45 | - KeyUsageExtension::KEY_ENCIPHERMENT), |
|
| 46 | - new BasicConstraintsExtension(true, false)); |
|
| 43 | + new KeyUsageExtension(true, |
|
| 44 | + KeyUsageExtension::DIGITAL_SIGNATURE | |
|
| 45 | + KeyUsageExtension::KEY_ENCIPHERMENT), |
|
| 46 | + new BasicConstraintsExtension(true, false)); |
|
| 47 | 47 | // sign certificate with issuer's private key |
| 48 | 48 | $algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto( |
| 49 | - $private_key_info->algorithmIdentifier(), new SHA512AlgorithmIdentifier()); |
|
| 49 | + $private_key_info->algorithmIdentifier(), new SHA512AlgorithmIdentifier()); |
|
| 50 | 50 | $cert = $tbs_cert->sign($algo, $private_key_info); |
| 51 | 51 | echo $cert; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | |
| 17 | 17 | // load EC private key from PEM |
| 18 | 18 | $private_key_info = PrivateKeyInfo::fromPEM( |
| 19 | - PEM::fromFile(dirname(__DIR__) . "/test/assets/ec/private_key.pem")); |
|
| 19 | + PEM::fromFile(dirname(__DIR__) . "/test/assets/ec/private_key.pem")); |
|
| 20 | 20 | // extract public key from private key |
| 21 | 21 | $public_key_info = $private_key_info->publicKeyInfo(); |
| 22 | 22 | // DN of the subject |
@@ -25,6 +25,6 @@ discard block |
||
| 25 | 25 | $cri = new CertificationRequestInfo($subject, $public_key_info); |
| 26 | 26 | // sign certificate request with private key |
| 27 | 27 | $algo = SignatureAlgorithmIdentifierFactory::algoForAsymmetricCrypto( |
| 28 | - $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier()); |
|
| 28 | + $private_key_info->algorithmIdentifier(), new SHA256AlgorithmIdentifier()); |
|
| 29 | 29 | $csr = $cri->sign($algo, $private_key_info); |
| 30 | 30 | echo $csr; |
@@ -28,19 +28,19 @@ |
||
| 28 | 28 | // build certification path from CA to end-entity certificate |
| 29 | 29 | $path = CertificationPath::fromTrustAnchorToTarget($ca, $cert); |
| 30 | 30 | foreach ($path->certificates() as $idx => $cert) { |
| 31 | - printf("#%d: %s\n", $idx, |
|
| 32 | - $cert->tbsCertificate() |
|
| 33 | - ->subject() |
|
| 34 | - ->toString()); |
|
| 31 | + printf("#%d: %s\n", $idx, |
|
| 32 | + $cert->tbsCertificate() |
|
| 33 | + ->subject() |
|
| 34 | + ->toString()); |
|
| 35 | 35 | } |
| 36 | 36 | // validate certification path with default configuration |
| 37 | 37 | $config = PathValidationConfig::defaultConfig(); |
| 38 | 38 | $result = $path->validate($config); |
| 39 | 39 | printf("Certificate '%s' is valid.\n", |
| 40 | - $result->certificate() |
|
| 41 | - ->tbsCertificate() |
|
| 42 | - ->subject() |
|
| 43 | - ->toString()); |
|
| 40 | + $result->certificate() |
|
| 41 | + ->tbsCertificate() |
|
| 42 | + ->subject() |
|
| 43 | + ->toString()); |
|
| 44 | 44 | // remove temporary files |
| 45 | 45 | unlink($ca_file); |
| 46 | 46 | unlink($csr_file); |
@@ -13,16 +13,16 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class FreshestCRLExtension extends CRLDistributionPointsExtension |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Constructor. |
|
| 18 | - * |
|
| 19 | - * @param bool $critical |
|
| 20 | - * @param DistributionPoint ...$distribution_points |
|
| 21 | - */ |
|
| 22 | - public function __construct(bool $critical, |
|
| 23 | - DistributionPoint ...$distribution_points) |
|
| 24 | - { |
|
| 25 | - Extension::__construct(self::OID_FRESHEST_CRL, $critical); |
|
| 26 | - $this->_distributionPoints = $distribution_points; |
|
| 27 | - } |
|
| 16 | + /** |
|
| 17 | + * Constructor. |
|
| 18 | + * |
|
| 19 | + * @param bool $critical |
|
| 20 | + * @param DistributionPoint ...$distribution_points |
|
| 21 | + */ |
|
| 22 | + public function __construct(bool $critical, |
|
| 23 | + DistributionPoint ...$distribution_points) |
|
| 24 | + { |
|
| 25 | + Extension::__construct(self::OID_FRESHEST_CRL, $critical); |
|
| 26 | + $this->_distributionPoints = $distribution_points; |
|
| 27 | + } |
|
| 28 | 28 | } |