CG Report

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

BELAGAVI - 590 018, KARNATAKA.

MINI PROJECT REPORT

ON

“ATOM SIMULATION”
Submitted in the partial fulfillment of requirements
FOR
Computer Graphics and Visualization Lab (18CSL67)
Submitted by

Raghavendra M 4BD20CS074
Aditya D Benkikere 4BD20CS122

PROJECT GUIDES:

Prof. Madhuri Deekshith S B.E, M. Tech., Prof.Gangamma H B.E, M. Tech.,


Asst. Professor, Asst. Professor
Department of CS&E Department of CS&E,
B.I.E.T., Davanagere B.I.E.T., Davanagere

2023
Department of Computer Science and Engineering.
Bapuji Institute of Engineering & Technology
Davangere- 577004
Bapuji Institute of Engineering and Technology
Davangere -577004

Department of Computer Science and Engineering

CERTIFICATE
This is to certify that Raghavendra M and Aditya D Benkikere bearing USN
4BD20CS074 and USN 4BD20CS122 respectively of Computer Science and Engineering
department have satisfactorily submitted the mini project report entitled “DEFFIE-HELLMAN
KEY EXCHANGE”. The report of the project has been approved as it satisfies the academic
requirements in respect of project work prescribed for the academic year 2023.

Project Guide1 Project Guide 2

Prof. Madhuri deekshith S B.E., M. Tech., Prof. Gangamma H B.E., M. Tech.,

Asst. Professor Asst. Professor


Department of CS&E Department of CS&E
B.I.E.T., Davangere. B.I.E.T., Davangere.

Head of Department

Dr. Nirmala C.R M. Tech., Ph.D.,


Prof & Head, Department of CS&E
B.I.E.T., Davangere

Date: Signature of Examiners:

Place: (1)

(2)
ACKNOWLEDGEMENT

Salutations to our beloved and highly esteemed institute, “BAPUJI INSTITUTE OF


ENGINEERING AND TECHNOLOGY” for having well qualified staff and labs furnished with
necessary equipments.

We express our sincere thanks to our guide Prof. Madhuri deekshith S & Prof. Naveen
H M for giving us constant encouragement, support and valuable guidance throughout the course
of the project without whose stable guidance this project would not have been achieved.

We express whole hearted gratitude to Dr. Nirmala C R who is our respectable HOD of
Computer Science & Engineering Department. We wish to acknowledge her help who made our
task easy by providing with his valuable help and encouragement.

We also express our whole hearted gratitude to our principal, Dr. Aravind H B, for his
moral support and encouragement.

We would like to extend my gratitude to all staff of Department of Computer Science


and Engineering for the help and support rendered to me. I have benefited a lot from the feedback,
suggestions given by them.

We would like to extend my gratitude to all my family members and friends especially for
their advice and moral support.

RAGHAVENDRA M (4BD20CS074)
ADITYA D BENKIKERE (4BD20CS062)
Vision and Mission of the Institute

Vision
“To be a centre of excellence recognized nationally internationally, in distinctive areas of engineering
education and research, based on a culture of innovation and invention.”

Mission
“BIET contributes to the growth and development of its students by imparting a broad based
engineering education and empowering them to be successful in their chosen field by inculcating in
them positive approach, leadership qualities and ethical values.”

Vision and Mission of the Computer Science and Engineering


Department

Vision
“To be a centre-of-excellence by imbibing state-of-the-art technology in the field of Computer
Science and Engineering, thereby enabling students to excel professionally and be ethical.”

Mission

1. Adapting best teaching and learning techniques that cultivates Questioning and
Reasoning culture among the students.
2. Creating collaborative learning environment that ignites the critical thinking in
students
and leading to the innovation.
3. Establishing Industry Institute relationship to bridge skill gap and make them
industryready and relevant.
4. Mentoring students to be socially responsible by inculcating ethical and moral
values.
Program Educational Objectives (PEOs):

PEO1 To apply skills acquired in the discipline of computer science and engineering
forsolving Societal and industrial problems with apt technology intervention.
PEO2 To continue their carrier ion industry /academia or pursue higher studies and
research.
PEO3 To become successful entrepreneurs, innovators to design and develop software
products and services that meets societal, technical and business challenges.
PEO4 To work in the diversified environment by acquiring leadership qualities with
effectivecommunication skills accompanied by professional and ethical values.

