You are on page 1of 61

-ENCRYPTION AND DECRYPTION FOR SECURE COMMUNICATION IN WLAN A PROJECT REPORT Submitted by VASINYA.S.(41501104104) DEVI PRIYA.

B(41501104019) TANUJA(41501104095) in partial fulfillment for the award of the degree of BACHELOR OF ENGINEERING In COMPUTER SCIENCE AND ENGINEERING

S.R.M. ENGINEERING COLLEGE, KATTANKULATHUR-603 203, KANCHEEPURAM DISTRICT.

ANNA UNIVERSITY : CHENNAI - 600 025

MAY 2005

BONAFIDE CERTIFICATE Certified that this project report ENCRYPTION AND DECRYPTION FOR SECURE COMMUNICATION IN WLAN is the bonafide work of VASINYA.S.(41501104104) DEVI PRIYA.B(41501104019) TANUJA

(41501104095) who carried out the project work under my supervision.

Prof.S.S.SRIDHAR HEAD OF THE DEPARTMENT COMPUTER SCIENCE AND ENGG S.R.M.Engineering College Kattankulathur - 603 203 Kancheepuram District

Mr.R.MANOOV SUPERVISOR LECTURER COMPUTER SCIENCE AND ENGG. S.R.M.Engineering College Kattankulathur - 603 203 Kancheepuram District

ACKNOWLEDGEMENT We would like to take the opportunity to acknowledge the enthusiasm and the motivation rendered by the following personalities. Our heartfelt thanks to the Director of the Institution to us in completing the project in a successful manner. We express our profound gratitude to our HOD, Prof. S.Sridhar B.E, M.S, who provided guidance and was a constant source of encouragement through the course of this project. Our heartfelt thanks to our project coordinators, Mrs. C.Lakshmi M.E, Ph.d and Mrs. M.Puspalatha M.E who gave us valuable input and advice. Dr.

T.P.Ganesan and Principal Prof.Venkataramani, for their kind cooperation shown

We are deeply indebted to our internal guide Mr.Manoov M.Tech, who has been instrumental in the successful development of this project. We also thank all the staff members of the Computer Science and Engineering department for their interest in the development of the project. Last but not the least, we would like to thank our families and friends for their cooperation. ABSTRACT This project comes into use when we want the data communication to be protected from others. During war times, when a particular base wants to send a message to remotely located units which belong to the same army, in between any third party can trap the data when it is transmitted in wires or wireless. The essence of our project comes into this particular scene of the military world. Our project protects the data from strangers. This is achieved by incorporating a new wireless network system in which data is code modulated and then encrypted to get an encoded version of the data to be transmitted. This makes it have a lighter edge over current wireless systems by making use of Bluetooth compatible ICs. At the receiving end the PIC microcontroller will then decode the Received data and separates the data for different units and displays the message on the display. In future it can be enhanced to be in wireless for long distance.

TABLE OF CONTENTS CHAPTER NO TITLE ABSTRACT LIST OF TABLES LIST OF FIGURES LIST OF ABBREVIATIONS 1. INTRODUCTION 1.1 1.2 1.3 1.4 1.5 1.6 2 Objective General concepts Block diagram Description Scope Organization of Report 2 4 4 5 6 7 8 8 9 10 11 11 12 13 15 16 16 PAGE NO. iv ix x xi 1

LLITERATURE REVIEW 2.1 2.2 2.3 2.4 Wireless Networking Wireless Pros and Cons Secure Wireless Paradigm Cryptography 2.4.1 Simplified Model 2.4.2 Conventional Model 2.5 Significance of Wireless

3. 4.

PROPOSED SYSTEM AND ITS FEATURES REQUIREMENT SPECIFICATION 4.1 Hardware Specification 4.2 Software Specification

5.

DESIGN DOCUMENTATION 5.1 5.2. Modules in the Project Software Design 5.2.1 PC Coding 5.2.1.1 Designing the user interface 5.2.1.2 Encrypting Data 5.2.1.3 Wireless Transmission 5.2.2 PIC 16f877 Micro Controller coding 5.2.2.1 Authentication 5.2.2.2 Wireless Reception 5.2.2.3 Decryption 5.2.2.4.Presentation of Message 5.2.3 Data Flow Diagram 5.2.3.1 Data flow 5.2.3.2 Description 5.2.3.2.1 Message Entry 5.2.3.2.2 Encryption 5.2.3.2.3 Transmission and reception 5.2.3.2.4 Decryption 5.2.3.2.5 Display 5.3 Hardware Design

18 18 18 19 19 19 19 20 20 20 20 20 21 21 22 22 22 23 23 23 24 27 28 28 29

5.3.1 RF Transmitter Module 5.3.1.1 Features 5.3.1.2 Specifications 5.3.1.3 Applications

5.3.2 Rf Receiver Module 5.3.2.1 Features 5.3.2.2 Specifications 5.3.4. PIC microcontroller 5.3.4.1 PIC16f877 Ckt Description 5.3.4.2 IC Interface design 5.3.5 RS-232 Interface with MAX232 circuitry 5.3.5.1.RS 232 5.3.5.2 MAX 232 5.3.5.3.MAX 232 details 5.3.6 Power Supply Section 5.3.6.1 Circuit Diagram 5.3.6.2 Details 6. IMPLEMENTATION 6.1 User Interfaces 6.2 Source Code 6.2.1 Encryption 6.2.2 Decryption PIC Coding 7. CONCLUSION 7.1 Future Enhancements Appendix 1 Appendix 2 References

30 31 31 32 32 34

35 36 36 36 38 38 39 41 42 43 43 51 69 70 73 75 77

LIST OF TABLES Table 1 Table 2 SPECIFICATION RF TRANSMITTER SPECIFICATION RF RECEIVER

LIST OF FIGURES

