87
Appendices

Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Embed Size (px)

Citation preview

Page 1: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Appendices

Page 2: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 3.1

/*For Generation of LFSR Stream*/

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

int a(5000) ,b(5000) ,i,m,n;

FILE *ftl,*ptl

//function for reading LFSR

void lfsr_read(FILE *ft)

{

fscanf(ft, "%d", &n) ;// n is the degree of polynomial

for( i=O;i<n; i++)

fscanf("%d", &a(i)); II reading of polynomial

for(i=O;i<n;i++)

260

fscanf(ft,"%d",&b[i)) ;/*reading of initial condition

of the polynomial */

fscanf(ft,"%d",&m); //bit length of lfsr's output

} //end of lfsr_read()

//function for writing LFSR's output

void lfsr_write(FILE *pt)

{

int sum=O, temp,k=O;

do

{

for(i=O;i<n;i++)

sum=sum+a[i]*b[i];

temp=sum%2;

i=O;

while(i<(n-1))

{

b ( i] =b ( i + 1] i

Page 3: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

i++i

}

b[n-1]=temp;

sum=O;

k++;

}while (k! =m) ;

}//end of lfsr_write()

main ()

ft1=fopen( 11 input.dat 11,

11 r 11);

lfsr_read(ft1); //lfsr_read() is called

pt1=fopen (II lfsr. dat II, 11 W 11

) ;

lfsr_write(ptl);

close(ft1);

close (pt1) ;

}

input.dat:

Degree of polynomial

4

polynomial:

1 0 0 1

Initial condition:

0 1 0 1

//lfsr_write() is called

Length of LFSR's output:

20

lfsr.dat:

0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 1 1

261

Page 4: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 3.2

/* LFSR Stream Processing*/

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

