Chapter-2 Part 2
Chapter-2 Part 2
Chapter-2 Part 2
Chapter 2-continued
11/17/2024 1
Cryptographic Algorithms
access it.
Triple DES
Digital Signature
Digital Certificate
calculation f
11/17/2024 8
2. DES…..
following illustration
11/17/2024 9
2. DES…..
1. Initial Permutation (IP)
11/17/2024 11
2. DES…..
Initial and Final Permutations
11/17/2024 12
2. DES…..
3. Round Function
The heart of this cipher is the DES function, f. The
DES function applies a 48-bit key to the rightmost
32 bits to produce a 32-bit output.
11/17/2024 13
DES…..
• DES is a block cipher--meaning it operates on plaintext blocks of a given size
(64-bits) and returns cipher text blocks of the same size.
• The steps are:
• Step 1: Create 16 sub keys, each of which is 48-bits long.
• Step 2: Encode each 64-bit block of data.
Step 1: Create 16 sub keys, each of
which is 48-bits long.
• Let K be the hexadecimal key K = 133457799BBCDFF1. This gives us as the
binary key (setting 1 = 0001, 3 = 0011, etc., and grouping together every
eight bits, of which the last one in each group will be unused):
• K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111
11110001
• Step1=>perform permutation on 64 bit k. (let say the permutation produced
is : 57 49 41 33 25 17 9 1 58 50 42 34 26 18 10 2 59 51 43 35 27 19 11 3 60
52 44 36 63 55 47 39 31 23 15 7 62 54 46 38 30 22 14 6 61 53 45 37 29 21 13
5 28 20 12 4)
• what does it means?
Cont …
• From the original 64-bit key
• K = 00010011 00110100 01010111 01111001 10011011 10111100 11011111
11110001
• we get the 56-bit permutation
• K+ = 1111000 0110011 0010101 0101111 0101010 1011001 1001111 0001111
• Next, split this key into left and right halves, C0 and D0, where each half has 28 bits.
• Example: From the permuted key K+, we get
• C0 = 1111000 0110011 0010101 0101111
D0 = 0101010 1011001 1001111 0001111
• With C0 and D0 defined, we now create sixteen blocks Cn and Dn, 1<=n<=16. Each pair
of blocks Cn and Dn is formed from the previous pair Cn-1 and Dn-1, respectively, for n =
1, 2, ..., 16
Cont. …
• C0 = 1111000011001100101010101111 D9 = 0011110001111010101010110011
• Shift schedule,
D0 = 0101010101100110011110001111
• C1 = 1110000110011001010101011111
• C10 = 0101010111111110000110011001
D1 = 1010101011001100111100011110
D10 = 1111000111101010101011001100
• C2 = 1100001100110010101010111111
• C11 = 0101011111111000011001100101
D2 = 0101010110011001111000111101
D11 = 1100011110101010101100110011
• C3 = 0000110011001010101011111111
• C12 = 0101111111100001100110010101
D3 = 0101011001100111100011110101
D12 = 0001111010101010110011001111
• C4 = 0011001100101010101111111100
• C13 = 0111111110000110011001010101
D4 = 0101100110011110001111010101
D13 = 0111101010101011001100111100
• C5 = 1100110010101010111111110000
• C14 = 1111111000011001100101010101
D5 = 0110011001111000111101010101
D14 = 1110101010101100110011110001
• C6 = 0011001010101011111111000011
• C15 = 1111100001100110010101010111
D6 = 1001100111100011110101010101
D15 = 1010101010110011001111000111
• C7 = 1100101010101111111100001100
• C16 = 1111000011001100101010101111
D7 = 0110011110001111010101010110
D16 = 0101010101100110011110001111
• C8 = 0010101010111111110000110011
D8 = 1001111000111101010101011001
• C9 = 0101010101111111100001100110
• We now form the keys Kn, for 1<=n<=16, by applying permutation to each of the
concatenated pairs CnDn. Each pair has 56 bits, but PC-2 only uses 48 of these.
• If we have (14 17 11 24 1 5 3 28 15 6 21 10 23 19 12 4 26 8 16 7 27 20 13 2 41 52 31 37
47 55 30 40 51 45 33 48 44 49 39 56 34 53 46 42 50 36 29 32) permutation table
• For the first key we have C1D1 = 1110000 1100110 0101010 1011111 1010101 0110011
0011110 0011110
• which, after we apply the permutation PC-2, becomes
• K1 = 000110 110000 001011 101111 111111 000111 000001 110010
• K2 = 011110 011010 111011 011001 110110 111100 100111 100101
K3 = 010101 011111 110010 001010 010000 101100 111110 011001
K4 = 011100 101010 110111 010110 110110 110011 010100 011101
K5 = 011111 001110 110000 000111 111010 110101 001110 101000
K6 = 011000 111010 010100 111110 010100 000111 101100 101111 .....
•Now we have our 16 keys.
•What's next?
Step 2: Encode each 64-bit block
of data.
• The first step should be to prepare your plain text into 64 bit length of block, than continue
with encoding
• Assume we have IP 58 50 42 34 26 18 10 2 60 52 44 36 28 20 12 4 62 54 46 38 30 22 14 6 64
56 48 40 32 24 16 8 57 49 41 33 25 17 9 1 59 51 43 35 27 19 11 3 61 53 45 37 29 21 13 5 63 55
47 39 31 23 15 7
• Applying the initial permutation to the block of text M.
• M = 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111
IP = 1100 1100 0000 0000 1100 1100 1111 1111 1111 0000 1010 1010 1111 0000 1010 1010
• Next divide the permuted block IP into a left half L0 of 32 bits, and a right half R0 of 32 bits.
• Example: From IP, we get L0 and R0
• L0 = 1100 1100 0000 0000 1100 1100 1111 1111
R0 = 1111 0000 1010 1010 1111 0000 1010 1010
Cont. …
• We now proceed through 16 iterations, for 1<=n<=16, using a function f
which operates on two blocks--a data block of 32 bits and a key Kn of 48 bits--
to produce a block of 32 bits. Let + denote XOR addition, (bit-by-bit addition
modulo 2). Then for n going from 1 to 16 we calculate
• Ln = Rn-1
Rn = Ln-1 + f(Rn-1,Kn)
• Example: For n = 1, we have
• K1 = 000110 110000 001011 101111 111111 000111 000001 110010
L1 = R0 = 1111 0000 1010 1010 1111 0000 1010 1010
R1 = L0 + f(R0,K1)
• how the function f works?
Cont. …
• To calculate f, we first expand each block Rn-1 from 32 bits to 48 bits. This is
done by using a selection table that repeats some of the bits in Rn-1 .
• We'll call the use of this selection table the function E.
• Thus E(Rn-1) has a 32 bit input block, and a 48 bit output block.
• Expansion Permutation Box − Since right input is 32-bit
and round key is a 48-bit, we first need to expand right input
to 48 bits. Permutation logic is graphically depicted in the
following illustration:
Cont. …
• Example: We calculate E(R0) from R0 as follows:
• R0 = 1111 0000 1010 1010 1111 0000 1010 1010
E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101
• Next in the f calculation, we XOR the output E(Rn-1) with the key Kn:
• Example: For K1 , E(R0), we have
• K1 = 000110 110000 001011 101111 111111 000111 000001 110010
E(R0) = 011110 100001 010101 010101 011110 100001 010101 010101
K1+E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111.
• We have not yet finished calculating the function f,
Function f …
• To this point we have expanded Rn-1 from 32 bits to 48 bits, using the selection table, and XORed
the result with the key Kn .
• We now have 48 bits, or eight groups of six bits.
• We now do something strange with each group of six bits: we use them as addresses in tables
called "S boxes".
• Each group of six bits will give us an address in a different S box.
• Located at that address will be a 4 bit number. This 4 bit number will replace the original 6 bits.
• The net result is that the eight groups of 6 bits are transformed into eight groups of 4 bits (the
4-bit outputs from the S boxes) for 32 bits total.
• Write the previous result, which is 48 bits, in the form:
• Kn + E(Rn-1) =B1B2B3B4B5B6B7B8, where each Bi is a group of six bits. We now calculate
• S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)
• where Si(Bi) referres to the output of the i-th S box.
S-box value calculation
• If S1 is the function defined in this table and B is a block of 6 bits,
then S1(B) is determined as follows:
• The first and last bits of B represent in base 2 a number in the
decimal range 0 to 3 (or binary 00 to 11). let that number be i.
• The middle 4 bits of B represent in base 2 a number in the decimal
range 0 to 15 (binary 0000 to 1111). Let that number be j.
• Look up in the table the number in the i-th row and j-th column. It
is a number in the range 0 to 15 and is uniquely represented by a 4
bit block. That block is the output S1(B) of S1 for the input B.
• For example, for input block B = 011011 the first bit is "0" and the
last bit "1" giving 01 as the row. This is row 1.
• The middle four bits are "1101". This is the binary equivalent of
decimal 13, so the column is column number 13.
• In row 1, column 13 appears 5. This determines the output; 5 is
binary 0101, so that the output is 0101. Hence S1(011011) = 0101.
Permutation on S-box
• Example: For the first round, we obtain as the output of the eight S boxes:
• K1 + E(R0) = 011000 010001 011110 111010 100001 100110 010100 100111.
• S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) = 0101 1100 1000 0010 1011 0101 1001 0111
• The final stage in the calculation of f is to do a permutation P of the S-box output to obtain the
final value of f:
• f = P(S1(B1)S2(B2)...S8(B8))
• Let The permutation P is(16 7 20 21 29 12 28 17 1 15 23 26 5 18 31 10 2 8 24 14 32 27 3 9 19 13
30 6 22 11 4 25)
• from the output of the eight S boxes:
• S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8) = 0101 1100 1000 0010 1011 0101 1001 0111 we
get
• f = 0010 0011 0100 1010 1010 1001 1011 1011
• Finally we have F function F
11/17/2024 40
4. Digital Signature…
A digital signature consists of three algorithms:
Key Generation Algorithm
Signing Algorithm
Signature Verifying Algorithm
11/17/2024 41
4. Digital Signature…
1. Key generation algorithm
2. Signing algorithm
11/17/2024 44
4. Digital Signature…
The steps which are followed in creating a
digital signature are:
Step 1. Select a file to be digitally signed.
Step 2. The hash value of the message or file
content is calculated. This message or file content
is encrypted by using a private key of a sender to
form the digital signature.
Step 3. Now, the original message or file content
along with the digital signature is transmitted.
11/17/2024 45
4. Digital Signature…
The steps which are followed in creating a
digital signature are:
Step 4. The receiver decrypts the digital signature
by using a public key of a sender.
Step 5. The receiver now has the message or file
content and can compute it.
Step 6. Comparing these computed message or
file content with the original computed message.
The comparison needs to be the same for ensuring
integrity.
11/17/2024 46
4. Digital Signature…
At the sender site
11/17/2024 47
4. Digital Signature…
At the Receiver site
11/17/2024 48
5. AES
The more popular and widely adopted symmetric
encryption algorithm likely to be encountered
nowadays is the Advanced Encryption Standard
(AES).
11/17/2024 50
5. AES…
The features of AES are as follows:
Symmetric key symmetric block cipher
128-bit data, 128/192/256-bit keys
Stronger and faster than Triple-DES
11/17/2024 51
5. AES…
Working of the cipher
11/17/2024 53
5. AES…
The schematic of AES structure is given in the
following illustration:
11/17/2024 54
5. AES…
Encryption :
| b1 | b5 | b9 | b13 |
| b2 | b6 | b10| b14 |
| b3 | b7 | b11| b15 ]
11/17/2024 55
5. AES…
Each round comprises of 4 steps :
SubBytes
ShiftRows
MixColumns
Add Round Key
11/17/2024 58
5. AES…
ShiftRows :
11/17/2024 59
5. AES…
MixColumns :
11/17/2024 62
5. AES…
Decryption :
11/17/2024 63
5. AES…
Inverse MixColumns :
11/17/2024 64
5. AES…
Inverse SubBytes :
11/17/2024 65
6. Diffie-Hellman Key Exchange
Diffie-Hellman algorithm is one of the most
important algorithms used for establishing a
shared secret.
11/17/2024 66
6. Diffie-Hellman Key Exchange…
Workign Principle
ka=kb
Example:
y=(82 mod33)=64mod33= 31
8.
11/17/2024 25 is the shared secret.
70
7. Secure Hash Algorithm(SHA-1)
SHA-1 or Secure Hash Algorithm 1 is a
cryptographic hash function which takes an input
and produces a 160-bit (20-byte) hash value.
11/17/2024 72
7. Secure Hash Algorithm(SHA-1) …
11/17/2024 73
Thank You
11/17/2024 74