Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Cha 2018-2019 A

Download as pdf or txt
Download as pdf or txt
You are on page 1of 65

IMAGE ENCRYPTION USING LOGISTIC AND

RECTANGULAR CHAOTIC MAPS


A Project report submitted in partial fulfillment of the requirements for
the award of the degree of

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

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


ANIL NEERUKONDA INSTITUTE OF TECHNOLOGY AND SCIENCES
(UGC AUTONOMOUS)
(Permanently Affiliated to AU, Approved by AICTE and Accredited by NBA & NAAC with ‘A’ Grade)
Sangivalasa, bheemili mandal, visakhapatnam dist.(A.P)
2018-2019
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
ANIL NEERUKONDA INSTITUTE OF TECHNOLOGY AND SCIENCES
(UGC AUTONOMOUS)(Permanently Affiliated to AU, Approved by
AICTE and Accredited by NBA & NAAC with ‘A’ Grade)
Sangivalasa, bheemili mandal, visakhapatnam dist.(A.P)

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.

Project Guide Head of the Department

Mrs. Ch. Anoosha Dr. V.Rajyalakshmi


Asst. Professor Professor
Department of E.C.E Department of E.C.E
ANITS ANITS
ACKNOWLEDGEMENT

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

Chaos-based image cryptosystems usually adopt the traditional confusion


diffusion architecture which is considered insecure against known/chosen plain text
attacks. To overcome this drawback, this paper proposes a novel chaos-based image
encryption scheme, in which a fast encryption method is presented which utilizes a
substitution-permutation network using two chaotic maps. Logistic maps are used to
create substitution box while key dependent rectangular chaotic maps is used for
permutation of pixels. The algorithm is applicable to images of any dimension. This
method is most suitable for image encryption due to the chaotic behavior.
CONTENTS

Certificate
Acknowledgement
Abstract
List of Figures
List of Tables
1. Introduction
1.1 Introduction to Cryptography .................................................................................1

1.2 Terminology ............................................................................................................ 3


1.2.1 Cipher............................................................................................................. 3
1.3 History of Cryptography ......................................................................................... 5
1.4 Computer Era .......................................................................................................... 5
1.5 Modern Cryptography ............................................................................................. 7
1.5.1 Symmetric-Key Cryptography ....................................................................... 9
1.5.2 Asymmetric-Key Cryptography ....................................................................10
1.6 Different Types of Symmetric Algorithms… ....................................................... 13
1.6.1 DES and Triple DES .................................................................................... 14
1.6.2 RC2… .......................................................................................................... 14
1.6.3 Blowfish and Twofish… .............................................................................. 14
1.6.4 Serpent… ..................................................................................................... 15
1.6.5 IDEA ............................................................................................................ 15
2. Python Programming
2.1 Introduction… ....................................................................................................... 16
2.2 Applications of Python… ..................................................................................... 17
2.3 Features ................................................................................................................. 18
2.4 Advantages/Benefits of Python…..........................................................................19
2.5 OpenCV ................................................................................................................ 20
2.6 OpenCV-Python… ................................................................................................ 21
2.6.1 Features in OpenCV… ................................................................................. 21
2.7 Getting Started with Images…...............................................................................22
2.7.1 Read an Image...............................................................................................22
2.7.2 Display an Image ......................................................................................... 22
2.7.3 Write an Image ............................................................................................. 22
2.8 Histogram Calculation in OpenCV… ................................................................... 23
3. Reason for Choosing Chaotic Maps
3.1 Pre Existing Image Encryption Methods… .......................................................... 24
3.2 Drawbacks of DES… ........................................................................................... 24
3.3 Drawbacks of AES… ........................................................................................... 24
3.4 Drawbacks of RSA ............................................................................................... 25
4. Logistic and Rectangular Chaotic Maps
4.1 Motivation… ......................................................................................................... 26
4.2 Actual Procedure ................................................................................................... 26
4.3 Principles of Proposed Algorithm… ..................................................................... 28
4.3.1 Logistic Map ................................................................................................ 28
4.3.2 2D Rectangular Transform… ......................................................................29
4.4 Proposed Algorithm .............................................................................................. 31
4.5 Detailed Study ....................................................................................................... 33
5. Performance Analysis and Results
5.1 Introduction… ....................................................................................................... 36
5.2 Statistical Analysis ................................................................................................ 36
5.3 Histogram Analysis… ........................................................................................... 38
5.4 Correlation Analysis ............................................................................................. 39
5.5 Information Entropy Analysis................................................................................41
5.6 Differential Attack Analysis ................................................................................. 42
5.7 Key Space Analysis .............................................................................................. 45
5.8 Speed Analysis ...................................................................................................... 45
5.9 Results… ............................................................................................................... 46
6. Conclusion ...................................................................................................................53
7. References… ................................................................................................................ 54
LIST OF FIGURES

