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:----ol35UKiJDQrz+oI7jPWMQoC0AQpcwtosSuLINZ+MuzJTw85C8Y+48AT3AdFQhlpPBf1pYtccIwE0L2uAH05a6nOnGuqWB/UF9qD3ialP8sMMXmNK/MbMn1FPrPBxo1hWOhE2fKxLqtl0VAsUkLfALCZCfbDpxg2h/bRvoGPXa5f2STHo/csZYeVqp/LP58y5QcUjOXgxM6up5jP8xtTQCMOW7Occ3iTbJSOooWauOy0h1P91zPdNeDMa6fETGw6+F0cbys9xqeqHI9tm95RxatUcyBpI1aZlrb3+q8NqtsJ15kWz4s8o87k9T6LoSpDMCbroLvI0Pw856QFwH4F0GjOe6lJgGxyE0O/LcttcUnQ+XIuzk+9JafBSB/KyFXBQElHxpjuaStq6rR0oY/iyVLKGYyhfpoljIhmePc3G85ujbN/hjLb/Yqgh1p2sK89CrWc7tWP1o/6uujRqOVwB0MOnw56TAOFqQU9o8zIM4WR/B6BFna7tRX/y/7WpGrSXhU76K87Dm9amv9OabpGKfekHS9M4NESEAOGwM2grPpeynoSnt39T/cDpWkDJhgAjzAlIVhH1jCFF3GTGWnJwM6aDUayzbkCi21HU+LtZ/oC0+x06CEX3QlvTxiHmRDVhZa1tRnIClWWT3Dg2+EG+4SiUCXfqGeiBMevTVH6DZbY=----ATTACHMENT:----NTA0Njc5NDM2NTA1NzU4NSAzOTUwMzkwMzIwNzI5Mjc1IDMyMzE2MjEwNjA5MTI1MzA=