IMAGE ENCRYPTION AND DECRYPTION USING BLOWFISH

advertisement
IMAGE ENCRYPTION AND DECRYPTION USING
BLOWFISH ALGORITHM IN MATLAB
Akshit Shah, Aagam Shah, Prof. Tanaji Biradar
EXTC, DJSCOE, Mumbai University, India
EXTC, DJSCOE, Mumbai University, India
EXTC, DJSCOE, Mumbai University, India
ashah2421@gmail.com, aagamshah09@gmail.com, tanaji.biradar@djsce.ac.in
Abstract: With the progress in communication technology, the necessity of information security has
become a global issue. Due to advancement in multimedia application, security becomes an
important issue of communication and storage of data. This paper is about cryptographic analysis
of data using 64-bits Blowfish which is a secret key block cipher having a variable key size up to 448
bits designed in order to secure communication and improve its performance. It iterates simple
function 16 times by employing Feistel network. The blowfish algorithm runs faster and prevents
unauthorized attack than the popular existing algorithms. Here MATLAB is used to design and
implement the algorithm.
Keywords: Cryptography, Image encryption, Decryption, Blowfish, Block Cipher.
I. Introduction:
Imagine a situation where in a military personal
wants to communicate with another person
regarding the national security and someone else
is able to intercept the message. How disastrous
it can be? He can easily debase with the national
security issue. It is also possible that the third
person may not allow the message to receive to
the receiver or intercepts the message and sends
his own message instead of the original
message. This is nothing but masquerading
which can be a threat to the national security.
Hence, there is a need to maintain security of
these data. The solution to this problem is
cryptography. Cryptography can be defined as
the art of safeguarding documents and it makes
sure that only the intended people are able to
visualize its content. In order to assure the
secrecy of the system every security system
must provide a bundle of security functions.
These functions are usually referred to as the
goals of the security system. The five main goals
behind using
Cryptography
includes
Confidentiality,
Authentication, Integrity, Non-Repudiation,
Service Reliability and Availability.
In this modern world data is stored more in
computers, hard disk, compact disks, etc and a
very less amount as papers in files. These data
and images stored in computers, when needed,
are to be transmitted over short and long
distances through both secure and insecure
computer networks for various applications.
During their transmissions, there are chances for
these highly confidential data to fall into wrong
hands, thus leading to dangerous situations.
Hence Cryptography comes into play to
maintain the confidentiality and security of the
same. There are many cryptographic methods to
provide security from which this paper
concentrates on Blowfish algorithm.
D=Decryption Ke and Kd=Encryption key and
Decryption key. Sender and receiver have pair
of keys for encryption and decryption in the
beginning and then they can begin to encrypt
and decrypt messages between them using those
keys. It is commonly used in Rivest Shamir
Adlman algorithm and Diffie Hellman Key
exchange.
II. Cryptography types:
The two types of cryptography are:
1. Symmetric key cryptography.
2. Asymmetric key cryptography.
Symmetric key cryptography is also called as
secret key cryptography or private key
cryptography. In secret key cryptography a
single key is used for encryption and decryption.
It is represented by P=D(K,EP()). Where
P=Plain text, E(P)=Encryption of plain text, D=
Decryption, K=Key.
Both the parties must agree upon the key before
any transmission begin, and nobody else should
know about it. Sender and receiver only have to
specify the shared key in the beginning and then
they can begin to encrypt and decrypt messages
between them using that key. It is commonly
used in Data Encryption Standard and Blowfish
Algorithm.
Asymmetric key cryptography is also called as
public key cryptography or conventional
cryptography system. In asymmetric key
cryptography two keys are used, one for
encryption and other is for decryption. It is
represented by P=D(Kd,E(Ke,P)) where
P=Plaintext, E(P)=Encryption of Plain text,
Figure 1: Symmetric and Asymmetric Encryption
Figure 2: Cryptography types
III. Blowfish Algorithm:
Blowfish algorithm is one of the symmetric or
private key cryptography techniques, which was
designed Bruce Schneier in 1993 and placed in
the public domain. Blowfish was designed with
the intention of replacing the aging Data
Encryption Standard (DES) and overcoming the
problems with other algorithms. It is very
popular in cryptographic software because it is
available to everyone. This algorithm is a 64-bit
block cipher technique where a message is
divided into multiple blocks of data which has
fixed length.It uses same secret key of variable
length for both encryption as well as decryption
of the messages. It is supposed to be faster than
DES when implemented onthe Pentium and the
PowerPC which are 32-bit microprocessors with
large stack data. Since Blowfish algorithm is
used where the key does not change much, it is
apt for applications like communications
link.The fundamental reason to design such an
algorithm was to keep the algorithm as simple to
implement and as secure as possible at the same
time. It is designed using so many key bits such
that the attacks which reduce the key bits
become irrelevant.
For example,
The input is a 64-bit data element, a.
If the input data is not 64 bits, then we pad zeros
to make it 64 bits.
The Blowfish encryption includes:
1. Manipulation of datain large blocks using
random permutations.
2. It uses a scalable key, from 32 bits to at least
256 bits.
3. It employs and generates precomputable subkeys.
4. It takes into account simple operations that are
efficient on microprocessors.
5. The no. of iterations varies for every
encryption.
6. Usageof sub-keys that are a one-way hash of
the key.
Divide into two 32-bit halves: aL, aR.
Blowfish algorithm constitutes of two main
parts: Data Encryption and Key-expansion.
The data encryption part constitutes of a 16round Feistal network wherein each round
consists of permutations depending on the keys
and substitutions depending on keys as well as
data. The operations which are used are XOR,
ADD and MOV which are chosen for faster
speeds.
In key-expansion, it converts a key of at the
most 448 bits into various sub-key arrays, 4168
bytes in total.[1]
Now we recombine aL and aR to get the
encrypted text.[2]
IV. Data encryption:
As shown below, Blowfish data encryption uses
a Feistal network with 16 rounds.
A Feistel network is a generic method to
transform any function (f function) into a
permutation.
The steps of how a single round of Feistal
network works is as follows:
1. Split each block of divided message into two
halves.
2. The old Right half of block becomes new left
half.
3. Apply function f to the old right half and the
key.
4. We get the new right half once we XOR the
old left half and the result of step 3.
Let Pb for b = 1 to 16 be the different sub-keys
used.
aL = aL XOR Pb
aR = F(aL) XOR aR
Swap aL and aR.
Continue this till the end of the 16thround, swap
aL and aR again to undo the last swap.
In the end, aR = aR XOR P17 and aL = aL XOR
P18.
Nevertheless, if this computation is not done, the
encryption operation should still be possible.
P is an array of 18, 32-bit integers.
S is an array of 32 bit integers which has
dimensions 4x256.
We initialize the P-array and only after that we
will initialize the S-boxes in this order only, with
a fixed string consisting of hexadecimal digits of
pi.
First entry of P-array (P1) = 0x243f6a88
Second entry of P-array (P2)= 0x85a308d3
Third entry of P-array (P3)= 0x13198a2e
Fourth entry of P-array (P4) = 0x03707344 etc.
1. Now, we XOR P1 with the first 32 key bits,
XOR P2 with the next 32 key bits and so on. We
continue to do this until all elements of the Parray has been XOR’d by the key bits.
2. Then we encrypt the zero string using these
sub-keys with the Blowfish algorithm.
Figure 3: Feistel Network
Figure 4: Generation of f function
V. Data Decryption:
To decrypt the data, we use the same
techniqueas that of encryption. The only
difference is that we use the sub-keys P1 to P18
in exactly the reverse order as that of encryption.
VI. Generation of Sub-keys:
Blowfish algorithm uses a large number of subkeys. These sub-keys are pre-computed in
Blowfish before it can be applied to any data
encryption or decryption. If this pre-computation
is not done, the speed of operations will get
compromised (i.e. it will get slower).
3. The output of step 2 is used to replace P1 and
P2.
4. The output of step 2 is encrypted with the
Blowfish algorithm using the modified keys.
5. P3 and P4 are replaced with the output of step
4.
6. We follow this process until all elements of Parray are replaced. After that we replace all 4 Sboxes in order only. The output of the ever
changing Blowfish algorithm replaces these
elements.
We need 521 iterations in sum to generate all the
sub-keys which are required for Blowfish
encryption. 4KB of the data will be processed.
These sub-keys can be stored somewhere rather
than computing it multiple times.[5]
VII. Advantages:
1. It has been accepted as one of the strong
encryption techniques.
2. Blowfish is patent as well as royalty free. It
can be used by any user.
3. It is the fastest encryption algorithm with the
speed of 26 clock cycles per byte.
4. It is very compact with less than 5 KB of
memory needed.
5. It is also secure due to variable length secret
keys.[4]
VIII. Disadvantages:
Figure 5: Image 1
1. It can be cracked only using brute-force
attacks if 256 bit keys are not used.
2. Susceptible to attacks on relatively weaker
keys.
3. It is recommended not to use Blowfish
encryption for files whose size is more than 4
GB due to its small 64-bit block size.
4. There are modern day successors of Blowfish
like AES, Twofish, Threefish etc. However,
these have not been as widespread as Blowfish
has.[4]
IX. Simulation and result:
In this paper we have simulated the image
processing part of Encryption and decryption in
MATLAB software. Here we would be taking
an image. Firstly we would be obtaining the
matrix and pixels of the chosen image & then we
would be encrypting the image matrix using
blowfish algorithm. The result shows the
original image, encrypted image and the
decrypted image. The other image in the image
will be hidden using a specific key and image
hidden with a data is encrypted and decrypted by
a 32 bit iteration loop and display in MATLAB.
We will clearly see that the decrypted image is
same as the original image.
Figure 6: Image 2
Figure 7: Encrypted Image 1
Figure 8: Encrypted Image 2
Figure 9: Decrypted Image 1
Figure 10: Decrypted Image 2
Conclusion:
Both color and black & white image of any size
saved in tagged image file format (TIF), Bit map
(bmp), Portable network graphics (PNG), Joint
Photographic Experts group (jpg), etc. can be
encrypted & decrypted using blowfish
algorithm. Histogram of encrypted image is less
dynamic and significantly different from the
respective histograms of the original image.
Blowfish cannot be broken until an attacker tries
28k+1 combinations where k is the number of
rounds. Hence if the number of rounds are been
increased then the blowfish algorithm becomes
stronger. Since Blowfish has not any known
security weak points so far it can be considered
as an excellent standard encryption algorithm.
References:
[1]. Irfan Landge, Burhanuddin Contractor,
Aamna Patel and Rozina Choudhary "Image
encryption and decryption using Blowfish
algorithm" Proceedings of the 2012 National
Conference of Emerging Trends in Information
Technology, Shirpur, Maharashtra, April 21 ,
2012.
[2]. https://www.schneier.com/paper-blowfishfse.html
[3].
http://www.embedded.com/design/configurablesystems/4024599/Encrypting-data-with-theBlowfish-algorithm
[4].
https://en.wikipedia.org/wiki/Blowfish_(cipher)
[5]. Singhal, Nidhi and Raina, J P S.
“Comparative Analysis of AES and RC4
Algorithms for Better Utilization”, International
Journal of Computer Trends and Technology,
ISSN: 2231-280, July to Aug Issue 2011.
Download