Skip to content

Commit 60978e2

Browse files
authored
Merge pull request #353 from pitdicker/doc-fixes
Documentation improvements to ChaCha and ISAAC
2 parents ba88dad + 09bc2b0 commit 60978e2

File tree

3 files changed

+32
-23
lines changed

3 files changed

+32
-23
lines changed

src/prng/chacha.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@ const STATE_WORDS: usize = 16;
3737
/// and security, 8 rounds are considered the minimum to be secure. A different
3838
/// number of rounds can be set using [`set_rounds`].
3939
///
40-
/// We deviate slightly from the ChaCha specification regarding the nonce, which
41-
/// is used to extend the counter to 128 bits. This is provably as strong as the
42-
/// original cipher, though, since any distinguishing attack on our variant also
43-
/// works against ChaCha with a chosen-nonce. See the XSalsa20 [3] security
44-
/// proof for a more involved example of this.
40+
/// We deviate slightly from the ChaCha specification regarding the nonce and
41+
/// the counter. Instead of a 64-bit nonce and 64-bit counter (or a 96-bit nonce
42+
/// and 32-bit counter in the IETF variant [3]), we use a 128-bit counter. This
43+
/// is because a nonce does not give a meaningful advantage for ChaCha when used
44+
/// as an RNG. The modification is provably as strong as the original cipher,
45+
/// though, since any distinguishing attack on our variant also works against
46+
/// ChaCha with a chosen nonce.
4547
///
4648
/// The modified word layout is:
4749
///
@@ -58,8 +60,8 @@ const STATE_WORDS: usize = 16;
5860
/// [2]: [eSTREAM: the ECRYPT Stream Cipher Project](
5961
/// http://www.ecrypt.eu.org/stream/)
6062
///
61-
/// [3]: Daniel J. Bernstein. [*Extending the Salsa20 nonce.*](
62-
/// http://cr.yp.to/papers.html#xsalsa)
63+
/// [3]: [ChaCha20 and Poly1305 for IETF Protocols](
64+
/// https://tools.ietf.org/html/rfc7539)
6365
///
6466
/// [`set_rounds`]: #method.set_counter
6567
#[derive(Clone, Debug)]

src/prng/isaac.rs

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,19 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
2828
/// series of array based random number generator designed by Robert Jenkins
2929
/// in 1996[1][2].
3030
///
31-
/// Although ISAAC is designed to be cryptographically secure, its design is not
32-
/// founded in cryptographic theory. Therefore it is _not recommended for_
33-
/// cryptographic purposes. It is however one of the strongest non-cryptograpic
34-
/// RNGs, and that while still being reasonably fast.
31+
/// ISAAC is notably fast and produces excellent quality random numbers for
32+
/// non-cryptographic applications.
3533
///
36-
/// Where fast random numbers are needed which should still be secure, but where
37-
/// speed is more important than absolute (cryptographic) security (e.g. to
38-
/// initialise hashes in the std library), a generator like ISAAC may be a good
39-
/// choice.
34+
/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
35+
/// been stringently cryptanalyzed and thus cryptographers do not not
36+
/// consensually trust it to be secure. When looking for a secure RNG, prefer
37+
/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
38+
/// the stream-ciphers selected the by eSTREAM contest.
4039
///
4140
/// In 2006 an improvement to ISAAC was suggested by Jean-Philippe Aumasson,
42-
/// named ISAAC+[3]. But because the specification is not complete, there is no
43-
/// good implementation, and because the suggested bias may not exist, it is not
44-
/// implemented here.
41+
/// named ISAAC+[3]. But because the specification is not complete, because
42+
/// there is no good implementation, and because the suggested bias may not
43+
/// exist, it is not implemented here.
4544
///
4645
/// ## Overview of the ISAAC algorithm:
4746
/// (in pseudo-code)
@@ -84,6 +83,8 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
8483
///
8584
/// [3]: Jean-Philippe Aumasson, [*On the pseudo-random generator ISAAC*](
8685
/// https://eprint.iacr.org/2006/438)
86+
///
87+
/// [`Hc128Rng`]: prng/hc128/struct.Hc128Rng.html
8788
#[cfg_attr(feature="serde-1", derive(Serialize,Deserialize))]
8889
pub struct IsaacRng {
8990
#[cfg_attr(feature="serde-1",serde(with="super::isaac_serde::rand_size_serde"))]

src/prng/isaac64.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
2929
/// series of array based random number generator designed by Robert Jenkins
3030
/// in 1996[1].
3131
///
32-
/// Although ISAAC is designed to be cryptographically secure, its design is not
33-
/// founded in cryptographic theory. Therefore it is _not recommended for_
34-
/// cryptographic purposes. It is however one of the strongest non-cryptograpic
35-
/// RNGs, and that while still being reasonably fast.
36-
///
3732
/// ISAAC-64 is mostly similar to ISAAC. Because it operates on 64-bit integers
3833
/// instead of 32-bit, it uses twice as much memory to hold its state and
3934
/// results. Also it uses different constants for shifts and indirect indexing,
4035
/// optimized to give good results for 64bit arithmetic.
4136
///
37+
/// ISAAC-64 is notably fast and produces excellent quality random numbers for
38+
/// non-cryptographic applications.
39+
///
40+
/// In spite of being designed with cryptographic security in mind, ISAAC hasn't
41+
/// been stringently cryptanalyzed and thus cryptographers do not not
42+
/// consensually trust it to be secure. When looking for a secure RNG, prefer
43+
/// [`Hc128Rng`] instead, which, like ISAAC, is an array-based RNG and one of
44+
/// the stream-ciphers selected the by eSTREAM contest.
45+
///
4246
/// ## Overview of the ISAAC-64 algorithm:
4347
/// (in pseudo-code)
4448
///
@@ -68,7 +72,9 @@ const RAND_SIZE: usize = 1 << RAND_SIZE_LEN;
6872
///
6973
/// [1]: Bob Jenkins, [*ISAAC and RC4*](
7074
/// http://burtleburtle.net/bob/rand/isaac.html)
75+
///
7176
/// [`IsaacRng`]: prng/isaac/struct.IsaacRng.html
77+
/// [`Hc128Rng`]: prng/hc128/struct.Hc128Rng.html
7278
#[cfg_attr(feature="serde-1", derive(Serialize,Deserialize))]
7379
pub struct Isaac64Rng {
7480
#[cfg_attr(feature="serde-1",serde(with="super::isaac_serde::rand_size_serde"))]

0 commit comments

Comments
 (0)