Program Specific Outcomes (PSOs):

PSO1 Analyse and develop solutions for problems that are complex in nature but
applying theknowledge acquired from the core subjects of this program.
PSO2 To develop secure, scalable, resilient and distributed applications for industry
and
societal Requirements.
PSO3 To learn and apply the concepts and contract of emerging technologies like artificial
intelligence, machine learning, deep learning, big-data analytics, IOT, cloud
computingetc for any real time problems.

Course Outcomes :

CO1 Apply the concepts of computer graphics


CO2 Implement computer graphics applications using OpenGL
CO3 Animate real world problems using OpenGL
CO4 CO4 Implementation of line drawing and clipping algorithms using OpenGL
functions
CO5 Design and implementation of algorithms Geometric transformations on both 2D
and 3D objects.
ABSTRACT

The above abstract summarizes a mini project focused on the application of the Diffie-Hellman key
exchange algorithm in computer graphics. The project aims to explore and implement the algorithm
to establish secure communication channels between a client and a server. The abstract covers the
introduction and explanation of the Diffie-Hellman algorithm, its use in computer graphics, the
implementation process, security analysis, and the demonstration of successful results. The project
emphasizes the importance of the Diffie-Hellman algorithm in ensuring secure data transmission in
computer graphics systems.
CONTENTS

CHAPTER 1: INTRODUCTION ............................................................................... 1


1.1 OPENGL .................................................................................................................. 1
1.2 HISTORY. ................................................................................................................ 1
1.3 FEATURES OF OPENGL .......................................................................................2
1.4 BASIC OPENGL OPERATIONS ............................................................................ 4
1.5 OPENGL INTERFACE. .......................................................................................... 5
1.6 GRAPHICS FUNCTIONS… ...................................................................................7
1.7 DATA TYPES ........................................................................................................... 9
CHAPTER 2: SYSTEM REQUIREMENTS ............................................................ 10
2.1 SOFTWARE REQUIREMTS ..................................................................................10
2.2 HARDWARE REQUIREMENTS........................................................................... 10
CHAPTER 3: SYSTEM DESIGNS ............................................................................ 11
3.1 INITIALIZATION ................................................................................................... 11
3.2 DISPLAY ................................................................................................................. 12
3.3 FLOWCHART… ..................................................................................................... 13
CHAPTER 4: IMPLEMENTATION .........................................................................14
4.1 OVERVIEW ............................................................................................................. 14
4.2 USER INTERFACE ................................................................................................. 14
4.3 STRUCTURE… ....................................................................................................... 15
4.4 ANALYSIS .............................................................................................................. 16
4.4.1 MAIN FUNCTION. ....................................................................................... 16
4.4.2 FUNCTION T0 DISPLAYS PROBLEM AND SOLUTION ....................... 17
4.4.3 FUNCTION FOR DRAWING DIFFERENT OBJECTS .............................. 20
4.4.4 KEYBOARD FUNCTION FOR INTERACTION… .................................. 21
CHAPTER 5: SNAPSHOTS ........................................................................................ 24
CONCLUSION
REFERENCES
LIST OF FIGURES

Sl. Fig.no Description Page. no


no
1 5.1 Initial View 24
2 5.2 Problem statement for a 24
algorithm
3 5.3 Solution for algorithm 25
4 5.4 Requesting to exchange 25
Public keys
5 5.5 Public keys exchanged 26
6 5.6 Adding Private key 26

7 5.7 Connection Established 27


Deffie-Hellmsn Key Exchange

CHAPTER 1
INTRODUCTION
1.1 OPENGL

OpenGL is the abbreviation for Open Graphics Library. It is a software interface for
graphics hardware. This interface consists of several hundred functions that allow you, a graphics
programmer, to specify the objects and operations needed to produce high-quality color images of
two-dimensional and three-dimensional objects. Many of these functions are actually simple
variations of each other, so in reality there are about 120 substantially different functions.The main
purpose of OpenGL is to render two-dimensional and three-dimensional objects into the frame
buffer. These objects are defined as sequences of vertices (that define geometric objects) or pixels
(that define images).OpenGL performs several processes on this data to convert it to pixels to
form the final desired image in the frame buffer.

