Skip to content

Commit cad6d57

Browse files
committed
Merge commit from fork
Validate AES-GCM Authentication Tag
1 parent 5e9c726 commit cad6d57

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;
@@ -158,6 +159,9 @@ public function decrypt(
158159
$options = OPENSSL_RAW_DATA | OPENSSL_ZERO_PADDING;
159160
if ($this->useAuthTag) { // configure GCM mode
160161
$authTag = substr($ciphertext, - self::AUTH_TAG_LEN);
162+
if (strlen($authTag) !== self::AUTH_TAG_LEN {
163+
throw new RuntimeException('Authentication tag length is invalid');
164+
}
161165
$ciphertext = substr($ciphertext, 0, - self::AUTH_TAG_LEN);
162166
$options = OPENSSL_RAW_DATA;
163167
}

0 commit comments

Comments
 (0)