You are on page 1of 53

CHAPTER TWO

ELEMENTARY CRYPTOGRAPHY

Part One

Computer Networks and Information Security


(CE 211)
1
Objectives
 Introducing Cryptography and Stenography
 Explain the basic steganography methods

 Describe about the basic cryptography concepts and terminologies

 Understand the Characteristics of Cryptographic Systems

 Explain about Symmetric and Asymmetric Encryption techniques

2
Cryptography Vs. Steganography
1. Steganography:- is the art and science of writing hidden messages in such a way
that no one, apart from the sender and intended recipient, suspects the existence of
the message.
 It is a form of security through obscurity.
 The word steganography is of Greek origin and means "concealed writing"
from the Greek words steganos meaning "covered or protected", and
graphei meaning "writing".
 The advantage of steganography, over cryptography alone, is that messages do
not attract attention to themselves.
 Plainly visible encrypted messages—no matter how unbreakable—will arouse
suspicion, and may in themselves be incriminating in countries where
encryption is illegal.
 Therefore, whereas cryptography protects the contents of a message,
steganography can be said to protect both messages and communicating
parties.
3
Steganography Methods
Some of the many methods of steganography includes:
a. Character Marking:- Selected letters of text are overwritten in pencil. The
marks are not visible unless the paper is held at an angle to bright light.
b. Invisible ink:- Substances can be used that leave no visible trace heat or some
chemical is applied.
c. Pin Punctures:- Small pin punctures on selected letters are not ordinarily
visible unless paper is held in front of light.
d. A message can be concealed in a much longer, innocent-looking piece of text;
the long text is composed so that a subsequence of the letters (chosen by some
rule known to the recipient) forms the message.
For example, taking every fifth letter(excluding the white spaces) of “The
prepared letters bring news of amounts” gives the message “Retreat”.

4
Contd.
2. Cryptography:- is the art of protecting transmitted information from
unauthorized interception or tampering.
 It is the art and science of encompassing the principle and methods of
transforming an intelligible(plain text) message into one that is
unintelligible(cipher text), and then retransforming that message back to its
original form.
 The sender enciphers a message into unintelligible form, and the receiver
deciphers it into intelligible form.
 The word “cryptology” is derived from the Greek kryptos (hidden) and
logos (word)
 Cryptography is closely related to another part of communication theory,
namely coding theory.
 Coding Theory involves translating information of any kind (text, scientific
data, pictures, sound, and so on) into a standard form for transmission, and
protecting this information against distortion by random noise.
5
Basic Cryptography Concepts and Terminologies
 Plaintext:- is the original intelligible message or data that is fed into the algorithm as
input.
 The plaintext is not quite the same as the message being sent.
 The message probably has to be translated into some standard form to be encrypted;
for example, this might be leaving out the punctuation, turning it into ASCII code or
a sequence of numbers, etc.
 But there is nothing secret about this stage; knowing the plaintext is equivalent to
knowing the message.
 Ciphertext:- is the scramble message produced as an output of the encryption
algorithm.
 Key(Secret Key):- is some critical information used by the encryption algorithm as
input to encrypt the plaintext.
 It is independent of the plaintext and encryption algorithm
 It is only known to the sender and receiver.
6
Contd.
 Enciphering or Encryption:- is the process of converting the plaintext to
ciphertext.

 Deciphering/Decryption:- is the process of restoring back the plaintext


from the ciphertext.

 Cryptography:- The enciphering and deciphering of messages into secret


codes by means of various transformations of the plaintext.

 Cryptanalysis(code breaking):- The process of deriving the plaintext


from the ciphertext (breaking a code) without being in possession of the key or
the system.

 Cryptology:- The scientific study of cryptography and cryptanalysis.


7
Encryption
 As we stated before , Encryption is considered as a component of the
cryptographic framework . It’s role is to offer the confidentiality axis
of the CIA triad .
 Recalling the systematic view
of any cryptographic
component , Encryption needs
an input (Clear message & key)
to deliver the cipher form
(output) , this cipher form to be
decrypted (converted to the
clear form ) we shall need a key
and the same algorithm .
Two Basic approaches to Security
 Workstations are attached to LANs so that users can reach other hosts,
workstations and servers in the same LAN that are interconnected via bridges and
routers.
 Since data is transmitted in the form packets (visible on the LAN) which contain
source/destination IDs, and other information, an eavesdropper can have access to
this information.
 An eavesdropper may also occur in any of the communications links which