1.2 HISTORY
As a result, SGI released the OpenGL standard In the 1980s, developing software that
could function with a wide range of graphics hardware was a real challenge. Software developers
wrote custom interfaces and drivers for each piece of hardware. This was expensive and resulted
in much duplication of effort.

By the early 1990s, Silicon Graphics (SGI) was a leader in 3D graphics for workstations.
Their IRIS GL API was considered the state of the art and became the de facto industry standard,
overshadowing the open standards-based PHIGS. This was because IRIS GL was considered easier
to use, and because it supported immediate mode rendering. By contrast, PHIGS was considered
difficult to use and outdated in terms of functionality.

SGI's competitors (including Sun Microsystems, Hewlett-Packard and IBM) were also able
to bring to market 3D hardware, supported by extensions made to the PHIGS standard. This in
turn caused SGI market share to weaken as more 3D graphics hardware suppliers entered the
market. In an effort to influence the market, SGI decided to turn the Iris GL API into an open
standard.

CS&E Dept, B.I.E.T, Davangere 1


Deffie-Hellmsn Key Exchange

SGI considered that the Iris GL API itself wasn't suitable for opening due to licensing and
patent issues. Also, the Iris GL had API functions that were not relevant to 3D graphics. For
example, it included a windowing, keyboard and mouse API, in part because it was developed
before the X Window System and Sun's NEWSsystems were developed.

In addition, SGI had a large number of software customers; by changing to the OpenGL
API they planned to keep their customers locked onto SGI (and IBM) hardware for a few years
while market support for OpenGL matured. Meanwhile, SGI would continue to try to maintain
their customers tied to SGI hardware by developing the advanced and proprietary Iris Inventor and
Iris Performer programming APIs.

1.3 FEATURES OF OPENGL


• Industry standard
An independent consortium, the OpenGL Architecture Review Board, guides the OpenGL
specification. With broad industry support, OpenGL is the only truly open, vendor-neutral,
multiplatform graphics standard.

• Stable
OpenGL implementations have been available for more than seven years on a wide variety
of platforms. Additions to the specification are well controlled, and proposed updates are
announced in time for developers to adopt changes. Backward compatibility requirements
ensure that existing applications do not become obsolete.

• Reliable and portable

All OpenGL applications produce consistent visual display results on any OpenGL API-
compliant hardware, regardless of operating system or windowing system.

• Evolving
Because of its thorough and forward-looking design, OpenGL allows new hardware
innovations to be accessible through the API via the OpenGL extension mechanism. In this
way, innovations appear in the API in a timely fashion, letting application developers and
hardware vendors incorporate new features into their normal product release cycles.

CS&E Dept, B.I.E.T, Davangere 2


Deffie-Hellmsn Key Exchange

• Scalable
OpenGL API-based applications can run on systems ranging from consumer electronics to
PCs, workstations, and supercomputers. As a result, applications can scale to any class of
machine that the developer chooses to target.

• Easy to use
OpenGL is well structured with an intuitive design and logical commands. Efficient
OpenGL routines typically result in applications with fewer lines of code than those that
make up programs generated using other graphics libraries or packages. In addition,
OpenGL drivers encapsulate information about the underlying hardware, freeing the
application developer from having to design for specific hardware features.

• Well-documented
Numerous books have been published about OpenGL, and a great deal of sample code is
readily available, making information about OpenGL inexpensive and easy to obtain.

CS&E Dept, B.I.E.T, Davangere 3


Deffie-Hellmsn Key Exchange

1.4 BASIC OPENGL OPERATION

The following diagram illustrates how OpenGL processes data. As shown, commands enter
from the left and proceed through a processing pipeline. Some commands specify geometric
objects to be drawn, and others control how the objects are handled during various processing
stages.

Fig 1.4.1: OpenGL Block Diagram

The processing stages in basic OpenGL operation are as follows:

• Display list

Rather than having all commands proceed immediately through the pipeline, you can
choose to accumulate some of them in a display list for processing later.

