File: secretstream_vectors.rst

package info (click to toggle)
python-nacl 1.5.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 14,776 kB
  • sloc: ansic: 45,889; python: 7,249; sh: 6,752; asm: 2,974; makefile: 1,011; cs: 35; xml: 30; pascal: 11
file content (54 lines) | stat: -rw-r--r-- 1,935 bytes parent folder | download | duplicates (4)
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
secretstream reference vectors
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Since libsodium's tests do not provide reference data for the secretstream
construction, the implementation is verified with a
``secretstream_test_vector`` utility program that produces custom test vectors
by making specific calls to the libsodium API.

To build the ``secretstream_test_vector`` you need a ``C`` language compiler,
a prebuilt libsodium library more recent than version 1.0.14 and the
corresponding include headers.

In a UNIX-like programming environment you should then execute:

.. code-block:: bash

    $ cc -o secretstream_test_vector secretstream_test_vector.c -lsodium -lc

If you prefer using a locally compiled installation of the bundled sources,
refer to :ref:`building-a-local-library` and then run:

.. code-block:: bash

    $ cc -o secretstream_test_vector secretstream_test_vector.c \
      ${SODIUMINCL} ${SODIUMLIB} -lsodium -lc

Vector generation
"""""""""""""""""

.. code-block:: bash

    $ ./secretstream_test_vector -h
    Usage: secretstream_test_vector [-c num_chunks] [-r]

When called, the program will output a JSON dictionary containing
``key``, ``header``, and ``chunks``. The ``chunks`` is a list of individual
messages passed to ``crypto_secretstream_xchacha20poly1305_push`` containing
``tag``, ``message``, ``ad`` and ``ciphertext`` keys.

Source code for the vector checker utility
""""""""""""""""""""""""""""""""""""""""""

The source code for ``secretstream_test_vector`` is available inside
the ``docs/vectors/c-source`` directory of PyNaCl distribution
and can also be directly downloaded from
:download:`secretstream_test_vector.c <./c-source/secretstream_test_vector.c>`.

..
    put the and... sentence under a ..only:: builder_html
    when readthedocs begins to correctly support the directive

.. literalinclude:: c-source/secretstream_test_vector.c
    :language: c
    :caption: secretstream_test_vector.c