provide connectivity to the system.
1. Link Encryption:- Each vulnerable communication link is equipped on both ends
with an encryption device.
 The main disadvantage is that it is effective only if all potential weak links from
source to destination are secured.
2. End-to-End Encryption:- Data is encrypted only at the source node and
decrypted at the destination node.
9
Roadmap of Cryptography
 Classical cryptography (--- 1920s)
 secret writing required only pen and paper
 Mostly: transposition, substitution ciphers
 Easily broken by statistics analysis (e.g., frequency)

 Mechanical devices invented for encryption


 Rotor machines (e.g. Enigma cipher) 1930s-1950s
 featured in films, such as in the James Bond adventure From Russia with Love

 Specification of DES and the invention of RSA (1970s) --- modern


ciphers
 Public key system, most notably

 Quantum Cryptography (future?)

10
Current Two Aspects of Quantum Cryptography
1. Quantum key exchange (also known as quantum key distribution), a
method for secure communications based on quantum mechanics
2. Conjectured effect of quantum computing on cryptanalysis, although it
is currently, like quantum computing itself, only a theoretical concept.
 Basic idea of quantum key exchange is to use the "noisy" properties of
light to render incoherent an image that acts to complement a secret key.
 This image can be represented in a number of ways, but the ability to
decode that image rests upon an understanding of how it was made. No way
to intercept the transmission without changing it is possible, so key
information can be exchanged with great confidence it has been transmitted
secretly.
 quantum computing will considerably extend the reach of cryptanalysis,
making brute force key space searches much more effective -- if such
computers ever become possible in actual practice

11
b) 16th-century book-shaped
a) German Lorenz cipher machine, French cipher machine, with
used in World War II to encrypt arms of Henri II of France
very-high-level general staff
messages

c) Reconstructed ancient Greek


scytale (rhymes with "Italy"), an d) Credit card with smart-
early cipher device card capabilities.
12
Characteristics of Cryptographic Systems

1. The type of operation used for transforming plaintext to ciphertext:-


All encryption algorithms are based on two general principles:
a. Substitution, in which each element in the plaintext(bit, letter, group
of bits or letters) is mapped into another element, and
b. Transposition, in which elements in the plaintext are rearranged.
2. The number of keys used:- if both sender and receiver use the same key,
the system is referred to as symmetric, single-key or conventional
encryption.
 If the sender and receiver use different keys, then the system is
referred to as Asymmetric, two-key or public-key
encryption.
Contd.

3. The way in which the plaintext is processed:- Input plaintext can be

processed either using block cipher or stream cipher.

 A block cipher processes the input one block of elements(typically


64 or 128 bits) at a time, producing an output block for each input

block.

 A stream cipher processes the input elements (one bit or one byte)
continuously, producing output one element at a time, as it goes

along.
Symmetric Vs. Asymmetric Encryption
 Symmetric encryption is a form of cryptography in which encryption
and decryption are performed using the same key.
 It is a single-key encryption which was the only encryption in use
prior to the development of public-key encryption 1970s.
 It is also known as conventional Encryption.
 The modern study of symmetric-key ciphers relates mainly
to the study of block ciphers and stream ciphers and to
their applications.
A block cipher is, in a sense, a modern embodiment of
Alberti's polyalphabetic cipher: block ciphers take as input
a block of plaintext and a key, and output a block of
ciphertext of the same size.
Contd.
 Since messages are almost always longer than a single block,
some method of knitting together successive blocks is required.
 The Data Encryption Standard (DES) and the Advanced
Encryption Standard (AES) are block cipher designs which have
been designated cryptography standards by the US government
(though DES's designation was finally withdrawn after the AES
was adopted).
 Stream ciphers, in contrast to the 'block' type, create an
arbitrarily long stream of key material, which is combined with
the plaintext bit-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 which changes as the cipher operates.
 RC4 is a widely used stream cipher;
Contd.
Contd.
 To wrap the concept let us discuss a case for three entities that need to
communicate securely using symmetric encryption.
 From the figure , we can conclude that
we will use 9 different private keys for
achieving bidirectional communication
between xyz and abc .
 We can conclude also that we need to
define a way by which we can
exchange these private keys in a secure
manner between distant entities.
 DES , 3DES , Blowfish , IDEA , RC5 ,
Safer , Serpent and AES are the well
known symmetric encryption
algorithms .
Asymmetric Encryption
 Here the sender will use a key to encrypt the message and the receiver
