| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | namespace SimpleSAML\XMLSecurity\XML\xenc11; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use DOMElement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use SimpleSAML\Assert\Assert; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use SimpleSAML\XML\Exception\InvalidDOMElementException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use SimpleSAML\XML\Exception\MissingElementException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use SimpleSAML\XML\Exception\TooManyElementsException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use function array_pop; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * Class representing <xenc11:PBKDF2ParameterType>. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @package simplesamlphp/xml-security | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 19 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 20 |  |  | abstract class AbstractPBKDF2ParameterType extends AbstractXenc11Element | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |      * PBKDF2ParameterType constructor. | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |      * @param \SimpleSAML\XMLSecurity\XML\xenc11\Salt $salt | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |      * @param \SimpleSAML\XMLSecurity\XML\xenc11\IterationCount $iterationCount | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      * @param \SimpleSAML\XMLSecurity\XML\xenc11\KeyLength $keyLength | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |      * @param \SimpleSAML\XMLSecurity\XML\xenc11\PRF $prf | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |     final public function __construct( | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |         protected Salt $salt, | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         protected IterationCount $iterationCount, | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |         protected KeyLength $keyLength, | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         protected PRF $prf, | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     ) { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |      * Get the value of the $salt property. | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |      * @return \SimpleSAML\XMLSecurity\XML\xenc11\Salt | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     public function getSalt(): Salt | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         return $this->salt; | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |      * Get the value of the $iterationCount property. | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |      * @return \SimpleSAML\XMLSecurity\XML\xenc11\IterationCount | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     public function getIterationCount(): IterationCount | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |         return $this->iterationCount; | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |      * Get the value of the $keyLength property. | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |      * @return \SimpleSAML\XMLSecurity\XML\xenc11\KeyLength | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function getKeyLength(): KeyLength | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 68 |  |  |         return $this->keyLength; | 
            
                                                                        
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 71 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 72 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 73 |  |  |      * Get the value of the $prf property. | 
            
                                                                        
                            
            
                                    
            
            
                | 74 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 75 |  |  |      * @return \SimpleSAML\XMLSecurity\XML\xenc11\PRF | 
            
                                                                        
                            
            
                                    
            
            
                | 76 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |     public function getPRF(): PRF | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 79 |  |  |         return $this->prf; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 80 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 81 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |      * @inheritDoc | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      * | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |      * @throws \SimpleSAML\XML\Exception\InvalidDOMElementException | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |      *   If the qualified name of the supplied element is wrong | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     public static function fromXML(DOMElement $xml): static | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 91 |  |  |         Assert::same($xml->localName, static::getLocalName(), InvalidDOMElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 92 |  |  |         Assert::same($xml->namespaceURI, static::getNamespaceURI(), InvalidDOMElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 93 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 94 |  |  |         $salt = Salt::getChildrenOfClass($xml); | 
            
                                                                        
                            
            
                                    
            
            
                | 95 |  |  |         Assert::minCount($salt, 1, MissingElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 96 |  |  |         Assert::maxCount($salt, 1, TooManyElementsException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 97 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 98 |  |  |         $iterationCount = IterationCount::getChildrenOfClass($xml); | 
            
                                                                        
                            
            
                                    
            
            
                | 99 |  |  |         Assert::minCount($iterationCount, 1, MissingElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 100 |  |  |         Assert::maxCount($iterationCount, 1, TooManyElementsException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 101 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 102 |  |  |         $keyLength = KeyLength::getChildrenOfClass($xml); | 
            
                                                                        
                            
            
                                    
            
            
                | 103 |  |  |         Assert::minCount($keyLength, 1, MissingElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 104 |  |  |         Assert::maxCount($keyLength, 1, TooManyElementsException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 105 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 106 |  |  |         $prf = PRF::getChildrenOfClass($xml); | 
            
                                                                        
                            
            
                                    
            
            
                | 107 |  |  |         Assert::minCount($prf, 1, MissingElementException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 108 |  |  |         Assert::maxCount($prf, 1, TooManyElementsException::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 109 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 110 |  |  |         return new static( | 
            
                                                                        
                            
            
                                    
            
            
                | 111 |  |  |             array_pop($salt), | 
            
                                                                        
                            
            
                                    
            
            
                | 112 |  |  |             array_pop($iterationCount), | 
            
                                                                        
                            
            
                                    
            
            
                | 113 |  |  |             array_pop($keyLength), | 
            
                                                                        
                            
            
                                    
            
            
                | 114 |  |  |             array_pop($prf), | 
            
                                                                        
                            
            
                                    
            
            
                | 115 |  |  |         ); | 
            
                                                                        
                            
            
                                    
            
            
                | 116 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 117 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 118 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 119 |  |  |     /** | 
            
                                                                        
                            
            
                                    
            
            
                | 120 |  |  |      * @inheritDoc | 
            
                                                                        
                            
            
                                    
            
            
                | 121 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     public function toXML(?DOMElement $parent = null): DOMElement | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |         $e = $this->instantiateParentElement($parent); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         $this->getSalt()->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |         $this->getIterationCount()->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         $this->getKeyLength()->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $this->getPRF()->toXML($e); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 131 |  |  |         return $e; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 132 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 133 |  |  | } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 134 |  |  |  |