1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sodium-crypto-box-seal" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sodium_crypto_box_seal</refname>
<refpurpose>Anonymous public-key encryption</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>sodium_crypto_box_seal</methodname>
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>message</parameter></methodparam>
<methodparam><type>string</type><parameter>public_key</parameter></methodparam>
</methodsynopsis>
<para>
Encrypt a message such that only the recipient can decrypt it.
</para>
<para>
Unlike with <function>sodium_crypto_box</function>, you only need to know the recipient's
public key to use <function>sodium_crypto_box_seal</function>. One consequence of this
convenience, however, is that the ciphertext isn't bound to a static public key,
and is therefore not authenticated. Hence, anonymous public-key encryption.
</para>
<para>
<function>sodium_crypto_box_seal</function> still provides ciphertext integrity. Just not
sender identity authentication.
</para>
<para>
If you also need sender authentication, the <function>sodium_crypto_sign</function> functions
are likely the best place to start.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
The message to encrypt.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>public_key</parameter></term>
<listitem>
<para>
The public key that corresponds to the only key that can decrypt the message.
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
A ciphertext string in the format of (one-time public key, encrypted message, authentication tag).
</para>
</refsect1>
<refsect1 role="examples"><!-- {{{ -->
&reftitle.examples;
<example xml:id="sodium-crypto-box-seal.example.basic"><!-- {{{ -->
<title><function>sodium_crypto_box_seal</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$keypair = sodium_crypto_box_keypair();
$public_key = sodium_crypto_box_publickey($keypair);
// Obfuscated plaintext to make the example more fun
$plaintext_b64 = "V3JpdGluZyBzb2Z0d2FyZSBpbiBQSFAgY2FuIGJlIGEgZGVsaWdodCE=";
$decoded_plaintext = sodium_base642bin($plaintext_b64, SODIUM_BASE64_VARIANT_ORIGINAL);
$sealed = sodium_crypto_box_seal($decoded_plaintext, $public_key);
var_dump(base64_encode($sealed));
$opened = sodium_crypto_box_seal_open($sealed, $keypair);
var_dump($opened);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
string(120) "oRBXXAV4iQBrxlV4A21Bord8Yo/D8ZlrIIGNyaRCcGBfpz0map52I3xq6l+CST+1NSgQkbV+HiYyFjXWiWiaCGupGf+zl4bgWj/A9Adtem7Jt3h3emrMsLw="
string(41) "Writing software in PHP can be a delight!"
]]>
</screen>
</example><!-- }}} -->
</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
-->
|