0% found this document useful (0 votes)
9 views10 pages

DES and RSA Encryption Overview

Uploaded by

Kareem Dwidar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

DES and RSA Encryption Overview

Uploaded by

Kareem Dwidar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Team members:

1. Kareem Abdullraheem
2. Nour El-Deen Osama
3. Hassan Yasser

DES (Data Encryption Standard)


is a block cipher with a 56-bit key length that has played a significant role in
data security.

EXAMPLE: Given the plaintext "GAIN" and


the hypothetical 64-bit key:
10100011 10100011 10100011 10100011 10100011 10100011 10100011
10100011
perform DES encryption.

STEP1: Create 16 subkeys, each of which is 48­


bits long.
1. Discard every 8th-bit from the original key by Key
Permutation(PC-1) to be 56-bit:
Original key:
10100011 10100011 10100011 10100011 10100011 10100011
10100011 10100011
Discard 8th-bit:
1111111 1000000 0011111 1110000 1111111 1000000 0000000
0000000

2. split this key into left and right halves, C0 and D0


where each half has 28 bits:
C0:1111111 1000000 0011111 1110000
D0:1111111 1000000 0000000 0000000

3. Key Scheduling to Generate Subkeys:

C1:111111 1000000 0011111 11100001


D1:111111 1000000 0000000 00000001
C1D1:111111 1000000 0011111 11100001 111111 1000000
0000000 00000001

4. Make the keys 48-bit by applying PC-2 for each subkey:


K1:010011 110110 110100 110101 001000 100010 000110
000011
-- Continue until round 16 in 3&4 to get all the subkey,
to follow for the next steps
STEP2: Encryption.

1. Convert "GAIN"(ASCII) to Binary:


● G = 71 -> 01000111
● A = 65 -> 01000001
● I = 73 -> 01001001
● N = 78 -> 01001110
● Binary: 01000111 01000001 01001001 01001110

2. Initial Permutation (IP):

Plain text in 64-bit:01000111 01000001 01001001 01001110


00000000 00000000 00000000 00000000

-- The remaining 32-bit put them with zeros

After IP:00000000 00000000 00000000 00000000 00000000


00000000 01110010 01100010

3. divide the permuted block IP into a left half L0 of


32-bits, and a right half R0 of 32-bits.

L0:00000000 00000000 00000000 00000000

R0:00000000 00000000 01110010 01100010

4. Apply for 16 iterations:

Ln = Rn-1
Rn = Ln-1 XOR f(Rn-1,Kn)

For n=1, we have:

K1:010011 110110 110100 110101 001000 100010 000110


000011 (48-bit)

L1 = R0 = 00000000 00000000 01110010 01100010

R1 = L0 XOR f(R0 XOR K1)

– Expand the Right half (R) from 32 bits to 48 bits using


an expansion table.

R0 = 000000 000000 111001 011000 100010 110001 101001


011000

– Make XOR between E(R0) and K1.

R0 = 000000 000000 111001 011000 100010 110001 101001 011000

K1 = 010011 110110 110100 110101 001000 100010 000110 000011

XOR =010011 110110 001101 101101 101010 010011 101111 011011


S1 S2 S3 S4 S5 S6 S7 S8
- takes a 6­
-bit block from the XOR as input and yields a 4­bit
block as output by applying an S-box.(32-bit)
Let’s take the first block 010011 and assume we're using
S-box1 (S1):

● Row: Constructed from bits 1 and 6: 01 (binary for 1)


● Column: Constructed from bits 2 to 5: 1001 (binary for 9)
● Lookup: Let's assume S1 at row 1, column 9 gives us
(binary of 6) 1100.

S1(B1)S2(B2)S3(B3)S4(B4)S5(B5)S6(B6)S7(B7)S8(B8)= 1100 1011


0101 1001 1110 0011 0001 0110

- The final stage in the calculation of f is to do a


permutation P of the S­
box output to obtain the final
value

f = 10000101 01111010 11001011 01100011

- Getting R1:

L0=00000000 00000000 00000000 00000000

f =10000101 01111010 11001011 01100011

XOR=10000101 01111010 11001011 01100011


--After finishing these steps for 16 iteration

Finaly do final permutation for R16L16:

L16R16= 01010101 01010101 01010101 01010101 10011001 10011001


10011001 10011001

After final permutation= 11101001 10011010 10100101 01101001


01010101 10011001 01101001 10010101

Example:

You have reached the final stages of the DES encryption


process. Given are the outputs from Round 15 and the subkey
for Round 16.

Given:

• L_{15} : 10101010 10101010 10101010 10101010

• R_{15} : 01010101 01010101 01010101 01010101

• Subkey for Round 16 ( K_{16} ): 11001100 11001100


11001100 11001100 11001100 11001100

Tasks:

1. Calculate L_{16} and R_{16} for the final round


using the DES function f .
2. Apply the Final Permutation (IP^-1) to generate the
ciphertext. The Final Permutation table (IP^-1) is as follows:

Provide the calculated values of L_{16}, R_{16}, and the


final ciphertext in binary format.

Answer:

Step 1: Calculating L_{16} and R_{16}

• L_{16} : Since L_{16} is simply the value of


R_{15} from the previous round:

• L_{16} = 01010101 01010101 01010101 01010101

• R_{16} : Calculated using the DES function f ,


which involves expansion, XOR with K_{16} , substitution, and
permutation. The result of f is hypothetically:

• f(R_{15}, K_{16}) = 00110011 00110011 00110011


00110011

• Thus, R_{16} = L_{15} XOR f(R_{15}, K_{16}) =


10011001 10011001 10011001 10011001

Step 2: Applying the Final Permutation (IP^-1)

• Combine L_{16} and R_{16} to form the final


block before encryption:

• 01010101 01010101 01010101 01010101 10011001


10011001 10011001 10011001
• Apply the Final Permutation (IP^-1) to this 64-bit
block:

• Based on IP^-1, rearrange the bits to their final


positions to create the ciphertext:

• For example, if the bit arrangement based on IP^-1


gives:

• 01101001 10100101 01101001 10100101 01010101


10011001 01101001 10010101

Final Ciphertext:

• The final ciphertext after applying IP^-1 is:

• 01101001 10100101 01101001 10100101 01010101


10011001 01101001 10010101

RSA:
is a cryptographic system that uses mathematics to secure information
(Unicode،). It relies on two keys:

Public Key: Used by anyone to encrypt messages.

Private Key: Kept only by the recipient to decrypt the


messages.
Q Encrypt and Decrypt the
message m=43
Key Generation:
steps to generate an RSA key

1. choose two prime numbers p,q(3,7)


2. Compute n=p*q=3*7=21
3. Compute euler = (p-1)(q-1)=2*6=12
4. Choose (e) , 1 < e < euler , and must be comprime
with euler for example (7)
5. The key is (n,e)=(21,7)

Message Encryption
C=m^e mod n

C for cipher text


M for plain text

Message Decryption
m=C^d mod n
D=e^-1 mod euler

m=4
C=m^e mod n
C=4^7 mod 21= 16384 mod 21= 4

d=e^-1 mod euler


d=7^-1 mod 12=7

m=C^d mod n
m=4^7 mod 21=4
______________________________________________________

m=3
C=m^e mod n
C=3^7 mod 21= 2187 mod 21= 3

d=e^-1 mod euler


d=7^-1 mod 12=7

m=C^d mod n
m=3^7 mod 21=3

You might also like