1.1 Encryption and Decryption… ....................................................................................... 8


1.2 Symmetric Key Algorithm .......................................................................................... 10
1.3 Asymmetric Key Cryptography .................................................................................. 11
4.1 Logistic Map Values for n=50… ................................................................................ 29
4.2 Beads… ....................................................................................................................... 32
4.3 Histogram (Beads)… .................................................................................................. 32
4.4 Encrypted Beads (S-Box)… ....................................................................................... 32
4.5 Histogram (Encrypted Beads with one S-Box) ........................................................... 32
4.6 Encrypted Beads (Different S-Box)… ........................................................................ 32
4.7 Histogram (Encrypted Beads with different S-Box)… ............................................... 32
4.8 First Round of Substitution (Type 1)… ...................................................................... 33
4.9 Last Round of Substitution (Type 2)… ......................................................................34
4.10 Overview of Algorithm… ......................................................................................... 35
5.1 Results of Encryption and Decryption (References)… ...............................................37
5.2 Images and Histograms of Considered Images ........................................................... 39
5.3 Different Types of Correlations of Cameraman Image .............................................. 40
5.4 Original Image (Colour Image)...................................................................................46
5.5 Round 1 Encrypted Output… ..................................................................................... 46
5.6 Round 2 Output… ....................................................................................................... 46
5.7 Round 3 Output… ....................................................................................................... 46
5.8 Round 4 Output… ....................................................................................................... 48
5.9 Decrypted Output… .................................................................................................... 49
5.10 Original Image (Gray Scale Image)… ...................................................................... 49
5.11 Encrypted Output of Round 1… ............................................................................... 50
5.12 Output of Round 2… ................................................................................................ 50
5.13 Output of Round 3… ................................................................................................ 51
5.14 Encrypted Output ...................................................................................................... 51
5.15 Decrypted Output… .................................................................................................. 51
LIST OF SYMBOLS

r Logistic map control parameter


Initial key/seed
System state at iteration 𝑛
H Height of the plain image
W Width of the plain image
Shuffled x co-ordinate
Shuffled y co-ordinate
Height parameter
Width parameter
Random number
Co-efficient of correlation
LIST OF TABLES

5.1 Chi-Square Characteristics Comparisons Between Different Algorithms… ...............37


5.2 Correlations of the Plain and Encrypted Images… ..................................................... 40
5.3 Comparison of Average Coefficient Between Different Algorithms ......................... 41
5.4 Entropy Comparison Between Different Algorithms… ............................................. 41
5.5 Plain Text Sensitivity of the Proposed Scheme .......................................................... 43
5.6 NPCR Comparison Between Different Algorithms… ................................................ 44
5.7 UACI Comparison Between Different Algorithms… ................................................ 44
5.8 Encryption Time of Different Algorithms… .............................................................. 46
CHAPTER 1

INTRODUCTION

1.1 Introduction to Cryptography:

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.

Cryptography prior to the modern age was effectively synonymous with


encryption, the conversion of information from a readable state to apparent text that does
not make sense. The originator of an encrypted message shared the decoding technique
needed to recover the original information only with interded recipients, thereby
precluding unwanted persons firom doing the same.

Modern cryptography is heavily based on mathematical theory and computer


science practice cryptographic algorithms are designed arcund computational hardness
assumptions, making such algorithms hard to break in practice by any adversary. It is
theoretically possible to break such a system, but it is not feasible to do so by any known
practical means. These schemes are therefore termed computationally secure.

