CNS Unit2
CNS Unit2
UNIT 2
Cryptography
Fig: Cryptanalysis
1
Sangameshwar College CNS
Clear text, or plain text, signifies a message that can be understood by the
sender, the recipient, and also by anyone else who gets access to that message.an
example, they replace each alphabet with the alphabet that is actually
three alphabets down the order. So, each A will be replaced by D, B will be
replaced by E, C will be replaced by F, and so on. To complete the cycle, each W will
be replaced by Z, each X will be replaced by A, each Y will be replaced by B and each
Z will be replaced by C. We can summarize this scheme as shown in following Fig. .
The first row shows the original alphabets, and the second row shows what each
original alphabet will be replaced with.
fig: A scheme for codifying messages (replacing each alphabet with an alphabet
three places down the line)
Thus, using the scheme of replacing each alphabet with the one that is three
places down the line, a message I love you shall become L ORYH BRX as
shown in following Fig.
2
Sangameshwar College CNS
It is not necessary to replace each alphabet with the one that is three places
down the order. It can be the one that is four, five or more places down
the order. The point is, however, that each alphabet in the original message can
be replaced by another to hide the original contents of the message. The
codified message is called cipher text. Cipher means a code or a secret message.
When a plain-text message is codified using any suitable scheme, the resulting
message is called cipher text. Based on these concepts, let us put these terms
into a diagrammatic representation, as shown in following Fig.
3
Sangameshwar College CNS
SUBSTITUTION TECHNIQUES
1.Caesar Cipher
The scheme explained earlier (of replacing an alphabet with the one three places
down the order) was first proposed by Julius Caesar, and is termed Caesar
cipher. It was the first example of substitution cipher. In the substitution-cipher
technique, the characters of a plain-text message are replaced by other
4
Sangameshwar College CNS
Clearly, the Caesar cipher is a very weak scheme of hiding plain-text messages.
All that is required to break the Caesar cipher is to do the reverse of the Caesar
cipher process—i.e. replace each alphabet in a cipher-text message produced by
Caesar cipher with the alphabet that is three places up the line. Thus,
to work backwards, take a cipher text produced by Caesar cipher, and replace
each A with X, B with Y, C with Z, D with A, E with B and so on. The simple
algorithm required to break the Caesar cipher can be summarized as shown in
following Fig.
The process shown above will reveal the original plain text. Thus, given a
cipher-text message L ORYH BRX, it is easy to work backwards and obtain the
plain text I LOVE YOU as shown in following fig.
The Caesar cipher is good in theory, but not so good in practice. Alphabet A in
plain text would not necessarily be replaced by D. It can be replaced by any
valid alphabet, i.e. by E or by F or by G, and so on. Once the replacement
scheme is decided, it would be constant and will be used for all other alphabets
in that message. As we know, the English language contains 26 alphabets. Thus,
an alphabet A can be replaced by any other alphabet in the English alphabet set,
(i.e. B through Z). Of course, it does not make sense to replace an alphabet by
5
Sangameshwar College CNS
itself (i.e. replacing A with A). Thus, for each alphabet, we have 25 possibilities
of replacement. Hence, to break a message in the modified version of Caesar
cipher, our earlier algorithm would not work. Let us write a new algorithm to
break this version of the Caesar cipher, as shown in following Fig.
Let us take a cipher-text message produced by the modified Caesar cipher, and
try breaking it to obtain the original plain-text message by applying the
algorithm shown earlier. Since each alphabet in the plain-text can be potentially
replaced by any other of the 25 alphabets, we have 25 possible plain-text
messages to choose from. Thus, the output produced by the above algorithm to
break a cipher-text message KWUM PMZN is shown in following Fig
We can see that the cipher text shown in the first row of the figure needs 25
different attempts to break in, as depicted by the algorithm shown earlier. As it
turns out, the 18th attempt reveals the correct plain text corresponding to the
cipher text. Therefore, we can actually stop at this juncture. For the sake of
completeness, however, we have shown all the 25 steps, which is, of course, the
worst possible case.
6
Sangameshwar College CNS
the following points to break a cipher-text message using the brute-force attack,
in this scheme:
1. Substitution technique was used to derive the cipher text from the original
plain text.
3.Mono-alphabetic Cipher
The major weakness of the Caesar cipher is its predictability. Once we decide to
replace an alphabet in a plain-text message with an alphabet that is k positions
up or down the order, we replace all other alphabets in the plain-text message
with the same technique. Thus, the cryptanalyst has to try out a maximum of 25
possible attacks, and he/she is assured of success.
Now imagine that rather than using a uniform scheme for all the alphabets in a
given plain-text message, we decide to use random substitution. This means that
in a given plain-text message, each A can be replaced by any other alphabet (B
through Z), each B can also be replaced by any other random alphabet (A or C
through Z), and so on. The crucial difference being, there is no relation between
the replacement of B and replacement of A. That is, if we have decided to
replace each A with D, we need not necessarily replace each B with E—we can
replace each B with any other character!To put it mathematically, we can now
have any permutation or combination of the 26 alphabets, which
7
Sangameshwar College CNS
In the polygram substitution cipher technique, rather than replacing one plain-
text alphabet with one cipher text alphabet at a time, a block of alphabets is
8
Sangameshwar College CNS
TEUI, as shown in following Fig.. This is true in spite of the first four
characters of the two blocks of text (HELL) being the same. This shows that in
the polygram substitution cipher, the replacement of plain text happens block by
block, rather than character by character.
Polygram substitution cipher technique replaces one block of plain text with
another block of cipher text—it does not work on a character-by-character basis.
This cipher uses multiple one-character keys. Each of the keys encrypts one
plain-text character. The first key encrypts the first plain-text character; the
second key encrypts the second plain-text character, and so on. After all the
keys are used, they are recycled. Thus, if we have 30 one-letter keys, every 30th
character in the plain text would be replaced with the same key. This number (in
this case, 30) is called the period of the cipher.
9
Sangameshwar College CNS
(b) It uses a key that determines which rule is used for which transformation.
For example, let us discuss the Vigenére cipher, which is an example of this
cipher. In this algorithm,26 Caesar ciphers make up the mono-alphabetic
substitution rules. There is a shifting mechanism, from a count of 0 to 25. For
each plain-text letter, we have a corresponding substitution, which we call the
key letter. For instance, the key value is e for a letter with shift as 3.
The logic for encryption is quite simple. For key letter p and plain-text letter q,
the corresponding cipher-text letter is at the intersection of row titled p and
column titled q. For this very particular case, the cipher text, therefore, would
be F, based on the above table.
10
Sangameshwar College CNS
TRANSPOSITION TECHNIQUES
1. Rail-Fence Technique
Let us illustrate the rail-fence technique with a simple example. Suppose that
we have a plain-text message :Come home tomorrow. This is shown in
following Fig. As the figure shows, the plain-text message ‘Come home
tomorrow’ transforms into ‘Cmhmtmrooeoeoorw’ with the help of rail-fence
technique.
Rail-fence technique involves writing plain text as a sequence of diagonals and
then reading it row by row to produce cipher text.
11
Sangameshwar College CNS
1. Basic Technique
12
Sangameshwar College CNS
As we can see, the only addition in this technique to the basic simple columnar
transposition technique is step 4, which results in the execution of the basic
algorithm on more than one occasion. Although this sounds trivial, in reality, it
makes the cipher text far more complex as compared to the basic simple
columnar transposition technique. Let us extend our earlier example to now
have multiple rounds of transposition, as shown in following Fig
13
Sangameshwar College CNS
As the figure shows, multiple rounds or iterations add more complexity to the
cipher text produced by the basic simple columnar transposition technique. The
more the number of iterations, the more complex is the cipher text thus
produced.
14
Sangameshwar College CNS
Let us apply the Vernam cipher algorithm to a plain-text message HOW ARE
YOU using a one-time pad NCBTZQARX to produce a cipher-text message
UQXTRUYFR as shown in following Fig.
It should be clear that since the one-time pad is discarded after a single use, this
technique is highly secure and suitable for small plain-text message, but is
clearly impractical for large messages. The Vernam Cipher was first
implemented at AT&T with the help of a device called the Vernam machine.
Vernam Cipher uses a one-time pad, which is discarded after a single use, and
therefore, is suitable only for short messages
The idea used in book cipher, also incorrectly called running-key cipher, is quite
simple, and is similar in principle to the Vernam cipher. For producing cipher
text, some portion of text from a book is used, which serves the purpose of a
one-time pad. Thus, the characters from a book are used as onetime pad, and
15
Sangameshwar College CNS
they are added to the input plain-text message similar to the way a one-time pad
works
Fig: Decryption
16
Sangameshwar College CNS
To encrypt a plain-text message, the sender (we shall henceforth treat the term
sender to mean the sender’s computer) performs encryption, i.e. applies the
encryption algorithm. To decrypt a received encrypted message, the recipient
performs decryption, i.e. applies the decryption algorithm. The decryption
algorithm must be the same as the encryption algorithm.The second aspect of
performing encryption and encryption of messages is the key.
Every encryption and decryption process has two aspects: the algorithm and the
key used for encryption and decryption.
17
Sangameshwar College CNS
Broadly, there are two cryptographic mechanisms, depending on what keys are
used. If the same key is used for encryption and decryption, we call the
mechanism symmetric key cryptography. However, if two different keys are
used in a cryptographic mechanism, wherein one key is used for encryption, and
another, different key is used for decryption; we call the mechanism
asymmetric key cryptography
Symmetric key cryptography involves the usage of the same key for encryption
and decryption. Asymmetric key cryptography involves the usage of one key for
encryption, and another, different key for decryption.
STEGANOGRAPHY
Steganography is a technique that facilitates hiding of a message that is to be
kept secret inside other messages. This results in the concealment of the secret
message itself! Historically, the sender used methods such as invisible ink, tiny
pin punctures on specific characters, minute variations between handwritten
characters, pencil marks on handwritten characters, etc.
18
Sangameshwar College CNS
1. Cipher-Text Only Attack -In this type of attack, the attacker does not
have any clue about the plain text. She has some or all of the cipher text.
(Interestingly, we should point out that if the attacker does not have an
access even to the cipher text, there would be no need to encrypt the plain
text to obtain cipher text in the first place!).
19
Sangameshwar College CNS
The attacker analyzes the cipher text at leisure to try and figure out the original
plain text. Based on the frequency of letters (e.g. the alphabets e, i, a are very
common in English, etc.) the attacker makes an attempt to guess the plain text.
Obviously, the more cipher text available to the attacker, more are the
chances of a successful attack. For instance, consider a very small cipher text
block, RTQ. It is very difficult to guess the original plain text, given this block.
There could be numerous possible plain texts, which yield this cipher text upon
encryption. In contrast, if the cipher text size is bigger, the attacker
can narrow down the various permutations and combinations to try and obtain
the original plain text. The concept is shown in Fig.
20
Sangameshwar College CNS
Here, the attacker selects a plain-text block, and tries to look for the encryption
of the same in the cipher text. Here, the attacker is able to choose the messages
to encrypt. Based on this, the attacker intentionally picks patterns of cipher text
that result in obtaining more information about the key.
For example, a telegraph company may offer a paid service where they encrypt
people’s messages and send them to the desired recipient. The telegraph
company on the other side would decrypt the message and give the original
message to the recipient. Therefore, it is quite possible for the attacker to choose
some plain text, which she thinks is quite commonly used in secret messages.
21
Sangameshwar College CNS
Therefore, the attacker chooses some such plain text and pays the telegraph
company to encrypt it. The result of this is that the attacker now has access to
some plain text that he/she had chosen, and its corresponding cipher text.
In the chosen cipher-text attack, the attacker knows the cipher text to be
decrypted, the encryption algorithm that was used to produce this cipher text,
and the corresponding plain-text block. The attacker’s job is to discover the key
used for encryption. However, this type of attack is not very commonly used.
5. Chosen-Text Attack
The chosen-text attack is essentially a combination of chosen plain-text attack
and chosen cipher-text attack. This is shown in following Fig
22
Sangameshwar College CNS
23
Sangameshwar College CNS
Asymmetric cryptography
24
Sangameshwar College CNS
It is a modern encryption
Techniques It is an old technique.
technique.
25