Fig 1 Fig 2 Fig 3 Fig 4 Fig 5 Fig 6 Fig 7 Fig 8 Fig 9 Fig 10 Fig 11 Fig 12 Fig 13 Fig 14

BLOCK DIAGRAM TRANSMITTER MODULE RECEIVER MODULE SIMPLE MODEL CONVENTIONAL MODEL DATA FLOW DIAGRAM TRANSMITTER CIRCUIT RECEIVER CIRCUIT TRANSMITTER MODULE RECEIVER MODULE PIC16F877 MAX 232 POWER SUPPLY USER INTERFACE LIST OF ABBREVIATIONS

1. PIC 2. Tx 3. Rx

Peripheral Interface Controller Transmitter Receiver

4. RF 5. WLAN 6. PCN 7. DES 8. LCD 9. F

Radio Frequency Wireless Local Area Network Personal Communication Network Data Encryption Standard

Liquid Crystal Display Micro Farad Ohm Micro second Mega hertz Giga hertz Bits per second

10. 11. S 12. Mhz 13. Ghz 14. bps

INTRODUCTION

INTRODUCTION 1.1 OBJECTIVE The need for this project arises when we want the data communication to be protected from others. This is highly essential in the military field and especially during war times. Because during war periods when a particular army wants to send a message to remotely located units which belongs to the same army, in between any person can trap the data when it is transmitted through wires or wireless. Our aim of the project is to protect the data from the ensnares. To accomplish this, we have used a PC as a sender and PIC microcontroller as a receiver station. The message to be sent is fed in to the computer for different units. The computer will encode the data by generating a 7 bit access code for each units and the code will be sent along with the mixed data of other units message also.

At the receiving end the PIC microcontroller will then decode the Received data and separates the data for different units and displays the message on the display. The communication takes place through RS232 Port. In future it can be enhanced to be in wireless for long distance. To ensure or to draw the attention of the Units this unit also contains an alarming unit to indicate the Message has been received from the Central unit. The project has a provision to see the encoded data as a text file in a computer.

1.2 GENERAL CONCEPTS One of the emerging technologies in recent days in Embedded Systems, which is a combination of both hardware and software and perhaps additional mechanical parts designed to perform a specific function. It provides a very cost-effective solution to a problem. The inputs to a system can be from a device or functions call routines. Processors used can be a micro-controller or a micro-processor or a DSP. The outputs from the system are the actual physical data required. The memory is used to interface the system with the database and the software code. The technique used to send data safely across is Code Modulation, which is the process of generating a random code for each bit of the binary 8-bit code of each character and then interlacing them with different messages to get the modulated data. In such a case, a strong Encryption scheme is followed by the use of code generated for each bit, which takes more amount of time to be tapped. And thus the retrieval of data becomes difficult for the hacker.

1.3 BLOCK DIAGRAM

Fig 1 Block Diagram 1.4 DESCRIPTION OF THE BLOCK DIAGRAM The PC is main center of sending the data. It transmits data to different units, each kept distances apart. The user at the PC is the controller. The user is prompted to send messages to various units at his own will. The data got is then code modulated and a 8-bit code is generated for each bit of the 8-bit character of the message. This is then transmitted over a wireless network. The transmitter circuit is connected to PC via the RS-232 interface. At the receiving end, there is a receiver to receive the transmitted data. This encoded data is then passed to the PIC microcontroller, which then decodes as per the algorithm and then generates the original data. This data is then sent to the display circuit, which has a display driver and a display interface unit. This unit displays the message in a 16 bit alphanumeric display format.

10

To indicate the user at the receiving end that the message is from the base control station, a buzzer is used. Also, in order to provide an authentication mechanism for the user to see his message, he is provided with a button, which is a simulation of a password entry before the first screen. 1.5 SCOPE OF THIS PROJECT This project is mainly used for Military purposes sending data from base to the intended soldier. Spying giving commands over a tapped area. General secure communication between peers or officials. Police patrol.

1.6 ORGANIZATION OF REPORT This report has been organized in the most coherent manner, explicitly bringing out the projects objective, requirements, and implementation details along with a user manual to guide the user through the execution of the system created. Chapter2 of the report gives a brief insight into concepts of wireless technology. It gives an overview of wireless networking and security. Chapter 3 gives the features of the proposed system to be built. Chapter 4 lists the hardware and software requirements of the system. Chapter 5 explains the projects design elaborately along with its modular description. Chapter 6 contains the logical flow, user interfaces and abstracted code of the system. Chapter 7 gives the conclusion with the merits and future extensions of the system.

11

LITERATURE REVIEW LITERATURE REVIEW 2.1 WIRELESS NETWORKING Organizations of all sizes are installing and operating wireless networks, known as wireless local area networks (WLANs) or Wi-Fi networks. Low cost, ease of installation, flexibility are the benefits that are propelling the widespread adoption of wireless technology. While the benefits of WLANs are substantial, wireless technology introduces security holes that network administrators must take into account if they are to adequately protect their organizations from hackers, cyber terrorists, and unauthorized intruders. Wireless networks are notoriously easy to compromise when improperly installed and operated. Once compromised, a WLAN gives intruders an open conduit to your entire network and places all your proprietary and mission-critical information in jeopardy. Wireless security is not impossible to achieve. In fact, when a comprehensive, layered-security approach is implemented, a WLAN can be more secure and easier to use and manage than a typical wired network. 2.2 WIRELESS PROS AND CONS The operational characteristics described in the previous paragraphs give rise to a number of advantages that are driving wireless technologys growing popularity. These advantages include: Increased productivity and flexibility Wireless users can move throughout the coverage area from offices to conference rooms, from the lunch room to the shop floor without disconnecting from the network. A study conducted by NOP World found that wireless users stay connected to the network an average of 1.75 hours longer per day, which translates roughly to a 20% increase in productivity.

