ISSN 2319-8885 Vol.03,Issue.27 September-2014,

Pages:5415-5418

www.ijsetr.com

Secured Data Transmission using RC4 Algorithm: Encrypting and Decrypting Double Byte Data 1 2 3 SAIPRIYA SAMALA , P.NAVITHA , DR. M.GURUNADHA BABU Dept of VLSI System Design, CMRIT, Hyderabad, India, Email: [email protected].

Abstract: is a science which deals with hiding the data. For hiding the information is done by using encryption algorithm, to retrieve it back decryption is done by decryption algorithm. Cryptography can be performed on two types of ciphers which are and . In stream cipher transmission is performed either bit by bit or byte by byte. Where as in Block cipher transmission is performed block by block. In this paper we deal with stream cipher; and one of the most popular stream ciphers is the RC4 stream cipher. RC4 stream cipher usually generates one byte per clock cycle. Proposed RC4 algorithm generates two bytes per clock cycle. Encryption is performed by using two keys and two blocks of plain texts. Similarly, decryption is performed by using the two keys and two blocks of cipher texts.

Keywords: Cryptography, Decryption, Encryption, Loop Unrolling, Pipelining, RC4, Stream Cipher.

I. INTRODUCTION II. RC4 STREAM CIPHER In any communication channel, it is important that the The RC4 stream cipher was designed in 1987 by Ron data being transmitted from the sender to the receiver end Rivest for RSA Data Security. RC4 cipher stream is a reaches the receiver without any change in the data which is variable -size stream cipher with byte-oriented operations. transmitted. Such communication without any change in the It is based on use of random permutation (PRGA). RC4 was data can be done using the cryptographic techniques. a trade secret by RSA Security until September 1994when Cryptography means to communicate in the presence of a the algorithm was posted on internet on the hacker's cyberpunk. It should also meet the requirements such as remailers list. This algorithm is simple and quite easy to confidentiality, authentication, data integrity and non- explain. It uses a memory location of N=256 bytes repudiation. The theory of cryptography tells what exactly represented as S-box S.A secret key of l bytes represented as these problems are, how to evaluate them, about protocols k is used to scramble this initially used 256 memory location that support to solve them, and how to build protocols in bytes. For encryption and decryption, a single byte S[n] is whose security we can have confidence. The basic issues can generated from S by selecting data in one of the 255 locations be discussed with the process of encryption. Basic problem in in a systematic fashion. As each value of S[n] is generated the field of cryptography is secured communication over an after scrambling, the data in memory locations in S are once insecure channel. Person X wants to send person Y a secret again permuted. message over a communication channel which can be tapped by a cyberpunk. A. Initialization and Scrambling In the beginning, the 256 memory locations are assigned The solution to this problem is private key encryption. In values in a order as s[0]=0, s[1]=1, s[2]=2,s[3]=3…and so on private key encryption: x and y agree on a pair of encryption i.e., s[I]=I. A temporary 256 bytes memory is also generated. and decryption algorithms A and B, with an additional This temporary memory location has a key of K=256 bytes. information K to be kept secret. We refer to K as common If the key is not of 256 bytes and by considering the key to be secret key. The cyberpunk can know the encryption and „keylength‟ bytes, the first number of bytes same as decryption algorithms A and B which are being used, but „keylength‟ are occupied by the key in the temporary cannot know K. When X wants to send Y the clear text or memory location and in the place of remaining bytes the plaintext message m over the insecure communication line, X „keylength‟ is repeated until it reaches I=255 location. This encrypts m by computing the cipher text c = A (K; m) and temporary memory location can be represented as T [I].These sends c to Y. Upon receipt Y decrypts c by computing m = B operations can be mathematically shown as: (K; c). The line-tapper, who does not know K, should not be for I = 0 to 255 able to compute m from c. S [I] = I;

T [I] = K [I mod keylength];

Copyright @ 2014 IJSETR. All rights reserved. SAIPRIYA SAMALA, P.NAVITHA, DR. M.GURUNADHA BABU Then T is used to produce initial permutation of S (scrambling). This starts from s [0] and goes till s [255] and each s [I] is swapped with other ith location in S by following the below shown method: j = 0; Because the only operation on S is a swap, the only effect is a permutation. S still contains all the numbers from 0 for I = 0 to 255 through 255 but not necessarily in the same order. do j = (j + S [I] + T [I]) mod 256; Swap (S [I], S[j]);

Since the operation performed is only swapping S will all values from 0 to 255 but not necessarily in the same order.

B. Pseudo random Stream Generation Once the S is initialized, the input key K is not used anymore. Stream generation starts with S[0] and goes through till S[255], and, for every S[I], swapping S[I] with another byte in S according to a method dictated by the current configuration of S. After S [255] is reached, the process continues, again from S [0] following the same process:

