Cha 2018-2019 A
Cha 2018-2019 A
Cha 2018-2019 A
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION ENGINEERING
Submitted by
A. Jaya Kumar (315126512002) Harsha Aditya R (315126512050)
G. Rajesh (315126512046) A. Sandya Rani (315126512007)
Under the guidance of
Mrs Ch. Anoosha
Asst. Professor
CERTIFICATE
This is to certify that the project report entitled “IMAGE ENCRYPTION USING
LOGISTIC AND RECTANGULAR CHAOTIC MAPS” submitted by A. Jaya
Kumar (315126512002), Harsha Aditya. R (315126512050), G. Rajesh
(315126512046), A. Sandya Rani (315126512007) in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in Electronics &
Communication Engineering of Andhra University, Visakhapatnam is a record of
bonafide work carried out under my guidance and supervision.
We would like to express our deep gratitude to our project guide Name of project guide
Designation, Department of Electronics and Communication Engineering, ANITS, for
his/her guidance with unsurpassed knowledge and immense encouragement. We are
grateful to Dr. V. Rajyalakshmi, Head of the Department, Electronics and
Communication Engineering, for providing us with the required facilities for the
completion of the project work.
We are very much thankful to the Principal and Management, ANITS, Sangivalasa,
for their encouragement and cooperation to carry out this work.
We express our thanks to all teaching faculty of Department of ECE, whose suggestions
during reviews helped us in accomplishment of our project. We would like to thank all
non-teaching staff of the Department of ECE, ANITS for providing great assistance in
accomplishment of our project.
We would like to thank our parents, friends, and classmates for their encouragement
throughout our project period. At last but not the least, we thank everyone for supporting
us directly or indirectly in completing this project successfully.
PROJECT STUDENTS
A. Jaya Kumar (315126512002)
Harsha Aditya. R (315126512050)
G. Rajesh (315126512046)
A. Sandya Rani (315126512007)
ABSTRACT
Certificate
Acknowledgement
Abstract
List of Figures
List of Tables
1. Introduction
1.1 Introduction to Cryptography .................................................................................1
INTRODUCTION
The word cryptography comes from the Greek words Krypto (hidden or secret) and
graphein (writing). Oddly enough, cryptography is the art of secret wrting More generally
people think of cryptography as the art of mangling informaticn nto apparent
unintelligibility in a manner allowing a secret methcd of unmargl ng. The basic service
provided by cryptography is the ability to send information between participants in a way
that prevents others from reading it. In this book we will concentrate on the kind of
cryptography that is based on representing information as numbers and mathematically
manipulating those numbers. This kind of cryptography can provide other services, such
as
• Integrity checking-reassuring the recipient of a message that the message has not been
altered since it was generated by a legitimate source
• Authentication-verifying someane's (or something's) identity
But back to the traditional use of cryptography. A message in its criginal form is
known as plaintext or clear text. The mangled information is known as cipher-text. The
process for producing cipher-text from plaintext is known as encryption. The reverse of
encryption is called decryption. While crvptographers invent clever secret codes,
cryotanalysts attempt to break these codes. These two disciplines constantly try to keep
anead of each other. Ultimately, the success of the cryptographer's rests on the plaintext,
cipher-text, plaintext encrypt on end
decryption.
Cryptographic systems tend to involve both an algorithm and a secret value. The
secret value is known as the key. The reason for having a key in addition to an algoritnm
is that it is difficult to keep devising new al gorithms that will allow reversible
1
scrambling of information, and it is difficult to quickly explain a newly devised algorithm
to the person with whom you'd like to start communicating securely. With a good
cryptographic scheme, it is perfectly OK to have everyone, including the bad guys (and
the cryptanalysts) know the algorithm because knowledge of the algorithm without the
key does not help unmangle the information. The concept of a key is analogous to the
combination for a combination lock. Although the concept of a combination lock is well
known (you dial in the secret numbers in the correct sequence and the lock opens), you
can't open a combination lock easily without knowing the combination.
Cryptography is the practice and study of techniques for secure communication in
the presence of third parties called adversaries. More generally, cryptography is about
constructing analysing prctocols that prevent third parties or the public from reading
private messages various aspects in information security such as data confidentiality, data
integ'ity. authentication, and non-repudiation are central to modern cryptography.
2
difficult to implement than the best theoretically breakable but computationally secure
mechanisms.
The growth of cryptographic technology has raised a number of legal issues in the
information age. Cryptography's potential for use as a tool for espionage and sedition has
led many governments to classify it as a weapon and to limit or even prohibit its use and
export. In some jurisdictions where the use of cryptography is legal, laws permit
investigators to compel the disclosure of encryption keys for documents relevant to an
investigation. Cryptography also plays a major rcle in digital rights management and
copyright infringement of digital media.
1.2 Terminology
The first use of the term cryptograph (as opposed to cryptogram) dates back to the
19th century- it originated in The Gold-Buy, a novel by Edgar Allan Pos.
1.2.1 Cipher
It is a pair of algorithms that create the encryption and the reversing decryption.
The detailed operation of a cipher is controlled both by the algorithm and n cach
instance by a "key". The key is a secret (ideally known only to the communicants),
usually a short string of characters which is needed to decrypt the cipher text.
3
decryption algorithms which correspond to each key. Keys are important both formally
and in actual practice, as ciphers without variable keys can be trivially broken with only
the knowledge of the cipher used and are thereforc uscless (or even counter-productive)
for most purposes. Historically, ciphers were often used directly for encryption or
decryption withcut additional procedures such as authentication or integrity checks.
There are two kinds of cryptosystems: symmetric and asymmetric. In symmetric systems
the sarne key (the secret key) is used to encrypt and decrypt a message. Data
manipulation in symmetric systems is faster than asymmetric as they generally use
shorter key lengths. Asymmetric systems use a public key to encrypt a message a private
key to decrypt it. Use of asymmeric systems enhances the security of communication.
Examples of asymmetric systems include RSA (Rivest-Shamir-Adleman), and ECC
(Elliptic Curve Cryptography). Symmetrice models include the commonly used AES
(Advanced Encryption Standard) which replaced the older DES (Data Encryption
Standard).
In colloquial use, the term "code" is often used to mean any method of encrypticn
or concealment of meaning. However, in cryptography, code has a more specific
meaning. It means the replacement of a unit of plaintext with a code word (for example,
"wallaby" replaces attack at dawn")
Cryptanalysis is the term used for the study of methods for obtaining the meaning
of encrypted information without access to the key normally required to do so; i.e., it is
the study of how to crack encryption algorithms or their implementations.
4
The study of characteristics of languages that have some application in
cryptography or cryptology (e.g. frequency data, etter combinations, universal patterns,
ete.) is called crypto linguistics.
5
design and cryptanalysis. Many computer ciphers can be characterized by their operation
on binary bit sequences (sometimes in groups or blocks), unlike classical and mechanical
sehemes, which generally manipulate traditional characters (i.c., letters and digits)
directly. However, computers have also assisted cryptanalysis, which has compensated to
some extent for increased cipher complexity Nonetheless, good modern ciphers have
stayed ahead of cryptanalysis; it is typically the case that use of a quality cipher is very
efficient (i.e, fast and requiring few resources, such as memory or CPU capability). while
breaking it requires an effort many orders of magnitude larger, and vastly larger than that
required for any classical cipher, making cryptanalysis so inefficient and impractical as to
be effectively impossible.
6
As well as being aware of cryptographic history, cryptographic algorithm and
system design must also sensibly consider probable furure developments while working
on their designs. For instance, continuous improvements in computer processing power
have increased the scope of brute-force attacks, so when specifying key lengths, the
required key lengths are similarly advancing.] The potential effects of quantum
computing are already being considered by some cryptographic system designers
developing post-quantum cryptography: the announced imminence of small
implementations of these machines may be making the need for this pre emptive caution
rather more than merely speculative.
Essentially, pricr to the early 20th century, cryptography was chiefly concerned
with linguistic and lexicographic patterns. Since then the emphasis has shifted, and
eryptography now makes extensive use of mathematics, including aspects of information
theory, computational complexity, statistics, combinatorics, abstract algebra, number
theory, and finite mathematics generally. Cryptography is also a brarch of engineering,
but an unusual one since it deals with active, intelligent, and malevolent opposition (see
cryptographic engineering and security engineering); other kinds of engineering (e.g,
civil or chemical engineering) need deal only with neutral natural forces. There is also
active research examining the relationship between cryptographic problems and quantum
physics (see quantum cryptography and quantum computer).
7
modern technology, cyphers using keys with these lengths are becoming easier to
decipher DES, an carly US Government approved cypher, has an effective key length of
56 bits, and test messages using that cypher have been broken by brute force key search.
However, as technology advances, so does the quality of encryption. Since World War II,
one of the most notable advances in the study of cryptography is the introduction of the
asymmetric key eyphers (sometimes termed public-key cyphers). These are algorithms
which use two mathematically related keys for encryption of the same message. Some of
these algorithms permit publication of one of the keys, due to it being extremely difficult
to determine one key simply from knowledge of the other.
The modern field of cryptography can be divided into several areas of study.
8
1.5.1 Symmetric-Key Cryptography (Private Key Cryptography)
Symmetric key ciphers are implemented as either block c phers or stream ciphers.
A block cipher enciphers input in blecks of plainext as opposed tc indivicual characters,
the input form used by a stream cipher.
The Data Encryption Standerd (DES) and the Advanced Encryption Standard(A
ES) are block cipher designs that have heen designated cryptography standerds by the US
govemment (though DESs designation was finally withdrawn after the AFS was adopted)
Despite its deprecation as an official standard, DES (especially its still-approved and
much more secure triple-DES variant) remains quite popular; it is used across a wide
range of applications, from ATM encryption to e-mail privacy and secure remote access
Many other block ciphers have been designed and released, with considerable variation in
quality. Many have been thoroughly broken, such as FEAI.
Stream ciphers, in contrast to the block' type, creare an arbitrarily long stream of
key material, which is combined with the plaintext bic-by-bit or character-by-character,
somewhat like the one-time pad. In a stream cipher, the output stream is created based on
a hidden internal state that changes as the cipher operates. That internal state is iritially
set up using the secret key material. RC4 is a widely used stream cipher; see category
stream ciphers. Block ciphers can be used as stream ciphers; see block cipher modes of
operation.
9
Message authentication codes (MACs) are much like cryptographic hash
functions, except that a secret key can be used to authenticate the hash value upon
receipt; the additional complication blocks a attack scheme against bare digest
algorithms, and so has been thought worth the effort.
Symmetric-key cryptosystems use the same key for encryption and decryption of
a message, though a message or group of messages may have a different key than others.
A significant disadvantage of symmetric ciphers is the Key Management necessary to use
them securely Each distinct pair of communicating parties must, ideally, share a different
key, and perhaps each cipher text exchanged as well. The number of keys required
increases as the square of the number of network members, which very quickly requires
complex key management schemes to keep them all consistent and sccrct. The difficulty
of securely establishing a secret key between two communicating parties, when a secure
10
channel does not already exist between them, also presents a chicken-and-egg problem
which is a considerable practical obstacle for cryptography users in the real world.
In public-key cryptosystems, the public key may be freely distributed, while its
paired private key must remain secret. In a public-key encryption system, the public key
is used for encryption, while the private or secret key is used for decryption. While Diffie
11
and Hellman could not find such a system, they showed that public-key cryptography was
indeed possible by presenting the Diffie-Hellman key exchange protocol, a solution that
is now widely used in secure communications to allow two parties to secretly agree on a
shared encryption key.
12
schemes. Digital signatures are central to the operation of public key infrastructures and
many network security schemes (e.g.. SSL/TLS, many VPNs, etc.).
Algorithms for encrypting computer data come in two main varieties: symmetric
and asymmetric. Each encryption type has inherent strengths and weaknesses. Symmetric
algorithms convert plain-text daia into an unreadable ciphertext using a single key or
password they decrypt the ciphertext using the same key. These algorithms are relatively
simple and quick, but if third parties intercept the key they can cecrypt the messages. The
need for trustworthy e-commerce and computer-file security has led researchers to
develop several types of encryption algorithms.
13
1.6.1 DES and Triple DES:
The Triple Data Encryption Standard, or Triple DES a gorithm, evolved from the
original DES a gorithm introduced as a standard in 1976. DES uses 56 bits of a 64-bit key
to encrypt messages in fixed-sized blocks of data. Though considered secure in the
1970s, advances in computing speed led to scphisticated attacks breaking DES encryption
in the late 1990's. Because researchers found DES vulnerable, software developers
instead use a newer standard, Triple DES. The new standard increases the strength of the
algcrithm by using twc or three 64-bit keys and performing encryption three times on
each message. The results of each pass are used as the source for the next one.
1.6.2 RC2
Rivest developed the RC2 algorithm in the late 1980s as a replacement for DES.
RC2 encrypts data in 64-bit blocks and has a variable key size of 8 to 128 bits in 8-bit
increments Lotus Development requested Rivest's help in creating RC2 for the company's
Lotus Note software. Because a large part of an encryption algorithm's strength lies in the
length of its keys researchers now consider RC2 to be too casily compromised.
14
1.6.4 Serpent:
Cambridge researchers Ross Anderson, Eli Biham, and Lars Knudsen developed
the Serpent algorithm in 2000. The researchers believed other algorithms had theoretical
flaws that rendered their encryption vulnerable to shortcut attacks. They sought to
develop an encryption algorithm that was as free from thesc flaws as possible. Serpent
was the result of their efforts; it uses a 128-bit block and 256-bit keys. As with Blowfish
and Twofish, the Serpent algorithm is in the public domain. Researchers have given
Serpent very high scores for "safety factor." Or trustworthiness against attacks.
1.6.5 IDEA:
15
CHAPTER 2
PYTHON PROGRAMMING
2.1 Introduction
The idea of Python originated in 1989 when its creator Guido van Rossum was
confronted by the shortcomings of ABC language (namely extensibility). Rossum started
work on developing a new language that integrated all good features of ABC language
and new desired features, such as extensibility and exception handling. Python 1.0 was
released in 1994; it borrowed the module system from Modula-3, had the capability to
interact with Amoeba operating system, and included functional programming tools.
December 2008 saw the release of Python 3.0, giving up backward compatibility
and possessing a new design to avoid duplicative constructs and modules. It is still a
multi-paradigm language offering developers the options of object-orientation, structured
programming and functional programming.
16
Released in February 2015, Python 3.4.3 offers drastic improvement in Unicode
support, among other new features. Python 3.5 is currently in development, with
scheduled release in September 2015.
Often, programmers like Python because of the increased productivity it provides. Since
there is no compilation step, the edit-test-debug cycle is incredibly fast. Debugging
Python programs is easy: a bug or bad input will never cause a segmentation fault.
Instead, when the interpreter discovers an error, it raises an exception. When the program
doesn't catch the exception, the interpreter prints a stack trace. A source level debugger
allows inspection of local and global variables, evaluation of arbitrary expressions,
setting breakpoints, stepping through the code a line at a time, and so on. The debugger is
written in Python itself, testifying to Python's introspective power. On the other hand,
often the quickest way to debug a program is to add a few print statements to the source:
the fast edit-test-debug cycle makes this simple approach very effective.
17
• Enterprise and business applications
• Operating systems
• Language development
• Prototyping
2.3 Features
1. Readable: Python is a very readable language.
2. Easy to Learn: Learning python is easy as this is a expressive and high level
programming language, which means it is easy to understand the language and thus easy
to learn.
3. Cross platform: Python is available and can run on various operating systems such as
Mac, Windows, Linux, UNIX etc. This makes it a cross platform and portable language.
5. Large standard library: Python comes with a large standard library that has some
handy codes and functions which we can use while writing code in Python.
6. Free: Python is free to download and use. This means you can download it for free and
use it in your application.
8. Advanced features: Supports generators and list comprehensions. We will cover these
features later.
18
9. Automatic memory management: Python supports automatic memory management
which means the memory is cleared and freed automatically. You do not have to bother
clearing the memory.
The diverse application of the Python language is a result of the combination of features
which give this language an edge over others. Some of the benefits of programming in
Python include:
The Python Package Index (PyPI) contains numerous third-party modules that make
Python capable of interacting with most of the other languages and platforms.
Python provides a large standard library which includes areas like internet protocols,
string operations, web services tools and operating system interfaces. Many high use
programming tasks have already been scripted into the standard library which reduces
length of code to be written significantly.
Python language is developed under an OSI-approved open source license, which makes
it free to use and distribute, including for commercial purposes.
Further, its development is driven by the community which collaborates for its code
through hosting conferences and mailing lists, and provides for its numerous modules.
Python offers excellent readability and uncluttered simple-to-learn syntax which helps
beginners to utilize this programming language. The code style guidelines, PEP 8,
19
provide a set of rules to facilitate the formatting of code. Additionally, the wide base of
users and active developers has resulted in a rich internet resource bank to encourage
development and the continued adoption of the language.
Python has built-in list and dictionary data structures which can be used to construct fast
runtime data structures. Further, Python also provides the option of dynamic high-level
data typing which reduces the length of support code that is needed.
Python has clean object-oriented design, provides enhanced process control capabilities,
and possesses strong integration and text processing capabilities and its own unit testing
framework, all of which contribute to the increase in its speed and productivity. Python is
considered a viable option for building complex multi-protocol network applications.
As can be seen from the above-mentioned points, Python offers a number of advantages
for software development. As upgrading of the language continues, its loyalist base could
grow as well.
2.5 OpenCV
OpenCV was started at Intel in 1999 by Gary Bradsky and the first release came
out in 2000. Vadim Pisarevsky joined Gary Bradsky to manage Intel’s Russian software
OpenCV team. In 2005, OpenCV was used on Stanley, the vehicle who won 2005
DARPA Grand Challenge. Later its active development continued under the support of
Willow Garage, with Gary Bradsky and Vadim Pisarevsky leading the project. Right
now, OpenCV supports a lot of algorithms related to Computer Vision and Machine
Learning and it is expanding day-by-day. Currently OpenCV supports a wide variety of
programming languages like C++, Python, Java etc and is available on different
platforms including Windows, Linux, OS X, Android, iOS etc. Also, interfaces based on
CUDA and OpenCL are also under active development for high-speed GPU operations.
20
OpenCV-Python is the Python API of OpenCV. It combines the best qualities of OpenCV
C++ API and Python language.
2.6 OpenCV-Python
Python is a general purpose programming language started by Guido van Rossum,
which became very popular in short time mainly because of its simplicity and code
readability. It enables the programmer to express his ideas in fewer lines of code without
reducing any readability. Compared to other languages like C/C++, Python is slower. But
another important feature of Python is that it can be easily extended with C/C++. This
feature helps us to write computationally intensive codes in C/C++ and create a Python
wrapper for it so that we can use these wrappers as Python modules. This gives us two
advantages: first, our code is as fast as original C/C++ code (since it is the actual C++
code working in background) and second, it is very easy to code in Python. This is how
OpenCV-Python works, it is a Python wrapper around original C++ implementation. And
the support of Numpy makes the task more easier. Numpy is a highly optimized library
for numerical operations. It gives a MATLAB-style syntax. All the OpenCV array
structures are converted to-and-from Numpy arrays. So whatever operations you can do
in Numpy, you can combine it with OpenCV, which increases number of weapons in
your arsenal. Besides that, several other libraries like SciPy, Matplotlib which supports
Numpy can be used with this. So OpenCV-Python is an appropriate tool for fast
prototyping of computer vision problems.
21
2.7 Getting Started with Images
2.7.1 Read an image:
Use the function cv2.imread() to read an image. The image should be in the working
directory or a full path of image should be given. Second argument is a flag which
specifies the way image should be read.
• cv2.IMREAD_COLOR : Loads a color image. Any transparency of image will be
neglected. It is the default flag.
• cv2.IMREAD_GRAYSCALE : Loads image in grayscale mode.
• cv2.IMREAD_UNCHANGED : Loads image as such including alpha channel.
Instead of these three flags, you can simply pass integers 1, 0 or -1 respectively.
22
2.8 Histogram Calculation in OpenCV
So now we use cv2.calcHist() function to find the histogram. Let’s familiarize with the
function and its parameters :
cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate]])
1. Images : it is the source image of type uint8 or float32. it should be given in square
brackets, ie, “[img]”.
2. Channels : it is also given in square brackets. It the index of channel for which we
calculate histogram. For example, if input is grayscale image, its value is [0]. For
color image, you can pass [0],[1] or [2] to calculate histogram of blue,green or red
channel respectively.
3. Mask : mask image. To find histogram of full image, it is given as “None”. But if
you want to find histogram of particular region of image, you have to create a mask
image for that and give it as mask. (I will show an example later).
4. HistSize : this represents our BIN count. Need to be given in square brackets. For
full scale, we pass [256].
23
CHAPTER 3
• RSA (Rivest-Shamir-Adleman)
Weak keys : the key that is selected on the rounds are a problem . During splitting of
keys to two half and swapping them might throw up the same result if they have
continuous 1’s and 0’s. Thins ends up in using the same key through out the 16-
cycles.
There can be same output from the S-Boxes on different inputs on permutation.
These are called Semi weak keys.
If the message is encrypted with a particular key, and is taken 1’s compliment of
that encryption will be same as that of the encryption of the compliment message
and compliment key.
24
3.5 Drawbacks of RSA
• RSA algorithm can be very slow in cases where large data needs to be encrypted
by the same computer.
• It requires a third party to verify the reliability of public keys.
• Data transferred through RSA algorithm could be compromised through
middlemen who might temper with the public key system.
• In conclusion, both the symmetric encryption technique and the asymmetric
encryption technique are important in encryption of sensitive data
25
CHAPTER 4
4.1 Motivation
With the advent of the internet and new communication technologies, sharing of
digital images has become easier and faster. It is important to send images over a network
securely to avoid any corruption of data because of malice. The easiest solution will be to
consider an image as a stream of bits and encrypt using conventional algorithms like Data
encryption Standard (DES), Advanced Encryption Standard (AES) or International Data
Encryption Standard (IDEA) for encryption [1]. However, these schemes do not exploit
the unique properties of images like huge data redundancy and no predetermined
statistical distribution of pixels. They also require higher computation power and time. As
a broad comparison, given the same conditions, chaotic encryption needs 14 seconds to
process 500 kB of image data, while DES requires 467 seconds [2]. In real time
scenarios, they may introduce significant latency. Hence it is necessary to use encryption
which is fast, computationally inexpensive and of high security. The chaotic system bears
characteristics like pseudo-random nature and initial condition sensitivity which are
essential for cryptographic applications. They are computationally inexpensive and
introduce a high level of randomness. This makes them highly suitable for encryption.
Cryptography is the most useful technique for information security. However the
conventional cryptographic algorithms appear not to be ideal for image encryption due to
some intrinsic properties of digital images such as bulky data capacity, high redundancy
and strong correlation among adjacent pixels.
4.2 Actual Procedure
Chaotic systems, benefiting from their characteristics of aperiodicity, high sensitivity
to initial conditions and pseudo-randomness, have attracted significant attention of
researchers for the design of new image cryptosystems. Since Matthews suggested that
chaotic map could be used as one time pad for encrypting messages, a variety of chaos-
based image algorithms have been proposed. Most of them adopt the confusion diffusion
26
architecture [3], where the confusion and diffusion are usually provided by chaotic
permutation, substitution, and other nonlinear operations. Permutation plays an important
role in breaking the correlation between adjacent pixels by shuffling the positions of the
image pixels. There are two main approaches for permutation. One is based on the
chaotic permutation matrix, in which the permutation matrix is first constructed using a
chaotic pseudo-random sequence, and then employed to relocate image pixels.This
approach can offer a good scrambling effect, but it is very time-consuming to construct a
permutation matrix, especially a large one. Another approach for the permutation is to
directly transform the position of each pixel to another using a chaotic map, such as baker
map[6], Arnold map[2] and standard map[9]. Arnold map is an efficient technique for
position transformation, and is widely applied to permutate image pixels. However,
Arnold transform has a weakness, which is that the transform can not deal with whole
image directly when the plain image is not square. Since the permutation only shuffles
the pixel positions but remains the pixel values unchanged, it can be easily cryptanalyzed.
As a result, the security defect exists in some permutation based image encryption
schemes[1]. Substitution is a nonlinear transformation which replaces each pixel value
with another. An efficient approach for substitution is to use the substitution box (S-box).
Due to its properties of nonlinearity, differential uniformity and strict avalanche criterion,
S-box has been widely used in image encryption. However, it is found that the S-box
only ciphers are vulnerable to chosen plaintext attacks because these ciphers solely
depend on the secret keys. Zhang and Xiao have studied the security issues for the
general S-box-only image ciphers and presented a successful cryptanalysis. In order to
avoid this weakness, some S-box-based image encryption algorithms either incorporate
the S-box with other encryption methods or use the dynamic S-boxes. For example, a
permutation-diffusion based image encryption algorithm using AES S-box is proposed in
[26], where the S-box is utilized for converting pseudorandom number from the output of
chaotic system. In [10], the S-box is used in total shuffling encryption scheme to provide
extra confusion. On the other hand, Wangetal. propose a block cipher with dynamic
Sboxes based on tent map, where a cipher feedback is employed to change the state value
of the tent map, which makes the S-boxes relevant to the plaintext and enhances the
confusion and diffusion properties of the cryptosystem. In [9], a chaotic image encryption
27
algorithm based on dynamic S-boxes is also presented, in which the image pixels are
grouped in four directions, and the pixels of each group are substituted using a new S-box
that is generated dependently on the previous group. Although the schemes based on
dynamic S-boxes in [6] can effectively resist chosen plaintext attacks, they have two
defects. First, the correlation between adjacent pixels within a block can not be
completely broken since the invariant S-box is used for a specific block. Second, these
schemes are not robust against noise or other external disturbances because the state
value of the chaotic system changes according to a cipher feedback
28
Fig. 4.1. Logistic Map values for 𝑛=50
𝑟∈ (3.7,4) resemble random data and are completely uncorrelated. The values of
logistic map start becoming truly chaotic only after a few initial iterations [11]. Thus,
to generate random values having more uniform distribution, we run (1) through
some fixed iterations first before taking the values. The logistic map has singularities
for certain values of r, where the value of oscillates about a small number of
fixed positions. Hence r is used as a control parameter and not as part of the key. If an
incorrect value is selected, the values of will only take a small set of values
which makes it insecure.
F: = mod
29
such that, gcd(a, ) =1
(b mod ) =0 or (c mod ) =0
gcd(d, ) =1
gcd(ad−bc,p)=1
where H and W are the height and width of plain-image, respectively; (x,y) is the
original position of image pixel while ( , ) is the mapping position of (x,y); p=
gcd(H,W),
= H/p, and =W/p.
The matrix, A=[ , ] is called coefficient matrix of 2D rectangular
transform if A satisfies the constraints in (1). In the application of 2D rectangular
transform, how to effectively generate the coefficient matrix is a practical problem.
To address this problem, we present a fast method to construct a random coefficient
matrix using chaotic system. First, we can find the following property of the
coefficient matrix according to (1).
Property Suppose is a coefficient matrix of 2D rectangular transform. For any
positive integers e and f satisfying gcd(e,H)=1 and gcd(f,W) =1, let
× ,
30
(3) Let = mod l (1≤ i ≤4). Then calculate the coefficient matrix A by the following
formula.
A= ×
As mentioned earlier, the algorithm uses two substitution stages and two
permutation stages. The image is divided into macroblocks for substitution of pixels.
Permutation is done on the whole image. Each macroblock has its own unique sbox.
The successive logistic map values are treated as a pseudorandom number stream.
These values are used to generate a unique permutation of the symbols in the message
space to generate a sbox. The random permutation of the message symbol space is
performed using the Fisher-Yate shuffle. The original FisherYate algorithm is
elaborated in [13]. Fisher-Yate shuffle ideally uses a uniformly distributed random
number sequence to generate the permutation. However, even though the distribution
of logistic map values isn’t completely uniform, by applying multiple maps and
sboxes to the image, Fisher-Yate produces an adequately random sbox. For an 8 bpp
image, the sbox contains 256 values corresponding to the intensity levels of the
image.
The justification for using four substitution rounds can be illustrated using the
images in fig. 4.3, 4.3 & 4.4. The image in fig. 4.4 is the result of encrypting the
original image using only one sbox. The encrypted image still has an imprint of the
original and the histogram in fig 4.5 is only shuffled since the pixels with equal
intensities are mapped onto the same value from the sbox. It results in a very simple
one to one mapping of plaintext pixel to ciphertext pixel. The image in fig. 4.6 is the
result of using a different sbox for each macroblock. The histogram in fig. 4.7 is
equalized to a certain extent but mode of the histogram still stands out. The
encrypted image also has a blocky appearance. It can be easily inferred that the center
region of the image is highly detailed but the region elsewhere has fairly constant
31
values. If all pixels in the macroblock have identical value, then the sbox is
ineffective as all pixels map to the same value.
Fig. 4.4. Encrypted Beads (one sbox) Fig. 4.5. Histogram (Encrypted
Beads with one sbox)
Fig. 4.6. Encrypted Beads (different sbox) Fig. 4.7 Histogram (Encrypted
Beads with different sbox)
32
4.4 Detailed Study
33
Fig. 4.9 Last round of substitution (Type-2)
Logistic map requires as its initial value. The first value behaves like a key for
encryption, and should be the same for decryption. The logistic map values are
extremely sensitive to changes in this value. This will help in scrambling of the image
between substitution rounds. This is done using the rectangular chaotic map. The
smaller the size of the macroblocks, the greater the security, but also the greater the
processing time. Applying 2 rounds of substitution further increases computation
time.
To counter this, larger macroblocks (16×16 pixels) can be used in the 1st round
while smaller, more secure macroblock sizes (8×8 pixels) can be used in the
remaining rounds. This makes sense as the first sbox has less effectiveness at
reducing redundancy and a reduction in the security at that stage does not
compromise the system. These methods provide good protection against statistical
attacks. However it would fail against differential attacks, as small change in value of
1 pixel would only change the value of 1 pixel in the encrypted domainThus we can
ensure improper decryption if the original key is wrong. The permutation is done
34
using the rectangular chaotic map which shuffles the pixels. The seed for the
permutation is also obtained from the original . The overview of the whole process
is given in fig.4.10.
35
CHAPTER 5
5.1 Introduction
In this section, the experimental results and performance analysis on the proposed
image encryption scheme are provided. We have chosen several sample images of
different sizes with 256 gray levels. The sizes of these sample images are given in Chi-
square statistics comparisons between different algorithms Tables where Black is the
image with the identical pixel value 0 and White is the image with the identical pixel
value 255. In experiments, these images are encrypted by the proposed approach, and
then various analysis are carried out to demonstrate the performance of our image
encryption scheme. The below figure shows the encryption and decryption results of the
images Baboon and Saturn whose sizes are 448×512 and 1024×496, respectively. For
comparison, we have chosen four image encryption schemes which are proposed in
Chaotic block cipher, Dynamic s-box implementation by using chaos, In total pixel
shuffling and bidirectional diffusion, In the scheme using reverse 2-dimensional chaotic
map and dependent diffusion . The schemes in Chaotic block cipher, Total pixel shuffling
and bidirectional diffusion are based on traditional permutation-diffusion structure, where
the total shuffling and bidirectional diffusion adopts total shuffling method, and the
chaotic block cipher adopts block encryption. The scheme in reverse 2-dimensional
chaotic map and dependent diffusion improves the traditional permutation-diffusion
structure by using reverse 2D Arnold map, while the implementation of s-box using
chaos adopts substitution-only structure.
36
Table 5.1 :- Chi-square statistics comparisons between different algorithm:
Image Size Ours Total S-Box Block
Shuffling Cipher
Baboon 448×512 246.21 260.67 4767.8 257.96
Fig 5.1. Results of encryption and decryption. a–c Plain, encrypted and decrypted images
of Baboon. d–f Plain, encrypted and decrypted images of Saturn
37
5.3 Histogram Analysis
Histogram analysis of the decrypted and the original images has been performed to
validate the proposed method. A histogram shows the distribution of pixel values in an
image. For image encryption algorithms, the histogram of the encrypted image should be
uniform enough and totally different from that of the original image. Figure Images and
histograms shows the histograms of the plain and the cipher images of Boat and Lena.
From the figure, we can see that the histograms of the cipher images are fairly uniform.
In order to evaluate the uniformity of the pixel-value distribution, Chi-square test can be
employed. The chi-square statistic of a image with 256 gray levels is calculated as:
χ2 =
where Ni is the occurrence frequency of gray level i, N = (W × H)/256 is the expected
occurrence frequency of each gray level. The chi-square statistics for each sample image
encrypted by different algorithms are listed in above table. Assuming the significant level
of 0.05, the corresponding χ2(0.05,255) is 293.25. For all the images encrypted by our
scheme, the chi-square statistics are less than χ2(0.05,255), which indicates that the
histogram distributions of the cipher images are significantly uniform. Compared with
other five algorithms, our algorithm exhibits superior performance in the histogram
distribution
38
Fig 5.2 .Images and histograms. a–d The plain and the encrypted images of Boat and their
histograms. e–h The plain and the encrypted images of Lena and their histograms
where and are pixel values of two adjacent pixels, N is the total number of the
adjacent pixel pairs ( ), x and y denote the mean values of x and y, respectively.
Correlations of the plain and the encrypted images table lists the correlation coefficients
of the plain images and the images encrypted by the proposed scheme, in which the
average coefficient(AC) is calculated using
AC=
39
where HC, VC and DC are the horizontal, vertical and diagonal coefficients in an image,
respectively. From Correlations of the plain and the encrypted images Table it is obvious
that all of the correlation coefficients of encrypted images are close to zero, which means
our approach can effectively remove the correlations among adjacent pixels.
Fig 5.3. a–d Plain image Cameraman and its horizontal, vertical, and diagonal
correlations. e–h Encrypted image of Cameraman and its horizontal, vertical,and diagonal
correlations.
Image HC VC DC HC VC DC AC
40
Boat 0.93812 0.97131 0.92401 0.00146 −0.00372 −0.00079 0.00199
H(m)=
41
Saturn 7.99966 7.99959 7.97816 7.96584
where N is the total number of symbols, ∈m, andp( ) represents the probability of
the symbol mi. For a random image with 256 gray levels, the entropy should ideally be
H(m) = 8. Therefore, any effective encryption algorithm should produce an encrypted
image with the entropy close to 4. The information entropies of cipher images using
different algorithms are shown in Entropy comparison between different algorithms
tables. It is clear that the entropies of all images encrypted by our algorithm are very
close to the theoretical optimal value, which demonstrates that the cipher images are
almost close to a random source. Compared with other four algorithms, our algorithm can
produce cipher image with higher randomness almost close to a random source.
Compared with other four algorithms, our algorithm can produce cipher image with
higher randomness.
NPCR=
UACI= x100%
42
Table 5.5 :- Plaintext sensitivity of the proposed scheme:
where and are two images with the same size W × H, D(i,j) = 0 if (i,j) = (i,j);
otherwise,D(i,j) = 1. For two random images, the average NPCR is about 0.9961,while
the average UACI is about 0.3346. We randomly change only one pixel in original plain
image to obtain a modified image, encrypt the original image and the modified image
using our algorithm with the same secret key, and calculate NPCR and UACI of the
encrypted images. In the experiment, this test is performed 1000times for each sample
image, and the average, maximum, minimum values of NPCR and UACI are given in
Plaintext sensitivity of the proposed scheme Table. It can be seen from above Table that
the NPCR and UACI of encrypted images produced by our algorithm are close to the
average NPCR and UACI of random images. This means that the proposed scheme can
effectively resist the differential attack. For comparison, the average NPCR and UACI
values of each image encrypted by different algorithms are given in NPCR comparison
between different algorithms and UACI comparison between different algorithms
tables.We can find that our algorithm has the same excellent performance as the
algorithms in chaotic block cipher,Implementation of dynamic S-boxes by using chaos,
43
total shuffling and bidirectional diffusion and reverse 2-dimensional chaotic map and
dependent diffusion, while total shuffling require additional multiple rounds of
encryption to achieve a desired effect.
44
5.7 Key Space Analysis
Any encryption must produce varying changes to the encrypted result due to key
changes, in our case the key is the value of 𝑥0. A slight deviation in the key should
produce different results. To test the key space of our algorithm we use a same key but
with very minute changes in the order of 10−16 to see the decrypted image. Fig. 8c
shows that the key is sensitive to changes of the order of 10−16. It means the effective
key space is about 1016. This translates to a key space of roughly 53 bits. Changes in the
order of 10−17 will not be detected and the image will be decrypted. A greater key space
can be obtained with higher precision floating point arithmetic making the key difficult to
find through brute force attack.
45
directions and to dynamically construct S-box for each block. Our algorithm only uses a
few S-boxes and updates the S-box easily by modifying the start pointer, so it achieves
the high speed.
5.9 Results
46
Fig. 5.5. Round 1 encrypted output(substitution)
Using 16×16 block size macro blocks
47
Fig. 5.7. Round 3 output
48
Fig. 5.9. Decrypted Output
49
Fig 5.11. Encrypted Output of Round 1 (Substitution)
Using 16×16 block size macro blocks
50
Fig 5.13. Output of Round 3
51
Fig 5.15. Decrypted Output
52
CHAPTER 7
CONCLUSION
This paper has proposed a robust chaos-based image encryption scheme with
permutation substitution architecture, in which pixel permutation and pixel substitution
are integrated into one traverse of the image pixels to accelerate the encryption process
and enhance the security.In order to enable the proposed scheme applicable to non-square
image encryption, we employed the 2D rectangular transform to shuffle image pixels. We
also presented a fast method to effectively generate the coefficient matrix of 2D
rectangular transform using chaotic system. Furthermore, the dependent substitution was
introduced to make the substitution operation provide both confusion and diffusion
effects. The proposed scheme has been compared with four existing schemes. The
experimental results and security analysis show that the proposed scheme can achieve
higher security level to resist various common attacks, such as statistical attack,
differential attack, brute-force attack. Meanwhile, our scheme is faster than the existing
schemes and more practical for image encryption and transmission.
53
REFERENCES
[1] Minal Avasare and Vishaka Kelkar, “Image Encryption using Chaos Theory,” in 2015
International Conference on Communication, Information & Computing Technology
(ICCICT), Jan 16-17, Mumbai, India.
[2] Z. Yun-peng, Z. Zheng-jun, L. Wei, N. Xuan, C. Shui-ping, D. Wei-di, “Digital
Image Encryption Algorithm Based on Chaos and Improved DES,” Proceedings of the
2009 IEEE International Conference on Systems, Man and Cybernetics, San Antonio,
TX, USA.
[3] Nidhi Sethi and Deepika Sharma, “A New Cryptology Approach for Image
Encryption,” in 2012 2nd IEEE International Conference on Parallel, Distributed and
Grid Computing.
[4] Chen Wei-bin, Zhang Xin, “Image Encryption Algorithm Based on Henon Chaotic
System,” in International Conference on Image Analysis and Signal Processing, 2009.
[5] Sukalyan Som and Atanu Kotal, “Confusion and diffusion of Grayscale Images using
Multiple Chaotic Maps,” in 2012 National Conference on Computing and
Communication Systems, West Bengal, India.
[6] Jeyamala. C, GopiGanesh. S and Raman G. S, “An Image Encryption Scheme Based
on One Time Pads – A Chaotic Approach,” in 2010 Second International Conference on
Computing, Communication and Networking Technologies.
[7] S. El Assad, M. Farajallah, C. Vladeanu, “Chaos-based Block Ciphers: An
Overview,” in 10th International Conference on Communications, 2931 May, 2014.
[8] Claude. E. Shannon, “Communication Theory of Secrecy Systems,” Bell System
Technical Journal, Vol. 28-4, Page 656-715, October 1949.
[9] Jiri Fridrich, “Symmetric Ciphers Based on Two-Dimensional Chaotic Maps,” in
International Journal of Bifurcation and Chaos, Vol 8, No. 6 (1998) 1259-1284.
[10] Xuanping Zhang, Xing Fan, Jiayin Wang and Zhongmeng Zhao, “A Chaos-based
Image Encryption Scheme using Rectangular Transform and Dependent Substitution,” in
Multimedia Tools and Applications, 21 Nov 2014, Springer US.
54