Vous êtes sur la page 1sur 80

ENHANCED NETWORK SECURITY USING THREE

LEVEL SECURITY

PROJECT REPORT

Submitted by

V.ARAVINDAN (113115205009)

G.SURIYA PRAKASH (113115205065)

B.INDRAJITH (113115205023)

In partial fulfillment for the award of the degree

Of

BACHELOR OF TECHNOLOGY

in

INFORMATION TECHNOLOGY

VEL TECH MULTI TECH Dr. RANGARAJAN Dr. SAKUNTHALA

ENGINEERING COLLEGE

AVADI, CHENNAI 600 062

ANNA UNIVERSITY : CHENNAI 600 025

APRIL 2019
BONAFIDE CERTIFICATE

Certified that this project report “ENHANCED NETWORK SECURITY USING THREE LEVEL
SECURITY” is the bonafide work of V.ARAVINDAN (113114205009), G.SURIYA PRAKASH
(113114205065), B.INDRAJITH (113114205023) who carried out the project work under
my supervision certificate further, that to the best of my knowledge, the work reported
here is does not form part of any other project report or dissertation on the basis of which
degree or award was conferred on an earlier occasion of this or any other candidate.

SIGNATURE SIGNATURE

Mr.R.PRABU, M.Tech., Dr.M.RAJESH KHANNA, B.Tech, M.E, Ph.D.,


HEAD OF THE DEPARTMENT, INTERNAL GUIDE,
ASSISTANT PROFESSOR, ASSOCIATE PROFESSOR,
Dept. of Information Technology, Dept. of Information Technology,
Vel Tech Multi Tech Dr.Rangarajan Vel Tech Multi Tech Dr.Rangarajan

Dr.Sakunthala Engineering College Dr.Sakunthala Engineering College

42, Alamathi Road 42, Alamathi Road

Avadi, Chennai – 600062 Avadi, Chennai – 600062

ii
CERTIFICATE OF EVALUATION

College Name : VEL TECH MULTI TECH Dr. RANGARAJAN


Dr. SAKUNTHALA ENGINEERING COLLEGE.

Branch : INFORMATION TECHNOLOGY

Semester : VIII

S. No NAME OF THE STUDENT TITLE OF NAME OF THE


WHO HAS DONE THE THE SUPERVISOR
PROJECT
PROJECT

1. V.ARAVINDAN ENHANCED Dr. M. Rajesh


NETWORK Khanna, B.Tech,
[113115205009] M.E, Ph.D.,
SECURITY
USING ASSOCIATE
2. G. SURIYA PRAKASH
THREE PROFESSOR

[113115205065] LEVEL DEPARTMENT OF


SECURITY INFORMATION
3. B.INDRAJITH TECHNOLOGY

[113115205023]

The report of this project work submitted by the above students in partial
fulfillment for the award of Degree of Bachelor of Technology in Information
Technology of Anna University was evaluated and confirmed to be the report of
work done by the above student. This project report was submitted for the viva-
voce held on at Vel Tech Multi Tech Dr.Rangarajan
Dr.Sakunthala Engineering College.

INTERNAL EXAMINER EXTERNAL EXAMINER

iii
ACKNOWLEDGEMENT

We wish to express our sincere thanks to almighty and the people who
extended their help during the course of our work.

We are greatly and profoundly thankful to our honorable Chairman, Col.


Prof. Vel. Shri Dr.R.Rangarajan B.E.(ELEC), B.E.(MECH), M.S.(AUTO), D.Sc.,
& Vice Chairman, Dr. Sakunthala Rangarajan MBBS., for facilitating us with
this opportunity.

We take this opportunity to extend our gratefulness to our respectable


Chairperson & Managing Trustee Smt. Rangarajan Mahalakshmi Kishore
B.E., M.B.A., for her continuous encouragement.

Our special thanks to our cherishable Vice- President Mr.K.V.D. Kishore


Kumar B.E., M.B.A., for his attention towards students community.

We also record our sincere thanks to our honourable Principal,


Dr.V.Rajamani M.E., Ph.D., for his kind support to take up this project
and complete it successfully.

We would like to express our special thanks to our Head of the Department
Mr.R.Prabu, M.Tech., Department of Information Technology Engineering and
our project supervisor Dr.M.Rajesh Khanna, B.Tech, M.E, Ph.D., for their
moral support by taking keen interest on our project work and guided us all along,
till the completion of our project work.

Further, the acknowledgement would be incomplete if we would not


mention a word of thanks to our most beloved Parents for their continuous
support and encouragement all the way through the course that has led us
to pursue the degree and confidently complete the project work.

iv
TABLE OF CONTENTS

CHAPTER NO. TITLE PAGE NO.

ABSTRACT ix

LIST OF FIGURES vii

LIST OF ABBREVIATIONS viii

1. INTRODUCTION 1

1.1 OVERVIEW OF THE PROJECT 1


1.2 OBJECTIVE
2

2. SYSTEM ANALYSIS 2

2.1 LITERATURE SURVEY 4


2.2 EXISTING SYSTEM 7
2.2.1 Disadvantages 7
2.3 PROPOSED SYSTEM 7
2.3.1 Construction of Magic Rectangle 8
2.3.2 Magic Rectangle Generation
8
2.3.3 Advantages
8

3. SYSTEM IMPLEMENTATION 10

3.1 HARDWARE REQUIREMENTS 10

3.2 SOFTWARE REQUIREMENTS 10


4. SYSTEM MODULES 11

4.1 SYSTEM ARCHITECTURE 11


4.1.1 MODULE DESCRIPTION
11
4.1.1.1 Generation of MRGA
11
4.1.1.2 Mapping
11
4.1.1.3 Encryption
12
4.1.1.4 Decryption
12
4.1.1.5 3-Prime RSA Formation
12

11
5. SYSTEM DESIGN 14

5.1 UML DIAGRAMS 14


5.1.1 USE CASE DIAGRAM
15
5.1.2 SEQUENCE DIAGRAM
16
5.1.3 ACTIVITY DIAGRAM
17
5.1.4 CLASS DIAGRAM
18
5.1.5 COLLABORATION DIAGRAM
19
5.1.6 DEPLOYMENT DIAGRAM 20
5.1.7 PACKAGE DIAGRAM 21

6. CONCLUSION 22