12

Ease of installation a WLAN could be operational in a matter of hours, whereas a wired network might take days or weeks to install. Cost WLANs can be installed more economically than wired LANs. On average, adding users to a wired LAN costs approximately $130 per connection, so extending coverage to new office space for 50 users would cost about $6500. The same characteristics that make WLANs attractive also create a number of serious and potentially catastrophic disadvantages, including: No physical control over network connections Weak built-in security measures Security complacency 2.3 THE SECURE WIRELESS NETWORK PARADIGM Their ease of use and productivity benefits have allowed unsecured wireless networks to slip under the wire of good network security practices. The tendency has been to utilize wireless network technology to extend the network beyond the physical ports of the secure LAN. WLANs are mistakenly considered secure since they are protected behind the firewall from insecure Internet traffic. The problem is that WLANs provide additional entry points for attack into the network. Physical access through your wireless network is even easier than through your connection to the Internet intruders can attack your network from outside of the building! Adequate wireless security requires that we change how we treat and secure wireless networks. The secure wireless network paradigm demands that WLANs be treated as unsecured networks requiring best security practice measures for access, authentication, and encryption. As with all network security best practices, a layered approach provides the best protection. The growth in wireless communication, together with recent developments

in hardware miniaturization, has opened a new dimension to future wireless networks

13

whose ultimate goal is to support universal personal communications. To realize such a vision, the next generation personal communications networks (PCNs) will need to support a very high level of user traffic along with a wide range of high-quality services of varying bit rates, some of which are beyond today's technology. Our research focuses on developing essential technologies for sending more than 2Mb/s information over the air. 2.4 CRYPTOGRAPHY Cryptography, defined as the study of mathematical systems for solving two kinds of security problems - privacy and authentication. Military Cryptography (before 1976) - The two milestones in modern cryptology DES (Data Encryption Standard) - NIST 1976 New Directions in Cryptography - Diffie and Hellman, IEEE Trans. on Information Theory, vol.IT-22, no.6, November 1976 2.4.1 Simplified Model Fig 4 Simple Model

14

2.4.2 Conventional Model

Fig 5 Conventional Model

2.5 SIGNIFICANCE OF WIRELESS SYSTEMS The next few years will bring dramatic changes to the technologies for wireless data communication in the U.S.; Speeds, rates and coverage are improving. And most enterprises have completed their back-office automation and are now poised to extend the information to the field. Early adopters are proving that the ROI can be very favorable when the applications are focused on providing the right amount of data at the right time. All of these factors will contribute to significant growth in wireless data adoption.

For mobile workers still relying on paper systems, the payback of wireless communications can be significant often generating 20-30% ROI. In addition, speed of information can be critical to meeting customer expectations on responsiveness and maintaining a competitive advantage.

15

The move from paper to electronic data should be carefully planned. As part of the requirements analysis, companies should focus on identifying the information that has particular value in real time. To keep costs low, enterprises should focus on a dual-communication approach, using wide-area wireless where there is an identified value. Other data can be sent a few times a day in a batch mode using Ethernet, 802.11b wireless, or even dialup. Application designs should take into consideration the limitations of coverage, speed and data costs.

PROPOSED SYSTEM AND FEATURES PROPOSED SYSTEM AND FEATURES Wireless technology has been a boon for both business and home users. Dependence upon this mode of connectivity carries a dark side. The aspect of sending your data into the air where there are no barriers to its propagation has provided another avenue for malicious users to gain access to your data and your network. The existing systems provide very weak security and ensnarers can easily manipulate and/or fabricate the data that is being transmitted. All wireless communication devices require very high security especially if sensitive information is being transmitted. Therefore in the proposed system the PC is used as the sender and a PIC micro controller is used as the receiver station. The message that is to be sent is fed in to the computer for different units. The computer will encode the data by generating a random number sequence. Each letter is converted into its ASCII value and then the corresponding binary digit. 0 is assigned a value and 1 another value. These random values are transmitted. Each letter is transmitted ten times so no data is lost during transmission. The transmitter module converts this encoded data into radio signals and sends through the antenna. The PIC Micro controller decodes the received data and separates the data for different units and displays the message on the display device. The communication takes place through RS232 port. The current system is enhanced so that wireless communication is applied for long distance communications

16

an alarming system is included to indicate that the Message has been received from the Central unit. The receiver keys in a 4-letter password, which is validated before the message is displayed to him.

REQUIREMENT SPECIFICATION REQUIREMENT SPECIFICATION 4.1 HARDWARE REQUIREMENTS PC P-III WITH WINDOWS 2000 PIC 16F877 MICROCONTROLLER LCD, KEYPAD AND BUZZER. RS-232 TRANSMITTING AND RECEIVING INTERFACING CIRCUITS

4.2 SOFTWARE REQUIREMENTS HITECH-C FOR PIC MICROCONTROLLER VISUAL BASIC FOR USER INTERFACES AND ENCRYPTION ALGORITHMS DESIGN DOCUMENTATION DESIGN DOCUMENTATION 5.1 MODULES IN THE PROJECT CREATING A USER DEFINED INTERFACE

17

DESIGNING THE ENCRYPTION ALGORITHM INTERFACING THE PC WITH THE PERIPHERALS PROGRAMMING THE MICROCONTROLLER CONNECTING THE LCD, KEYPAD AND BUZZER.

5.2 SOFTWARE DESIGN CODE GENERATION The design must be translated into machine-readable form. The code generation performs this task. If the design is performed in a detailed manner, code generation can be accomplished mechanistically. Coding for our project involves: Encrypting Data at Transmission end using Microsoft Visual Basic Transmission in Wireless Media using Visual Basic Decoding Received Data in Hi-Tech C Validating the password given by the receiver using Hi-Tech C Sounding the buzzer in Hi-Tech C Displaying Message on the Display unit using C

