Triple Des
Triple Des
1. INTRODUCTION…………………………………….3-4
2. METHODOLOY…………………………………………5- 8
3. WORKING PRINCIPLE …….………………………...9
4. BLOCK DIAGRAM ………………………………...10
5. CODES………………………………………………….11-21
6. CONCLUSION …………………………………………21
7. REFERENCES…………………………………………22
2
INTRODUCTION
3
attacks involve some modification of the data stream or the creation of a
false stream and can be subdivided into four categories:
1.Masquerade,
2.Replay, modification of messages,
3.and Denial of service:
1.Masquerade of one entity as some other
2.Replay previous messages.
3.Modify/Alter messages in transit to produce an unauthorized effect.
4.Denial of service - prevents or inhibits the normal use or management
of communications facilities
4
Methodology
5
The encryption
process is made of two permutations (P-boxes), which we call
initial and final permutations,
and sixteen Feistel rounds. Each round uses a different 48-
bit round key generated
from the cipher key according to a predefined algorithm
the initial and final permutations are straight P-boxes that
are inverses of each other.
They have no cryptography significance in DES.
The round takes LI−1 and RI−1 from previous round (or the
initial permutation box)
and creates LI and RI, which go to the next round (or final
permutation box). As we discussed
in Chapter 5, we can assume that each round has two cipher
elements (mixer and
swapper). Each of these elements is invertible. The swapper
is obviously invertible. It
swaps the left half of the text with the right half. The mixer is
invertible because of the
XOR operation. All noninvertible elements are collected
inside the function f (RI−1, KI).
6
The heart of DES is the DES function. The DES function
applies a 48-bit key to the
rightmost 32 bits (RI−1) to produce a 32-bit output. This
function is made up of four sections:
an expansion P-box, a whitener (that adds key), a group of S-
boxes, and a straight
P-box
the major criticism of DES regards its key length. With
available
technology and the possibility of parallel processing, a brute-
force attack on DES is
feasible. One solution to improve the security of DES is to
abandon DES and design a
new cipher.
The second solution is to use multiple (cascaded) instances
of DES with multiple keys; this solution,
which has been used for a while, does not require an
investment in new software
and hardware. We study the second solution here.
a substitution that maps every possible input to
7
every possible output is a group, with the mappings as the
set elements and the composition
as the operator. In this case, using two consecutive
mappings is useless
because we can always find the third mapping that is
equivalent to the composition of
the two (closure property). This means that if DES is a group,
using double DES with
two keys k1 and k2 is useless because a single DES with key
k3 does the same thing
8
Working Principle
Triple DES
9
BLOCK DIAGRAM
10
CODES
11
"0011": '3',
"0100": '4',
"0101": '5',
"0110": '6',
"0111": '7',
"1000": '8',
"1001": '9',
"1010": 'A',
"1011": 'B',
"1100": 'C',
"1101": 'D',
"1110": 'E',
"1111": 'F'}
hex = ""
for i in range(0, len(s), 4):
ch = ""
ch = ch + s[i]
ch = ch + s[i + 1]
ch = ch + s[i + 2]
ch = ch + s[i + 3]
hex = hex + mp[ch]
return hex
# S-box Table
sbox = [[[14, 4, 13, 1, 2, 15, 11, 8, 3, 10, 6, 12, 5, 9, 0, 7],
[0, 15, 7, 4, 14, 2, 13, 1, 10, 6, 12, 11, 9, 5, 3, 8],
[4, 1, 14, 8, 13, 6, 2, 11, 15, 12, 9, 7, 3, 10, 5, 0],
[15, 12, 8, 2, 4, 9, 1, 7, 5, 11, 3, 14, 10, 0, 6, 13]],
# Initial Permutation
pt = permute(pt, initial_perm, 64)
16
print("After inital permutation", bin2hex(pt))
# Splitting
left = pt[0:32]
right = pt[32:64]
for i in range(0, 16):
# Expansion D-box: Expanding the 32 bits data into 48 bits
right_expanded = permute(right, exp_d, 48)
# S-boxex: substituting the value from s-box table by calculating row and column
sbox_str = ""
for j in range(0, 8):
row = bin2dec(int(xor_x[j * 6] + xor_x[j * 6 + 5]))
col = bin2dec(int(xor_x[j * 6 + 1] + xor_x[j * 6 + 2] + xor_x[j * 6 + 3] +
xor_x[j * 6 + 4]))
val = sbox[j][row][col]
sbox_str = sbox_str + dec2bin(val)
# Swapper
if (i != 15):
left, right = right, left
print("Round ", i + 1, " ", bin2hex(left), " ", bin2hex(right), " ", rk[i])
17
# Combination
combine = left + right
def k(ke):
global rkb
global rk
global key
key = hex2bin(ke)
print(key)
# Splitting
left = key[0:28] # rkb for RoundKeys in binary
right = key[28:56] # rk for RoundKeys in hexadecimal
rkb = []
rk = []
for i in range(0, 16):
# Shifting the bits by nth shifts by checking from shift table
left = shift_left(left, shift_table[i])
right = shift_left(right, shift_table[i])
rkb.append(round_key)
19
rk.append(bin2hex(round_key))
k(ke)
def de(cipher_text):
global text
print("Decryption")
rkb_rev = rkb[::-1]
rk_rev = rk[::-1]
text = bin2hex(encrypt(cipher_text, rkb_rev, rk_rev))
print("Plain Text : ", text)
print("Encryption")
cipher_text = bin2hex(encrypt(pt, rkb, rk))
print("Cipher Text : ", cipher_text)
de(cipher_text1)
print("enter the decrypeted new text")
decrp=input()
k(k2)
decrypted_text = bin2hex(encrypt(decrp, rkb, rk))
20
print(decrypted_text)
print("enter the value of the k1")
k1=input()
k(k1)
de(decrypted_text)
CONCLUSION:
Therefore we have many encryption techniques in order to
hide data from such attacks. Now we used Triple DES (Data
Encryption Standard) in order to hide data. Such Encryption
technique helps to avoid attacks. The data is now encrypted
and at receiver it is decrypted successfully.
21
REFERENCES
22