2. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Symmetric Cryptography
Symmetric encryption principles, Cryptography, Cryptanalysis, types of attacks on encryption messages,
Feistel’s Cipher structure, block ciphers, Overview of DES, 3DES, AES, algorithms. Stream cipher structure,
RC4 algorithm, Cipher block modes of operation, location of encryption devices, key distribution, Message
Authentication, MAC, Secure hash and HMAC, SHA-1, MD5, applications of symmetric cryptography and
hash functions.
TOPICS TO BE COVERED
2
3. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Symmetric Cryptography
Symmetric cryptography, known also as secret key cryptography,
is the use of a single shared secret to share encrypted
data between parties. Ciphers in this category are called
symmetric because you use the same key to encrypt and to
decrypt the data. In simple terms, the sender encrypts data using
a password, and the recipient must know that password to access
the data.
SYMMETRIC CRYPTOGRAPHY
3
5. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Symmetric Cryptosystem
Scenario
Alice wants to send a message (plaintext P) to Bob.
The communication channel is insecure and can be eavesdropped
If Alice and Bob have previously agreed on a symmetric encryption scheme and a secret key K, the message can be
sent encrypted (ciphertext C)
SYMMETRIC CRYPTOGRAPHY
5
C P
P encrypt
K
decrypt
K
6. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Basics
✓ Notation
Secret key K
Encryption function EK(P)
Decryption function DK(C)
Plaintext length typically the same as ciphertext length, sometimes may be CT size will be more than
PT.
Encryption and decryption are one-one mapping functions on the set of all n-bit arrays
✓ Efficiency
functions EK and DK should have efficient algorithms
✓ Consistency
Decrypting the ciphertext yields the plaintext
DK(EK(P)) = P
SYMMETRIC CRYPTOGRAPHY
6
7. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Symmetric Encryption is also known as Conventional Encryption or private-key encryption or single-key
encryption.
Plain Text: Actual message that is sent through transmission line is called plain text.
For example: ABC Company is in profit, purchase shares.
Cipher Text: Cipher text is the text which is converted plain text. Plain text converted into random nonsense or non
understandable form by using some algorithm and key is called as Cipher Text.
For the above plain text cipher text by using adding three characters to each char is
ABC Company is in profit, purchase shares.
+3 for each character.
DEF Frpsdqb lv lq surilw sxufkdvh vkduhv
SYMMETRIC ENCRYPTION & PRINCIPLES
7
8. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Encryption:
Encryption algorithm is an algorithm which converts Plain Text to Cipher Text by using a Key. The key is any
value that is not known to Opponents and it is independent of Plain Text.
For example:
(a) Assign numbers for each alphabet (1 for A, 2 for B........ 26 for Z)
(b) Repeat steps e to f for each character in the plain text message.
(c) Obtain number for character in Plain text (for example 3 for C)
(d) Add 3 to it and find the corresponding new character. If it exceeds 26 again start from 1.
(e) Concatenate new character to Cipher Text (F is cipher text for C)
(f) Go for next character
(g) Print Cipher Text
(h) stop
SYMMETRIC ENCRYPTION & PRINCIPLES
8
9. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Decryption:
Decryption is a process that converts Cipher Text to Plain Text by using the key used for encryption process
(symmetric key model).
For example:
(a) Assign numbers for each alphabet (1 for A, 2 for B......., 26 for Z)
(b) Repeat steps c to f for each character in cipher text message.
(c) Obtain number for character in Cipher text( for example 6 for F)
(d) Subtract 3 from it and find corresponding new character. If it less than 0 start from 26
(e) Concatenate new character to Plain Text (C is Plain Text for F)
(f) Go for next character
(g) Print Plain Text
(h) Stop
SYMMETRIC ENCRYPTION & PRINCIPLES
9
11. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Basic Terminologies:
✓ Encryption Notation: A’ = Ek(A)
✓ Decryption Notation: A = DK(A’)
✓ Cryptography: Techniques or algorithms that are used to transforming plaint to cipher text and cipher text to
plain text are called as cryptographic techniques and of these techniques are known as cryptography or the
science and art of develop cryptosystems is known as Cryptography.
✓ Cryptographer: The person who deals with cryptography is known Cryptographer. Figure shows the role of
cryptographers.
SYMMETRIC ENCRYPTION & PRINCIPLES
11
12. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Basic Terminologies:
✓ Cryptanalysis: Studying the cipher text to obtain plain text or key without know actual key or algorithm used is
called as Cryptanalysis. The science and art of evaluating the strength of cryptosystems is also known as
Cryptanalysis.
Some of the possibilities:
▪ Breaking a single message
▪ Recognizing patterns in encrypted messages in order to break subsequent messages
▪ Finding general weaknesses in encryption algorithms
✓ Cryptanalyst: The person who deals with cryptanalysis.
✓ Cryptology: Studies of Cryptography & Cryptanalysis.
SYMMETRIC ENCRYPTION & PRINCIPLES
12
13. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Cryptanalysis: Identifying plain text or key from cipher text.
There are several types of attacks that can attack on encrypted message to obtain plain text or cipher text. Some of
them are:
a. Cipher Text Only: In this type of attack, only some cipher-text is known and the attacker tries to find the corresponding
encryption key and plaintext. Its the hardest to implement but is the most probable attack as only ciphertext is required.
b. Known Plain Text: In this type of attack, some plaintext-ciphertext pairs are already known. Attacker maps them in
order to find the encryption key. This attack is easier to use as a lot of information is already available.
c. Chosen Plain Text: In this type of attack, the attacker chooses random plaintexts and obtains the corresponding
ciphertexts and tries to find the encryption key. Its very simple to implement like KPA but the success rate is quite low.
d. Chosen Cipher Text: This is opposite to Chosen Plain Text Attack. Here opponent obtained temporary access to
decryption machinery. So he can choose cipher text string & can construct corresponding plain text string.
SYMMETRIC ENCRYPTION
13
14. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
SYMMETRIC ENCRYPTION
14
Hi, Bob.
Don’t
invite
Eve to
the
party!
Love,
Alice
Encryption
Algorithm
Plaintext Ciphertext
key
Eve
Hi, Bob.
Don’t
invite
Eve to
the
party!
Love,
Alice
Plaintext Ciphertext
key
ABCDEF
G
HIJKLM
NO
PQRST
UV
WXYZ.
Plaintext Ciphertext
key
IJCGA,
CAN
DO
HIFFA
GOT
TIME.
Plaintext Ciphertext
key
Eve
001101
110111
(a)
(b)
(c)
(d)
Eve
Eve
Eve
Encryption
Algorithm
Encryption
Algorithm
Encryption
Algorithm
16. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Requirements of Conventional Encryption:
1. The opponent should be unable to decrypt cipher text or discover the key even if he is in possession of a number
of cipher text words together with the plaintext that produced each cipher text.
2. Sender or receiver must have obtained copies of the secret key in a secure fashion and must keep the key secure.
It is important to note that the security of conventional encryption depends on the secrecy of the key, not the
secrecy of the algorithm and the algorithm, is supposed to be public.
Cipher Security: There are two different ways in which ciphers may be secure.
▪ Unconditionally Security: What ever the computer power, one can't break the cipher.
▪ Computationally Security: With in stipulated time you can't decrypt the message.
SYMMETRIC ENCRYPTION
16
17. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Requirements for Classification of Cryptographic Systems
As from the definition of cryptography, cryptographic systems classification depends on
1. Which kind of operations used to change from plain text to cipher text?
2. How many number of keys used?
3. How the plain text is transformed to cipher text?
SYMMETRIC ENCRYPTION
17
18. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Block Cipher Versus Stream Cipher
SYMMETRIC ENCRYPTION
18
S.NO Block Cipher Stream Cipher
1.
Block Cipher Converts the plain text into cipher
text by taking plain text’s block at a time.
Stream Cipher Converts the plain text into cipher
text by taking 1 byte of plain text at a time.
2.
Block cipher uses either 64 bits or more than 64
bits.
While stream cipher uses 8 bits.
3. The complexity of block cipher is simple. While stream cipher is more complex.
4. Block cipher Uses confusion as well as diffusion. While stream cipher uses only confusion.
5. In block cipher, reverse encrypted text is hard.
While in-stream cipher, reverse encrypted text is
easy.
6.
The algorithm modes which are used in block
cipher are ECB (Electronic Code Book) and
CBC (Cipher Block Chaining).
The algorithm modes which are used in stream
cipher are CFB (Cipher Feedback) and OFB
(Output Feedback).
8.
Block cipher is slow as compared to a stream
cipher.
While stream cipher is fast in comparison to block
cipher.
19. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Block Cipher Versus Stream Cipher Structures
SYMMETRIC ENCRYPTION
19
EN CR YP TI ON MO DE
Example for processing ENCRYPTION MODE as block cipher
S A N T O S H
Example for processing SANTOSH as stream cipher
20. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 20
Cipher Modes of Operation:
Cipher Modes
Electronic
Code Book
(ECB)
Stream
Transmission
Block
Transmission
Cipher Block
Chaining
(CBC)
Output Feed
Back
(OFB)
Cipher Feed
Back
(CFB)
CIPHER BLOCK MODES OF OPERATION
21. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
Electronic Code Book(ECB)
CIPHER BLOCK MODES OF OPERATION
21
SIZE OF BLOCK = 64 bits, Size of plain text = size of cipher text, Suitable for short messages
PLAIN TEXT - 1
ENCRYPTION
CIPHER TEXT - 1
DECRYPTION
PLAIN TEXT - 1
KEY
KEY
PLAIN TEXT - N
ENCRYPTION
CIPHER TEXT - N
DECRYPTION
PLAIN TEXT - N
KEY
KEY
- - - - - - - - - - - -
22. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
CIPHER BLOCK MODES OF OPERATION
22
PLAIN TEXT - 1
ENCRYPTION
CIPHER TEXT - 1
DECRYPTION
PLAIN TEXT
KEY
KEY
- - - - - - - - - - - -
+
IV
+
IV
PLAIN TEXT - 1
ENCRYPTION
CIPHER TEXT - 1
PLAIN TEXT
KEY
KEY
+
+
CIPHER TEXT - 1
PLAIN TEXT - 1
ENCRYPTION
CIPHER TEXT - 1
PLAIN TEXT
KEY
KEY
+
+
CN-1
DECRYPTION DECRYPTION
CIPHER TEXT - 1
Cipher
Block
Chaining
(CBC)
CN-1
23. CIPHER BLOCK MODES OF OPERATION
Cipher Feed Back mode (CFB)
ENCRYPTION
Top Register
Shift Left
(n bits)
(n bits) Plain Text = s bits
(n bits)
KEY
Cipher Text
Select s bits MSB
+
Plain
Text
(s bits) 1 < s < n
Cipher Text
Feedback
ENCRYPTION
Cipher Text
Select s bits MSB
Shift Left
(n bits)
KEY
(n bits)
(s bits)
+ Plain Text
ENCRYPTION
DECRYPTION
P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 23
24. CIPHER BLOCK MODES OF OPERATION
Output Feed Back mode (OFB)
ENCRYPTION
Top Register
Shift Left
(n bits)
(n bits) Plain Text = s bits
(n bits)
KEY
Cipher Text
Select s bits MSB
+
Plain
Text
(s bits) 1 < s < n
Cipher Text
Feedback
ENCRYPTION
Cipher Text
Select s bits MSB
Shift Left
(n bits)
KEY
(n bits)
(s bits)
+ Plain Text
ENCRYPTION
DECRYPTION
P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 24
25. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
FEISTEL’S CIPHER STRUCTURE
25
Feistel’s Cipher structure Introduction
✓ Feistel proposed scheme to a produced a block cipher using permutation and
substitution alternatively.
✓ The inputs to the encryption algorithm are a plaintext block of length 2w bits and a
key Ki. The plaintext block is divided into two halves, LE0 and RE0.
✓ The two halves of the data pass through rounds of processing and then combine to
produce the ciphertext block.
27. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
DES
27
Data Encryption Standard is a symmetric-key algorithm for the encrypting
the data. It comes under block cipher algorithm which follows Feistel
structure. Here is the block diagram of Data Encryption Standard.
✓ Block Cipher Algorithm
✓ Converts Plain Text to Cipher Text
▪ Has total 16 rounds
▪ Text Size = 64 bits
▪ Key Size = 48 bits
✓ In each round, 4 steps are performed:
▪ Expansion/Permutation
▪ XOR-1
▪ Non linear substitutions (S-Box)
▪ Permutation
▪ XOR-2
29. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
DOUBLE DES
29
In this approach, we use two instances of DES ciphers for
encryption and two instances of reverse ciphers for decryption.
Each instances use a different key.
The size of the key is doubled.
There are issues of reduction to single stage.
However, double DES is vulnerable to meet-in-the-middle attack.
Given a plaintext P and two encryption keys K₁ and K₂, a cipher
text can be generated as,
C = E(K₂, E(K₁, P))
Decryption requires that the keys be applied in reverse order,
P = D(K₁, D(K₂, C))
30. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
TRIPLE DES WITH 2 KEY
30
✓ Use three stages of DES for encryption and decryption.
✓ The 1st , 3rd stage use K1 key and 2nd stage use K2 key.
✓ To make triple DES compatible with single DES, the middle stage
uses decryption in the encryption side and encryption in the
decryption side.
✓ It's much stronger than double DES.
✓ The function follows an encrypt-decrypt-encrypt (EDE) sequence.
C = E(K₁, D(K₂, E(K₁, P)))
P = D(K₁, E(K₂, D(K₁, C)))
✓ By the use of triple DES with 2-key encryption, it raises the cost of
meet in-the-middle attack to 2112.
✓ It has the drawback of requiring a key length of 56 × 3 = 168bits
which may be somewhat unwieldy.
31. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
TRIPLE DES WITH 3 KEY
31
✓ Although the attacks just described appear
impractical, anyone using two key 3DES may feel
some concern.
✓ Thus, many researches now feel that 3-key 3DES is
the preferred alternative.
✓ Use three stages of DES for encryption and
decryption with three different keys.
✓ 3-key 3DES has an effective key length of 168 bits and
is defined as,
C = E(K3, D(K₂, E(K₁, P)))
P = D(K₁, E(K₂, D(K3, C)))
32. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
AES
32
✓What is AES?
✓Features of AES
✓How does AES work?
✓Applications of AES
47. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
RC4
47
✓ RC4
✓ Stream Cipher Algorithm
Procedure:
1. Uses and array(s) – state vector of length 256 (0-255)
2. It has a key encoded with ASCII.
3. It has a key array of length 256 (0-255)
RC4 Algorithm has 3 steps:
1. Key Scheduling
2. Key Stream Generation
3. Encryption & Decryption
48. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
RC4
48
1. Key Scheduling
No. of Iterations = size of s-array
Algorithm:
j=0
for i=0 to 255 do
j=[j+S(i)+T(j)]mod 256
swap(S[i],S[j]);
S[i] = state vector
T[i] = key array(temporary vector)
2. Stream Geneation
No. of Iterations = size of key
Algorithm:
i,j=0
while(true)
i=[i+1]mod 256;
j=[j+S[i]]mod 256;
swap(S[i],S[j]);
T=(S[i],S[j])mod256;
K=S[T]
3. Encryption & Decryption
Encryption:
Plain Text XOR New Key
(First Convert into binary)
Decryption:
Cipher Text XOR New Key
49. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
KEY DISTRIBUTION IN SYMMETRIC CRYPTOGRAPHY
49
Key Distribution is done in 4 ways:
1. Physical Delivery (most secured)
2. Key Distribution Centre(KDC)
3. Using Previous keys
4. Using Third Party
50. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MESSAGE AUTHENTICATION
50
Authentication: Verifying the identity of the user(user id correct person or not)
How it is done?
✓ By Authenticator
✓ Authenticator is generated by Authentication Functions.
✓ Authentication Functions:
1. Message Encryption
2. Message Authentication Code (MAC)
3. Hash Functions(H)
51. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
51
MD-5 (Message Digest-5)
✓ Developed by Rivest
✓ One way cryptographic function
✓ Initially designed for digital signatures
✓ Fast and produces 128-bit message digests
Working of MD-5:
1. Padding
2. Appending
3. Dividing
4. Initialising
5. Processing
52. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
52
1. Padding
Original Message + Extra bits (Padding)
(so that total length is 64 bit less than exact multiple of 512)
Example:
Original Message = 1000 bits
512 * 1 = 512 bits (512-64 < 1000)
512 * 2 = 1024 bits (1024-64 < 1000)
512 * 3 = 1536 bits (1536-64 = 1472 > 1000)
Then add 472 bits (1000 + 472 = 1472 bits)
53. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
53
2. Appending
✓ Append the original length before padding
✓ Calculate length mod 64 (1000 mod 64)
✓ In most of the cases, 64 bits is obtained as the answer (Therefore append 64 bits)
✓ So, it becomes multiple of 512 again
54. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
54
3. Dividing (each 512 bits)
Output obtained
in Step-2
512 Bit Block-1 512 Bit Block-2 512 Bit Block-n
- - - - - - - - - - - - - - -
Example:
If it is 1024 bits, the number of subblocks will be 2.
If it is 1536 bits, the number of subblocks will be 3.
55. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
55
4. Initializing
✓ Initialize the variables (4 chaining variables)
✓ Each variable is of size 32 bits.
✓ A, B, C, D – values are preferred
✓ These chaining variables will have pre-
defined values
56. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MD5 (MESSAGE DIGEST-5)
56
5. Processing
✓ Copy 4 Chaining variables into corresponding
variables
✓ A=a, B=b, C=c, D=d
✓ Divide 512 bit blocks into 16- 32bit blocks (32 bit
each)
✓ Four rounds
✓ 16 sub blocks and constant k
16 subblocks Constant (k)
One round
a b c d
Formulae to calculate the values of 4 variables:
1. a=b + (a + p(b, c, d)+m[i] + T[k])
2. b=a + (b + p(a,c,d) + m[i] + T[k])
3. c=d + (c + p(a,b,d) + m[i] + T[k])
4. d=c + (d + p(a,b,c) + m[i] + T[k])
58. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
SHA (SECURE HASH)
58
SECURE HASH(SHA):
✓ Modified version of MD5
✓ In MD5, length of output = 128 bits
✓ In SHA, length of output = 160 bits
Working:
1. Padding
2. Appending
3. Dividing
4. Initializing
5. Processing
First 3 steps are same as MD5
59. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 59
4. Initializing
✓ Initialize the variables (5 chaining variables)
✓ Each variable is of size 32 bits.
✓ A, B, C, D, E – values are preferred
✓ These chaining variables will have pre-defined values
SHA (SECURE HASH)
60. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 60
5. Processing
✓ Copy 4 Chaining variables into corresponding
variables
✓ A=a, B=b, C=c, D=d, E=e
✓ Divide 512 bit blocks into 16- 32bit blocks (32 bit
each)
✓ Four rounds
✓ 16 sub blocks and constant k
SHA (SECURE HASH)
Formulae to calculate the values of 4 variables:
1. a = b + (a + p(b, c, d, e)+m[i] + T[k])
2. b = a + (b + p(a ,c ,d , e) + m[i] + T[k])
3. c = d + (c + p(a ,b ,d ,e) + m[i] + T[k])
4. d = c + (d + p(a ,b , c, e) + m[i] + T[k])
5. e =
61. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 61
SHA -1
SHA-1
It is a 160 bit or a 20-byte long hash-based
function-based encryption mechanism that is
used to resemble the year-old MD5 algorithm.
The particular algorithm was designed and
developed by the NSA, i.e. the National
Security Agency and was supposed to be part
of the critical component- Digital Signature
Algorithm (DSA). The weaknesses related to
the cryptographic techniques were found in
SHA-1; the encryption standard was later on
discarded and was not much put to use.
SHA OR SHA-0
It is a retronym that is applied to the basic
version of the year-old 160 bit or 20-byte long
hash function, which was published back in
1993 with the name of the SHA algorithm. It
was withdrawn very shortly after it was
published due to a major flaw, and therefore
SHA-1 came into the picture.
63. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
MAC (MESSAGE AUTHENTICATION CODE)
63
MAC (MESSAGE AUTHENTICATION CODE)
✓ Similar to Message Digest
✓ Symmetric key cryptography is used
Working:
If a sender wants to send a message “M”
M
H1(MAC CODE) Cipher Text
(M+K=H1)
Symmetric Key(k)
M
H1
+
(Plain Text)
(Cipher Text)
Sent to Receiver
Calculate hi/her own
MAC Code by using the same
Symmetric key “k”
Now,
On Receivers side, H1 and h2 are compared.
H1 = H2 =>No change in message
H1 ≠ H2 => Change in Message
64. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE 64
HMAC (HASH BASED MAC)
HMAC:
✓ Used in SSL
Working:
Original Message(M) Message Digest is generated
MD5/SHA
Key(k)- same for sender and receiver
Encryption
MAC (Cipher Text)
66. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
APPLICATIONS OF SYMMETRIC CRYPTOGRAPHY
66
✓Exchanging Secret Information
✓Validating Information
✓Hashing
✓Random Number Generation
67. P.RAMA SANTOSH NAIDU, MVGR(A)-CSE
APPLICATIONS OF HASH FUNCTIONS
67
Applications of Hash Functions
1. Password storage
2. Data Integrity check
3. Digital Signature