CRYPTOGRAPHIC MERSENNE TWISTER and FUBUKI STREAM/BLOCK CIPHER 1. Introduction in This Paper, We Consider Cryptographic Systems I
Total Page:16
File Type:pdf, Size:1020Kb
CRYPTOGRAPHIC MERSENNE TWISTER AND FUBUKI STREAM/BLOCK CIPHER MAKOTO MATSUMOTO, TAKUJI NISHIMURA, MARIKO HAGITA, AND MUTSUO SAITO Abstract. We propose two stream ciphers based on a non-secure pseudoran- dom number generator (called the mother generator). The mother generator is here chosen to be the Mersenne Twister (MT), a widely used 32-bit integer generator having 19937 bits of internal state and period 219937 − 1. One proposal is CryptMT, which computes the accumulative product of the output of MT, and use the most significant 8 bits as a secure random numbers.Itsperiodisprovedtobe219937 − 1, and it is 1.5-2.0 times faster than the most optimized AES in counter-mode. The other proposal, named Fubuki, is designed to be usable also as a block cipher. It prepares nine different kinds of encryption functions (bijections from blocks to blocks), each of which takes a parameter. Fubuki encrypts a sequence of blocks (= a plain message) by applying these encryption functions iteratedly to each of the blocks. Both the combination of the functions and their parameters are pseudorandomly chosen by using its mother generator MT. The key and the initial value are passed to the initialization scheme of MT. 1. Introduction In this paper, we consider cryptographic systems implemented in software. We assume a 32-bit CPU machine with fast multiplication of words, and a moderate size of working area (about 4K bytes). In a narrow sense, a stream cipher system is to generate cryptographically secure pseudorandom numbers (PN) from a shared key, and take exclusive-or with the plain message to obtain ciphered message. One way to generate such PN is to use a non-secure generator like LFSR (which we call the mother generator), initialize it by using the key, and then filter its outputs, i.e., apply some complicated functions to obtain a secure sequence. Along this line, we propose to use a GF(2)-linear generator whose internal state consists of 19937 bits, Mersenne Twister (MT) (see §3 for the detail). MT is invented by two of the authors [4]. It has period 219937 − 1 and uniform equidis- tribution property upto 623 dimension. Its initialization scheme is improved to accept an array of any length as an initial seed in 2002. MT is widely accepted in Date: June 1, 2005. Key words and phrases. Mersenne Twister, non-secure random number generator, stream ci- pher, CryptMT, Fubuki, AES. The cipher systems CryptMT and Fubuki in this paper are proposed to ECRYPT Stream Cipher Proposal http://www.ecrypt.eu.org/stream/. The reference codes and a prototype of this paper are available there. The first author was supported in part by JSPS Grant-In-Aid #14654021 and #16204002, and Hiroshima University President’s Discretion Fund ’05. 1 2 MAKOTO MATSUMOTO, TAKUJI NISHIMURA, MARIKO HAGITA, AND MUTSUO SAITO Figure 1. CryptMT: period 219937 − 1, and twice faster than the optimized AES (Pentium-M, gcc -O3) the society of MonteCarlo simulations, and implementations in C and many other languages are available from the homepage [5]. As described in this homepage, a way to generate a cryptographically secure PN sequence is to use MT, and compress its outputs by using, say, MD5 or SHA1. 2. CryptMT The first proposal in this paper is even simpler. MT generates a sequence of unsigned 32 bit integers (which from now on we shall call words). The given key and initial value are concatenated and passed to the initialization scheme (§3) of MT. We prepare a variable accum of word size, which is set to 1 at the beginning (this may be any odd integer). Then, we iterate the following process to obtain (probably) a cryptographically secure PN sequence of 8-bit integers (= byte): (1) Generate one pseudorandom word gen rand by MT. (2) Multiply it to accum: accum ← accum × (gen rand | 1). (3) Output the most significant 8 bits of accum.GotoStep1. To raise the security, the first 64 bytes of the outputs are discarded. Here the C-language-like notation “|” denotes bitwise-OR operation. This op- eration is to make the multiplier odd (otherwise, after several iterations, accum would be zero). Multiplication is considered modulo 232. This method generates a PN sequence of bytes, which fits to the usual require- ments for a stream cipher. We call this stream cipher CryptMT, meaning Crypto- graphic Mersenne Twister. Our experiment shows that CryptMT is faster by a factor of 1.5–2.0 than the well- optimized counter-mode AES (see §6.1), widely known as rijndael-alg-fst.c. The size of the internal state of MT seems to be enough to make any kind of time-memory-trade-off attacks infeasible. If all bits of accum were used (differently from the 8 bits as in CryptMT) then the sequence would not be cryptographically secure, since from the change of the CRYPTOGRAPHIC MERSENNE TWISTER AND FUBUKI STREAM/BLOCK CIPHER 3 accum we could recover the output of MT (except for the least significant bit), then by linear algebra one can decide the internal state after observing 19937 bits of the output. However, if only the most significant 8 bits after multiplication are observed, then we can not imagine how to obtain the internal state of MT. It is important to use the most significant bits: the least significant bit is always 1, and the second bit of accum coincides with the summation (modulo 2) of the second bit of the outputs of MT so far, from which one could compute MT’s internal state. The most significant bits seem to be safe, since the bit-diffusion pattern of the multiplication is from right to left, and most significant bits gather information of all the less significant bits of the two operands: accum and the output of MT. The above gave a complete description of CryptMT, except for the description of the mother generator MT (§3). Security of CryptMT is largely depending on the mother generator MT and its initialization. The facts that (1) the size of internal state of MT is huge, (2) 3/4 of the output bits of MT are discarded, (3) MSBs after multiplication gather information of all bits, and (4) initialization is highly nonlinear, seem to imply high security, but we need more detailed study. The period of each of 8 bits of the output of CryptMT is 219937 − 1 (see Appendix A). Design rationales of CryptMT are (1) use a fast linear generator, which has a huge state (e.g. thousands of bits), and (2) filter its output by a finite state non-linear automaton which has a relatively small state (e.g. one word), (3) Only a small fraction of the information of the state is output (e.g. 8 bits among 32 bits). as seen in Figure 1. The former ensures the long period, and the latter ensures complicated bit-diffusion, under a compromise with the speed in software imple- mentation. 3. Mersenne Twister MT generates a PN word sequence by the GF(2)-linear recursion w624+i = w397+i ⊕ ((wi&0x80000000)|(w1+i&0x7fffffff))A (i =0, 1, 2,...). Here wi (i =0, 1, 2,...) are 32-bit integers, each of which is considered as a 32- dimensional row vector over the two element field GF(2). The binary operator ⊕ denotes bitwise exclusive-or, i.e., addition as a vector. The C-like hexadecimal notation 0x80000000 denotes the vector whose compo- nents are all zero except for the left most 1. Thus, ((wi&0x80000000)|(w1+i&0x7fffffff)) is the row vector obtained by concatenating the MSB of wi and all bits but the MSB of w1+i. To this vector a constant 32 × 32 matrix A is multiplied from the right. This matrix A is of the form ⎛ ⎞ 1 ⎜ ⎟ ⎜ 1 ⎟ ⎜ ⎟ ⎜ .. ⎟ , ⎜ . ⎟ ⎝ 1 ⎠ a31 a30 ··· ··· a0 4 MAKOTO MATSUMOTO, TAKUJI NISHIMURA, MARIKO HAGITA, AND MUTSUO SAITO and so the multiplication is computed by shiftright(x) (if the LSB of x is 0) xA = shiftright(x) ⊕ a (if the LSB of x is 1), where a is a constant vector a =(a31,a30,...,a0)=0x9908B0DF in the hexadecimal notation. These constants are chosen so that the period of the sequence is 219937 − 1. The number of nonzero terms in the characteristic polynomial of the state transition function is 153. Figure 2 illustrates the state transition of MT. The state consists of 623 words + 1 bit. The next state is obtained by shifting one words to the above, and insert a new word linearly computed from the discarded part and a middle term. In a software implementation, instead of shifting, we use round robin technique (i.e. to use a pointer) for the efficiency of the generation. Advantages of this configuration over usual LFSR with coefficients, say, in GF(232), are (1) No need of costive operations like “multiplication modulo polynomials,” (2) There is a fast algorithm to check the maximality of the period by paring and Galois theory [4], (3) The generation speed is independent of a, which makes the parameter-search easier. This is different from LFSR, where the generation speed depends on a particular choice of the coefficients. Remark 3.1. In the original MT, the output is transformed by a linear trans- formation to attain nearly optimally high-dimensional equidistribution at MSBs. This is called Tempering. We removed this transformation, since we think it non- necessary because of the application of complicated functions to the outputs of MT in the encryption process. For initialization, we need to specify w0,w1,...,w623 as the initial state (to be precise, all the 31 bits of w0 but the most significant bit are neglected in generating the next word, so the state space has 624 × 32 − 31 = 19937 bits).