will use a different key to decrypt the message , in case we have a
bidirectional communication , each pair will use two keys one of them is
public for others and a private key for himself.
Contd.
 Back to the same case that was assumed when using symmetric
encryption.
 ABC and XYZ have their public keys
distributed over each other , anyone needs
to talk to the other will use the other’s
public key to encrypt the traffic and the
other will use his own private key to
decrypt the traffic , X will use A’s public
key to encrypt clear traffic A will receive
the cipher to decrypt it using his own
private key .
 Less number of keys and simple key
distribution.
Let us now compare them (symmetric and asymmetric) :

Symmetric key encryption suffers from scalability issues ; to achieve a


secure communication between N points , we will need to generate (N(N-
1))/2 different keys .

Symmetric key encryption requires “ out of band “ secure exchange of


keys , because , both the communicating parties needs to know about the
keys before proceeding into the communication .

Asymmetric key encryption systems are incredibly complex , and that


complexity will surely impact the performance . Asymmetric key
encryption is up to 1000 times slower than symmetric key encryption .

Now how can we deal with that problem ?!!! , Diffie and Hellman will
answer this question for us .
Key Management

 Using secret channel

 Encrypt the key

 Third trusted party

 The sender and the receiver generate key


 The key must be same

 We will talk more about how we can generate keys for two
parties who are “unknown” of each other before, and want
secure communication
22
Diffie-hellman
 Diffie-Hellman algorithm will use
public key encryption to only
distribute symmetric keys for
communicating parties , symmetric
key encryption will be used to deal
with clear data to create the cipher ,
so we will have no odds: high
performance using symmetric key
encryption and simple key
distribution process using Diffie-
Hellman algorithm.
Contd.
 Khaled will generate two (public and private ) keys using his own
Diffie-Hellman algorithm , Ali will do the same thing ; both of them will
exchange his own public key , khaled will have his own private key and
Ali’s public key , he will use his Diffie-Hellman algorithm to generate a
new private key ; Ali will have the same private key if he executed the
same operation.
Requirements for Secure use of Conventional Encryption
1. Strong Encryption algorithm:- The algorithm should be strong enough
so that an opponent who knows the algorithm and has access to one or
more ciphertext would be unable to decipher the ciphertext or figure out
the key.
2. Sender and receiver must have obtained copies of the secret key in a
secure fashion and must keep the key secure.
 If someone can discover the key and knows the algorithm, all
communication using the key is readable.
 Therefore, if the key is generated at the message source, then
it must be provided to the destination by means of some secure
channel.
 Alternatively, a third party could generate the key and securely
deliver it to both source and destination.
Contd.

General idea of symmetric-key cipher

26
Contd.
If P is the plaintext, C is the ciphertext, and K is the key,

We assume that Bob creates P1; we prove that P1 = P:

27
Attacking Symmetric Encryption
 cryptanalysis
 rely on nature of the algorithm

 plus some knowledge of plaintext characteristics

 even some sample plaintext-ciphertext pairs

 exploits characteristics of algorithm to deduce specific plaintext or key

 brute-force attack
 try all possible keys on some ciphertext until get an intelligible
translation into plaintext
 On average, half of all possible keys must be tried to achieve success.

28
Cryptanalysis

 Objective:- to recover the plaintext of a ciphertext or, more typically, to

recover the secret key.

 Kerkhoff’s principle:- the adversary knows all details about a

cryptosystem except the secret key.

 Two general approaches to attack conventional encryption scheme:

 brute-force attack

 non-brute-force attack (cryptanalytic attack)

29
Brute-Force Attack
 The attacker tries every possible key on a piece of ciphertext until an
intelligent translation into plaintext is obtained.
 On average, need to try half of all possible keys
 Time needed proportional to size of key space
Key Size (bits) Number of Time required at 1 Time required at 106
Alternative Keys decryption/µs decryptions/µs
32 232 = 4.3  109 231 µs = 35.8 minutes 2.15 milliseconds

56 256 = 7.2  1016 255 µs = 1142 years 10.01 hours

128 2128 = 3.4  1038 2127 µs = 5.4  1024 years 5.4  1018 years

168 2168 = 3.7  1050 2167 µs = 5.9  1036 years 5.9  1030 years

26 characters 26! = 4  1026 2  1026 µs = 6.4  1012 years 6.4  106 years
(permutation)

30
Cryptanalytic Attack
 Cryptanalytic attacks rely on the nature of the algorithm plus perhaps
some knowledge of the general characteristics of the plaintext or even
some sample plaintext-ciphertext pairs.
 This type of attack exploits the characteristics of the algorithm to
