You are on page 1of 11

VISVESVARAYA TECHNOLOGICAL UNIVERSITY,

BELAGAVI – 590 018

CRYPTOGRAPHY (18CS744)
Submitted as subject assignment work

BY

ADAM M SANADI 4AL19CS003

ADISH K 4AL19CS004

AJAY N 4AL19CS005

AKHILESH HERKAL 4AL19CS006

AKHILESH V 4AL19CS007

Under the Guidance of

Dr. Manjunath Kotari


Head of Department

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING


ALVA’S INSTITUTE OF ENGINEERING AND
TECHNOLOGY MOODBIDRI-574225, KARNATAKA
2022 – 2023
ALVA’S INSTITUTE OF ENGINEERING AND TECHNOLOGY MIJAR,
MOODBIDRI D.K. -574225 KARNATAKA

DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING

CERTIFICATE

This is to certify that, assignment work for the subject “Cryptography

(18CS744)” has been successfully completed and report submitted by Adam M

Sanadi (4AL19CS003), Adish k (4AL19CS004), Ajay N (4AL19CS005),

Akhilesh Herkal (4AL19CS006), Akhilesh V (4AL19CS007) during the

academic year 2022– 2023. It is certified that all corrections/suggestions indicated

presentation session have been incorporated in the report and scored , _____,

_____, _____, ______, Marks out of 10 and deposited in the departmental

library.

Dr. Manjunath Kotari

Head of Department

i
ACKNOWLEDGEMENT
The satisfaction and euphoria that accompany a successful completion of any task would
be incomplete without the mention of people who made it possible, success is the epitome of
hard work and perseverance, but steadfast of all is encouraging guidance.

So, with gratitude we acknowledge all those whose guidance and encouragement served
as beacon of light and crowned the effort with success.

We sincerely thank, Dr. Manjunath Kotari, Professor and Head, Department of


Computer Science & Engineering who has been the constant driving force behind the completion
of the group task.
We thank our beloved Principal Dr. Peter Fernandes, for his constant help and support
throughout.
We are indebted to Management of Alva’s Institute of Engineering and Technology,
Mijar, Moodbidri for providing an environment which helped us in completing our group task in
Database Management System.

Also, we thank all the teaching and non-teaching staff of Department of Computer
Science & Engineering for the help rendered.

Adam M Sanadi 4AL19CS003

Adish K 4AL19CS004

Ajay N 4AL19CS005

Akhilesh Herkal 4AL19CS006

Akhilesh V 4AL19CS007

ii
TABLE OF CONTENTS

SL.NO. PAGE
DESCRIPTIONS
NO.

PROBLEM STATEMENT
1 Find 321 mod 11 using Fermat’s theorem.
1-2

A student has been asked to solve the following seemingly simple


2
problem: x ≡ 21990 mod 1990. Help her/him to get the solution by
approaching the problem as follows 3-4

i) Factorize 1990 into prime factors

ii) For all the prime factors pi express the given congruence as x ≡ ai
mod pi

3 5-6
Give the Case Study on SSL Protocol.
Cryptography

1. Find 321 mod 11 using Fermat’s theorem.

1.1 What is Fermat's theorem?


• Fermat’s little theorem states that if p is a prime number, then for any integer a, the number a p –
a is an integer multiple of p.
• Here p is a prime number.
• ap ≡ a (mod p).
• Special Case: If a is not divisible by p, Fermat’s little theorem is equivalent to the statement that
a p-1-1 is an integer multiple of p.
• ap-1 ≡ 1 (mod p)
OR
• ap-1 % p = 1
• Here a is not divisible by p.

1.2 Why is Fermat's theorem used?

Fermat's little theorem is a fundamental theorem in elementary number theory, which helps compute
powers of integers modulo prime numbers. It is a special case of Euler's theorem, and is important in
applications of elementary number theory, including primality testing and public-key cryptography.

1.3 Algorithm
• Begin
• Function power () is used to compute a raised to power b under modulo M
• function mod Inverse () to find modular inverse of a under modulo m :
• Let m is prime
• If a and m are relatively prime, then
• modulo inverse is a ^ (m - 2) mod m
• End

