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
use io;
use crateStream;
/// An [`XOF`] is an extendable output function, which is a cryptographic
/// primitive that can take arbitrary input in the same way a hash
/// function does, and then create a stream of output, up to a limit
/// determined by the size of the internal state of the hash function
/// the underlies the [`XOF`].
///
/// When [`xor_key_stream()`] is called with zeros for the source, an [`XOF`]
/// also acts as a PRNG. If it is seeded with an appropriate amount
/// of keying material, it is a cryptographically secure source of random
/// bits.
///
/// [`XOF`] implements [`io::Write`] which absorbs more data into the hash's state.
/// It should throw an error if called after [`read()`]. Use [`reseed()`] to reset the xof
/// into a state where more data can be absorbed via [`io::Write`].
///
/// [`XOF`] implements [`io::Read`] which reads more output from the hash.
/// It returns a value `n != 0` if EOF has been reached.
///
/// [`XOF`] implements [`Stream`], so that callers can use [`xor_key_stream`]
/// to encrypt/decrypt data. The key stream is read from the [`XOF`] using
/// the [`io::Read`] trait. If [`read()`] returns an error, then [`xor_key_stream`]
/// will panic.
/// An [`XOFFactory`] is a trait that can be mixed in to local suite definitions.