in t a [ 10 0] I b [50 0 0] 1 d [50 0 0] 1 e [50 0 0 l 1 f [50 0 0] 1

g[5000] 1 p[5000] 1 q[5000l~r[5000];

int ilnlolil;

int U 1 llzlv;

FILE *ftl 1 *ft2 1 *ft3 1 *ft4 1 *ptl 1 *pt2 1 *pt3 1 *pt4 1 *pt5;

void lfsr_read(FILE *ft)

{

262

fscanf(ft 1 "%d" 1 &n); //n ~s the degree of the polynomial

for(i=O;i<n;i++)

fscanf(ft 1 "%d" 1 &a[i]) ;//reading of polynomial

for(i=O; i<n; i++)

fscanf (ftl "%d" I &b[i]);

//reading of initial condition of the polynomial

fscanf(ft 1 "%d" 1 &m);

}

//Function for writing LFSR's output

void lfsr_write(FILE *pt 1 int c[])

int sum=O~temp~k=O;

do{

c[k]=b[O];

fprintf(pt 1 "%d\n"~c[k]);

for(i=O;i<n;i++)

sum=sum+a[i]*b[i];

temp=sum%2;

i=O;

Page 5: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

while(i<(n-1))

{

b [ i] =b [ i + 1] ;

i++;

}

b[n-1]=temp;

sum=O;

k++;

}while (k! =m) ;

}

//function for multiplication of two LFSR

void mult(int s[] 1 int t[]~int u[])

{

int j=O;

do{

s [ j] =t [ j] *u [ j] ;

printf ( ll%dll Is [j]);

j++;

}while(j!=m);

printf (II \n \n II) ;

}

main ()

{

for(i=O;i<25;i++)

printf (II \nil);

II lfsr_read{) is called

263

f t 1 = f open ( II s s . da t II I II r II ) ;

lfsr_read(ft1);

pt1=fopen (II tt. dat 11 I

11 W 11 );

lfsr_write(pt1~d); //lfsr_write() lS called for x1

close ( ft1) ;

close(pt1);

ft2=fopen( 11 SS .datil I llrll);

Page 6: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

lfsr_read(ft2);

pt2=fopen( 11 ttl.dat', 11 W 11);

264

lfsr_write(pt2,e);

close(ft2);

close(pt2);

//lfsr_write() is invoked for X2

ft3=fopen (II ss2, dat II, II r II) ;

lfsr_read(ft3);

pt3=fopen (II tt2. dat II. 11 W 11

);

lfsr_write(pt3,f);

close (pt3) ;

close(ft3);

i=O;

//lfsr_write() lS invoked for x3

//generation of combining function

printf( 11 Complement of x3\n 11);

do{

g[i]=f[i]"'l;

printf (II %d II, g ( i] ) ;

i++;

}while(i!=m);

priritf (II \n\nll);

printf( 11 Multiplication of compx3 & xl is\n 11);

mul t (p, g, d) ;

printf( 11 Multiplication of x3& x2 is\n 11);

mult (q!; f, e);

printf( 11 The key stream is\n 11) ;//generation of key stream

pt4=fopen (II tt3. dat II, 11 W 11

);

1=0;

do{

r [ l ] =p [ l ] * q [ 1 ] ;

fprintf (pt4, 11 %d 11 ,r[l]);

l++;

}while ( 1! =m) ;

Page 7: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

fprintf(pt4, "\n");

printf("\n\n");

close(pt4);

ft4=fopen ( "ss3 . dat", "r") ;

for(o=O;o<m;o++)

fscanf(ft4,"%d",&w[o));

printf("The coded message\n");

for(o=O;o<m;o++)

printf("%d", w[o]);

printf("\n");

//generation of cipher-text

pt5=fopen ( "tt4. dat", "w");

z=O;

fprintf(pt5, "The cipher-text is \n");

do{

y [ z) =r [ z) Aw [ z] ;

fprintf(pt5, "%d" ,y[z]);

z++;

}while ( z! =m) ;

fprintf(pt5, "\n");

close(ft4);

close(pt5);

printf("coded message \n");

il=O;

do{

xx[il]=f[il]Ay[il];

printf("%d",xx[il]);

il++;

}while ( il! =m) ;

print£ ( "\n");

}

265

Page 8: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

266

Output:

Complement of x3-------->

0100111010011101001110100111010011101001110100111010011

Multiplication of Complement of x3 and x1---------->

0100100000011100001100100011010001100000010100101000000

The Key Stream is --------->

1100100000111100101100101011111001100000011100101000100

The Coded Message (I like apples) is-------->

0110001001011001111010000110000110101101010011000010100

Page 9: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 3.3

/*Generation of LFSR Stream and Ciphertext*/

#include<stdio.h>

#include<stdlib.h>

#include<math,h>

in t a ( 10 0 ] , B ( 10 0 ] , d ( 4 0 0 0] , e ( 4 0 0 0 ] , m;

int i,i1,i2,i3,i4,j2,n,o,t,r;

int u[10] ,jjj,iik,ijk,k1,kind;

int jj=O,i1=0,index,total,cnt,doub;

float v,j=O.O,i=O.O,w;

FILE *ft1,*ft2,*pt1,*pt2;

//function for reading lfsr

viod lfsr_read(FILE *ft)

{

fscanf (ft, "%d", &n);

//n is the degree of the polynomial

for(i=O; i<n; i++)

fscanf( ft, "%d", &a(i]);

for(i=O; i<n; i++)

fscanf ( ft, "%d", &b[i]); I /initial conditions

fscanf{ ft, "%d", &m); //bit length of LFSR 's output

fscanf( ft, "%d", &t); //no.of taps

}

void lfsr_write(FILE *pt, int c[])

//function for writing lfsr

{

int sum=O, temp, k=O;

do{

c[k]=b[O];

//output of LFSR

fprintf(fp, "%d\n", c[k];

for (i=O; i<n; i++)

267

Page 10: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

sum=sum+ a[i]*b[i];

temp=sum%2;

i=O;

while(i <n-1) {

b[i]=b[i+1]; i++;

}

b[n-1]= temp;

sum=O;

k++i

}while(k!=m);

}

main ()

{

ft1 = fopen("input.dat", "r");

lfsr_read(ft1); 1/lfsr_read() is invoked

pt1 = fopen("lfsr.dat","w");

lfsr_write(pt1,d);

close (ft1);

close (pt1) ;

II lfsr_write is invoked

pt2 = fopen("cipher.dat", "w"); I* Generation of cipher

stream *I

for (i=O; i, m; i++) {

v= (((float)rand())l((float)RAND-MAX) );

if ( v <=0.6)

e[i]=d[i]

else

e[i]=1"d[i];

fprintf (pt2, "%d\n",e[i]);

}

close(pt2);

268

Page 11: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

contents of input.dat

Degree of polynomial:

4

Polynomial:

1 0 0 1

Initial condition:

0 1 0 1

Length of LFSR's output:

20

Number of taps:

2

Contents of lfsr.dat

Generating LFSR Stream:

269

0 1 0 1 1 0 0 1 0 0 0 1 1 1 1 0 1 0 liB 1

Contents of cipher.dat

The ciphertext:

0 1 0 1 0 0 1 1 0 0 0 1 1 1 0 0 0 I '1/ I,

11: 0 0 I I

Page 12: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 3.4

/*Expression of Each Bit of LFSR Stream In Terms of

Initial Condition*/

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

main()

{

int ijlilmlf[lOO] ljj=O~ll=O~ijk;

int a[lOO] 1b[100] lnlhlolctr~t~ictrl

indltempl~illi21j21rlu;

int **pos 1 jjj 1 iik~iij 1 indexlsum 1 temparr[50];

FILE *ft 1*pt4;

//initial condition of no of degree to no of bit

pt4=fopen ("break. dat" I "w");

ft=fopen("input.dat"l "r");

fscanf(ft 1 "%d" 1&n);

//n is the degree of the polynomial

for(i=O;i<n;i++)

fscanf(ft 1"%d" 1 &a[i]);

//reading co-efficients of polynomial

for(i=O;i<n;i++)

fscanf(ft 1"%d" 1 &b[i]);

//reading of LFSR's initial condition

fscanf ( ft I" %d" I &m) ; I /bit length of LFSR' s output

fscanf (ftl "%d" I &t);

pos=(int**)malloc(m*sizeof(int*));

for(i=O;i<m;i++)

pos[]=(int*)malloc(n*sizeof(int));

index=O;

for(i=O;i<n;i++)

270

Page 13: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

if(a[i]==1)

{

f[index]=i+1;

index++;

}

for(o=O;o<n; o++)

{

for(iik=O;iik<n; iik++)

{

if(o==iik)

pos [ o] [ iik] =1;

else pos[o] [iik]=O;

fprintf (pt4, "%d" ,pos [o] [iik]);

}

fprintf(pt4,"\n");

}

for(o=n;o<m;o++)

{

for(iik=O;iik<=t-1;iik++)

pos [o] [iik] =o-f [ (t-1) -iik];

for(i1=0;i1<t;i1++)

temparr [ i1] =pos [ o] [ i1) ;

for(jjj=O;jjj<n;jjj++)

{

sum=O;

for(ijk=O;ijk<t;ijk++)

sum=sum + pos[temparr[ijk]) [jjj);

pos[o] [jjj]=sum%2;

fprintf(pt4, "%d" ,pos[o) [jjj]);

}

fprintf(pt4,"\n");

}

271

Page 14: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

for(i=O;i<m;i++)

free(pos[i]);

close(pt4);

}

output:

272

Expression of each bit LFSR stream in terms of initial

condition

0=1000,1=0100,2=0010,3=0001,4~1001,5=1101,6=1111,7=1110,

8=0111,9=1010,10=0101,11=1011,12=1100,13=0110,14=0011,

15=1000,16=0100,17=0010,18=0001,19=1001

Page 15: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 3.5

/*Distance calculation and initial condition

checking */

#include<stdio.h>

#include<stdlib.h>

#include<math.h>

int a[lOO] ,b[lOO] ,c[lOOOO] ,z[lOOOO] ,zsum,m,nchoosek;

int i,il,i2,i3,i4,j2,n,o,t,r,s[100] ,num[10] ,si[lOO];

int dist[100],u[100] ,jjj,iik,ijk,kl,kind,guess,number,

sum;

int jj=O,ll=O,p[lOO] ,**pos,index,total,powl,cnt,doub;

float partl,part2,frac[2];

double grandist[2];

char ch [ 100] ;

FILE *ftl,*ft2,*pt2,*pt3,*pt4;

II function for simulation of LFSR

void lfsr_write(int c[])

{

int i,sum=O,temp,k=O;

do{

c[k]=b[O);

for(i=O;i<n;i++)

sum=sum+a[i]*b[i];

temp=sum%2;

i=O;

while(i<(n-1))

{

b [ i] =b [ i + 1] ;

i++;

}

b[n-l]=temp;

273

Page 16: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

sum=O;

k++;

}while (k! =m) ;

}

//function for binary to decimal

int b2d(int ss[] lint bits)

{

int i 1 Ct 1 number;

ct=l;number=O;

for(i=O;i<bits;i++)

{

number=number+ss[i)*ct;

ct=ct*2;

}

return(number);

}

//function to read LFSR polynomial

void lfsr_read(FILE *ft)

{

fscanf(ftl "%d" 1 &n) ;//n is the degree of polynomial

for(i=O;i<n;i++)

f scan f ( f t I " % d " I & a [ i ] ) ;

//reading of co-efficients of lfsr polynomial

for(i=O;i<n;i++)

fscanf(ftl "%d" 1 &b[i));

//reading of initial condition

fscanf(ftl "%d" 1 &m); //bit length of lfsr output

fscanf(ft 1 "%d" 1 &t);

}

int power(int n 1 int m)

{

//no of taps

274

Page 17: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

int q;

if(m==O)

q=l;

else

q=n*power(n,m-1);

return (q) ;

}

main()

{

ftl=fopen ("input. dat II, 11 r II)

" 27$

lfsr_read(ftl); //lfsr_read() is invoked

pt2=fopen("cipher.dat", 11 r");

pt3=fopen("break.dat 11,

11 r 11);

pt4=fopen("rubbish.dat 11,

11 W11);

pos=(int**)malloc(m*sizeof(int*));

for(i=O;i<m;i++)

pos[i]=(int*)malloc(n*sizeof(int));

for(i=O;i<m;i++)

{

fscanf(pt2, 11 %d 11 ,&Z[i]);

fscanf(pt3, 11 %S 11 ,&ch);

for(il=O;il<n;il++)

pos[i] [il]=ch[il]-'0';

}

for(i=O;i<n;i++)

u[i]=O;

for(kl=l;kl<n;kl++)

{

for(guess=O;guess<=l;guess++)

{

u[kl-l]=guess;

kind=power(2,n-k1);

Page 18: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

for(i=O;i<kind;i++)

{

si[i]=O;

num[i]=O;

}

for(o=n;o<m-l;o++)

{

for(i2=o+l;i2<m;i2++)

{

for(j2=0; j2<n;j2++)

p [ j 2] =pos [ o] [ j 2] "pos [ i2] [ j 2] ;

for(j2=kl;j2<n;j2++)

s [ j 2-kl] =p [ j 2] ;

number=b2d(s,n-kl);

si[number]++;

zsum=(z[o]+z[i2])%2;

sum=O;

for(j2=0;j2<kl;j2++)

sum=sum+u[j2]*p[j2];

sum=sum%2;

if(sum=zsum)

num:[number]++;

}

}

grandlist[guess]=O;

nchoosek=O;

for(i=O;i<kind;i++)

nchoosek=nchoosek+si[i];

for(i=O;i<kind;i++)

{

276

partl= ( (float) ( si [ i] -2 *num [ i]) ) I ( sqrt ( (float) nchoosek) ) ;

part2=partl*partl;

Page 19: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

grandlist[guess]=grandlist[guess]+part2;

}

}

u[k1-1]=(grandlist[O]>grandlist[1])? 0:1;

fprintf(pt4, "results %d %d \n", k1-1,u[k1-1]);

fprintf(pt4, "grandlist[0]=%1f

grandlist[1]=%1f\n",grandlist[O] ,grandlist[1]);

II the following part determines u[n-1]

for(guess=O;guess<=1;guess++)

{

u[n-1]=guess;

for(i=O;i<n;i++)

b [ i] =u [ i] ;

lfsr_write(c);

frac[guess]=compare(c,z)/( (float)m);

}

u[n-1]=(frac[O]>frac[1])? 0:1;

fprintf(pt4, "frac0=%f frac1=%f\n",frac[O] ,frac[1]);

fprintf(pt4,"results %d %d ", n-1,u[n-1]);

close(pt2);

close(pt3);

close (pt4) ;

int compare(int c[], int z[])

{

int l;

int sum=O;

for(i=O;i<m;i++)

if (c [i] ==z [i])

sum++;

return (sum) ;

}

277

Page 20: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

output:

results u[O]=O

grandlist[0]=46.70808l,grandlist[l]=2.213033

results u(l]=l

grandlist(0]=4.231664 grandlist[l]=89.184492

results u[2]=0

grandlist[0]=178.022575 grandlist[l]=0.346407

frac0=0.490000 fracl=0.585000

results u[3]=1

278

Page 21: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Appendix 3.6

/*Encrypted message transmission between Sender &

Receiver using Object Oriented Approach for DES*/

#include<stdio.h>

#include<conio.h>

static int p[64]={

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};

static int invp[64]={

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,

32,2,42,10,50,18,58,26,33,1,41,9,49,17,57,25};

class Base{

} i

public:

int keyout[17] [48];

void des_init(unsigned char *);

void lshift(unsigned char[]);

void cipher(int *r,int cnt,int *fout);

219

Page 22: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

class Sender : public Base{

unsigned char *key;

public:

void getskey();

void des_encrypt(unsigned char *input);

} ;

class Receiver : public Base{

unsigned char *key;

public:

void getrkey();

void des_decrypt(unsigned char *input);

} ;

void Base des_init(unsigned char *key)

{

unsigned char c[28] ,d[28];

static int pcl[56]={

57,49,41,33,25,17,9,

01,58,50,42,34,26,18,

10,02,59,51,43,35,27,

19,11,03,60,52,44,36,

63,55,47,39,31,23,15,

07,62,54,46,38,30,22,

14,06,61,53,45,37,29,

21,13,05,28,20,12,04

} ;

static int pc2[48]={

14,17,11,24,1,5,

3,28,15,6,21,10,

23,19,12,4,26,8,

16,7,27,20,13,2,

280

Page 23: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

41,52,31,37,47,55,

30,40,51,45,33,48,

44,49,39,56,34,53,

46,42,50,36,29,32

} ;

static int nls[17]={

0,1,1,2,2,2,2,2,2,1,2,2,2,

2,2,2,1

} ;

static int cd[56] ,keyb[64];

static int cnt,n=O;

register int i,j;

for(i=O;i<8;i++)

for(j=O;j<8;j++) //Read in Key

keyb[n++]=(key[i]>>j&Ox01);

for{i=O;i<56;i++)

cd(i]=keyb[pc1(i]-1];

for(i=O;i<28;i++)

{

c [ i] =cd [ i] ;

d[i]=cd[i+28];

}

for(cnt=1;cnt<=16;cnt++)

{

for(i=O;i<nls[cnt] ;i++) {

lshift(c);

lshift (d);

}

for(i=O;i<28;i++)

{

cd [ i] =c [ i] ;

cd[i+28] =d[i];

281

Page 24: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

}

for(i=O;i<48;i++)

keyout[cnt] [i]=cd[pc2[i]-1];

}

void Base .. lshift(unsigned char shft[])

{

}

register int temp,i;

temp=shft[O];

for(i=O;i<27;i++) shft[i]=shft[i+1];

shft[27]=temp;

void Base cipher(int *r,int cnt,int *fout)

{

static int expand[48],b[8] [6] ,sout[8] ,pin[48];

register int i,j;

static int n,row,col,scnt;

static int p[32]=

{

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

} i

static int e[48]={

31,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,

282

Page 25: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

24,25,26,27,28,29,

28,29,30,31,32,1};

283

static int s[8] [64]={

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,1

5,12,9,7,3,10,5,0,15,12,8,2,4,9,

1,7,5,11,3,14,10,0,6,13,15,1,8,1

4,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,1

1,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,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,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,

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,1

5,9,12,5,6,3,0,14,11,8,12,7,1,14

,2,13,6,15,0,9,10,4,5,3,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,13,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,4,11,2,14,15,0,8

Page 26: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

284

,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,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,1

2,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

} ;

for(i=O;i<48;i++)

expand[i]=r[e[i]-1];

for(i=n=O;i<8;i++) {

for(j=O;j<6;j++,n++)

b[i] [j]=expand[n]Akeyout[cnt] [n];

}

for(scnt=n=O;scnt<8;scnt++) {

row=(b[scnt] [0]<<1)+b[scnt] [5];

col=(b[scnt] [1]<<3)+(b[scnt] [2]<<2)+(b[scnt] [3]<<1)+

b[scnt] [4];

}

sout[scnt]=s[scnt] [ (row<<4)+col];

for(i=3;i>=O;i--){

}

pin[n]=sout[scnt]>>i;

sout[scnt]=sout{scnt)-(pin[n++]<<i);

for(i=O;i<32;i++)

fout[i]=pin[p[i]-1];

Page 27: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

void Sender :: getskey() {

printf{"\nFrom Sender End::");

}

key=(unsigned char*)getpass{"\n\tEnter key:->");

des_init (key);

void Sender des_encrypt(unsigned char *input)

{

static unsigned char out[64];

static int inputb[64],ir[64] ,1[32],r[32];

static int fn[32],cnt,n;

register int i,j;

for(i=n=O;i<8;i++)

for(j=O;j<8;j++)

inputb[n++]=(input[i]>>j&OxOl);

for(i=O;i<64;i++)

{

ir[i]=inputb[p[i]-1];

if(i<32)

l[i]=ir[i];

else

r[i-32]=ir[i];

}

for(cnt=l;cnt<=l6;cnt++)

{

cypher(r,cnt,fn);

for(i=O;i<32;i++)

{

}

j=r[i];

r[i]=l[i]Afn[i];

l[i]=j;

285

Page 28: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

}

for(i=O;i<32;i++) {

ir[i]=r[i];

ir[i+32]=l[i];

}

for(i=O;i<64;i++)

out[i)=ir[invp[i)-1];

for(i=l;i<=8;i++)

for(j=1;j<=8;j++)

input[i-1]=(input[i-1]<<1) jout[i*B-j];

void Receiver :: getrkey() {

}

printf ( "\nFrom Sender End: : ") ;

key=(unsigned char*)getpass("\n\tEnter key:->");

des_ini t (key) ;

void Receiver :: des_decrypt(unsigned char *input) {

static unsigned char out[64];

static int inputb[64],lr[64] ,1[32] ,r[32];

static int fn[32];

static int cnt,rtemp,n;

register int i,j;

for(i=n=O;i<8;i++)

for(j=O;j-<8;j++)

inputb[n++J=(input[i]>>j&Ox01);

for(i=O;i<64;i++) {

lr[i]=inputb[p[i]-1];

if(i<32)

l[i]=lr[i];

else

r[i-32]=lr[i];

}

286

Page 29: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

for(cnt=16;cnt>O;cnt--) {

cypher(r,cnt,fn);

for(i=O;i<32;i++) {

rtemp=r[i];

}

}

if(l[i]==l && fn[i]==l)

r[i]=O;

else

r [ i] = ( l [ i] I I fn [ i] ) ;

l[i]=rtemp;

for(i=O;i<32;i++) {

lr[i]=r[i];

lr[i+32]=l[i];

}

for(i=O;i<64;i++)

out[i]=lr[invp[i]-1];

for(i=l;i<=8;i++)

for(j=1;j<=8;j++)

input[i-1]=(input[i-1]<<1) lout[i*8-j];

void main ()

{

clrscr();

Senders; //s lS sending encrypted message tor

Receiver r;

287

1/r is decrypting the received message uslng same secret

I !key

unsigned char *data;

int n;

s.getskey(); //getting secret key from sender

printf("\nEnter your message:->");

Page 30: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

288

gets(data); II getting message

s.des_encrypt(data); //encrypting the message

printf("\nData after encryption:->");

puts (data);

r.getrkey() ;//getting secret key from the receiver

r.des_decrypt(data);

//decrypting the received encrypted message

printf("\nData after decryption:->");

puts (data);

getch();

}

OUTPUT:

From Sender End::

Enter key:->abcd1234

Enter your message:->dip12345

Data after encryption:->_8A+_•)'

From Receiver End::

Enter key:-> abcdl234

Data after decryption:->dip12345

Page 31: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 4.1

/*Implementation of RSA Digital Signature

using Object Oriented Approach */

#include<iostream.h>

#include<string.h>

#include<conio.h>

#include<stdio.h>

#include<math.h>

class RSAl{

public :

char *msg;

long int Nalice,sign;

} ;

289

/*msg lS a string of characters and sign represent

digital signature*/

class RSA2{

public:

int hash(char []);

int GCD(int,int);

} ;

/*hash ( ) function is used to create a hash value . GCD

lS used to determine the GCD value of two numbers.

The detail implementation of GCD which is a member

function of RSA2 class is as follows:

*I

int RSA2

{

int r;

if(n>m)

{

GCD(int m, int n)

Page 32: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

r=n;

n=m;

· m=r;

}

while (n! =0)

{

}

r=m%n;

m=n;

n=r;

return m;

}

290

/*The detail implementation of hash ( ) which is a member

function of RSA2 class is as follows:*/

int RSA2 hash(char msg[])

{

int s=O;

int l=strlen(msg);

cout<< II \n II;

for(int i=O;i<l;i++)

{

}

cout<< 11 Msg[ 11 <<i<<"]="<<msg[i];

s=s+(int(msg[i] )%2);

return s;

}

/*Detail implementation of class Bob, a multiple

inheritance of RSAl and RSA2 derived both publicly as

follows:*/

Class Bob : public RSA2 , public RSAl

{

public:

Page 33: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

long int Palice;

int check();

} ;

291

/*Class Alice derived publicly from RSA2 and privately

from RSAl is as follows*/

Class Alice: public RSA2 1

{

private:

long int U1 V;

long int h;

long int Salice;

public:

long int Palice;

void getData();

Bob send ();

} ;

void Alice : :getData()

{

cout<<"Enter Message

· gets (msg) ;

• II • • I

private

cout<<"\nMessage :"<<msg;

cout<<"\nEnter Two Prime Number

cout<<"\nEnter U :";

cin>>U;

cout<<"Enter V

cin>>V;

• II • • I

int n=(U-l)*{V-1);

int flag=l;

int c;

while(flag)

{

RSAl

• II • • I

Page 34: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

}

cout<<"Enter Palice

cin>>Palice;

• 11. • I

if(GCD(Palice,n)==l && (Palice >1 && Palice <n))

flag=O;

Bob Alice send() // sending signed message

{

}

Bob b;

getData();

Nalice=U*V;

cout <<"\n u="<<U<<" v="<< V;

cout<<"\nNalice :"<<Nalice;

Salice=((U-1)*(V-l)*(Palice-1)+1)/Palice;

cout<<"\nSalice :"<<Salice;

cout<<"\nMessage :"<<msg;

h=hash (msg);

cout<<"\nHash Value :"<<h;

long int x=pow(h,Salice);

sign=x%Nalice;

int l=strlen(msg);

b.msg=new char[l+1];

strcpy(b.msg,msg);

cout<<"\nBob Received Message :"<<b.msg;

b.sign=sign;

//sign is actually the RSA digital signature

b.Palice=Palice;

b.Nalice=Nalice;

return b;

292

Page 35: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

int Bob

{

check( ) II verifying the received signature

}

long int h,hl;

h=hash (msg) ;

cout<<"\nHash Value :"<<h;

long int x=pow(sign,Palice);

hl=x%Nalice;

cout<<"\n Hl="<<hl;

if(h= =hl)

return 1;

else

return 0;

293

I* The program execution starts from the function main().

Here a lS an object of type Alice and b is an object of

type Bob. a.send( sends a signed message to b.

b.check() verifies the signature and detects whether the

received message is unaltered or modified by a third

party i. e. intruder. *I

void main ( )

{

Alice a;

Bob b;

int x;

b=a.send() ;II a is sending signed message to b

x=b.check() ;// b is received the signed message

if(x= =1)

cout<<"\nMessage lS Ok";

else

cout<<"\nMessage is Wrong";

} // end of main ( )

Page 36: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Input:

Enter Message : deposit rs 5000

Message : deposit rs 5000

Enter Two Prime Number :

Enter U :3

Enter V :5

Enter Palice :7

Nalice :15

Salice :7

Hash Value :1

Bob Received Message deposit rs 5000

Hash Value :1

H1=1

Message is Ok

294

Page 37: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Appendix 4.2

/* Implementation of Elgamal Digital Signature using

Object Oriented Approach {for Integer Message)*/

295

/*An Object A (Alice) of Sender class sends a Signed

Message to Object B (Bob) of Receiver class. Algorithm

development process 1s the creation of several objects

and object-to-object communication using member

functions.

Input: A random number b and a pr1me number U.

Output: A signed message to Bob

*I

#include<iostream.h>

#include<string.h>

#include<conio.h>

#include<stdio.h>

#include<math.h>

Class Digi-Sign

{

Public:

Int hi . Vi ;

II Abstract base class

Static Int P_obj (int,int,int ); II public key generator

int Readmessage( ) ;

//read the message i.e. transaction to be sent to Bob

int Signi int, int, int, int)

friend Static Int Hi ( int, int);

friend int Generate_prime( );

}; II end of base class

int Generate_prime( )

{

Page 38: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Int X;

for (; ; )

{

x = rand( )%100 ;

for ( int i = 2; i<=x/2; i++)

{

if ( x%2 )==0)

break;

}

if(x%2!=0) break;

}

return x;

}

Class Sender : public Digi-Sign

//Sender is inheriting Digi-Sign class

{

Private:

int S_key, msg, s1gn, Ri

int Get_Secretkey( ) ;

Public:

int pk

void Get_Ri( ) ;

/* S_key is the secret

key* I

II pk 1s the public key

296

Receiver Send (int, int ) ; /*object of rece1ver type 1s

} ;

int Digi_Sign

{

sent by sender*/

P_Obj ( int b, int S, int U )

return (POW( b, S ) ) % U

}

int

{

Digi_Sign Readmessage ( )

Page 39: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

297

int x· I

cout <<"Enter the message to be sent";

cin >> x;

return (x);

}

int Hi( int msg, int Vi ) II Hash the message

{

return ( shift_right_one_bit ( msg ) XOR Vi)

}

II Compute the signature

int Digi_Sign :: Signi( int Ri, int hi, int Secretkey,

int U)

{

return ( Ri + hi*Secretkey % (U-1));

}

void sender Get_Secretkey( )

{

cout<<"enter secret key";

c1n >> S_key;

}

void sender Get_Ri ( )

{

cin>> Ri;

}

class Receiver public Digi-Sign

{

public:

Int msgl, signl, pkl;

void verify-signature(int, int);

} ;

II Send message, sign & Public Key

Receiver Sender:: Send ( int b,int u

to receiver

Page 40: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

298

{

char ch;

Receiver xx;

Get_Secretkey( ) ;

Pk=P_obj (b,u,s_key) II s_key is the sender's secret key

Get Ri( ) ;

int x = pow(b, ri);

Vi = x%u ;

msg=Readmessage(

hi=Hi (msg, Vi) ;

sign=signi(ri, hi, u, S_key);

cout<<"do you want to modify message ·"

cin>>ch;

if (ch=='y' II ch=='Y')

{

cout<<"\n enter message

cin>>msg;

}

• II • • I

xx.Vi= Vi; II receiver object is xx.

xx.signl=sign;

xx.msgl=msg;

xx.pkl=pk

II send receiver object

return xx ; II return an object of receiver class

}

void Receiver:: verify-signature( int b, int U)

{

hi=Hi (msgl, vi) ;

int t = pow(b, signl);

t=t mod u;

int x=vi*pow(pkl,hi);

x=x mod u;

Page 41: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

if(t==x){

cout << " Alice has signed the meassage'' << "\n"

}

else

{

<< " Message has not been modified by third

party" << "\n";

cout << " Alice has not signed the meassage'' << "\n"

<< " OR the message has been modified by

third party" << "\n";

}

maln ( )

{

Sender Alice; //Alice is an Object of Sender class

Receiver Bob; // Bob is an Object of Receiver class

int b = rand( ) ;

int U= Generate_prime( );

299

Alice.Get_Secretkey( ) ; /* secret key of Alice lS

generated*/

Bob=Alice.send(b,u); /* Alice sends message, signature,

P-Alice and the ephemeral public

key vi*/

Bob.verify-signature (b, U ); /*Bob verify the signature

of Alice*/

}

Input:

Enter secretKey : 3

Enter ephemeral key ri :5

Enter a message in integer :7

Calculated Signature is : 4

Page 42: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Received message 1s 7

Value of Recomputed signature :4

Signature is OK

300

Page 43: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 4.2.1

/*Implementation of Elgamal Digital Signature using

Object Oriented Approach (for Character Message)*/

#include<iostream.h>

#include<math.h>

#include<string.h>

#include<ctype.h>

#include<stdlib.h>

#include<stdio.h>

#include<conio.h>

class Receiver;

class Digi_Sign //Abstract class

{

public:

long int hi;//hash value

long int vi;//ephemeral public key

static long int P_obj (long int,long int, long int);

//public key generator

301

char *Readmessage() ;//read the message to be send to Bob

long double Signi(long int,long int,long int,long int);

friend long int Hi(char *,long int) ;// hash calculator

friend int Generate_prime() ;//Prime number generator

};//end of abstract class

int Generate_prime()

{

int x;

for (; ; )

{

x=rand () %100;

for(int i=2;i<=x/2;i++) {

if(x%2==0)

Page 44: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

break;

}

if(x%2!=0)

break;

return x;

}

class Sender :public Digi_Sign

{

private

long int s_key;//secret key

long int rl;

long double sign;//sign ,mesage

char *msg;

public:

long int pk;//public key

Receiver send(int,int);

void get_seckey() ;//get secretkey

long int get_ri{}// ephemeral secret key generator

{

cout<<"\n Enter rl

cin>>ri;

return ri;

}

} ;

• II • • I

class Receiver :public Digi_Sign

{

public:

long double signl;//receiving sign

char *msgl;//receiving msg

long int pkl;//receiving public key

void verify_signature(int,int);

302

Page 45: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

II verify signature function

} ;

void Sender:: get_seckey{)//get secretkey

{

cout<<"\n Enter secretKey

cin>>s_key;

}

• II • • I

char* Digi_Sign: :Readmessage{}// message read

{

char *x;

x=new char[lOOO];

cout<<"\nEnter a message • II • • I

gets (x) ;

printf("Message 1s

return x;

}

%s" I x);

303

long int Hi(char *msg 1 long int v}// hash value calculator

{

long int x;

int t=strlen(msg);

x=toascii(msg[O])>>lAv;

for(int i=l;i<t;i++)

x=x>>lAtoascii(msg[i]); //***change msg[O] to msg[i];

return x;

}

long int Digi_Sign: :P_obj(long int b 1 long int ullong int

s)

{

long int p; // calculate public key

p=pow (bl s) ;

p=p%u;

Page 46: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

return p;

}

long double Digi_Sign: :Signi(long int ri,long int

hi,long int u,long int s)

{ II calculate sign of the messag~

long double x;

x=(ri+hi*s)%(u-1);

return x;

}

Receiver Sender

{

char ch;

send (int b,int u)

Receiver xx;// create an object of receiver class

get_seckey(); //get secret key

pk=P_obj (b,u,s_key) ;// genreate public key

long int r=get_ri() ;II get ephemeral secret key

long int x=pow(b,r);

vi=x%u; II generate ephemeral public key

char *temp=Readmessage();

msg=new char[strlen(temp+l)];

strcpy(msg,temp) ;//read message

hi=Hi(msg,vi) ;//generate hash value

sign=Signi(r,hi,u,s_key) ;// generate signature

I* send signature,message,public key,ephemeral publickey

to Receiver*/

cout<<"\n Do you want to interrupted message

cin>>ch;

if ( ch== I Y I I I ch== I Y I )

gets(msg) ;//read message

XX.Vl=Vl;

• II • • I

Page 47: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

xx.signl=sign;

strcpy(xx.msgl,msg);

xx.pkl=pk;

!* send receiver object*/

return xx;

}

void Receiver verify_signature(int b, int u)

//receiver check sign

{

hi=Hi(msgl,vi); //generate hash value

long double t=pow(b,signl);

t=fmod(t,u);

long double x=vi*pow(pkl,hi);

x=fmod (x, u) ;

if(t==x)

cout<<"Ok";

else

cout<<"Error";

}

void main ()

{

Sender Alice;

Receiver Bob;

clrscr();

int b=random(200);

int u=Generate_prime();

//Generate_prime();

Bob=Alice.send(b,u);// Alice send signature to Bob

Bob.verify_signature(b,u) ;//Bob verify the signature

getch () ;

}

305

Page 48: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Output:

Enter secretKey :3

Enter ri :5

Enter a message :deposit

Received Message is : deposit

Value of the signature :4

Recomputed Signature 1s : 4

Signature is OK

306

Page 49: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

APPENDIX 7.1

/* Object Oriented program for Authentication using

Digital Certificate*/

/* Simulation of three part message transmission from a

customer to a bank using Digital Certificate */

#include<iostream.h>

#include <stdio.h>

#include <conio.h>

#include<ctype.h>

#include <string.h>

#include <math.h>

class Cust;

class Bank;

class Base{

public:

int Pbank,Pcust,Pca,Pid;

long double hash;

int GCD(int,int);

int Base GCD(int x, int y)

{

}

if(x>=y)

if(x==y)

return x;

else

return GCD(x-y,y);

else

return GCD (y, x);

307

Page 50: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

class RSA{

} i

public:

char *mesg;

int U,V;

int Nbank,Ncust;

class CA : public Base,public RSA{

private:

} ;

int Sea;

public:

long double cer;

int Nca;

long double hashfun(int,int);

long double cer_cal(int);

long double CA :: hashfun(int keyl,int key2) {

long double hash,hl;

}

char h;

if(keyl>=key2)

hash=fmod(keyl,key2);

else

hash=fmod(key2,keyl);

h=mesg[O];

h=tolower (h) ;

hl=h%5;

hash=pow(hl,hash);

return hash;

long double CA

clrscr();

cer_cal(int Pcust) {

308

Page 51: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

cout<<"\n\t\t\t**********~**For

Certification**************";

cout<<"\n\nEnter Pid for customer: ";

cin>>Pid;

cout<<''\nEnter the values(reltively prime) for U &

V: \n";

cin>>U>>V;

Nca=U*V;

int n=(U-l)*(V-1);

int flag=l,p,k=l;

while(flag){

cout<<"\nEnter a no. for public key:->";

cin>>p;

Cust c;

if(GCD(p,n)==l && (p>l && p<n))

{

flag=O;

cout<<"\nKey granted. This 1s ur public key";

}

else

cout<<"\nKey not granted. Try again";

}

getch () ;

flag=l;

while(flag)

{

if ( (n*k+l) %p==0)

flag=O;

else

k++;

}

Sca=((U-l)*(V-l)*k+l)/p;

309

Page 52: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Pca=p;

cer=hashfun(Pcust,Pid);

cer=pow(cer,Sca);

cer=fmod(cer,Nca);

return cer;

} ;

class Bank public CA{

private:

int Sbank;

public:

long double msg[lOO];

void createKey();

void decrypt();

void dformat_msg();

void decrypt_sig();

void decrypt_cer();

void check();

void get_msg ();

void check_sig();

void check cer();

} ;

void Bank createKey(){

clrscr();

cout<<"\n\t\t\t*************Information about Bank

*************"· I

cout<<"\n\nEnter the values(reltively prime) for U &

V: \n";

cin>>U>>V;

Nbank=U*V;

int n=(U-l)*(V-1);

310

Page 53: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

int flag=l,p,k=l;

while(flag) {

}

cout<<"\nEnter a no. for public key:->";

cin>>p;

Cust c;

if(GCD(p,n)==l && (p>l && p<n))

{

flag=O;

cout<<"\n\nKey granted. This is ur public key";

}

else

cout<<"\n\nKey not granted. Try again";

getch () ;

flag=l;

while(flag)

{

if( (n*k+l)%p==0)

flag=O;

else

k++;

}

Sbank=((U-l)*(V-l)*k+l)/p;

Pbank=p;

}

void Bank decrypt(){

int i=O;

long double h;

do{

h=pow(msg[i],Sbank);

h=fmod (h, Nbank);

311

Page 54: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

msg[i++]=h;

}while (h! =7) ;

msg[i]=7;

}

void Bank

int j=O;

char x;

dformat_msg() {

for(int i=O;msg[i] !=7;i+=2)

{

if(msg[i]>O)

{

}

else

{

if(msg[i] !=5)

{

}

else

x=msg[i+l]*S+msg[i];

x+=96;

mesg[j++]=x;

if(msg[i]==5 && msg[i+l]==6)

mesg[j++]=32;

else

{

}

x=msg[i+l]*5;

X+=96;

mesg[j++]=x;

msg[i]*=-1;

x=msg[i+l]*S+msg[i];

312

Page 55: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

x+=48;

rnesg[j++]=x;

}

}

rnesg [ j ] = I \0 I ;

}

void Bank :: decrypt_sig(){

long double h=pow(hash,Pcust);

h=frnod(h,Ncust);

hash=h;

}

void Bank:: decrypt_cer(){

long double h=pow(cer,Pca);

h=frnod(h,Nca);

cer=h;

}

void Bank:: check(){

get_rnsg();

clrscr();

II'

check_cer();

cout<< 11 \n\nPRESS ENTER • • • • • I

getch();

cout<< 11 \n\n\n 11;

check_sig();

cout<< 11 \n\nPRESS ENTER

getch ();

cout<< 11 \n \n \n 11;

puts( 11 \n");

II • • • • • • I

cout<<"\nMessage Received by Bank(after

313

Page 56: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

decryption):=> "<<mesg;

}

void Bank :: get_msg() {

long double hashl,hash2;

decrypt();

dformat_msg();

}

void Bank:: check_sig() {

long doub~e hashl,hash2;

decrypt_sig();

hashl=hash;

hash2=hashfun(Pcust,Pbank);

if(hashl==hash2)

cout<<"\nSignature 1s Ok";

else

cout<<"\ninvalid signature";

}

void Bank :: check_cer() {

long double cerl,cer2;

decrypt_cer();

cerl=cer;

cer2=this->hashfun(Pcust,Pid);

if(cerl==cer2)

cout<<"\nCertificate is Ok.";

else

cout<<"\ninvalid certificate.";

}

class Cust

private:

public CA{

int Scust;

314

Page 57: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

public:

int fmsg[lOO];

void getData();

void format_msg();

long double encrypt(int);

long double create_sig();

Bank send (Bank) ;

} ;

void Cust

clrscr();

getData(){

315

cout<<"\n\t\t**********Message of Customer************";

cout<<"\n\nEnter the values(relatively prime) for U

& V: \n";

cin>>U>>V;

Ncust=U*V;

int n=(U-l)*(V-1);

int flag=l,k=l;

while(flag) {

}

cout<<"\nEnter a no. to generate public key:>";

cin>>Pcust;

if(GCD(Pcust,n)==l && (Pcust>l && Pcust<n))

{

}

else

flag=O;

cout<<"\nKey granted. This is your public key";

cout<<"\nKey not granted. Try again";

flag=l;

while(flag)

{

if((n*k+l)%Pcust==O)

Page 58: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

flag=O;

else

k++;

}

Scust=({U-1)*(V-1)*k+l)/Pcust;

cout<<"\n\nNow enter the message which u want to

transmit:-> ";

gets (mesg) ;

format_msg();

}

void Cust

int j=O;

format_msg() {

for(int i=O;mesg[i] !='\0' ;i++)

{

if( (mesg[i]%64)>=1 && (mesg[i]%64)<=26)

{

}

else

if((m~sg[i]%64)%5==0)

fmsg[j++]=5;

else

fmsg[j++]=(mesg[i]%64)%5;

fmsg[j++]=(mesg[i]%64)/5;

if((mesg[i]%96)>=1 && (mesg[i]%96)<=26)

{

}

if( (mesg[i]%96)%5==0)

fmsg[j++]=5;

else

fmsg[j++]=(mesg[i]%96)%5;

fmsg[j++]=(mesg[i]%96)/5;

316

Page 59: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

}

else

}

fmsg[j]=7;

if(mesg[i]==' ')

{

}

else

{

}

fmsg[j++]=5;

fmsg[j++]=6;

fmsg[j++]=-(mesg[i]%48)%5;

fmsg[j++]=( (mesg[i]%48) /5};

Bank Cust :: send(Bank b) {

getData();

Pbank=b.Pbank;

Nbank=b.Nbank;

for(int i=O;fmsg[i] !=7;i++)

{

b.msg[i]=encrypt(fmsg[i]);

}

b.msg[i]=encrypt(fmsg[i]);

b.Pcust=Pcust;

b.Ncust=Ncust;

hash=hashfun(Pcust,Pbank);

b.hash=create_sig(};

b.Ncust=Ncust;

cer=cer_cal(Pcust);

b.Pid=Pid;

b.cer=cer;

317

Page 60: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

b.Pca=Pca;

b.Nca=Nca;

return b;

}

long double Cust

long double n;

n=pow (m, Pbank);

n=fmod (n, Nbank) ;

return n;

}

encrypt ( int m) {

long double Cust :: create_sig() {

long double e=pow(hash,Scust);

e=fmod(e,Ncust);

return e;

}

void main() {

CA c;

Cust a;

Bank b;

b. createKey () ;

b=a. send (b);

b. check ();

getch();

}

318

Page 61: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Three Significant Journal Papers

Page 62: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

' ~ .. Modelling

CfiletJouremenf

& Confrol

D PRODUCTION ENGINEERING & MANAGEMENT,

ORGANISATION, HUMAN & SOCIAL PROBLEMS,

ECONOMICS, CllY & LAND USE, TRANSPORTATION

Page 63: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

AMSE PERJODICALS

AMSE publishes 8 periodicals devoted not only to modelling and simulation. but to all problems ci signals. data & systems (Methodologies & examples) under two main titles.

ADVANCES IN MODELLING & ANALYSIS. Centred on methodological aspects:

s~ri~~ A: Mathematical, general mathematical modelling.

~rl~i B: Signal<. infnrmatinn, pattern<, data acqui<ition, tran~i<<ion, prooe<.<ing, cla<<ification

~[~~~

s~rl~~

C: U:

Systems analysis. control & design, simulation. CAD.

Computer tools. statistic & Combinatory scienoes (Games).

MODELLING. MEASUREMENT & CONTROL. Centred on examples in all areas ci activities:

~rle§ A: C'.erw!ral plly<ic.<. el<etronic.<, electrical engineering.

Ss:tls:l 8: Solid & nuid mcochanies & thennies, mechanical systems. robotics. civil engineering.

~rl~§ C: Energetics. chemistry & chemical engineering. eanh resouroes, environment, biomedical problems.

Series D: Production engineering & managemenl organisation, economies, human & social problems, city & land use, transponation.

IN MEMORIAM OF PROFESSOR G. MESNARD, FOUNDING MEMBER OF AMSE.

The Editorial board works under the ~ of: ?relessor Jaime Oil Aluja

Olai rman of the AMSE board. 16, Avenue de Orange Blanche Av. Diagonal, 612

69160 Tassin Ia Demi-Lune ()1021 Barcelona France Spain

Fax: 33 4 7lG4S417 !'ax: 349.3201W47 Phone: 33 4 78343604 Pllone:34 932016155

Telex: 389595 Email: [email protected] (Both addresses can be used for the Editon in Otiel)

Editors jn CWef:

Prciessor Christian Berger-Vachon & Professor Anna Maria Oil Lafuente

EdjLoria! Boo!:

Prciessor Dr. B. Ballaz: PruCcpor Dr. C. Berger-VliChon: ProCessor Dr. J. Oil Aluja: Prciessor Dr. A.M Oil Lafuentt: Professor Dr. F. GonUiez-Santoyo: Professor Dr. A.llorodedd: ProCessor Dr. D. P. Kothari: Professor Dr. L. Kuznetsov: Professor Dr. D. Lakov: Professor Dr. E. !..6pez GonzAlez: Prof..., nr. n. Marino: Professor Dr. C. Morabito:

Professor Dr. R H. ~rez: Professor Dr. A. P. Tacu: Professor· Dr. J. Tinto: Professor Dr. A. Zayegh:

Ecole Suphieure des Affaires, Pierre Mendez F~ Univmity. Grenoble (F~). Mo:dicool Engi,..,;ng, Oaude-Be11'121f1l Univt:Oiity, Lyoo (Fnulco:). Department of Management Economics, University d Barcelona (Spain). Department of Economy and Business Adminiw-ation. University of Barcelona (Spain). Department of Economies and Management University d Michoacan. Morelia (Mlxico). Clectrical engineering, Technical University, Lublin (Poland). Energy Study Dcpanmcn~ Indian Institute oC Technology, New Delhi (India). Autom3tic Systems Control Dcpat1men~ Upet;k Stale Technical University. UpetSt (Russia). Engineering &: Financial applications, llornalic l..aboratories, Sofia (Bulgaria). Department d Management and Economics of the company. University d Leon (Spain). Oepartrnenl c-1 F..:mnmico. ~<ina Univenity. Me.1.<;ina (Italy). Electronics and -Applied Mathematics Department, University of Reggio-Calabria, Recgio­Calabria (Italy). Faculty d Economic. University d Buenos Aires. Buenos Aires (Argentina). Economy Departmen~ Ali Kuz.o University, Iasi (Rumania). Department of Economics. University of Los Andes. MUi(ja (Venezuela). Department of Electric & Electronic deparlmen~ Victoria University d Technology, Melbourne (Australia).

Page 64: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Modellmg D- 2003

Vol 24 n" 3

-··Neural nct"ork approach for financial forecasting ... Walid A. Salameh (Jordan) . -"A h~ bnd approach for selecting an econometric soft\\are package .. Zaycd F. Alhosan (Sandi

Arabia) . 13 - ··Making the best choice using a decision support system based on ELECTRE methodology ...

M. L Rebaiaia: S. Delhoum: J. M. Joam: A. M. Hasnah (Qatar) . . ... 29 - '·Production quality control of an industrial unit using qualitative models and statistical

methods·· George K. Adam: Konstantinos Perakis (Greece) 49

Vol24 n" 4

- '·Exact and approximation algorithms for scheduling unrelated machines under uzzy environment''. Amer Al-Salem: Omar M. Saad: Robert L. Armacost (Qatar-Usa).. I

- '·Genetic algorithms for university course schedulingO>. Enas T. Ghandour: Sami I. Serhan (Jordan)........................... . . ... ... .. . ... . . . ... .. . . . . . . . ... . . . . . .25

- "Effect of quality and maintainability on the performance of production industries in Nigeria··. M. S Abifarin (Nigeria)........... . ... . ...... .. . . 45

- "Application of Cryptography to E-Commcrcc an electronic banking transaction system·· Sunil Karforma: Sripati Mukhopadhyay (India)................. . . .55

Page 65: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Received: Feb. 2003; Revised: July 7, 2003; Accepted: Sept. 11, 2003

Application of Cryptography to E-Commerce- An Electronic Banking Transaction System

Sunil Karforma, Sripati Mukhopadhyay Department of Computer Science, Burdwan University, Burdwan-713104, INDIA

Abstract

Application of cryptography to various fields of E-Commerce where security of information is a

must, is an area of research activities now-a-days. Transaction processing in banking environment

electronically is one such area. In this article we have applied cryptographic technique for

transaction processing in banking environment. An electronic card based banking application has

been developed and transaction takes place between two parties having electronic cards.

Keywords

Cryptography, Banking Transaction, E-Commerce

1. Introduction

E-commerce is generally described as a method of buying and selling products and services

electronically. The main methods of E-commerce [I, 7, I 0, 12] remain in the internet and world wide

web, but use of e-mail, fax, and telephone orders are also prevalent. E-commerce encompasses all

ranges of transactions like Business-to-Business, Consumer-to-Business, Consumer-to-Consumer,

Business-to-Consumer. The fact remains that the commercialisation and the population of the

internet have put the E-commerce at the top of public agenda. We think nothing of ordering the

products we have seen advertised on the television or printed catalogs with a phone call or a fax,

and AIMs are always within reach for quick, easy, and automatic ban~ing. Corporations advertise

through broadcasting networks, and consumers flock to local outlets of national and international

franchise network.

As the world becomes increasingly interconnec:_ ~. particularly through the internet with its open

protocols, forward-looking businesses will be able to make their products available to a global

market, the largest possible market, without having to create and maintain their own private

networks for sales, delivery, and customer support.

The number of businesses devoted to promoting commerce on the internet has been growing

exponentially, but they all share the goal of making commercial transactions over the Internet safe,

simple, and secure and earning profit in the process.

55

Page 66: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

The growth of electronic commerce has created the potential new risks and abuses. Customers

routinely buy products, trade investment and bank online using credit cards, Social security

numbers concern over the privacy and security of on-line transactions in E-Commerce.

The Internet is simply an implementation of protocols, rules of operations, and standards that

define the way in which connected computer communicate with each other. When every connected

system follows these rules, they can communicate with each other even if they use different

hardware, software or operating systems. Connected systems can be connected with different other

system but as long as they all run TCP/IP protocols, they will be able to intemperate.

Hackers can attack the internet in three different ways:

(i) Denial of service

(ii) Information theft

(iii) Information destruction

Denial of service: A denial of service attack occurs when a hacker floods an internet site with

requests, overwhelming the fileserver or communication channel and rendering the site

inaccessible.

Information theft: The theft of customer information can destroy the credibility of E-Commerce.

Since credit cards are used for 90% of all on-line payment, credit card numbers are a frequent

target.

Information destruction: Hackers not sophisticated enough to steal information from a system can

more easily destroy information, typically by introducing a computer virus into the system.

The methods employed to achieve these 'are somewhat various. But can be categorized as either

creating secure and reliable channels to carry transactions across internet connections which are

inherently unsecure and unreliable, or using more traditional channels to carry sensitive

information.

Electronic merchants need to feel confident that they can safely market and deliver their products,

get paid for all products purchased, and not lose any products to theft: Electronic consumers need

to feel confident that they can safely select and take delivery of products, pay for them, and not be

concerned about compromise of payment information. Everyone wants to feel confident that the

individuals they deal with across the internet are who they say they are, to avoid losses to fraud.

When considering on-line commerce, it is important to maintain a perspective and to define a

context. With widespread use of credit cards, consumers and merchants can happily transact

business over the computer network. Highly sensitive banking transactions have been routinely

processed through A TM networks.

56

Page 67: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Commercial transactions over the internet are not only possible, as long as proper tools are used.

Beyond basic issues of security as manifested in authentication of offers, authorization of buyers

and sellers, and verification of content, merchants and conmsumers also need to understand how

these methods as well as the use of digital currencies can also be fitted into a commercial

environment for processing of transactions.

Cryptography is the art and science of secret writing. Traditional cryptography [1,3,4,5] relied on

the use of keys and coding algorothms. Secret Key Cryptography [5] and Public Key

Cryptography[l,4,7,8, II, 12] are two general methods for cryptography.

In secret key cryptography the algorithm, is kept secret and manipulate the message to be coded in

a repeatable way; the key also kept secret, provided a starting point for encoding and decoding

message.

The Secret Key encryption schemes used with todays digital computers, of course are far more

complex than alphabet substitution.The most widely used Secret key Cryptography today is called

"Data Encryption Standard" (DES)[! ,4, 10, II, 12]. DES employs a 56 bit secret key and a series of

permutations to transform a block of plaintext into ciphertext.

In Secret Key Cryptography the length of the secret key is significant. A 56 bit key means that

there are 256 possible key choices. Assuming that cryptographic algorithm is solid, a large size

key means that there are too many possible key choices for an attacker to possibly guess the current

key in a reasonable amount of time.

A major consideration with the actual use of DES and other secret key cryptography schemes is

sharing the secret key between two communicating parties.

Transaction security is the most important aspect for banks and with their large numbers of

customers, cost comes a close second. With increasing service demands, banks require tools and

techniques for transaction security. In this present article we simply explain how banking

transactions [3,7] can be executed securely across an unreliable and unsecure medium in a computer

network like the Internet.

2. Transaction Model

A transaction must be in one of following states: Active, the initial state; Partially Committed,

after the last statement have been executed; Failed, after the discovery that normal execution can no

longer proceed: Aborted, after the transaction has been rolled back and the database restored to its

state prior to the start of the transaction; Committed, after "successful" completion. The state

diagram is shown in Fig.l.

57

Page 68: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Fig. I: Transaction state diagram

We say that a transaction has commilled only if it has entered the committed state. Similarly. we

say that a transaction has aborted only if it has entered in aborted state. Furthermore such a

transaction may be said to have terminated. Once a transaction has terminated, a new transaction

can be processed.

A transaction starts m active state and when it reaches its last statement it enters partially

committed state. At this point, the transaction has completed its execution, but it is still possible

that it may have to be aborted since the actual output may not have been written to disk yet, and

thus a hardware failure may preclude its successful completion. We, must therefore, be cautious

when dealing with observable external writes- that is, writes that cannot be erased. Most systems

allow such writes to take place only after the transaction has entered the committed state. One way

to implement such a scheme is to store any value associated with such external writes temporarily

in a non-volatile storage, and perform the actual writes only at commit time.

A committed transaction will then always be able to complete its external writes except in case of

disk failure. In order to ensure that even a disk failure will not prevent an observable external write,

an approximation of stable storage may be used. For certain applications it may be desirable to

allow active transactions to display data to users. This is true particularly for long-duration

transaction that run for minutes or hours. Unfortunately such output of observable data cannot be

allowed unless we are willing to compromise transaction atomicity. All transaction systems must

ensure atomicity.

58

Page 69: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

A transaction enters the failed state after it is determined that the transaction can no longer proceed

with its normal execution. Such a transaction must be rolled back. Once this is accomplished, the

transaction enters aborted state.At this point of time the system has two options.

Restart the transaction: This can take place only if the transaction was aborted as a result of some

software error or hardware failure which was not created through the internal logic of the

transaction. A restarted transaction is considered to be a new transaction.

Kill the transaction : This usually takes place because of some internal logical error which can be

corrected only by rewriting the application program, or because of bad input or because the desired

data was not found in the database.

2.1 Transaction Model and Database Consistency

A transaction is a program unit that accesses and possibly updates various data items in a database.

Each one of these items is read precisely once by the transaction and is written at most once by the

transaction if it updates that data item. It is required that transactions do not violate any database

consistency constraints. That is, if the database is consistent when a transaction started the

database must be consistent when the transaction successfully terminates. However during the

execution of a transaction it may be necessary to temporarily allow inconsistency. This temporary

inconsistency, though necessary, may lead to difficulty if failure occurs.

Transactions interact with the database system by transfering data from program variable to the

database and from the database to program variables. This transfer of data is achieved using

following two operations.

Read(X, x), which assigns the value of data item X to local variable x, this operartion is executed

as follows:

1. If the block on which X resides is not in main memory, then issue Input(X).

11. Assign the x the value of X from the buffer block.

Write(X, x), which assigns the local variable x to data item X in the buffer block. This operation is

executed as follows

i. If the block on which X resides is in main memory , then issue Input(X).

ii. Assign the value x to X in the buffer block for X.

Both operations may require the transfer of a block from disk to main memory. They do not

however, specifically require the transfer of a block from main memory to disk.

A buffer block is eventually written out to the disk either because the buffer manager needs the

memory space for other purpopses or because the database system wishes to reflect the change to X

59

Page 70: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

on the disk. We shall say that the database system force outputs the buffer block of X if it issues an

Output( X).

When a transaction needs to access a data item X for the first time , it must execute Read(X, x). All

updates to X are then performed on x. After the Transaction accesses X for the last time, it must

execute

Write (X, x) in order to reflect the change to X in the database itself.

The Output(X) operation need not take effect immediately after Write(X,x) is executed, since the

block on which X resides may contain other data items that are still being accessed. Thus, the

actual output takes place later. Notice that if the system crashes after the Write(X,x) operartion was

executed but before Output(X) was executed, the new value of X is never written to disk and, thus,

is lost.

Now we present an algorithm for transaction processing in a banking environment.

3. Banking Transaction Algorithm

Consider a simplified banking system consisting of several amounts and a set of transactions that

access and update those accounts. Let T be a transaction that transfers $50 from account A to

account B. This transaction may be defined as:

T:

Read(A,a);

if not successful read then Roll_back;

a=a-50;

Write(A,a);

if not successful write then Roll_back;

Read(B,b);

if not successful read then F.oll_back;

b=b+50;

Write(B, b);

if not successful write then Roll_back;

Commit;

Where Commit and Roll_back have the following significance:

60

Page 71: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Commit: A Commit ends the current transaction and makes permanent any changes made during

that transaction. While a transaction is in progress no other user can see the data being processed.

Roll_back: The Roll_back statement does the exact opposite of the Commit statement.It ends the

transaction but undoes any changes made during the transaction. Roll_back is useful for two

reasons:

(i) If someone made a mistake, such as deleting the wrong record for a file, Roll_back can be

used to resotore the original data.Roll_back will take back to an intermediate statement in

the current transaction, which means that entire transaction do not have to erase.

(ii) Roll_back is useful if some transaction has started but cannot be completed. This might

occur if the transaction has a logical problem. In such cases, Roll_back allow us to take

corrective action and perhaps try again.

The consistency constraint is that sum of A and B is unchanged by the execution of the

transaction.

Suppose that just prior to execution of transaction T the values of accounts A and B are $1000 and

$2000 respectively. Further suppose that main memory contains the buffer block of A but not that

of B.

\Vhen Read(A, a) is executed the action that takes place is to assign value $1000 to a. When

Read(B, b) is executed however the system must first bring the physical block of B to Main

Memory by executing the operation Input(B). After the completion of Input operation b is assigned

value $2000.

During the execution of transaction T the values of a and b are changed to $950 and $2050

respectively. Thus after the Write operations are executed, in this example, the Output(A),

Output(B) have not been executed. Therefore the values of A and B on the buffer and physical

blocks differ.

Suppose that during the execution of transaction T a failure has occured that prevented T from

completing its execution successfuly.Further ,suppose that this happened after the Output(A)

operation was executed but before the Output(B) operation was executed. In this case the values of

accounts A and B reflected in the database on the disk are $950 and $2000. We have destroyed $50

as a result of this failure.ln particular, it is to be noted that the sum A+B is no longer preserved.

It may be noted, however, that the system must at some point be in inconsistent state. Even if

transaction T is executed to completion, there exists a point at which the value of account A is $950

and value of account B is $2000, which is clearly an inconsistent state. This state, however, is

61

Page 72: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

eventually replaced by the consistent state where the value of account A is $950, and the value of

account 8 is $2050.

Note that it is the responsibility of the programmer to define properly the various transactions so

that each preserves the consistency of th~: database. For example, the transaction to transfer funds

from account A to account 8 could be defined to be composed of two separate programs; one which

debits account A, and the other which credits account B.

The execution of these two programs one after another will indeed preserve consistency. However,

each program by itself does not transform the database from a consistent state to a new consistent

state. Thus. those programs are not a transaction. hut entire two programs collectively behaving like

a transaction.

4. Review of the DES Algorithm for Security

DES operate on a 64-bit blm:k of plaintext. After an initial permutation, the block is broken into a

right half and a left half.each 32 hits long.Then there are 16 round of identical operations called

function f. in which the data are combined with the key. After the sixteenth round, the right and left

half halves are joined, and in final pemJUtation the inverse of the initial permutation finishes off the

algorithm.

In each round, the key bits arc shifted. and then 4X hits are selected from 56 bits of the key.The

right half of the data is expanded to 48 bits via an expansion permutation, combined with 48 bits of

a shifted and permuted key via an XOR operation. sent through 8 S-boxes producing 32 new

bitsand permuted again. These four operations make up function f, The output of function f is then

combined with the left half via another XOR operarion.The result of these operations becomes the

repeated 16 times, making 16 rounds of DES. One round of DES is depicted in Fig.2

If 8; is the result of ith iteration . L; and R; arc the left and right halves of 8;, K; is the 48-bit key

for round i, and f is the function on that iteration that does all the substituting and permuting and

XORing with the Key, then a round looks like:

L;::R;.t

R;=Li-1 XOR f(R;. 1,K;)

Initial Permutation: The initial permutation occurs before round I, the initial permutation and the

corresponding final permutation do not effect DES's security

62

Page 73: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

The Key Transposition: Initially the M-hit kl:y is rcdw.:ed to 56 bit.After 56 bit key is extracted.

a different 48-bit subkey is generated for each of tilL· I 6 rounds of DES in the order I I 2 2 2 2 2 2

I 2 2 2 2 2 2 I respectivc:ly. Subk~:ys.K, arc dch:nnim:d in following manner:

First 56- bit key is divided into two 2X hit halves.

Then the halves are circularly shiflcd lcfl hy either one or two bits depending on the roum.l.

After being shifted, 4H out of)(, hits an: sc·k~:tcd. lkcausc the operation permutes the order of :,it~

as well as selects a subset of hits. it is called compression pcnnutation. 1

The Expansion Permutation : 1· This operation expands the right half of thc data, Ri. frum 32 bits to 48 bits.Because this operation ;

• changes the order of the bits as well as n.:pL·ating CL'rlain hits. it is known as expansion permutation. :

11

S-Box Substitution:

After the compressed key is XORcd with the expanded block, the 48 bit result moves to a.

substitution operation. The substitutions an: performed by 8 S-boxes. Each S-box has a 6 bi( i.t

input and a 4 bit output. The 48 bits ;1rc divided into eight 6-bit sub-blocks. Each seperate block isjj:

operated on by different S-boxcs. !·'·.!

P-Box Permutation:

The 32 bit output of the S-hux substillltion is permuted according to a P-box. This permutatiqni

maps each input bit to an output position: no bit an: used twice and no bits are ignored. This 1 i~· called a straight permutation. /frf Finally, the result of P-Box pc·rrnulalion i' XORed with lhL· lcfl half of the initial 64-hit hlock.Th

1L!1

the left and right halves arc s11 itclwd ;uul anulhn ro111HI kgins.

The Final Permutation:

The final permutation is the inverse of initial pnmutalion. The left and ri'ght haln~~ arc· !n?t exchanged after the last round of DES: instead llw concatenated block R 16Ll6 is used as the i1)p~u~ to tho r;ooJ ""'""'";oo ' :/

Decrypting DES:Using abov~: steps DES algorithm can encrypt 6-+-bit blocks The '·im·'

~~::.;·:~;~~:: ~:,::,: ":~:~::.,::,;";~,:::•: ::~;::::., J. ><> "'"YJ'l Ut dcctYJH " h',, k The ,1 difference is that the key~ must bL: liSL'Li in the reverse orJl!r.That is. if the encryption keys for/~t~h round are kl. k2. U. k4. k5. k(,, k7. kX. k'J. kiO. U I. kl2. kl). kl4. kl5. kl6th.:nthe dccniiJL-,

1.1 .

63

Page 74: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

keys are kl6, kl5, kl4, kl3, kl2, kll, klO, k9, k8, k7, k6, k5, k4, k3, k2, kl in 16 rounds

respectively.The algorithm that generate the key used for each round is circular as well.The key

shift is a right shift and the number of positions shifted is 0, I, 2, 2, 2, 2, 2, 2, I, 2, 2, 2, 2, 2, 2, I

R;.J

Expansion Pennutation

P-Box Pennutation

Fig.2 : One Round of DES

S. Algorithm for Banking Transaction using DES

64

Compression Pennutation

Page 75: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

An electronic card based banking application has been developed by applying cryptography. The

system provides a secure debit card suitable for regions where poor telephone services make on­

line verification impossible. Both customers and merchants have cards. Customers can use their

cards to transfer money to merchants. Merchants can then take their cards to a telephone and

deposit the money in their bank account.Customers can take their cards to a telephone and have

money moved onto their card. There is no intention to provide fraud.

Here is the communication protocol between party A and party B. Both parties just plug their cards

into a machine and wait for it to complete the transaction . When party A gets his card, he is given a

key pair kl and k2; the bank calculates them from his name and some secret function.

Only the card of party B have the secrets necessary to work out these customer keys.

Step I: Party A sends his name A, party B 's name B and a random number, R •. encrypted using

DES: first with k2 and then with kl. Party A sends his name clearly in following form:

A, Ek1 (Ek2 (A, B, Ra))

Step2: Party B calculates kl and k2 from party A's name. He decrypts the message, confinns that

A and Bare correct, then encpYpts party A's unencrypted second message with k2.

Ek2 (A, B, R.)

Party B does not send this message to party A .56 ~its of the ciphertext become k3.Party B then

sends his name to party A, name of party A, and another random number, Rb, encrypted using

DES:

First with k3 and then with kl in following fonn:

Ek1 (Ek3 (B, A, Rb))

Step3: Party A computes k3 in the same manner party B did. Party A decrypts party B's message,

confirms that B and A are correct, then encrypts B's unencrypted message with k3 in following

form:

Ek3 (B, A, Rb)

A does not send this message to B. 56 bits of the ciphertext become k4. A then sends his name to

party B, with name of party B , and the digital cheque, c . This cheque contains the name of the

sender and recipient, a date, a cheque number, an amount, and two MACs, all encrypted using DES

in following form using DES: first with k4 and then with k I.

One of the MACs can be verified by party A's bank and another can be verified by the clearing

center. Party A debits his account by the correct amount as follows:

Ekl (Ek4 (A, B, c))

Step4: Party B computes k4 in the same manner party A did. Assuming all the names match and

the cheque is correctly formed, he accepts it for payment.

65

Page 76: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

6. Conclusion

A good point about this protocol is that the encryption key for each message depends on the

previous message. Each message doubles as an authenticator for all previous messages. This means

that someone can not replay an old message. The receiver can never decrypt it.

Here both cards store records for every transaction. When the cards eventually go on-line to

communicate with the bank the merchant can deposit his money and the customer can get more

money - the bank uploads these records for auditing purposes.

A tamperproof hardware prevents either participant from messing with the data.

Party A cannot change value of his card. Extensive audit trails provide data to identify and

prosecute fraudulent transactions. There are universal secrets in the cards. MAC keys in the

customer cards functions to converts customer names to k I and k2 in the merchant cards. But these

are assumed to be difficult to reverse-engineer.

This scheme is more secure than either paper cheque or traditional debit cards. The system can

protect against fraud from opportunistic customers and merchants.

The message exchange is an excellent example of a robust protocol, here every message names both

parties, includes unique information to ensure freshness and depends explicitly on only all the

messages that came before it. Although transaction is being taken place between two parties having

cards but it can be equally applied between the party and bank itself-that is, credit or debit, in the

customer account may be done.But in electronic banking transaction system it is assumed that there

is no scope of rolled-back transaction due to power failure.Once a transaction starts it must be

successfui.The hardware, software, everything,should be arranged accordingly.

References

I. Bruce Schneier, Applied Cryptography , 2"d edn, john Wiley &Sons, Inc.Delhi,l996

2. Ivan Bayross, Commercial Application Development using ORACLE DEVELOPER 2000, BPB

publication, New Delhi, 1999

3. Henry F.Korth & A. Silberschatz, Database System Concepts, 2"d edn, Mcgraw-Hill inc., New

Delhi, 1991

4. Pete Loshin & Paul A. Murphy, Electronic Commerce, 2"d edn, Jaico Publishing House,

Mumbai, 2000

5. S. Karforma, S. Mukhopadhyay, Balaram Bhattcharya, "Data Security in Information Age,"

SAJOSPS, Vol.2, No.2, pp.I08-112, 2002

66

Page 77: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

6. S. Karforma, S. Mukhopadhyay, A.M.Midda, "Internet: A Cryptosystem for Internet Security,"

CALIBER 2002, pp.209-216, 2002

7. R. C. Fairfield, A. Matusevich, and J. Plany, "An LSI Digital Encryption Processor (DEP) , "

IEEE Communications, Vol. 23, No.7, pp. 30-41, 1988

8. M. Greenstein, and T. M. Feinman, " Electronic Commerce : Security, Risk management and

control, "4'h edn, Tata Mcgraw-Hill company Ltd., 2001

9. R.L.rivest, A. Shamir, and L.M. Adleman, "On digital signatures and public key cryptography ",

MIT Lab. for computer science Technical Report, MIT/LCSffr-212,jan,1979

10. Alfred J. Menezes, Paul C. Van Oorschot, and Scott A. Vanstone, " Handbook of Applied

Cryptography". CRC Press, 1996

II. A. S. Tanenbaum, "Computer Networks", third edition, New Delhi, Prentice- Hall Inc., 1999

I 2. M. J. Wiener, "Efficient DES Key Search," Technical Report TR- 244, School of Computer

Science, Carleton Univ. , Ottawa, 1994

67

Page 78: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

www.ultrascientist.org ISSN 0970-9150 Regd. No. R.N. 52077/90 Email : [email protected]

JOURNAL OF ULTRA SCIENTIST OF PHYSICAL SCIENCES

Post Box-93, City GPO, Bhopal-462 001 (India) (An International Journal in Physical Sciences)

Ref. No nJSPs/ fllafj,;, /11ft/ 20-D !:-- Datei!.ll/4./.o.S:. ............ ..

Dear DrS. ~o.jS. MLJ/.e~'!rf • This is to acknowledge with thanks the receipt of your manuscript entitled ___ _

you will be infonned in due course about the comments of our referee and the decision of Editorial Board.

has been accepted for publication in' Journal of Ultra Scient Vol /7 No 2-M 200S-

To expedite the process of publication kindly send your subscription and of your coauthor( s ).

Please send at your earliest a crossed bank draft of Rs,/ X Cf_ c;r; f~ drawn in favour of Journal of Ultra Scientist of Physical Sciences as printin~-making charges failing which the paper may not be included in the coming issue. ·

It is regretted that as per comments of the referee your manuscript entitled

has not been found suitable for publication in Journal of Ultra Scientist of Physical Sciences.

Kindly arrange the contents of your !llanuscript according to the fonnat of our journal and send back to us.

Subscription Printing charges Block making charges Postal charges for Reprints Total

- Rs./ - Rs./

~oo:! o o fiJ!<sr~'TJ)~ 6ao~oo /

~ ( Dr. A. -H. Ansari )

Chief Editor

Page 79: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Digital Certificate for Secure Transactions in E-Banking

S. Karforma*, S. Mukhopadhyay

Department of Computer Science, University of Burdwan, Burdwan-713104, INDIA

*E-Mail: [email protected]

Abstract

Transaction processing in a E-Banking system requires some technique for identification, authentication and

non-repudiation of the customer. Digital certificate, using cryptographic technique, implements above three

elements of security needed for E-banking. In this paper we have discussed how digital certificate can be

used for secure transactions in E-banking.

Keywords: Digital Certificate, PKI, Security, E-Banking

Cryptography is necessary for the success of E-Banking [ 1 ,8] to ensure the privacy and integrity of

transactions [1 ,2,3], as well as to assure both parties that they are communicating with whom they think they

are. Secret key cryptography [1] is essential to keep message private, but a priori exchange of keys is

needed. Public key cryptography [I ,2] solves the key exchange problem by allowing the sender and receiver

to exchange this information. Digital certificates [4,5] provide not only the information with which to

conduct secure electronic transactions, but also the additional information necessary to build the trust

relationship between the customer and the bank.

Competition in the financial services industry has lead banks to deliver services more efficiently. Digital

certificates issued pursuant to a Public Key Infrastructure (PKI) [4,5] system are an effective means to

deliver these services. By using complex mathematical algorithms, PKI permits the generation of "key

pairs" consisting of a private key and a public key, which are unique to a user or subscriber. A digital

certificate is simply an electronic message "signed" by the issuer of the certificate (known as Certification

Authority, CA) with that CA's private key, so that it uniquely identifies the user holding the issued key pair.

The user keeps his private key from disclosure, but shares his public key with the world to decrypt and

authenticate message sent by that user: only the user's public key can open message sent by him. The

significance to this relationship is that all parties trust the CA to confirm that the user to whom the certificate

is issued is who he or she purports to be. This is often referred to as a "trusted third party'' system. At times,

a Registration Authority or RA assists the CA in processes that involve local contact with a subscriber and

performs part of the issuers work as specified in a contract. A digital certificate is an identification document

in addition to significant security produced by digital signature [4,5]. For most E-Commerce [4] applications·

Page 80: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

digital certificates use a fonnat defined in international telecommunication union telecommunication

standardization sector (ITU-T) recommendation known as X.509 (6]. Among other information, the content

(C) of a digital certificate consists of owner's infonnation (I) and owner's public key (K). The content is

signed digitally by CA. If we assume that the RSNMDS [4,5] signature method is used, then the digital

signature is given by ERsA[HMo5[C) J Key private, eA] where Key private, eA is the private key of the CA. During

transaction between client and server web browsers establish a secure Secure Socket Layer (SSL) (7]

session. During the initiation of the SSL protocol, the server will send its digital certificate to the client

machine, and client machine will validate the certificate proving the identity of the server to the client

machine.

Internet being an open network, the risks inherent in E-Banking are as follows:

(I) Data privacy and confidentiality: compromising the confidentiality of subscriber evidence

and account infonnation.

(II ) Data integrity: compromising the integrity of Repository infonnation.

(III ) Authentication: pretending to be a legitimate Web site by "IP spoofing" (setting up a phony

site that accepts traffic directed to the real one, sort of like setting up a phony A TM that

records PIN keystrokes) or pretending to be an account holder.

( IV ) Repudiation: claiming that a party did not engage in a certain transaction, or claiming that

it took place without his or her authorization.

( V ) Flaws in access control and system design, includin~

a) System architecture and design.

b) Security scanning products

c) Logical access controls such as passwords

d) Security flaws, and bugs/active content languages (Java, ActiveX).

e) Viruses and malicious code

Algorithm below demonstrates how a customer named Alice gets a digital certificate from CA

Step 0. Alice sends two pieces of infonnation to CA, named Alice's identity and his Public Key, P Alice·

Step I. The CA cryptographically binds the parts of the certificate by encrypting them with CA 's secret key,

SeA (SeA is also called the certification key) and sends it to Alice. CA 's public key, PeA (PeA is also

called the verification key). The CA broadcasts its verification key widely, so that no one can easily

replace it with a false key.

Page 81: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

Algorithm for authentication of Alice to Bob

Step 0. Initialization steps:

A. Bob creates his public key pair Psob and Ssob· He publishes Psob so everyone can find it.

B. Alice creates his/her public key key pair P Alice and SAiice· He sends his identity information

IDAlice and P Alice to theCA, and theCA issues Alice his certificate { P Alice+ IDA! ice } SeA·

Step I. Alice composes a three part transaction to the Bob:

Alice writes the message to the Bob, which he encrypts with Bob's public key, Paob

A. Alice then forms a digital signature for the message:

i. Alice passes it through a hashing function to form the hash hashAiice .

ii. Alice encrypts the hash with his secret key, SAii~e. to create his digital signature

{hash} S Alice·

B. Alice attaches his certificate.

Step 2. Alice sends his transmission to the Bob (Bank) over the Internet. The transmission consists of

the encrypted message, the digital signature and Alice's digital certificate

Step 3. Bob (Bank) receives Alice's three-part transmission

A. Bob uses his secret public key, Ssob , to decrypt the encrypted message. Bob interprets the

decrypted message as message I .

B. He hashes message! with his hashing function to obtain hash I.

C. He validates the plaintext portion of the digital certificate by:

i. Hashing the plaintext portion to obtain the "hash Alice!"

ii. Decrypting the CA's signature using the CA's Verification key, PCA, to obtain

"hash Alice"

iii. Bob now compares hashAiice with hashAiicel· If they are identical, Bob can conclude that

Alice's certificate is valid as created.

D. Bob now uses the P Alice from the plaintext portion of Alice's digital certificate to decrypt the

digital signature to obtain the hash that Alice computed.

E. Bob compares hash 1 with hash. If they are identical, Bob validated the signature and

authenticated Alice because he knows that:

i. The message arrived unmodified from when it was signed.

ii. P Alice properly decrypted the digital signature

Page 82: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

iii. Alice signed the message because only Alice knows SAiice' and only Alice could have

created a signature that could be decrypted with P Alice

iv. P Alice was obtained from trusted digital certificate that cryptographically bound P Alice to

Alice's identity, and now Bob knows that the real Alice owns P Alice and real Alice

signed the message

v. In the future, Alice cannot deny that Alice signed the message because only Alice

knows SAlim and the digital signature was created with the use of SAiice- Because Alice

cannot renege on the signature on his message, the message is said to have property of

non-repudiation.

In conclusion we should point out that there is no doubt that the Internet possesses numerous risks for the

financial services like E-banking, including data privacy, integrity, authentication, repudiation and denial of

service. With implementation of digital certificates, third party security assessments and E-Business

insurance, the financial services industry will realize a level of safety, reliability and trust in an efficient

manner to use the Internet for secure electronic transactions.

References:

I. S. Karforma, S. Mukhopadhyay, "Application of Cryptography to E-Commerce- An Electronic

Banking Transaction System", International Journal Modelling, Measurement & Control (D), Vol

24, No.3-4 ,AMSE, France pp. 55- 67(2003).

2. Karforma, S., Mukhopadhyay, S. and Bhattcharya, B. "Data Security in Information Age",

SAJOSPS, Vol.2, No.2, pp.I08-112 (2003).

3. Karforma, S., Mukhopadhyay S. and Midda, A. M. "Internet: A Cryptosystem for Internet

Security", CALIBER 2002, pp.209-216 (2002).

4. Chan, H., Chang, E., Lee, R., and Dillon, T. "E-Commerce: Fundamentals and Applications", John

Wiley & Sons, New York ( 2002)

5. Graff, J. C." Cryptography and E-commerce", John Wiley & Sons, New York, (2001).

6. ITU-T, "Summary ofiTU-T Recommendation X.509", www.itu.int (2001).

7. Rescorla," SSL and TLS : Designing and Building Secure Systems", Addision- Wesley, ( 2000).

8. Spinellis, D. " E-Commerce Technologies and Infrastructure", Lecture Notes,

http:// www.spinellis.gr/isdilindex.htm, (2004).

Page 83: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

~ ~- - ~ "' •• '-...~ • - • • • • ' • • .. " < ••

JJ-IIr('J J)JAN.-JUN.2002!

The advancement of computer techno I· ogy has made this age Information Age and security of information is a must. Manage­ment can take correct decision based on in· formation only. Data

Entering a data processing system and the programs processing the data must be kept secure . By security we mean protect· ing the data and programs against accidental or intentional modifications or destructions or disclosure to unauthorized persons. The following requirements must be made to en­sure the security. I . The data and programs must be protected

from theft,tire,disk corruptions and other type of physical destructions. Dupli· cate copies are to kept in a place away • rrun , l-'UllT))U reT~.

2. Data should be reconstructable in case of loss despite precautions. Back up cop· ies of master files and transaction files are to be kept.

3. For data security guarding of user's data and programs against interference by ex­ternal entities passwords system should be introduced. If password system is bro­ken by an intruder a secret transforma­tion may be used to transform the stored data. Even if the data is accessed it will be meaningless to the intruder

4. Only authorized persons should be al· lowed to use computers. Password sys· tern should be used to prevent unautho· rized access Computer viruses also affects file $ecu­

rity .A virus is a small program written by a mischievious programmer and spreads by copying itself from one computer hard disk to another and there by destroying data on hard disk. Virus can also spread through com­puter network . It is essential for a security system to protect files from virus. One physical control is not to allow to copy floppy disk from unknown sources. Anti Virus softwares such as scandisk, Norton's antivirus etc should be used.

Data security in a computer network is incorporated using cryptography techniques. Cryptology is concerned with guarding user's data from a third person when the data is being communicated over communi­cation channel in a computer network.

Cryptology consists of two stages: En­cryption of data and Decryption of data. The original form of data is called plaintext. After application of encryption, an algorithm, by which plain text is transformed to Cypher text or may be called encrypted data. The c_yphertext is decrypted using another algo­rJthm.tct-tWain.th~JU'is>Jmu.rtma.._

We represent encryption and decryption of data (I) using algorithms En &De with

108

Page 84: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

key K as the application of functions Enk and DeK respectively

Enk(d): d encrypted by algorithm En using key K.

Dek(e) : e decrypted by algorithm De using same key K, the value of K must be kno~n to the users. Where Enk and Dek sat­isf:f'the following relation:

Dek(Enk(d)) = d for all d.

2. Attacks on cryptosystem: An intruder can manipulate encrypted

data knowing Dek and theoratically it is pos­sible to find out Dek. An intruder may use one of the following approaches to deter­mineDek.

(i) Cyphertext only (ii) Known plaintext (iii) Chosen plaintext In cyphertext only method the intruder

has to bank on extraneous knowledge of Cypher text in order to guess about Dek

In known plain text attack is possible if an intruder can secure within the computer system from which he can observe cyphertext corresponding to known plain text.

In chosen plaintext an intruder is able to observe the encrypted form of any data of his choice that is he can choose any d and observed Enk(d) and can guess about Dek. Details about attacks has been described by Meier and Staffelbach (2)

3. Encryption techniques: Encryption can be of two types (i) Block Cypher technique (ii) Stream Cypher technique Encryption techniques has been

disscussed by Leample (3) In our present work a cryptosystem has

been developed using stream cypher tech­nique implemented by Linear Feedback Shift Register (LFSR)

4. IMPLEMENTATION OF ENCRYPTION

Encryption is done by stream cipher. Stream Ciphers operate on bits. A random sequence of bits equal to length of the mes­sage is generated. This forms the key stream which is exclusively Xored (XORed) with the message producing bit by bit encryption. Stream ciphers operate on small units of plaintext, usually bits. Stream ciphers can be designed to be exceptionally fast and hence popularly used in cryptographic applica­tions. The chief problem. however, is the generation of a keystream which is truly ran­dom in order that the system may be per­fectly secure. In practice. a pseudorandom sequence generator is used at both the sender and receiver ends, set up with the same ini­tial conditions. Such a generator is commonly implemented using Linear Feedback Shift

109

Register (LFSR) An LFSR is a connected series of regis­

ters, each of which can store a binary value. The connections are made in such a way that the resulting recurrence relation can be repre­sented by a polynomial. This polynomial is the connection polynomial of the LFSR. When this polynomial is chosen to be primi­tive, the period of the pseudorandom se­quence generated is of maximal length , i.e. 2d-1 where d stands for the length of the LFSR or number of shift registers. The con­nection polynomial for LFSR is l+X+X4. The initial condition of the primitive poly­nomial is set, to begin with in order to com­pute LFSR's outputs. At each clock-pulse the values of each register are shifted to the left-hand one. Thus the values of the leftmost register are shifted out. This is the output of the register for given clock-pulse. The next outputs of for each clock-pulse are deter­mined by XORing the bits, corresponding to the bit-position of the primitive polynomial and transferring the value into the right-most register simultaneously. The pseudorandom sequence thus generated has random occur­rence of a zero and one.

The basic system for encryption is as follows:

The outputs of several LFSRs are com­bined using a non-linear combining function in order that certain types of attacks on the system (utilizing the linearity of the system) can be avoided. The output of the combining function is the keystream which is bit-wise XORed with the coded plaintext (for example, using the Murray code ) to form the ciphertext. It can be observed thatJn order to recover the coded plaintext we need to only XOR the keystream with the ciphertext. Implementation:

I: LFSR stream generation: Appendix 2.1 Inputs :The length of the polynomial n, the connection polynomial e.g. the poly­nomial l+x+X4 is represented as I 0 0 I, the initial condition (of length equalling the degree of the polynomial, d) the de­sired length m of the output sequence and the no. of taps!. Output: A pseudorandom sequence with period 2d -I.

5. The LFSR-based encryption system: Ap­pendix 2.2

Three LFSRs arc combined using a mul­tiplexer i.e.

y = x,X 3 + X 2 X 3

to form the keystream Y. This bit wise XORed with the plaintext (a message in En­glish coded into binary using the Murray code) to produce the ciphertext. Inputs :A message in English and the LFSR

polynomials. Output : The ciphertext.

5. METHOD AND IMPLEMENTATION OF DECRYPTION

Attacks on cryptosystems can be a vari­ous kinds viz. Ciphertext only, Know Plaintext and Chosen Plaintext. In this piece of work, we shall implement a ciphertext only attack. As the name indicates, the ciphertext alone is available to the 'adversary' in this type of attack. The attack considered in the present work, hings on the existence of some correlation between the generated LFSR se­quences and the received ciphertext and is hence, termed as a Correlation attack. For the stream cipher architecture outlined in the last section. we shall assume that the LFSR polynomials and the combining function, are both known. The initial conditions form the secret key. Once these are determined, the keystream can be generated and the ciphertext decrypted.

When he ciphertext is correlated with each of the LFSR output sequences, a 'divide and conquer' approach may be adopted and the initial conditions of each LFSR determined separately. If Mi represents the number of initial conditions of ith LFSR, the total num­ber of initial conditions for the composite

kcystream is. n:.,M, Using the divide and

conquer approach, this reduces to. :2.~ M,

Note that MI =2di-l, where di and this re­sults in an enormous amount of savings in computation if all initial conditions are to be tested. In the algorithm in considered here, we consider only one LFSR without loss of generality (since each LFSR is attacked sepa­rately). Further. since we assume that a cer­tain correlation exists between the ciphertext and the LFSR output sequence, say Prob (ciphertext = LFSR output sequence) = p, we generate a ciphertext satisfying this re­quirement and test the algorithm on this (de­tails cab be found in the Implementation de­scribed later).

Algorithm: I. Let us consider the unknown initial state

of the target LFSR, denoted u = (u I, u2, .................. , ud) We can express each ui as some known linear combination of the initial stale u, i.e.,

,, ui= Iw,JuJ \;ii~l

j=l

where wij, i ( I, I ( j ( d are known; constants. Define the initial state polynomial, de­noted U(x), to be U(x) = U(x I. x2, ...................... , xd) = u 1 xI + u2x2 + ................... + udxd.

Page 85: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

The correlation between ui and zi can be described by introducing a noise vector eas e = (e I, e2, ............ ,eN), Then we model the correlation by writing z = u + e, giving z = (U(x I)+ e I, U(x2) + e2, ................. , U(xN) +eN). where xi are known.

2. Since U(x) is linear polynomial, the sum of these two noisy observations will give rise to an even more noisy observation in the point xi + xj, since P(zi + zj = U(xi + xj)) =P(zi + zj = U(xi) + U(xj)) =P(zi = U(xi)) P(zj = U(xj)) + P(zi = U(xi)) P(zj ( U(xj)) = (1/2 + ()2 + (1/2- ()2 =1/2 + 2(2

Now we want to check whether the hypoth-esized value (. ...... , ) of (u I, ..... , uk) is correct or not. This is done by first se­lecting a certain (d-k) tuple si, and then by finding all linear combinations oft (here t = 2) vectors in {xI, x2, ........... , xn}.

I

(i)=I,x.i ~I

We get the form (i) = (1, ............... , k, sk+ I. ....... , sd) for all values of I, ......... , k (not all zero). Let

Si be the number of times the tuple si can be formed in this way.

From out previous arguments, we can get the relation between U(x(i)) and (i) in the form.

U ((i)) = (i) + e Where e is a noise vector It is equivalent expressed as

k d

~:UJxJ + I,uh z(i)+ e i•l jook+l

This can be rewritten as

d

where W = . 2, u is i j•k+l

Suppose is correct. Then k

I, (u i + u Jx i = 0 jool

k

• l,ujxj +z(i)

jol

and p (W+e) = 0= p ( 2,ujx j = i. (i)) j=l

k

Let Ti = I, whenever L u iX. i = i. (i) and z(i) j=l

and num = (Ti If W = 0, P(W+e) = 0 = 1/2-2(2

1i:fi,J'JJJJAN.·JUN.20o21

It W = 1. P(W+e) = 0 = 1/2-2(2 where 1/2+2(2 and 1/2-2(2 are denoted by Pw. (num ( Bin (Si, pw) where nub has a binomial distribution Bin (Si, pw). with pw being one of the two probabilities. If is wrong, num (Bin (Si. l/2)

3. In order to separate between the two, we calculate

dist = !ts-2•num)' ,., for all combinations of (Sk +I, ....... , Sd) for the two candidate values of ui. Fi­nally, we select uj for the highest dist value.

4. In order that above algorithm can be ex­ecuted sequentially, the values of k are varied from I to d-1 and uk calculated. Note that each step, the ui values calcu­lated in the earlier ones, are used, so that a choice between 0 and I only, has to be made.

5. In order to determine ud, we consider both the candidate values and generate the cor­responding LFSR output sequences. We then decide in favour of the one that gives rise to the sequence which has the greater number of matches with the ciphertext.

Implementation : I. LFSR stream and ciphertext generation:

Appendix 3.1 Inputs: Degree of the polynomial, the coefficients of polynomial and initial conditions. The value p =· Prob (Ciphertext = LFSR output sequence) is kept fixed at 0.6. Outputs : LFSR output sequence and Ciphertext.

2. Expressing every bit of LFSR sequence in terms of the initial conditions: Ap­pendix 3.2 Inputs : Same as above. Outputs : A matrix with m rows and d columns. The ith row corresponds to the ith bit of the LFSR output sequence and a 'I' in the jth column of that row indicates that the bit is dependent on the jth initial condition or uj.

3. Implementation of the fast correlation attack. Inputs : Same as above. Outputs: The initial conditions u I, ....... , ud identified to be the correct ones.

6. CONCLUSIONS The algorithm was found to work well

for a system using an LFSR polynomial . Vari­ous sets of initial conditions were used and the algorithm was able to identify them cor­rectly in each case. REFERENCES

I. D.M.Dhamdhere : "prolection and securitlsystem Programming and operating system 2/t, ·w_;.3B8·603, ., I 1999, TMH , l 2. W. Meier, and 0. Staffelbach" FastcorielationattllCI:s on certain stream ciphers", Journal of c}y#og~ vol·

3. A.Leampk:, "Cryptology in transitiorl" , computing 1.19S9.pp-159-J?6 , .

1,

Servey. Vol No-4, pp-285-303 _'1 . I 4. S. Karforma, S. Mukhopadhyay, A.M.Midda: ntcmet:

l'l : ~

A cryptosystem for Internet Security", CA·ll.JBER-[2002, 2002, pp-209-216 : • S.M. M.Wofsey. Advances in computer secunltY. mana. ge·

' > I ment, (1983) John wiley,ncwyork • 1

//APPENDIX 2.1 for generation of LFSR Strffl)" #include<stdio.h> '. · #i nclude<stdlib.h> #include<math.h> int al5000(,b[5000(,i,m,n: i ~ FILE •ftl,*ptl II function for reading LFSR void lfsr_read(FILE *ft) I fscanf(ft, "%d", &n):l/ n is the degree otJll:llyno+al

for( i=O;i<n; i++) ,h 1· fscanf("%d", &a(il):l/ reading ofpolynorru. ill , · for(i=O;i<n;i++) ":' · . . fscanf(ft,"%d",&b!i !);}/reading of initial condition ~f the

~,0~~:r~;,!.~d·:.&m):/lbit length oflfsr's outp~·{·· . }II end of lfsr~read() "j ' 1 II function for; writing LFSR's output : :. . void lfsr_write(FILE •pt) ! >

I inl sum=O, temp,k=O; do I for(i=O;i<n;i++) sum=sum+ali l•b[i I; temp=sum%2: i=O: while(i<(n-1 )) ( blil=bli+ll; i++:

bl n-l}=temp; sum=O: k++:

while(k!=m); l main() ft I =fopen("input.dat" ,"r"); lfsr_read(ftl);//lfsr_read() is culled pt I =fopen("lfsr.dat","w"); lfsr_write(ptl):lllfsr_write() is called close(ftl ); close(ptl ); I input.dat Degree of polynomial 4 polynomial: I 0 0 I Initial condition: 0 I 0

Length of LFSR's output: 20 lfsr.dat: 0 I 0 I I 0 0 I

110

Page 86: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

0 0 0

l 0 I 0 I l //APPENDIX 2.2 II genemtion of LFSR stream and CIPHER-TEXT #include<stdio.h> #include<stdlib.h> #include<math.h> i t

~ ICOLb(ml~IDJic(IDJtJ\ml\j:!ID>\P.rol\qiDJJI{IDJJ int i,n,o,il; int u,l,z,v;

FILE •ft!.•ft2.•ft3 .. ft4,•ptl .. pt2 .. pt3 .. pt4 .. pt5; void lf~r_read(FILE •ft) ( .

fscanf(ft,"%d",&n);//n is the degree of the polynomial for(i=O;i..:n;i++) fscunf(ft,"%d", &ali ():I/ reading of polynomial for(i=O; i<n; i++) fscunf(ft."%d", &b(i(); //reading of initial condition of the polynomial fscanf(f~"%d",&m};

I

//Function for writing LFSR's output void lf~r_write(FILE •pt. int c(l) int sum=<l,temp.k=O; do \c\kjzbjOJ; fprintf(pt,"%d\n",c(k 1): for(i=O;i..:n;i++} sum:sum+a(i J•b[il: temp:sum%2: i=O; while(i<(n- I}} (bliJ=b(i+l J; i++;

bl n-1 !=temp; sum=O; k++;

I while(k!=m};

1 void mull(int ~ll.intt(J,int ull}// function for multiplica­tion of two LFSR ( intj=O; do

l sljl:t(jJ•u!jJ; printf("%d".~(j J); j++;

I while (j!=m}; printf("\n\n");

I rroin() ( for(i=O;i<25;i++) printf("\n"); ftl :fopen("ss.dat","r"): lf~r_read(ftl ):II lfsr_read() is called pt I =fopen("U.dat", "w"): lfsr_write(ptl,d):l/lfsr_write() is called for xl close(ftl ); close(pll ); ft2=fopen("ss.dat","r"): lfsr_read(ft2); pt2=fopen("ttl.dat' ,"w"); lfsr_write(pt2,e):J/Ifsr_write() is invoked for X2 close(ft2);

111

close(pt2); ft3=fopen("ss2,dat" ,"r"): lfsr_read(ft3); pt3=fopen("tt2.dat"."w"); Jfsr_write(pt3,f):J/Ifsr_write() is invoked for x3 close(pt3); close(ft3); i=O: II generation of combining function printf("complement of x31n"); do [glil=fliJAI; printf("%d",g[i]); i++; Jwhile(i!=m): printf("\nln"): printf("multiplication of compx3&x I isln"); mull(p,g,d); printf("multiplication of x3& x2 is\n "); mull(q.f.e): printf("the key stream is\n");//generation of key stream pt4=fopen("tt3.dat","w"): 1=0; do (r[IJ=p!Jl"q(J) fprintf(pt4,"%d",r(IJ); )++; l while(l!=m); fprintf(pt4,"\n"); printf("lnln"): close(pt4): ft4=fopen("ss3.dat","r"): for(o=O;o<m;o++) fscanf(ft4,"%d",&w( ol}; printf("the coded mes~age\n"); for(o=O;o<m;a++) printf("%d", wjoJ); printf("\n"); II genemtion of cipher-text pt5=fopen("tt4.dat", "w"); z=O: fprintf(ptS,"the cipher-text is \n"); do I ylzl=rlzJAw(z); fprintf(pt5,"%d",y(zl}: z.++:Jwhile(z.!=m); fprintf(pt5,"\n"): close(ft4): close(pt5); printf("coded message \n"); ii=O: do (xx(il)=flii]Ay(il];

printf("%d",xx(il J); il++; I while(il !=m): printf("ln");

I II APPENDIX3.1 II GENERATION OF LFSR-STREAM AND CIPHER TEXT//

# INCLUDE <stdio.h> # include < stdlib.h> #include< math,h> int a! IOOJ,B(IOO]di4000J,e(4000],m; int i,i l,i2,i3,i4,j2,n,o,t,r; int ul IOJ,jjj,iik,ijk.kl,kind; int jj=O,i I =O,index,total,cnt,doub; float v,j=O.O,i=O.O. w; FILE •ni .. ft2 .. ptl .. pt2; viod lfsr_read(FILE •ft) t•function for reading lfsr •1 I fscanf (ft, "%d", &n); I" n is the degree of the polynomial •t for (i=O; i,n; i++) fscanf( ft, "%d", &a(ij); for (i=O; i,n: i++) fscanf( ft, "%d", &b{i]);/* initial con­dition~ •t fscanf( ft, "%d", &m):i• bit length ofLFSR 's output•/ fscunf( ft. "%d", &tl: 1• no.of taps •t l viod Jfsr_write(FJLE •pt,int ell) !•function for writing Jfsr •1

inl sum=O, temp, k=O; do

I cfk]=b!OJ; 1• output of LFSR •1 fprintf(fp."%d\n", cJkJ; for (i=O; i,n; i++) sum=sum+ ali!"bliJ; temp=sum%2; i=O; while (i, 9n-l)) I b!il=bli+l 1: i++:J

bl n-11= temp: sum=O; k++;

I while (k!=m);

I main() \ ftl = fopen("input.dat","r"); Jfsr_read(ftl ); 1• Jfsr_read() is invoked •1 ptl = fopen("lfsr.dat","w"): Jfsr_writc(ptl .d); !• lfsr_write i~ invoked •t close (ftl): clo~e (ptl); pt2 = fopen("cipher.dat","w"); 1• Generaiio~;o~j'ci-

pher ~tream •1 for(i=O; i,m: i+1-l I

I

v= (((noat)rand())/((flout)RAND-MAX));, if ( v,=.6)e{i l=dlil else eli 1=1 'd(iJ; fprintf (pt2,"%d\n",e( i (): I close(pt2):

contents of input.dat Degree of polynomial: 4 Polynomial: I 0 0

Initial condition: 0 I 0

Length of LFSR's output 20 Number of taps: 2

Contents of lfsr.dat (Jenemting LFSR- Stream: 0

0 I I 0 0

0 0 0

I 0 I 0

Contents of cipher.dut The cipher-text: 0 I 0 I 0 0

Ji·l lif>JJjJAN:-JUN.2002I 1 ~~ ... 1

Page 87: Appendices - Information and Library Network Centreshodhganga.inflibnet.ac.in/bitstream/10603/63998/18/18_appendices.pdf · Appendices . APPENDIX 3.1 ... 1 *pt3 1 *pt4 1 *pt5; void

I 0 0 0

0 0 0 I 0 0 //APPENDIX 3.2 //document for pro£-2 1/expre~sion of each bit of LFSR meam in terms of initial condition #include<stdio.h> #include<stdlib.h> #include<math.h> main() I int ij,i,m.fiiOOJjj=O.li=O.ijk; int all OO{.b{l OOI.n.h.o.ctr.t.icrr.ind,temp l,i l,i2,j2,r,u; int .. pos.jjj,iik.iij,index.sum.temparrj50{;

FILE •ft. •pt4; //initial condition of no of de£ree to no of bit pt4=fopen("break.dat","w"); ft=fopen("input.dat","r"); fscanf(ft,"%d",&n)J/n is the degree of the polynomial for(i=O:i<n;i++) fscanf(ft."'ibd", &ali J)://reading co-efficients of polyno­mial for(i=O;i<n:i++) fscanf(ft,"%d". &bliJ)J/reading ofLFSR's initial condi· tion fscanf(ft,"%d",&m);/lbitlen£1h of LFSR's output fscanf(ft."'ibd",&t); pos=(int••Jmalloc(m•sizeof(int•)); for(i=O:i<m:i++) pos{I=Cint•)malloc(n•sizeof(int)); index=(); for(i=O;i<n;i++) if(a{il=l) I flindexl=i+l; index++; I for(o=O;a<n:o++) I

for(iik=O:iik<n :iik++) I if(o==iik)

poslolliikl=l; else po5{o\liik{.O:

fprintf(pt4,"%d" .posl o 11 i ik {); I fprintf(pt4."\n"); I for(o=n:e><m;a++) I for(iik=O;iik<=t·l :iik++) posl o lliik l=o-fl (t·l )-iik 1: for(i I =O;i1<t:i 1 ++) temparr{i1\=pos{olli11: for(jjj=O:jjj<n :jjj++) I sum=O; for(ijk=O;ijk<t;ijk++) sum=sum+pos{ temparr{ ijk 1\\jjj 1: pos{ol{jjjl=sum%2: fprintf(pt4, "%d" ,pos{ o l{jjj {); l fprintf(pt4,"\n"); I for(i=O;i<m:i++) free(pos{ i J); close(pt4); I 1/output:exprcssion of each bit LFSR stream in terms of initial condition O=HXXl,l=0100.2=0010.3=00:ll.4=1001.5=1101,6=1111,7=1 110,8=0111,9=1010,10=0101,11=1011,12=1100,13=0110

JJ·IIlJ'JJ)JAN.-JUN:2002l

14=0011,15=1000,16=0100.17=0010,18=0001,19=1001

//APPENDIX 3.3 //document of program-3 II distance calculation and initial condition checking #include<stdio.h> #inc 1ude<stdl ib.h> #include<math.h> int all OO).b{l OO!.cl1 OOOO].zll OOOO],zsum,m,nchoosek; int i,i l,i2,i3,i4,j2.n,o,t,r,sllOOI.numllOI.siiiOOI: int distil OO].ull 001, jjj, iik, ijk.k I. kind, guess, number, sum; int jj=O,li=O.p{l 001. • •pos,index,total.pow l.cnt,doub; float pan l,part2.frac{21; double grandist{21; char ch{IOOI: FILE •ft I, •ft2 .. pt2. •pt3 .. pt4; void lfsr_write(int c{ {)//function for simulation of LFSR I int i.sum=O,temp.k=O; do I clkl=b{OJ; for(i=O;i<n;i++) sum=sum+alii•b{i I; temp=sum%2; i=O: while(i<(n-1 )) I blil=bli+ll; i++; I b{ n-ll=temp; sum=O; k++; ) while(k'=m); I int b2d(int ss{j,int bits)//function for binary to decimal I int i,ct.number; ct= 1 ;number=O; for(i=O;i<bits;i++) I number=number+ss{ i j•ct; ct=ct•2: I return(number); I

void lfsr_read(FILE •ft)//function to read LFSR polyno­mial I fscanf(ft,"%d",&n);// n is the degree of polynomial for(i=O;i<n;i++) fscanf(ft,"%d", &a(i J)J/readin~ of co-efficient~ of lfsr poly­nomial for(i=O;i<n;i++) fscanf(ft,"%d",&blii); //reading of initial condition fscanf(ft,"%d",&m); II bit length of lfsr output fscanf(ft,"%d", &t); II no of taps I

int power(int n, int m) I int q; if(m=O) q=l; else q=n•power(n,m-1 ); return(q); I main() { ft 1 =fopen("input.dat", "r") lfsr_read(ftl ): 1/lfsr_read() is invoked pt2=fopen("cipher.dat", "r"); pt3=fopen("breuk.dat", "r"); pt4=fopen("rubbish.dat","w");

pos=(int••)malloc(m•sizeof(int•)); for(i=O;i<m;i++) posl i J=(i nt •)malloc(n • sizeof(i nt)); for(i=O;km;i++) I fscanf(pt2,"%d",&z{iJ);

fscanf(pt3,"%s",&ch); l'or(i I =O;i I <n;i I++) posliJii l{=ch[i 1]-'0'; I for(i=O;i<n:i++) u{ii=O; for(k I= I ;kl<n:kl++) I

for(gucss=O;gucss<= I ;guess++) I u(kl-ll=guess; kind=powcr(2,n-k I); for(i=O:i<kind;i++) I silii,O: num{ii=O; l

for(o=n;O<m-1 ;o++) ( for(i2=o+ I :i2<m;i2++) I forG2=0; j2<n;j2++)

p{j2j=posjoj{j2j•pos{i21{j2{; for(j2=k I ;j2<n;j2++) sij2-kl{=pjj2{; number=b2d(s,n-k I); si{number{++; zsum=(z{ o{+zli2 {)%2; sum=O; for(j2=0;j2<k I ;j2++) sum=sum+ujj2{*plj2{; ,,um=sum%2; if(surn=zsum) num{ number]++; I l grand list{ guess 1=0: nchoosek=O; for(i=O;i<kind;i++) nchoosek=nchoosek+sil i 1: for(i=O;i<kind;i++) I part! =((float)(sil i 1·2*num{ i J))/(sqrt((float)nchoosek)); part2=part I •part I; grandli st{ gues. {=grand li stl guess l+part2; I I ul k 1-ll=(grundlist{ Ol>grandlist{l{)? 0: I; fprintf(pt4,"results %d %d \n", kl-l,u{kl-1]); fprintf(pt4,"grandlist(0]=%1f grandlist{IJ=% I f\n" .grandlistiOI.grandlist[ I]);

II the following part determines u{n-11 for(guess=O;guess<= I ;guess++) I u{ n-ll=guess; for(i=O;i<n:i++) blil=ulil; lfsr_write(c): tracl guess {=compare( c,z)/( ( float)m); I u{n-IJ=(frac{O{>frac{IJ)" 0: I; fpri ntf(pt4, "fruc0=%f fruc I =%1\n" .frac{ 0 {.froc{l ]); fprintf(pt4,"rcsult.' %d %d ", n-l,u(n·lll; close(pt2); close(pt3 ); close(pt4); int compare( in! ell. int zli) I int i; int sum=O; for(i=O:i<m;i++) i f(c{ il==zi i {) .sum++: return(sum); I output: results u{OJ=O grandlistl01=46. 708081,grandlistll]=2.213033 results ul11= 1 grandlistl0!=4.231664 grandlist[l ]=89.184492 results ul21=0 grandlistl01=178.022575 grandlistlll=0.346407 frac0=0.490000 fmc I =0.585000