1.4 Program
#include <iostream>
using namespace std;
int pow(int a, int b, int M) {
int x = 1, y = a;
while (b > 0) {
if (b % 2 == 1) {

Department of CSE, AIET,Mijar Page no 1


Cryptography

x = (x * y);
if (x > M)
x %= M;
}
y = (y * y);
if (y > M)
y %= M;
b /= 2;
}
return x;
}
int modInverse(int a, int m) {
return pow(a, m - 2, m);
}
int main() {
int a, m;
cout<<"Enter number to find modular multiplicative inverse: ";
cin>>a;
cout<<"Enter Modular Value: ";
cin>>m;
cout<<modInverse(a, m)<<endl;
}
1.5 Output
Enter number to find modular multiplicative inverse: 3
Enter Modular Value: 11
4

Department of CSE, AIET,Mijar Page No 2


Cryptography

2. A student has been asked to solve the following seemingly simple problem: x ≡

21990 mod 1990. Help her/him to get the solution by approaching the problem as
follows

i) Factorize 1990 into prime factors

ii) For all the prime factors pi express the given congruence as x ≡ ai mod pi

i) Prime Factor of 1990 are


1 × 1990 = (1, 1990)
2 × 995 = (2, 995)
5 × 398 = (5, 398)
10 × 199 = (10, 199)
199, 5, 2
ii) P1 = 199, P2 = 5 and P3 = 2
Let R1 = mod(21990 ,199)

According the the Fermet’s Theorem, MOD(ap, p) ≡ a 

∴ MOD(2199, 199) ≡ 2.

∴ MOD((2199)10, 199) = MOD(210, 199)

∴ MOD(21990, 199) = MOD(1024, 199) 

  29 = R1.

Let R2 = mod(21990 ,5)

According the the Fermet’s Theorem, MOD(ap, p) ≡ a

∴ MOD(21990, 5) ≡ 2.

=4 * MOD(21988 , 5)

= 4 * (4)994 MOD 5

= 4 * (-1)994 MOD 5

= 4 MOD 5

=4

Department of CSE, AIET,Mijar 3


Cryptography

Let R3 = mod(21990 ,2)


According the the Fermet’s Theorem, MOD(ap, p) ≡ a
∴ MOD(21990, 2) ≡ 2.
= 21990 mod 2
=0

Department of CSE, AIET,Mijar 4


Cryptography

3. Give the Case Study on SSL Protocol.

3.1 What is SSL? Purpose of SSL?

Hacker or attacker can capture the message from unsecured connection. Username and password
are also sent in plain text form.
User interact with server and server user secure https, it shows secure connection between client
and server.

SSL certificate is added at server side. So, http use SSL, it converts into https. Connection is
secured, it means all the data in encrypted from during transmission.
3.2 What is an SSL Certificate?
An SSL certificate is a bit of code on your web server that provides security for online
communications.
• When a web browser contacts your secured website, the SSL certificate enables an encrypted
connection. 
• It's kind of like sealing a letter in an envelope before sending it through the mail. Websites need
SSL certificates to keep user data secure, verify ownership of the website, prevent attackers from
creating a fake version of the site, and convey trust to users.

Department of CSE, AIET,Mijar 5


Cryptography

3.3 SSL Architecture

The current version of SSL is 3.0. SSL is works in between application layer and transport layer
the reason SSL is also called TLS (Transport Layer Security). SSL encrypt the data received from
application layer of client machine and add its own header (SSL header) into the encrypted data
and send encrypted data to the server side. SSL is not a single protocol to perform security tasks
there are two layers of sub-protocols which supports SSL there are the SSL handshake protocol,
SSL change cipher specification, SSL alert protocol and the SSL record protocol shown in
architecture.
SSL Handshake Protocol: Connection establishment.

SSL Change Spec Protocol: Use of required cipher techniques for data encryption.

SSL Alert Protocol: Alert (warning, error if any) generation.

SSL Record Protocol: Encrypted data transmission and encapsulation of the data sent by the
higher layer protocols. Two important SSL concepts are the SSL Connection and the SSL
Session.

SSL Connection: It is a transport that provides a suitable type of service. Each connection is
associated with one SSL session.

SSL Session: It is a set of cryptographic security parameters which can be shared among here.

Department of CSE, AIET,Mijar 6


Cryptography

Department of CSE, AIET,Mijar 7

You might also like