7. FUTURE ENHANCEMENT 22

APPENDIX I (SOURCE CODE) 23


APPENDIX II (SNAP SHOT) 60

REFERENCES 69

LIST OF FIGURES

S.NO FIGURES PAGE NO

4.1 System Architecture 11

5.1.1 Use Case Diagram 15


5.1.2 Sequence Diagram 16
5.1.3 Activity Diagram 17
5.1.4 Class Diagram 18
5.1.5 Collaboration Diagram 19
5.1.6 Deployment Diagram 20

5.1.7 Package Diagram 21

vii

LIST OF ABBREVIATIONS

ABBREVIATIONS EXPANSION

RSA Rivest-Shamir-Adlmen
IDE Integrated Development Environment

MR Magic Rectangle
AES Advanced Encryption Standard
DES Data Encryption Standard

RC4 Rivest Cipher 4

MRGA Magic Rectangle Generation Algorithm

viii

ABSTRACT

The main objective of this project titled “ ENHANCED NETWORK SECURITY


USING THREE LEVEL SECURITY” is to provide more secured crypt analysis
technique by enhancing the randomness in the encryption process. Here 3-
prime RSA along with magic rectangle is used. Two crypt analysis techniques
are merged and in place of 2-prime RSA ,3-prime RSA is used to make data
more secured than any other previous techniques.
In today’s world, security is required to transmit confidential information over
the network. Security is also demanded in wide range of applications.
Cryptographic algorithms play an important role in providing the data security
against malicious attacks. The efficiency of cryptographic algorithm is not only
based on its time taken for encryption and decryption, and it also accounts for
number of stages used to obtain the cipher text from a plain text. Rivest-Shamir-
Adleman (RSA) algorithm is a popular encryption scheme that guarantees
confidentiality and authenticity over an insecure communication channel.
However, several attacks are introduced to break the security of these
algorithms due to certain constraints. Also, it may not be guaranteed that the
cipher text is fully secured. One such limitation in the past crypto system is
using ASCII Characters for numerical representation of the selected text. To
overcome the above said issue, an innovative algorithm, namely, Magic
Rectangle is being proposed in this work. It is helpful to enhance the security on
account of its complexity of the encryption process.

ix
CHAPTER 1

INTRODUCTION

1.1 OVERVIEW OF THE PROJECT

The efficiency of cryptographic algorithm is not only based on the time taken
for encryption and decryption, but also the number of levels used to get the cipher text
from a plain text. The public key cryptosystem RSA is one of the widely used
algorithms. However, several attacks are introduced to break this algorithm due to
certain limitations. Also, it may not be guaranteed that the cipher text is fully secured.
One of such limitations in the past cryptosystem is using ASCII characters for numerical
representation of the text. To overcome the above said limitation, an innovative
algorithm namely Magic Rectangle Generation Algorithm (MRGA) is being proposed in
this work. It is helpful to enhance the security due to its complexity in encryption
process. The singly even magic rectangle is formed based on the seed number, start
number, row sum and column sum. The value of row sum and column sum is very
difficult to be traced. The proposed work introduces one more level of security in public
key algorithms such as RSA, ElGAMAL etc. Finally, MRGA helps to overcome the
weakness of public key cryptosystem. Cipher text developed by this method can be
entirely different when compared to the plain text and will be suitable for the secured
transmission over the internet. Cryptography is a science of secret writing. It is the
technique of defending the information by transforming it into an unreadable format in
which a message can be hidden from the casual reader and only the intended recipient
will be able to convert it into original text. It is the study of mathematical techniques
related to aspects of information security such as confidentiality, Data Integrity, user
validation, and data source authentication. Symmetric and Asymmetric keys are the two
categories of cryptography algorithms. In Symmetric keys encryption or secret key
1
encryption, for encryption and decryption of data a single key is used. The secret key is
known only to the sender and receiver of a message who can apply the same key for
encryption and decryption process. The main challenge is getting the sender and receiver
to agree on the secret key without anyone else finding out. The key should be distributed
before transmission between entities. The concept of public- key cryptography was
brought into use during 1976 by Whitfield Diffie and Martin Hellman to overcome the
key management issues. Two separate keys are used in Public-key cryptography. The
first key is acting as a secret key and the remaining one is public. Even though these
keys are different, the two parts of the key pair are mathematically linked. The
algorithms used for public key cryptography are based on mathematical relationships
such as integer factorization an discrete logarithms.

1.2 OBJECTIVE

Add-on Security Level for Public Key Cryptosystem using Magic Rectangle
with Column/Row Shifting to provide encryption and decryption more efficient by
applying two thick layer of security. To provide encryption and decryption more efficient
by applying two thick layer of security. The parameters used in encryption and decryption
process of the algorithm plays a vital role for security. In RSA, the secret key is derived
from the public key and choosing p and q with very large size. Even though the above
parameters are considered carefully in RSA, it is not fully secured because of using ASCII
character. The same cipher text value will be repeated if the same character is repeated
more than one place in the plain text. To overcome this problem, this paper tries to
develop a method with different singly even magic rectangle of the order 32 x 48. Thus
preferably different numerals representing the position of ASCII values are taken from
magic rectangle. The encryption process is being performed using RSA crypto-system. It
provided another layer of security to any public key algorithm. Sonia Goyat proposed an
algorithm pertaining to the application of Genetic algorithm to cryptography and modifies

2
the approach to generate keys that have more strength. There is no repetition of random
values used in key generation. Proposed a work focuses on factorization of all trivial and
nontrivial integer numbers and requires fewer steps for factorization process of RSA
modulus N. The Pollard rho factorization method forms the basis for New Factorization
method. Sonal Sharma, Saroj Hiranwal, Prashant Sharma[6] present a new algorithm
(Modified Subset-Sum cryptosystem over RSA) which is secured against various types of
Mathematical attacks on RSA as well as Shamir attacks.

Analyzed the speed of RSA public key cryptosystem to reduce the time taken for finding
factor for a large number, and proposed a new algorithm and its performance was
compared with Fermats factorization Algorithm and trial division algorithm. The security
of RSA cryptography algorithm based on additive homomorphic properties. The proposed
algorithm is secured based on the factoring problem as well as decisional composite
residuosity assumption. It is observed that whenever the file size is increases, the total
time for encryption and decryption process will also increases as shown in. The limitation
in the proposed work is that it needs additional time to construct magic rectangle initially.
However, encryption and decryption process does not call for any addition time. The
randomness of the value of magic rectangle enhances the security of the cipher text. In the
existing concept of ASCII, the cipher text values are repeated whenever the same
characters are repeated in the plain text.

