Skip to content

Commit

Permalink
Merge pull request from GHSA-ww7x-3gxh-qm6r
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Nov 27, 2023
1 parent f9029fc commit f509e30
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/XML/SignedElementTrait.php
Expand Up @@ -24,6 +24,7 @@
use SimpleSAML\XMLSecurity\Utils\XPath;
use SimpleSAML\XMLSecurity\XML\ds\Reference;
use SimpleSAML\XMLSecurity\XML\ds\Signature;
use SimpleSAML\XMLSecurity\XML\ds\SignedInfo;
use SimpleSAML\XMLSecurity\XML\ds\X509Certificate;
use SimpleSAML\XMLSecurity\XML\ds\X509Data;

Expand Down Expand Up @@ -124,12 +125,11 @@ private function validateReferenceUri(Reference $reference, DOMElement $xml): vo


/**
* @param \SimpleSAML\XMLSecurity\XML\ds\SignedInfo $signedInfo
* @return \SimpleSAML\XMLSecurity\XML\SignedElementInterface
*/
private function validateReference(): SignedElementInterface
private function validateReference(SignedInfo $signedInfo): SignedElementInterface
{
/** @var \SimpleSAML\XMLSecurity\XML\ds\Signature $this->signature */
$signedInfo = $this->signature->getSignedInfo();
$references = $signedInfo->getReferences();
Assert::count(
$references,
Expand Down Expand Up @@ -177,8 +177,12 @@ private function verifyInternal(SignatureAlgorithmInterface $verifier): SignedEl
/** @var \SimpleSAML\XMLSecurity\XML\ds\Signature $this->signature */
$signedInfo = $this->signature->getSignedInfo();
$c14nAlg = $signedInfo->getCanonicalizationMethod()->getAlgorithm();

// the canonicalized ds:SignedInfo element (plaintext)
$c14nSignedInfo = $signedInfo->canonicalize($c14nAlg);
$ref = $this->validateReference();
$ref = $this->validateReference(
SignedInfo::fromXML(DOMDocumentFactory::fromString($c14nSignedInfo)->documentElement),
);

if (
$verifier?->verify(
Expand Down

0 comments on commit f509e30

Please sign in to comment.