Examples include, improvements in integer factorization algorithms, and faster


computing technology require these solutions to be continually adapted. There exist
information-theoretically secure schemes that probably cannot be broken even with
unlimited computing power-an example is the one-time pad-but these schemes are more

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.

Until modern times, cryptography referred almost exclusively to encryption,


which is the process of converting ordinary information (called plaintext) into
unintelligible text (call cipher text) Decryption is the reverse, in other words, moving
from the unintelligible cipher text back to plaintext

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.

Formally, a "cryptosystem" is the ordered list of elements of finite possible


plaintexts, finite possible cypher texts, finite possible keys, and the encryption and

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.

Some use the terms cryptography and cryptology interchangeably in English,


while others (including US military practice generally) use cryptography to refer
specifically to the use and practice of cryptographic techniques and cryptology to refer to
the combined study of cryptography and cryptanalysis English is more flexible than
several other languages in which cryptology (done by cryptologists) is always used in the
second sense above. RFC 2828 advises that steganography is sometimes included in
cryptology.

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.

1.3 History of Cyptography

Before the modern era, cryptography focused on message confidentiality (i.e.,


encryption)-conversion of messages from a comprehensible form into an
inccmprehensible one and back again at the other end, rendering it unreadable by
interceptors without secret knowledge (namely the key needed for decryption of that
message). Encryption attempted to ensure secrecy in communications, such as those of
spies, military leaders, and diplomats. In recent decades the field has expanded beyond
confidentiality concerns to include techniques for message integrity checking,
sendet/receiver identity authentication, digital signatures, interactive proofs and sccure
computation, among others.

1.4 Computer Era

Cryptanalysis of the new mechanical devices proved to be both difficult and


laborious. In the United Kingdom, cryptanalytic efforts at Bletchley Park during WWII
spurred the development of more efficient means for carrying out repetitious tasks. This
culminated in the development of the Colossus, the world's first fully electronic, digital,
programmable computer, which assisted in the decryption of ciphers gererated by the
German Army's Lorenz SZ40/42 machine.

Just as the development of digital computers and electronics helped in


cryptanalysis, it made possible much more complex ciphers. Furthermore, computers
allowed for the encryption any kind of data representable in any binary format, unlike
classical ciphers which only encrypted writen language texts: this was new and
significant. Computer use has thus supplanted linguistic cryptography, both for cipher

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.

Extensive open academie research into cryptography is relatively recent; it began


only in the mid-1970s. In recent times, IBM personnel designed the algorithm that
became the Federal (i.e.. US) Data Encrypticn Standard: Whitield Diffie and Martin
Hellman published their key agreement algorithm, and the RSA algorithm was published
in Martin Gardner's Scientific American column. Since then, cryptography has become a
widely used tool in communications computer networks, and computer security
generally. Sone modern cryptographic techniques can only keep their keys secret if
certain mathematical problems are intractable, such as the integer factorization or the
discrete logarithm problems, so there are deep connections with abstract mathematics.
There are very few cryptosystems that are proven to be unconditionally secure. The one-
time pad is one. There are a few important ones that are proven secure under certain
unproven assumptions. For example, the infeasibility of factoring extremely large
integers is the basis for believing that RSA is secure, and some other systems, but even
there, the procf is usually lost due to practical considerations. There are systems similar
to RSA, such as one by Michael O. Rabin that is provably secure provided factoring n pq
is impossible, but the more practical system RSA has never been proved secure in this
sense. The discrete logarithm problem is the basis for believing some other cryptosystems
are secure, and again there are related, less practical systems that are provably secure
relative to the discrete log problem.

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).

1.5 Modern Cryptography

Encryption in modern times is achieved by using algorithms that have a key to


encrypt anddecrypt information. These keys convert the messages and data into "digital
gibberish" through encryption and then return them to the original form through
decryption. In general, the longer the key is, the more difficult it is to crack the code. This
holds true because deciphering encrypted message by brute force would require the
attacker to try every possible this in context, each binary unit of information, or bit, has a
value of 0 or 1. An 8-bit key would then have 256 or 28 possible keys. A 56-bit key
would have 256, or 72 quadrillion, possible keys to try and decipher the message. With

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.