CHAPTER 2

3
SYSTEM ANALYSIS

2.1 LITERATURE SURVEY

TITLE : Enhancing the Security in Cryptosystems Based on Magic


Rectangle

AUTHOR : Mani. K, Viswambari. M

YEAR : 2017

Description: The security of any cryptosystems is based on the way in which it produces
different ciphertext for the same plaintext. Normally, various block cipher modes viz.,
CBC, OFC, etc., are used in producing different ciphertext for the same plaintext but it is
a time consuming process. Instead of using block cipher, a different encoding method for
the plaintext is proposed in this paper using magic rectangle. The advantage of using the
encoding scheme is different numerals is used in encoding each characters of a plaintext.
Thus instead of considering the ASCII encoding for a character to be encrypted, the
numeral which occurs at the position which corresponds to the ASCII value of the
character is taken from the magic rectangle. Further, different numerals from magic
rectangles for the same character are produced by considering the magic sum, starting
number and template of magic rectangle. Once the magic rectangles are created, the
numerals which occur in the magic rectangles are considered for the encoding of the
plaintext character which is then used for encryption in the cryptosystems like RSA,
ElGamal. The proposed work provides an additional layer of security to any public key
cryptosystems. As this model is acting as a wrapper to any public key cryptosystems, it
ensures enhanced security.
TITLE : Add-on Security Level for Public Key Cryptosystem using
Magic Rectangle
4
AUTHOR : Hardik Gandhi,Vinit gupta,Rajput

YEAR : 2015

Description: The methodology of the proposed security model is described in the


following steps. Construct different singly even magic rectangle of order 32x48 and used
in lieu of ASCII table with 128 values. The Magic rectangle contains totally 1536 values.
It has been divided into 12 quadrants, each consists of 128 characters. Each character of
the plain text is converted into numerals based on its position in magic rectangle in
different quadrants. The numerals are then encrypted and decrypted using RSA
algorithm. It is observed that whenever the file size is increases, the total time for
encryption and decryption process will also increases. The limitation in the proposed
work is that it needs additional time to construct magic rectangle initially. However,
encryption and decryption process does not call for any addition time. The randomness
of the value of magic rectangle enhances the security of the cipher text. In the existing
concept of ASCII, the cipher text values are repeated whenever the same characters are
repeated in the plain text. In the proposed magic rectangle, different values are applied in
the cipher text for each occurrence of same character in plain text. It enhances of the
security of the cipher text. Instead of single ASCII table, 12 tables with different set of
values are used. It is more complicated to identify the value of MR assigned.

TITLE : A Research on Enhancing Public Key Cryptography

5
AUTHOR : Alaa Hussein Al-Hamami and Ibrahem abdallah aldariseh,
“Enhanced Method of RSA cryptosystem Algorithm”,Kuala Lampur

YEAR : 2013

DESCRIPTION : This work prohibits any intruders from obtaining the plain text in a
readable form. The security aspect is enhanced as there is no repetition of values in Magic
rectangle. There are several parameters used to increase the time complexity for the
construction of magic rectangle such as seed value, column sum, Minstart and Maxstart
values. Even if the intruders found the initial values of MR, it is very difficult to trace the
row/column. It plays a vital role in increasing the randomness and security of the
algorithm. And the use of RSA have the issue that the prime numbers used should be more
than 100. So have taken N-prime RSA so that more than two prime numbers will be used
and that can make the prediction of prime numbers som what easier. And the other thing is
that two same character in plain text do not have same cipher text. One of the issues in the
proposed work is additional time needed for the construction of Magic rectangle initially.

 A Third prime is used in the RSA process.

 Each number has 100 digits and “n” has 300 digits as before.

 Speed of the algorithm has increased

 Complexity of analysis has increased

2.2 EXISTING SYSTEM

6
Maintaining a database for this problem also has lots of problem with it.
 Two large prime numbers are used
 RSA Cryptosystem is used to generate keys
 Plaintext is encrypted with respect to ASCII values
 Cipher text is decrypted by RSA
 Repeated characters will have repeated ciphers.

2.2.1 DRAWBACKS

 Time taken to factorize n is less.

 It relies upon factoring problem only ,i.e single layer security.

 Prime numbers should be carefully chosen such that they are not relatively

close and small.

2.3 PROPOSED SYSTEM

The methodology of the proposed security model is described in the following steps.
Construct different singly even magic rectangle of order 32x48 and used in lieu of ASCII
table with 128 values. The Magic rectangle contains totally 1536 values. It has been
divided into 12 quadrants, each consists of 128 characters. Each character of the plain
text is converted into numerals based on its position in magic rectangle in different
quadrants. The numerals are then encrypted and decrypted using RSA algorithm.

This methodology of the security model is shown in figure 4.1

2.3.1 Construction of Magic Rectangle

The magic square concept forms the basis for magic Rectangle. A magic square of order
7
n is an arrangement of integers in an nxn matrix such that the sums of all the elements in
every row, column are equal. In addition, the sums of all elements along the two main
diagonals are also equal. The magic constant of a magic square depends only on n and
has the value

M (n) = n (n2 + 1) / 2

Magic square can be classified into three types: odd, doubly even (n divisible by four),
singly even (n is even and not divisible by four) .

2.3.2 Magic Rectangle generation

The MR algorithm started with the input values Minstart, Maxstart, column sum and
seed value. The seed value is the 4 bit binary value. If the input seed value is ‘1’ bit, then
either row or column of Magic Rectangle is shifted circularly. Otherwise shifting of row
or column is not warranted. The Pseudo code of the above concept is shown in Figure 3.

This methodology is implemented in Java. The time taken for encryption and decryption
of various size of file message are measured. As an illustration, the following magic
rectangles are generated with row sum as 4629 and column sum as 3086. In this
experiment, the seed value is 0010. The first, second and the last Magic rectangles are
unchanged as the respective seed value is ‘0’. The column values are shifted circularly in
the third Magic rectangle since the seed value for the same is ‘1’.

