Skip to content

Commit

Permalink
[PHP 8.4] Add new Sodium functions and constants
Browse files Browse the repository at this point in the history
Signed-off-by: Maurício Meneghini Fauth <[email protected]>
  • Loading branch information
MauricioFauth committed Oct 16, 2024
1 parent e4efbf3 commit e4796fd
Show file tree
Hide file tree
Showing 8 changed files with 598 additions and 0 deletions.
88 changes: 88 additions & 0 deletions reference/sodium/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,94 @@
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis128l-keybytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS128L_KEYBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis128l-nsecbytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS128L_NSECBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis128l-npubbytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS128L_NPUBBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis128l-abytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS128L_ABYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis256-keybytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS256_KEYBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis256-nsecbytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS256_NSECBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis256-npubbytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS256_NPUBBYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aegis256-abytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AEGIS256_ABYTES</constant>
(<type>int</type>)
</term>
<listitem>
<simpara>
Available as of PHP 8.4.0.
</simpara>
</listitem>
</varlistentry>
<varlistentry xml:id="constant.sodium-crypto-aead-aes256gcm-keybytes">
<term>
<constant>SODIUM_CRYPTO_AEAD_AES256GCM_KEYBYTES</constant>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sodium-crypto-aead-aegis128l-decrypt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sodium_crypto_aead_aegis128l_decrypt</refname>
<refpurpose>Verify then decrypt a message with AEGIS-128L</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>string</type><type>false</type></type><methodname>sodium_crypto_aead_aegis128l_decrypt</methodname>
<methodparam><type>string</type><parameter>ciphertext</parameter></methodparam>
<methodparam><type>string</type><parameter>additional_data</parameter></methodparam>
<methodparam><type>string</type><parameter>nonce</parameter></methodparam>
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>key</parameter></methodparam>
</methodsynopsis>
<para>
Verify then decrypt a message with AEGIS-128L.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>ciphertext</parameter></term>
<listitem>
<para>
Must be in the format provided by <function>sodium_crypto_aead_aegis128l_encrypt</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>additional_data</parameter></term>
<listitem>
<para>
Additional, authenticated data. This is used in the verification of the authentication tag
appended to the ciphertext, but it is not encrypted or stored in the ciphertext.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>nonce</parameter></term>
<listitem>
<para>
A number that must be only used once, per message.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>key</parameter></term>
<listitem>
<para>
Encryption key (128-bit).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the plaintext on success, &return.falseforfailure;.
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>sodium_crypto_aead_aegis128l_encrypt</function></member>
<member><function>sodium_crypto_aead_aegis128l_keygen</function></member>
</simplelist>
</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
-->
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sodium-crypto-aead-aegis128l-encrypt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sodium_crypto_aead_aegis128l_encrypt</refname>
<refpurpose>Encrypt then authenticate a message with AEGIS-128L</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>sodium_crypto_aead_aegis128l_encrypt</methodname>
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>message</parameter></methodparam>
<methodparam><type>string</type><parameter>additional_data</parameter></methodparam>
<methodparam><type>string</type><parameter>nonce</parameter></methodparam>
<methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>key</parameter></methodparam>
</methodsynopsis>
<para>
Encrypt then authenticate a message with AEGIS-128L.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>message</parameter></term>
<listitem>
<para>
The plaintext message to encrypt.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>additional_data</parameter></term>
<listitem>
<para>
Additional, authenticated data. This is used in the verification of the authentication tag
appended to the ciphertext, but it is not encrypted or stored in the ciphertext.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>nonce</parameter></term>
<listitem>
<para>
A number that must be only used once, per message.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>key</parameter></term>
<listitem>
<para>
Encryption key (128-bit).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the ciphertext and authentication tag as a string of raw binary bytes.
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>sodium_crypto_aead_aegis128l_decrypt</function></member>
<member><function>sodium_crypto_aead_aegis128l_keygen</function></member>
</simplelist>
</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
-->
60 changes: 60 additions & 0 deletions reference/sodium/functions/sodium-crypto-aead-aegis128l-keygen.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sodium-crypto-aead-aegis128l-keygen" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>sodium_crypto_aead_aegis128l_keygen</refname>
<refpurpose>Generate a random AEGIS-128L key</refpurpose>
</refnamediv>

<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>sodium_crypto_aead_aegis128l_keygen</methodname>
<void />
</methodsynopsis>
<para>
Generate a random key for use with <function>sodium_crypto_aead_aegis128l_encrypt</function> and
<function>sodium_crypto_aead_aegis128l_decrypt</function>.
</para>
</refsect1>

<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>

<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns a 128-bit random key.
</para>
</refsect1>

<refsect1 role="seealso">
&reftitle.seealso;
<simplelist>
<member><function>sodium_crypto_aead_aegis128l_decrypt</function></member>
<member><function>sodium_crypto_aead_aegis128l_encrypt</function></member>
</simplelist>
</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
-->
Loading

0 comments on commit e4796fd

Please sign in to comment.