5.2.1 PC CODING 5.2.1.1 Designing the user interface The user interface is designed in VB. Provision is made to allow two units of data not exceeding 8 characters each. This is done by designing a form in VB with necessary buttons (send, reset etc) and text boxes.

18

5.2.1.2 Encrypting the data Each character is converted to its ASCII value and the corresponding binary digit.0 is assigned a value and 1 another value. These random values are then transmitted. Each letter is transmitted ten times so no data is lost during transmission. This is the basic encryption scheme used in the project and thus 64 data bits are transferred for the transfer of one of the character in the message. This is called as Pseudo Random Binary Sequence Algorithm. Now, the data bits are overlapped with the units messages, therefore it is difficult for a third party to tap the output. 5.2.1.3 Wireless transmission Message is sent in a PIC understandable format. The frequency of the transmitter and receiver circuitry is 433.9 Mhz, and they can be placed at a distance ranging from 2040 feet The converted format of the message is present there. Each and every code is taken one by one. It is then transmitted a number of times, as it is wireless based and so data could be lost if sent just once. Every code is sent in a particular format. 5.2.2 PIC 16F877 MICRO CONTROLLER CODING 5.2.2.1 Authentication As soon as the message is received the buzzer will sound. Once the buzzer sounds, the receiver has to key in a 4-letter password on the keypad provided. The message is displayed on the display unit if and only is the password is correct 5.2.2.2 Wireless Reception The code is got from the transmitter in a particular format. The received code is then checked along its database of codes and finds out whether the code corresponds to a 0 or a 1 in the character. It continues until it receives all 8 bits of the character and then reconstructs the character from binary format. 5.2.2.3 Decryption The received message is then decoded into a format that will be comprehensive to the user at the receiving end. The received message is in the scrambled form. The last

19

character is in the first position and viceversa, therefore left shifting is done n-times to get the information. Both the units messages are overlapped and therefore all the even bits are separated as message 1 and all the odd bits as message 2. 5.2.2.4 Presentation of the message The message is then displayed in the display unit. This is done by enabling the output registers of the PIC and giving them respective data. The buzzer is then activated to indicate the reception of a character. There is a continuous beep at the end of reception of the message. 5.2.3 DATA FLOW DIAGRAM 5.2.3.1 DATA FLOW Data flow architecture is applied when input data are to be transformed through a series of computational or manipulative components into output data. The data flow degenerates into a single line of transforms as per this project goes, and so this is called as a batch sequential data flow. This pattern accepts a message as a whole (batch) and then applies a series of sequential components to transform it to the format that is acceptable by a PIC, and then this is transformed into a format that is able to be displayed in the display unit.

20

DATA FLOW DIAGRAM

Fig 6 Data flow diagram 5.2.3.2 DESCRIPTION 5.2.3.2.1 Message Entry A required message to be sent is prompted to the user and this message is then saved onto the PC. 5.2.3.2.2 Encryption

The algorithm encourages the use of 64-bit binary code for each and every character that is 8-bit in binary form, and then an encryption scheme is applied such that data cant be searched for or tapped by a hacker.

5.2.3.2.3 Transmission and Reception Message is sent in a PIC understandable format. The frequency of the transmitter and receiver Blue tooth compatible circuitry is 433.9 Mhz, and they can be placed at a distance ranging from 20-50 feet

21

5.2.3.2.4 Decryption The received message is then decoded into a format that will be comprehensive to the user at the receiving end 5.2.3.2.5 Display Messages are displayed in a scrolling manner in the alphanumeric display unit A buzzer is there to indicate the reception of one character. 5.3 HARDWARE DESIGN The hardware section is divided into two modules namely 1) Transmitter circuit 2) Receiver circuit The transmitter circuit is designed to interface the Pc with the Transmitter module. It consists of the following subsections 1) RF Transmitter 2) MAX 232 3) Power supply unit A single board is designed around the PIC Microcontroller for the receiver circuit. It consists of: (1) PIC Microcontroller (2) Max 232 (3) RF Receiver (4) Power supply unit (5) Display Circuit

22

5.3.1 TRANSMITTER MODULE - FT_COM_TX2_433.92 MHz

20 mm

28 mm 1 2 3 4 5 6 Fig 9 Transmitter module PIN 1 - RF OUT PIN 2 - VCC PIN 3 - GROUND PIN 4 - GROUND PIN 5 - DATA IN PIN 6 - GROUND 5.3.1.1 FEATURES: Complete RF Transmitter module with no external components and no tuning required. High performance SAW based architecture with a maximum range of 100 feet at 2400 bps data rate. Interfaces directly to encoders and Microcontrollers with ease. Low power consumption suitable for battery operated devices.

23

5.3.1.2 SPECIFICATION - RF TRANSMITTER: Parameters Modulation Method Voltage Supply Current Minimum Typical Maximum Units

ON_OFF KEYED(OOK) Modulation (AM) 2.7 3 5.2 v DC 5 5.5 mA

Stand by Current

Micro Amp

Output power into 50ohm

-2

dBm

Overall frequency Accuracy Data Input low Data Input high Operating Temp Range Operating Frequency Maximum Data Rate

-250

250

KHz

0 > 0.8 0 433.67 433.92

0.8 Vcc 70 433.17 2400

Volts Volts Deg.cel MHz Bps

A t

External wave whip Helical or PCB Trace SMP

5.3.1.3 APPLICATIONS - Wireless remote control system - Keyless entry for cars - Home security - Wireless Gate and Garage door openers - Lighting control - Personal assistance/paging devices - Remote status/position sensing

24

- Access control system (RFID) - Wireless serial data transmission 5.3.2 RECEIVER MODULE - FT_COM_RX2_433.92 MHz 44 mm

Component side

15 mm