• Evaluator

The evaluator stage of processing provides an efficient way to approximate curve and
surface geometry by evaluating polynomial commands of input values.

CS&E Dept, B.I.E.T, Davangere 4


Deffie-Hellmsn Key Exchange

• Per-vertex operations and primitive assembly

OpenGL processes geometric primitives - points, line segments, and polygons all of which
are described by vertices. Vertices are transformed, and primitives are clipped to the
viewport in preparation for rasterization.

• Rasterization

The rasterization stage produces a series of frame-buffer addresses and associated


values using a two-dimensional description of a point, line segment, or polygon. Each so
produced is fed into the last stage, per-fragment operations.

• Per-fragment operations

These are the final operations performed on the data before it is stored as pixels in the
frame buffer Per-fragment operations include conditional updates to the frame buffer based
on incoming and previously stored z values (for z buffering) and blending of incoming
pixel colors with stored colors, as well as masking and other logical operations on pixel
values.

• Pixel operation

Input data can be in the form of pixels rather than vertices. Such data which might describe
an image for texture mapping skips the first stage of processing and instead processed as
pixels in the pixel operation stage.

• Texture memory

The result of pixel operation stage is either stored as texture memory for use in rasterization
stage or rasterised and resulting fragment merged into the frame buffer just as they were
generated from the geometric data.

CS&E Dept, B.I.E.T, Davangere 5


Deffie-Hellmsn Key Exchange

1.5 THE OPENGL INTERFACE

Most of our applications will be designed to access OpenGL directly through functions in
three libraries. They are

• GL – Graphics Library

Functions in the main GL (or OpenGL in Windows) library have names that begin with the
letters gl and are stored in a library usually referred to as GL (or OpenGL in Windows).

• GLU – Graphics Utility Library

This library uses only GL functions but contain code for creating common objects and
simplifying viewing. All functions in GLU can be created from the core GL library but
application programmers prefer not to write the code repeatedly. The GLU library is
available in all OpenGL implementations; functions in the GLU library begins with the
letters glu.

• GLUT – OpenGL Utility Toolkit

To interface with the window system and to get input from external devices into our
programs we need at least one more library. For the X window System, this library is called
GLX, for Windows, it is wgl, and for the Macintosh, it is agl. Rather than using a different
library for each system, we use a readily available library called the OpenGL Utility Toolkit
(GLUT) , which provides minimum functionality that should be expected in any modern
windowing system.

CS&E Dept, B.I.E.T, Davangere 6


Deffie-Hellmsn Key Exchange

Fig 1.5.1: Library Organization

The above figure shows the organization of the libraries for an X Window System
environment.

In most implementations, one of the include lines

#include<GL/glut.h>

or

#include<GLUT/glut.h>

is sufficient to read in glut.h, gl.h and glu.h.

CS&E Dept, B.I.E.T, Davangere 7


Deffie-Hellmsn Key Exchange

1.6 GRAPHICS FUNCTIONS

Our basic model of a graphics package is a black box, a term that engineers use to denote
a system whose properties are described only by its inputs and outputs; we may know nothing
about its internal workings.

OpenGL functions can be classified into seven major groups:

• Primitive function: The primitive functions define the low-level objects or atomic entities
that our system can display. Depending on the API, the primitives can include points, lines,
polygons , pixels, text, and various types of curves and surfaces.

• Attribute functions
If primitives are the what of an API – the primitive objects that can be displayed- then
attributes are the how. That is, the attributes govern the way the primitive appears on the
display. Attribute functions allow us to perform operations ranging from choosing the color
with which we display a line segment, to picking a pattern with which to fill inside of a
polygon.

• Viewing functions
The viewing functions allow us to specify various views, although APIs differ in the degree
of flexibility they provide in choosing a view.

• Transformation functions
One of the characteristics of a good API is that it provides the user with a set of
transformations functions such as rotation, translation and scaling.

• Input functions
For interactive applications, an API must provide a set of input functions, to allow users to
deal with the diverse forms of input that characterize modern graphics systems. We need
functions to deal with devices such as keyboards, mice and data tablets.

