File: sodium-crypto-pwhash-scryptsalsa208sha256.xml

package info (click to toggle)
php-doc 20250827~git.abe740d%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 71,968 kB
  • sloc: xml: 985,760; php: 25,504; javascript: 671; sh: 177; makefile: 37
file content (103 lines) | stat: -rw-r--r-- 4,066 bytes parent folder | download | duplicates (2)
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
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.sodium-crypto-pwhash-scryptsalsa208sha256" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>sodium_crypto_pwhash_scryptsalsa208sha256</refname>
  <refpurpose>Derives a key from a password, using scrypt</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <type>string</type><methodname>sodium_crypto_pwhash_scryptsalsa208sha256</methodname>
   <methodparam><type>int</type><parameter>length</parameter></methodparam>
   <methodparam><modifier role="attribute">#[\SensitiveParameter]</modifier><type>string</type><parameter>password</parameter></methodparam>
   <methodparam><type>string</type><parameter>salt</parameter></methodparam>
   <methodparam><type>int</type><parameter>opslimit</parameter></methodparam>
   <methodparam><type>int</type><parameter>memlimit</parameter></methodparam>
  </methodsynopsis>
  <para>
   This is the scrypt counterpart to <function>sodium_crypto_pwhash</function>.
  </para>
  <para>
   A common reason to use this particular function is to derive the seeds for cryptographic keys from a password and salt,
   and then use these seeds to generate the actual keys needed for some purpose (e.g. <function>sodium_crypto_sign_detached</function>).
  </para>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>length</parameter></term>
    <listitem>
     <para>
      The length of the password hash to generate, in bytes.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>password</parameter></term>
    <listitem>
     <para>
      The password to generate a hash for.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>salt</parameter></term>
    <listitem>
     <para>
      A salt to add to the password before hashing. The salt should be unpredictable, ideally generated from a good random number source such as <function>random_bytes</function>, and have a length of at least <constant>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_SALTBYTES</constant> bytes.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>opslimit</parameter></term>
    <listitem>
     <para>
      Represents a maximum amount of computations to perform. Raising this number will make the function require more CPU cycles to compute a key. There are some constants available to set the operations limit to appropriate values depending on intended use, in order of strength: <constant>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_INTERACTIVE</constant> and <constant>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_OPSLIMIT_SENSITIVE</constant>.
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>memlimit</parameter></term>
    <listitem>
     <para>
      The maximum amount of RAM that the function will use, in bytes. There are constants to help you choose an appropriate value, in order of size: <constant>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_INTERACTIVE</constant> and <constant>SODIUM_CRYPTO_PWHASH_SCRYPTSALSA208SHA256_MEMLIMIT_SENSITIVE</constant>. Typically these should be paired with the matching <parameter>opslimit</parameter> values.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   A string of bytes of the desired length.
  </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
-->