1234 Fig 10 Receiver Module PIN 1 - GND PIN 2 DATA OUT PIN 3 LINEAR OUTPUT PIN 4 VCC (+5 V) 5.3.2.1 FEATURES:

5678

PIN 5 - VCC (+5 V) PIN 6 - GND PIN 7 - GND PIN 8 RF IN

Complete Super regenerative RF Module operating at 433.92 MHz. Easy to integrate with decoders and Microcontroller directly. Compact size designed with SMD components

25

5.3.2.2 SPECIFICATION - RF RECEIVER: PARAMETER Operating Frequency Sensitivity Operating Voltage Current Data Rate Band width 5.3.4 PIC MICROCONTROLLER 5.3.4.1 PIC16F877 CKT DESCRIPTION The PIC Microcontroller board consists of circuits necessary to operate a Microcontroller with PC interface. The board contains provisions for interfacing 8 analog inputs and 23 Digital level signals. The Description of the circuit is given below. Analog inputs: Pin no 2 to 10 can be used to connect any analog signals of range 0-5v. Digital signals: The pin outs from the port is taken to a 26-pin FRC connector through which we can connect our Digital level signals 0 or 5 volts. Clock: The PIC16F877 can be operated in Four Different oscillator modes. The user can program two configuration bits FOSC1 and FOSC0 to select one of these four modes. The clock we have used is 10 MHZ, which full under HS category. LP - Low Power crystal XT - crystal / resonator RANGE 433.92 -103 +5 2.7 2400 4 UNITS MHz dBm V Dc mA bps MHz

26

MCLR/VPP:

HS - High speed crystal/resonator RC - Resistor capacitor

This is master clear input pin to the IC. A logic low signal will generate a reset signal to the microcontroller. So we have tied this pin to VCC for the proper operation of the microcontroller. TXD and RXD: To communicate with the outside world the microcontroller has an inbuilt USART. The O/P and I/P line from the USART is taken and given to a MAX232 IC for having communication with the PC. Since we have used comport for interfacing the microcontroller. VCC and Ground Pin no 32, 11 are tied to VCC and pin no 31, 12 are grounded to provide power supply to the chip.

27

5.3.4.2 PIC INTERFACE DESIGN

Fig 11 PIC 16F877

28

5.3.5 RS-232 INTERFACE WITH MAX 232 CIRCUITRY 5.3.5.1 RS 232 The most common communication interface for short distance is RS-232. RS232 defines a serial communication for one device to one computer communication port, with speeds upto 19,200 baud. Typically 7 or 8 bits (on/off) signal is transmitted to represent a character or digit. The 9-pin connector is used. The pin details are given below. RS-232 9- PIN CONNECTOR TxD- TxD+ COM +5V COM

+12V CTS RxDRxD+ Fig 12 Pin Connector

29

5.3.5.2 MAX-232 BLOCK DIAGRAM

MAX 232

Fig13 MAX 232

5.3.5.3 MAX 232 DETAILS The Max 232 is a dual RS-232 receiver / transmitter that meets all EIA RS232C specifications while using only a +5V power supply. It has 2 onboard charges pump voltage converters, which generate +10V, and 10V power supplies from a single 5V power supply. It has four level translators, two of which are RS232 transmitters that convert TTL\ CMOS input levels into + 9V RS232 outputs. The other two level translators are RS232 receivers that convert RS232 inputs to 5V

30