CS&E Dept, B.I.E.T, Davangere 8


Deffie-Hellmsn Key Exchange

• Control functions
These functions enable us to communicate with the window system, to initialize our
programs, and to deal with any errors that take place during the execution of our programs.

• Query functions
If we are to write device independent programs, we should expect the implementation of
the API to take care of the differences between devices, such as how many colors are
supported or the size of the display. Such information of the particular implementation
should be provides through a set of query functions.

CS&E Dept, B.I.E.T, Davangere 9


Deffie-Hellmsn Key Exchange

CHAPTER 2

SYSTEM REQUIREMENTS

2.1 SOFTWARE REQUIREMENTS

1. Operating System : Microsoft Windows XP,Microsoft Windows 7

2. Compiler used: VC++ 6.0 compiler

3. Language used: C/ C++

2.2 HARDWARE REQUIREMENTS

1. Main Processor: PENTIUM III or above.

2. Processor Speed: 800 MHz

3. RAM Size: 128MB DDR

4. Monitor resolution - A color monitor with a minimum resolution of 1000*700

CS&E Dept, B.I.E.T, Davangere 10


Deffie-Hellmsn Key Exchange

CHAPTER 3

DESIGN

3.1 INITIALIZATION
Select Prime Numbers:
Choose two large prime numbers, p and q, where p is a prime and q is a prime divisor of (p-1).
These prime numbers ensure the security and effectiveness of the algorithm. The larger the prime
numbers, the more secure the key exchange will be.

Generate a Primitive Root:


Find a primitive root, g, modulo p. A primitive root is an element whose powers generate all
possible residues modulo p. This primitive root will be used to perform modular exponentiation in
the key exchange process.

Generate Private Keys:


Each participant (client and server) generates a private key. These keys, denoted as a and b, are
randomly chosen positive integers within a specified range. These private keys should be kept secret
and not shared over the network.

Calculate Public Keys:


Using the generated private keys, each participant calculates their respective public key. The
public key for participant A is computed as g raised to the power of a modulo p (g^a mod p), while
the public key for participant B is computed as g raised to the power of b modulo p (g^b mod p).

Exchange Public Keys:


The participants exchange their calculated public keys over the untrusted network. These public
keys can be transmitted openly since they do not reveal any information about the private keys.

CS&E Dept, B.I.E.T, Davangere 11


Deffie-Hellmsn Key Exchange

3.2 DISPLAY
The Diffie-Hellman key exchange algorithm in the computer graphics mini project can be visually
represented as a step-by-step process. It includes displaying the generated primitive root, the private
keys of the client and server, the computed public keys, and the exchanged public keys. Additionally,
the shared secret key can be displayed once it is computed. A graphical user interface (GUI) or
console output can be utilized to present these values and facilitate a clear understanding of the key
exchange process in computer graphics.

Fig 3.2.1: Display of Atom Simulation

CS&E Dept, B.I.E.T, Davangere 12


Deffie-Hellmsn Key Exchange

3.3 FLOWCHART

Fig 3.3.1: Flowchart of Atom Simulation

CS&E Dept, B.I.E.T, Davangere 13


Deffie-Hellmsn Key Exchange

CHAPTER 4

IMPLEMENTATION
4.1 OVERVIEW

The Diffie-Hellman key exchange algorithm, implemented in the computer graphics mini project,
enables secure communication between a client and server. It involves selecting prime numbers,
generating a primitive root, and exchanging public keys. The algorithm computes a shared secret key
based on the exchanged public keys and private keys. This key is then used to encrypt and decrypt
graphic data, ensuring confidentiality during transmission. The mini project explores the
implementation, security analysis, and successful demonstration of the algorithm, highlighting its
significance in securing data exchange in computer graphics systems.

4.2 USER INTERFACE


Input Fields:
Provide input fields where the user can enter the required parameters, such as the prime numbers
(p and q) and the private keys for the client and server (a and b). These input fields allow the user
to customize the key exchange process based on their specific requirements.

Generate Keys Button:


Include a button labeled "Generate Keys" that triggers the generation of public keys and the
computation of the shared secret key. When clicked, this button initiates the algorithm's execution
and performs the necessary calculations.

