mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-19 18:38:55 +00:00
192 lines
5.3 KiB
XML
192 lines
5.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<refentry xml:id="function.openssl-open" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>openssl_open</refname>
|
|
<refpurpose>Open sealed data</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>openssl_open</methodname>
|
|
<methodparam><type>string</type><parameter>data</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter role="reference">output</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>encrypted_key</parameter></methodparam>
|
|
<methodparam><type class="union"><type>OpenSSLAsymmetricKey</type><type>OpenSSLCertificate</type><type>array</type><type>string</type></type><parameter>private_key</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>cipher_algo</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>iv</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>openssl_open</function> opens (decrypts)
|
|
<parameter>data</parameter> using the private key associated with
|
|
the key identifier <parameter>private_key</parameter> and the envelope key
|
|
<parameter>encrypted_key</parameter>, and fills
|
|
<parameter>output</parameter> with the decrypted data.
|
|
The envelope key is generated when the
|
|
data are sealed and can only be used by one specific private key. See
|
|
<function>openssl_seal</function> for more information.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>data</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>output</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
If the call is successful the opened data is returned in this
|
|
parameter.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>encrypted_key</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>private_key</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>cipher_algo</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The cipher method.
|
|
<caution>
|
|
<simpara>
|
|
The default value (<literal>'RC4'</literal>) is considered insecure.
|
|
It is strongly recommended to explicitly specify a secure cipher method.
|
|
</simpara>
|
|
</caution>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>iv</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The initialization vector.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>private_key</parameter> accepts an <classname>OpenSSLAsymmetricKey</classname>
|
|
or <classname>OpenSSLCertificate</classname> instance now;
|
|
previously, a &resource; of type <literal>OpenSSL key</literal> or <literal>OpenSSL X.509 CSR</literal>
|
|
was accepted.
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>cipher_algo</parameter> is no longer an optional parameter.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>openssl_open</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// $sealed and $env_key are assumed to contain the sealed data
|
|
// and our envelope key, both given to us by the sealer.
|
|
|
|
// fetch private key from file and ready it
|
|
$fp = fopen("/src/openssl-0.9.6/demos/sign/key.pem", "r");
|
|
$priv_key = fread($fp, 8192);
|
|
fclose($fp);
|
|
$pkeyid = openssl_get_privatekey($priv_key);
|
|
|
|
// decrypt the data and store it in $open
|
|
if (openssl_open($sealed, $open, $env_key, $pkeyid)) {
|
|
echo "here is the opened data: ", $open;
|
|
} else {
|
|
echo "failed to open data";
|
|
}
|
|
|
|
// free the private key from memory
|
|
openssl_free_key($pkeyid);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>openssl_seal</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|