attempt to deduce a specific plaintext or to deduce the key being used.
 May be classified by how much information needed by the attacker:
1. Ciphertext-only attack
2. Known-plaintext attack
3. Chosen-plaintext attack
4. Chosen-ciphertext attack
5. Chosen-text attack

31
Ciphertext-only attack
 Attacker knows ciphertext of several messages encrypted with same
key (but doesn’t know plaintext).

 Possible to recover plaintext (also possible to deduce key) by looking


at frequency of ciphertext letters

 That is, Given: a ciphertext c


Q: what is the plaintext m?

 An encryption scheme is completely insecure if it cannot resist


ciphertext-only attacks.

 Ciphertext-only attack is the easiest to defend against because the


opponent has the least amount information to work with.
32
Contd.

The attacker knows the Algorithm and ciphertext but does


not know the plaintext
33
Known-plaintext attack

 Attackers observe pairs of plaintext-ciphertext encrypted with the

same secret key.

 Possible to deduce key and/or devise algorithm to decrypt

ciphertext.

 That is, Given: (m1,c1), (m2,c2), …, (mk, ck) and a new ciphertext
c

Q: what is the plaintext c?

Q: what is the secret key in use?


34
Contd.

The attacker knows the Algorithm, ciphertext and plaintext-ciphertext


pair
35
Chosen-plaintext attack

 Attacker can choose the plaintext and look at the paired ciphertext
 Attacker has more control than known-plaintext attack and may be
able to gain more info about key

 That is, Given: (m1,c1), (m2,c2), …,(mk,ck), where m1, m2, …, mk are

chosen by the adversary; and a new ciphertext c.

Q: what is the plaintext c, or what is the secret key?

36
Contd.

The attacker knows the Algorithm, ciphertext and chosen plaintext and
its ciphertext 37
Example: chosen-plaintext attack
 In 1942, US Navy cryptanalysts discovered that Japan was planning an attack on
“AF”.

 They believed that “AF” means Midway island.


 Pentagon didn’t think so.
 US forces in Midway sent a plain message that their freshwater supplies were low.
 Shortly, US intercepted a Japanese ciphertext saying that “AF” was low on water.
 This proved that “AF” is Midway.

38
Chosen-ciphertext attack

 Attacker chooses a series of plaintexts, basing the next plaintext on the

result of previous encryption

 The Encryption algorithm, ciphertext and purported ciphertext chosen by


cryptanalyst, together with its corresponding decrypted plaintext generated

with the secret key are known to cryptanalyst.

 That is, Given: (m1,c1), (m2,c2), …,(mk, ck), where c1, c2, …, ck are chosen

by the adversary; and a new ciphertext c.

Q: what is the plaintext of c, or what is the secret key?


39
Contd.

The attacker knows the Algorithm, ciphertext and chosen plaintext


and its ciphertext
40
Chosen-text attack
 Here the attacker has the capability to choose arbitrary plaintexts to be encrypted
and obtain the corresponding ciphertexts.
 The attacker knows the Algorithm, ciphertext, chosen plaintext and
ciphertext
 The goal of the attack is to gain some further information which reduces the
security of the encryption scheme.
 In the worst case, a chosen-plaintext attack could reveal the scheme's secret key.
 The Encryption algorithm, ciphertext, plaintext message chosen by the
cryptanalyst, together with its corresponding ciphertext generated with the secret
key and purported ciphertext chosen by cryptanalyst, together with its
corresponding decrypted plaintext generated with the secret key are known to
cryptanalyst.

41
Two forms of Chosen-text attack

 Batch chosen-plaintext attack, where the cryptanalyst chooses all

plaintexts before any of them are encrypted.

 This is often the meaning of an unqualified use of "chosen-

plaintext attack".

 Adaptive chosen-plaintext attack, where the cryptanalyst makes a


series of interactive queries, choosing subsequent plaintexts based on

the information from the previous encryptions.

42
Definitions
1. An encryption scheme is unconditionally secure, if the ciphertext
generated by the scheme does not contain enough information to determine
uniquely the corresponding plaintext, no matter how much ciphertext is
available.

 No such encryption algorithm exists.

2. An encryption scheme is said to be conditionally secure, if either of the


following two criteria are met:

 The cost of breaking the cipher exceeds the value of the encrypted
information.

 The time required to break the cipher exceeds the useful timeline of the
