| 1 |
secretstream reference vectors |
| 2 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 3 |
|
| 4 |
Since libsodium's tests do not provide reference data for the secretstream |
| 5 |
construction, the implementation is verified with a |
| 6 |
``secretstream_test_vector`` utility program that produces custom test vectors |
| 7 |
by making specific calls to the libsodium API. |
| 8 |
|
| 9 |
To build the ``secretstream_test_vector`` you need a ``C`` language compiler, |
| 10 |
a prebuilt libsodium library more recent than version 1.0.14 and the |
| 11 |
corresponding include headers. |
| 12 |
|
| 13 |
In a UNIX-like programming environment you should then execute: |
| 14 |
|
| 15 |
.. code-block:: bash |
| 16 |
|
| 17 |
$ cc -o secretstream_test_vector secretstream_test_vector.c -lsodium -lc |
| 18 |
|
| 19 |
If you prefer using a locally compiled installation of the bundled sources, |
| 20 |
refer to :ref:`building-a-local-library` and then run: |
| 21 |
|
| 22 |
.. code-block:: bash |
| 23 |
|
| 24 |
$ cc -o secretstream_test_vector secretstream_test_vector.c \ |
| 25 |
${SODIUMINCL} ${SODIUMLIB} -lsodium -lc |
| 26 |
|
| 27 |
Vector generation |
| 28 |
""""""""""""""""" |
| 29 |
|
| 30 |
.. code-block:: bash |
| 31 |
|
| 32 |
$ ./secretstream_test_vector -h |
| 33 |
Usage: secretstream_test_vector [-c num_chunks] [-r] |
| 34 |
|
| 35 |
When called, the program will output a JSON dictionary containing |
| 36 |
``key``, ``header``, and ``chunks``. The ``chunks`` is a list of individual |
| 37 |
messages passed to ``crypto_secretstream_xchacha20poly1305_push`` containing |
| 38 |
``tag``, ``message``, ``ad`` and ``ciphertext`` keys. |
| 39 |
|
| 40 |
Source code for the vector checker utility |
| 41 |
"""""""""""""""""""""""""""""""""""""""""" |
| 42 |
|
| 43 |
The source code for ``secretstream_test_vector`` is available inside |
| 44 |
the ``docs/vectors/c-source`` directory of PyNaCl distribution |
| 45 |
and can also be directly downloaded from |
| 46 |
:download:`secretstream_test_vector.c <./c-source/secretstream_test_vector.c>`. |
| 47 |
|
| 48 |
.. |
| 49 |
put the and... sentence under a ..only:: builder_html |
| 50 |
when readthedocs begins to correctly support the directive |
| 51 |
|
| 52 |
.. literalinclude:: c-source/secretstream_test_vector.c |
| 53 |
:language: c |
| 54 |
:caption: secretstream_test_vector.c |