Display Areas:
Allocate display areas where the generated public keys, exchanged public keys, and shared secret
key can be shown. These areas update dynamically as the key exchange progresses, providing real-
time feedback to the user.

Encryption/Decryption Options:
Provide options for the user to encrypt and decrypt graphic data using the shared secret key. This
can be in the form of checkboxes or buttons labeled "Encrypt" and "Decrypt" that allow the user to
apply the cryptographic operations on their chosen graphic data.

CS&E Dept, B.I.E.T, Davangere 14


Deffie-Hellmsn Key Exchange

Results and Visual Feedback:


Include sections where the results of the key exchange process, such as the computed public keys
and the shared secret key, are displayed. Visual feedback, such as success messages or error
notifications, can be presented to inform the user about the progress and outcome of the algorithm.

4.3 STRUCTURE
• void outputRed(int x,int y,char *string)
• void outputPink(int x,int y,char *string)
• void outputHelveticaWhite(int x,int y,char *string)
• void outputBlack(int x,int y,char *string)
• void output(int x,int y,char *string)
• void success()
• void computer()
• void computer_dest()
• void computer_intruder()
• void miniUses()
• void clearKey(int kposx)
• void keyDraw(int kposx)
• void keyfunc (unsigned char key, int x, int y)
• int main(int argc,char** argv)

CS&E Dept, B.I.E.T, Davangere 15


Deffie-Hellmsn Key Exchange

4.4 ANALYSIS
Purpose:
• Main function.
• Function to displays instructions and labels on screen.
• Methods defining coordinate values for objects.
• Function for drawing different objects on screen.
• Keyboard and Mouse function for interaction.
• Display function.

4.4.1 MAIN FUNCTION

int main(int argc,char** argv)


