Skip to content

Commit 640364f

Browse files
committed
Add NoDiscard-attribute to harden the code when it comes to signature validation
1 parent e921ce2 commit 640364f

File tree

3 files changed

+5
-0
lines changed

3 files changed

+5
-0
lines changed

src/XML/CanonicalizableElementTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ abstract protected function getOriginalXML(): DOMElement;
3939
* filters).
4040
* @return string
4141
*/
42+
#[\NoDiscard]
4243
public function canonicalize(string $method, ?array $xpaths = null, ?array $prefixes = null): string
4344
{
4445
return XML::canonicalizeData($this->getOriginalXML(), $method, $xpaths, $prefixes);

src/XML/SignableElementTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public function sign(
104104
* @param string $digestAlg The digest algorithm to use.
105105
* @param \SimpleSAML\XMLSecurity\XML\ds\Transforms $transforms The transforms to apply to the object.
106106
*/
107+
#[\NoDiscard]
107108
private function getReference(
108109
string $digestAlg,
109110
Transforms $transforms,
@@ -167,6 +168,7 @@ private function getReference(
167168
* @param \DOMElement $xml The element to sign.
168169
* @return \DOMElement The signed element, without the signature attached to it just yet.
169170
*/
171+
#[\NoDiscard]
170172
protected function doSign(DOMElement $xml): DOMElement
171173
{
172174
Assert::notNull(

src/XML/SignedElementTrait.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ private function validateReference(SignedInfo $signedInfo): SignedElementInterfa
192192
*
193193
* @return \SimpleSAML\XMLSecurity\XML\SignedElementInterface The Signed element if it was verified.
194194
*/
195+
#[\NoDiscard]
195196
private function verifyInternal(SignatureAlgorithmInterface $verifier): SignedElementInterface
196197
{
197198
/** @var \SimpleSAML\XMLSecurity\XML\ds\Signature $this->signature */
@@ -260,6 +261,7 @@ public function isSigned(): bool
260261
* in the signature.
261262
* @throws \SimpleSAML\XMLSecurity\Exception\RuntimeException if the signature fails to verify.
262263
*/
264+
#[\NoDiscard]
263265
public function verify(?SignatureAlgorithmInterface $verifier = null): SignedElementInterface
264266
{
265267
if (!$this->isSigned()) {

0 commit comments

Comments
 (0)