Secured Data Transmission Using RC4 Algorithm: Encrypting and Decrypting Double Byte Data 1 2 3 SAIPRIYA SAMALA , P.NAVITHA , DR
Total Page:16
File Type:pdf, Size:1020Kb
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: Cryptography is a science which deals with hiding the data. For hiding the information encryption 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 stream cipher and block cipher. 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 key-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.