{

glutInit(&argc,argv);

glutInitDisplayMode(GLUT_RGB|GLUT_SINGLE);

glutInitWindowPosition(0,0);

glutInitWindowSize(1000,700);

glutCreateWindow("Diffie-Hellman Key Exchange");

glMatrixMode(GL_MODELVIEW);//INIT

gluOrtho2D(0,700,0,700);

glPointSize(100.0);

glutKeyboardFunc(keyfunc);//enabling keyboard
glutCreateMenu(menu);
glutAddMenuEntry("1.Exchange Public Keys",1);
glutAddMenuEntry("2.Add Your Private Key",2);
glutAddMenuEntry("3.Quit",3);
glutAttachMenu(GLUT_RIGHT_BUTTON);

//credits();
glutDisplayFunc(credits);
glutMainLoop();

CS&E Dept, B.I.E.T, Davangere 16


Deffie-Hellmsn Key Exchange

4.4.2 FUNCTION TO PROBLEM AND SOLUTION INSTRUCTIONS


void problem(){
glClearColor(0.101,0.176,0.231,1);

glClear(GL_COLOR_BUFFER_BIT);

glColor3f(0,0,0.0); // Top
glBegin(GL_QUADS);
glVertex2f(0,650);
glVertex2f(700,650);
glVertex2f(700,700);
glVertex2f(0,700);
glEnd();

output(285,665,"PROBLEM");

outputWhite(70,500,"Exchanging the keys between two communicating ");


outputWhite(70,450,"parties securely,we dont just want to establish a common key ");
outputWhite(70,400,"but want to do so in a such way that anyone who is listning to");
outputWhite(70,350,"communication between the devices donot find out the key.");

int kposx=20;
int i=0;
while(i<=40){

keyDraw(kposx);
i+=1;
kposx+=1;
}

glColor3f(1,1,0); //key
glBegin(GL_LINE_LOOP);
glVertex2f(500.0+kposx,550.0);
glVertex2f(520.0+kposx,580.0);
glVertex2f(525.0+kposx,580.0);
glVertex2f(525.0+kposx,550.0);
glVertex2f(520.0+kposx,530.0);
glVertex2f(525.0+kposx,510.0);
glVertex2f(520.0+kposx,490.0);
glVertex2f(525.0+kposx,470.0);
glVertex2f(525.0+kposx,410.0);
glVertex2f(545.0+kposx,390.0); //Bottom
glVertex2f(545.0+kposx,360.0);
glVertex2f(525.0+kposx,330.0);
glVertex2f(500.0+kposx,330.0);
glVertex2f(525.0+kposx,330.0);
glVertex2f(500.0+kposx,330.0);
glVertex2f(480.0+kposx,360.0);
glVertex2f(480.0+kposx,390.0);
glVertex2f(500.0+kposx,410.0);

CS&E Dept, B.I.E.T, Davangere 17


Deffie-Hellmsn Key Exchange

glVertex2f(500.0+kposx,410.0);
glEnd();
glFlush(); // keyDraw(kposx);
miniUses();
glColor3f(0,0,0.0); // Bottom
glBegin(GL_QUADS);
glVertex2f(0,50);
glVertex2f(700,50);
glVertex2f(700,0);
glVertex2f(0,0);
glEnd();
output(260,020,"Press S/s to Continue");
glFlush();

void solution(){

glClearColor(0.101,0.176,0.231,1);
glClear(GL_COLOR_BUFFER_BIT);

glColor3f(0,0,0.0); // Top

glBegin(GL_QUADS);
glVertex2f(0,650);
glVertex2f(700,650);
glVertex2f(700,700);
glVertex2f(0,700);
glEnd();
output(285,665,"SOLUTION");
int i=0;

while(i<150){

outputC(50+i,550,"DIFFIE-HELLMAN KEY EXCHANGE");


outputRed(50+i,540,"_______________________________");
delay(8);
outputBG(50+i,550,"DIFFIE-HELLMAN KEY EXCHANGE");
outputBG(50+i,540,"______________________________");
i+=1;

outputC(50+i,550,"DIFFIE-HELLMAN KEY EXCHANGE");


outputRed(50+i,540,"______________________________");
outputWhite(50,460,"- Diffe-Hellman key exchange algorithm establishes a shared secret between two
parties,");
outputWhite(50,430," that can be used for secret communication for exchanging data over public
networks.");

CS&E Dept, B.I.E.T, Davangere 18


Deffie-Hellmsn Key Exchange

//miniSecure();

// that can be used for secret communication for exchanging data over public networks.");

outputWhite(50,350,"- This algorithm can also be used for:");


outputWhite(54,310," Encryption");
outputWhite(54,270," Password Authenticated Agreement");
outputWhite(54,230," Forward Secrecy");

miniSolution();

//miniSecure();

glColor3f(0,0,0.0); // Bottom

glBegin(GL_QUADS);
glVertex2f(0,50);
glVertex2f(700,50);
glVertex2f(700,0);
glVertex2f(0,0);
glEnd();

output(225,020,"Press \"S\" to Start Simulation");

glFlush();

CS&E Dept, B.I.E.T, Davangere 19


Deffie-Hellmsn Key Exchange

4.4.3 FUNCTION FOR DRAWING DIFFERENT OBJECTS ON SCREEN

void drawCircle1(){
float theata;

glColor3f(1,0,0);
glBegin(GL_POLYGON);
for(int i=0;i<360;i++){
theata=i*3.142/180;
glVertex2f(250+10*cos(theata),250+10*sin(theata));
}

glEnd();
glFlush();
}

void drawCircle2(){
float theata;

glColor3f(1,0,0);
glBegin(GL_POLYGON);
for(int i=0;i<360;i++){
theata=i*3.142/180;
glVertex2f(250+10*cos(theata),250+10*sin(theata));
}

glEnd();
glFlush();

CS&E Dept, B.I.E.T, Davangere 20


Deffie-Hellmsn Key Exchange

4.4.5 KEYBOARD FUNCTION FOR INTERACTION


void keyfunc (unsigned char key, int x, int y)
{
switch(key) {

case 'S' :
case 's' :
// glutDisplayFunc(keys);
// glutPostRedisplay();
home();
break
case 'q':
case 'Q':
exit(0);

case '\r':
problem();
break;

default: solution();
}
void clearKey(int kposx){

glColor3f(0.101,0.176,0.231); // Top

// glColor3f(1,0,0); // Top

glBegin(GL_LINE_LOOP);
glVertex2f(500.0+kposx,550.0);
glVertex2f(520.0+kposx,580.0);
glVertex2f(525.0+kposx,580.0);
glVertex2f(525.0+kposx,550.0);
glVertex2f(520.0+kposx,530.0);
glVertex2f(525.0+kposx,510.0);
glVertex2f(520.0+kposx,490.0);
glVertex2f(525.0+kposx,470.0);
CS&E Dept, B.I.E.T, Davangere 21
Deffie-Hellmsn Key Exchange

glVertex2f(525.0+kposx,410.0);
glVertex2f(545.0+kposx,390.0); //Bottom
glVertex2f(545.0+kposx,360.0);
glVertex2f(525.0+kposx,330.0);
glVertex2f(500.0+kposx,330.0); //prob
// glVertex2f(500.0+kposx,410.0);
glVertex2f(480.0+kposx,360.0);
glVertex2f(480.0+kposx,390.0);
glVertex2f(500.0+kposx,410.0);
glEnd();
// float t=0;
// // glColor3f(0.101,0.176,0.231); //Bob head
// glBegin(GL_POLYGON);
// for(int i=0;i<360;i++){
// t=i*3.142/180;
// glVertex2f(480+10*cos(t)+i,380+20*sin(t));
// }

// glEnd();
// glFlush();

glFlush();

void keyDraw(int kposx){

// glColor3f(0.75,0.85,0.65); //key

glColor3f(1,1,0); //key

glBegin(GL_LINE_LOOP);
glVertex2f(500.0+kposx,550.0);
glVertex2f(520.0+kposx,580.0);
glVertex2f(525.0+kposx,580.0);

CS&E Dept, B.I.E.T, Davangere 22


Deffie-Hellmsn Key Exchange

glVertex2f(525.0+kposx,550.0);
glVertex2f(520.0+kposx,530.0);
glVertex2f(525.0+kposx,510.0);
glVertex2f(520.0+kposx,490.0);
glVertex2f(525.0+kposx,470.0);
glVertex2f(525.0+kposx,410.0);

glVertex2f(545.0+kposx,390.0); //Bottom
glVertex2f(545.0+kposx,360.0);

glVertex2f(525.0+kposx,330.0);
glVertex2f(500.0+kposx,330.0);

glVertex2f(525.0+kposx,330.0);
glVertex2f(500.0+kposx,330.0);

glVertex2f(480.0+kposx,360.0);
glVertex2f(480.0+kposx,390.0);
glVertex2f(500.0+kposx,410.0);
glVertex2f(500.0+kposx,410.0);

glEnd(

CS&E Dept, B.I.E.T, Davangere 23


Deffie-Hellmsn Key Exchange

CHAPTER 5
SNAPSHOTS

Fig 5.1: Initial View

Fig 5.2: Problem statement for Deffie-Hellman Key Exchange

CS&E Dept, B.I.E.T, Davangere 24


Deffie-Hellmsn Key Exchange

Fig 5.3: Solution for Deffie-Hellman Key Exchange

Fig 5.4: Requesting to exchange public keys

CS&E Dept, B.I.E.T, Davangere 25


Deffie-Hellmsn Key Exchange

Fig 5.5: Public keys exchanged

Fig 5.6: Adding Private key

CS&E Dept, B.I.E.T, Davangere 26


Deffie-Hellmsn Key Exchange

Fig 5.7: Connection Established

CS&E Dept, B.I.E.T, Davangere 27


CONCLUSION

In conclusion, simulating the Diffie-Hellman key exchange using a GL language involves


implementing the necessary mathematical operations, such as modular exponentiation, and
following the steps outlined above. The simulation should demonstrate how two parties can
establish a shared secret key over an insecure channel using the Diffie-Hellman protocol.
REFERENCES

BOOKS:

[1] Edward Angel: Interactive Computer Graphics A Top-Down Approach with OpenGL, 5
edition, Pearson Education, 2008.

[2] Donald Hearn and Pauline Baker: Computer Graphics-OpenGL Version, 3d Edition,
Pearson 2004.

LINKS:

[1] https://www.opengl.org/

[2] https://www.glprogramming.com

[3] https://open.gl/transformations

You might also like