Cryptography - Computer Networks-Lecture Notes
Cryptography - Computer Networks-Lecture Notes
Lecture 17
Ms. Sukla Banerjee, Asst Prof, Dept. of CSE,
RCCIIT
Cryptography
What Is Cryptography?
Cryptography -- from the Greek for “secret
writing” -- is the mathematical “scrambling”
of data so that only someone with the
necessary key can “unscramble” it.
Cryptography allows secure transmission of
private information over insecure channels
(for example packet-switched networks).
Cryptography also allows secure storage of
sensitive data on any computer.
Plaintext and Ciphertext
The original message, before being transformed, is called plaintext.
After the message is transformed, it is called ciphertext. An
encryption algorithm transforms the plaintext into ciphertext; a
decryption algorithm transforms the ciphertext back into plaintext.
The sender uses an encryption algorithm, and the receiver uses a
decryption algorithm.
Cipher
We refer to encryption and decryption algorithms as ciphers. The
term cipher is also used to refer to different categories of algorithms
in cryptography. One cipher can serve millions of communicating
pairs.
Key
A key is a number (or a set of numbers) that the cipher, as an
algorithm, operates on. To encrypt a message, we need an
encryption algorithm, an encryption key, and the plaintext. These
create the ciphertext. To decrypt a message, we need a decryption
algorithm, a decryption key, and the ciphertext. These reveal the
original plaintext.
Figure 20.1 Cryptography components
Figure 20.2 Categories of cryptography
Classical Cryptography:
Secret-Key or Symmetric Cryptography
Alice and Bob agree on an encryption
method and a shared key.
Alice uses the key and the encryption
method to encrypt (or encipher) a
message and sends it to Bob.
Bob uses the same key and the related
decryption method to decrypt (or
decipher) the message.
Figure 20.3 Symmetric-key cryptography
Note
Solution
The cipher is probably monoalphabetic because both
occurrences of L’s are encrypted as O’s.
Example 20.2
Solution
The cipher is not monoalphabetic because each
occurrence of L is encrypted by a different character.
The first L is encrypted as N; the second as Z.
How this Cipher Works
1.Pick a keyword (for our example, the keyword will be "MEC").
2.Write your keyword across the top of the text you want to encipher,
repeating it as many times as necessary.
3.For each letter, look at the letter of the keyword above it (if it was 'M',
then you would go to the row that starts with an 'M'), and find that row
in the Vigenere table.
4.Then find the column of your plaintext letter (for example, 'w', so the
twenty-third column).
5.Finally, trace down that column until you reach the row you found
before and write down the letter in the cell where they intersect (in this
case, you find an 'I' there).
Keyword:
MECMECMECMECMECMECMECM
Plaintext:
weneedmoresuppliesfast
Ciphertext:
IIPQIFYSTQWWBTNUIUREUF
Vigen�re Table
ROW
0 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 B C D E F G H I J K L M N O P Q R S T U V W X Y Z A
2 C D E F G H I J K L M N O P Q R S T U V W X Y Z A B
3 D E F G H I J K L M N O P Q R S T U V W X Y Z A B C
4 E F G H I J K L M N O P Q R S T U V W X Y Z A B C D
5 F G H I J K L M N O P Q R S T U V W X Y Z A B C D E
6 G H I J K L M N O P Q R S T U V W X Y Z A B C D E F
7 H I J K L M N O P Q R S T U V W X Y Z A B C D E F G
8 I J K L M N O P Q R S T U V W X Y Z A B C D E F G H
9 J K L M N O P Q R S T U V W X Y Z A B C D E F G H I
10 K L M N O P Q R S T U V W X Y Z A B C D E F G H I J
11 L M N O P Q R S T U V W X Y Z A B C D E F G H I J K
12 M N O P Q R S T U V W X Y Z A B C D E F G H I J K L
13 N O P Q R S T U V W X Y Z A B C D E F G H I J K L M
14 O P Q R S T U V W X Y Z A B C D E F G H I J K L M N
15 P Q R S T U V W X Y Z A B C D E F G H I J K L M N O
16 Q R S T U V W X Y Z A B C D E F G H I J K L M N O P
17 R S T U V W X Y Z A B C D E F G H I J K L M N O P Q
18 S T U V W X Y Z A B C D E F G H I J K L M N O P Q R
19 T U V W X Y Z A B C D E F G H I J K L M N O P Q R S
20 U V W X Y Z A B C D E F G H I J K L M N O P Q R S T
21 V W X Y Z A B C D E F G H I J K L M N O P Q R S T U
22 W X Y Z A B C D E F G H I J K L M N O P Q R S T U V
23 X Y Z A B C D E F G H I J K L M N O P Q R S T U V W
24 Y Z A B C D E F G H I J K L M N O P Q R S T U V W X
25 Z A B C D E F G H I J K L M N O P Q R S T U V W X Y
Note
Solution
We encrypt one character at a time. Each character is
shifted 15 characters down. Letter H is encrypted to W.
Letter E is encrypted to T. The first L is encrypted to A.
The second L is also encrypted to A. And O is encrypted to
D. The cipher text is WTAAD.
Example 20.4
Solution
We decrypt one character at a time. Each character is
shifted 15 characters up. Letter W is decrypted to H.
Letter T is decrypted to E. The first A is decrypted to L.
The second A is decrypted to L. And, finally, D is
decrypted to O. The plaintext is HELLO.
Note
Solution
We first remove the spaces in the message. We then divide
the text into blocks of four characters. We add a bogus
character Z at the end of the third block. The result is
HELL OMYD EARZ. We create a three-block ciphertext
ELHLMDOYAZER.
Example 20.6
Solution
The result is HELL OMYD EARZ. After removing the
bogus character and combining the characters, we get the
original message “HELLO MY DEAR.”
Figure 20.6 XOR cipher