Traditionally, all the cryptanalytical attacks launched against TinyJambu have been conducted in block cipher cryptanalysis, (e.g., differential and linear cryptanalyses). Nevertheless, the cryptosystem TinyJambu can be considered a stream cipher cryptosystem in that both encryption and decryption are concerned. This is the reason why an analysis of the sequence generated using TinyJambu (the so-called keystream sequence) deserves a section in this work. To our knowledge, a deep study of such a sequence cannot be found in the literature. The analysis of this sequence is a way of evaluating TinyJambu’s strength.
The encryption/decryption procedure in TinyJambu is a typical stream cipher procedure that is carried out as follows:
As the initialization of TinyJambu depends on several parameters (key, nonce, associated data, plain text), for our randomness analysis, we generated multiple keystream sequences originating from different choices of random keys, nonces and AD, as well as distinct types of plain texts (e.g., text files, images, videos, etc.). The lengths of our sequences were 2
23 bits. Moreover, we made use of three kinds of tests: graphical tests [
18,
19], the Diehard battery of tests [
20,
21] and the family of statistical tests FIPS 140-2 developed by the NIST [
22]. For more details concerning the meaning and assessment of such tests, see references [
18,
19]. In the following subsections, we show the obtained results.
5.1. Graphical Tests
In this subsection, we discuss the application of the main graphical tests developed in reference [
18]. These tests were implemented in Matlab 9.1 and executed on the PC described in
Section 1. Most of the graphical tests group the bits in octets (groups of eight bits), except for the linear complexity test, which analyzes the sequence bit after bit, and the chaos game, which considers the bits in groups of two elements. Now, we detail the applied tests.
This test is a measure of the sequence entropy, which would detect any useful information about the parameters used in the design of the sequence generator. The result of this test should be a distribution of points with no trends, no lines, no figures, etc., that is, without any specific pattern. Basically, the return map is a graph of the sequence terms
as a function of the previous terms
.
Figure 3 shows the return map of a keystream sequence generated using TinyJambu. In fact, it exhibits a cloud of disordered points spread out all over the rectangle without any particular distribution. In brief, it does not provide any information for a possible cryptanalysis, and consequently, from the point of view of this graphical test, the sequence is suitable for cryptographic application.
In [
18] (Section 5, Figure 3a,b), several examples of return maps obtained from quadratic generators reveal clearly geometric structures and a lack of randomness.
- 2.
Linear Complexity
Traditionally, linear complexity (LC) is a measure of the unpredictability of a sequence, which is a powerful metric for cryptographic sequences. LC is defined as the length of the shortest Linear Feedback Shift Register (LFSR) able to generate such a sequence [
23] (pp. 27–29). The algorithm of Berlekamp–Massey [
24] computes the value of this parameter. A typical linear complexity profile is a staircase graph that closely follows, but irregularly, the 1/2 line (that is, the straight line with a slope of 1/2), exhibiting average step lengths and step heights of values 2 and 4, respectively. More details concerning LC can be found in [
25,
26].
For cryptographic purposes, the complexity must be as large as possible. In practice, for a sequence of period T, its LC must satisfy
. In
Figure 4, we can see (a) the complexity profile for the first 20,000 bits of a TinyJambu sequence and (b) a zoom-in of the linear complexity profile. After the analysis of 20,000 bits, the value of LC should be approximately LC = 10,000, as can be observed in
Figure 4a.
- 3.
Shannon Entropy and Min-Entropy
The entropy of a sequence is a measure of the amount of information provided by a process with a result that is the sequence, or equivalently, it is a measure of the uncertainty of a random variable X. Such a measure is expressed in bits; see [
20]. Shannon entropy is defined as the average probability of all the values that the random variable can take. More precisely, let X be a random variable that takes the values x
1, x
2, x
3, …, x
n. Thus, Shannon entropy is defined as
If the process is the generation of a sequence of integers modulo m, perfectly random with m = 2n, then its entropy is equal to n. In our case, the entropy of a random sequence must be close to n = 8 bits per octet (byte). The min-entropy is the measure of the probability of the more frequent occurrence value of the random variable. It is a measure recommended by the NIST SP 800–90B standard for True Random Number Generators.
In order to determine whether the TinyJambu generator of keystream sequences is suitable for these values of entropy, we can say that for a sequence of 220 bytes, the Shannon entropy must be ≥7.976 bits per byte, while the min-entropy must be approximately 7.91 bits per byte. In the analysis of the TinyJambu sequences, we obtained, on average, the following values:
Shannon entropy (ideal) = 8 bits per octet.
Shannon entropy (minimum accepted) = 7.976 bits per octet.
Shannon entropy measured = 7.9986 bits per octet.
Min-entropy (ideal) = 7.91 bits per octet.
Min-entropy (minimum accepted) = 7.608 bits per octet.
Min-entropy measured = 7.8132 bits per octet.
In view of the numerical values obtained, we can say that the Shannon entropy and min-entropy tests were passed.
- 4.
Samples in increasing order
The TinyJambu sequence is codified in groups of 8 bits. Such octets, considered numerical values in the interval [0, …, 255], are sorted in increasing order and represented by means of a graph. If all the 8-bit numbers were generated, then the representation would be a continuous line. At the same time, if the density were uniform (all the numerical values appear with the same frequency), then the slope line (over which the samples are represented) would be 45 degrees.
Figure 5 depicts the results of this test. The samples give rise to a continuous straight line (in red) with a 45-degree slope line, which totally covers the blue line with the same slope used as reference. In view of the results of
Figure 5, the samples under the increasing order test satisfactorily passed.
The chaos game is a mathematical technique that allows us to convert a one-dimensional sequence such as that generated using TinyJambu into a two-dimensional sequence, giving rise to a more detailed visual representation. From such a representation, we can characterize possible patters in the sequence under consideration. The outcome of a chaos game representation is called an attractor (fractal or compact set); for more details, the interested reader is referred to [
18,
19]. In fact, this technique can determine non-randomness in the kind of pseudorandom sequences that we are analyzing. In
Figure 6, we can just see a cloud of disordered points spread out all over the square. No patterns or fractals are observed. Consequently, the chaos game test was passed.
In [
18] (Section 5, Figure 7a,b), examples of chaos game representations obtained from quadratic generators show fractal structures that reveal a lack of randomness.
Autocorrelation (or cross-correlation) is a mathematical technique that looks for repeated samples among the different portions of a sequence when they are compared. This property is very useful for finding periodic or repetitive patterns within a signal or, in this case, within a binary sequence. The sequence is compared with a shifted version of the same sequence. The number of agreements and disagreements among bits for the pair of the original sequence and shifted version are computed. The comparison is carried out for all the possible shifts of the sequence over itself.
Figure 7 represents the autocorrelation of a TinyJambu sequence after analyzing 120,000 bits. The first autocorrelation coefficient is always equal to 1, as the sequence coincides with itself (autocorrelation in phase); the remaining coefficients corresponding to the successive shifts must be as small as possible (autocorrelation out of phase). In
Figure 7, it is clear that the obtained values in red are close to 0. This means that, as far as this metric is concerned, the analyzed sequence exhibits good randomness characteristics, and consequently, the autocorrelation test was passed.
A Fast Fourier Transform (FFT) efficiently computes a Discrete Fourier Transform or transformation of a signal into the frequency domain. In the analysis of binary sequences, a FFT may detect repetitive patterns in the sequence under study. In fact, a random sequence must exhibit all the FFT harmonics with approximately the same amplitude, and no up/down trends should appear.
Figure 8 shows the result of this test applied to a TinyJambu sequence of 120,000 bits. It can be seen that all the amplitudes are in the same range; consequently, the test was passed.
5.2. The Diehard Battery of Pseudorandomness Tests
Random number generators only exist in nature. In practice, we have to settle with pseudorandom number generators, which are tested, and their results should not exhibit neither evidence of regularity nor evidence of a statistical distribution. At this point, we applied the Diehard battery of tests, which consists of 15 independent tests, although some of them are repeated but with distinct parameter values. Diehard tests use the chi-square goodness-to-fit technique for computing uniform
p-values in the interval [0, 1); see [
20,
21].
In order to apply the previous tests to the TinyJambu sequences, we created a series of sequences, all of them generated using the same generator but with different choices of key, nonces, AD or plain text.
From the Diehard battery, we applied the following tests:
Binary Rank Test for 6 × 8 matrices;
3DSPHERES Test;
Overlapping 5-permutation Test;
SQEEZE Test;
Parking lot Test;
Binary Rank Test for 31 × 31 matrices;
Binary Rank Test for 32 × 32 matrices;
Birthday spacing Test;
Overlapping sums Test;
Runs Test;
Craps Test;
Minimum distance Test.
For the sake of simplicity, we considered the previous tests among the 15 proposed in the Diehard battery. Since all of these are statistical tests, it is more accurate to determine whether their results (the
p-values) fall inside a determined upper and lower bound. In fact, the
p-values may fluctuate but not trespass these bounds, indicating good statistical properties or good pseudorandomness characteristics. In this work, we established our boundaries in the following margins:
Sequences with
p-values greater or lower than these bounds were said to exhibit poor pseudorandomness [
27,
28]. At this point, we applied the Diehard battery of tests to a series of sequences generated using TinyJambu.
The following results are for tests 1–4, and they are depicted in
Figure 9:
Binary Rank Test for 6 × 8 matrices: sequence_5 and sequence_10 showed a slightly higher p-value than the established upper bound.
3DSPHERES Test: only sequence_11 exhibited a p-value lower than the bound, which means a slightly deficient pseudorandomness.
Overlapping 5-permutation Test: here, the p-values were too low for sequences 1 and 2, showing poor pseudorandomness characteristics.
SQEEZE TEST: all sequences passed this test satisfactorily.
Next, the following results are for tests 5–8, and they are depicted in
Figure 10:
- 5.
Parking lot Test: sequence_6 slightly surpassed the upper bound, which indicates a slight deficiency in pseudorandomness.
- 6.
Binary Rank Test for 31 × 31 matrices: all sequences showed good pseudorandomness characteristics.
- 7.
Binary Rank Test for 32 × 32 matrices: all sequences showed good pseudorandomness characteristics.
- 8.
Birthday spacing Test: all sequences exhibited good pseudorandom characteristics, although sequence_6 was near the bound.
For tests 9–12,
Figure 11 shows the results, and the results are as follows:
- 9.
Overlapping sums Test: all sequences exhibited p-values within the boundaries.
- 10
Runs Test: all sequences showed good pseudorandomness characteristics.
- 11.
Craps Test: all sequences showed good pseudorandomness characteristics.
- 12.
Minimum distance Test: all sequences showed good pseudorandomness characteristics, except for sequence_7, which showed a poorer pseudorandomness.
As we have seen from the above results, in general, the TinyJambu sequences pass the tests. Some sequences exhibit p-values beyond the boundaries for any test. Nevertheless, we must remember that we are applying statistical tests to detect regularities, and we could not find any at this point. Based on the results, we can say that the sequences generated using the cryptosystem TinyJambu show good pseudorandomness.