php-doc-en/reference/openssl/functions/openssl-seal.xml
Andrey Gromov d91faeacc8 remove duplicate changelog section
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@343577 c90b9560-bf6c-de11-be94-00142212c4b1
2017-12-05 11:10:28 +00:00

192 lines
5.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.openssl-seal">
<refnamediv>
<refname>openssl_seal</refname>
<refpurpose>Seal (encrypt) data</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>int</type><methodname>openssl_seal</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam><type>string</type><parameter role="reference">sealed_data</parameter></methodparam>
<methodparam><type>array</type><parameter role="reference">env_keys</parameter></methodparam>
<methodparam><type>array</type><parameter>pub_key_ids</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>method</parameter><initializer>"RC4"</initializer></methodparam>
<methodparam choice="opt"><type>string</type><parameter role="reference">iv</parameter></methodparam>
</methodsynopsis>
<para>
<function>openssl_seal</function> seals (encrypts)
<parameter>data</parameter> by using the given <parameter>method</parameter> with a randomly generated
secret key. The key is encrypted with each of the public keys
associated with the identifiers in <parameter>pub_key_ids</parameter>
and each encrypted key is returned
in <parameter>env_keys</parameter>. This means that one can send
sealed data to multiple recipients (provided one has obtained their
public keys). Each recipient must receive both the sealed data and
the envelope key that was encrypted with the recipient's public key.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>data</parameter></term>
<listitem>
<para>
The data to seal.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>sealed_data</parameter></term>
<listitem>
<para>
The sealed data.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>env_keys</parameter></term>
<listitem>
<para>
Array of encrypted keys.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>pub_key_ids</parameter></term>
<listitem>
<para>
Array of public key resource identifiers.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>method</parameter></term>
<listitem>
<para>
The cipher method.
</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>
Returns the length of the sealed data on success, or &false; on error.
If successful the sealed data is returned in
<parameter>sealed_data</parameter>, and the envelope keys in
<parameter>env_keys</parameter>.
</para>
</refsect1>
<refsect1 role="changelog"><!-- {{{ -->
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>7.0.0</entry>
<entry>
The <parameter>iv</parameter> has been added.
</entry>
</row>
<row>
<entry>5.3.0</entry>
<entry>
The <parameter>method</parameter> has been added.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1><!-- }}} -->
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>openssl_seal</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
// $data is assumed to contain the data to be sealed
// fetch public keys for our recipients, and ready them
$fp = fopen("/src/openssl-0.9.6/demos/maurice/cert.pem", "r");
$cert = fread($fp, 8192);
fclose($fp);
$pk1 = openssl_get_publickey($cert);
// Repeat for second recipient
$fp = fopen("/src/openssl-0.9.6/demos/sign/cert.pem", "r");
$cert = fread($fp, 8192);
fclose($fp);
$pk2 = openssl_get_publickey($cert);
// seal message, only owners of $pk1 and $pk2 can decrypt $sealed with keys
// $ekeys[0] and $ekeys[1] respectively.
openssl_seal($data, $sealed, $ekeys, array($pk1, $pk2));
// free the keys from memory
openssl_free_key($pk1);
openssl_free_key($pk2);
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>openssl_open</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
-->