Vendor/langcode-conv/zendframework/zend-filter/src/Encrypt/Openssl.php
protected function _setKeys($keys)
    {
        if (!is_array($keys)) {
            throw new Exception\InvalidArgumentException('Invalid options argument provided to filter');
        }

        foreach ($keys as $type => $key) {
            if (is_file($key) and is_readable($key)) {
                $file = fopen($key, 'r');
                $cert = fread($file, 8192);
                fclose($file);
            } else {
                $cert = $key;
                $key  = count($this->keys[$type]);
            }

            switch ($type) {
                case 'public':
                    $test = openssl_pkey_get_public($cert);
                    if ($test === false) {
                        throw new Exception\InvalidArgumentException("Public key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->keys['public'][$key] = $cert;
                    break;
                case 'private':
                    $test = openssl_pkey_get_private($cert, $this->passphrase);
                    if ($test === false) {
                        throw new Exception\InvalidArgumentException("Private key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->keys['private'][$key] = $cert;
                    break;
                case 'envelope':
                    $this->keys['envelope'][$key] = $cert;
                    break;
                default:
                    break;
            }
        }

        return $this;
    }
protected function _setKeys($keys)
    {
        if (!is_array($keys)) {
            throw new Exception\InvalidArgumentException('Invalid options argument provided to filter');
        }

        foreach ($keys as $type => $key) {
            if (is_file($key) and is_readable($key)) {
                $file = fopen($key, 'r');
                $cert = fread($file, 8192);
                fclose($file);
            } else {
                $cert = $key;
                $key  = count($this->keys[$type]);
            }

            switch ($type) {
                case 'public':
                    $test = openssl_pkey_get_public($cert);
                    if ($test === false) {
                        throw new Exception\InvalidArgumentException("Public key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->keys['public'][$key] = $cert;
                    break;
                case 'private':
                    $test = openssl_pkey_get_private($cert, $this->passphrase);
                    if ($test === false) {
                        throw new Exception\InvalidArgumentException("Private key '{$cert}' not valid");
                    }

                    openssl_free_key($test);
                    $this->keys['private'][$key] = $cert;
                    break;
                case 'envelope':
                    $this->keys['envelope'][$key] = $cert;
                    break;
                default:
                    break;
            }
        }

        return $this;
    }
protected function _setKeys ( $ keys ) { if ( ! is_array ( $ keys ) ) { throw new Exception \ InvalidArgumentException ( 'Invalid options argument provided to filter' ) ; } foreach ( $ keys as $ type => $ key ) { if ( is_file ( $ key ) and is_readable ( $ key ) ) { $ file = fopen ( $ key , 'r' ) ; $ cert = fread ( $ file , 8192 ) ; fclose ( $ file ) ; } else { $ cert = $ key ; $ key = count ( $ this -> keys [ $ type ] ) ; } switch ( $ type ) { case 'public' : $ test = openssl_pkey_get_public ( $ cert ) ; if ( $ test === false ) { throw new Exception \ InvalidArgumentException ( "Public key '{$cert}' not valid" ) ; } openssl_free_key ( $ test ) ; $ this -> keys [ 'public' ] [ $ key ] = $ cert ; break ; case 'private' : $ test = openssl_pkey_get_private ( $ cert , $ this -> passphrase ) ; if ( $ test === false ) { throw new Exception \ InvalidArgumentException ( "Private key '{$cert}' not valid" ) ; } openssl_free_key ( $ test ) ; $ this -> keys [ 'private' ] [ $ key ] = $ cert ; break ; case 'envelope' : $ this -> keys [ 'envelope' ] [ $ key ] = $ cert ; break ; default : break ; } } return $ this ; }
Sets the encryption keys

@param  string|array $keys Key with type association
@return self
@throws Exception\InvalidArgumentException
Sets the encryption keys