Jose\Algorithm\KeyEncryption\PBES2AESKW::unwrapKey PHP Method

unwrapKey() public method

public unwrapKey ( Jose\Object\JWKInterface $key, $encrypted_cek, array $header )
$key Jose\Object\JWKInterface
$header array
    public function unwrapKey(JWKInterface $key, $encrypted_cek, array $header)
    {
        $this->checkKey($key);
        $this->checkHeaderAlgorithm($header);
        $this->checkHeaderAdditionalParameters($header);
        $wrapper = $this->getWrapper();
        $hash_algorithm = $this->getHashAlgorithm();
        $key_size = $this->getKeySize();
        $salt = $header['alg'] . "" . Base64Url::decode($header['p2s']);
        $count = $header['p2c'];
        $password = Base64Url::decode($key->get('k'));
        $derived_key = hash_pbkdf2($hash_algorithm, $password, $salt, $count, $key_size, true);
        return $wrapper->unwrap($derived_key, $encrypted_cek);
    }