Kerberos authentication
#include <stdio.h>
#include <time.h>
#include <conio.h>
#include <iostream.h>
#include <dos.h>
#include <stdlib.h>
void main ()
{ clrscr();
int ka,kb,ktgs,ks,a=66,b=67,kab;
char *date,*dt;
time_t timer;
timer=time(NULL);
cout<<"A identity=66\n\n";
cout<<"A send identity to AS\n\n";
delay(500);
ks=random(10)+1;
cout<<"ks by AS=>"<<ks<<"\n\n";
ktgs=a+ks;
cout<<"Ticket="<<ktgs<<"\n\n";
ka=random(10)+1;
cout<<"message send to A "<<ka+ks+ktgs<<"\n\n";
cout<<"A authnticated \n\n";
date = asctime(localtime(&timer));
dt=date;
cout<<"A send ticket to TGS on "<<date<<" and 66 as B's identity\n\n";
delay(5000);
date = asctime(localtime(&timer));
cout<<"msg got by TGS on "<<date<<"\n\n";
cout<<"TGS verifies\n\n";
delay(1000);
kab=random(10)+1;
kb=random(10)+1;
cout<<"TGS send "<<ks+b+kab<<" and "<<kb+a+kab<<"\n\n";
cout<<"A send "<<kb+a+kab<<" to B"<<" and "<<"time "<<dt<<" with kab\n\n";
cout<<"B verifies\n\n";
delay(2000);
cout<<"A authnticatd\n\n";
cout<<"B send encrypted "<<dt<<" to A , encrypted with kab\n\n";
cout<<"A verifies\n\n";
delay(2000);
cout<<"B autnticated\n\n";
getch();
}
OUTPUT:
A identity=66
A send identity to AS
ks by AS=>1
Ticket=67
message send to A 69
A authnticated
A send ticket to TGS on Fri Oct 15 09:32:28 2010
and 66 as B's identity
msg got by TGS on Fri Oct 15 09:32:28 2010
TGS verifies
TGS send 72 and 71
A send 71 to B and time Fri Oct 15 09:32:28 2010
with kab
B verifies
A authnticatd
B send encrypted Fri Oct 15 09:32:28 2010
to A , encrypted with kab
A verifies
B autnticated