I, j = 0; Fig2. Circuit 2 used for calculating j1 and j2 while (true) I = (I + 1) mod 256; C. Swapping j = (j + S [I]) mod 256; The swapping operation mentioned in the algorithm swap Swap (S [I], S[j]); (s[i],s[j]) results in any one of the following eight possible t = (S [I] + S[j]) mod 256; data transfers among the registers of the S-bank, depending k = S[t]; on the possible values of i1, j1, i2, j2.

To encrypt XOR the value k with the next byte of plaintext, Table1. to decrypt XOR the value k with the next byte of cipher text. III. PROPOSED METHOD FOR PERFORMING RC4 A. Calculation of i1 and i2 i0 is a memory byte which initially stores the value 0 and is then incremented by 1 and 2 using the same clock pulse applied to two synchronous 8-bit counters. The i1 counter is initially loaded with 00000001 and the counter i2 is initially loaded with 00000010, initial states of these two indices. This is the first round of the KSA of RC4. This will result in increments of odd values 1,3,5…, in the i1 counter and increments of even values 2,4,6…, for i2 counter as required in RC4. This assures that the LSB of i1will always be 1 and that of i2 will always be 0.

Fig1. Circuit 1 to calculate i1 and i2

B. Calculation of ji and j2 The values of j1 and j2 can be calculated using a 2-input adder as shown in the below equation. This equation has two conditions as mentioned below: J1=j0+1; Fig3. Circuit 3 for calculating S[k] after pseudo random J2=ji+s1[i2]=j0+s0[i1]+s1[i2] generation. j = (j + S [I] + T [I]) Mod 256; International Journal of Scientific Engineering and Technology Research Volume.03, IssueNo.27, September-2014, Pages: 5415-5418 Secured Data Transmission using RC4 Algorithm: Encrypting and Decrypting Double Byte Data The circuit 5 is used two calculate the value of Z2 after the execution of second PRGA loop.

IV. ENCRYPTION The plain text when XORed with key obtained from the RC4 algorithm gives the cipher text. S[i] xor k{i]=C[i] The above equations are used to perform the swap operations. The values of i1,i2,j1 and j2 lead to eight possible data transfers. The transfer and the swapping operations are performed based on the above equations.

D. Stream generation The two consecutive values of Z are generated together, for the consecutive plaintext bytes to be encrypted. Assume that the initial values of the variables i,j and S are i0, j0, and S0, respectively. After the first execution of the PRGA loop, these values will be i1, j1, and S1, respectively, and the output byte is Z1, say. Similarly, after the second execution of the PRGA loop, these will be i2, j2, S2, and Z2, respectively. Thus, for the first two loops of execution to complete, the following table is used. Fig6. V. DECRYPTION The cipher text when XORed with the same key used in encryption gives the plain text initially sent from the sender. C[i] xor k[i]=S[i]

Fig4. Circuit 4 to calculate Z1 Fig7. The circuit 4 is used for calculating the value of Z after the VI. SIMULATION RESULTS execution of the first loop of PRGA.

