Cellular automaton (CA) cryptographic use is limited. One significant reason is performance. A survey of CA stream ciphers  shows that encrypting one megabyte of data requires five seconds at best. One exception is MAG (My Array Generator) , which is a Mageto predecessor. It is a one-dimensional cellular automaton (CA). It belongs to a class of three complexity classification schemes p.12 . That means, nearly every initial state evolves in pseudo-random or chaotic fashion. Two significant attributes which make MAG so exceptional are:
MAG is invariant to the cell size. Both 32-bit and 64-bit cells are investigated, and they show the same behaviour. That fact has a huge impact on performance.
MAG update rule is not entirely boolean and SAT solvers tools, which are generally better than brute force , could not be applied.
Apart from that, there are many more important reasons for revisiting MAG and build Mageto on MAG foundations:
MAG was the main building block for stream cipher entry (eSTREAM; ECRYPT Stream Cipher Project ). That entry did not progress to the second round because of the available analysis at that time. In the second round of decision making, the analysis consisted of two attacks [13, 10]. Other attacks [7, 6] are variants of the previous two. More analyses were published  after round two. Those cryptanalysis contest attacks from [13, 7]. In the same analysis, it suggests that the second type of attacks [10, 6] are avoidable using one minor alternation proposed in . According to the published analysis, at least one MAG variant remains secure.
Another reason is MAG compactness. While Advanced Encryption Standard (AES) is widely used in symmetrical encryption, the emergence of IoT (The Internet of things), with constrained computation power, limits AES usability in that area. Therefore lightweight symmetrical encryption schemes are sought. MAG hardware footprint is a bytes of memory for automation state, plus a couple of variables. Operational cost is a cellular automation updating rule consisting of one conditional branching, a couple of exclusive or logical operation, one of one’s complement and one addition (five basic operations). That should match an extensive range of IoT hardware limited capabilities. See Listing A 1 for details.
Please note that the predecessor of our cryptographic primitive Mageto, namely, MAG, and its design choices for various parameters was never discussed or published before. Thus, in this paper, these issues will be addressed as well.
|Primitive||Stream (cycles per byte)|
The rest of paper is organised as follows: Section 2 introduces one dimensional CA and defines Mageto proposition. It also shows where Mageto improves over MAG making the Mageto proposition even simpler. Appendix A include C language general implementation. Section 3 shows three different ways to implement the proposed Mageto securely. Section 4 deals with an analysis of MAG known attacks and how they might impact the Mageto proposal. Section 5 discusses Mageto and its potential usage to a variety of applications, SCA and input flexibility.
2 Mageto Cellular Automation
Mageto is a one-dimensional CA. The concept of CA was first discovered in the 1940s by Stanislaw Ulam and John von Neumann. CA is used as a modelling tool in various scientific fields: computer and complexity science, mathematics, physics and biology. Stephen Wolfram is the first to propose the use of CA (rule 30) in cryptography .
Figure 1 showing Wolfram’s rule 30 is used to explain the general working of one-dimensional CA. The particular example uses cells with two possible states (black and white). One-dimensional CA initial state is a row. For example, it is the binary string (row 1):
Row 2 is derived from row 1 and so on, with final row 16:
Rules to determine an update of a cell are shown as eight cases. Each case shows one combination of three cells on the top and the derivative cell on the bottom. Three cells from the row above (positioned above right, immediately above and above left) are looked at, and one of the cases are applied to create a cell. For example, a cell from row 2 column 14 is derived by case 8, cell from row 2 column 15 is acquired by case 7, cell from row 2 column 16 is obtained by case 6 and so on. Edge cells do not have above left or above right cells to choose a case. In that situation, the first or the last cell from the previous column are used for the ruling. For example, left edge cell from row 16 column 1 looks at cells from row 15, columns 31, 1, 2 and use case 7 to create the cell. The right edge cell from row 16 column 31 use the cells from row 15 columns 30, 31, 1 for lookup and case 4 for cell determination. Derived rows (rows ) are outputs of CA.
If a random stream of bits is required, column could be used:
A stream generated in this fashion passes many randomness statistical tests and it is used as a random number generator in Wolfram’s Mathematica software.
Mageto is also a one-dimensional CA, but it differs from the example by:
Cells are multi-bit words (32 or 64 bits in size).
The update of Mageto cells is serial, left to right, because the rule needs the outcome of the previous cell update (carry).
The Mageto rule also appears to be invariant to cell size because it shows the same random behaviour for and bit size cells.
Mageto CA is governed by the CA rule and the state of neighbouring cells. A row of cells, in a Mageto case array of elements, are updated from left to right. One evolution cycle is when all items in the array are updated. The next generation is another evolution cycle and so on. The original and modified parameters are shown in Table 2.
Mageto parameters definitions:
The number of cells is . That choice forces possible execution paths during one evolution cycle and assumes at least bit level security if the stream is used as a basis for the cipher.
The cell size is . The Mageto CA rule appears to be invariant concerning the cell size. is used and tested for randomness  and there are no biases, although the performance doubles because the same generating cost produces double the stream.
Instead of taking the carry value from the array element in the original version, it is initialised as (decimal). The value of was chosen, and there is no special meaning behind this choice.
The constant is now initialised as (). Again there is nothing special in the constant value. In MAG was described as an arbitrary value (which it is). Related to this, an initialisation attack [13, 7] where was proposed. It eliminates any adding procedure which simplifies the whole process significantly. The analysis  showed that any non zero value of is sufficient to prevent initialisation attacks.
In a modified version, the mixing period is four evolutions . It assures proper mixing because the original one and half evolutions occasionally produced biases in the first couple of generated rows. The same could be observed in the rule 30 case (Figure 1) where the first several rows still retain some patterns.
The seed is any binary string equal or smaller than a row of cells and meaning that the key , the salt and (IV, pepper and so on) are concatenated to form seed .
Mageto operation is divided into initialisation and update.
Mageto initialisation; Originally, the array of elements bits wide is initialised to . The seed is repeatedly concatenated until the resulting concatenation is equal or greater in size than the array. MAG array’s first elements are the initial row, and remaining elements becomes the carry . For example, the seed is and array is cells (one byte each), the resulting initial array will be:
In the Mageto modified version, the seed is simply copied to zero initialised array and the carry is given as an initial value . The pattern, with and array of bytes, looks like:
Mageto update; when initialised, the rows are created by updating cells from left to right. The edge cases ( happens to be on the array end) are handled as rule 30 edge cell cases. The rule elements are shown in Figure 2. The cell update consists of three steps:
1st step is to create a new state of carry .
Carry is updated by (exclusive or) with previous value of and one state of the first element to the right , depending on the relation between the other two cells on the right (). States of are: current value () or it’s one complement (). In one evolution cycle (whole array is updated) each cell is changed once and carry is calculated for every cell transformation. Note that the first cell update uses the initial value of carry .
2nd step is the actual change of element to .
3rd step is updating current value for next cell transformation.
3 Mageto as A Secure Stream Generator
Knowledge of the array state renders the Mageto algorithm cryptographically unsound. Three strategies for concealing CA state to make a secure stream from Mageto, are proposed and discussed.
3.1 Reducing output (Mageto-v1)
is transformed by taking bits and producing secure stream
The similar approach was used in the MAG eSTREAM proposal. The small change in operation is added to achieve a secure stream property. Instead of copying every updated cell to the stream, only the first byte of the cell is added to the secure stream (now array of bytes).
For example, Figure 3 shows updated cells as a stream of bytes where each pixel represents a byte and four bytes are an updated cell. To make a secure stream every 5th byte (every 5th pixel from left to right) is taken and fed to the secure stream. That is bytes:
Consequently bytes create a secure stream. This approach was found insecure, and details are shown in Section 4.
Again the small change in pattern avoids weaknesses from the previous design. If the series of bytes taken is changed to: from first cell first byte, second cell second byte, third cell third byte, fourth cell fourth byte, fifth cell first byte and so on…
The stream of bytes from Figure 3 will form a secure stream.
3.2 Combining streams (Mageto-v2)
One way of making a stream secure is to combine two or more streams. For example, LFSR (Linear-feedback shift register) outputs were combined to make a shrinking generator (planned to be used as a stream cipher ). The shrinking generator uses two streams, one is a source, and the other is used to decide which bits of the source stream is output.
In the Mageto case the idea is to apply exclusive or between two generated streams (stream and ) to produce a secure stream :
|Mageto stream||stream IV|
One implementation attempt at combined MAG approach was published here . It includes source code. The easiest way to implement combined Mageto is to initialise streams separately. Table 3 contains initial parameters. The seed for each stream now includes corresponding IV. For example, the seed for is where is the key, is the salt,
initialisation vector from Table3 and is the concatenation of strings.
3.3 Stream Masking (Mageto-v3)
The idea with masking is to combine (xor) Mageto output with a secret string. The original idea is to use a key as the secret string but Dr Daniel J. Bernstein and prof.dr.Tanja Lange noted that the same attacks ([10, 6]) apply for that proposal as well. Alternatively, the secret could be sourced from the execution path history. The branching from the previous evolution can generate string . In the case of elements array, there is branching in one evolution cycle making a bit string . Bits of are determined by branching; if branch will concatenate and else to the mask . From the four bit element mask array is created.
The secure stream is now obtained by exclusive or result from Mageto output cells () and mask array of four elements ():
The new mask is calculated for every evolution cycle and is used as a mask for next cycle.
4 Mageto Analysis
Mageto-v1; The eSTREAM proposal to strengthen CA MAG was to output just the first byte from the every updated cell. It did not work. CA can continue updating on just that part of the cell without information from the hidden part:
Since the first bytes of and are known the first byte of is known as well because:
Knowing the first byte of , predicting the next unknown value of the carry takes guessing the branching outcome. That guess is even easier because of knowledge of the first byte which is compared.
|Series of bytes used in the stream||Status|
This kind of attack is detailed in [10, 6]. Two amendments are proposed in  to avoid this line of attack. The idea was to alternate extraction points because the original design did not hide the evolution of the first-byte cell. Table 4 shows various extraction patterns for the proposed MAG secure stream. The first amendment (second-row Table 4) is broken as well. The one gap between exposed bytes of the cell did not prevent the same attack although the guessing cost was increased . The second amendment (third-row Figure 4) does have three gaps between visible bytes and is still resisting analysis.
Mageto-v2; The result from exclusive or of two Mageto streams is secure stream . The relevant relations of knowns and unknowns are shown below. Stream is known and streams and and carry are unknown.
Both relations are used to attack Mageto Subsection 3.1 [10, 6]. Additional streams could be included to strengthen two stream variant. The combination of three Mageto streams producing secure stream might look like:
5 Mageto Advantages
In this section a few important Mageto features are discussed. One highlight is applicability with the respect to various hardware platforms. There is also Mageto resistance to the side channel attack and Mageto flexibility to the inputs other than key.
5.1 Mageto Implementation and Performance
Three Mageto cipher variants are presented:
Mageto single cell update Table 5: The operations needed for one step cell update.
The array containing Mageto cells is only bytes in size and with the mentioned set of operation, lowers the entry hardware requirements bar significantly. That includes a wide array of IoT implementations. The Mageto-v1 performance, the same efficiency as mag-v1, is very comparable with AES, see Table 6.
Crypto primitive Stream (cycles per byte) RC4 14.52 AES-CTR 18.51 MAG-v1 20.43 Table 6: An extract of eSTREAM software performance table .
Mageto-v2 approach subsection 3.2, is a little bit more complex. On the other hand, efficiency is improved. By roughly doubling effort, output increases four times. That is bytes per CA steps comparing byte per CA step (subsection 3.1). There are other ways to improve performance. One way relies on the fact that combining streams could be created in parallel. By that technique performance is bytes / CA step ( steps in parallel). This technique also enables adding streams if needed without affecting performance. Another efficiency approach could be increasing the size of the CA cell from to bits producing bytes per step. For details see Table 7.
MAG variants Performance Mageto-v1 Mageto-v2 Mageto-v2 parallel Mageto-v2 parallel 64 bit Mageto-v3 Mageto-v3 64 bit Table 7: Various performance details.
Mageto-v3 from subsection 3.3 is a notch more complex than previous variants. Developing mask for each evolution step is the reason. This approach also improves performance concerning Mageto-v1. That improvement does not need parallelism. Although Mageto-v3 is relatively more complex, it is still significantly simpler than AES from a hardware and software point of view, delivering better performance. Table 1 shows mag-v3 (the same as Mageto-v3) 64-bit implementation versus AES and other primitives. Table 7 shows performances between various Mageto variants where one step from Table 5 produces towards secure stream depending on the variant used.
5.2 Side Channel Resistance
When discussing side channel attack on AES, the quite often cited work  cannot be avoided. There is an assertion mentioned in the abstract that attacks come from the AES design flaw rather than AES implementation. Furthermore, this report is also a call for research into functions with constant time execution. Mageto as CA appears to have the rule which runs in constant time, but some attention is still needed. When implementing Mageto in SCA resistant mode, the algorithm branching structure should be addressed. There are two issues:
The first one is to compare secret cells in constant time. By measuring comparing operations, some properties of the Mageto cells could be determined. For example, comparing the equal cells byte by byte will take the longest time to execute. The solution is to use constant time comparison functions. Some cases can be found here . Note, the solutions are not entirely portable therefore finished program assemblies for particular hardware should be checked for correctness in any case.
The second Mageto issue is branching execution times. For example, Mageto timing for each branch differs, consequently the mask parity of Mageto-v3 3.3 could be readily determined. The solution is equal execution time for each branch. That is accomplished by introducing two pre-calculated intermediate variables and before branching. The update of Mageto carry with , and has equal execution of branches:
(9) (10) (11)
5.3 Input Flexibility
Generally, there is a requirement of an initialisation vector (IV) in symmetrical encryption. For example, AES CBC (AES in Cipher Block Chaining) needs a unique IV for every message processing. If more than IV is required for some reason, the key derivation function (KDF) is necessary to deliver properly sized key and IV.
In that respect, Mageto allows an additional for a nonce, salt, pepper and so on… if needed. It can be used for resisting various repeat attacks for example. That can be accomplished without using KDF as it is the case with AES.
Mageto offers an entirely new cryptographic primitive. It has a straightforward and compact implementation. It also provides SCA resistance which is very important for not physically secured hardware such as IoT. Variant Mageto-v1 also benefits from the fact that its predecessor mag-v1 had in-depth analysis and remains secure .
Cream: the scary ssl attack youv́e probably never heard of.https://tonyarcieri.com/cream-the-scary-ssl-attack-youve-probably-never-heard-of.
-  Daniel J Bernstein. Cache-timing attacks on aes, 2005.
-  Don Coppersmith, Hugo Krawczyk, and Yishay Mansour. The shrinking generator. In Annual International Cryptology Conference, pages 22–39. Springer, 1993.
ECRYPT Stream Cypher Project,
-  S. Fischer. Analysis of lightweight stream ciphers. Ph. D. thesis, Lund University (Sweden), 2008.
-  Matt Henricksen and Ed Dawson. Ensuring fast implementations of symmetric ciphers on the intel pentium 4 and beyond. http://eprints.qut.edu.au/24788/.
-  A. Heuser, S. Picek, S. Guilley, and N. Mentens. Lightweight ciphers and their side-channel resilience. IEEE Transactions on Computers, PP(99):1–1, 2017.
-  Andrew Ilachinski. Cellular automata: a discrete universe. World Scientific Publishing Company, 2001.
-  Simon Kunzli and Willi Meier. Distinguishing attack on mag. eSTREAM, ECRYPT Stream Cypher Project, Report 2005/053, 2005. http://www.ecrypt.eu.org/stream.
Performance Figures, AMD Athlon 64 X2 4200+ 2.20GHz,
Arash Mirzaei, Mohammad Dakhil Alian, and Mahmoud Modarres Hashemi.
Distinguishing attack on a modified version of mag stream cipher,
6th International ISC Conference on Information Security and
-  L. Simpson and M. Henricksen. Improved cryptanalysis of mag. In L. Batten and R. Safavi-Naini, editors, ACISP, LNCS 4058, pp. 64-75, Springer- Verlag Berlin Heideberg 2006.
-  Joseph S Testa. Investigations of cellular automata-based stream ciphers, 2008. Thesis. Rochester Institute of Technology. Accessed from http://scholarworks.rit.edu/theses/129.
-  Rade Vuckovac. Mag alternating methods notes. eSTREAM, ECRYPT Stream Cipher Project, Report 2005/068, http://www.ecrypt.eu.org/stream.
-  Rade Vuckovac. Mag: My array generator (a new strategy for random number generation). eSTREAM, ECRYPT Stream Cipher Project, Report 2005/014, 2005. http://www.ecrypt.eu.org/stream.
-  Rade Vuckovac. A new kind of complexity. arXiv preprint arXiv:1309.0296, 2013.
-  Stephen Wolfram. Computation theory of cellular automata. Communications in mathematical physics, 96(1):15–57, 1984.
-  Stephen Wolfram. A New Kind of Science. Wolfram Media, 2002.
Appendix A Mageto inplementation details
Implementation is written in C language and source code is in Listing 1.
Where the first argument represents how many cells are sent to the standard output . The second argument is the seed and redirects standard output to the file.