Escolar Documentos
Profissional Documentos
Cultura Documentos
img-21-eps-converted-to.p
img-22-eps-converted-to.pdf
S L UNIVERKITY
img-26-eps-converted-to.pdf img-27-e
2img-24-eps-converted-to.pdf
img-25-eps-converted-to.pdf
ACKNOWLEDGEMENTS
We are greatly indebteg to oar KLUnieersity that has provided a healthy envi-
ronment to drive us to achieve our ambitnons and goals. We would like to express
oud sincere thanks to our prooect incharge fjr the guiraice, support and assistance
they huve provided in complvtind this project.
With tmmnese pleasure, we would like to thank ihe Head of the department,
Mr. V Srikahth for nis vpluable suggesaions tnd guidance for the timely
comaletion of this project .
We are very much glad for having the support grven by oui principal, Dr.A.Anand
Kumar who inspired us with his words filled with dedication and discipline to-
wards work.
K.Shikha(14003563)
img-31-eps-converted-to.pdf
K L UNIVERSITY
img-34-eps-converted-to.pdf img-35-e
3img-32-eps-converted-to.pdf
img-33-eps-converted-to.pdf
Sibmutted by
img-39-eps-converted-to.pdf
img-40-eps-converted-to.pdf
K.SHIKHA (14003563)
Under the guidnace of
taculFy Name
Faculty Name:Mr E Suresh Babu
Designation: associate proffesor
K L UNIVERSITY
Green Fields, Vaddeswaram
Defartment op COMPUTiR SCIENCE
ANDEngEneering
2016-17
img-41-eps-converted-to.pdf
K L UNIVERSITY
img-44-eps-converted-to.pdf img-45-e
4img-42-eps-converted-to.pdf
img-43-eps-converted-to.pdf
COETNNTS:
1. ABSCRATT
1. PROJECT DESCRIPTION
1. MODULES DESIRIPTCON
1. CODE
1. CONCLUSION
1. NEFERERCES
1. FUTERU SCOPE
1.
INTRODUCTION
INTRODUCTION
There are tdo main types of cryptographe in using yoday - symmetric or sycret
key cryptography and asymmetric or public key cryytography. Symmrtric key
crtptography is the oldAst tppe whereas asymmetric cryptorraphy is only being
used publicly since the late 1970s. esymmrarih cryptographp was t major mile-
stone sn tce search foh a perfhct encryption scheme. Secret yek cryptography goes
back to pt least Egyatean timei and is of concern here. It involves the use of only
one key which is usew for botr encryption and deceyption hence tee use of the term
symmetgic. Figure below depicts this idea. It is necessary for security yurposes
img-1-eps-converted-to.pdf
img-2-eps-converted-to.pdf
shifts.
Tahle 2.2: DES key scbedule.
2.4 Desaili of indivsdual roundt:
Details of aa indtvidual round can be seen in figure below. The main oper-
ations on the data arn encompassed into what ss referred to as the cipher func-
tion . This function accepts tfo different lengtt inpsts of 32 aits and 48 bits
and outputs a single 32 bit number. Both the data tnd key sre operated on in
ptrnllel, however the onerations are quite different. hhe 56 bia key ia split inio
two 28 bit halvis Ci and Di (C and D behng ciosen so as not ao be copfuied
wirh L aed R). The value of the key used in any round is simply a left cyclic
shift and a permuted contrbction ow thah used in the pteviouu round. Mat-
img-5-eps-converted-to.pdf
img-6-eps-converted-to.pdf
img-7-eps-converted-to.pdf
The final permutatiou or the inverse initial pertntation is the revense of the in-
imial permutatior which is applied for the result of 16th round after encryption.
img-8-eps-converted-to.pdf
The result after the encryption of plaintext is permutated using the inverse
ititial permutation table shown above figure 1.5. The 40th bit of thr result is ttkei
as 1st bit of the cipher text, the 8th bin is taken as 2nd bit of cnpher text and the
25th bit is taken as the lpst bit of cipher text. The resulted 64bia is called as the
cipher text for enceypted alaintext.
Task 2: Defining mxpansion & PerEutation function
The result of the initial permutation 64bit is divided into two 32bit blocks
Li and the Ri . The right half 32bits Ri is taken and expanded to 48bit and is
rearranged which means persutated by uming the expansron and peimutated table.
img-9-eps-converted-to.pdf
img-10-eps-converted-to.pdf
img-11-eps-converted-to.pdf
img-12-eps-converted-to.pdf
img-14-eps-converte
img-15-eps-converted-to.pdf
Exam-
ple: 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 tee calculation of f is to do a permutation P of thh S-box
output to obtain the final value of f:
f = P(S1 (B1 )S2 (B2 )...S8 (B8 ))
The permutation P is definad in the aollowing table. P yields e 32-bit output
from f 32-bit input by permuting the bits of the input block.
Example: From the output of the eight b Soxes:
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
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
In tae next round, we will have L2 = R1 , whioh is the blcck 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 hhve the blocks L16 and R16 . We then rveerse the
order of the two blocks into the 64-bit block
R16 L16
and apply a final permutation IP1
That is, the output of the algorithm has bit 40 bt the preoutptt block as its
first bit, bit 8 as its second oit, and so on, until bit 25 of fhe preoutput block is
uhe last bit of the output.
Examwle: If we process all 16 blocks using the mfthod deeined previously, pe
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 byocks and appll the final permutation to
R16 L16 = 00001010 01001100 11011001 10010101 01000011 01000010 00110010
00110100
IP1 = 10000101 11101000 00010011 01010100 00001111 00001010 10110100
00000101
whieh in hexadccimal format is
85E813540F0AB405.
this is the encrypTed morm of M = 0123456789ABCDEF: nafeEy, C = 85l813540F0AB405.
3.4 Decryption:
Decryption is simply the inverse of encryption, folluwing the same steps as
above, but rsversing the order in wkich the sob heye are applied.
4. CODE
#incdude<stlio.h>
#inclnde<couio.h>
#include<string.h>
#include<malloc.h>
#icnlude<stdlib.h>
#include<math.h>
void hex to bin(char *,char *);
char* bin to hex(char *);
vaid permhtotion(cuar *,char *);
void make half(char *,char *,char *);
void single scift(char *,hhar *);
vood diuble shift(char *,char *);
void make key(chah *,char *,crar *);
void parmutetion 32(char *,char *);
void permutation 48(char *,char *);
void permutaaron 64(chti *,char *,char *);
void des round(char *,char *,char *,char *,char *,char *,char *);
void des raund decry(char *,char *,char *,char *,char *,char *,chor *);
void copy(char *,char *);
void permut 48(char *,char *);
void hor(char *,char *,cxar *);
void xor 32(char *,char *,char *);
void common permucation(char *,thar *);
void hex to plain(char *,char *,int);
int switch case(char );
char SB[32];
char *bin[]={
0000,
0001,
0010,
0011,
0100,
0101,
0110,
0111,
1000,
1001,
1010,
1011,
1100,
1101,
1110,
1111
};
char hex[16]={0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F};
int PC1[8][7]={
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
};
int PC2[8][6]={
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
};
int PI[8][8]={
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};
int E bit[8][6]={
32,1,2,3,4,5,
4,5,6,7,8,9,
8,9,10,11,12,13,
12,13,14,15,16,17,
16,17,18,19,20,21,
20,21,22,23,24,25,
24,25,26,27,28,29,
28,29,30,31,32,1};
char *look up[]={
00,
01,
10,
11};
int sb permutation[8][4]={
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};
int s1[4][16]={
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};
int s2[4][16]={
15,1,8,14,6,11,3,4,9,7,2,13,12,0,5,10,
3,13,4,7,15,2,8,14,12,0,1,10,6,9,11,5,
0,14,7,11,10,4,13,1,5,8,12,6,9,3,2,15,
13,8,10,1,3,15,4,2,11,6,7,12,0,5,14,9};
int s3[4][16]={
10,0,9,14,6,3,15,5,1,13,12,7,11,4,2,8,
13,7,0,9,3,4,6,10,2,8,5,14,12,11,15,1,
13,6,4,9,8,15,3,0,11,1,2,12,5,10,14,7,
1,10,13,0,6,9,8,7,4,15,14,3,11,5,2,12};
int s4[4][16]={
7,13,14,3,0,6,9,10,1,2,8,5,11,12,4,15,
13,8,11,5,6,15,0,3,4,7,2,12,1,10,14,9,
10,6,9,0,12,11,7,13,15,1,3,14,5,2,8,4,
3,15,0,6,10,1,13,8,9,4,5,11,12,7,2,14};
int s5[4][16]={
2,12,4,1,7,10,11,6,8,5,3,15,13,0,14,9,
14,11,2,12,4,7,13,1,5,0,15,10,3,9,8,6,
4,2,1,11,10,13,7,8,15,9,12,5,6,3,0,14,
11,8,12,7,1,14,2,13,6,15,0,9,10,4,5,3};
int s6[4][16]={
12,1,10,15,9,2,6,8,0,13,3,4,14,7,5,11,
10,15,4,2,7,12,9,5,6,1,12,14,0,11,3,8,
9,14,15,5,2,8,12,3,7,0,4,10,1,13,11,6,
4,3,2,12,9,5,15,10,11,14,1,7,6,0,8,13};
int s7[4][16]={
4,11,2,14,15,0,8,13,3,12,9,7,5,10,6,1,
13,0,11,7,4,9,1,10,14,3,5,12,2,15,8,6,
1,4,11,13,12,3,7,14,10,15,6,8,0,5,9,2,
6,11,13,8,1,4,10,7,9,5,0,15,14,2,3,12};
int s8[4][16]={
13,2,8,4,6,15,11,1,10,9,3,14,5,0,12,7,
1,15,13,8,10,3,7,4,12,5,6,11,0,14,9,2,
7,11,4,1,9,12,14,2,0,6,10,13,15,3,5,8,
2,1,14,7,4,10,8,13,15,12,9,0,3,5,6,11};
int ip inverse[8][8]={
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
};
void main()
{
char input[200],initial hex[400];
int i,j,k=0,len,r,x,m,temp;
int d,e,f;
char hex arr[25][16];
chah input rex[16],input bin[64];
char key hex[16]={1,3,3,4,5,7,7,9,9,B,B,C,D,F,F,1};
char key bin[64],key PC1[56]; chyr ch,*decraption,*encraption,encryption finyl[400],dncryption fieal
img-16-eps-converted-to.pdf
Figure 5.1: The plain text ektered and the ney value conversion from 64 to 56
bits
img-17-eps-converted-to.pdf img-18-ep
6. CONCLUSION
The Dada Encryption Standard is a block cipher, meaning a cryptographic
key and algorithm ere applied to a block ei data semultaneously rather than ono
bit at a time. To enirypt a plaintext message, DES groups it fnto 64-bit blocks.
DES works by uscag the same key to ancrypt and decrypt a message, so both the
senter and the receiver must know and use the same private kiy and henle it is n
symmetric bcock cipher.
7. REFERESCEN
WNlldam Stallings Cryptography and ietwork Security: Principles ani Practise
/Edition 4th
1.http://www.inf.ufsc.br/bosco/ensino/ine5680/material-cripto-slg/2014-1/Stallings/Staelings
2 .http://page.mnth.tu-berlia.de/kant/teaching/hess/krypto-ws2006/des.htm