Fig. 1.1. Encryption and Decryption

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 cryptography refers to eneryption methods in which both the


sender and receiver share the same key (or, less commorly, in which their keys are
different, but related in an easily computable way). This was the only kind of encryption
publicly known until June 1976.

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.

Cryptographic hash functions are a third type of cryptographic algorithm. They


take a message of any length as input, and output a short, fixed length hash, which can be
used in (for example) a digital signature.

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.

Fig. 1.2. Symmetric Key Algorithm

1.5.2 Asymmetric-Key Cryptography (Public-Key Cryptography):

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.

Fig. 1.3. Asymmetric Key Cryptography

In a ground-breaking, Whitfield Diffie and Martin Hellman proposed the notion


of public-key (also, more generally, called asymmetric key) cryptography in which two
different but mathematically related keys are used-a public key and a private key. A
public key system is so constructed that calculation of one key (the 'private key) is
computationally infeasible from the other (the 'public key"), even though they are
necessarily related. Instead, both keys are generated secretly, as an interrelated pair. The
historian David Khan described public-key cryptography as "the most revolutionary new
concept in the field since polyalphabetic substitution emerged in the Renaissance"

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.

Diffie and Hellman's publication sparked widespread academic efforts in finding


a practical public-key encryption system. This race was finally won in 1978 by Ronald
Rivest, Adi Shamir and Len Adleman, whose solution has since become known as the
RSA algorithm.

The Diffie-Hellman and RSA algorithms, in addition to be the first publicly


known examples of high quality public-key algorithms, have been among the most
widely used. Others include the Cramer-Shoup cryptosystem, ElCamal encryption, and
various elliptic curve techniques.

Too much surprise, a document published in 1997 by the Government


Communications Headquarters (CCHQ), a British intelligence organization, revealed that
cryptographers a GCHQ had anticipated several acedemic developments. Reportedly,
around 19 Ellis had conceived the principles of asymmetric key cryptography. In 1973,
Clifford Cocks invented a solution that essentially resembles the RSA algorithm. And in
1974, MaleolmJ Williamson is claimed to have developed the Diffie-Hellman key
exchange.
Puhlic-key cryptography can alsc be used for implementing digital signature schemes. A
digital signature is reminiscent of an ordinary signature; they both have the characteristic
of being easy for a user to produce, but difficult for anyone else to forge. Digital
signatures can also be permanently tied to the conten: of the message being signed; they
cannot then be moved' from one document to another, for any attempt will be detectablc.
In digital signature schemes, there are two algorithms: one for signing, in which a secret
key is used to process the message (or a hash of the message, or both), and one for
verification, in which the matching public key is used with the message to check the
validity of the signature. RSA and DSA are two of the most popular digital signature

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.).

Public-key algorithms are most often based on the computational complexity of


"hard" problems, often from number theory. For example, the hardness of RSA is related
to the integer factorization problem, while Diffie-Hellman and DSA are related to the
discrete logarithm problem. More recently, elliptic curve cryptography has developed, a
system in which security is based on number theoretic problems involving elliptic curves.
Because of the difficulty of the underlying problems, most public-key algorithms involve
operations such as modular multiplication and exponentiation, which are much more
computatiorally expensive than the techniques used in most block ciphers, especially with
typical key sizes. As a result, public-key cryptosystems are commonly hybrid.
cryptosystems, in which a fast high-quality symmetric-key encryption algorithm is used
for the message itself, while the relevant symmetric key is sent with the message but
encrypted using a public-key algorithm. Similarly, hybrid signature schemes are often
used, in which a cryptographic hash function is computed, and only the resulting hash is
digitally signed.`

1.6 Different Types of Symmetric Algorithms

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.

1.6.3 Blowfish and Twofish:

Security researcher Bruce Schneier developed the symmetric algorithm


"Blowfish" in the early 1990s. As with RC2, Blowfish breaks messages up into equal-
sized 64-bit blocks and encrypts the blocks. Its key sizes range from 32 to 448 bits.
Schneier released Blowfish as a public domain algorithm, freely available to anyone
wanting to encrypt data. Seeking to improve upon Blowfish, he later developed Twofish,
which uses 128-bit blocks and keys up to 256 bits long Twofish is one of the fastest
fixed-block algorithms currently available, and though it has theoretical vulnerabilities,
no one has yet broken it.

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:

The International Data Encryption Algorithm (IDEA) was developed in Zurich,


Switzerland by James L. Massey and Xuejia Lai and published in 1990. IDEA uses a
128-bit key. IDEA is used by the popular program PGP to encrypt files and electronic
mail. Unfortunately, wider use of IDEA has been hampered by a series of software
patents on the algorithm, which are currently held by Ascom-Tech AG in Solothum,
Switzerland.

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.

In 2000, Python’s core development team moved to Beopen.com, and in October


2000, Python 2.0 was released with many improvisations including a garbage collector
and support for Unicode.

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.

Python today has multiple implementations including Jython, scripted in Java


language for Java Virtual Machine; IronPython written in C# for the Common Language
Infrastructure, and PyPy version written in RPython and translated into C. To be noted,
Cpython which is written in C and developed by Python Software Foundation is the
default and most popular implementation of Python. While these implementations work
in the native language they are written in, they are also capable of interacting with other
languages through use of modules. Most of these modules work on community
development model and are open-source and free.

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.

Python is an interpreter, object-oriented, high-level programming language with


dynamic semantics. Its high-level built in data structures, combined with dynamic typing
and dynamic binding; make it very attractive for Rapid Application Development, as well
as for use as a scripting or glue language to connect existing components together.
Python's simple, easy to learn syntax emphasizes readability and therefore reduces the
cost of program maintenance. Python supports modules and packages, which encourages
program modularity and code reuse. The Python interpreter and the extensive standard
library are available in source or binary form without charge for all major platforms, and
can be freely distributed.

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.

2.2 Applications of Python

• GUI based desktop applications


o Image processing and graphic design applications
o Scientific and computational applications
o Games
• Web frameworks and web applications

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.

4. Open Source: Python is a open source programming 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.

7. Supports exception handling: An exception is an event that can occur during


program exception and can disrupt the normal flow of program. Python supports
exception handling which means we can write less error prone code and can test various
scenarios that can cause an exception later on.

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.

2.4 Advantages/Benefits of Python

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:

1. Presence of Third Party Modules:

The Python Package Index (PyPI) contains numerous third-party modules that make
Python capable of interacting with most of the other languages and platforms.

2. Extensive Support Libraries:

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.

3. Open Source and Community Development:

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.

4. Learning Ease and Support Available:

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.

5. User-friendly Data Structures:

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.

6. Productivity and Speed:

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.

2.6.1 Features in OpenCV


• Learn to load an image, display it and save it back
• Learn to play videos, capture videos from Camera and write it as a video
• Learn to draw lines, rectangles, ellipses, circles etc with OpenCV
• Draw stuffs with your mouse
• Create trackbar to control certain parameters

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.

2.7.2 Display an Image:


Use the function cv2.imshow() to display an image in a window. The window
automatically fits to the image size. First argument is a window name which is a string.
second argument is our image. You can create as many windows as you wish, but with
different window names.
cv2.waitKey() is a keyboard binding function. Its argument is the time in milliseconds.
The function waits for specified milliseconds for any keyboard event. If you press any
key in that time, the program continues. If 0 is passed, it waits indefinitely for a key
stroke. It can also be set to detect specific key strokes like, if key a is pressed etc which
we will discuss below.
cv2.destroyAllWindows() simply destroys all the windows we created. If you want to
destroy any specific window, use the function cv2.destroyWindow() where you pass the
exact window name as the argument.

2.7.3 Write an image:


Use the function cv2.imwrite() to save an image. First argument is the file name, second
argument is the image you want to save.

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].

Ranges : this is our RANGE. Normally, it is [0,256].

23
CHAPTER 3

REASON FOR CHOOSING CHAOTIC MAPS

3.1 Pre Existing Image Encryption Methods

• DES (Data Encryption Standard)

• AES (Advanced Encryption Standard)

• RSA (Rivest-Shamir-Adleman)

3.2 Drawbacks of DES

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.

3.4 Drawbacks of AES

• It uses too simple algebraic structure.


• Every block is always encrypted in the same way.
• Hard to implement with software.
• AES in counter mode is complex to implement in software taking both
performance and security into considerations.

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

LOGISTIC AND RECTANGULAR CHAOTIC MAPS

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

4.3 PRINCIPLES OF PROPOSED ALGORITHM


Chaos has been widely investigated since the 1990s for encryption. It suggests
transformations and mapping functions which depend on initial conditions. Chaos theory
is a field of mathematics which focuses on dynamic systems, whose response is very
sensitive to initial conditions. Minute changes in the initial arguments can lead to a very
different output. They appear random, but their behavior is governed by mathematical
equations. These properties make chaotic systems a suitable choice for cryptography.
The chaotic maps used in the project are:
4.3.1 Logistic Map
The system should be highly unpredictable. However, repetition of values (many-to-
one function) conflicts with the requirement of invertibility. But if we sacrifice
invertibility temporarily, thereby introducing singularities, one dimensional chaotic
map can be easily found, as illustrated in the logistic map. It is one of the simplest
chaos functions given by (1). = 𝑟. .(1− ); 𝑛 = 0,1,2… (1)
Where, 𝑟is the control parameter of the logistic map and 𝑟𝜖[0,4];
is the system state at iteration 𝑛, 𝑥𝑛 𝜖 [0,1]; is
the initial condition of the system.
The values of generated for 𝑟 𝜖 [3.7,4] are chaotic and are independent of each other.
Any small change in generates varying values thus making it sensitive to the
initial value. This is shown in fig. 1, where 𝑟 = 3.9874 and is varied. The blue and red
trajectories in the graph are for = 0.324327 and = 0.324324

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.

4.3.2 2D Rectangular Transform


The conventional 2D transform is usually unable to directly scramble non-square
images. For a rectangle image, it needs to expand the image into a square one or
divide the image into several square sub-images, which brings extra computational
cost. In order to overcome this weakness, Shao [22] presented a 2D rectangular map
and proved its bijective feature, which can be considered as an extension of Arnold
map. Let gcd(m,n) denote the greatest common divisor of m and n, 2D rectangular
transform can be described as:

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

× ,

then and are the coefficient matrixes of 2D rectangular transform.

Based on this property, a random coefficient matrix of 2D rectangular transform


can be generated by using 7 random integers (1≤i ≤7) as follows:
(1) Set p=gcd(H,W) and = W/p. Generate two integer sequences{ , ,..., }
and { , , ..., } such that gcd( ,H)= 1 and gcd( ,W)= 1 (1≤ i<l ), where l is
a constant and is set to 512 in this paper.
(2) Let = , = × , and j = mod l. Construct a special coefficient matrix
as:

30
(3) Let = mod l (1≤ i ≤4). Then calculate the coefficient matrix A by the following
formula.

A= ×

4.4 PROPOSED ALGORITHM

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.2. Beads Fig. 4.3. Histogram (Beads)

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

To counter these problems we propose the following solutions- Applying


successive rounds of substitution after a permutation of all pixel positions. After a
round of substitution for each macroblock, permutation of the pixels will help mix the
pixels of each macroblock with other macroblocks. c. To counter this, in the last one
rounds of substitution, we find the product of each pixel in the macroblock &
normalize it by dividing by 25664. In the first two rounds, the seed for the successive
logistic maps is the last value generated by the previous logistic map (type-1). In the
last two rounds, each successive substitution box is derived from a new logistic map
whose initial seed is the normalized product value of the previous macroblock (type-
2). This ensures that if 1 pixel changes, it alters the seed for the next logistic map and
this error cascades forward for all pixels.The procedure for the substitution rounds
can be understood with the help of fig. 4.8 & 4.9.

Fig. 4.8 First round of substitution (Type-1)

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.

Fig. 4.10 Overview of Algorithm

35
CHAPTER 5

PERFORMANCE ANALYSIS AND RESULTS

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.

5.2 Statistical analysis


An ideal encryption algorithm should be robust against any statistical attack. To
prove the security of the proposed encryption scheme, we have carried out the statistical
analysis

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

Black 960×960 297.26 374.89 517992 143760

Boat 512×512 243.68 256.24 7904.2 392.25

Cameraman 256×256 279.56 278.18 2882.8 310.89

Lena 512×512 261.36 286.59 3553.5 376.87

Saturn 512×512 261.36 286.59 3553.5 376.87

White 760×760 321.42 326.38 343795 61000

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

5.4 Correlation Analysis


Because of the high correlation between adjacent pixels in plain image, an
effective encryption algorithm should eliminate this correlation in the encrypted image.
The correlations between two adjacent pixels along the horizontal, vertical and diagonal
directions in the plain images and the cipher images have been analyzed. We randomly
select 1000 pairs of adjacent pixels in three directions from the plain image Cameraman
and its encrypted image, respectively, and then show the correlation between adjacent
pixels as Fig below. It can be found from Fig below that the strong correlation between
adjacent pixels in the plain image is greatly reduced in the encrypted image. To quantify
and compare the correlations of adjacent pixels in the cipher images encrypted by
different algorithms, the correlation coefficients are calculated by using formula.

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.

In Comparison of average coefficient between different algorithms Table, we


give the average coefficient of each image encrypted by different algorithms,where the
last row showsthe mean ofaverage coefficients foreach algorithm.It can be seen that the
mean of average coefficients of the proposed algorithm is smaller than that of the others.
Therefore, our scheme can reduce the correlation between adjacent pixels in the plain
image more effectively.

Table 5.2 :-Correlations of the plain and the encrypted images

Image HC VC DC HC VC DC AC

Baboon 0.86640 0.76983 0.72920 0.00081 −0.00139 −0.00035 0.00000

Black 1.00000 1.00000 1.00000 0.00011 0.00035 0.00010 0.00019

40
Boat 0.93812 0.97131 0.92401 0.00146 −0.00372 −0.00079 0.00199

Cameraman 0.93348 0.95922 0.91299 −0.00329 −0.00388 0.00084 0.00267

Lena 0.97187 0.98498 0.96387 −0.00211 −0.00122 0.00160 0.00164

Saturn 0.99813 0.98808 0.98748 −0.00106 0.00027 −0.00009 0.00047

White 1.00000 1.00000 1.00000 0.00090 0.00107 0.00120 0.00106

Table 5.3 :- Comparison of average coefficient between different algorithms:

Table Ours Total Shuffling S-Box BlockCipher


Baboon 0.00085 0.00157 0.00198 0.00192
Black 0.00019 0.00186 0.06629 0.00767
Boat 0.00199 0.00199 0.00150 0.00238
Cameraman 0.00267 0.00280 0.00991 0.00232

5.5 Information entropy analysis


The information entropy is defined to express the degree of uncertainties or
randomness in a given system. The entropy H(m)of an m is calculated as:

H(m)=

Table 5.4 :-Entropy comparison between different algorithms:


Image Ours Total Shuffling S-Box Block Cipher

Baboon 7.99922 7.99931 7.98491 7.99918

Black 7.99977 7.99959 7.83104 7.91606

Boat 7.99930 7.99931 7.97839 7.99891

Cameraman 7.99731 7.99712 7.96775 7.99658

Lena 7.99927 7.99915 7.99018 7.99896

41
Saturn 7.99966 7.99959 7.97816 7.96584

White 7.99965 7.99931 7.93196 7.93426

Mean 7.99948 7.99905 7.95177 7.97283

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.

5.6 Differential Attack Analysis

In order to resist the differential attack, a secure cryptosystem should be sensitive


to the plaintext.That is to say,a minor plain image modificationwouldcause a
substantialchange in the cipher image. Such difference can be measured by means of the
number of pixels change rate (NPCR) and unified average changing intensity (UACI).
NPCR and UACI can be computed by below equations.

NPCR=

UACI= x100%

42
Table 5.5 :- Plaintext sensitivity of the proposed scheme:

Average Maximum Minimum

Image NPCR UACI NPCR UACI NPCR UACI

Baboon 99.6208 33.5034 99.7197 33.8127 99.5357 33.3972

Black 99.6465 33.4641 99.7503 33.5698 99.5768 33.3998

Boat 99.6219 33.4863 99.7116 33.5477 99.5300 33.3682

Cameraman 99.6172 33.4668 99.7009 33.7587 99.5392 33.2356

Lena 99.6099 33.4522 99.6628 33.5424 99.5327 33.3720

Saturn 99.6300 33.4725 99.8405 33.6168 99.5529 33.4176

White 99.6207 33.4721 99.7074 33.5645 99.5519 33.4037

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.

Table 5.6 :-NPCR comparison between different algorithms:


Image Ours Total Shuffling S-Box Block cipher

Baboon 99.6208 99.6545 99.7109 99.6034

Black 99.6465 99.6444 99.8684 99.6112

Boat 99.6219 99.6519 99.8902 99.6021

Cameraman 99.6172 99.6565 99.7737 99.6191

Lena 99.6099 99.6443 99.5847 99.6006

Saturn 99.6300 99.6319 96.0919 99.5890

Table 5.7 :-UACI comparison between different algorithms:


Image Ours Total Shuffling S-Box Block Cipher

Baboon 33.5034 33.4647 32.4752 33.4043

Black 33.4641 33.4750 33.8458 33.4499

Boat 33.4863 33.4648 34.0643 33.3665

Cameraman 33.4668 33.4882 34.1766 33.4710

Lena 33.4522 33.4333 34.4237 33.4257

Saturn 33.4725 33.4405 33.7824 33.3587

White 33.4721 33.4855 33.8739 33.4056

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.

5.8 Speed analysis


The speed of the proposed scheme is tested and compared with other schemes on
the same platform, which is the Microsoft VC++ programming on a personal computer
with 3.10 GHz Intel(R) Core(TM) i5-2400CPU and4 GB memory running on Microsoft
Windows7. We perform each encryption algorithm for 100 times on 256 gray-scale
images of different sizes.The average encryption time for different size images are listed
in Encryption time of different algorithms (in ms) table.Obviously, our algorithm has
higher encryption speed. This is mainly because our algorithm employs dependent
substitution and requires only two traverses of the image pixels.In reverse 2-dimensional
chaotic map and dependent diffusion. Arnold transform needs to be run twice to
permutate image pixels,which results in extra time consumption.Total shuffling and
bidirectional diffusion scheme uses the large permutation of the same size as the plain
image for totally shuffling pixels, which spends much time to construct such a large
permutation.chaotic block cipher algorithm adopts block cipher to avoid the construction
of large permutation. However this algorithm needs re-sorting the permutation for each
image block. In dynamic S-boxes implementation by chaos method, S-box is used for
block cipher instead of permutation, but it takes a lot of time to scan the image in four

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.

Table 5.8. :-Encryption time of different algorithms (in ms):


Algorithm 64KB 256KB 1MB 4MB 9MB 16MB

Ours 0.45545 1.85149 8.02970 45.09901 189.8317 338.1089

Total 2.13725 8.56863 35.1764 136.7254 357.2745 669.8823


Shuffling
S-Box 1.38614 5.09901 22.7029 113.5247 280.3366 1114.702

Block 3.39604 8.02970 26.5643 102.4059 227.5148 404.2079


Cipher

5.9 Results

5.9.1 For Coloured Image

Fig. 5.4. Original Image

46
Fig. 5.5. Round 1 encrypted output(substitution)
Using 16×16 block size macro blocks

Fig 5.6. Round 2 output(permutation)


Shuffled using Rectangular maps

47
Fig. 5.7. Round 3 output

Fig. 5.8. Round 4 output(ENCRYPTED)

48
Fig. 5.9. Decrypted Output

6.2 For a gray scale image:

Fig 5.10. Original Image

49
Fig 5.11. Encrypted Output of Round 1 (Substitution)
Using 16×16 block size macro blocks

Fig 5.12. Output of Round 2 (Permutation)


Shuffled using Rectangular maps

50
Fig 5.13. Output of Round 3

Fig 5.14. Encrypted Output (Round 4)

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

You might also like