paragonie / pecl-libsodium-doc

Free Online Documentation for the Libsodium PHP Extension

Home Page:https://paragonie.com/book/pecl-libsodium

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Usage of `random_bytes` in non-extended-nonce

inkeliz opened this issue · comments

In this page the LibSodium describe the safest way to create a nonce in AES-GCM, ChaCha20Poly1305, ChaCha20Poly1305-IEFT and XChaCha20Poly1305.

Based on this information all methods are safe using "Counter, permutation". The XChaCha20Poly1305 is the only one that can be random, due to the size of the nonce.

However, in the 08-advanced.md all methods uses the random_bytes and no more information are given. The documentation already says about the nonce-size, but maybe the reader has no clue about the generation of the nonce. Considering that all examples uses the random nonce, it can make even harder to for the reader figure that out.

I think is better to include some information about the nonce in this page, maybe change the example too.