Skip to content

Commit fdc1244

Browse files
authored
Merge commit from fork
Validate AES-GCM Authentication Tag
1 parent 7390685 commit fdc1244

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/Backend/OpenSSL.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use SimpleSAML\XMLSecurity\Constants as C;
88
use SimpleSAML\XMLSecurity\Exception\InvalidArgumentException;
99
use SimpleSAML\XMLSecurity\Exception\OpenSSLException;
10+
use SimpleSAML\XMLSecurity\Exception\RuntimeException;
1011
use SimpleSAML\XMLSecurity\Key\AsymmetricKey;
1112
use SimpleSAML\XMLSecurity\Key\KeyInterface;
1213
use SimpleSAML\XMLSecurity\Key\PrivateKey;
@@ -153,6 +154,9 @@ public function decrypt(
153154
$options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
154155
if ($this->useAuthTag) { // configure GCM mode
155156
$authTag = substr($ciphertext, - self::AUTH_TAG_LEN);
157+
if (strlen($authTag) !== self::AUTH_TAG_LEN {
158+
throw new RuntimeException('Authentication tag length is invalid');
159+
}
156160
$ciphertext = substr($ciphertext, 0, - self::AUTH_TAG_LEN);
157161
$options = OPENSSL_RAW_DATA;
158162
}

0 commit comments

Comments
 (0)