2.3.3 ADVANTAGES:

8
It is observed that whenever the file size is increases, the total time for encryption and
decryption process will also increases. The limitations in the proposed work it that it needs
additional time to construct magic rectangle initially. However, encryption and decryption
process does not call for any addition time. The randomness of the value of magic
rectangle enhances the security of the cipher text. In the existing concept of ASCII, the
cipher text values are repeated whenever the same characters are repeated in the plain text.
In the proposed magic rectangle, different values are applied in the cipher text for each
occurrence of same character in plain text. It enhances of the security of the cipher text.
Instead of single ASCII table, 12 tables with different set of values are used. It is more
complicated to identify the value of MR assigned into the plain text by any intruders.

It is summarized that,

1. Each communication session uses a newly generated Magic Rectangle

2. Increases the randomness of the cipher text value even though the characters are
repeated.

3. Can generate rectangles from any values with equal row sums and column sums.

4. No change in the encryption and decryption time using MR.

5. Increases the complexity to derive the plain text from the cipher text by any intruders.

6. Capable of applying MR in any Public key algorithms.

7. To overcome the existing issues in RSA algorithm.

CHAPTER 3

SYSTEM IMPLEMENTATION

9
3.1 HARDWARE REQUIREMENTS:

Hardware Specifications

System Pentium IV 2.4 GHz.

Hard Disk 500 GB

Monitor 15 VGA Color

RAM 4 GB

3.2 SOFTWARE REQUIREMENTS:

Software Specifications

Operating system Windows XP/7/8.

Coding Language Java

Tool Net Beans 7.4

10
CHAPTER 4

SYSTEM MODULES

4.1 SYSTEM ARCHITECTURE:

Fig: 4.1 System Architecture

11
4.1.1 MODULE DESCRIPTION

4.1.1.1 Generation of MRGA

The column sum(32*48), min start and max start is obtained to


compute MR.Magic square can be classified into three types namely odd, doubly
even (n divisible by four) and singly even (n is even and not divisible by four). A
magic rectangle of order mxn is an arrangement of integers such that the sums of
all the elements in every row are equal and also the sums of all the elements in
every column are equal. The magic rectangle is in the category of singly even.ie,
the order of the matrix is even but not divisible by four such as 4x6, 8x12,etc.

4.1.1.2 Mapping

Input ASCII value are mapped with numerals in quadrants.


The most well known algorithm design strategies are to divide instance of
problem into two or more smalle instances such as Solving smaller instances
recursively Obtaining solution to original instance combining these solution In
magic rectangle , column sum is fixed as 16x24 . The existing column sum is
divided by two and then apply in 8x12. Further the column sum is divided by
two and apply in 4x6 matrix. This approach is adapted from divide and
conquer strategy.

4.1.1.3 Encryption

The mapped numeral is sent to 3-prime RSA to obtain cipher.


The column sum is taken as even value then it matches exactly in magic
rectangle.In case of, the column sum is taken as odd value then the column
sum is reduced by one because of fractional value. For example, the initial

12
column sum is taken as a odd value such as 12345. The column sum generated
by the rectangle is 12344.

4.1.1.4 Decryption

The cipher is decrypted to get numerals. The given message is


“HELLO”. First, each and every character of the message is converted to the
numerical value by using magic rectangle. The ASCII value of ‘H’,’E’,’L’,’O’
is 72,69,76 and 76 respectively. To encrypt ‘H’, the value of the 72 position in
the first MR 16x24 is taken, then the value of the second and third characters
are also taken from the same matrix. The character ‘L’ is repeated twice
consecutively in the plain text. The first occurrence of ‘L’ value is taken from
one matrix of order 16*24 and the second occurrence uses another matrix of
the same size. So the value of the cipher text cannot be repeated even if the
character is repeated more than once.

4.1.1.5 3-Prime RSA Formation

Choose three distinct prime numbers p, q and s.And find n such that
n = p*q*s. ‘N’ will be used as the modulus for both the public and private
keys. Then find the Phi of n, ¥(n) = (p-1)(q-1)(s-1).Finally choose an e such
that 1 < e < ¥ (n), and such that e and ¥ (n) share no divisors other than 1 (e
and ¥ (n) are relatively prime). At last ‘E’ is kept as the public key exponent.
Then determine d (using modular arithmetic) which satisfies the congruence
relation .d=e ^- 1 (mod ¥ (n)).

13
CHAPTER 5

SYSTEM DESIGN

5.1 UML DIAGRAMS

UML is simply User graphical representation of a common


semantic model. UML provides a comprehensive notation for the full
lifecycle of object- oriented development.

To represent complete systems (instead of only the software


portion) using object oriented concepts.To establish an explicit
coupling between concepts and executable code.

To take into account the scaling factors the inherent to complex


and critical systems.
a) To creating a modeling language usable by both humans
and machines.
b) UML defines several models for representing systems.
c) The class model captures the static structure.
d) The state model expresses the dynamic behavior of objects.
e) Te use case model describes the requirement of the user.
f) The interaction model represents the scenarios and messages flows.
g) The implementation model shows the work units.
h) The development model provides details that pertain to
process allocation.

14
5.1.1 USE CASE DIAGRAM

Fig: 5.1.1 Use Case Diagram

DESCRIPTION :

The user receives the ascii message before starting the process. Then magic
rectangle is generated based on some conditions. Then the ascii message or ascii
values are mapped to the MRG values and they are encrypted. The encrypted
key is passed to the receiver in order to decrypt the same message. The
decryption process is performed similar to encryption process and hence the
plaintext is obtained.
15
5.1.2 SEQUENCE DIAGRAM

Fig: 5.1.2 Sequence Diagram

DESCRIPTION :

The ascii message is mapped with MRG values. The resultant would be
randomized input, which is further used to generate key. The encrypted cipher is
sent to the receiver for decryption process. The decryption process is performed
similar to encryption process and hence the plaintext is obtained. After all the
process acknowledgement will be sent to the user.

16
5.1.3 ACTIVITY DIAGRAM

Fig: 5.1.3 Activity Diagram

DESCRIPTION :

In this process, the quadrant separation is done. The quadrants are generated
based on the some conditions. It uses several parameters such as min_start,
max_start, column_sum and so on. Only after generating magic rectangle the
mapping process is performed. Thus, the input message is encrypted and then
decrypted within few process.