Fig5. Circuit for calculating Z2. Fig8. International Journal of Scientific Engineering and Technology Research Volume.03, IssueNo.27, September-2014, Pages: 5415-5418 SAIPRIYA SAMALA, P.NAVITHA, DR. M.GURUNADHA BABU [9] P. Hamalainen, M. Hannikainen, T. Hamalainen, and J. Saarinen,“Hardware Implementation of the Improved WEP and RC4 Encryption Algorithms for Wireless Terminals,”Proc. European Signal Processing Conf.,pp. 2289-2292, 2000. [10] P. Kitsos, G. Kostopoulos, N. Sklavos, and O. Koufopavlou, “Hardware Implementation of the RC4 Stream Cipher,” Proc. IEEE 46th Midwest Symp. Circuits and Systems, http:// dsmc.eap.gr/en/members/pkitsos/papers/Kitsos_c14.pdf, 2003. [11] J.-D. Lee and C.-P. Fan, “Efficient Low-Latency RC4 Architecture Designs for IEEE 802.11i WEP/TKIP,”Proc. Int‟l Symp. Intelligent Signal Processing and Comm. Systems (ISPACS ‟07),pp. 56-59, 2007. [12] T. Lynch and E.E. Swartzlander Jr., “A Spanning Tree Carry Lookahead Adder,”IEEE Trans. Computers,vol. 41, no. 8, pp. 931-939, Aug. 1992. [13] I. Mantin, “Predicting and Distinguishing Attacks on RC4 Keystream Generator,”Proc. 24th Ann. Int‟l Conf. Theory and Applications of Cryptographic Techniques (EUROCRYPT ‟05), Fig9. vol. 3494, VII. CONCLUSION pp. 491-506, 2005. In this paper we designed proposed algorithm. It has [14] I. Mantin, “A Practical Attack on the Fixed RC4 in the WEP ksa and prga algorithms.KSa was discussed using 3 circuits Mode,”Proc. 11th Int‟l Conf. Theory and Application of and PRGA was implemented using five circuits. Using these Cryptology two algorithms we generated two keys . this key was used to and Information Security,vol. 3788, pp. 395-411, 2005. perform encryption and decryption. All the above mentioned [15] I. Mantin and A. Shamir, “A Practical Attack on modules were implemented using Xillinx 13.2 and VHDL. Broadcast RC4,” Proc. Eighth Int‟l Workshop Fast Software Encryption (FSE ‟01), VIII. REFERENCES vol. 2355, pp. 152-164, 2001. [1] M.D. Galanis, P. Kitsos, G. Kostopoulos, N. Sklavos, and [16] D.P. Matthews Jr., “System and Method for a Fast C.E. Goutis, “Comparison of the Hardware mplementation of Hardware Implementation of RC4,” US Patent Number Stream Ciphers,”Int‟l Arab J. Information Technology,vol. 2, no. 6549622, Campbell, CA, http://www.freepatentsonline.com/ 4, pp. 267-274, 2005. 6549622.html, Apr. 2003. [2] J. Golic, “Linear Statistical Weakness of Alleged RC4 [17] D.P. Matthews Jr., “Methods and Apparatus for Keystream Generator,”Proc. Advances in Cryptology Accelerating ARC4 Processing,” US Patent Number EUROCRYPT,vol. 1233, pp. 226-238, 1997. 7403615, Morgan Hill, CA, http://www.freepatentsonline. [3] T. Good and M. Benaissa, “Hardware Results for Selected com/7403615.html, July 2008. StreamCipher Candidates,” eSTREAM, ECRYPT Stream Cipher [18] A. Maximov and D. Khovratovich, “New State Project, SASC, Report 2007/023, 2007. Recovering Attack on RC4,”Proc. 28th Ann. Conf. : Advances in Cryptology, vol. 5157, pp. 297-316, 2008. [4] F.K. Gurkaynak, P. Luethi, N. Bernold, R. Blattmann, V. [19] I. Mironov, “(Not So) Random Shuffles of RC4,” Proc. Goode,M. Marghitola, H. Kaeslin, N. Felber, and W. 22nd Ann. Int‟l Cryptology Conf. Advances in Fichtner, “Hardware Evaluation of eSTREAM Candidates: Cryptology,pp. 304-319, 2002. , , MICKEY, MOSQUITO, SFINKS, [20] G. Paul and S. Maitra, “On Biases of Permutation and , VEST, ZK-Crypt,” eSTREAM,ECRYPT Stream Keystream Bytes of RC4 Towards the Secret Cipher Project, Report 2006/015, 2006 Key,”Cryptography and Comm., vol. 1, no. 2, pp. 225-268, [5] Software Performance Results from the eSTREAM 2009. Project,eSTREAM, the ECRYPT Stream Cipher Project, [21] A. Roos, “A Class of Weak Keys in the RC4 Stream http://www.ecrypt.eu.org/stream/perf/#results, 2012. Cipher,” Two Posts in sci.crypt, http://marcel.wanda.ch/ [6] The Current eSTREAM Portfolio, eSTREAM, the ECRYPT Archive/WeakKeys, 1995. Stream Cipher Project, http://www.ecrypt.eu.org/stream/ index. [22] S. Sen Gupta, K. Sinha, S. Maitra, and B.P. Sinha, “One html, 2012. Byte per Clock: A Novel RC4 Hardware,”Proc. [7] S.R. Fluhrer and D.A. McGrew, “Statistical Analysis of the INDOCRYPT ‟10,vol. 6498, pp. 347-363, 2010. Alleged RC4 Keystream Generator,”Proc. Seventh Int‟l [23] B.P. Sinha and P.K. Srimani, “Fast Parallel Algorithms Workshop Fast Software Encryption (FSE ‟00),vol. 1978, pp. 19- for Binary Multiplication and Their Implementation on 30, 2000. Systolic Architectures,”IEEE Trans. Computers,vol. 38, no. [8] S.R. Fluhrer, I. Mantin, and A. Shamir, “Weaknesses in the 3, pp. 424-431, Mar. 1989. Key Scheduling Algorithm of RC4,”Proc. Eighth Ann. Int‟l [24] D. Wagner My RC4 Weak Keys, Post in sci.crypt, http:// Workshop Selected Areas in Cryptography (SAC ‟01),vol. 2259, www.cs.berkeley.edu/daw/my-posts/my-rc4-weak-keys, pp. 1-24, 2001. 1995. International Journal of Scientific Engineering and Technology Research Volume.03, IssueNo.27, September-2014, Pages: 5415-5418