Professional Documents
Culture Documents
Final Documentation
Final Documentation
(LFSR) for
Secure Message Transfer
A mini project report submitted in partial fulfillment for the award of the degree of
B.Tech
In
INFORMATION TECHNOLOGY
By,
Mrs. P. Jayalakshmi
Asst. Professor
VIT University
MAY 2010
Vellore - 632 014, TN, India
DECLARATION
I hereby declare that the main project report entitled “Linear Feedback Shift Register
(LFSR) for Secure Message Transfer” submitted by me to the School of Information
Technology and Engineering, VIT University, Vellore-14 as per the curriculum requirement
for VIII Semester of B.Tech Information Technology is a record of bonafide project work
carried out by me under the guidance of Mrs. P. Jayalakshmi, Asst. Professor, SITE. I
further declare that the work reported in this project has not been submitted and will not
be submitted, either in part or in full, for the award of any other degree or diploma of this
institute or of any other institute or university.
Place: Vellore
Date:
Signature of candidate
BONAFIDE CERTIFICATE
This is to certify that the project report entitled “Linear Feed Back Shift Register
(LFSR) for Secure Message Transfer” submitted by Nikin Kumar Jain (06BIT113) to VIT
University, Vellore as per the curriculum requirement for VIII Semester of B.Tech
Information Technology is a record of bonafide work carried out by him under my
guidance. The project fulfills the requirement as per the regulations of this institute and in
my opinion meets the necessary standards of submission. The contents of this report have
not been submitted and will not be submitted either in part or in full for the award of any
other degree or diploma in this institute or any other institute or university.
Place: Vellore
Date:
______________Signature_______________________
(Mrs. P. JayaLakshmi)
Asst. Professor
Date: Date:
ACKNOWLEDGEMENT
I dedicate this page to all those who have silently or actively left an indelible mark on my
project report, so that they may get all credit which they richly deserve.
Talent and capability is of course necessary but opportunities and right guidance is two very
important prerequisites without which any person cannot climb the ladder of success. Proper
guidance and direction are required in order to achieve the goal and making optimum of each and
every opportunity.
Mundane words are not enough to express my insufficient indebtedness towards Honorable
Chancellor Dr. G. Viswanathan, Dr. Bandaru Rama Krishna Rao, Director, SITE, VIT
University and Mr. S. Balaraman, Program Manager, SITE, VIT University whose enormous
assistance has helped me in the completion of the project.
I am thankful from the core of my heart and express my feeling of gratitude to my Year
Coordinator Mr. P. J. Kumar Asst. Professor and Project Guide Mrs. Jayalakshmi P., Asst.
Professor, School of Information Technology and Engineering, VIT University whose constant
support and faith in me has always motivated. Their knowledge and brilliance have pulled me
out of doldrums many a time in this project.
I
ABSTRACT
Most communication channels like telephone lines and radio broadcasts transmit signals
which are many-a times tapped by an undesirable source. This breach of security can be
surmounted by a secret signal that has been transformed into a form that is difficult to be
decrypted from sources without knowledge of a secret key and this way, the secret signal can be
transmitted undetected. Internet users frequently need to store, send or retrieve private
information. The most common way to do this is to transform the plain data into a non-
understandable form called “Encrypted Data”. Only those who know how to decrypt it can
understand the encrypted data. This method of protecting data is known as encryption.
The purpose of this document is to describe the steps taken in the development of encryption
tool using LFSR technique. This document describes the development phases as well as the
working of the tool. This comprehensive tool thus developed finds extensive use in transferring
crucial data over various channels safely. The two level security offered by the tool enhances
increases its reliability thus enhancing its usability.
II
Table of Contents
III
Chapter No. Contents Page
7.1 File Encryption-Decryption 21
7.1.1 Applet Encryption Module 21
7.1.2 Command-Line File Encryption 22
7.1.3 Server-Side File Receivables 23
8 Unit Testing and Integration Testing 24
8.1 Project Scheduling 24
8.2 PERT Chart 25
9 Deployment and Acceptance Testing 26
9.1 Frame-Work Applied 26
9.2 Requirements 26
9.3 Product Perspective 26
9.4 Product function 26
10 Conclusion 27
11 Future Enhancements 27
12 Literature Survey and References 27
Appendix – A 28
IV
List of Figures
V
List of Tables
VI
1. INTRODUCTION
Most communication channels like telephone lines and radio broadcasts transmit signals
which are many-a times tapped by an undesirable source. This breach of security can be
surmounted by a secret signal that has been transformed into a form that is difficult to be
decrypted from sources without knowledge of a secret key and this way, the secret signal can be
transmitted undetected. Internet users frequently need to store, send or retrieve private
information. The most common way to do this is to transform the plain data into a non-
understandable form called “Encrypted Data”. Only those who know how to decrypt it can
understand the encrypted data. This method of protecting data is known as encryption.
1.1 Definition
Cryptography: It is a practice of hiding information. Modern Cryptography intersects the
disciplines of mathematics, computer science and engineering. Application of cryptography
includes ATM cards, computer passwords and electronic commerce. Cryptography is the process
of converting ordinary information into cipher text. Decryption is the reverse, in other words,
moving from the unintelligible cipher text back to plain text.
Encryption: Encryption is the process of passing data or plaintext through a series of
mathematical operations that generate an alternate form of the original data known as cipher-text.
The encrypted data can only be read by parties who have been given the necessary key to decrypt
the cipher-text back into its original plaintext form. Encryption doesn't hide data, but it does
make it hard to read!
1.2 Motivation
Literature Survey: The development of digital computers and electronics made possible
much more complex ciphers. Many computer ciphers can be categorized by their operation on
binary bit sequences, unlike classical and mechanical schemes, which generally manipulate
traditional characters directly. Developers need to be very much aware because of continuous
improvement in computer processing power have increased the scope of brute-force attack.
1
1.3 Aim & Objective
Problem Formulation: Alice and Bob are in male/female prisons and want to
communicate to make an escape plan. Warden Wendy would let them communicate but would
monitor the communication. A solution needs to be found out such that the communication
would seem to be unperceivable to person who isn’t aware that “something lies beneath it”.
2
2. REQUIREMENTS
2.1 Requirements
2.1.1 System Requirements: Since the product is using Java as a supporting language the
product will be portable and can work on operating systems which support JVM (Java Virtual
Machine). The system requires any platform supporting .Bmp, Gif, .Txt formats with minimum
RAM 64 Mb.
I. Design Constraint: The system requires O.S environments Windows 9x, 2000,
NT or XP.
II. Software Requirements: J2SE.
III. Hardware Requirements: Should be capable of supporting basic Networking.
3
2.4 Functional Requirements
Implementation of LFSR Encryption
4
3. ARCHITECTURE SPECIFICATIONS
5
3.1 LFSR Implementation Strategy:
Linear Feed Shift Registers (LFSR) is a mechanism of generating a random binary sequence.
The Linear Feedback Shift Register consists of a series of D flip-flops that are initialized by an
initialization vector, also called as seed value. A clock synchronizes the D flip-flops. At every
clock tick, a bit is output and the values in the flip-flops are shifted to the right by one. The first
flip-flop gets its value from a polynomial function involving certain cells.
The polynomial function is responsible for incorporating Non-Linearity in the output binary
sequence. Linear Feed Shift Registers play an extremely vital role in generating keys for various
encryption techniques. Linear Feed Shift Registers generate extremely good pseudo random
sequence. The period of sequence is 2 raise to power n minus 1 (2n –1), where n is the number of
cells in the LFSR.
Fig3.1.2: D Flip-Flop
D1 D2 D3 D4 D5
XOR
Consider the output of the last 3 flip-flops of the above figure. At every stage we get a random
decimal number ranging from 0 to 7. The length of this sequence of random numbers is 2n –1,
after which the sequence starts repeating. Higher the values of n, higher are the randomness.
6
In this technique we store the data in the bit that is the decimal values shown by the last 3
flip-flops. So we store the data in the 2nd bit of first byte, then in the 3rd bit of second byte, then
in the LSB of the third byte and so on. Hence the attacker would not be able to know the secret
data until the attacker knows the seed value, which was used to initialize the flip-flops because
with different initialization vector we get different random sequence. The randomness involved
in this encryption technique secures the data to a great extent.
The shift register size (m) is equal to length + 1, where length is an integer between 1 and 31.
m
The shift register produces a sequence of 2 - 1 bit. For example, a shift register size of 32
produces a shift register sequence of 232 - 1 bits and is specified by setting the length input to 31.
The length input is synchronous to the rising edge of the clock. When a clock edge loads the
length input, the mega function will automatically reconfigure the shift register's size.
The load input initializes the contents of the shift register. Whenever load is asserted, the
mega function configures itself to a normal shift register size of 32. The desired initial value will
be loaded through the shift in input using 32 clock cycles. Because the length value is ignored
when load is asserted, length can be asserted any time before load de-asserts. The load input can
be de-asserted after the 32nd rising clock edge. The next rising edge of the clock would then
configure the shift register size and feedback logic and initialize the length sequence.
One of the two main parts of an LFSR is the shift register (the other being the feedback
function). A shift register is a device whose identifying function is to shift its contents into
adjacent positions within the register or, in the case of the position on the end, out of the register.
The position on the other end is left empty unless some new content is shifted into the register.
The contents of a shift register are usually thought of as being binary, that is, ones and zeroes.
If a shift register contains the bit pattern 1101, a shift (to the right in this case) would result in the
contents being 0110; another shift yields 0011. After two more shifts, things tend to get boring
since the shift register will never contain anything other than zeroes.
8
Two uses for a shift register are 1) Convert between parallel and serial data and 2) Delay a
serial bit stream. The conversion function can go either way -- fill the shift register positions all
at once (parallel) and then shift them out (serial) or shift the contents into the register bit by bit
(serial) and then read the contents after the register is full (parallel). The delay function simply
shifts the bits from one end of the shift register to the other, providing a delay equal to the length
of the shift register.
Clocking: One of the inputs to a shift register is the clock; a shift occurs in the register when
this clock input changes state from one to zero (or from zero to one, depending on the
implementation). From this, the term "clocking" has arisen to mean activating a shift of the
register. Sometimes the register is said to be "strobe" to cause the shift.
Shift direction: A shift register can shift its contents in either direction depending on how the
device is designed. (Some registers have extra inputs that dictate the direction of the shift.) For
the purposes of this discussion, the shift direction will always be from left to right.
Output: During a shift, the bit on the far right end of the shift register is moved out of the
register. This end bit position is often referred to as the output bit. To confuse matters a bit, the
bits that are shifted out of the register are also often referred to as output bits. To really muddy
the waters, every bit in the shift register is considered to be output during a serial to parallel
conversion. Happily, the context in which the term "output" is used generally clears things up.
Input: After a shift, the bit on the left end of the shift register is left empty unless a new bit (one
not contained in the original contents) is put into it. This bit is sometimes referred to as the input
bit. As with the output bit, there are several different references to input that are clarified by
context.
9
3.3.3 Feedback Function
In an LFSR, the bits contained in selected positions in the shift register are combined in some
sort of function and the result is fed back into the register's input bit. By definition, the selected
bit values are collected before the register is clocked and the result of the feedback function is
inserted into the shift register during the shift, filling the position that is emptied as a result of the
shift.
The feedback function in an LFSR has several names: XOR, odd parity, sum modulo 2.
Whatever the name, the function is simple: 1) Add the selected bit values, 2) If the sum is odd,
the output of the function is one; otherwise the output is zero. Table 1 shows the output for a 3
input XOR function.
0 0 0 0
0 0 1 1
0 1 0 1
0 1 1 0
1 0 0 1
1 0 1 0
1 1 0 0
1 1 1 1
10
The bit positions selected for use in the feedback function are called "taps". The list of the
taps is known as the "tap sequence". By convention, the output bit of an LFSR that is n bits long
is the nth bit; the input bit of an LFSR is bit 1.
An LFSR is one of a class of devices known as state machines. The contents of the register,
the bits tapped for the feedback function, and the output of the feedback function together
describe the state of the LFSR. With each shift, the LFSR moves to a new state. (There is one
exception to this -- when the contents of the register are all zeroes, the LFSR will never change
state.) For any given state, there can be only one succeeding state. The reverse is also true: any
given state can have only one preceding state.
A state space of an LFSR is the list of all the states the LFSR can be in for a particular tap
sequence and a particular starting value. Any tap sequence will yield at least two state spaces for
an LFSR. (One of these spaces will be the one that contains only one state -- the all zero one.)
Tap sequences that yield only two state spaces are referred to as maximal length tap sequences.
The state of an LFSR that is n bits long can be any one of 2^n different values. The largest
state space possible for such an LFSR will be 2^n - 1 (all possible values minus the zero state).
Because each state can have only once succeeding state, an LFSR with a maximal length tap
sequence will pass through every non-zero state once and only once before repeating a state.
One corollary to this behavior is the output bit stream. The period of an LFSR is defined as
the length of the stream before it repeats. The period, like the state space, is tied to the tap
sequence and the starting value. As a matter of fact, the period is equal to the size of the state
space. The longest period possible corresponds to the largest possible state space, which is
produced by a maximal length tap sequence. (Hence "maximal length")
11
4. METHODOLOGY
4.1 Implementation of LFSR Encryption
12
4.2 Implementation of LFSR Decryption
13
5. DESIGN
2) Pseudo-noise sequences
14
5.4 Logical Implementation of LFSR
15
5.5 Uses in Cryptography
LFSRs have long been used as pseudo-random number generators for use in stream ciphers
and especially in military cryptography. It is also used in digital broadcasting and
communications to prevent short repeating sequences from spectral lines. The repeating
sequences of states of an LFSR allow it to be used as clock divider.
16
Fig 5.6.2 HLD of Server
17
6. IMPLEMENTATION MODULES
/*
<applet code="FileSender" width=300 height=200>
</applet>
*/
setSize(299, 199);
a = fd.getFile();
msg += fd.getFile();
if (flag == 1)
name.setText(msg);
}
if (str.equals(" Send "))
{
try
{
Socket s = new Socket("localhost", 8080);
InputStream is = new FileInputStream(msg);
BufferedInputStream bis = new BufferedInputStream
(s.getInputStream());
BufferedOutputStream bos = new BufferedOutputStream
(s.getOutputStream());
PrintWriter pw = new PrintWriter(bos);
int key = 0;
pw.println(a);
while ((key = is.read()) != - 1)
{
pw.print((char)key);
System.out.print((char)key);
pw.flush();
}
pw.print(key);
s.close();
remove(send);
}
catch (UnknownHostException e)
{
System.out.println("Hose Exception Caught");
}
catch (IOException e)
{
19
System.out.println("IO Exception Caught");
}}}
public void start(){}
public void paint(Graphics g)
{
showStatus("Vignette by Nikin Kumar Jain ");
}
}
}
}
20
7. MODULES-OUTPUT/RESULTS
7.1 File Encryption – Decryption
7.1.1 Applet Encryption Module
File Sender Applet: The File-Sender Applet is used for transfer of a file from Client to the
Server. Here we have a Browse Button and a Send Button. Both these button does their
functionality as their name signifies. Browse button opens a File Dialog Box where-as Send
Button is used for transferring of files from Client to Server Side.
Command-Line Encryption: This module is used for running the applet-viewer along
with taking the data values for Encryption. It asks for the file name and the new encrypted file is
created.
Server-Side File Receivables: Here the server-side is activated to receive file from client-
side. The Server receives the file once it-is encrypted.
23
8. Unit Testing and Integration Testing
8.1 Project Scheduling
Project scheduling is concerned with the techniques that can be employed to manage the
activities that need to be undertaken during the development of a project. Scheduling is carried
out in advance of the project commencing and involves:
24
Gantt and Pert chart are being used to depict the scheduling process of this system. We
describe the technique.
PERT (Project Evaluation & Review Technique) chart is a scheduling technique that also
shows graphically which tasks must be completed before others are begun. PERT controls time
and costs during the project and also facilitates finding the right balance between completing a
project on time and completing it within the budget. PERT recognizes that projects are complex,
that some tasks must be completed before others can start, and that the appropriate way to
manage a project is to define and control each task.
1 2 4 6 7 8
9 10
25
9. Deployment and Acceptance Testing
26
10. Conclusion
I have developed with the support of my guide a comprehensive tool which can generate
pseudo-random sequence and this could be used in producing stream cipher and deciphering
product as the output. The development of digital computers and electronics made possible much more
complex ciphers. Many computer ciphers can be categorized by their operation on binary bit
sequences, unlike classical and mechanical schemes, which generally manipulate traditional
characters directly. We, the Developers need to be very much aware because of continuous
improvement in computer processing power have increased the scope of brute-force attack.
1. Paper on Extended period LFSR using variable TAP function by Ariel Molina- Rueda and
Team.
2. http://www.wikipedia.org/
27
Appendix - A
Sample Encrypted and Decrypted Code:
Original Code:
Hello How Are You I am Nikin Kumar Jain it is a practice of hiding information. Modern
Cryptography intersects the disciplines of mathematics, computer science and engineering.
Application of cryptography includes ATM cards, computer passwords and electronic commerce.
Cryptography is the process of converting ordinary information into cipher text. Decryption is the
reverse, in other words, moving from the unintelligible cipher text back to plain text.
Encrypted Code:
r_VVU_rUM_{H__cUO_s_[W_tSQST_qOW[H_p[ST
sN_SI_[_JH[YNSY__U\_RS^ST]_ST\UHW[NSUT_
wU^_HT_yHCJNU]H[JRC_STN_HI_YNI_NR__^SIYSJVST_I_U\_W[NR_W[NSYI__YUWJON_H_I
YS_TY__[T^__T]ST__HST]_
{JJVSY[NSUT_U\_YHCJNU]H[JRC_STYVO^__{nw_Y[H^I__YUWJON_H_J[IIMUH^I_[T^__V_YN
HUTSY_YUWW_HY__
yHCJNU]H[JRC_SI_NR__JHUY_II_U\_YUTL_HNST]_UH^ST[HC_ST\UHW[NSUT_STNU_YSJR
_H_N_BN_
~_YHCJNSUT_SI_NR__H_L_HI___ST_UNR_H_MUH^I__WULST]_\HUW_NR__OTSTN_VVS]SXV
__YSJR_H_N_BN_X[YQ_NU_JV[ST_N_BN_
Decrypted Code:
Hello How Are You I am Nikin Kumar Jain it is a practice of hiding information. Modern
Cryptography intersects the disciplines of mathematics, computer science and engineering.
Application of cryptography includes ATM cards, computer passwords and electronic commerce.
Cryptography is the process of converting ordinary information into cipher text. Decryption is the
reverse, in other words, moving from the unintelligible cipher text back to plain text.
28