2727 */
2828trait EncryptedElementTrait
2929{
30- /** @var \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey|null */
31- protected ? EncryptedKey $ encryptedKey = null ;
30+ /** @var \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[] */
31+ protected array $ encryptedKey = [] ;
3232
3333
3434 /**
@@ -46,7 +46,7 @@ public function __construct(
4646
4747 foreach ($ keyInfo ->getInfo () as $ info ) {
4848 if ($ info instanceof EncryptedKey) {
49- $ this ->encryptedKey = $ info ;
49+ $ this ->encryptedKey [] = $ info ;
5050 break ;
5151 }
5252 }
@@ -60,16 +60,16 @@ public function __construct(
6060 */
6161 public function hasDecryptionKey (): bool
6262 {
63- return $ this ->encryptedKey !== null ;
63+ return ! empty ( $ this ->encryptedKey ) ;
6464 }
6565
6666
6767 /**
6868 * Get the encrypted key used to encrypt the current element.
6969 *
70- * @return \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey
70+ * @return \SimpleSAML\XMLSecurity\XML\xenc\EncryptedKey[]
7171 */
72- public function getEncryptedKey (): EncryptedKey
72+ public function getEncryptedKey (): array
7373 {
7474 return $ this ->encryptedKey ;
7575 }
@@ -120,7 +120,7 @@ protected function decryptData(EncryptionAlgorithmInterface $decryptor): string
120120
121121 if (in_array ($ decryptor ->getAlgorithmId (), C::$ KEY_TRANSPORT_ALGORITHMS )) {
122122 // the decryptor uses a key transport algorithm, check if we have a session key
123- if ($ this ->hasDecryptionKey () === null ) {
123+ if (! $ this ->hasDecryptionKey ()) {
124124 throw new RuntimeException ('Cannot use a key transport algorithm to decrypt an object. ' );
125125 }
126126
@@ -129,7 +129,9 @@ protected function decryptData(EncryptionAlgorithmInterface $decryptor): string
129129 }
130130
131131 $ encryptedKey = $ this ->getEncryptedKey ();
132- $ decryptionKey = $ encryptedKey ->decrypt ($ decryptor );
132+ Assert::count ($ encryptedKey , 1 , RuntimeException::class);
133+
134+ $ decryptionKey = $ encryptedKey [0 ]->decrypt ($ decryptor );
133135
134136 $ factory = new EncryptionAlgorithmFactory (
135137 $ this ->getBlacklistedAlgorithms () ?? EncryptionAlgorithmFactory::DEFAULT_BLACKLIST ,
0 commit comments