information.
43
Classical Cryptography

 Sender, receiver share common key


 Keys may be the same, or trivial to derive from one another

 Sometimes called symmetric cryptography

 Two basic types


 Transposition ciphers

 Substitution ciphers

 Combinations are called product ciphers

44
Transposition Cipher
 Rearrange letters in plaintext to produce ciphertext
1. Rail-Fence Cipher, the plaintext is written downwards and diagonally on
successive "rails" of an imaginary fence, then moving up when we reach the
bottom rail.

 When we reach the top rail, the message is written downwards again
until the whole plaintext is written out.

 The message is then read off in rows.

 For example, if we have 3 "rails" and a message of ‘KILL THE


QUEEN', the cipher writes out:
K . . . T . . . U . . . Then the ciphertext will be:
. I . L . H . Q . E . N
KTU ILHQEN LEE
. . L . . . E . . . E . 45
2. Route Cipher
 In a route cipher, the plaintext is first written out in a grid of given
dimensions, then read off in a pattern given in the key.

 Route ciphers have many more keys than a rail fence.

 In fact, for messages of reasonable length, the number of possible keys is


potentially too great to be enumerated even by modern machinery.

 For example, if we have 3 "rails" and a message of ‘KILL THE QUEEN',


the cipher writes out:

K L E E The key might specify "spiral inwards, clockwise,


I T Q E
starting from the top right". That would give a
L H U N
46
cipher text of: EENUHLIKLEQT
3. Columnar transposition
 In a columnar transposition, the message is written out in rows of a fixed
length, and then read out again column by column, and the columns are
chosen in some scrambled order. Both the width of the rows and the
permutation of the columns are usually defined by a keyword.

 For example, the word ZEBRAS is of length 6 (so the rows are of length 6),
and the permutation is defined by the alphabetical order of the letters in the
keyword. In this case, the order would be "6 3 2 4 1 5".

 In a regular columnar transposition cipher, any spare spaces are filled with
nulls; in an irregular columnar transposition cipher, the spaces are left blank.

47
Contd.
 Finally, the message is read off in columns, in the order specified by the
keyword.
 For example, suppose we use the keyword ZEBRAS and the message WE
ARE DISCOVERED FLEE AT ONCE. In a regular columnar
transposition, we write this into the grid as:
6 3 2 4 1 5 6 3 2 4 1 5
W E A R E D W E A R E D
I S C O V E I S C O V E
R E D F L E R E D F L E
E A T O N C E A T O N C
E Q K J E N E
Providing five nulls (QKJEU) at the end. The In the irregular case, the columns are not
ciphertext is then read off as: EVLNE ACDTK completed by nulls. The ciphertext is then read
ESEAQ ROFOJ DEECU WIREE off as EVLNA CDTES EAROF ODEEC
WIREE 48
4. Double transposition
 A single columnar transposition could be attacked by guessing possible
column lengths, writing the message out in its columns (but in the wrong
order, as the key is not yet known), and then looking for possible anagrams.

 Thus to make it stronger, a double transposition was often used. This is


simply a columnar transposition applied twice.

 The same key can be used for both transpositions, or two different keys can be
used.

 As an example, we can take the result of the irregular columnar transposition


in the previous section, and perform a second encryption with a different
keyword, STRIPE, which gives the permutation "564231":

49
Contd.
5 6 4 2 3 1
E V L N A C
D T E S E A
R O F O D E
E C W I R E
E

As before, this is read off columnwise to give the ciphertext:

CAEEN SOIAE DRLEF WEDRE EVTOC

50
5. Myszkowski Transposition
 A variant form of columnar transposition, proposed by Émile Victor
Théodore Myszkowski in 1902, requires a keyword with recurrent

letters.

 In usual practice, subsequent occurrences of a keyword letter are

treated as if the next letter in alphabetical order, e.g., the keyword

TOMATO yields a numeric keystring of "532164."

 In Myszkowski transposition, recurrent keyword letters are numbered


identically, TOMATO yielding a keystring of "432143." 51
Contd.
4 5 2 1 4 3
W E A R E D
I S C O V E
R E D F L E
E A T O N C
E

Plaintext columns with unique numbers are transcribed downward; those


with recurring numbers are transcribed left to right:
ROFOA CDTDE ECWEI VRLEN EESEA

52
6. Disrupted Transposition
 In disrupted transposition, certain positions in a grid are blanked out,
and not used when filling in the plaintext.

 This breaks up regular patterns and makes the cryptanalyst’s job

more difficult.

[Reading Assignment]

53

You might also like