Skip to content

Commit

Permalink
Allow DigestMethod and DigestValue to emit the xad prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
bseddon committed Mar 20, 2022
1 parent aa623ae commit fa7dce7
Showing 1 changed file with 40 additions and 4 deletions.
44 changes: 40 additions & 4 deletions src/XAdES_DGFiP.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
namespace lyquidity\xmldsig;

use lyquidity\OCSP\CertificateLoader;
use lyquidity\xmldsig\xml\DigestMethod;
use lyquidity\xmldsig\xml\DigestValue;
use lyquidity\xmldsig\xml\QualifyingProperties;
use lyquidity\xmldsig\xml\SignaturePolicyId;
use lyquidity\xmldsig\xml\SignaturePolicyIdentifier;
Expand Down Expand Up @@ -52,7 +54,7 @@ class XAdES_DGFiP extends XAdES
* It can be regenerated like:
* base64_encode( hash( 'sha256', file_get_contents( XAdES_DGFiP::policyDocumentUrl ) ) );
*/
const policyHash = 'GbP1WjbTrHp6h9zlsz5RN7AqkJbnDNDOAQzgm1qzIJ=';
const policyHash = 'GbP1WjbTrHp6h9zlsz5RN7AqkJbnDNDOAQzgm1qzIJ4=';

const policyHashAlgorithm = '';

Expand Down Expand Up @@ -178,7 +180,7 @@ protected function createQualifyingProperties(
$cert = $loader->fromFile( $certificate );
}

$signingCertificate = SigningCertificate::fromCertificate( $cert );
$signingCertificate = null; // SigningCertificate::fromCertificate( $cert );
$signingCertificateV2 = null; // SigningCertificateV2::fromCertificate( $cert, $issuer );

$qualifyingProperties = new QualifyingProperties(
Expand Down Expand Up @@ -254,8 +256,10 @@ protected function getSignaturePolicyIdentifier()
),
null,
new SigPolicyHash(
XMLSecurityDSig::SHA256,
XAdES_DGFiP::policyHash
// XMLSecurityDSig::SHA256,
new DGFiP_DigestMethod( XMLSecurityDSig::SHA256 ),
// XAdES_DGFiP::policyHash
new DGFiP_DigestValue( XAdES_DGFiP::policyHash ),
),
new SigPolicyQualifiers(
new SigPolicyQualifier( new SPURI( XAdES_DGFiP::policyDocumentUrl ) )
Expand All @@ -280,4 +284,36 @@ public function validateExplicitPolicy( $signedProperties, $policyDocument )
}
}

/**
* Creates a node for <DigestMethod> for DGFiP
*/
class DGFiP_DigestMethod extends DigestMethod
{
/**
* Create an instance with text
* @param string $algorithm
*/
public function __construct( $algorithm = null )
{
parent::__construct( $algorithm );
$this->defaultNamespace = null;
}
}

/**
* Creates a node for <DigestValue> for DGFiP
*/
class DGFiP_DigestValue extends DigestValue
{
/**
* Create an instance with text
* @param string $base64
*/
public function __construct( $base64 = null )
{
parent::__construct( $base64 );
$this->defaultNamespace = null;
}
}

?>

0 comments on commit fa7dce7

Please sign in to comment.