
Journal of Polish Safety and Reliability Association Summer Safety and Reliability Seminars , Volume 4, Number 1, 2013 Sugier Jarosław Wrocław University of Technology, Wrocław, Poland Low-cost hardware implementations of Salsa20 stream cipher in programmable devices Keywords FPGA, stream cipher, hardware implementation, pipelining, iterative architecture Abstract Salsa20 is a 256-bit stream cipher that has been proposed to eSTREAM, ECRYPT Stream Cipher Project, and is considered to be one of the most secure and relatively fastest proposals. This paper describes hardware implementation of various architectures of this cipher in popular Field Programmable Gate Arrays (FPGA). The implemented architectures are based on the loop-unrolled data flow organization and after pipelining they can reach the throughput in the range of 20 – 30 Gbps even after fully automatic implementation in popular low-cost families of Spartan-3 and Spartan-6 from Xilinx. More resource-limited iterative architectures achieve speed of 1 – 2 Gbps. The results that are included in this work present potential of the algorithm when it is implemented in a specific FPGA environment and provide some information for evaluation of cipher effectiveness in contemporary popular programmable devices. 1. Introduction software provided by the chip manufacturer, without any special “handmade” optimization, neither in A hardware implementation is an important option layout nor routing. for every cipher and numerous realizations using The text is organized as follows. In the next section both mask- (ASIC) and field- programmable gate we discuss organization of the Salsa20 algorithm as arrays (FPGA) silicon devices have been developed a hash function and as a stream cipher, then we for AES contest candidates or for algorithms that introduce the three basic kinds of cipher took part in the ECRYPT project. In this work we implementation in hardware: the combinational, the present results obtained after implementation of pipelined and the iterative one, and finally we different architectures of Salsa20 stream cipher in evaluate the results of automatic implementation of popular-grade FPGA devices. While most of the these architectures in the two selected families of solutions described in the literature are customized FPGA devices. for specific device architectures and/or operating environments and they are highly optimized to reach 2. The Salsa20 cipher maximum efficiency either in speed or in size, in this work we look from different point at the task of Salsa20 family of stream ciphers [2]-[3] has been cipher implementation. developed by Daniel J. Bernstein from the University The terms “popular-grade” or “low-cost” that we of Illinois at Chicago, USA, in 2005 and submitted to refer to in the title and in the text are understood as the eSTREAM project. After passing all phases of follows: 1) the programmable devices used for selection unmodified it has been included in the final implementation are chosen from inexpensive, portfolio of Profile 1 (software) ciphers along with 4 popular and commonly used line of FPGA chips, other proposals. widely available on the market; 2) the design is At its core the Salsa20 cipher is a hash function described in hardware description language on the which operates in the counter mode as a stream relatively high level of abstraction (no less than at cipher: the 64B[yte] input consisting of 32B of the Register Transfer Level, RTL) and then synthesized key (or twice repeated 16B key) together with 8B and implemented fully automatically by standard nonce plus 8B counter and 16 constants bytes is 121 Sugier Jarosław Low-cost hardware implementations of Salsa20 stream cipher in programmable devices hashed into 64B result which is then XOR’ed with wi’ values. The flow of data which results from the the plaintext. State of the cipher is also 64B wide and above equations is graphically visualized in Figure 1 . is represented as a series of 4B state words . During decryption the same hash result is XOR’ed with the quarterround ciphertext stream to produce plaintext. There is no w0 w0’ <<7 feedback of the data stream to the hash stream. << 18 w1 w1’ 2.1. The Salsa20 hash function << 9 The Salsa20 hash function consists in application of w2 w2’ 20 rounds which are executed over the state q = ( q0, << 13 q0, … q15 ), where each qi represents a single 32b[it] state word. Different permutations of the state words w3 w3’ are used as input to even- and odd-numbered rounds - sum mod 232 but otherwise the in-round processing is identical so - ExclusiveOr the whole organization is very uniform. Moreover, in << n - left rotation the entire algorithm only the following three basic Figure 1. Transformations of the state words in the transformations are used, all operating on the entire Salsa20 quarterround function 32b words: - bitwise Exclusive-Or (XOR) of the two words, Four quarterrounds operating in parallel constitute denoted as ⊕; a single round of the cipher and this can be one of the - sum mod 2 32 of the two words, denoted as + two kinds: a row round or a column round . A row (since there is no other kind of addition used here round function is defined as rowround ( q ) = q’ such there is no risk of confusion); that - rotation to the left by the given (constant) number of bits, denoted as <<. ( q0’, q1’, q2’, q3’) = quarterround (q0, q1, q2, q3) In contrast to the contemporary symmetric block ( q5’, q6’, q7’, q4’) = quarterround (q5, q6, q7, q4) ciphers, in Salsa20 there is no key pre-processing ( q10 ’, q11 ’, q8’, q9’) = quarterround (q10 , q11 , q8, q9) path running in parallel with data (cipher) path which ( q15 ’, q12 ’, q13 ’, q14 ’) = would compute a separate key for each round; the quarterround (q15 , q12 , q13 , q14 ) user supplied external key is embedded into the input 64 bytes producing directly half of the 16 state words whereas a column round function is defined as and then the 512b vector is processed in its entirety. columnround ( q ) = q’ such that The elementary organizational unit of the cipher is a quarterround function which transforms a group of ( q0’, q4’, q8’, q12 ’ ) = quarterround ( q0, q4, q8, q12 ) four state words: quarterrorund (w0, w 1, w 2, w 3) = ( q5’, q9’, q13 ’, q1’ ) = quarterround ( q5, q9, q13 , q1 ) (w0’, w 1’, w 2’, w 3’) such that ( q10 ’, q14 ’, q2’, q6’ ) = quarterround ( q10 , q14 , q2, q6 ) w1’ = w1 ⊕ ( ( w0 + w3) << 7 ) ( q15 ’, q3’, q7’, q11 ’ ) = w ’ = w ⊕ ( ( w ’ + w ) << 9 ) 2 2 1 0 quarterround ( q15 , q3, q7, q11 ) ⊕ w 3’ = w3 ( ( w2’ + w1’) << 13 ) ⊕ w 0’ = w0 ( ( w3’ + w2’) << 18 ) Justification for the round names becomes evident after the quarterround inputs are marked on the 16 The above equations are given in specific order in words of the state q visualized as a 4×4 matrix, as it which they can be sequentially executed modifying is done in Figure 2 . In both cases the four wi words in place : first, w1 is replaced with the new quarterround functions are loaded with, respectively, value w1’ which is computed from the current w0 and rows (in a row round) and columns (in a column w3 words, then w2 is replaced with the new value round) extracted from the matrix and then rotated: computed from w1’ and w0, then w3 is replaced with the k-th row or column ( k = 0 … 3) is rotated by k the value computed from w2’ and w1’, and finally w0 positions to the left or upwards so that the diagonal is replaced with the value computed from w3’ and elements are given always as the first quarterround w2’. In this way the quarterround can be argument w 0. implemented in software as a chain of four A column round followed by a row round make up transformations executed one after another without a so called double round : any temporary registers for intermediate storage of doubleround ( q ) = rowround ( columnround ( q ) ) 122 Journal of Polish Safety and Reliability Association Summer Safety and Reliability Seminars , Volume 4, Number 1, 2013 q0 q 1 q 2 q 3 with plaintext to give ciphertext (during encryption) or with ciphertext to give plaintext (during q q q q 4 5 6 7 decryption). This scheme is outlined in Figure 3 . The q 8 q 9 q 10 q 11 simple XOR operation as the final and the only transformation applied to the plaintext makes q q q q 12 13 14 15 encryption and decryption equally efficient. It also allows to use the same hash module in both q0 q 1 q 2 q 3 operations what significantly simplifies either q 4 q 5 q 6 q 7 software or hardware implementations. q 8 q 9 q 10 q 11 Counter q 12 q 13 q 14 q 15 Constants Figure 2. Arrangement of the state words at the Nonce 8B 8B 16B inputs to the quarterrounds in a row round (above) Key 16/32B and a column round (below) k v n σ/τ Having introduced all the above elementary Salsa20 hash components the final hash function can be defined. function In short, to generate the Salsa20 hash value for a 64B h input x, first the double round is applied ten times to 64B p c it and then the result is added: Plaintext Ciphertext Salsa20 ( x ) = doubleround 10 ( x ) + x Figure 3. Salsa20 hash function operating as Nevertheless, strictly speaking, since all the core a stream cipher definitions operate on a sequence of 4B words, the input x as well as the result needs to be transformed To create 64 bytes of the input to the hash function, using little endian notation (btw note that the ‘+’ sign the 16 or 32B key k, the 8B nonce ( number once – in the above equation is the sum mod 2 32 applied on a unique message identifier) and the 8B counter n are a word-by-word basis).
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-