TTL\CMOS output level. These receivers have a nominal threshold of 1.3V, a typical hysterisis of 0.5V and can operate upto + 30V input. 1. 2. 3. Suitable for all RS232 communications. +12V power supplies required. Voltage quadrapular for input voltage upto 5.5V Section of computers, peripherals, and modems). Three main sections of MAX232 are 1. A dual transmitter 2. A dual receiver 3. +5V to + 10V dual charge pump voltage converter 5.3.6 POWER SUPPLY SECTION 5.3.6.1 CIRCUIT DIAGRAM (used in power supply

Fig 14 Power Supply Section

31

5.3.5.2 POWER SUPPLY DETAILS The MAX232 power supply section has 2 charge pumps the first uses external capacitors C1 to double the +5V input to +10V with input impedance of approximately 200. The second charge pump uses external capacitor to invert +10V to 10V with an overall output impedance of 45. The best circuit uses 22F capacitors for C1 and C4 but the value is not critical. Normally these capacitors are low cost aluminum electrolyte capacitors or tantalum if size is critical. Increasing the value of C1 and C2 to 47F will lower the output impedance of +5V to+10V doubles by about 5 and +10V to -10V inverter by about 10. Increasing the value of C3 and C4 lowers the ripple on the power supplies thereby lowering the 16KHz ripple on the RS232 output. The value of C1 and C4 can be lowered to 1F in systems where size is critical at the expense of an additional 20 impedance +10V output and 40 additional impedance at 10V input. Transmitter section: Each of the two transmitters is a CMOS inverter powered by + 10V internally generated supply. The input is TTL and CMOS compatible with a logic threshold of about 26% of Vcc. The input if an unused transmitter section can be left unconnected: an internal 400K pull up resistor connected between the transistor input and Vcc will pull the input high forming the unused transistor output low. The open circuit output voltage swing is guaranteed to meet the RS232 specification + 5v output swing under the worst of both transmitter driving the 3K. Minimum load impedance, the Vcc input at 4.5V and maximum allowable ambient temperature typical voltage with 5K and Vcc= +.9 v The slow rate at output is limited to less than 30V/s and the powered done output impedance will be a minimum of 300 with +2V applied to the output with Vcc =0V.The outputs are short circuit protected and can be short circuited to ground indefinitely.

32

Receiver section The two receivers fully conform to RS232 specifications. Theyre input impedance is between 3K either with or without 5V power applied and their switching threshold is within the +3V of RS232 specification. To ensure compatibility with either RS232 IIP or TTl\CMOS input. The MAX232 receivers have VIL of 0.8V and VIH of 2.4V the receivers have 0.5V of hysterisis to improve noise rejection. The TTL\CMOS compatible output of receiver will be low whenever the RS232 input is greater than 2.4V. The receiver output will be high when input is floating or driven between +0.8V and 30V.

IMPLEMENTATION

6.1

USER INTERFACE

6.2 SOURCE CODE 6.2.1 PC CODING - ENCRYPTION Priv ate Sub Co mm and 2_C lick () 'Sen d For i = 1 To 8

33

Command2.Caption = "Sending.... " & i DoEvents j=1 For k = 1 To 10 Sstr = "[0" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[1" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=2 For k = 1 To 10 Sstr = "[2" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[3" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=3

34

For k = 1 To 10 Sstr = "[4" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[5" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=4 For k = 1 To 10 Sstr = "[6" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[7" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=5 For k = 1 To 10 Sstr = "[8" & Chr(Udata1(i, j)) & "]" Sleep (2)

35

Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[9" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=6 For k = 1 To 10 Sstr = "[A" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[B" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=7 For k = 1 To 10 Sstr = "[C" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10

36

Sstr = "[D" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next j=8 For k = 1 To 10 Sstr = "[E" & Chr(Udata1(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next For k = 1 To 10 Sstr = "[F" & Chr(Udata2(i, j)) & "]" Sleep (2) Mscomm1.Output = Sstr Next Next Command2.Caption = "Send" End Sub Private Sub Command3_Click() End End Sub Private Sub Form_Load() Mscomm1.PortOpen = True End Sub Private Sub RR_Click()

37

Text1 = "" Text2.Text = UCase(Text2.Text) Text3.Text = UCase(Text3.Text) Splen = 8 - Len(Text2.Text) Text2.Text = Text2.Text & Space(Splen) Splen = 8 - Len(Text3.Text) Text3.Text = Text3.Text & Space(Splen) For i = 1 To 8 Mybyte = Asc(Mid$(Text2.Text, i, 1)) If (Mybyte And &H80) = &H80 Then Udata1(i, 1) = 116 Else Udata1(i, 1) = 11 End If If (Mybyte And &H40) = &H40 Then Udata1(i, 2) = 116 Else Udata1(i, 2) = 11 End If If (Mybyte And &H20) = &H20 Then Udata1(i, 3) = 116 Else Udata1(i, 3) = 11 End If If (Mybyte And &H10) = &H10 Then

38

Udata1(i, 4) = 116 Else Udata1(i, 4) = 11 End If If (Mybyte And &H8) = &H8 Then Udata1(i, 5) = 116 Else Udata1(i, 5) = 11 End If If (Mybyte And &H4) = &H4 Then Udata1(i, 6) = 116 Else Udata1(i, 6) = 11 End If If (Mybyte And &H2) = &H2 Then Udata1(i, 7) = 116 Else Udata1(i, 7) = 11 End If If (Mybyte And &H1) = &H1 Then Udata1(i, 8) = 116 Else Udata1(i, 8) = 11 End If Mybyte = Asc(Mid$(Text3.Text, i, 1))

39

If (Mybyte And &H80) = &H80 Then Udata2(i, 1) = 92 Else Udata2(i, 1) = 35 End If If (Mybyte And &H40) = &H40 Then Udata2(i, 2) = 92 Else Udata2(i, 2) = 35 End If If (Mybyte And &H20) = &H20 Then Udata2(i, 3) = 92 Else Udata2(i, 3) = 35 End If If (Mybyte And &H10) = &H10 Then Udata2(i, 4) = 92 Else Udata2(i, 4) = 35 End If If (Mybyte And &H8) = &H8 Then Udata2(i, 5) = 92 Else Udata2(i, 5) = 35 End If

40

If (Mybyte And &H4) = &H4 Then Udata2(i, 6) = 92 Else Udata2(i, 6) = 35 End If If (Mybyte And &H2) = &H2 Then Udata2(i, 7) = 92 Else Udata2(i, 7) = 35 End If If (Mybyte And &H1) = &H1 Then Udata2(i, 8) = 92 Else End If For j = 1 To 8 Text1.Text = Text1.Text & Chr(Udata1(i, j)) & " " & Chr(Udata2(i, j)) & vbCrLf Next Next End Sub 6.2.2 PIC CODING DECRYPTION #include <pic.h> #include <math.h> #include <string.h> #include <stdio.h> #include "delay10.c" Udata2(i, 8) = 35

41

short int ScanKey(); unsigned char RetKey(short int Ky); short int Key,j,k; short int i = 0,Chcnt = 0; char Rval; short int Rrdy_Flag=0,Sync_Flag=0; unsigned char Rbuf[3]; unsigned char Rdata[16]; short int Ptr=0,St=0,Flg=0; unsigned char U1char=' ',U2char=' '; static void interrupt Int(); void LCD_SendData(unsigned char dat); void LCD_SendCmd(unsigned char cmd); void CheckBusy(); void ClearLine(short int st); char Data[4]; char Ch; char Mess1[10],Mess2[10],Mess3[10];

void main() { delayMs(100); TRISB = 0x00; TRISD = 0x0f; TRISC = 0xb0;

42

TRISE = 0x00; PORTB = 0x00; PORTD = 0x0f; ADCON0 = 0x81; ADCON1 = 0x82; SPBRG = 64; TXEN = 1; BRGH = 0; SYNC = 0; SPEN = 1; // Enable Serial Port CREN = 1; // Enable continuous reception RCIF = 0; // Clear RCIF Interrupt Flag RCIE = 1; // Set RCIE Interrupt Enable PEIE = 1; // Enable peripheral interrupts GIE = 1; // ; Enable global interrupts // Enable transmit // ; Select high baud rate

LCD_SendCmd(0x38); DelayMs(100); DelayMs(100); CheckBusy(); LCD_SendCmd(0x06); CheckBusy(); LCD_SendCmd(0x0c); CheckBusy(); LCD_SendCmd(0x01); CheckBusy();

43

LCD_SendCmd(0x02); CheckBusy(); LCD_SendCmd(0x80); CheckBusy(); LCD_SendData('E'); RC0 = 0; RC1 = 1; RC2 = 1; for(;;) { if(Rrdy_Flag == 1) { Rrdy_Flag = 0; switch(Rbuf[0]) {Case '0': Rdata[0] = Rbuf[1]; Flg = 0; break; case '1': Rdata[1] = Rbuf[1]; break; case '2': Rdata[2] = Rbuf[1]; break; case '3':

44

Rdata[3] = Rbuf[1]; break; case '4': Rdata[4] = Rbuf[1]; break; case '5': Rdata[5] = Rbuf[1]; break; case '6': Rdata[6] = Rbuf[1]; break; case '7': Rdata[7] = Rbuf[1]; break; case '8': Rdata[8] = Rbuf[1]; break; case '9': Rdata[9] = Rbuf[1]; break; case 'A': Rdata[10] = Rbuf[1]; break; case 'B': Rdata[11] = Rbuf[1];

45

break; case 'C': Rdata[12] = Rbuf[1]; break; case 'D': Rdata[13] = Rbuf[1]; break; case 'E': Rdata[14] = Rbuf[1]; break; case 'F': if(Flg == 0) { Flg = 1; Rdata[15] = Rbuf[1]; St = 1; k = 0; } break; } if(St == 1) { St = 0; U1char = 0; U2char = 0;

46

for(i=0; i <= 15; i+=2) { U1char <<= 1; if(Rdata[i] == 11) { U1char |= 0x00; } if(Rdata[i] == 116) { U1char |= 0x01; } } for(i=1; i <= 15; i+=2) {

U2char <<= 1; if(Rdata[i] == 35) { U2char |= 0x00; } if(Rdata[i] == 92) { U2char |= 0x01; } }

47

Mess1[Chcnt] = U1char; Mess2[Chcnt] = U2char; Chcnt++; while(Chcnt == 8) { RC1 = 0; RC2 = 0; strcpy(Mess3,Mess1); if(k == 0) { RC0 = 1; DelayMs(250); DelayMs(250); DelayMs(250); DelayMs(250); RC0 = 0; }

CheckBusy(); LCD_SendCmd(0x81); CheckBusy(); LCD_SendData('E'); CheckBusy(); LCD_SendData('n'); CheckBusy(); LCD_SendData('t');

48

CheckBusy(); LCD_SendData('e'); CheckBusy(); LCD_SendData('r'); CheckBusy(); LCD_SendData(' '); CheckBusy(); LCD_SendData('P'); CheckBusy(); LCD_SendData('w'); CheckBusy(); LCD_SendData('d'); CheckBusy(); LCD_SendData(':'); CheckBusy(); LCD_SendCmd(0x8b); i = 1; j = 0; while(i) { Key = ScanKey(); if(Key != 20) { Ch = RetKey(Key); CheckBusy(); LCD_SendData('*');

49

Data[j++] = Ch; if(j == 4) { i = 0; continue; } } } Data[j] = '\0'; j = strcmp(Data,"9182"); if(j==0) { ClearLine(0x80); ClearLine(0xc0);

for(i=0; i<8;i++) { CheckBusy(); LCD_SendCmd(0x80+i); CheckBusy(); LCD_SendData(Mess3[i]); CheckBusy(); LCD_SendCmd(0xc0+i); CheckBusy();

50

LCD_SendData(Mess2[i]); } Chcnt = 0; i = 1; while(i) { Key = ScanKey(); if(Key != 20) { Ch = RetKey(Key); if(Ch == 'E') { i = 0; continue; } } } ClearLine(0x80); ClearLine(0xc0); RC1 = 1; RC2 = 1; } else { RC0 = 1; DelayMs(250);

51

RC0 = 0; DelayMs(250); RC0 = 1; DelayMs(250); RC0 = 0; ClearLine(0x80); ClearLine(0xc0); k++; if( k > 2) { k = 0; Chcnt = 0; RC1 = 1; RC2 = 1; } } } } } DelayMs(20); } } static void interrupt Int() { if(RCIF)

52

RCIF = 0; if(Sync_Flag != 0) { if(RCREG == ']') { Rrdy_Flag = 1; Sync_Flag = 0; } else

{ if((RCREG >= 0x30 && RCREG <= 0x39) || (RCREG >= 0x41 && RCREG <= 0x46) || RCREG == 116 || RCREG == 11 || RCREG == 92 || RCREG == 35) Rbuf[Ptr++] = RCREG; } } else { if(RCREG == '[') { Sync_Flag = 1; Ptr = 0; } } } } void CheckBusy() { TRISB = 0xff;

53

do {RE0 = 0; RE1 = 1; RE2 = 1; DelayUs(20); RE2 = 0; }while(RB7); TRISB = 0x00; PORTB = 0x00; } void LCD_SendCmd(unsigned char cmd) { PORTB = cmd; RE0 = 0; RE1 = 0; RE2 = 1; DelayUs(20); RE2 = 0; } void LCD_SendData(unsigned char dat) { PORTB = dat; RE0 = 1; RE1 = 0; RE2 = 1; DelayUs(20); RE2 = 0;

54

} void ClearLine(short int st) { short int l; for(l=0;l<=15;l++) { CheckBusy(); LCD_SendCmd(st+l); CheckBusy(); LCD_SendData(' '); } } short int ScanKey() { PORTD = 0x00; PORTD = 0x80; DelayMs(2); if( (PORTD & 0x0f) == 0x01) { while(RD0) continue; return(1); } if( (PORTD & 0x0f) == 0x02) { while(RD1) continue; return(2); } if( (PORTD & 0x0f) == 0x04) { while(RD2) continue; return(3); } PORTD = 0x00; PORTD = 0x40; DelayMs(2); if( (PORTD & 0x0f) == 0x01) { while(RD0) continue; return(4); } if( (PORTD & 0x0f) == 0x02) { while(RD1) continue; return(5); } if( (PORTD & 0x0f) == 0x04) { while(RD2) continue; return(6); } PORTD = 0x00; PORTD = 0x20;

55

DelayMs(2); if( (PORTD & 0x0f) == 0x01) { while(RD0) continue; return(7); } if( (PORTD & 0x0f) == 0x02) { while(RD1) continue; return(8); } if( (PORTD & 0x0f) == 0x04) { while(RD2) continue; return(9); } PORTD = 0x00; PORTD = 0x10; DelayMs(2); if( (PORTD & 0x0f) == 0x01) { while(RD0) continue; return(10); } if( (PORTD & 0x0f) == 0x02) { while(RD1) continue; return(11); } if( (PORTD & 0x0f) == 0x08) { while(RD3) continue; return(12); } PORTD = 0x00; return(20);} unsigned char RetKey(short int Ky) { switch(Ky) { case 1: return('1'); case 2: return('2'); case 3: return('3'); case 4: return('4'); case 5: return('5'); case 6:

56

return('6'); case 7: return('7'); case 8: return('8'); case 9: return('9'); case 10: return('.'); case 11: return('0'); case 12: return('E'); } }

CONCLUSION CONCLUSION This project aimed at Encryption and Decryption for secure communication in WLAN has satisfied the goal. The development and implementation of this system has given us a great satisfaction. Through our efforts, we have incorporated into the system several features such as authentication and integrity. The implementation of the project provides the following: User-friendly interface Security Encryption of data. Authentication Checking for password at receiver end.

57

Scalability Further features can be easily added 7.1 FUTURE ENHANCEMENTS The PIC microcontroller which is being used has to receive the data from the base station has limited memory capacity and processing speed. This severely inhibits the potential of the receiver. The frequency used is 433 Mhz which has a very limited bandwidth. The use of higher bandwidth of around 3 Ghz will increase the speed of transmission. In order to use higher bandwidth the speed of the processor must also be increased proportionally. The presence of more memory will help the receiver to store the received data on to the buffer. This buffer is useful if we were to present authentication mechanism.

The amount of authentication mechanism should be improved by adding more keys to the receiver to authenticate the persons identity. The processor should also be custom designed to improve performance and to reduce operational overhead. The base station software could also be improved to design a better interface to transmit data to multiple units. The number of error messages and status mechanism should also be improved. There should be a feedback from the receiver that the data has been received successfully. APPENDIX APPENDIX -1 LINEAR CONGRUENTIAL GENERATOR. This is the most commonly used type of generator. Very Fast and adequate for most purposes. But this type of generator does have some significant well-known flaws. Has parameters for two separate good linear congruence formulas. /* linear congruential generator. Generator x[n+1] = a * x[n] mod m */ #define RAND_INT(l,h) (((int)(random() * ((double)(h)-(l)+1))) + (l))

58

double random (void);

/* return the next random number x: 0 <= x < 1*/

void rand_seed (unsigned int);

/* seed the generator */

static unsigned int SEED = 93186752;

double random () { /* The following parameters are recommended settings based on research uncomment the one you want. */ static unsigned int a = 1588635695, m = 4294967291U, q = 2, r = 1117695901; /* static unsigned int a = 1223106847, m = 4294967291U, q = 3, r = 625646750;*/ /* static unsigned int a = 279470273, m = 4294967291U, q = 15, r = 102913196;*/ /* static unsigned int a = 1583458089, m = 2147483647, q = 1, r = 564025558; */ /* static unsigned int a = 784588716, m = 2147483647, q = 2, r = 578306215; */ /* static unsigned int a = 16807, m = 2147483647, q = 127773, r = 2836; */

/* static unsigned int a = 950706376, m = 2147483647, q = 2, r = 246070895; */ SEED = a*(SEED % q) - r*(SEED / q); return ((double)SEED / (double)m); }

59

void rand_seed (unsigned int init) { } APPENDIX - 2 Combination of a Multiply with carry generator and a simple multiplicative generator. Simple but fast and good. /* returns x(n) + z(n) where x(n) = x(n-1) + x(n-2) mod 2^32 z(n) = 30903 * z(n-1) + carry mod 2^16 Simple, fast, and very good. Period > 2^60 */ unsigned int rand(); /* returns a random 32-bit integer */ if (init != 0) SEED = init;

void rand_seed( unsigned int, unsigned int, unsigned int ); /* return a random float >= 0 and < 1 */ #define rand_float ((double)rand() / 4294967296.0)

static unsigned int x, y, z; /* the seeds */ unsigned int rand() { unsigned int v; v = x * y; x = y; y = v;

60

z = (z & 65535) * 30903 + (z >> 16); return (y + (z&65535)); } void rand_seed(seed1, seed2, seed3 ) unsigned int seed1, seed2, seed3; { x = (seed1<<1) | 1; x = x * 3 * x; y = (seed2<<1) | 1; z = seed3; } REFERENCES 1. 2. 3. 4. Aquila Controls, Visual Identification System for Portal Applications.

Fehrouzan, Data Communication And Computer Networks. John Schiller, Mobile And Wireless Communications. Mikael Skoglund and Stefan Parkvall, Code Design for Combined Channel Estimation and Error Correction.

5. 6.

Roger S. Pressman, Software Engineering-A Practitioners Approach. Microchip MPLAB ICD - Users Guide.

61

You might also like