| 1 |
Blake2b reference vectors |
| 2 |
^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 3 |
|
| 4 |
While the blake2b construction is a keyed hash and variable output |
| 5 |
length algorithm which can optionally be initialized with limited |
| 6 |
size salt and personalization parameters, the `known answers`_ json |
| 7 |
file in the reference `blake2`_ sources just provides vectors for |
| 8 |
default length hash with empty salt and personalization. |
| 9 |
|
| 10 |
To fill this test gap, we used both the pyblake and the libsodium implemented |
| 11 |
generators provided by `crypto test vectors`_ for the `blake2b` mechanism |
| 12 |
to generate twenty vectors in each of |
| 13 |
`test/data/crypto-test-vectors-blake2-nosalt-nopersonalization.txt` |
| 14 |
and |
| 15 |
`test/data/crypto-test-vectors-blake2-salt-personalization.txt` |
| 16 |
|
| 17 |
Vector generation |
| 18 |
""""""""""""""""" |
| 19 |
|
| 20 |
After cloning the github project with |
| 21 |
|
| 22 |
.. code-block:: bash |
| 23 |
|
| 24 |
$ git clone https://github.com/jedisct1/crypto-test-vectors.git |
| 25 |
|
| 26 |
the needed source files will be available in the `nosalt-nopersonalization` |
| 27 |
and `salt-personalization` subdirectories of |
| 28 |
`crypto-test-vectors/crypto/hash/blake2/blake2b/`. |
| 29 |
|
| 30 |
To run the python generators, after ensuring the needed `pyblake2`_ module |
| 31 |
is available in the python environment, it will be enough to run the following |
| 32 |
commands at the shell prompt: |
| 33 |
|
| 34 |
.. code-block:: bash |
| 35 |
|
| 36 |
$ BLAKE="${PWD}/crypto-test-vectors/crypto/hash/blake2/blake2b" |
| 37 |
$ NOPERS="${BLAKE}/nosalt-nopersonalization/generators" |
| 38 |
$ PERSON="${BLAKE}/salt-personalization/generators" |
| 39 |
$ python "${NOPERS}/pyblake2/generator.py" 10 > py_nopers_vectors |
| 40 |
$ python "${PERSON}/pyblake2/generator.py" 10 > py_pers_vectors |
| 41 |
|
| 42 |
On linux systems, after installing the required `libsodium` development |
| 43 |
package, the C-language generators, can get built by running: |
| 44 |
|
| 45 |
.. code-block:: bash |
| 46 |
|
| 47 |
$ BLAKE="${PWD}/crypto-test-vectors/crypto/hash/blake2/blake2b" |
| 48 |
$ NOPERS="${BLAKE}/nosalt-nopersonalization/generators" |
| 49 |
$ PERSON="${BLAKE}/salt-personalization/generators" |
| 50 |
$ for i in "${NOPERS}/libsodium" "${PERSON}/libsodium"; do (cd "${i}" && make); done |
| 51 |
|
| 52 |
and then run by executing: |
| 53 |
|
| 54 |
.. code-block:: bash |
| 55 |
|
| 56 |
$ BLAKE="${PWD}/crypto-test-vectors/crypto/hash/blake2/blake2b" |
| 57 |
$ NOPERS="${BLAKE}/nosalt-nopersonalization/generators" |
| 58 |
$ PERSON="${BLAKE}/salt-personalization/generators" |
| 59 |
$ "${NOPERS}/libsodium/generator" 10 > py_nopers_vectors_c |
| 60 |
$ "${PERSON}/libsodium/generator" 10 > py_pers_vectors_c |
| 61 |
|
| 62 |
|
| 63 |
.. _blake2: https://github.com/BLAKE2/BLAKE2 |
| 64 |
|
| 65 |
.. _known answers: |
| 66 |
https://github.com/BLAKE2/BLAKE2/blob/master/testvectors/blake2-kat.json |
| 67 |
|
| 68 |
.. _crypto test vectors: https://github.com/jedisct1/crypto-test-vectors |
| 69 |
|
| 70 |
.. _pyblake2: https://pythonhosted.org/pyblake2/ |