5.1.4 CLASS DIAGRAM


17
Fig: 5.1.4 Class Diagram

DESCRIPTION :

There are several classes such as 3-prime RSA, Receiver, Mapping, Sender, and
finally MRGA. It even has 1 to 1 mapping and 1 to many mapping. The classes
consist of objects such as seed value, sender id etc. The classes communicate
with other classes through objects.

5.1.5 COLLABORATION DIAGRAM

18
Fig: 5.1.5 Collaboration Diagram

DESCRIPTION :

It is similar to class diagram. All the properties, objects, etc used by the classes
are also used by the collaboration diagram. It is similar to interaction diagram.
There are several classes such as 3-prime RSA, Receiver, Mapping, Sender, and
finally MRGA. The process is performed based on step by step manner.

5.1.7 DEPLOYMENT DIAGRAM

19
Fig: 5.1.7 Deployment Diagram

DESCRIPTION :

The entire system is deployed by this deployment diagram. The tools and
databases are used to represent the outside layer of the system. The java runtime
environment is used and all the data contents are fetched from databases. The
operating system is used in order to run the softwares related to the system.

5.1.8 PACKAGE DIAGRAM

20
Fig: 5.1.8 Package Diagram

DESCRIPTION :

They maintain packages since a single package consist of several classes,


methods, objects, etc. The entire system is represented through 3 major
packages and several sub packages. The UI package deals with all the visual
entities, components and validation. The Domain package performs all
operations that are required for the system. The technical layer provides
authentication to the message contents.

CONCLUSION

21
• The encryption and decryption has become efficient

• The Cryptanalysis is worsened because of complication in factoring


problem.

• Randomness is further increased and so the security gets enhanced.

• Another layer of security is added to the existing RSA cryptosystem.

• Mapping ascii values with MRGA is a unique process and is more


effective,

FUTURE ENHANCEMENT

• The order of magic rectangle can be increased from 32*48 to 64*96.

• The randomness is increased enormously but the time taken is very high.

• Chosen prime number should not be much higher and it should not be
much lower as both are prone to attacks.

• The improvement in choosing the prime number and reducing the time
for matrix generation and mapping needs to be done.

APPENDIX-I

SOURCE CODE

MRGAlgorithm.java
22
package mrgalgorithm;

import java.util.ArrayList;

import java.util.List;

import java.util.Scanner;

import java.lang.*;

import java.math.BigInteger;

import java.util.ArrayList;

import java.util.HashMap;

import java.util.List;

import java.util.Map;

import java.util.Scanner;

import javax.swing.JOptionPane;

import javax.swing.JFrame;

