| 1 |
Argon2 constructs reference vectors |
| 2 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 3 |
|
| 4 |
Since libsodium implements a different API for argon2 constructs |
| 5 |
than the one exposed by the reference implementation available at |
| 6 |
`The password hash Argon2... <https://github.com/P-H-C/phc-winner-argon2/>`, |
| 7 |
the ``kats`` data provided along to the reference implementation sources |
| 8 |
cannot be directly used as test vectors in PyNaCl tests. |
| 9 |
|
| 10 |
Therefore, we are using a python driver for the command line |
| 11 |
``argon2``, which can be built following the instruction in the |
| 12 |
reference implementation sources. |
| 13 |
|
| 14 |
|
| 15 |
Vector generation |
| 16 |
""""""""""""""""" |
| 17 |
|
| 18 |
The ``argondriver.py`` requires setting, via the command line option |
| 19 |
``-x``, the path to the argon2 executable; and as a default generates |
| 20 |
hex-encoded raw hash data on standard output. |
| 21 |
|
| 22 |
Setting the ``-e`` option on the command line allows generating |
| 23 |
modular crypt formatted hashes. |
| 24 |
|
| 25 |
The other command line options influence the minimum and maximum sizes |
| 26 |
of generated parameters as shown in the driver's command line help, |
| 27 |
which is printed by inserting the ``-h`` option in the command line. |
| 28 |
|
| 29 |
To generate vector data files in ``tests/data``, the argondriver.py |
| 30 |
have been called to generate password hashes with parameters compatible |
| 31 |
with ``libsodium``'s implementation; in particular, the minimum operations |
| 32 |
count must be 3 for ``argon2i`` and 1 for ``argon2id``, and the salt |
| 33 |
length must be 16 for raw hashes, and can vary for modular crypt formatted |
| 34 |
hashes. |
| 35 |
|
| 36 |
The full command lines used in generating the vectors are: |
| 37 |
|
| 38 |
for raw argon2i |
| 39 |
.. code-block:: bash |
| 40 |
|
| 41 |
python3 docs/vectors/python/argondriver.py \ |
| 42 |
-x ~/phc-winner-argon2/argon2 \ |
| 43 |
-c argon2i \ |
| 44 |
-s 16 -S 16 -p 8 -P 16 -m 14 -M 18 \ |
| 45 |
-l 18 -L 32 -t 3 -T 5 -n 10 \ |
| 46 |
-w tests/data/raw_argon2id_hashes.json |
| 47 |
|
| 48 |
for raw argon2id |
| 49 |
.. code-block:: bash |
| 50 |
|
| 51 |
python3 docs/vectors/python/argondriver.py \ |
| 52 |
-x ~/phc-winner-argon2/argon2 \ |
| 53 |
-c argon2id \ |
| 54 |
-s 16 -S 16 -p 8 -P 16 -m 14 -M 18 \ |
| 55 |
-l 18 -L 32 -t 1 -T 5 -n 10 \ |
| 56 |
-w tests/data/raw_argon2id_hashes.json |
| 57 |
|
| 58 |
for modular crypt argon2i |
| 59 |
.. code-block:: bash |
| 60 |
|
| 61 |
python3 docs/vectors/python/argondriver.py \ |
| 62 |
-x ~/phc-winner-argon2/argon2 \ |
| 63 |
-c argon2i -e \ |
| 64 |
-s 8 -S 16 -p 8 -P 16 -m 14 -M 18 \ |
| 65 |
-l 18 -L 32 -t 3 -T 5 -n 10 \ |
| 66 |
-w tests/data/modular_crypt_argon2id_hashes.json |
| 67 |
|
| 68 |
for modular crypt argon2id |
| 69 |
.. code-block:: bash |
| 70 |
|
| 71 |
python3 docs/vectors/python/argondriver.py \ |
| 72 |
-x ~/phc-winner-argon2/argon2 \ |
| 73 |
-c argon2id -e \ |
| 74 |
-s 8 -S 16 -p 8 -P 16 -m 14 -M 18 \ |
| 75 |
-l 18 -L 32 -t 1 -T 5 -n 10 \ |
| 76 |
-w tests/data/modular_crypt_argon2id_hashes.json |
| 77 |
|
| 78 |
|
| 79 |
Code for the vector generator driver |
| 80 |
"""""""""""""""""""""""""""""""""""" |
| 81 |
|
| 82 |
The code for ``argondriver.py`` is available inside |
| 83 |
the ``docs/vectors/python`` directory of PyNaCl distribution |
| 84 |
and can also be directly downloaded from |
| 85 |
:download:`argondriver.py <./python/argondriver.py>`. |
| 86 |
|
| 87 |
.. |
| 88 |
put the and... sentence under a ..only:: builder_html |
| 89 |
when readthedocs begins to correctly support the directive |
| 90 |
|
| 91 |
.. literalinclude:: python/argondriver.py |
| 92 |
:language: python |
| 93 |
:caption: argondriver.py |