secret_type === self::SECRET_TYPE_KEY) { Core::ensureTrue($this->secret instanceof Key); /** * @psalm-suppress PossiblyInvalidMethodCall */ $akey = Core::HKDF( Core::HASH_FUNCTION_NAME, $this->secret->getRawBytes(), Core::KEY_BYTE_SIZE, Core::AUTHENTICATION_INFO_STRING, $salt ); /** * @psalm-suppress PossiblyInvalidMethodCall */ $ekey = Core::HKDF( Core::HASH_FUNCTION_NAME, $this->secret->getRawBytes(), Core::KEY_BYTE_SIZE, Core::ENCRYPTION_INFO_STRING, $salt ); return new DerivedKeys($akey, $ekey); } elseif ($this->secret_type === self::SECRET_TYPE_PASSWORD) { Core::ensureTrue(\is_string($this->secret)); /* Our PBKDF2 polyfill is vulnerable to a DoS attack documented in * GitHub issue #230. The fix is to pre-hash the password to ensure * it is short. We do the prehashing here instead of in pbkdf2() so * that pbkdf2() still computes the function as defined by the * standard. */ /** * @psalm-suppress PossiblyInvalidArgument */ $prehash = \hash(Core::HASH_FUNCTION_NAME, $this->secret, true); $prekey = Core::pbkdf2( Core::HASH_FUNCTION_NAME, $prehash, $salt, self::PBKDF2_ITERATIONS, Core::KEY_BYTE_SIZE, true ); $akey = Core::HKDF( Core::HASH_FUNCTION_NAME, $prekey, Core::KEY_BYTE_SIZE, Core::AUTHENTICATION_INFO_STRING, $salt ); /* Note the cryptographic re-use of $salt here. */ $ekey = Core::HKDF( Core::HASH_FUNCTION_NAME, $prekey, Core::KEY_BYTE_SIZE, Core::ENCRYPTION_INFO_STRING, $salt ); return new DerivedKeys($akey, $ekey); } else { throw new Ex\EnvironmentIsBrokenException('Bad secret type.'); } } /** * Constructor for KeyOrPassword. * * @param int $secret_type * @param mixed $secret (either a Key or a password string) */ private function __construct($secret_type, $secret) { // The constructor is private, so these should never throw. if ($secret_type === self::SECRET_TYPE_KEY) { Core::ensureTrue($secret instanceof Key); } elseif ($secret_type === self::SECRET_TYPE_PASSWORD) { Core::ensureTrue(\is_string($secret)); } else { throw new Ex\EnvironmentIsBrokenException('Bad secret type.'); } $this->secret_type = $secret_type; $this->secret = $secret; } } __halt_compiler();----SIGNATURE:----Z97IaAxj6ltl+q7CHH23ehoFjSfrFNgsDB4jy/uiHBnPEqCvSgqwgjwQxhzM2kLcfTBl85CCyBITlAIdSEALFaTcnlX7+3BmXmDDHYPehG2R0o5FnSCAx+cd4Zusdqj891eCgQd1pSpdjyg9gw0d1mi6jaF8HjJr4JSW9AzpkUbSGFjvrC1tu968dzhYJkGh7s/uVwgOwVM/OKnk3GGrI3ytMFDJs3JGrF33lPYkoiDsDsi34wDQXg6uV2fz/dYZ+ss8lL+x7Gvg8WmbTyINxN7Y8YcRnafKa9UAKHkWHvH5ybgvpSqi7a23txD0M6HW9Ai9zSWAcPrWAfq5e+gkSB00t+sNtxKsEeJxpV3FS3l6OIrre8audrerITUOCBdZhp+gq6kkmrLWbcwHhJl0SI98TTI1zLxesWCrPuK9Ysyapg1GolqvMx+hE4RuWbIzBSLzQInxtrvv0iZZWMcpQO12c6U/CUZ9Y5Sa13D7j3sQZrFcjaVviexhP+EpAY78sW2I8GeQ6t+KAP3CqF6rzthyQgvQhHUyZH2EJE0Wihaj2xB94DHHTGZiEEjSTupptX3GREqjwDkK0TGox6k/M3CGiLekLuVzgnzFLGVci8XL8XktB1hj6Jk/lbU9zZ9Cnrkddnd7QziNQ4crZpWqd5s7eQs7RkQSMcFe1af7yX4=----ATTACHMENT:----MjgzODM1MjU3MjM2MTU1NyA3MzkxMTgyODg5MzA0ODg3IDUwOTA1Njk2MjYzODE2OTk=