An Optimized Encryption Algorithm and F Function With Dynamic Substitution For Creating S-Box and P-Box Entries For Blowfish Algorithm
An Optimized Encryption Algorithm and F Function With Dynamic Substitution For Creating S-Box and P-Box Entries For Blowfish Algorithm
Rekha C, Krishnamurthy G N
Department of Computer Science and Engineering, BNM Institute of Technology, Bengaluru, Karnataka, India
Corresponding Author:
Rekha C,
Department of Computer Science and Engineering,
BNM Institute of Technology,
Bengaluru, Karnataka, India.
Email: [email protected]
1. INTRODUCTION
Cryptography plays an important role in network security [1], that transfers sensitive information
across insecure networks using encryption and decryption process. In cryptography the Key are confidentiality,
integrity, and authentication [2], [3]. Cryptographic algorithm is categorised into two different types symmetric
and asymmetric key cryptography. In symmetric key cryptography, only one key is used to encrypt and decrypt
the information. The key plays a major role in symmetric key cryptography. Depending on the basis of
operation symmetric key cryptography is divided into two types stream cipher and block cipher. A block cipher
is the one where a block of plaintext is converted into ciphertext block of same length [4]. One example of
symmetric block cipher is blowfish. A blowFish is a 16 round Feistel network which operates on plaintext with
64 bit blocks converted to ciphertext of 64 bit blocks, using a key which is ranging from 32 bits to 448 bits
used in the encryption and decryption of plaintext. Blowfish algorithm includes two procedures: a key-
expansion procedure and a data-encryption procedure. Data encryption function take place via 16 round Fiestel
network as shown in Figure 1, each round having permutation and substitution, using F-function as shown in
Figure 2, with key dependent. All operation performed are XORed and additions on 32-bit words and additional
operations are four indexed array data lookups per round. Key expansion procedure converts 448-bit key into
few subkey arrays of 4168 bytes [4], [5].
The key expansion procedure uses a key to generating P-box and S-box. Initialization of 18-P array
using key taken as P0 from P-array is XORed with first 32 bits of the key. P1 XORed with second 32 bits of
the key. Repeat this cycle until all P-array XORed with key bits. After initialization, pass two values of P value
(P0 and P1 as L0 and R0) to the function Encrypt as mentioned in Figure 1, which generate two different
encrypted key values L17 and R17. The output L17 and R17 of encryption function, is then copied to P0 and
P1. Repeat this step until all 18-P value entries are generated continuously in order by replacing the output. In
the same way S-box entries are initialized with fixed string like ‘pi’ value or zero, then pass two values of
S-box (S0 and S1 as L0 and R0) to the encryption function as shown in Figure 1, generates two different
encrypted values like L17 and R17 which is copied to S0 and S1. This step Continues till, replacing the output
by changing continuously in order all entries of four S-boxes of Blowfish algorithm. The function F works
takes 32 bit value as an input, and it divids into four 8 bit data. Each four 8 bit data is used for substitution. first
8 bit is used to get 32 bit value from S-box 0, second 8 bit data is used to get 32 bit value from S-box 1, third
8 bit data is used to get 32 bit value from S-box 2 and finally last 8 bit for S-box 3. Then first 32 bit value is
added with second 32 bit value , the output is XORed with third 32 bit value, the output is then added with
fourth value will get final 32 bit value as shown in Figure 2. To perform this initialization and generation of P-
box and S-box takes more time because of 16-round of encryption algorithm.
The blowfish algorithm is fast and useful block cipher. many implementation has been conducted
either through software or hardware. But very few implementation has been proposed to generate entries of
P-box and S-box for blowfish algorithm. A new secret key as been proposed for block cipher, blowfish, which
is a Feistel network with block size 64 bit and 32-bit to 448-bit a variable key [5]. The algorithm implemented
with a complicated initialization and large data caches of 32-bit microprocessor. Implemented a novel VLSI
architecture for blowfish algorithm which is based on partial pipelined structure [6]. The author in this paper
has used two different techniques of modified Feistel function, first is iterative method and, second is partially
pipelined technique. A four stage pipelined architecture is used along with two iterations that increases the area
occupied with increasing throughput of the algorithm when compared with the two stage pipelining with 8
iterations that will reduce the area occupied with reduced throughput. Discusses general optimization principles
of designing the algorithms, and performance analyzes of RC4, SEAL, RC5, Blowfish, and Khufu/Khafre on
the Intel Pentium with respect to those general optimized principles [7]. Presented, a one round VLSI
architecture of the BLOWFISH, which is based on the loop-folding technique combined with secure different
modes (ECB, CBC2, CFB2 and OFB2) of operation [8]. The architecture uses a prototype chip to implement
by using $0.35$ /spl mu/ CMOS technology. Presented DRIL architecture, which is a four-tier architecture
involving both software and hardware designs, for implementing blowfish algorithm using architectural
features like inner loop pipelining and loop folding with dynamic reconfiguration [9]. The main objective of
the research which is presented in this paper is to develop an algorithm with low-power, high throughput, real-
time, reliable and secure crypto system, that can be achieved through hardware implementations [10].
Implement a new secret-key 'Blow-CAST-Fish' block cipher that uses good features of both CAST-128 and
Blowfish algorithms using VHDL implementation [11]. Proposed a modified the Blowfish algorithm by
enhancing its performance in terms of speed, Throughput, Power consumption and Avalanche effect [12].
Author has proposed a way to enhance the performance of the Blowfish cryptography algorithm by introducing
parallel processing technique and making modifications to the Fiestel (F) function of Blowfish by combining
An optimized encryption algorithm and F function with Dynamic substitution for creating… (Rekha C)
18 ISSN: 2722-3221
the Blowfish and the Runge-kutta (RK) Method. The F function of Blowfish has been modified with different
formulae and the outcome of a series of RK-Blowfish algorithms were compared with the Blowfish algorithm.
The blowfish algorithm has been widely used in network security method to enhance the security by
implementing through software or hardware based on variety of aspects like speed, security, portability etc.
The scope of this work includes generation of P-box and S-box entries using a modified fiestel network, which
is simple structure, in order to reduce the computational cost of generating P-box and S-box entries in blowfish
algorithm. The main motivation of proposed work is to design and implementation of generating P-box and
S-box entries by reducing the number of rounds instead of 16- rounds of encryption algorithm to overcome
the limitation of blowfish algorithm. In this paper, a simple P-box and S-box generating algorithm to overcome
the computational cost is designed and implemented using modified fiestel network.
After initialization, pass two values P0 and P1 each of 32-bit, (as left half L0 and right half R0) to
modified algorithm. In the algorithm,
Then swap L1 and R1 and considered as input for next iteration. Repeat these steps to get the output
with two values P0 and P1, for this the modified encryption algorithm takes 9 iterations instead of 16 iterations.
The flowchart of the proposed modified encryption algorithm is given in Figure 3 and the algorithm for
proposed encryption algorithm 1 is given in section 4.1. The F function takes 32 bit value as an input and divids
into four 8 bit value. Each four 8 bit value is used for substitution from each four S-box and first 4 bit from
each 8 bit value is considered from which S-box we should get the value. The flowchart of the proposed
modified F- function is given in Figure 4 and the algorithm 2 is given in section 2.1.
An optimized encryption algorithm and F function with Dynamic substitution for creating… (Rekha C)
20 ISSN: 2722-3221
Figure 6. Encrypted image of arms bmp using Figure 7. Decrypted image of arms bmp using
original algorithm original algorithm
Figure 8. Encrypted image of arms bmp using Figure 9. Decrypted image of arms bmp using
modified algorithm modified algorithm
∑255 ′
𝐿 [𝐻𝐿 (𝐹 ) − [𝐻𝐿 (𝐹)]]
𝐸𝑄 =
256
Let F and F' is represented as original image and encrypted image of size M*N pixels with L grey
levels. At position (x,y), the grey levels of the F and F',(0 ≤ x ≤ M-1, 0 ≤ y ≤ N-1) is represented as F(x,y) and
\(F'\)$(x,y) \in L$ ranging from $0 to 255$.
The steps are:
Compute HL(F) the number of occurrences of each gray level L in the original image and HL(\(F'\))
denotes the number of occurrences of each grey level in the encrypted image.
Compute the average number of changes to each grey level L using above given mathematical formula.
Encryption Quality test is calculated using both original and modified blowfish algorithm is
shown in Table1.
Case 1: Comparing Avalanche effect for encrypted image of Arms.bmp and B1Arms.bmp with same key1
using original and modified algorithm.
Case 2: Comparing Avalanche effect for encrypted image of Arms.bmp and B1Arms.bmp with same key2
using original and modified algorithm.
Case 3: Comparing Avalanche effect for encrypted image of Arms.bmp with key1 and key2 using original and
modified algorithm.
Case 4: Comparing Avalanche effect for encrypted image B1MAND.bmp with key1and key2 using original
and modified algorithm.
An optimized encryption algorithm and F function with Dynamic substitution for creating… (Rekha C)
22 ISSN: 2722-3221
Table 3. Comparison of avalanche effect of original and modified blowfish algorithm for different rounds
with four cases
Number of Case 1 Case 2 Case 3 Case 4
Rounds Org Mod Org Mod Org Mod Org Mod
2 1123 2527 770 1588 2015 1612 1630 2013
4 1149 2390 761 1547 2049 1620 389 3328
6 1137 2416 772 810 1131 1652 2473 1155
8 992 2552 716 1570 1131 1652 1162 2440
10 2340 1186 1513 778 2437 1151 1976 1623
12 2335 1192 882 1428 1168 2851 1069 2471
14 2379 1182 825 1474 1953 1646 2425 1152
16 1206 2333 800 804 1999 1141 2439 1135
𝑐𝑜𝑣(𝑥, 𝑦)
𝑟𝑥𝑦 =
√𝐷(𝑥)√𝐷(𝑦)
where D(X) and D(Y) represents the variance of x and y values and COV(X,Y) is covariance of x and
y and is given by
𝑁
1
𝑐𝑜𝑣(𝑥, 𝑦) = ∑(𝑥𝑖 − 𝐸(𝑥))(𝑦𝑖 − 𝐸(𝑦))
𝑁
𝑖=0
Where N represents number of horizontal adjacent pixels selected randomly, E(X) and E(Y) represents
the mean values of x and y values. This test is carried out for about randomly selected horizontally adjacent
pixels from the original image Arms.BMP and encrypted images. Then using above equations correlation
coefficient will be computed and is as shown in below Figure. 10, Figure. 11, and Figure. 12. The correlation
coefficient of original image is 0.072053 and for cipher image which is encrypted by blowfish algorithm is
0.005616 and for modified algorithm is -0.429036. In both original and modified algorithm the correlation
coefficients for plaintext image with that of ciphertext images are far apart.
Figure 10. Correlation distribution of two Figure 11. Correlation distribution of two
horizontally adjacent pixels for original image arms horizontally adjacent pixels for encrypted image
BMP using original algorithm
Figure 12. Correlation distribution of two horizontally adjacent pixels for encrypted image using modified
algorithm
3.5. Entropy
The entropy [15] of an information data is measured in bits per character.The entropy is calculated as
the average amount at which information data is produced by a truly random source of data. To calculate this
mean, the individual information are weighted with the probabilities of their occurrence. The mathematical
formula for calculating entropy is
1
𝐻(𝑚) = ∑2𝑁−1
𝑖=0 𝑝(𝑚) log 2 𝑏𝑖𝑡𝑠 =
𝑝(𝑚𝑖 )
where p(𝑚𝑖 ) be the probability of occurrence of a character and entropy is presented in bits. After
evaluating the above equation 4, we obtain its entropy as H(m) = 8 , which is corresponding to a truly random
source. Given an information source that generates random messages, in general its entropy value is lesser than
the ideal one. However, when the messages are encrypted, their entropy should be 8. If the output of a block
cipher emits with entropy less than 8, there exists certain degree of predictability, which endanger its security.
Let us consider the ciphertext of an image, encrypted using the original as well as modified algorithm, the
number of occurrence of each ciphertext block and the probability of occurrence is computed. The obtained
information entropy is very much close to the theoretical value of 8. This means that leakage of the information
data in the encryption process is negligible and the encryption system is secure against entropy attack. The
entropy is calculated using equation. 4 and is listed in below Table 4.
Table 4. Comparison of entropy for different rounds of original and modified blowfish algorithm
Number of Original Modified
Rounds Blowfish Blowfish
2 6.74 6.86
4 7.03 7.03
6 6.96 7.07
8 7.06 7.05
10 7.07 7.07
12 7.06 7.06
14 7.05 7.06
16 7.07 7.07
An optimized encryption algorithm and F function with Dynamic substitution for creating… (Rekha C)
24 ISSN: 2722-3221
Figure 14. Floating frequency for encrypted image using original algorithm
Figure 15. Floating frequency for encrypted image using modified algorithm
4. CONCLUSION
To enhance the security features of blowfish algorithm, the proposed method has been designed and
implemented to create S-box and P-box values of blowfish algorithm using modified encryption algorithm and
modified F function with dynamic substitution. The main motivation behind for proposed algorithm is to reduce
the time for generating s-box and P-box values by reducing the number of rounds, 9 iterations with 9 rounds,
instead of 9 iterations with 16 rounds in the encryption algorithm for blowfish algorithm. From the results, the
proposed modified encryption algorithm performs better in all the aspects when compared with the original
blowfish algorithm.
REFERENCES
[1] Kumar, M. Anand and S. Karthikeyan. “Investigating the Efficiency of Blowfish and Rejindael (AES) Algorithms.”
International Journal of Computer Network and Information Security, vol. 4, pp. 22-28, 2012.
[2] Behrouz A. Forouzan. “Cryptography and Network Security”, Tata McGraw-Hill, 2nd edition, 2008.
[3] Anand Kumar M and Dr. S. Karthikeyan. “Investigating the Efficiency of Blowfish and Rejindael Algorithms.”
International Journal of Computer Network and Information Security, pp. 22-28, 2012.
[4] William Stallings. “Cryptography and Network Security.” Fifth Edition, Pearson Publication, Prentice hall, 2013.
[5] B. Schneier. “Description o f a new variable-length key, 64-bit block cipher (blowfish).” International Workshop on
Fast Software Encryption, Springer, Berlin, Heidelberg, vol 809, pp 191-204, 1994.
[6] Karthigaikumar, P. and K. Baskaran. “Partially Pipelined VLSI Implementation of Blowfish Encryption/Decryption
Algorithm.” Int. J. Image Graph. vol. 10, pp. 327-341, 2010.
[7] Schneier B., Whiting D. “Fast software encryption: Designing encryption algorithms for optimal software speed on
the Intel Pentium processor.” In: Biham E. (Eds) Fast Software Encryption. FSE 1997. Lecture Notes in Computer
Science, Springer, Berlin, Heidelberg, vol 1267, 242-259, 1997.
[8] Yeong-Kang Lai and Yu-Chuan Shu. “A novel VLSI architecture for a variable-length key, 64-bit Blowfish block
cipher.” 1999 IEEE Workshop on Signal Processing Systems. SiPS 99. Design and Implementation (Cat.
No.99TH8461), Taipei, Taiwan, pp. 568-577, 1999.
[9] Sudarshan T.S.B., Mir R.A., Vijayalakshmi S. “DRIL– A Flexible Architecture for Blowfish Encryption Using
Dynamic Reconfiguration, Replication, Inner-Loop Pipelining, Loop Folding Techniques.” In: Srikanthan T., Xue J.,
Chang CH. (Eds) Advances in Computer Systems Architecture. ACSAC 2005. Lecture Notes in Computer Science,
Springer, Berlin, Heidelberg, vol 3740, pp. 625-639, 2005.
[10] P.KarthigaiKumara, K.Baskaran. “An ASIC implementation of low power and high throughput blowfish crypto
algorithm.” Microelectronics Journal, vol. 41, no. 6, pp. 347-355, June 2010.
[11] Krishnamurthy G.N, Dr. V. Ramaswamy, Leela G.H and Ashalatha M.E. “Blow-CAST-Fish: A New 64-bit Block
Cipher.” IJCSNS International Journal of Computer Science and Network Security, vol. 8, no.4, pp. 282-290, April
2008.
[12] Krishnamurthy G.N, Dr. V. Ramaswamy and Mrs. Leela G.H. “Performance enhancement of Blowfish algorithm by
modifying its function.” Innovative Algorithms and Techniques in Automation, Industrial Electronics and
Telecommunications, pp. 241-244, 2007.
[13] V Ramaswamy Krishnamurthy G N. “Encryption quality analysis and security evaluation of blow-castfish using
digital images.” Communicated to International Journal of Computational Science, 2008.
[14] Shailaja S1, Dr Krishnamurthy G N2. “Comparison of Blowfish and Cast-128 Algorithms Using Encryption Quality,
Key Sensitivity and Correlation Coefficient Analysis.” American Journal of Engineering Research (AJER), vol. 3,
no. 7, pp-161-166, 2014.
[15] Yue Wua, Joseph P. Noonana, Sos Agaianb. “Shannon Entropy based Randomness Measurement and Test for Image
Encryption.” Information Sciences, 2011.
[16] Sonal Kulshreshtha, Vikram Verma, Richa Kalra. “Analytical View of Cryptographic Techniques through Cryptool.”
Journal of Telecommunications, vol. 10, no. 2, pp. 22-26, 2011.
An optimized encryption algorithm and F function with Dynamic substitution for creating… (Rekha C)