Chapter-2-Part2
Chapter-2-Part2
Chapter 2-continued
12/14/2024 1
Cryptographic Algorithms
▪ In simple terms, they're processes that protect data by making sure that
12/14/2024 2
Cryptographic Algorithms…
▪ Most cryptography algorithms involve the use of encryption, which
allows two parties to communicate while preventing
unauthorized third parties from understanding those
communications.
▪ Operation of DES:
12/14/2024 11
1. DES …
▪ General Structure of DES
12/14/2024 12
1. DES ...
1. Initial Permutation (IP)
▪ The resultant 64-bit text is split into two equal halves of 32-bit each
called Left Plain Text (LPT) and Right Plain Text (RPT).
12/14/2024 13
1. DES …
2. Final Permtuation
12/14/2024 14
2. DES ...
▪ Initial and Final Permutations
12/14/2024 15
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.
12/14/2024 16
1. 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 3: Repeat 16 times
• Step 4: Perform inverse permutation
How DES works:
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
.....
How DES works:
Step 2: Encode each 64-bit block of data.
• Prepare the plain text into 64-bit length blocks; then continue with encoding
• Step2.1: perform initial permutation, IP on a block: e.g. use the following table:
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
• Step2.2: divide the permuted block IP into a left half L0 and a right half R0 of 32 bits each.
• 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
How DES works:
• Step2.3: 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 does the function f work?
How DES works:
• 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:
How DES works:
• 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,
How DES works:
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) refers to the output of the i-th S box.
How DES works: 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.
How DES works: 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 output of function F
• R1 = L0 + f(R0 , K1 )
= 1100 1100 0000 0000 1100 1100 1111 1111
+ 0010 0011 0100 1010 1010 1001 1011 1011
= 1110 1111 0100 1010 0110 0101 0100 0100
L1 = R0 = 1111 0000 1010 1010 1111 0000 1010 1010
R1 = 1110 1111 0100 1010 0110 0101 0100 0100
In the next round, we will have L2 = R1, which is the block we just calculated,
and then we must calculate R2 = L1 + f(R1, K2), and so on for 16 rounds.
At the end of the sixteenth round we have the blocks L16 and R16.
We then reverse the order of the two blocks into the 64-bit block
• R16L16
How DES works: Final Permutation
• apply a final permutation
• Let the permutation is defined by (40 8 48 16 56 24 64 32 39 7 47 15 55 23 63 31 38 6 46
14 54 22 62 30 37 5 45 13 53 21 61 29 36 4 44 12 52 20 60 28 35 3 43 11 51 19 59 27 34 2
42 10 50 18 58 26 33 1 41 9 49 17 57 25)
• Example: If we process all 16 blocks using the method defined previously, we get, on the
16th round,
• L16 = 0100 0011 0100 0010 0011 0010 0011 0100
R16 = 0000 1010 0100 1100 1101 1001 1001 0101
• We reverse the order of these two blocks and apply the final permutation to
R16L16 = 00001010 01001100 11011001 10010101 01000011 01000010 00110010 00110100
• Which gives:
IP-1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100 00000101
• which in hexadecimal format is 85E813540F0AB405.
• Thus, the encrypted form of M = 0123456789ABCDEF, with key K = 133457799BBCDFF1
is: C = 85E813540F0AB405.
How DES Works… summary
How secure is DES:
• Is it possible to crack DES?
• If yes, how much does it cost?
• 56-bit key means around 72 quadrillion keys
• DES was found out to be cracked by brute-force
• Dedicated system capable of brute-forcing DES keys in less than 5 days
was created in 1998
• Current machines (in parallel) – can do it in an hour
2. Toward triple DES
• Diffie and Hellman outlined a "brute force" attack on DES. (By "brute force" is
meant that you try as many of the 2^56 possible keys as you have to before
decrypting the ciphertext into a sensible plaintext message.) They proposed a
special purpose "parallel computer using one million chips to try one million
keys each" per second, and estimated the cost of such a machine at $20
million.
• Under the direction of John Gilmore of the EFF, a team spent $220,000 and
built a machine that can go through the entire 56-bit DES key space in an
average of 4.5 days. On July 17, 1998, they announced they had cracked a 56-
bit key in 56 hours. The computer, called Deep Crack, uses 27 boards each
containing 64 chips, and is capable of testing 90 billion keys a second.
2. Toward triple DES …
• Despite this, as recently as June 8, 1998, Robert Litt, principal associate
deputy attorney general at the Department of Justice, denied it was possible
for the FBI to crack DES: "Let me put the technical problem in context: It took
14,000 Pentium computers working for four months to decrypt a single
message . . . . We are not just talking FBI and NSA [needing massive
computing power], we are talking about every police department."
• Responded cryptograpy expert Bruce Schneier: " . . . the FBI is either
incompetent or lying, or both." Schneier went on to say: "The only solution
here is to pick an algorithm with a longer key; there isn't enough silicon in
the galaxy or enough time before the sun burns out to brute- force triple-
DES" (Crypto-Gram, Counterpane Systems, August 15, 1998).
• And in 1999 distributed.net and electronic frontier foundation collaborated
to break DES key in 22 hours and 15 minutes(the machine costs around
$250,000).
2. Triple DES
▪ Triple Data Encryption Standard (TDES) is upgraded or improved
version of DES which is a symmetric cryptographic approach in which
DES is used to each block three times which scrambles the plain text to
cipher text.
▪ Triple DES runs three times gradual than DES, but is much safer if
used properly.
▪ The procedure for decrypting object is the similar as the procedure for
encryption, other than it is executed in reverse. Like DES, data is
encrypted and decrypted in 64- bit chunks
12/14/2024 Computer and Network Security 37 By: Mechal T.
2. Triple DES …
2. Triple DES …
Next:
Advanced Encryption Standard(AES)
AES
12/14/2024 41
AES…
▪ The features of AES are as follows:
▪ Symmetric key symmetric block cipher
▪ 128-bit data, 128/192/256-bit keys
12/14/2024 42
AES…
▪ The features of AES are as follows:
▪ Symmetric key symmetric block cipher
▪ 128-bit data, 128/192/256-bit keys
12/14/2024 43
AES…
▪ Working of the cipher
▪ AES performs operations on bytes of data rather than in bits. Since the
block size is 128 bits, the cipher processes 128 bits (or 16 bytes) of the
input data at a time.
12/14/2024 44
AES Encryption Process
Stage 3
Stage 2
Stage 1
AES Structure
AES…
▪ Creation of Round keys :
▪ A Key Schedule algorithm is used to calculate all the round keys from
the key.
▪ So the initial key is used to create many different round keys which will
be used in the corresponding round of the encryption.
▪ But before that, let’s see how the 4 steps of each round are performed
12/14/2024 47
AES…
▪ Encryption :
b0 b4 b8 b12
b1 b5 b9 b13
b2 b6 b10 b14
b3 b7 b11 b15
12/14/2024 48
AES…
▪ Each round comprises of 4 steps :
▪ SubBytes
▪ ShiftRows
▪ MixColumns
12/14/2024 49
AES…
12/14/2024 51
AES…
▪ ShiftRows :
b0 b4 b8 b12 b0 b4 b8 b12
b1 b5 b9 b13 b5 b9 b13 b1
12/14/2024 52
AES…
▪ MixColumns :
▪ This step is basically a matrix
multiplication. Each column is
multiplied with a specific matrix and
thus the position of each byte in the
column is changed as a result.
▪ This step is skipped in the last round.
12/14/2024 53
AES…
▪ Add Round Keys :
▪ Now the resultant output of the previous stage is XOR-ed with the corresponding
round key.
▪ Here, the 16 bytes is not considered as a grid but just as 128 bits of data.
▪ After all these rounds 128 bits of encrypted data is given back as output.
▪ This process is repeated until all the data to be encrypted undergoes this process.
12/14/2024 54
AES Round
AES Key Expansion
Round constants:
(Rcon[i] = xi-1)
i Rcon[i]
1 01 00 00 00
2 02 00 00 00
3 04 00 00 00
4 08 00 00 00
5 10 00 00 00
6 20 00 00 00
7 40 00 00 00
8 80 00 00 00
9 1B 00 00 00
10 36 00 00 00
Digital Signatures
Digital Signature
▪ A digital signature is a mathematical technique which validates the
authenticity and integrity of a message, software or digital documents.
▪ It allows us to verify the author name, date and time of signatures, and
authenticate/signify agreement/ the message contents.
▪ The digital signature offers far more inherent security and intended to
solve the problem of tampering and impersonation (Intentionally copy
another person's characteristics) in digital communications.
• Signing data by
encryption – too
much overhead
Message authentication
Symmetric keys Symmetric encryption
codes (MAC)
Asymmetric encryption
Asymmetric keys (a.k.a. public-key Digital signatures
encryption)
64
Digital Signature…
12/14/2024 65
Digital Signature…
12/14/2024 66
Digital Signature…
1. Key generation algorithm
▪ The key generation algorithm selects private key randomly from a set of possible
private keys.
▪ This algorithm provides the private key and its corresponding public key.
2. Signing algorithm
12/14/2024 67
Digital Signature…
▪ Digital signatures are created and verified by using public key cryptography, also
known as asymmetric cryptography.
▪ By the use of a public key algorithm, such as RSA, one can generate two keys that are
mathematically linked- one is a private key, and another is a public key.
▪ The user who is creating the digital signature uses their own private key to encrypt the
signature-related document.
▪ There is only one way to decrypt that document: with the use of signer's public key.
12/14/2024 68
Digital Signature…
▪ How digital signatures work
▪ This technology requires all the parties to trust that the individual who
creates the signature has been able to keep their private key secret.
▪ If someone has access the signer's private key, there is a possibility that
they could create fraudulent signatures in the name of the private key
holder.
12/14/2024 69
Digital Signature…
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.
12/14/2024 70
Digital Signature…
▪ The steps . . .
12/14/2024 71
Diffie-Hellman Key Exchange
▪ At the time of exchanging data over a public network, we can use the
shared secret for secret communication.
▪ We use an elliptic curve for generating points and getting a secret key
using the parameters.
12/14/2024 72
Public Key Cryptography
Public Key Cryptography
• Diffie and Hellman [1976] – proposed public key and private key cryptography
• Used in message authentication and key distribution
• Classical cryptography requires the sender and recipient to share a common key.
Public key cryptography does not.
• If the encipherment key is public, to send a secret message simply encipher the
message with the recipient’s public key. Then send it.
• The recipient can decipher it using his private key
• A public key cryptosystem must meet the following three conditions:
• It must be computationally:
• easy to encipher or decipher a message given the appropriate key.
• infeasible to derive the private key from the public key.
• infeasible to determine the private key from a chosen plaintext attack.
• E.g. The Riv.Sham.Adle. cipher, which provides both secrecy and authentication.
Diffie-Hellman Key Exchange…
▪ Working Principle
2. The variables P and G both are publicly available. The sender selects a
private value, either a or b, for generating a key to exchange publicly.
The receiver receives the key, and that generates a secret key, after which
the sender and receiver both have the same secret key to encrypt.
12/14/2024 75
Diffie-Hellman Key Exchange…
▪ Steps..
Steps User1 User2
1. P, G => available public keys. P, G => available public keys.
2. a is selected as a private key. b is selected as a private key.
3. Eq. to generate key: x=Ga mod P Eq. to generate key: y=Gb mod P
4. After exchanging keys, user1 receives After exchanging keys, user2 receives
key y. key x.
5. User1 generates a secret key by using User2 generates a secret key by using
the received key y: ka=ya mod P the received key x: kb=xb mod P
12/14/2024 76
Diffie-Hellman Key Exchange…
▪ Algebraically, 5th step can be shown as follows:
▪ ka=kb
▪ It means that both the users have the symmetric secret key to encrypt.
▪ Example:
1. User1 and User2 get public keys P = 33 and G = 8.
2. User1 selects a as a private key, i.e., 3, and User2 selects b as a
private key, i.e., 2.
3. User1 calculate the public value: x=(83 mod 33)=512mod33=17
12/14/2024 77
Diffie-Hellman Key Exchange…
4. User2 calculate the public value:
y=(82 mod33)=64mod33= 31
6. User1 receives public key y = 31 and User2 receives public key x = 17.
7. User1 and User2 calculate symmetric keys:
12/14/2024 78
Hash Functions
▪ Major tech giants browsers like Microsoft, Google, Apple and Mozilla
have stopped accepting SHA-1 SSL certificates by 2017.
12/14/2024 82
Secure Hash Algorithm(SHA-1) …
▪ Because of the successful attacks on MD5, SHA-0 and theoretical
attacks on SHA-1, NIST perceived a need for an alternative,
dissimilar cryptographic hash, which became SHA-3.
12/14/2024 83
Summary
➢ have considered:
⚫ the AES selection process
⚫ the details of Rijndael – the AES cipher
⚫ implementation aspects
➢ Asymmetric Encryption
• Digital signature
• Hash Function
Please read about RSA and DSA digital
signature algorithm
12/14/2024 85