php-doc-en/reference/openssl/functions/openssl-seal.xml
Jakub Vrana 367fd4533b Output parameters with &
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@147873 c90b9560-bf6c-de11-be94-00142212c4b1
2004-01-05 13:17:42 +00:00

92 lines
3 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.6 $ -->
<!-- splitted from ./en/functions/openssl.xml, last change in rev 1.1 -->
<refentry id="function.openssl-seal">
<refnamediv>
<refname>openssl_seal</refname>
<refpurpose>Seal (encrypt) data</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>int</type><methodname>openssl_seal</methodname>
<methodparam><type>string</type><parameter>data</parameter></methodparam>
<methodparam><type>string</type><parameter>&amp;sealed_data</parameter></methodparam>
<methodparam><type>array</type><parameter>&amp;env_keys</parameter></methodparam>
<methodparam><type>array</type><parameter>pub_key_ids</parameter></methodparam>
</methodsynopsis>
<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>
<para>
<function>openssl_seal</function> seals (encrypts)
<parameter>data</parameter> by using RC4 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>
<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>
<simpara>
See also <function>openssl_open</function>.
</simpara>
</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:"../../../../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
-->