public class MRGAlgorithm {

private static final Scanner scanner = new Scanner(System.in);

23
String input;

public static void main(String[] args) {

new MRGAlgorithm().start();

private void start() {

System.out.println("**************** MRG Algorithm

*******************");

System.out.println("Enter Column Sum for 32*48 matrix: ");

final Integer colSum = scanner.nextInt();

final Integer _4Into6colSum = compute4Into6ColumnSum(colSum);

final Integer _4Into6RowSum =

compute4Into6RowSum(_4Into6colSum);

final Integer pivot = _4Into6RowSum - _4Into6colSum;

System.out.println("Pivot : " + pivot);

generateMatrix(pivot);

}
24
private void generateMatrix(Integer pivot) {

final List < Integer[][] > _16Into24Matrixes = new ArrayList <

Integer[][] > ();

final List < Integer[][] > _8Into12Matrixes = new ArrayList <

Integer[][] > ();

final List < Integer[][] > _4Into6Matrixes = new ArrayList <

Integer[][] > ();

int count = 4;

for (int i = 1; i <= 64; i++) {

final Integer minStart = count;

System.out.println("Min Start : " + minStart);

final Integer maxStart = pivot - count;

System.out.println("Max Start : " + maxStart);

count += i % 2 != 0 ? 32 : 16;

final Integer _4Into6[][] = new Integer[4][6];

generate4Into6Matrix(_4Into6, maxStart, minStart);

25
_4Into6Matrixes.add(_4Into6);

display(_4Into6);

if (i % 4 == 0) {

final Integer _8Into12[][] =

combineMatrix(_4Into6Matrixes.get(0), _4Into6Matrixes.get(1),

_4Into6Matrixes.get(2), _4Into6Matrixes.get(3));

display(_8Into12);

_8Into12Matrixes.add(_8Into12);

_4Into6Matrixes.removeAll(_4Into6Matrixes);

if (i % 16 == 0) {

final Integer[][] _16Into24 =

combineMatrix(_8Into12Matrixes.get(0), _8Into12Matrixes.get(1),

_8Into12Matrixes.get(2), _8Into12Matrixes.get(3));

display(_16Into24);

_16Into24Matrixes.add(_16Into24);

26
_8Into12Matrixes.removeAll(_8Into12Matrixes);

Integer[][] _32Into48 = combineMatrix(_16Into24Matrixes.get(0),

_16Into24Matrixes.get(1), _16Into24Matrixes.get(2),

_16Into24Matrixes.get(3));

display(_32Into48);

Map < Integer, Integer[] > map = quadrant_separation(_32Into48);

System.out.println();

input = JOptionPane.showInputDialog(null, "Enter message to

encrypt");

//JOptionPane.showInputDialog(input);

JFrame frame = new JFrame(input);

JOptionPane.showMessageDialog(frame, input);

doEncryption(map, input);

27
private void doEncryption(Map < Integer, Integer[] > map, String

input) {

int count;

StringBuilder builder = new StringBuilder();

char[] chars = input.toCharArray();

Integer[] quadrants = new Integer[input.length()];

System.out.println("\n\nMapped values for the given input

message:\n");

for (int i = 0; i < chars.length; i++) {

count = getCount(chars[i], i, input);

if (count > 12)

count = count % 12;

quadrants[i] = map.get(count)[(int) chars[i]];

System.out.println(quadrants[i]);

BigInteger[] bigIntegerArray = new BigInteger[quadrants.length];


28
for (int i = 0; i < quadrants.length; i++)

bigIntegerArray[i] = BigInteger.valueOf(quadrants[i]);

BigInteger[] eValue = new BigInteger[quadrants.length];

RSA rsa = new RSA(8);

eValue = rsa.RSAencrypt(bigIntegerArray);

System.out.print("\n the encrypted cipher is:\n");

for (int i = 0; i < input.length(); i++) {

System.out.println("\t" + eValue[i]);

// JOptionPane.showMessageDialog(null,"Encrypted cipher:

"+"\n"+eValue[i]);

BigInteger[] dValue = new BigInteger[input.length()];

dValue = rsa.RSAdecrypt(eValue);

System.out.println("decrypted value : ");

// rsa.RSAdecrypt(eValue);

29
//System.out.println("\nThe decrypted value is:");

for (int i = 0; i < dValue.length; i++) {

System.out.print("\t" + dValue[i]);

//System.out.println("\nThe plain text is:"+input);

private int getCount(Character c, int index, String input) {

String temp = input.substring(0, index);

int count = 1;

while (temp.contains(c.toString())) {

temp = temp.substring(0, temp.lastIndexOf(c));

count++;

return count;

30
private void doDecryption() {

private Integer compute4Into6ColumnSum(Integer colSum) {

return colSum / 8;

private Integer compute4Into6RowSum(Integer colSum) {

return (colSum / 2) + colSum;

private void generate4Into6Matrix(Integer mr[][], int maxStart, Integer

minStart) {

mr[0][0] = maxStart;

mr[0][1] = minStart + 2;

mr[0][2] = minStart + 4;

mr[0][3] = maxStart - 6;

mr[0][4] = maxStart - 16;

31
mr[0][5] = minStart + 16;

mr[1][0] = minStart + 8;

mr[1][1] = maxStart - 10;

mr[1][2] = maxStart - 12;

mr[1][3] = minStart + 14;

mr[1][4] = minStart + 24;

mr[1][5] = maxStart - 24;

mr[2][0] = maxStart - 14;

mr[2][1] = minStart + 12;

mr[2][2] = minStart + 10;

mr[2][3] = maxStart - 8;

mr[2][4] = maxStart - 30;

mr[2][5] = minStart + 30;

mr[3][0] = minStart + 6;

mr[3][1] = maxStart - 4;

32
mr[3][2] = maxStart - 2;

mr[3][3] = minStart;

mr[3][4] = minStart + 22;

mr[3][5] = maxStart - 22;

private Integer[][] combineMatrix(Integer p[][], Integer q[][], Integer

r[][], Integer s[][]) {

int length = p.length * 2;

int m = p.length;

int n = p[0].length;

final Integer[][] matrix = new Integer[length][length + p.length];

buildfinalMatrix(0, 0, m, n, p, matrix);

buildfinalMatrix(0, n, m, n + n, q, matrix);

buildfinalMatrix(m, 0, m + m, n, r, matrix);

buildfinalMatrix(m, n, m + m, n + n, s, matrix);

33
return matrix;

private void buildfinalMatrix(int startM, int startN, int endM, int endN,

Integer[][] subMatrix, Integer[][] finalMatrix) {

for (int i = startM, x = 0; i < endM; i++, x++) {

for (int j = startN, y = 0; j < endN; j++, y++) {

finalMatrix[i][j] = subMatrix[x][y];

private void display(Integer matrix[][]) {

System.out.println("****** DISPLAY MATRIX ******");

for (int i = 0; i < matrix.length; i++) {

for (int j = 0; j < matrix[0].length; j++) {

34
System.out.print(matrix[i][j] + "\t");

System.out.println();

private Map < Integer, Integer[] > quadrant_separation(Integer

finalmatrix[][]) {

int p = 0, q = 4, count = 0;

Map < Integer, Integer[] > map = new HashMap < Integer, Integer[]

> ();

Integer _1dquad1[] = new Integer[128];

Integer _1dquad2[] = new Integer[128];

Integer _1dquad3[] = new Integer[128];

Integer _1dquad4[] = new Integer[128];

Integer _1dquad5[] = new Integer[128];

Integer _1dquad6[] = new Integer[128];


35
Integer _1dquad7[] = new Integer[128];

Integer _1dquad8[] = new Integer[128];

Integer _1dquad9[] = new Integer[128];

Integer _1dquad10[] = new Integer[128];

Integer _1dquad11[] = new Integer[128];

Integer _1dquad12[] = new Integer[128];

map.put(1, _1dquad1);

map.put(2, _1dquad2);

map.put(3, _1dquad3);

map.put(4, _1dquad4);

map.put(5, _1dquad5);

map.put(6, _1dquad6);

map.put(7, _1dquad7);

map.put(8, _1dquad8);

map.put(9, _1dquad9);

36
map.put(10, _1dquad10);

map.put(11, _1dquad11);

map.put(12, _1dquad12);

final Integer[][] quadrant_1 = new Integer[32][4];

final Integer[][] quadrant_2 = new Integer[32][4];

final Integer[][] quadrant_3 = new Integer[32][4];

final Integer[][] quadrant_4 = new Integer[32][4];

final Integer[][] quadrant_5 = new Integer[32][4];

final Integer[][] quadrant_6 = new Integer[32][4];

final Integer[][] quadrant_7 = new Integer[32][4];

final Integer[][] quadrant_8 = new Integer[32][4];

final Integer[][] quadrant_9 = new Integer[32][4];

final Integer[][] quadrant_10 = new Integer[32][4];

final Integer[][] quadrant_11 = new Integer[32][4];

final Integer[][] quadrant_12 = new Integer[32][4];

37
final List < Integer[][] > quadrant = new ArrayList < Integer[][] > ();

System.out.println("****** QUADRANT SEPARATION******");

for (int k = 1; k <= 12; k++) {

count = 0;

for (int l = p; l < q; l++) {

for (int m = 0; m < 32; m++) {

if (k == 1) {

quadrant_1[m][count] = finalmatrix[m][l];

} else if (k == 2) {

quadrant_2[m][count] = finalmatrix[m][l];

} else if (k == 3) {

quadrant_3[m][count] = finalmatrix[m][l];

} else if (k == 4) {

quadrant_4[m][count] = finalmatrix[m][l];

} else if (k == 5) {

38
quadrant_5[m][count] = finalmatrix[m][l];

} else if (k == 6) {

quadrant_6[m][count] = finalmatrix[m][l];

} else if (k == 7) {

quadrant_7[m][count] = finalmatrix[m][l];

} else if (k == 8) {

quadrant_8[m][count] = finalmatrix[m][l];

} else if (k == 9) {

quadrant_9[m][count] = finalmatrix[m][l];

} else if (k == 10) {

quadrant_10[m][count] = finalmatrix[m][l];

} else if (k == 11) {

quadrant_11[m][count] = finalmatrix[m][l];

} else if (k == 12) {

quadrant_12[m][count] = finalmatrix[m][l];

39
}

count++;

p = p + 4;

q = q + 4;

quadrant.add(quadrant_1);

quadrant.add(quadrant_2);

quadrant.add(quadrant_3);

quadrant.add(quadrant_4);

quadrant.add(quadrant_5);

quadrant.add(quadrant_6);

40
quadrant.add(quadrant_7);

quadrant.add(quadrant_8);

quadrant.add(quadrant_9);

quadrant.add(quadrant_10);

quadrant.add(quadrant_11);

quadrant.add(quadrant_12);

System.out.println("the quadrants are:\n");

System.out.print("\n quadrant : 1 \n");

int b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad1[b] = quadrant_1[i][j];

b++;

41
display_quadrants(quadrant_1);

display_one_d(_1dquad1);

System.out.print("\n quadrant : 2 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad2[b] = quadrant_2[i][j];

b++;

display_quadrants(quadrant_2);

display_one_d(_1dquad2);

System.out.print("\n quadrant : 3 \n");

b = 0;

for (int i = 0; i < 32; i++) {

42
for (int j = 0; j < 4; j++) {

_1dquad3[b] = quadrant_3[i][j];

b++;

display_quadrants(quadrant_3);

display_one_d(_1dquad3);

System.out.print("\n quadrant : 4 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad4[b] = quadrant_4[i][j];

b++;

43
display_quadrants(quadrant_4);

display_one_d(_1dquad4);

System.out.print("\n quadrant : 5 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad5[b] = quadrant_5[i][j];

b++;

display_quadrants(quadrant_5);

display_one_d(_1dquad5);

System.out.print("\n quadrant : 6 \n");

b = 0;

for (int i = 0; i < 32; i++) {

44
for (int j = 0; j < 4; j++) {

_1dquad6[b] = quadrant_6[i][j];

b++;

display_quadrants(quadrant_6);

display_one_d(_1dquad6);

System.out.print("\n quadrant : 7 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad7[b] = quadrant_7[i][j];

b++;

45
display_quadrants(quadrant_7);

display_one_d(_1dquad7);

System.out.print("\n quadrant : 8 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad8[b] = quadrant_8[i][j];

b++;

display_quadrants(quadrant_8);

display_one_d(_1dquad8);

System.out.print("\n quadrant : 9 \n");

b = 0;

for (int i = 0; i < 32; i++) {

46
for (int j = 0; j < 4; j++) {

_1dquad9[b] = quadrant_9[i][j];

b++;

display_quadrants(quadrant_9);

display_one_d(_1dquad9);

System.out.print("\n quadrant : 10 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad10[b] = quadrant_10[i][j];

b++;

47
display_quadrants(quadrant_10);

display_one_d(_1dquad10);

System.out.print("\n quadrant : 11 \n");

b = 0;

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

_1dquad11[b] = quadrant_11[i][j];

b++;

display_quadrants(quadrant_11);

display_one_d(_1dquad11);

System.out.print("\n quadrant : 12 \n");

b = 0;

for (int i = 0; i < 32; i++) {

48
for (int j = 0; j < 4; j++) {

_1dquad12[b] = quadrant_12[i][j];

b++;

display_quadrants(quadrant_12);

display_one_d(_1dquad12);

return map;

private void display_quadrants(Integer sub_quads[][]) {

System.out.print("\n ");

for (int i = 0; i < 32; i++) {

for (int j = 0; j < 4; j++) {

49
System.out.print(sub_quads[i][j] + "\t");

System.out.print("\n");

private void display_one_d(Integer sub_quads[]) {

for (int i = 0; i < 128; i++) {

System.out.print("\t" + sub_quads[i]);

if (i % 32 == 0 && i != 0) {

System.out.print("\n");

50
RSA.java

package mrgalgorithm;

import java.math.BigInteger;

import java.util.Random;

import java.io.*;

import java.io.*;

import java.util.*;

import java.sql.*;

import javax.swing.*;

public class RSA {

/**

* Bit length of each prime number.

*/

int primeSize;

/**

* Two distinct large prime numbers p and q.

*/

BigInteger p, q, s;

/**

* Modulus N.

*/

51
BigInteger N;

/**

*r=(p-1)*(q-1)

*/

BigInteger r;

/**

* Public exponent E and Private exponent D

*/

BigInteger E, D;

String nt, dt, et;

/**

String publicKey;

String privateKey;

String randomNumber;

BigInteger[] ciphertext;

int m[] = new int[1000];

String st[] = new String[1000];

String str = "";

String sarray1[] = new String[100000];

StringBuffer sb1 = new StringBuffer();

String inputMessage, encryptedData, decryptedMessage;

public RSA(int primeSize) {

52
this.primeSize = primeSize;

// Generate two distinct large prime numbers p and q.

generatePrimeNumbers();

// Generate Public and Private Keys.

generatePublicPrivateKeys();

BigInteger publicKeyB = getE();

BigInteger privateKeyB = getD();

BigInteger randomNumberB = getN();

publicKey = publicKeyB.toString();

privateKey = privateKeyB.toString();

randomNumber = randomNumberB.toString();

System.out.println("Public Key (E,N): " + publicKey + "," +


randomNumber);

System.out.println("Private Key (D,N): " + privateKey + "," +


randomNumber);

//Encrypt data

//inputMessage=JOptionPane.showInputDialog(null,"Enter message
to encrypt");

//encryptedData=RSAencrypt(inputMessage);

//System.out.println("Encrypted message"+encryptedData);

//JOptionPane.showMessageDialog(null,"Encrypted Data
"+"\n"+encryptedData);

//Decrypt data

//decryptedMessage=RSAdecrypt();

53
//JOptionPane.showMessageDialog(null,"Decrypted Data
"+"\n"+decryptedMessage);

/**

* Generate two distinct large prime numbers p and q.

*/

public void generatePrimeNumbers() {

p = new BigInteger(primeSize, 10, new Random());

System.out.println("prime 1:" + p);

do {

q = new BigInteger(primeSize, 10, new Random());

while (q.compareTo(p) == 0);

System.out.println("prime 2:" + q);

do {

s = new BigInteger(primeSize, 10, new Random());

while (s.compareTo(q) == 0 && s.compareTo(p) == 0);

System.out.println("prime 3:" + s);

/**

* Generate Public and Private Keys.

*/
54
public void generatePublicPrivateKeys() {

N = p.multiply(q);

N = N.multiply(s);

System.out.println("The product of three primes is:" + N);

r = p.subtract(BigInteger.valueOf(1));

r = r.multiply(q.subtract(BigInteger.valueOf(1))); //(p-1)(q-1)

r = r.multiply(s.subtract(BigInteger.valueOf(1))); //(p-1)(q-1) (s-1)

System.out.println("The value of phi function is:" + r);

do {

E = new BigInteger(2 * primeSize, new Random());

while ((E.compareTo(r) != -1) ||


(E.gcd(r).compareTo(BigInteger.valueOf(1)) != 0));

D = E.modInverse(r);

public BigInteger getp() {

return (p);

public BigInteger getq() {

return (q);

public BigInteger getr() {

return (r);

}
55
public BigInteger getN() {

return (N);

public BigInteger getE() {

return (E);

public BigInteger getD() {

return (D);

/** Encryption */

public BigInteger[] RSAencrypt(BigInteger[] quadrants) {

E = new BigInteger(publicKey);

N = new BigInteger(randomNumber);

try {

ciphertext = encrypt(quadrants);

} catch (Exception e) {

System.out.println(e);

return ciphertext;

public BigInteger[] encrypt(BigInteger[] quadrants) {

56
int i;

BigInteger[] encrypted = new BigInteger[quadrants.length];

for (i = 0; i < quadrants.length; i++)

encrypted[i] = quadrants[i].modPow(E, N);

return (encrypted);

public BigInteger[] RSAdecrypt(BigInteger[] eData) {

D = new BigInteger(privateKey);

N = new BigInteger(randomNumber);

System.out.println("D = " + D);

System.out.println("N = " + N);

//int k1= 0;

//StringTokenizer st = new StringTokenizer(eData);

//while (st.hasMoreTokens()) {

//sarray1[k1] = st.nextToken(" ");

//k1++;

//}

BigInteger[] decrypted = new BigInteger[eData.length];

for (int i = 0; i < decrypted.length; i++) {

57
System.out.println("encrypted value passed:" + eData[i]);

decrypted[i] = eData[i].modPow(D, N);

System.out.println("decryption value:" + decrypted[i]);

//char[] charArray = new char[decrypted.length] ;

//byte[] byteArray = new byte[decrypted.length] ;

//for( i = 0 ; i < charArray.length ; i++ ) {

//charArray[i] = (char) ( decrypted[i].intValue() ) ;

//Integer iv = new Integer(0);

//iv=decrypted[i].intValue() ;

//byteArray[i] = iv.byteValue();

//}

//try {

//rs=new String( byteArray );

//}

//catch (Exception e) {

//System.out.println(e);

//}

return (decrypted);

/**

* KeyGeneration Main program for Unit Testing.

*/

58
public static void main(String[] args) throws IOException {

RSA akg = new RSA(8);

APPENDIX – 2

SNAPSHOTS

INPUTS

59
GENERATING 4*6 MATRIX

60
GENERATING 8*12 MATRIX

61
GENERATING 16*24 MATRIX

62
GENERATING 32*48 MATRIX

63
SPLITTING INTO QUADRANTS

64
INPUT PLAIN TEXT

65
MRGA MAPPING AND 3-PRIME RSA KEY GENERATION

66
ENCRYPTION

67
DECRYPTION AND SEARCHING

REFERENCES

68
[1]. A.J.Menezes ,P.C.Van Oorschot, and S.Vanstone , “Handbook of Applied
cryptography”, CRC Press, Boca Ration,Florida, USA,1997.

[2]. Gopinath Ganapathy, and K.Mani , “ Add-On Security Model for public
key Cryptosystem Based on Magic Square Implementation”, ISBN 978-988-
17012-6-8, Proceedings of the world congress on Engineering and Computer
Science 2009 Vol I, San Fransisco, USA

[3]. Sharma, P. Gupta, A.K. ; Vijay, A. “Modified Integer Factorization


Algorithm Using V-Factor Method” Page(s): 423 - 425 ,978-0-76954640-7/12,
IEEE 2012.

[4]. Ravi Shankar Dhakar, Amit Kumar Gupta, Prashant Sharma ”Modified
RSA Encryption Algorithm(MREA)”- 978-0-7695-46407/12, IEEE2012.

[5]. Alaa Hussein Al-Hamami and Ibrahem abdallah aldariseh, “Enhanced


Method of RSA cryptosystem Algorithm”, 978-0-7695-4959-0/13 , IEEE2013

[6]. Sami A Nagar and Saad Alshamma, “High speed implementation of RSA
Algorithm with modified Keys exchange”, SETIT2012,IEEE

[7]. Adam Rogers, and Peter Loly ,”The inertial properties of Squares and
Cubes”, Nov-2004, pp.1-3.

[8]. en.wikipedia.org/wiki/Golden_rectangle

[9]. Omotheinwa T.O, Ramon S.O., “ Fibonacci Numbers and Golden Ratio
in Mathematics and Science”, International Journal of Computer and Information
Technology (ISSN”2279-0764) Volume 03-Issue 04, July 2013

[10]. Mohammad Zaidul Karim and Nargis Akter, “ Optimum Partition


Parameter of Divide-And-Conquer Algorithm for solving closest-Pair Problem”,

69
International Journal of Computer Science & Information Technology (IJCSIT)
Vol 3, No 5,Oct 2011.

[11]. B.Schenier. “Applied Cryptography”, John Wiley & Sons Inc, New
York, Second Edition, 1996.

[12]. William Stallings, ”Cryptography and Network Security”, Prentice Hall,


Upper Saddle River, New Jersy, USA, Second Edition ,1997.

70

Vous aimerez peut-être aussi