Documente Academic
Documente Profesional
Documente Cultură
BACHELOR OF TECHNOLOGY
IN
INFORMATION TECHNOLOGY
Submitted by
Assistant Professor,
Certificate
This is to certify that the project work entitled
ii
Sree Vidyanikethan Engg. College Sree Vidyanikethan Engg. College
ABSTRACT
There are many kinds of security methods like DES algorithm, RSA algorithm
etc, but the most recent and efficient algorithm being the NTRU public key algorithm.
The earlier algorithms are less efficient in time. The NTRU public key provides the
more time efficient key creation with message. Integrity (i.e. use independent keys for
every transaction).
iii
ACKNOWLEDGEMENT
Before getting into the thickness of the things, we would like to thank the
personalities who were part of my project in numerous ways, those who gave me
outstanding support from birth of this project.
First and foremost, we express our sincere gratitude to our beloved Chairman,
PADMASRI Dr. M. MOHAN BABU for constant encouragement and support.
We are extremely thankful to express our special officer Prof. T. GOPAL RAO
who took keen interest and encouraged us in every effort throughout this course.
We are thankful with profound respect and sincere thanks to esteem guide
Ms.K. JYOTHSNA DEVI, Assistant Professor for her invaluable support and offering
us complete cooperation.
We are very much grateful to all the faculty members of the IT department for their
value based imparting of theory and practical subjects, which we have put to use in our
iv
project work. We also thank the members of the non-teaching staff for their cooperation
and timely help
CONTENTS
CHAPTER NAME PAGE NO
ABSTRACT i
ACKNOWLEDGEMENT ii
1 INTRODUCTION 1
2 SYSTEM DESIGN 5
2.1. Design using UML diagrams 5
3 SYSTEM IMPLEMENTATION 13
3.1. Requirements 13
3.1.1. Hardware Requirements 13
3.1.2. Software Requirements 13
3.2. Project Implementation Details 14
3.2.1. Algorithm Analysis 14
3.2.1.1. Modular Arithmetic 14
3.2.1.2. Truncated Polynomial Rings 15
3.2.1.3. Inverse in Truncated Polynomials 15
3.2.1.4. Inverse of Polynomial modulo m 16
3.2.1.5. Extended Euclidean Algorithm 18
3.2.1.6. Montgomery for NTRU 19
3.2.2. Modular Description 20
3.2.2.1. NTRU PKCS Parameters 20
3.2.2.2. Key Generation 19
3.2.2.3. Encryption 22
3.2.2.4. Decryption 23
3.2.2.5. The Principle 24
4 TESTING 26
5 RESULTS 29
6 CONCLUSTIONS 33
v
7 REFERENCES 34
LIST OF TABLES
TABLE NO NAME
PAGE NO
2.2 Description for the use case Generate public private keys 7
2.3 Description for the use case Receive public private keys 8
vi
LIST OF FIGURES
vii
1. INTRODUCTION
1.1 CRYPTOGRAPHY:
Cryptography is an algorithmic process of converting a plain text
message to a cipher text message based on an algorithm that both the sender
and receiver know, so that the cipher text message can be returned to
its original, plain text form. In its cipher form, a message cannot be
read by anyone other than the intended receiver. The act of converting a
plain text message to its cipher text is called enciphering. Reversing that
act is deciphering. Enciphering and deciphering are most commonly
referred to as encryption and decryption, respectively. Cryptography
concerns itself with four objectives:
4) Authentication (the sender and receiver can confirm each other’s identity
and the origin/destination of the information)
1
In symmetric Key cryptography, the same key is used for both
encryption and decryption. In asymmetric key cryptography, one key
is used for encryption and another, mathematically related key, is used for
decryption.
Symmetric-key systems are simpler and faster, but their main drawback is
that the two parties must somehow exchange the key in a secure way. Public
key encryption avoids this problem because the public key can be distributed
in a non-secure way, and the private key is never transmitted. Symmetric-key
cryptography is sometimes called secret-Key cryptography.
The most popular symmetric-key system is the Data Encryption
Standard (DES).
2
In secret key algorithms we have
D (k, E (k, m)) = m for each plain text m.
There are many algorithms in this process .The famous ones among them are
DES, IDEA etc.
An encryption system in which the sender and receiver of a message
share a single, common key that is used to encrypt and decrypt the
message. Contrast this with public-key cryptology, which utilizes two keys
a public key to encrypt messages and a private key to decrypt them. Which
use one key for encryption and another for decryption? A corresponding
pair of such keys constitutes a key pair. Also called asymmetric
cryptography.It is a coding system in which encryption and decryption
are done with public and private keys, allowing users who don’t know
each other to send secure or verifiable messages. Suppose Fred wants to
send a message. He would encrypt it with his private key, which no one
else knows; then, the recipient would decrypt it using Fred’s publicly
available key, thus verifying that themessage came from Fred. Alternately,
suppose Fred wants to receive an encrypted message. The sender would
encrypt the message with Fred’s public key, and only Fred would be
able to decrypt it, using his private key. This method, also known as dual-
key cryptography contrasts with the older secret-key or symmetric
cryptography, in which the sender and recipient must agree on and use
the same private key for encryption and decryption. Type of cryptography in
which the encryption process is publicly available and unprotected, but in
which a part of the decryption key is protected so that only a party with
knowledge of both parts of the decryption process can decrypt the cipher
text. In public key cryptography, keys are created in matched pairs.
Encrypt with one half of a pair and only the matching other half can
decrypt it. This contrasts with symmetric or secret key cryptography in
which a single key known to both parties is used for both encryption
and decryption.
3
One half of each pair, called the public key, is made public. The
other half, called the private key, is kept secret. Messages can then be sent
by anyone who knows the public key to the holder of the private key.
Encrypt with the public key and you know only someone with the matching
private key can decrypt. Public key techniques can be used to
create digital signatures and to deal with key management issues,
perhaps the hardest part of effective deployment of symmetric ciphers. The
resulting hybrid cryptosystems use public key methods to manage keys
for symmetric ciphers. Many organizations are currently creating PKCs,
public key infrastructures to make these benefits widely available.
Example:
A widely used public/private key algorithm is RSA, named after the
initials of its inventors, Ronald L. Rivest, Adi Shamir, and Leonard
M.Adleman .RSA depends on the difficulty of factoring the product
of two very large prime numbers . Although used for encrypting whole
messages, RSA is much less efficient than symmetric key algorithms
such as DES. ElGamal is another public/private key algorithm. It uses a
different arithmetic algorithm than RSA, called the discrete logarithm
problem. The most recently evolved public key cryptography is the NTRU
pkcs.
4
2. SYSTEM DESIGN
5
UML contains a variety of diagram types, including:
6
UML Diagrams
Table 2.2: Description for the Use case Generate public private key pairs
Actors Administrator
Description This use case generates public private key pairs based
7
on the polynomials.
Table 2.3: Description for the Use case Receive public private keys
Actors Administrator, Sender, Receiver
Description This usecase performs distribution of public private
keys to sender and receiver.
Table 2.4: Description for the Use case selects a public key
Actors Sender
Description This use case selects the public key of receiver for
encryption.
8
Fig 2.1.2 Class Diagram for NTRU pkcs
9
Class: Receiver
10
Table 2.14: Description of class Monto
Class: Monto
11
Fig 2.1.3 Sequence Diagram for client server
1. Generate keys
2. Receive public, private keys
3. Receive public private keys
4. Provide data for encryption
5. Generate cipher text
6. Gets the encrypted data
7. Transmit cipher text
8. Provides cipher text
9. Generate plain text
10. Display plain text
12
3. SYSTEM IMPLEMENTATION
3.1. Requirements
• 40 GB HDD.
• 512 MB RAM.
• Pentium IV processor
13
3.2 Project Implementation Details
3.2.1 Algorithm Analysis
14
3.2.1.2 Truncated polynomial Ring
The principal objects used by the NTRU Encrypt PKCS are
polynomials of degree N-1 having integer coefficients
a=a[0] + a[1]x + a[2]x^2 + - - - - - - + a[N-2]x^(N-2) + a[N-1]x^(N-1).
The coefficients a [0], a [1] - -- - - a [N-1] are integers. Some of the
coefficients are allowed to be 0.
The set of all such polynomials is denoted by R. The polynomials in R
are added together in the usual way by simply adding their coefficients.
a + b = ( a[0] + b[0] ) + ( a[1]+ b[1] )x + -- - + ( a[N-1] + b[N-1] )x^(N-1)
They are also multiplied in almost the usual manner, with one change.
After doing the multiplication, the power of x^n should be replaced by 1,
the power x^ (n+1) should be replaced by x, the power x^ (n+2)
should be replaced by x^2, and so on.
15
3.2.1.4 Inverse of Polynomial modulo M:
The inverse of f modulo p, f modulo q is determined using the
inverse algorithm of Silverman.
16
Working:
The input to the algorithm is the polynomial (a(x)) to which we are
finding the inverse and the value p. The output is inverse of a(x) which is
stored in polynomial (b(x)).First the variables and arrays are initialized i.e.
the coefficients of the polynomial are stored in the single dimensional array.
Loop until the degree of the polynomial (f) is zero. Next in do-while loop the
polynomial (f) is equated to the quotient polynomial which is obtained by
dividing f(x)/x. In order to perform this operation we left shift the
polynomial f(x) by once. In the step c(x) is shifted right once to obtain the
equivalent of(c(x)*x). Here k is incremented by one as long as f [0] is zero.
In the next step if the degree of the polynomial f is zero, then the inverse is
returned. Here the polynomial b is equated to the product of f0^-1 and b(x),
and the result is reduced modulo p. After calculating b(x) we return the
inverse by left rotating b(x) by k times or right rotating b(x) by N-k times. If
the degree of the Polynomial f is not zero then we checked the next
condition i.e. step 11.If the condition is true then f and g, b and c are
swapped. At step 13 the value of u is calculated by multiplying f0 with
inverse of g0.After calculating u we find F(x) and g(x) as stated in step 14,
15.This process is repeated until theinverse is found. The creation of NTRU
key pair often requires finding the inverse of polynomial f(x) modulo not
only a prime but also a prime power in particular a power of 2.However once
the inverse is determined modulo a prime p, a method based on Newton
iteration allows one to rapidly compute the inverse modulo powers p^ r.
17
3.2.1.5 The Extended Euclidean Algorithm
We will number the steps of the Euclidean algorithm starting with step 0.
The quotient obtained at step i will be denoted by q i. As we carry out each
step of the Euclidean algorithm, we will also calculate an auxiliary
number, pi.
For the first two steps, the value of this number is given:
p0 = 0 and p 1 = 1.
For the remainder of the steps, we recursively calculate
Pi = p i-2 - p i-1 qi-2 (mod n).
Continue this calculation for one step beyond the last step of the
Euclidean algorithm. The algorithm starts by "dividing" n by x. If the last
non-zero Remainder occurs at step k, and then if this remainder is 1, x has
an inverse and it is pk+2. (If the remainder is not 1, then x does not have an
inverse.) Here is an Example: Find the inverse of 15 mod 26.
Step 0: 26 = 1(15) + 11 p0 = 0
Step 1: 15 = 1(11) + 4 p1 = 1
Step 2: 11 = 2(4) + 3 p2 = 0 - 1(1) mod 26 = 25
Step 3: 4 = 1(3) + 1 p3 = 1 - 25(1) mod 26 = -24 mod 26 = 2
Step 4: 3 = 3(1) + 0 p4 = 25 - 2(2) mod 26 = 21
p5 = 2 - 21(1) mod 26 = -19 mod 26 = 7
18
3.2.1.6 Word Level Montgomery for NTRU
19
3.2.2 Module Description
3.2.2.1 NTRU PKCS Parameters
The basic collection of objects used by the NTRU Public Key Cryptosystem
is the ring R that consists of all truncated Polynomials of degree N-1
having integer coefficients.
a=a[0]+a[1]x+a[2]x^2+a[3]x^3+- - - - - - - - +a[N-2]x^(N-2)+a[N-1]x^(N-1)
Polynomials are added in the usual way. They also multiplied more-or-less
as usual, except that x^n is replaced by 1, x^ (n+1) is replaced by x, x^
(n+2) is replaced by x^2, and so on.
A full implementation of the NTRU Public Key Cryptosystem is specified
by a number of parameters. However, for the purpose of this overview
we will concentrate on the three most important:
20
Bob must keep the values of the polynomials f and g private, since
anyone who knows the value of either one of them will be able to decrypt
messages sent to Bob. Bob's next step is to compute the inverse of f
modulo q and the inverse of f modulo p. Thus he computes polynomials
fp and fq with the property that
F*fq=1(modulo q) and
F*fp=1 (modulo p)
(If by some chance these inverses do not exist, Bob will need to go back
and choose another f.)
Now Bob computes the product
h=p * fq * g (modulo q).
f = -1+x+x^2-x^4+x^6+x^9-x^10
21
g = -1+x^2+x^3+x^5-x^8-x^10
Fq=5+9x+6x^2+16x^3+4x^4+15x^5+16x^6+22x^7+20x^8+18x^9+30x^10
=8+25x+22x^2+20x^3+12x^4+24x^5+15x^6+19x^7+12x^8+19x^9+16x^10
(mo dulo 32)
Bob's private key is the pair of polynomials f and fp, and his public key is
the polynomial h.
3.2.2.3 Encryption
Alice wants to send a message to Bob using Bob's public key h. she first
puts her message in the form of a polynomial m whose coefficients are
chosen modulo p, say between -p/2 and p/2(in other words , m is a small
polynomial mod q). Next she randomly chooses another small polynomial, r.
this is the "Blinding value”, which is used to obscure the message.
Alice uses the message m, her randomly chosen polynomial r, and
Bob's public key h to compute the polynomial
e=r*h+m (modulo q).
The polynomial e is the encrypted message which Alice sends to Bob.
Example
As before, we need to specify what we mean by saying that r is a small
polynomial. we do this using the quantity dr. r has dr of its coefficients equal
to 1,it has dr of its coefficients equal to 1,it has dr of its coefficients equal to
22
-1, and it has all of the rest of its coefficients equal to 0.
For the purpose of this section, we take dr=3.
Now, suppose Alice wants to send the message
m=-1+x^3-x^4-x^8+x^9+x^10
Using the Bob's public key
h=8+25x+22x^2+20x^3+12x^4+24x^5+15x^6+19x^7+12x^8+19x^9+16x^10.
She first chooses a random polynomial r of degree 10 with three 1's and
Three -1's.say she chooses
r=1+x^2+x^3+x^4-x^5-x^7
Then her encrypted message e is e=r*h+m
=14+11x+26x^2+24x^3+14x^4+16x^5+30x^6+7x^7+25x^8+6x^9
+19x^10(modulo 32).
3.2.2.4 Decryption
Now Bob has received Alice's encrypted message e and he wants to decrypt
it. He begins by using his private polynomial f to compute the polynomial.
23
Example
Bob has received the encrypted message
e=14+11x+26x^2+24x^3+14x^4+16x^5+30x^6+7x^7+25x^8+6x^9+19x^10
a=f*e=3-7x-10x^2-11x^3+10x^4+7x^5+6x^6+7x^7+5x^8-3x^9-
7x^10(modulo 32).
Note that when Bob reduces the coefficients of f*e modulo 32, he
chooses values lying between -15 and 16, not between 0 and 31.It is very
important that he choose the coefficients in this way. Next Bob reduces the
coefficients of a modulo 3 to get
b= a=-x-x^2+x^3+x^4+x^5+x^7-x^8-x^10(modulo 3).
Finally Bob uses fp, the other part of his private key, to compute
c= fp*b=-1+x^3-x^4-x^8+x^9+x^10(modulo 3).
24
So although Bob doesn't know r and m, when he computes
a=f*e (modulo q), he is actually performing the following computation
a=f*e (modulo q)
=f*(r*h+m) (modulo q) [since e=r*h+m (modulo q)]
=f*(r*p*fq*g+m) (modulo q) [since h=p*fq*g (modulo q)]
=p*r*g + f*m (modulo p) [since f* fq =1(modulo q)]
Now look back at the sizes of the various parameters. The polynomials r,
g, f and m all have coefficients that are quite small. This means that
the coefficients of the products r*g and f*m are also quite small, at
least in comparison to q. since the prime p is also small compared to q,
this means (assuming that the parameters have been properly
chosen)that the coefficients of the polynomial p*r*g + f*m already lie
between -q/2 and q/2,so reducing the coefficients modulo q has no effect at
all!.
In other words when Bob computes a by first multiplying f*e and then
reducing the coefficients modulo q, the polynomial a that he ends up
with is exactly equal to the polynomial p*r*g + f*m. when Bob next
reduces the coefficients of a modulo p to form the polynomial b, he is
really reducing the coefficients of p*r*g + f*m modulo p, so the b that he
ends up with is equal to
b= f*m (modulo p)
Keep in mind that Bob still doesn't know the value of m, but he now knows
the value of b. so his final step is to multiply b by fp and use the
fact that fp*f=1(modulo p) to compute
c= fp*b=fp*f*m=m (modulo p)
Which allows him to recover Alice’s message m?
25
4. TESTING
4.1 Software Testing Techniques:
Software testing is a critical element of software quality assurance and
represents the ultimate review of specification, designing and coding.
4.1.1 Testing Objectives:
1. Testing is process of executing a program with the intent of finding an error.
2. A good test case design is one that has a probability of finding an as yet
undiscovered error.
3. A successful test is one that uncovers an as yet undiscovered error.
Testing cannot show the absence of defects, it can only show that software errors are
present.
In this testing each and every unit implemented in the project is tested individually.
For Key Generation when the participiants are registered the private and public
keys are generated automatically. Private keys, public keys generated are stored in a file in
the windows file system. These private and public keys are generated in matched pairs.
The sender receives the public keys of the receiver from the file and then stores the public
keys. The receiver has matched private keys.
26
Each and every operation mentioned above is tested separately for accurate results
and are obtained. Each and every component in all the frames is tested and accurate results
are obtained.
As mentioned earlier our project consists of three modules. They are Key
Generation, Encryption and Decryption. Each and every module is tested.
For Key Generation Module the input is given and tested whether the public key
and private keys are generated at the sender and receiver side and are same or not. The
private and public key pairs are generated and are found to be same. The module testing
for this module yielded accurate results.
For Encryption Module data is fed at the server and the file is encrypted. The
encrypted file is then send to the receiver and the encryption is performed based on the
public key of the receiver.And also it is tested whether the encryption is performed for the
valid key or not and is found that the encryption operation is performed for valid key input
only. The module testing for this module yeilded accurate results.
For Decryption Module data is received at the receiver and the file is decrypted.
The encrypted file is decrypted at the receiver based on the private key of the receiver.And
also it is tested whether the decryption is performed for the valid key or not and is found
that the decryption operation is performed for valid key input only. The module testing for
this module yeilded accurate results.
In this testing all the three modules are combined and are tested, in the below table
we have given the inputs to the modules with description, data type and sample values.
27
Table 4.1: Test Inputs
Name Description Type Sample Values
Generation In order to generate small int 3
random numbers. 4
4
Private In order to generate public Polynomial -1,1,1,0,-1,0,1,0,0,1,-1
keys keys. These are kept secret. 1,2,0,2,2,1,0,2,1,1,0
Public These keys are generated by Polynomial 2,18,0,8,20,8,22,26,6,24
keys the participants. In order to
communicate.
Encryption In order to encrypt the data. String Svec
Public key is used.
Decryption In order to decrypt the data. byte 1,21,16,12,13,27,19,2,8,12,2
Private key is used. 0,21,17,12,13,27,19,2,8,12,12
1,20,17,12,12,27,19,2,8,12,12
0,21,17,13,12,27,19,2,8,12,2
5. RESULTS
28
1. This screen shot shows the keys generated for the server.
2. This screen shot shows the keys generated for the client.
29
Fig 5.2 shot shows the keys generated for the client.
30
Fig 5.3. Shows encryption of data
31
Fig 5.4. Shows decryption of data.
6. CONCLUSTION
32
6.1. Conclustion
Since, the private key is prerequisite and kept secret, the message
can’t be decrypted easily. The reason is that the keys are generated
randomly .So the probability to decrypt the message is highly negligible.
REFERENCES
33
1. Optimizations for NTRU, J. Hoffstein, J. Silverman, Public-Key-
Cryptography and Computational Number Theory, Berlin-New York.
4. www.ntru.com.
www.tiac.net/users/ntru
34