Get help now

Improved Data Security in Wsn Using Leach-C Protocol by Integrated Aes

Updated August 25, 2022
dovnload

Download Paper

File format: .pdf, .doc, available for editing

Improved Data Security in Wsn Using Leach-C Protocol by Integrated Aes essay

Get help to write your own 100% unique essay

Get custom paper

78 writers are online and ready to chat

This essay has been submitted to us by a student. This is not an example of the work written by our writers.

IMPROVED DATA SECURITY IN WSN USING LEACH-C PROTOCOL BY INTEGRATED AES By TADESSE G/SILASIE DEPARTMENT OF COMPUTER AND INFORMATION TECHNOLOGY DEFENCE UNIVERSITY COLLEGE OF ENGINEERING BISHOFTU, ETHIOPIA JUNE, 2018 IMPROVED DATA SECURITY IN WSN USING LEACH-C PROTOCOL BY INTEGRATED AES M-Tech ThesisSubmitted in partial fulfillment of the requirement for the degree of Master of Technology in Network and Information Security BY Tadesse G/silasieUnder the guidance of Dr.

Jes.B. Sundar Department of Computer and Information Technology Defense UniversityCollege Of EngineeringBishoftu, Ethiopia June, 2018 DECLARATIONI hereby declare that the thesis project entitled “Improved data security in WSN using LEACH-C protocol by integrated AES” is submitted for M-Tech Degree is my original work and the thesis project has not formed the basis for the award of any degree, associate ship, fellowship or any other similar titles. Name: Tadesse GebresilasieSignature of the student___________ Place___________________________ Date: _________ CERTIFICATEThis is to certify that the thesis project entitled “Improved data security in WSN using LEACH-C protocol by integrated AES” has the work carried out by Tadesse Gebresilasie Weldetekle student of M-Tech, Defense Engineering College, Bishoftu, during the year 2017/2018. In partial fulfillment of the requirement for the award of the Degree of M-Tech of Computer and Information Technology with focus area of Network and Information Security and that the thesis project has not formed the basis for the award previously of any degree, diploma, associate ship, fellowship or any other similar rule. Name of advisor: Dr.

Jes.B. SundarSignature of the advisor: _______________ Place: ______________________________ Date: ________________ Approval by members of BoE Name Signature 1. External Examiner: _________________________ ______ 2. Internal Examiner: _________________________ ______ 3. Chairperson/HoD: _________________________ ______ 4. Advisor: _________________________ ______ ABSTRACTA wireless sensor node has made up of small electronics, which can be used to sense an object, process and transceiver information from a specific environment for a limited application time.

Sensor networks were interrelating with sensitive data under insecure environment, it is clear that security has the main concerns starting from the simple system design up to operation. To insure data Security in WSN has a serious challenge, due to limitation of energy, computational capability and storage resources of the sensor nodes. Information is a power, in the open medium channel; the data transfer sender to receiver it need to be hidden or secure from unauthorized access. In our thesis work distinguished two main concern problems constraint of energy and security. We tried to improve the data security by using cryptographic protection AES algorithm to ensure data confidentiality of the network and to minimize the consumption of energy we chosen centralized low energy adaptive clustering hierarchy (LEACH-C) protocol for cluster head selection, which was track at the BS, thus reduced the nodes energy consumption and increased their life-time.

By integrated this methodology it can improve data security and can extending the life time of the network. Using AES algorithm, Plain text message sent by sender is altered into completely new cipher text, which unauthorized access cannot guess original message at receiver using AES decryption, same plain text is successfully recovered from AES encrypted cipher text. Performance matrices of LEACH-C were evaluated based on various measures. To measure the performance of the proposed work we used three parameters which are: number of Dead nodes, number of packets transmitted and remaining energy of the network.

The network model was simulated in MATLAB tool to obtain the required proposed result. KEYWORDS – AES, Data security, LEACH-C, MATLAB and WSN ACKNOWLEDGMENTFirst of all I would like to thank the almighty of God for guiding me in all circumstances to accomplish my work. My appreciation goes also to my supervisor Dr. Jes.B. Sundar: for his advice, concern, encouragement, formal guidance and encouragement throughout my graduate studies. My special thanks go to Major Dessalegn Mesfin (Head of Department ICT), for his encouragement, and for scarifying his precious time whenever I needed help.

Lastly, I offer my best regards and blessings to all my family members and friends who supported me in any respect during the completion of my graduate study. TABLE OF CONTENTSContents Page No. TOC o “1-3” h z u DECLARATION PAGEREF _Toc515527156 h iCERTIFICATE PAGEREF _Toc515527157 h iiApproval by members of BoE PAGEREF _Toc515527158 h iiiABSTRACT PAGEREF _Toc515527159 h ivACKNOWLEDGMENT PAGEREF _Toc515527160 h vTABLE OF CONTENTS PAGEREF _Toc515527161 h viLIST OF TABLESixLIST OF FIGURES PAGEREF _Toc515527163 h xLIST OF ACRONYMS AND ABBREVIATIONS PAGEREF _Toc515527164 h xi CHAPTER 1- INTRODUCTION PAGEREF _Toc515527165 h 1-10 1.1.Background of WSN PAGEREF _Toc515527166 h 11.1.1.Major components of WSN PAGEREF _Toc515527168 h 21.1.2.Constraints of wireless sensor network PAGEREF _Toc515527169 h 21.2.Application domain of wireless sensor network PAGEREF _Toc515527170 h 31.3.Significance of Centralized LEACH routing protocol in WSN PAGEREF _Toc515527171 h 41.4.Significance of data security in WSN PAGEREF _Toc515527172 h 61.4.1.Data Security Constraints in WSN PAGEREF _Toc515527173 h 61.4.2.Security Requirements in Wireless Sensor Networks PAGEREF _Toc515527174 h 71.5.Statement of the problem PAGEREF _Toc515527175 h 81.6.Objectives PAGEREF _Toc515527176 h 81.6.1.General Objective PAGEREF _Toc515527177 h 81.6.2.Specific Objective PAGEREF _Toc515527178 h 81.7.Scope of the study PAGEREF _Toc515527179 h 91.8.Limitation of the thesis PAGEREF _Toc515527180 h 91.9.Research Methodology PAGEREF _Toc515527181 h 91.10.Expected outcome of the thesis PAGEREF _Toc515527182 h 101.11.Significance of the thesis PAGEREF _Toc515527183 h 101.12.Organization of the thesis PAGEREF _Toc515527184 h 10CHAPTER 2- LITERATURE REVIEW PAGEREF _Toc515527185 h 11-13 2.1.Data security in LEACH protocol PAGEREF _Toc515527186 h 112.2.Data security in multi hop routing protocol PAGEREF _Toc515527187 h 122.3.Data security in wireless sensor networks PAGEREF _Toc515527188 h 122.4.Brief summary of literature review and Research gap PAGEREF _Toc515527189 h 13CHAPTER 3 – THIORY OF LEACH-C & AES ALGORITHM PAGEREF _Toc515527190 h 14-26 3.1.Significance of Centralized LEACH protocol algorithm PAGEREF _Toc515527191 h 143.1.1.Network Model of LEACH-C PAGEREF _Toc515527192 h 153.1.2.Set-up phase PAGEREF _Toc515527193 h 163.1.3.Steady state Phase PAGEREF _Toc515527194 h 173.1.4.Energy Model PAGEREF _Toc515527195 h 183.2.Algorithm of Advanced Encryption Standard (AES) PAGEREF _Toc515527196 h 193.2.1.Operation of AES PAGEREF _Toc515527197 h 203.2.2.Encryption process PAGEREF _Toc515527198 h 203.2.3.Decryption process PAGEREF _Toc515527199 h 24CHAPTER 4- METHODOLOGY AND IMPLEMENTATION PAGEREF _Toc515527200 h 27-33 4.1.Requirement of WSN Simulation Tools PAGEREF _Toc515527201 h 274.2.Implementation of AES on LEACH-C routing protocol PAGEREF _Toc515527202 h 284.2.1.Implementation of LEACH-C Algorithm PAGEREF _Toc515527203 h 314.2.2.Implementation of AES Encryption Algorithm PAGEREF _Toc515527204 h 324.2.3.Implementation of AES Decryption Algorithm PAGEREF _Toc515527205 h 33CHAPTER 5- SIMULATION RESULTS AND ANALYSIS PAGEREF _Toc515527206 h 34-41 5.1.Simulation Environment and Parameters PAGEREF _Toc515527208 h 345.2.Performance metrics PAGEREF _Toc515527209 h 355.3.Simulation Results PAGEREF _Toc515527210 h 365.3.1.Total number of packet sent vs Rounds PAGEREF _Toc515527211 h 375.3.2.Number of dead nodes vs Rounds PAGEREF _Toc515527212 h 385.3.3.Total Remaining of Energy vs Rounds PAGEREF _Toc515527213 h 395.4.AES performance, memory usage and strength PAGEREF _Toc515527214 h 405.5.Chapter summary PAGEREF _Toc515527215 h 41CHAPTER 6- CONCLUSION AND RECOMMENDATION PAGEREF _Toc515527216 h 42-43 6.1.Summary PAGEREF _Toc515527217 h 426.2.Conclusion PAGEREF _Toc515527218 h 426.3.Future work PAGEREF _Toc515527219 h 43REFERENCES PAGEREF _Toc515527220 h 44APPENDICES PAGEREF _Toc515527221 h AAPPENDIX A: Encryption and Decryption Blocks Of AES PAGEREF _Toc515527222 h AAPPENDIX B: Centralized LEACH Algorithm PAGEREF _Toc515527223 h R LIST OF TABLESTable No. Description Page No.

Table 5-1 Simulation parameters 35 Table 5-2 Data of dead nodes & remaining energy of WSN 38 LIST OF FIGURESFigure No. Description Page No. Figure 1-1 Structure of sensor node 1 Figure 1-2 Application of WSNs 4 Figure 1-3 Taxonomy of routing protocols 5 Figure 3-1 Flow chart of setup phase in LEACH-C 16 Figure 3-2 Flow chart of steady state phase in LEACH-C 17 Figure 3-3 Time line showing LEACH-C operation 18 Figure 3-4 Radio energy dissipation model 18 Figure 3-5 AES structure 19 Figure 3-6 Overview of AES Encryption 21 Figure 3-7 Table of sub bytes 22 Figure 3-8 Shift row 22 Figure 3-9 Mix columns 23 Figure 3-10 Add round key 24 Figure 3-11 Key schedule 24 Figure 3-12 Inverse shift row 25 Figure 3-13 Inverse S-Box table 26 Figure 3-14 Inverse mix columns 26 Figure 4-1 Diagrammatic representation of communication 27 Figure 4-2 Flow chart of LEACH-C with integrating AES 29 Figure 4-3 Data flow diagram of AES Encryption 32 Figure 5-1 Deployment of sensor nodes & cluster formation 36 Figure 5-2 Total number of packet send to CH 37 Figure 5-3 Total number of packet send to BS 38 Figure 5-4 Total number of dead node 39 Figure 5-5 Total number of remaining energy 40 LIST OF ACRONYMS AND ABBREVIATIONSADC Analog to Digital Converter AESAdvanced Encryption Standard BSBase StationCBCCipher Block Chaining CFBCipher Feed Back Mode CHCluster Head DES Data Encryption Standard CLAECertificate less Authentication Encryption DSSS Direct Sequence Spread Spectrum ECBElectronic Code Book FIPS Federal Information Processing Standard GF Galois Field GPSGlobal Positioning System IEEEInstitute of Electrical and Electronics Engineers LEACH-B Balance Low Energy Adaptive Clustering Hierarchy LEACH-CCentralized Low Energy Adaptive Clustering Hierarchy PEGASIS Power-Efficient Gathering in Sensor Information Systems RSSIReceived Signal Strength Indicator SNR Signal to Noise Ratio SOP Standard Operating Procedure TDMATime Division Multiple Access TDMSTime Division Multi-attribute Sleep CHAPTER – 1 INTRODUCTIONBackground of WSN A WSN has a network formed by a large number of sensor nodes where each node has prepared with sensing unit, a processing unit, communication unit and power unit. Each and every node is capable to perform data gathering, sensing, processing and communicating with neighboring other nodes. The sensing unit of the sensor senses the environment; the processing unit computes the confined permutations of the sensed data, and the communication unit performs exchange of processed information among neighboring sensor nodes.

Sensor nodes were a self-configured network of small sensor nodes interactive among themselves using radio signals. WSN with security of cryptographic method was a revolutionary information gathered method to build the information and communication system which will greatly improve the reliability, confidentiality and efficiency of infrastructure systems. To compare with the wired solution, WSNs feature easier placement and better flexibility of devices in short period of time. Implement of security mechanisms in sensor nodes need to consider their storage space, power consumption and other factors 19. The general and very basic building block of a sensor node typically composed of four main components 6. Figure 1-1 Structure of Sensor NodeSensing unit: The sensing unit usually consists of one or more sensors and analog to digital converters (ADCs) device.

The sensors perceive the physical condition and generate analog signals based on the observed phenomenon. The ADCs convert the analog signals into digital signals, which are then fed to the processing unit. Processing Unit: The processing unit usually has a main part and consists of a microprocessor with memory, which provides intelligent control to the sensor node. Communication Unit: The communication unit consists of a short range radio for performing data transceiver over a radio channel. Power Unit: The power unit consists of a battery for supplying power to drive all other components in the system.

Major components of WSNSensor Field: A sensor field can be measured as the area or surrounding in which the nodes are positioned with limited distance range. Sensor Nodes: Sensors nodes are the heart of the network. They have a responsibility of gathering data and routing this information back to the sink or BS. Sink Node: A sink having high energy level and perform with the specific task of receiving, processing and storing data from the other sensor nodes.

They were contribution to reduce the total number of messages that need to be sent, hence decreasing the overall energy supplies of the network. Collects sensor position data, energy level related information and if nodes have more than average energy that was elected as cluster heads then inform decision back to the elected as cluster heads. Remote user: The remote user was the centralized point of command and control within the network, which extracts information from the network and broadcasts control information back to the network. It also functions as a gateway to other networks, a powerful data processing, storage center and an access point for a human interface. Constraints of wireless sensor network SNs were intended to operate their functions using wireless interconnection for data transceiver.

This means sensor nodes depend on local power sources such as power scavenging or onboard batteries for both data processing and communication. WSN suffers from prevalent constraints such as restricted memory, little computational capability, not rechargeable and restricted battery life. WSN has unique characteristics as follows: Dynamic Network Topology: Network topology changes regularly as nodes can be added or removed, node failure, energy depletion, channel fading or another security problem. Application Specific: The design requirement of the network varies with required application and duration.

Energy constrained: Nodes were easily portable and highly limited in energy, computation and storage capacities. This was the most important design consideration to improved life time of WSN. Self-configurable: Nodes were randomly or planning deployed in a specific location of area. Once deployed, nodes have to configure autonomously themselves into a communication network using Omni-directional radio antenna. Application domain of wireless sensor networkNow a day WSNs are rapidly progressively used in several real-world applications.

Naturally, a sensor node has constraint in terms of computation capability, energy reserves and security problem. The main concern of the sensor node was to gather the sensed data of the target area and transmit the data to nearest CH or BS (sink). A WSN contains of spatially dispersed autonomous sensors to supportively monitor physical or environmental conditions, such as temperature, sound, vibration, pressure, motion. Some of the specific applications of WSN are as follow: – Military application: Sensor networks used to large-scale acoustic ocean surveillance systems for the detection of submarines, self-organized and randomly deployed WSNs in ground or in air for battlefield surveillance and attaching micro sensors to weapons for store scrutiny. Environmental monitoring: Environmental monitoring can be used for animal tracking, forest surveillance, flood detection, and weather forecasting. Health Monitoring: WSNs can be embedded into a hospital building to track and monitor patient, all medical resources and status of temperature.

Traffic Control: Sensor networks have been used for vehicle traffic monitoring and control for some time. At many crossroads, there are either overhead or buried sensors to detect vehicles and to control the traffic lights. Furthermore, video cameras are also frequently used to monitor road segments with heavy traffic. Industrial Sensing: Industrial sensing as plant infrastructure ages, equipment failures cause more and more unplanned downtime to monitor the “health” of machines and to ensure safe operation, Aging pipelines and tanks, corrosion monitoring food industry to prevent the incidents of contaminating. Infrastructure Security: WSNs among multiple activities also can be used for infrastructure security and counterterrorism applications. Critical buildings and facilities such as power plants, airports, and military bases have to be protected from potential assaults.

WSN are contains of sensor nodes, BS (Sink node), internet or communication satellite and some other useful parts. Like Figure 1-2, the remote-user does not connect directly to sensor field but via a BS (Sink node). Sensor nodes scatter within the definite sensing areas. Each node can receive and transfer data to cluster head and then to BS, which can collect, process, upload data.

BS can also send information to each node in the same way. Because of the severe environment of the application, once deployed, the small sensor nodes are far away from users. Figure 12 Application of WSNsSignificance of Centralized LEACH routing protocol in WSNThere are many WSN routing protocols for data transmission in wireless sensor network. Among several kinds of WSN routing protocol centralized LEACH hierarchical routing protocols are used for improving energy consumption by arranging sensor nodes into clusters.

Every sensor cluster is managed by cluster head during the network operation such as data transmission. Centralized clustering formation technique is used to minimize the node level processing burden and avoid multiple communications. In addition, energy consumption of the sensors are depends on the request requirements. Therefore, Batteries play the main character indicator of the lifetime of a sensor. In Wireless network, maximum of the energy is consumed in the process of data transmission.

Thus, the energy efficiency routing protocols are needed to improve the lifetime of the networks. Among various kinds of network routing protocols centralized low energy adaptive clustering hierarchy has more rounds of transmission to BS and less energy. A routing protocol is measured adaptive if certain system parameters can be controlled in order to adapt to up-to-date network conditions and available energy levels. 68762943993LEACH-B Routing Protocols in WSN Path Establishment Network Structure Protocol Operation Hierarchical Flat Location Based LEACH-C Static Dynamic 00LEACH-B Routing Protocols in WSN Path Establishment Network Structure Protocol Operation Hierarchical Flat Location Based LEACH-C Static Dynamic Figure 13 Taxonomy of Routing Protocol The formation of cluster can aid to attain scalability, network lifetime, and energy efficiency. In Dynamic, cluster are changed with the rounds but in Static, once the clusters are created remain same throughout the network lifetime 14.

Centralized LEACH is a kind of improved of the normal LEACH and can generate better performance by issuing the cluster heads over the network. To discovery good clusters, the sink requires to guarantee that the energy load is regularly dispersed among all the nodes. To do this, sink analyses the average node energy, and computes which nodes have energy lower than the mean average. Once the CHs and related clusters are determined, the sink forwards a message that reaches the cluster head ID for each node. If a cluster head ID same as its own ID, the node is a cluster head; else the node determines its TDMA slot for data broadcast and goes sleep until it’s time to transmit data.

In LEACH-C, the position information and the remaining energy value of totally the nodes will be sent to the BS at the establishment of each round. Centralized LEACH is unlike from original LEACH in cluster formation but its process similar to original LEACH Protocol. LEACH-C make centralized cluster algorithm for selection of CH. In LEACH-C setup phase is similar to original LEACH but Steady state phase is unlike.

BS gathers position data and energy level related information from each node. It has global information of network and computes average remaining node energy. Nodes have energy more than average energy is elected as cluster heads and use GPS or other position tracking methods. BS sends its decision back to nodes that which nodes are elected as CH. Centralized LEACH uses a deterministic threshold algorithm in which quantity of energy in the node and/or whether or not the node was a cluster head in current time.

The central control algorithm is used in Centralized LEACH to form the clusters which produce improved clusters by distributing the cluster head nodes through the network. LEACH-C protocol can produce improved performance by allocating the cluster heads over the network. Centralized Clustering based protocols divide in two phases: setup phase and the steady state phase. Significance of data security in WSNIn WSN sensor nodes are closely deployed and they interact with their surrounding environment very closely. They are operate and functions without the absence of any remote monitoring system.

That is, the nodes are exposed to the hostile environment as well as to the unauthorized access at a risk of physically being damaged. Data Security Constraints in WSN A WSN consists of a large number of sensor nodes to sense a data from surrounding that are fundamentally resource-constrained devices. These nodes have limited processing capability, very low storage capacity, and constrained communication bandwidth. These constraints are due to limited energy and physical size of the sensor nodes. Due to these constraints, it is difficult to directly employ the conventional security mechanisms in WSNs.

Some of the major constraints of a WSN are listed below 11. Energy constraints: Energy is the biggest constraint for a WSN, such as, energy consumption in sensor nodes for the sensor transducer, for communication among sensor nodes, microprocessor computation. Memory limitations: A sensor is a tiny device with only a small amount of memory size and storage space. SN is usually includes flash memory and RAM. Flash memory is used for storing downloaded application code and RAM is used for storing application programs, sensor data, and intermediate results of computations.

Therefore not enough space to run complicated algorithms after loading the OS and application code. Unreliable communication: Unreliable communication is another serious constraint to sensor security. Security Requirements in Wireless Sensor Networks WSN is vulnerable to various attacks and unauthorized access, but its limited resource characteristics and unique application features requires some extra security requirements including the typical network requirements. Typically security mechanisms are built to address three well-known services; confidentiality, integrity and availability usually known as CIA security model.

These services are described in detail as follow: Data confidentiality: The security mechanism should ensure that no message data in the network is understood by anyone except intended recipient. Data confidentiality is one of the vital security requirements for WSN because of its application purpose activities (for example, military and key distribution applications). Sensor nodes communicate sensitive data, so it is necessary to ensure that any intruder or other neighboring network could not get confidential information intercepting in the transmissions. One standard security method of providing data confidentiality is to encrypt data and use of shared key until to intended receivers can get the sensitive data. Authenticity and integrity: Only providing data privacy is not enough to ensure the data security in WSN.

As an unauthorized access can change messages on communication authentication of data as well as sender are also crucial security requirements. Source authentication provides the truthfulness of originality of the sender. Whereas, during the transmission period data authentication ensures the receiver that the data has not been modified. Availability: It is importance of availability of nodes when they are needed. For example, when WSN is used for monitoring purpose in manufacturing system, unavailability of nodes may fail to detect possible accidents and necessary data.

Availability ensures that sensor nodes are active in the network to fulfill the functionality of the operation. It should be ensured that security mechanisms imposed for data confidentiality and authentication are allowing the authorized nodes to participate in the processing of data or communication when their services are needed. Self-organization: Each node should be self-organizing and self-healing in the WSN. This feature of a WSN also attitudes a great challenge to controlling security activities. The dynamic nature of a WSN makes it sometimes impossible to deploy any pre-installed shared key mechanism among each nodes and the CH. Secure localization: In many situations, it becomes necessary to accurately and automatically location of each sensor node in a WSN.

For example, a WSN designed to locate faults requires accurate locations of sensor nodes to identify the faults and their data. Statement of the problemData Security in Wireless Sensor Network is a serious challenge, due to limitation of energy, computational capability and storage resources of the sensor nodes. There were many research conducted to improve the data security problems in WSN. The data transfer sender to receiver it must be hidden or secure from unauthorized access. In this WSN there are two main problems: limitation of WSN lifetime and security issue between wireless sensor nodes data communication. Moreover, most of the research was conducted on the consecutive results and effects of security related problems.

ObjectivesThis thesis has general and specific objectives. The general objective specifies the overall task of the thesis work and the specific objective list out all supporting tasks to be accomplished to satisfy the general objective. General ObjectiveThe general objective of this thesis was improved data security in WSN using Centralized LEACH protocol by integrated AES. Specific ObjectiveWe made the following reasonable assumptions of the sensor network security schemes: Integrated algorithm for cluster head selection in WSN, this was run at the BS, thus reducing the nodes’ energy consumption and increasing their life-time Used Advanced Encryption Standard (AES) algorithm as a security mechanism to keep confidentiality of message exchange between wireless sensor nodes Integrated AES algorithm with LEACH-C protocol and simulate using MATLAB tool for the integrated technique Evaluated the implemented performance metrics: such as number of dead nodes, number of packet sent and remaining energy of the network Scope of the studyThe scope is focus on achieved Data secure and protection from unauthorized access to provide the confidentiality of a service, a resource or information in WSN using AES algorithm. Limitation of the thesisLimitations of this thesis are listed below in descending weight: Unavailability of subtopic books and access IEEE Lack of high processor computer/licensed application software tools (paid) Limited internet connectivity, repeated power interruption Research MethodologyWhile dealing with the study of this thesis, we tried to consider the following methodologies: Studies and analyzed LEACH-C protocol with another related protocols Integrated AES algorithm on LEACH-C routing protocol algorithm Simulated the integrated in MATLAB tool to demonstrate the overall outcome Organized tabulating data and graph with performance metrics, comparing and reporting Completed adjust hard copy & soft copy document Expected outcome of the thesis To ensure Data security in WSN with LEACH-C protocol using AES algorithm.

Tried to clear and accurate thesis project has to developed ensuring the data security system. Therefore, we are proposed this thesis that may find a slightly better way in our method or technique in simple and better way. Significance of the thesisSince the proposed system is improved data security in WSN using Centralized LEACH protocol by integrated AES. Data security issue which is regarded to confidentiality as much an essential factor as efficient performance and centralized low energy consumption is solved.

This thesis use AES algorithm to ensure the confidentiality of the data communication among the wireless sensor nodes and using centralized low energy adaptive clustering hierarchy to reduce power consumption in the network. Organization of the thesisOrganization of the rest of this thesis work has as follow: Chapter two: Provides details on the literatures review related to this thesis work with brief summary of literature review including the research gap addressed. Chapter three: Talks about the theory of methodology part stated in the introduction. In this chapter the Centralized LEACH routing protocol procedures and AES algorithm procedures discussed in detail.

Chapter four: Briefly discuss selected simulation environment which was MATLAB tool, methodology and implementation of Centralized LEACH and advanced encryption standard (AES) algorithm. Integration of AES algorithm as a cryptographic means of keeping the confidentiality is discussed in detail. Chapter five: Presents simulation results and analysis of the implemented improved data security between sensor nodes, discuss about the energy consumption and number of nodes remaining in the network. Chapter six: Presents the conclusion and recommendation for future of the thesis work. CHAPTER – 2 LITERATURE REVIEWIn the last decades, many researchers have concentrated studied on the energy consumption problem in WSN. But there are some slight differences between all the papers conducted by different researchers.

In order to obtain a deep understanding and knowledge of the applicable areas and where the specific problem is lies. Different literatures like standard journals, research papers, research publications and other information available on the internet; these are related with wireless sensor network. At national level TESFAY GEBRESLASSIE (2017) Proposed on Security enhanced fuzzy logic based clustering algorithm for WSN Defense University, College of Engineering Department of Computer and Information Technology 20. At international level, the following research papers have been published which have slight similarities with this thesis work.

Let us try to see the different approaches and protocols addressed in this area at international level. Data security in LEACH protocolDEEPIKA & MANPREET (2017): Proposed on Security Enhancement In Leach Protocol. In this paper, the author used LEACH protocol for reducing energy consumption and encrypting using DES algorithm to ensure the confidentiality and integrity of the data transmission. He used the following methodologies:- Study of LEACH protocol and implementation of DES on LEACH to enhance data security Comparing the performance metrics using MATLAB tool with encrypted data and without encryption The output of the proposed work that when an encryption technique is applied total remaining energy of nodes increased, so that they can perform function without consuming more energy and protected data transmission systems. The objective of this paper is work using DES encryption algorithm to enhance data security on the LEACH protocol. To achieve this situation from LEACH select a dynamic CH rotation that there is a new CH at each round and that consider three matrices, which are number of packets send, number of dead nodes and energy 4.

Data security in multi hop routing protocolGARIMA Et al. (2017): Proposed on Security Concepts for Secure Multi hop Routing Protocol. In this paper, the author uses a fixed value of hash function algorithm, and uses Triple DES and RSA algorithm. The objective of this author focuses on security of WSNs and its main purpose are attacks in different layers.

It classifies and compares different attacks based on their nature and goals. In the future work for security it needs security issues such as confidentiality, integrity or availability of a system 5. Data security in wireless sensor networksCRISTINA Et al. (2015): proposed on Measuring the performance and energy consumption Of AES in wireless sensor networks.

In this research paper the author using for power consumption low cost components and a way of determining the encryption/Decryption duration using only the wireless node itself. To provide an optimized implementation of AES, with four modes of operation (ECB, CBC, CFB & CTR) that uses the hardware accelerator available on the ATmega128FA1 microcontroller and compare it 3. SHAILENDRA Et al. (2017): Proposed to an Efficient Certificate less Authentication Encryption (CLAE) for WSN Based on Clustering Algorithm. The objective of this paper is to ensure lower reduction of energy, higher performance of network & Secured transmission of data.

User identity is protected by the private key and the hackers can’t break the confidential message. In CLAE architecture, the identity of the user is protected by the private key and the hackers cannot break the confidential message being transmitted using Key Generation Centre. CLAE is an ID based authentication encryption where public key is generated by identity strings and sender has to choose the trusted center to which the recipients have to identify it. The author used MATLAB tool to obtain desired result 19.

M. JOTHIMEENA Et al. (2017): Proposed on Implementation of Secured Sensor Nodes Using Cryptographic Algorithms. The author was used a model cryptographic algorithms AES ; PRESENT on 8-bit microcontrollers. As the wireless sensor networks continue to grow, they are nearest vulnerable to attacks.

So, it need for security mechanisms to provide fast and secure communication in wireless sensor nodes. The author used MATLAB tool to obtain desired result 8. MADHUMITA PANDA (2015): Proposed on data security in wireless sensor networks via AES algorithm. The authors were describes that identification of suitable cryptography method for WSN is an important challenge due to limitation of energy, computational capability and storage resources of the wireless sensor nodes. They had implemented AES symmetric cryptography has a higher effectiveness and require less energy consumption.

In the future work can be extended for encrypting image 9. Brief summary of literature review and Research gap In summary of the literature review:- Using security method improving data confidentiality, integrity, availability of the system and Comparing of power consumption among four modes of AES operations (ECB, CBC, CFB ; CTR) Using cryptographic algorithm, it can build better performance of the network, secure transmission of messages and identification of suitable cryptography for WSN is an important challenge due to limitation of energy, computational capability and storage resources of the sensor nodes Most of the authors describes only on data security or on reducing power consumption of the sensor networks. Unlike the first paper which is detailed studies on security enhancement in leach routing protocol. This thesis work is taking the paper entitled by “Proposed on Security Enhancement in Leach Protocol” which is published by DEEPIKA ; MANPREET (2017) as a benchmark paper. The authors use LEACH protocol for reducing energy consumption and DES algorithm to ensure the confidentiality and integrity of the data transmission but they used data security algorithm was DES which is now a day vulnerable for cryptanalysis and they used LEACH protocol using data transmission systems. But now a day there are many enhancing on LEACH protocol such as LEACH-B, LEACH-C etc.

The main objective of this thesis work is integrating effective security mechanism our proposed AES algorithm on Centralized LEACH algorithms. We are aims to prolong life time of WSN and for secure data communication between sensor nodes and sink. CHAPTER – 3 THIORY OF LEACH-C ; AES ALGORITHMIn this chapter we will see all the procedures followed to achieve the desired result of the proposed protocol and proposed AES algorithm. It lists down all the procedures followed and gives a detailed explanation for each of them step by step.

This chapter has two sections. The first sections talks about the Centralized Low Energy Adaptive Clustering protocol and the second detail brief discussion about the data confidentiality method Advanced Encryption Standard (AES). Significance of Centralized LEACH protocol algorithm Centralized clustering formation technique is used to minimize the node level processing load, avoid multiple communications and increasing the life time of the WSN, because of their approach in CH selection and data aggregation in the network. In addition, energy consumption of the sensors are depends on the request requirements. Therefore, Batteries energy plays the main character indicator of the lifetime of in a sensor.

In communication, maximum of the energy is consumed in the process of data transmission than receiving. Thus, the energy efficiency routing protocols are used to improve the period of the networks. Among various kinds of network routing protocols centralized low energy adaptive clustering hierarchy has more rounds of transmission to BS and less energy. LEACH-C make centralized cluster algorithm for selection of CH. In LEACH-C setup phase is similar to original LEACH but Steady state phase is unlike.

BS follows direct communication gathers position data and energy level related information from each node and then computes average remaining node energy. Sensor nodes have energy more than average energy is elected as cluster heads and then BS sends its decision back to nodes that which nodes are elected as CH. Centralised-LEACH uses a control threshold algorithm in which quantity of energy in the node and/or whether or not the node was a CH in current time. In BS selection CH algorithm had been used in Centralised-LEACH to form the clusters which produce improved clusters by distributing the CH id nodes through the network. LEACH-C protocol can produce improved performance by allocating the cluster heads over the network. In order to achieve the design goal the key tasks performed by Centralized LEACH is as follows 6: Randomized rotation of the CHs and the corresponding clusters Localized co-ordination and control for cluster setup and operation Low energy media access control Application specific data processing Network Model of LEACH-C In this article, we assume a sensor network model with the following properties: Sensor node: -All nodes have same configuration, limited energy and each node has the same starting energy in the network.

All nodes are stationary deployed, each node significant and finds its responsibility in the cluster by comparing its ID with the IDs of CH. Each node send request message to the nearest CH assigned then waiting for TDMA schedule time makes its TDMA slot and goes to sleep until its transmission turn comes. Sensor node is sense data from the area of near surrounding environment, data Encryption using AES algorithm ; sends data to CH. Cluster head: -Has responsibility of Creating TDMA schedule table for member sensor nodes, receiving data from member nodes and then reducing redundant data process and applies aggregation techniques.

Heavy tasks executing timing of on the CH can lead too much energy consumption, send aggregated data and dissemination to BS can reduce the duplicated data and save transmission time. Base station: – There is a fixed BS located center of the sensor nodes. We do not consider the energy consumption of the BS and assume that it has sufficient energy supply Calculates the average node energy, and computes which nodes have energy lower than mean average. After analyzing the received information, the BS selects the optimum clusters Keeps up-to-date information on location for all the nodes in the network.

A new round begins, new clusters will be rebuilt in the whole network and chose CH ID then broadcasts information of all the clusters in the network, received encrypted data then processing, decryption and storing Advertising selected CH ID for the next round are activities of BS. In the whole process, the cluster head just works as a relay node to help member nodes shorten the transmission distance so as to save energy. This routing protocol has two phases in each round. Set-up phaseIn LEACH-C, the position information and the remaining energy value of totally the nodes will be sent to the BS at the establishment of each round. Centralized LEACH was unlike from original LEACH in cluster formation but its process similar to original LEACH Protocol.

Centralized LEACH is a kind of improved of the normal LEACH and can generate better performance by issuing the cluster heads over the network. After finished the deployment of wireless sensor nodes to discovery good clusters, the sink requires guaranteeing that the energy load is regularly dispersed among all the nodes. To do this, sink analyses the average node energy, and computes which nodes have energy lower than the mean average. Tn=p1-p×rmod1p if n?G Equation 3.1 0, otherwise Where r is the round which already ended, p is the probability of the nodes to be the CH and G is a set of nodes which have never been CH in the last 1p rounds. Figure 31 Flow-chart of set-up phase in LEACH-C protocolOnce the CHs and related clusters are determined, the sink forwards a message that reaches the cluster head ID for each node. If a cluster head ID same as its own ID, the node is a cluster head; else the node determines its TDMA slot for data broadcast and goes sleep until it’s time to transmit data.

Steady state PhaseThe steady-state phase in LEACH-C was identical to the source of LEACH protocol. For dynamic clustering nodes were ordered into clusters originally by the BS using the same method as in LEACH-C to confirm that good clusters are formed. These clusters and CHs continue varied with number of round changed throughout the lifetime of the network. In LEACH-C were nodes transmit their data to the cluster head node during each frame of data transfer (using TDMA and a DSSS spreading code to ensure minimal inter-cluster interference) and the CH aggregates the data and sends the resulting data to the BS. When the CH node’s energy was exhausted, the nodes in the cluster lose communication ability with the CH or BS and it counts as a dead sensor node. In the steady-state the operation activities were divided a data in to frames, and the sensor nodes send their data to the CH at most once per frame during their allocated transmission slot.

The period of each slot in which a sensor node transmits data was constant, therefor time to send a frame of data depends on the number of nodes in the cluster and rounds. Figure 32 Flow-chart of steady state phase in LEACH protocol The operation of centralized LEACH protocol was divided into many rounds. Each round begins with status level of each sensor nodes or (set-up phase) then the clusters were organized, followed by a steady-state phase when data were transferred from the nodes to the BS at the beginning and continue send data to CH. CH was collected, computed and aggregated data and then send to the BS, as shown in Fig.

3-3. Figure 33 Time line showing LEACH-C operation Energy Model During set-up phase and steady-state phase, a sequence of operations was executed and each one consumes a significant amount of energy. The energy consumption of a node depends on the operation it accomplishes at a particular time. A single node may achieve one or more operations in each round.

Usually, free space attenuation channel mode and multipath fading channel model were used to calculate energy ingesting in the process of routing data transmission. The protocol chooses channel mode on the base of distance between the transmitters and receivers. If the distance between nodes were less than threshold d0, free space attenuation channel model was proper, otherwise multipath fading channel model. -90805596901 bit Packet Receive Electronics Tx Amplifier Transmit Electronics 1 bit Packet E*i*dv Eelec*i Eelec*i dETx(I,d) 01 bit Packet Receive Electronics Tx Amplifier Transmit Electronics 1 bit Packet E*i*dv Eelec*i Eelec*i dETx(I,d) Figure 34 Radio energy dissipation model Therefore, to transmit k bit data a distance d, the energy consumption is ETX(k,d)=Eelec×k+?amp×k×d2, d;d0Eelec×k+?amp×k×d4, d?d0 Equation 3.2 Where Eelec was electronics energy, ?amp is magnification times of amplifier.

Consumption of amplifier and distance dm is in a scale. If transmission distance is short, d;d0 and m=2, otherwise d?d0 and m=4. Algorithm of Advanced Encryption Standard (AES)The Rijndael block cipher algorithm was chosen by NIST as the original and enhanced advanced encryption standard (AES). As DES is not regarded as a Standard any more the industry would now rush into implementing AES for cryptographic implementations on their products. It was the strongest encryption algorithm which never has been broken still now; it derives with expenses like performance capacity.

The AES algorithm was a symmetrical block cipher that can encrypt and decrypt information to ensured confidentiality of a data. Encrypting alters data to an unintelligible form called cipher text and decrypting the cipher text alters the data back to its original form of data, called plaintext. The input for the AES algorithm is a sequence of 128 bits called the plaintext. The AES algorithm encrypts the plaintext to cipher text using a secret key called the cipher key. The cipher key was kept secret and not revealed outside. The series of operations that convert plaintext to cipher text using the cipher key was called cipher.

All the operations in the AES algorithm are performed on a two dimensional array of bytes called the state. A byte was a sequence of 8 bits. 128 bits of plaintext can be represented by a group of 16 bytes. Figure 35 Advanced Encryption Standard Structures The features of AES are as follows:- 128-bit data, with 128/192/256-bit keys Symmetric key with symmetric block cipher Arrangement full specification and proposal details Robust and more rapidly than Triple-DES Software implementation in C and Java Operation of AESAES was an iterative rather than Feistel cipher and based on ‘substitution–transformation network’. It includes of a sequence of linked processes, some of which involve substituting inputs by specific outputs replacements and others contain shuffling bits around permutations.

Interestingly, AES performs all its computations on bytes rather than bits and this was an advantage. Hence, AES reads the 128 bit of a plaintext block as 16 bytes. These 16 bytes were arranged in four columns and four rows for processing as a matrix unlike DES, the number of rounds in AES is flexible and depends on the length of the key. Hence, AES uses 10 rounds for 128-bit keys, 12 rounds for 192-bit keys and 14 rounds for 256-bit keys. Each of these rounds uses a different 128-bit or 16 bytes round key, which is intended from the original AES key. Encryption processIt starts with Add Round Key with RoundKey0 and then go to loop and do Sub Byte, Shift Row, Mix Column and Add Round Key in that order for 9 Rounds each round with different Round Key (1 to 9).

The final round (Round10) also repeat the same earlier functions in the loop except the Mix Column. Figure 36 Overview of AES Encryption Here, we restrict to description of a typical round of AES encryption. Each round comprise of four sub-processes. The first round process was depicted below: – Sub Byte: non-linear substitution step using S-box The operation of Sub Bytes was similar to the S-boxes used in the DES-algorithm. Rijndael had only one S-box and the design criteria for the S-box are such that it was resilient in contradiction of the known differential, linear cryptanalysis and attack using algebraic manipulations. The Sub bytes operation was a nonlinear substitution.

It was a major reason for the security of the AES. There are different ways of understanding the Sub bytes operation. In this process, it was sufficient to reflect the Sub bytes step as a lookup in a table. With the help of this lookup table, the 16 bytes of the state (the input data) are replaced by the conforming values found in the table Figure 37 Table of sub-Bytes Shift Row: transposition step As indirect by its name, the Shift rows operation procedures diverse rows.

A simple rotate with a different rotate width was performed. The first row was not changed started from second row of the matrix row input data (the state) shifted one byte position to the left in the matrix, the third row was shifted two byte to the left positions, and the fourth row is shifted three byte to the left positions. Figure 38 Shift Rows Mix Column: mixing operation of each column using GF The Mix Column transformation was an operation on the different columns. Designed the Mix Column conversion the columns of the existing state are measured as polynomials over GF.

Every column of four bytes had currently altered using a special calculated function. This function income was as input the four bytes of one column and outputs four totally new bytes, which swap the original column. The outcome was another new matrix having of 16 new bytes. It should be distinguished that this step was not performed in the last round. Figure 39 Mix Columns Mix Columns was contrasting to the Shift rows operation, which works on rows in the 4×4 state matrixes.

In principle the mix columns was only a matrix multiplication requirements to be performed. To make this operation changeable, the usual addition and multiplication are not used. In AES, Galois field operations were used. This document does not go into the mathematical details, it was only important to know that in a Galois field, an addition resembles to an XOR and a multiplication to a more complex correspondent. The detail that there were many instances of 01 in the multiplication matrix of the Mix columns operation makes this step easily computable. Add Round Key: The Add Round Key operation was a simple XOR operation between the State and the Round Key.

The Round Key was derived from the Cipher key by means of the key schedule. The State and Round Key were of the same size and to obtain the next State an XOR operation was done per element: s(i, j)= s(i, j) ? w(i, j). Where s is the current State, s the next State and w the round key Figure 310 Add round key Key schedule The Round Keys were derived from the Cipher Key by using the means of a key schedule. The number of Round Keys essential to encrypt one block of data depends on the block length and key length as this regulates the number of rounds. For a block length of 16 bytes, 11 Round Keys (1 for initial round, 9 for normal rounds and 1 for the last round) are required. Figure 311 Key Schedule Decryption process Decryption processes were the reverse of an encryption process in every step.

1st round was the 10th round of the encryption and it used the inverse functions of Mix Column, Sub Byte and Shift Row and as you can assume the Keys arrangement were reversed too as it starts with Roundkey10 instead of Roundkey0 as it was in the previous encryption process. The AES Encryption Decryption Flowchart specifies a Federal Information Processing Standards (FIPS) approved cryptographic algorithm that can be used to protect electronic data. The process of decryption of an AES cipher text was similar to the encryption process in the reverse order. Each round consists of the four processes conducted in the reverse order: – Add round key Mix columns Shift rows Byte substitution Since sub-processes in each round were in reverse style, unlike for a Feistel Cipher, the encryption and decryption algorithm needs to be separately implemented, although they are very closely related. In this section, the whole reverse cipher of the state is described in detail.

The state undergoes in a decryption sequence: Inverse shift row The inverse shift row step is just the inverse of the forward shift row operation used in the encryption process. The first row is kept as it is and the second row is right shifted one place, the third row is right shifted to two places and the fourth row is right shifted to three places. Figure 312 Inverse shift rowInverse Sub bytes transformation using S-Box The inverse sub bytes transformation uses the inverse S-Box table provided in the figure below. Figure STYLEREF 3 s 313 Inverse S-Box tableInverse Mix column The inverse mix column transformation acts independently on every column of the state.

Figure 314 Inverse mix columnInverse Round Key The inverse round key transformation is its own inverse. Each round key is generated for each round. CHAPTER – 4 METHODOLOGY AND IMPLEMENTATIONIn this chapter we are discusses about requirement of WSN simulation tools which used to simulate the algorithm and display in MATLAB graph, in addition to this according to my objective the integrations of centralized LEACH and advanced encryption standard algorithm as it is the selected data confidentiality and to improving data security of wireless sensor network. Figure 41 Diagrammatic representation of the communicationRequirement of WSN Simulation ToolsIn the study wireless sensor network simulators fall into three categories namely Monte Carlo, Discrete-Event and Trace-Driven simulations. The Discrete-Event and Trace-Driven, are commonly used in wireless sensor networks.

The widely used simulator in wireless sensor network is discrete-event as it is easy to simulate multi jobs that can run to various types of wireless sensor nodes. It includes a long list of pending events and global variables, which are simulated by many routines, such as initial, input, trace, and output routines. MATLAB is detailed simulation of the end nodes and their architecture, physical layer parameters, different modulation ; encoding techniques, communication channel modeling (SNR, effect of different Noise schemes, Interference, distance, etc…), various methods to monitor and record results, making use of the rich library of MATLAB/Simulink. Therefore we selected as the appropriate simulation tool for wireless sensor network in this thesis work. The environment in which we build our simulation model was MATLAB. The name MATLAB stands for matrix laboratory.

MATLAB, developed by Math Works Inc., is a software platform for high performance numerical computation and visualization. The grouping of analysis abilities, flexibility, reliability, and powerful graphics makes MATLAB the first software package for scientific researchers. MATLAB offers an interactive setting with hundreds of reliable and accurate built-in mathematical functions. These functions were provide solutions to a broad range of mathematical problems including matrix algebra, linear systems, optimization, differential equations, nonlinear systems, complex arithmetic, signal processing, and many other types of scientific calculations. The most vital feature of MATLAB was its programming capability, which allows user-developed functions and which was very easy to learn and too used.

Implementation of AES on LEACH-C routing protocolBS operation computes status of each node energy level with their location position and then choosing CH ID and broadcasting it to the network. All member nodes, after receiving this announcement, decide on the cluster to which they want to belong based on the signal strength of the advertisement. Then all member nodes inform (request message) the appropriate CHs that they will be a member of the cluster. After receiving all the messages from the nodes that would like to be included in the cluster and the CH node creates a TDMA schedule and allocates each node a time slot when it can transmit and then announcing to all the nodes in the cluster. The BS periodically changes both the cluster membership and the cluster-head (CH) to save energy of each sensor node. Centralized Clustering based protocols divide into two phases: setup phase and the steady state phase.

At the time of set-up phase of LEACH-C every node forwards information about its current position (possibly determined utilizing GPS) and residual energy level to the sink or BS. To finding good clusters, the sink requires to guarantee that the energy load is consistently dispersed among all the nodes. To do this, sink computes the average node energy, and calculates which nodes have energy lower than mean average. The entire sensor nodes request message is assigned to the CH which has shortest distance from all the CH 14.

Algorithm of CH selection in WSN Selected CH within the cluster initialization; while {No Change in Cluster Head Co-ordinates }do read current State of the Sensor Node; Apply Markov Model to analysis Sensor Node; if {Better Position is found} then (Update the Co-ordinates of Cluster head); else (Fix CH Position and Start Communication); end End Figure 42 Flowchart of LEACH-C with integrating AES LEACH-C procedure Steps: – Initialize the BS operation staring by receiving status of nodes from each node, Calculates the average node energy, and computes After analyzing the received information, the BS selects the optimum clusters Keeps up-to-date and chose CH ID then announce for all members of the network Each node I in the network compares their ID with the selected CH ID If Node I ID = CH ID, then the node received join request message from members, Else node I becomes non CH send join request message to selected CH Creating TDMA schedule table for member sensor nodes in the cluster then announce to them Each sensor node sense a data from surroundings, encrypted the data then send to CH selected node in the cluster and go to sleep mode to save energy Receiving data from member nodes and then reducing redundant data process and applies aggregation techniques using too much energy consumption, send aggregated data and dissemination to BS can reduce the duplicated data and save transmission time. BS received encrypted data then processing, decryption and storing The CH has responsible for reducing redundant data and applies aggregation techniques that dropping the data size and forwards it to the BS. The idea behind LEACH-C is to save energy of sensor nodes which was increased the lifetime of the network. Because the cluster head selection process was run at BS, which is expected to have infinite energy as compared to nodes energy. Thus any WSN process run at the BS does not generate energy overhead to the network nodes.

At the time of steady-state phase is a similar to the Steady-state phase of LEACH. In normal situations, member nodes can turn off their radio until them sense data from the area of near surrounding environment. If it needs to transmit, they will send data to CH during the idle slots recorded in the TDMA schedule table. The duty of CHs is to preserve up communication status at all times of receive data from different member of nodes.

Also, the data transmission distance becomes shorter comparing with transmitting to BS distinctly for each member node, which can save some energy for the member nodes. However, the heavy tasks executing timing of on the CH can lead too much energy consumption. In order to avoid making the CHs die early and cause the cascade effect in the network, a new round begins and new clusters will be rebuilt in the whole network the data sent by BS, CHs will aggregate them first and then send them to BS. Because some sensor nodes may sense similar environment data, it needs aggregation on the CH can reduce the duplicated data and save transmission time 4. Implementation of LEACH-C AlgorithmCentralized LEACH is a kind of improved of the normal LEACH and can generate better performance by issuing the cluster heads over the network. After finished the deployment of wireless sensor nodes to discovery good clusters, the sink requires guaranteeing that the energy load is regularly dispersed among all the nodes.

To do this, sink analyses the average node energy, and computes which nodes have energy lower than the mean average. Thus, the energy efficiency routing protocols are needed to improve the lifetime of the networks. The deployment of LEACH-C nodes is as shown below the network divided in clustering by using MATLAB simulation tool. The nodes were randomly distributed in the area of 400 x 400 m2.

The base station was located at the center point (200, 200) as multiplication sign and the cluster heads are represented as cross within circle sign. The other nodes are represented by circle sign in different color according to their energy level. Pseudo code of sensing, AES-encrypting in MATLAB s_box, inv_s_box, w, poly_mat, inv_poly_mat = aes_init; for r=0:1:rmax plaintext =randi(0 128,4,4) %Sense a data b/n 0 ; 128 ciphertext = cipher (plaintext, w, s_box, poly_mat, 1) %Sensed data encrypted process then transmit it if(mod(r, round(1/p) )==0) for i=1:1:n S(i).G=0; end endhold off; dead=0; packets_TO_BS=0; packets_TO_CH=0; PACKETS_TO_CH(r+1)=0; PACKETS_TO_BS(r+1)=0; Implementation of AES Encryption AlgorithmIt starts plain text with Add Round Key with RoundKey0. Therefor go to loop and do Sub Byte, Shift Row, Mix Column and Add Round Key in that order for 9 Rounds each round with different Round Key (1 to 9).

Then go to the final round (Round10) and replication the same earlier functions in the loop except Mix Column. After all encryption procedure finished then the output shows unreadable format it means ciphertext. 76489674575AddRoundKeyPlain Text MasterKeyAddRoundKeyAddRoundKeyMixColumnsShiftRowSubByteNr-1 Round SubByteShiftRowKeyExpansionFinal Round Cipher Text 00AddRoundKeyPlain Text MasterKeyAddRoundKeyAddRoundKeyMixColumnsShiftRowSubByteNr-1 Round SubByteShiftRowKeyExpansionFinal Round Cipher Text Figure 43 Data flow diagram of AES Encrypted//Pseudo code for cipher text Cipher (byte in 4*Nb, byte out4*Nb, word wNb*(Nr+1)) Begin Byte state4,Nb State=in AddRoundKey (state, w0, Nb-1) For round = 1 step 1 to Nr-1 SubBytes (state) ShiftRows(state) MixColumns(state) AddRoundKey (state), wround*Nb, (round+1)*Nb-1) End for SubBytes (state) ShiftRow (state) AddRoundKey (state, wNr*Nb, (Nr+1)*Nb-1) Out = state end Implementation of AES Decryption AlgorithmAES decryption is Cipher transformations to be inverted and then applied in reverse order to produce a direct Opposite Cipher for the AES algorithm. The individual transformations used in the Inverse Cipher – InvShiftRows(), InvSubBytes(), InvMixColumns(), and AddRoundKey(). //Pseudo code for Invcipher text InvCipher (byte in 4*Nb, byte out 4*Nb, word wNb*(Nr+1)) Begin Byte state 4,Nb State = in AddRoundKey (state, wNr*Nb, (Nr+1)*Nb-1) For round = Nr-1 step -1 down to 1 InvShiftRows (state) InvSubBytes (state) AddRoundKey (state, wround*Nb, (round+1)*Nb-1) InvMixColumns (state) End for InvShiftRows (state) InvSubBytes (state) AddRoundKey (state, w0, Nb-1) Out = state end-942981809800 CHAPTER – 5 SIMULATION RESULTS AND ANALYSISThis chapter discusses the centralized LEACH protocol operation and the effect of AES encrypted data under LEACH-C protocol. To evaluate the proposed improving data security using AES algorithm on LEACH-C protocol based on performance metrics such as, total packet sent, total dead nodes and total remaining energy is used and we provide a detailed analysis that obtained from the simulation results.

Simulation Environment and ParametersDemonstrated was a process in which you described a dynamic system with mathematical equations and then created a simplified representation of the system with a model. The general goal of this thesis was to improved data security function to wireless sensor network communication with centralized clustering protocol. MATLAB tool is the selected simulation environment with supporting libraries installed on Window 7 operating system. IEEE 802.11 MAC protocol was used in the experiments for the MAC layer in each node. IEEE 802.11 works in 2.4 GHz frequency. The initial energy available for each node was set to 0.5 Joules.

The type of antenna in all nodes was assumed to be Omni directional antenna. In our case specified by selecting the geographical location X span and Y span in given units 400m * 400m2 as our network size with 100 numbers of nodes randomly deployed in the network. The BS location was determine in the center of the network that means, xm,ym (200,200). Energy consumption of node one has taken as an example here in all the three scenarios as all the nodes were homogenous and hence had similar initial energy. The nodes were static randomly deployed and BS location in the center of the network. Table 51 Simulation parameters Symbol Parameters Value Xm,YmNetwork size 400x400m2 Connection type UDP, Wireless n Number of nodes 100 EoPrimary energy(Energy model=Battery) 0.5J Packet Packet size, k 500bit P Probability of a node to become a CH 0.1 X,Y Location of BS (200,200) EfsAmplifier Energy for short distance (d;do) 10pJ/bit/m2 EmpAmplifier Energy for long distance (d;do) 0.0013pJ/bit/m2 EecEnergy consumption coefficient of receiving node 50nJ/bit ETxTransmitter energy per node 50×10-9 ERxReceiver energy per node 50×10-9 EDA Data Aggregation Energy 5×10-9 Performance metricsPerformance metrics are used to analyze and experiment the network according to certain defined parameters.

There are three main performance metrics that are considered in this thesis there are number of Dead nodes, number of packets transmitted and remaining energy of the network. Different simulation scenarios with different number of round are conducted in the thesis work. All simulation parameters mentioned are presented below. In these three simulation scenarios, the thesis is going to show you the difference with respect to round.

Energy consumption of the wireless sensor network can be shown in total number of packet sent vs round, total number of dead nodes vs round and total number of remaining energy vs round. From the result my expectation is to have positive result from all three simulations. The selected cryptographic algorithm was used for encrypting the message at the sender side and decrypting it at the receiver side to keep the confidentiality of message exchange between sensor nodes. All the sensor nodes use a pre shared encryption decryption symmetric key which is loaded to each node before deployment. After checking the existence of the sensor node with enough energy level to communicate with neighboring sensor nodes, several types of performance metrics such as energy consumption, memory usage and strength of the encryption decryption algorithm as compared to other algorithms are computed. Simulation ResultsWhen running this improving data security program in MATLAB there are five different visualized figures.

Analysis of simulation results are discussed below: Figure one visualized “total clustering nodes deployment in WSN” from this figure it can analysis or interpreting the wireless network coverage area 400m2 by 400m2 labeled as x-axis and y-axis, number of sensor nodes are 100, a cluster formation, random deployed sensor nodes, at each cluster members there is one CH, there is different color sign node according to their energy level and the BS sign at location of 200m, 200m (xy coordination). Figure 51 Deployment of sensor nodes ; cluster formationFigure two visualized “total packet sent to CH” from this figure it visualized and shows that each sensor node according to their clustering sends an encrypted data to their CH. The sign shows a zigzag type, because of each sensor node deployed at different distance from CH. So that data packets transmit at near distance to CH it is fast, but at far distance it is slow.

The average mean data packet transmitting is 88.6 per round. In general up to 675 rounds the mean average of data packet transmit almost the same, but after rounds 675 when increasing number of round it becomes decreasing number of data transmitting. Because the performance of sensor node after so many rounds it become dead. CH at different round it selected by BS and has more responsibility and task, so it consumes more energy.

After collecting sensor data computing, aggregating to reducing redundancy and then transmit it to BS. Figure 52 Total number of packet sends to CHTotal number of packet sent vs RoundsThis figure shows the total number of packets send at different number of rounds. As shown in figure below it visualized each CH according to their clustering group send an encrypted data to BS. The sign shows a zigzag type, because of each CH deployed at different distance to BS.

So that data packets transmit at near distance to BS it is fast, but at far distance it is slow. The average mean data packet transmitting is 9.85 per round. The BS is as an admin it controls the network activities and received encrypted data then decryption process. After decryption the data it use to another analysis purpose or storing the data. At the next round BS operation computes status of each node energy level with their location position and then choosing CH ID and broadcasting it to the network. All the non-CH nodes, after receiving this announcement, decide on the cluster to which they want to belong based on the signal strength of the advertisement.

The BS periodically changes both the cluster membership and the cluster-head (CH) to save energy. Figure 53 Total numbers of packet send to BSNumber of dead nodes vs RoundsSensor node has initial energy and the sum of energy consumption of all the nodes in the network cause of to become dead a node. Energy consumption of each node is the difference between the energy of the node at the start of the communication and the energy of the node at the end of the communication. The total number of dead nodes vs rounds as shown below change to become after 675 rounds.

So the number of dead nodes is increasing slowly as round increasing. This means the dead nodes to be count as out of the operation of the wireless network and cannot perform the objectives without energy of sensor nodes. Let us see the following table Table 52 Data of dead nodes ; Remaining energy of WSN No. Number of Rounds Number of dead nodes Number of remain nodes Remaining energy in % 0-675 0 100 100% 822 3 97 97% 866 5 95 95% 966 7 93 93% As shown from the above table at round 822 it becomes dead node increasing by 3%, at round 866 increasing 5% and at round 966 its energy consumption 7%. This means the performance of wireless energy decreasing the life time of the network at round 966 it becomes 93%.

The dissipated energy: Energy consumption happens in packet transmission, packet reception, and processing by each node during network operation. Energy consumption in each node (i) is calculated by using the following equation: ECi = ETi+EPi+ ERi Equation 5.1 Where EC is the total consumed energy, ET is the consumed energy during transmission, EP is the consumed energy during processing and ER is the consumed energy during reception Figure 54 Total numbers of dead nodesTotal Remaining of Energy vs RoundsThe total number of remaining energy varying at different number of rounds as shown below change to become after 675 rounds. So the number of remaining energy is decreasing slowly as round increasing. This means the remaining energy to be count as active for operation of the wireless network and ready for another responsibilities or activities.

As shown from the above table at round 822 from the initial energy reducing by 3% it becomes 97%, at round 866 reducing 5% and at 966 reducing 7%. In general the wireless network is computing the operation for 966 rounds it remain energy of the network 93%. In the wireless network if using centralized clustering routing protocol it can be save energy of the node. This means the performance of wireless energy increasing the life period of the network, because there is a rotation clustering in each round the probability of a node to become CH and selected (computed) by BS.

This is an advantage to choose a centralized LEACH protocol. Figure 55 Total Remaining energyAdvanced encryption standard performance, memory usage and strengthThe AES standard is the most efficient algorithm through all platform processors starting from small 8-bit embedded to 64-bit CPUs. Performance of any encryption algorithm depends on its assembly level execution. Therefore, AES implementation is efficient with hardware implementation and for more optimized implementations. Let us take mica2/Z sensor node as an example as they are the most widely used application of sensor nodes in WSNs. It has 4kb RAM for data memory and 128 kb program flash memory each.

The source of power is double AA battery type with energy level greater than 5000 joule each. The encryption decryption algorithm implemented has a file size of 15.6 kb including the constants and the variables which is fair to be applied in this sensor node. Therefore the implementation is valid memory wise as the total memory size of the sensor node is greater than 100 kb. AES encryption with a 128-bit key has been verified to be secure enough to protect any classified information up to US Government’s secret level 20. Chapter summaryThis thesis is a titled “improving data security in WSN using centralized LEACH protocol by integrating AES”.

In this thesis we achieved all listed in specific objectives. Compare to our base paper titled “A research paper on security enhancement in LEACH protocol” and his methodology was implementation of DES encryption with LEACH protocol. There for the improving data security is using AES algorithm is more efficient than DES and using centralized LEACH is enhanced of this protocol with lifetime of the network is increasing. For evidence the network operation activities limited for only 500 rounds.

After this round couldn’t operate their application functionality because their energy level faster reduced. But our simulation result at round 822 from the initial energy reducing by 3% it becomes remaining energy 97%, at round 866 reducing 5% and at 966 reducing 7%. In general the wireless network is computing the operation for 966 rounds it remain energy of the network 93%. In the wireless network if using centralized clustering routing protocol it can be save energy of the node.

This means the performance of wireless energy increasing the life period of the network, because there is a rotation clustering in each round the probability of a node to become CH and selected (computed) by BS. This is an advantage to choose a centralized LEACH protocol. In addition to this when a program is running automatically sensor node sense data from surrounding and encrypted a data using AES algorithm to ensure the confidentiality until the recipient destination of BS. Therefor at BS the received encrypted information and decryption process using AES algorithm then the information storing or ready for another analysis processing.

This thesis program to completed the overall process consume time is less than 7 minutes to finished 1000 rounds and display the output five figures. CHAPTER – 6 CONCLUSION AND RECOMMENDATIONSummaryInformation is an asset. Precise and up to date information can provide from WSNs according to their purpose or target at a specified location within a limited period of time. Typically, a sensor node has constraint in terms of computation capability and energy resources. A WSN contains of spatially dispersed autonomous sensors to supportively monitor physical or environmental conditions, such as temperature, sound, vibration, pressure, motion etc.

WSNs have faced several security threats while sending, receiving and processing data, it will be essential securing with reduced energy consumption. In our thesis work we distinguished two main concern problems constraint of energy and security. We try to improve the data security by using cryptographic protection AES algorithm to ensure data confidentiality of the network and to minimize the consumption of energy we chosen centralized low energy adaptive clustering hierarchy (LEACH-C) protocol. By integrating this methodology it can improve data security and can extending the life time of the network.

ConclusionWireless sensor nodes are small electronics, which can be used to sense, process and transmits data or information from an environmental object. WSN is being a hot area of research nowadays because of its wide range application in military, environmental, structural monitoring, agricultural sector, home intelligence, industrial monitoring and other areas. In this thesis research we differentiated two main constraints of WSN, such as energy constraint and security problems occurs in the communication of WSN. To improve the data security and energy consumption problem are we follow two methodologies. Centralized clustering formation technique is used to minimize the node crowded processing burden and avoid multiple communications.

Among various kinds of network routing protocols centralized LEACH has more rounds of transmission to BS, make centralized cluster algorithm for selection of CH and uses less energy. The security mechanism should ensure that no message data in the network is understood by anyone except proposed receiver. Data confidentiality is one of the vital security requirements for WSN because of its application purpose activities (for example, military and key distribution applications). One standard security method of providing data confidentiality is to encrypt data and use of pre shared key until to intend receivers can get the sensitive data like secrete communication code in military. The AES standard is the most efficient algorithm through all platform processors starting from small 8-bit embedded to 64-bit CPUs. Performance of any encryption algorithm depends on its assembly level execution. Generally, the thesis work meets all its specific objectives by integrating LEACH-C and AES algorithm improving data security; enhance life time among communication of WSN. The simulation result at round 822 from the initial energy reducing by 3% it becomes remaining energy 97%, at round 866 reducing 5% and at 966 reducing 7%. In general the wireless network is computing the operation for 966 rounds it remain energy of the network 93%. In the wireless network if using centralized clustering routing protocol it can be save energy of the node. This means the performance of wireless energy increasing the life period of the network, because there is a rotation clustering in each round the probability of a node to become CH and selected (computed) by BS. This is an advantage to choose a centralized LEACH protocol. Future workImproving the energy consumption and security problem of sensor nodes to prolong life time of WSN is the core issue of many researchers. As a future works of this thesis work, it is recommended to ensure confidentiality of a data using AES algorithm under LEACH-C was already we operated. For more security hardware implementation of AES in wireless sensor nodes is faster than software implementation, it can be adding integrity and can be choosing more advanced routing protocol to improving energy consumption. REFERENCESADVANCED ENCRYPTION STANDARD (AES) (2001): Federal Information Processing Standards Publication 197 Amandeep Kaur (2015). LEACH and Extended LEACH Protocols in Wireless Sensor Network-A Survey. International Journal of Computer Applications (0975 – 8887) Volume 116 – No. 10, SBS State Technical Campus Moga Road, Ferozepur-152004 Cristina Panait and Dan Dragomir (2015) Measuring the performance and energy consumption of AES in wireless sensor networks Proceedings of the Federated Conference on Computer Science and Information Systems 978-83-60810-66-8/$25.00 © 2015, IEEE Deepika ; Manpreet (2017) A Research Paper on Security Enhancement In Leach Protocol. International Journal of Engineering Development and Research (www.ijedr.org) © 2016 IJEDR | Volume 4, Issue 3 | ISSN: 2321-9939 IJEDR Computer Science, Global Research Institute of Management in Technology, Radaur, India Garima, Sandeep ; Kumar (2017). A Review on Security Concepts for Secure Multihop Routing Protocol. International Journal of Emerging Technology and Advanced Engineering Website: www.ijetae.com (ISSN 2250-2459, ISO 9001:2008 Certified Journal, Volume 7, Issue 7) Heena Dhawan and Sandeep Waraich (2014). A Comparative Study on LEACH Routing Protocol and its Variants in Wireless Sensor Networks: A Survey International Journal of Computer Applications (0975 – 8887) Volume 95– No.8, June 2014 Department of Computer Science and Engineering Guru Nanak Dev University Amritsar, Punjab Jinat Rehana :Security of Wireless Sensor Network Helsinki University of Technology [email protected] TKK T-110.5190 Seminar on Internetworking M. Jothimeena ; R. Sherin Jenny (2017). Implementation of Secured Sensor Nodes Using Cryptographic Algorithms. ISSN: 2454-132X Impact factor: 4.295 (Volume3, Issue3) Available online at www.ijariit.com ©, www.IJARIIT.com All Rights Reserved Madhumita Panda (2015) Data Security in Wireless Sensor Networks via AES Algorithm SUIIT ,Sambalpur University Odisha,India. [email protected] 978-1-4799-6480-2/15 $31.00 © 2015 IEEE Manisha Choudhury (2013): A Centralized Clustering approach for Wireless Sensor Networks Department of Computer Science and Engineering National Institute of Technology Rourkela Rourkela-769008,Orissa,India MESERET TEKIE (2016): Network Lifetime optimization of wireless sensor network by dynamically regulating transmission power. Department: Computer and Information Technology Specialization: Computer Engineering Nakul Sorout ; Mahesh Singh (2016). Obtaining Security and Energy Efficiency for Leach-Clustering Protocol in Wireless Sensor Network. International Journal of Science, Engineering and Technology Research (IJSETR) ISSN: 2278 – 7798 Volume 5, Issue 6 Nisha Pachori ; Vivek Suryawanshi (2015) Cluster Head Selection Prediction in Wireless Sensor Networks: ISSN:0975-9646 VNS Institute of Technology Bhopal, India PAVAN R1, VASUDEVA PAI2 ; PRANESH V. KALLAPUR3 (JUNE 2015). Performance Evaluation of LEACH and Its Variants: IJCEIT Available online at: www.ijceit.org E-ISSN 2412-8856 (Online) M-Tech, Computer Network Enginnering, NMAMIT, Nitte Prashant Krishan (2013) “A Study on Dynamic and Static Clustering Based Routing Schemes for Wireless Sensor Networks” International Journal of Modern Engineering Research (IJMER) www.ijmer.com Vol.3, Issue.2, March-April. 2013 pp-1100-1104 ISSN: 2249-6645 Department of IT, Uttarakhand Technical University, Dehradun, INDIA S. Ananda Kumar, P. Ilango, Grover Harsh ;Dinesh (2016). A Modified LEACH Protocol for Increasing Lifetime of the Wireless Sensor Network. Bulgarian Academy of Sciences Cybernetics and Information Technologies Volume 16, No 3 Sofia Print ISSN: 1311-9702; Online ISSN: 1314-4081 School of Computer Science and Engineering, VIT University, Vellore, India S.Biedron ; T.Panskyi (2015). Analysis of a new model of low energy adaptive clustering hierarchy protocol in the wireless sensor network. V. Mosorov Doctor of Technical Science* E-mail:[email protected] E-mail: [email protected] *Institute of Applied Computer Science Lodz University of Technology Stefanowskiego str., 18/22, Lodz, Poland, 90-924 V. MosorovSaiqua Anam1,; Mr. Om Prakash Yadav (2017 ). Performance enhancement of leach protocol in wireless sensor network in terms of network life time. India International Journal For Technological Research In Engineering Volume 4, Issue 7 ISSN (Online): 2347 – 4718 www.ijtre.com Shailendra Singh Gaur, Dr. A.K. Mohapatra ; Rashmi Roges (2017). An Efficient Certificate less Authentication Encryption for WSN Based on Clustering Algorithm International Journal of Applied Engineering Research ISSN 0973-4562 Volume 12, Number 14 pp. 4184-4190 © Research India Publications. http://www.ripublication.comTesfay Gebreslassie (2017) Security enhanced fuzzy logic based clustering algorithm for WSN: Department of computer and information technology defense university college of engineering Bishoftu, Ethiopia Warda, Hadj ; Fateh (2015). Enhancing MR-LEACH Protocol using Ant Colony Algorithm. Mohammed Omari LDDI Laboratory, Mathematics and Computer Science Department, University of Adrar Adrar, Algeria [email protected] [email protected] 978-1-4673-6636-6/15/$31.00 © IEEE APPENDICESAPPENDIX A: Encryption and Decryption Blocks Of AES // AES Encryption Algorithm block mex AES_Encrypt.cpp #include;stdio.h; #define Nb 4 // The number of rounds in AES Cipher. It is simply initiated to zero. The actual value is recieved in the program. int Nr=0; // The number of 32 bit words in the key. It is simply initiated to zero. The actual value is recieved in the program. int Nk=0; // in – it is the array that holds the plain text to be encrypted. // out – it is the array that holds the key for encryption. // state – the array that holds the intermediate results during encryption. unsigned char in16, out16, state44; // The array that stores the round keys. unsigned char RoundKey240; // The Key input to the AES Program unsigned char Key32; int getSBoxValue(int num) {int sbox256 = { //0 1 2 3 4 5 6 7 8 9 A B C D E F 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, //0 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, //1 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, //2 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, //3 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, //4 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, //5 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, //6 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, //7 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, //8 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, //9 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, //A 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, //B 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, //C 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, //D 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, //E 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; //F return sboxnum;} // The round constant word array, Rconi, contains the values given by // x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(28) // Note that i starts at 1, not 0). int Rcon255 = { 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb }; // This function produces Nb(Nr+1) round keys. The round keys are used in each round to encrypt the states. void KeyExpansion() {int i,j; unsigned char temp4,k; // The first round key is the key itself. for(i=0;i;Nk;i++) {RoundKeyi*4=Keyi*4; RoundKeyi*4+1=Keyi*4+1; RoundKeyi*4+2=Keyi*4+2; RoundKeyi*4+3=Keyi*4+3;} // All other round keys are found from the previous round keys. while (i ; (Nb * (Nr+1))) {for(j=0;j;4;j++) {tempj=RoundKey(i-1) * 4 + j;} if (i % Nk == 0){ // This function rotates the 4 bytes in a word to the left once. // a0,a1,a2,a3 becomes a1,a2,a3,a0 // Function RotWord(){k = temp0; temp0 = temp1; temp1 = temp2; temp2 = temp3; temp3 = k;} // SubWord() is a function that takes a four-byte input word and // applies the S-box to each of the four bytes to produce an output word. // Function Subword(){temp0=getSBoxValue(temp0); temp1=getSBoxValue(temp1); temp2=getSBoxValue(temp2); temp3=getSBoxValue(temp3);} temp0 = temp0 ^ Rconi/Nk; } else if (Nk ; 6 ;; i % Nk == 4) {// Function Subword(){ temp0=getSBoxValue(temp0); temp1=getSBoxValue(temp1); temp2=getSBoxValue(temp2); temp3=getSBoxValue(temp3);}} RoundKeyi*4+0 = RoundKey(i-Nk)*4+0 ^ temp0; RoundKeyi*4+1 = RoundKey(i-Nk)*4+1 ^ temp1; RoundKeyi*4+2 = RoundKey(i-Nk)*4+2 ^ temp2; RoundKeyi*4+3 = RoundKey(i-Nk)*4+3 ^ temp3; i++;}} // This function adds the round key to state. // The round key is added to the state by an XOR function. void AddRoundKey(int round) {int i,j; for(i=0;i;4;i++) { for(j=0;j;4;j++){ stateji ^= RoundKeyround * Nb * 4 + i * Nb + j; }}} // The SubBytes Function Substitutes the values in the // state matrix with values in an S-box. void SubBytes() { int i,j; for(i=0;i;4;i++) { for(j=0;j;4;j++) { stateij = getSBoxValue(stateij);}}} // The ShiftRows() function shifts the rows in the state to the left. // Each row is shifted with different offset. // Offset = Row number. So the first row is not shifted. void ShiftRows() { unsigned char temp; // Rotate first row 1 columns to left temp=state10; state10=state11; state11=state12; state12=state13; state13=temp; // Rotate second row 2 columns to left temp=state20; state20=state22; state22=temp; temp=state21; state21=state23; state23=temp; // Rotate third row 3 columns to left temp=state30; state30=state33; state33=state32; state32=state31; state31=temp;} // xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b} #define xtime(x) ((x;;1) ^ (((x;;7) ; 1) * 0x1b)) // MixColumns function mixes the columns of the state matrix void MixColumns() { int i; unsigned char Tmp,Tm,t; for(i=0;i;4;i++) {t=state0i; Tmp = state0i ^ state1i ^ state2i ^ state3i ; Tm = state0i ^ state1i ; Tm = xtime(Tm); state0i ^= Tm ^ Tmp ; Tm = state1i ^ state2i ; Tm = xtime(Tm); state1i ^= Tm ^ Tmp ; Tm = state2i ^ state3i ; Tm = xtime(Tm); state2i ^= Tm ^ Tmp ; Tm = state3i ^ t ; Tm = xtime(Tm); state3i ^= Tm ^ Tmp ;}} // Cipher is the main function that encrypts the PlainText. void Cipher() { int i,j,round=0; //Copy the input PlainText to state array. for(i=0;i;4;i++) {for(j=0;j;4;j++) { stateji = ini*4 + j;}} // Add the First round key to the state before starting the rounds. AddRoundKey(0); // There will be Nr rounds. // The first Nr-1 rounds are identical. // These Nr-1 rounds are executed in the loop below. for(round=1;round;Nr;round++) { SubBytes(); ShiftRows(); MixColumns(); AddRoundKey(round);} // The last round is given below. // The MixColumns function is not here in the last round. SubBytes(); ShiftRows(); AddRoundKey(Nr); // The encryption process is over. // Copy the state array to output array. for(i=0;i;4;i++) { for(j=0;j;4;j++){ outi*4+j=stateji;}}} void main() {int i; // Recieve the length of key here. while(Nr!=128 ;; Nr!=192 ;; Nr!=256) {printf(“Enter the length of Key(128, 192 or 256 only): “); scanf(“%d”,;Nr);} // Calculate Nk and Nr from the recieved value. Nk = Nr / 32; Nr = Nk + 6; // Part 1 is for demonstrative purpose. The key and plaintext are given in the program itself. // Part 1: ******************************************************** // The array temp stores the key. // The array temp2 stores the plaintext. unsigned char temp16 = {0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 ,0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f}; unsigned char temp216= {0x00 ,0x11 ,0x22 ,0x33 ,0x44 ,0x55 ,0x66 ,0x77 ,0x88 ,0x99 ,0xaa ,0xbb ,0xcc ,0xdd ,0xee ,0xff}; // Copy the Key and PlainTextfor(i=0;i;Nk*4;i++) {Keyi=tempi; ini=temp2i;} flushall(); printf(“Enter the Key in hexadecimal: “); for(i=0;i;Nk*4;i++) {scanf(“%x”,;Keyi);} printf(“Enter the PlainText in hexadecimal: “); for(i=0;i;Nb*4;i++) {scanf(“%x”,;ini);} KeyExpansion(); Cipher(); printf(” Text after encryption: “); for(i=0;i;Nk*4;i++) {printf(“%02x “,outi);} printf(” “);} // AES Decryption Algorithm block #include;stdio.h; // The number of columns comprising a state in AES. This is a constant in AES. Value=4 #define Nb 4 // The number of rounds in AES Cipher. It is simply initiated to zero. The actual value is recieved in the program. int Nr=0; // The number of 32 bit words in the key. It is simply initiated to zero. The actual value is recieved in the program. int Nk=0; // in – it is the array that holds the CipherText to be decrypted. // out – it is the array that holds the output of the for decryption. // state – the array that holds the intermediate results during decryption. unsigned char in16, out16, state44; // The array that stores the round keys. unsigned char RoundKey240; // The Key input to the AES Program unsigned char Key32; int getSBoxInvert(int num) { int rsbox256 = { 0x52, 0x09, 0x6a, 0xd5, 0x30, 0x36, 0xa5, 0x38, 0xbf, 0x40, 0xa3, 0x9e, 0x81, 0xf3, 0xd7, 0xfb , 0x7c, 0xe3, 0x39, 0x82, 0x9b, 0x2f, 0xff, 0x87, 0x34, 0x8e, 0x43, 0x44, 0xc4, 0xde, 0xe9, 0xcb , 0x54, 0x7b, 0x94, 0x32, 0xa6, 0xc2, 0x23, 0x3d, 0xee, 0x4c, 0x95, 0x0b, 0x42, 0xfa, 0xc3, 0x4e , 0x08, 0x2e, 0xa1, 0x66, 0x28, 0xd9, 0x24, 0xb2, 0x76, 0x5b, 0xa2, 0x49, 0x6d, 0x8b, 0xd1, 0x25 , 0x72, 0xf8, 0xf6, 0x64, 0x86, 0x68, 0x98, 0x16, 0xd4, 0xa4, 0x5c, 0xcc, 0x5d, 0x65, 0xb6, 0x92 , 0x6c, 0x70, 0x48, 0x50, 0xfd, 0xed, 0xb9, 0xda, 0x5e, 0x15, 0x46, 0x57, 0xa7, 0x8d, 0x9d, 0x84 , 0x90, 0xd8, 0xab, 0x00, 0x8c, 0xbc, 0xd3, 0x0a, 0xf7, 0xe4, 0x58, 0x05, 0xb8, 0xb3, 0x45, 0x06 , 0xd0, 0x2c, 0x1e, 0x8f, 0xca, 0x3f, 0x0f, 0x02, 0xc1, 0xaf, 0xbd, 0x03, 0x01, 0x13, 0x8a, 0x6b , 0x3a, 0x91, 0x11, 0x41, 0x4f, 0x67, 0xdc, 0xea, 0x97, 0xf2, 0xcf, 0xce, 0xf0, 0xb4, 0xe6, 0x73 , 0x96, 0xac, 0x74, 0x22, 0xe7, 0xad, 0x35, 0x85, 0xe2, 0xf9, 0x37, 0xe8, 0x1c, 0x75, 0xdf, 0x6e , 0x47, 0xf1, 0x1a, 0x71, 0x1d, 0x29, 0xc5, 0x89, 0x6f, 0xb7, 0x62, 0x0e, 0xaa, 0x18, 0xbe, 0x1b , 0xfc, 0x56, 0x3e, 0x4b, 0xc6, 0xd2, 0x79, 0x20, 0x9a, 0xdb, 0xc0, 0xfe, 0x78, 0xcd, 0x5a, 0xf4 , 0x1f, 0xdd, 0xa8, 0x33, 0x88, 0x07, 0xc7, 0x31, 0xb1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xec, 0x5f , 0x60, 0x51, 0x7f, 0xa9, 0x19, 0xb5, 0x4a, 0x0d, 0x2d, 0xe5, 0x7a, 0x9f, 0x93, 0xc9, 0x9c, 0xef , 0xa0, 0xe0, 0x3b, 0x4d, 0xae, 0x2a, 0xf5, 0xb0, 0xc8, 0xeb, 0xbb, 0x3c, 0x83, 0x53, 0x99, 0x61 , 0x17, 0x2b, 0x04, 0x7e, 0xba, 0x77, 0xd6, 0x26, 0xe1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0c, 0x7d }; return rsboxnum; } int getSBoxValue(int num) { int sbox256 = { //0 1 2 3 4 5 6 7 8 9 A B C D E F 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 }; return sboxnum; } // The round constant word array, Rconi, contains the values given by // x to th e power (i-1) being powers of x (x is denoted as {02}) in the field GF(2^8) // Note that i starts at 1, not 0). int Rcon255 = { 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb, 0x8d, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36, 0x6c, 0xd8, 0xab, 0x4d, 0x9a, 0x2f, 0x5e, 0xbc, 0x63, 0xc6, 0x97, 0x35, 0x6a, 0xd4, 0xb3, 0x7d, 0xfa, 0xef, 0xc5, 0x91, 0x39, 0x72, 0xe4, 0xd3, 0xbd, 0x61, 0xc2, 0x9f, 0x25, 0x4a, 0x94, 0x33, 0x66, 0xcc, 0x83, 0x1d, 0x3a, 0x74, 0xe8, 0xcb }; // This function produces Nb(Nr+1) round keys. The round keys are used in each round to decrypt the states. void KeyExpansion() { int i,j; unsigned char temp4,k; // The first round key is the key itself. for(i=0;i;Nk;i++) { RoundKeyi*4=Keyi*4; RoundKeyi*4+1=Keyi*4+1; RoundKeyi*4+2=Keyi*4+2; RoundKeyi*4+3=Keyi*4+3; } // All other round keys are found from the previous round keys. while (i ; (Nb * (Nr+1))) { for(j=0;j;4;j++) { tempj=RoundKey(i-1) * 4 + j; } if (i % Nk == 0) { // This function rotates the 4 bytes in a word to the left once. // a0,a1,a2,a3 becomes a1,a2,a3,a0 // Function RotWord() { k = temp0; temp0 = temp1; temp1 = temp2; temp2 = temp3; temp3 = k; } // SubWord() is a function that takes a four-byte input word and // applies the S-box to each of the four bytes to produce an output word. // Function Subword() { temp0=getSBoxValue(temp0); temp1=getSBoxValue(temp1); temp2=getSBoxValue(temp2); temp3=getSBoxValue(temp3); } temp0 = temp0 ^ Rconi/Nk; } else if (Nk ; 6 ;; i % Nk == 4) { // Function Subword() { temp0=getSBoxValue(temp0); temp1=getSBoxValue(temp1); temp2=getSBoxValue(temp2); temp3=getSBoxValue(temp3); } } RoundKeyi*4+0 = RoundKey(i-Nk)*4+0 ^ temp0; RoundKeyi*4+1 = RoundKey(i-Nk)*4+1 ^ temp1; RoundKeyi*4+2 = RoundKey(i-Nk)*4+2 ^ temp2; RoundKeyi*4+3 = RoundKey(i-Nk)*4+3 ^ temp3; i++; } } // This function adds the round key to state. // The round key is added to the state by an XOR function. void AddRoundKey(int round) { int i,j; for(i=0;i;4;i++) { for(j=0;j;4;j++) { stateji ^= RoundKeyround * Nb * 4 + i * Nb + j; }}} // The SubBytes Function Substitutes the values in the // state matrix with values in an S-box. void InvSubBytes() { int i,j; for(i=0;i;4;i++) { for(j=0;j;4;j++) { stateij = getSBoxInvert(stateij); }}} // The ShiftRows() function shifts the rows in the state to the left. // Each row is shifted with different offset. // Offset = Row number. So the first row is not shifted. void InvShiftRows() { unsigned char temp; // Rotate first row 1 columns to right temp=state13; state13=state12; state12=state11; state11=state10; state10=temp; // Rotate second row 2 columns to right temp=state20; state20=state22; state22=temp; temp=state21; state21=state23; state23=temp; // Rotate third row 3 columns to right temp=state30; state30=state31; state31=state32; state32=state33; state33=temp; } // xtime is a macro that finds the product of {02} and the argument to xtime modulo {1b} #define xtime(x) ((x;;1) ^ (((x;;7) ; 1) * 0x1b)) // Multiplty is a macro used to multiply numbers in the field GF(2^8) #define Multiply(x,y) (((y ; 1) * x) ^ ((y;;1 ; 1) * xtime(x)) ^ ((y;;2 ; 1) * xtime(xtime(x))) ^ ((y;;3 ; 1) * xtime(xtime(xtime(x)))) ^ ((y;;4 ; 1) * xtime(xtime(xtime(xtime(x)))))) // MixColumns function mixes the columns of the state matrix. // The method used to multiply may be difficult to understand for the inexperienced. // Please use the references to gain more information. void InvMixColumns() { int i; unsigned char a,b,c,d; for(i=0;i;4;i++) { a = state0i; b = state1i; c = state2i; d = state3i; state0i = Multiply(a, 0x0e) ^ Multiply(b, 0x0b) ^ Multiply(c, 0x0d) ^ Multiply(d, 0x09); state1i = Multiply(a, 0x09) ^ Multiply(b, 0x0e) ^ Multiply(c, 0x0b) ^ Multiply(d, 0x0d); state2i = Multiply(a, 0x0d) ^ Multiply(b, 0x09) ^ Multiply(c, 0x0e) ^ Multiply(d, 0x0b); state3i = Multiply(a, 0x0b) ^ Multiply(b, 0x0d) ^ Multiply(c, 0x09) ^ Multiply(d, 0x0e); } } // InvCipher is the main function that decrypts the CipherText. void InvCipher() { int i,j,round=0; //Copy the input CipherText to state array. for(i=0;i;4;i++) { for(j=0;j;4;j++) { stateji = ini*4 + j; } } // Add the First round key to the state before starting the rounds. AddRoundKey(Nr); // There will be Nr rounds. // The first Nr-1 rounds are identical. // These Nr-1 rounds are executed in the loop below. for(round=Nr-1;round;0;round–) { InvShiftRows(); InvSubBytes(); AddRoundKey(round); InvMixColumns(); } // The last round is given below. // The MixColumns function is not here in the last round. InvShiftRows(); InvSubBytes(); AddRoundKey(0); // The decryption process is over. // Copy the state array to output array. for(i=0;i;4;i++) { for(j=0;j;4;j++) { outi*4+j=stateji;}}} void main() { int i; // Recieve the length of key here. while(Nr!=128 ;; Nr!=192 ;; Nr!=256) { printf(“Enter the length of Key(128, 192 or 256 only): “); scanf(“%d”,;Nr); } // Calculate Nk and Nr from the recieved value. Nk = Nr / 32; Nr = Nk + 6; unsigned char temp32 = {0x00 ,0x01 ,0x02 ,0x03 ,0x04 ,0x05 ,0x06 ,0x07 ,0x08 ,0x09 ,0x0a ,0x0b ,0x0c ,0x0d ,0x0e ,0x0f}; unsigned char temp216= {0x69 ,0xc4 ,0xe0 ,0xd8 ,0x6a ,0x7b ,0x04 ,0x30 ,0xd8 ,0xcd ,0xb7 ,0x80 ,0x70 ,0xb4 ,0xc5 ,0x5a}; // Copy the Key and CipherText for(i=0;i;Nk*4;i++) { Keyi=tempi; ini=temp2i; } KeyExpansion(); InvCipher(); printf(” Text after decryption: “); for(i=0;i;Nb*4;i++) { printf(“%02x “,outi); } printf(” “); } APPENDIX B: Centralized LEACH Algorithm xm=400; ym=400; sink.x=200; sink.y=200; n = 200; p=0.1; Eo=0.5; ch=n/10; ETX=50*0.000000001; ERX=50*0.000000001; Efs=10*0.000000000001; Emp=0.0013*0.000000000001; Efs1=Efs/10; Emp1=Emp/10; EDA=5*0.000000001; a=Eo/2; rmax=1000; packet=500; h=100; s=2; sv=0; s_box, inv_s_box, w, poly_mat, inv_poly_mat = aes_init; do=sqrt(Efs/Emp); do1=sqrt(Efs1/Emp1); figure(1); hold on; for i=1:1:n S(i).xd=rand(1,1)*xm; XR(i)=S(i).xd; S(i).yd=rand(1,1)*ym; YR(i)=S(i).yd; S(i).G=0; S(i).E=Eo S(i).ENERGY=0; plot(S(i).xd,S(i).yd,’o’); hold on; endS(n+1).xd=sink.x; S(n+1).yd=sink.y; countCHs=0; cluster=1; flag_first_dead=0; flag_teenth_dead=0; flag_all_dead=0; dead=0; first_dead=0; teenth_dead=0; all_dead=0; allive=n; packets_TO_BS=0; packets_TO_CH=0; figure(1); for r=0:1:rmax plaintext =randi(0 128,4,4) %Sense a data b/n 0 ; 128 ciphertext = cipher (plaintext, w, s_box, poly_mat, 1) %Sensed data encrypted process then transmit it if(mod(r, round(1/p) )==0) for i=1:1:n S(i).G=0; %%S(i).cl=0; end endhold off; dead=0; packets_TO_BS=0; packets_TO_CH=0; PACKETS_TO_CH(r+1)=0; PACKETS_TO_BS(r+1)=0; figure(1); for i=1:1:n if (S(i).E;=0) dead=dead+1; if (dead==1) if(flag_first_dead==0) first_dead=r; flag_first_dead=1; end end if(dead==0.1*n) if(flag_teenth_dead==0) teenth_dead=r; flag_teenth_dead=1; end end if(dead==n) if(flag_all_dead==0) all_dead=r; flag_all_dead=1; end end end if S(i).E;0 S(i).type=’N’; if (S(i).ENERGY==0) plot(S(i).xd,S(i).yd,’o’); end if (S(i).ENERGY==1) plot(S(i).xd,S(i).yd,’+’); end hold on; endendplot(S(n+1).xd,S(n+1).yd,’x’); STATISTICS.DEAD(r+1)=dead; STATISTICS.ALLIVE(r+1)=allive-dead; countCHs=0; cluster=1; if S(i).type==’C’ ;; S(i).E;a for j=1:1:ch countCHs=countCHs+1; S(i).type=’C’; S(i).G=round(1/p)-1; C(cluster).xd=S(i).xd; C(cluster).yd=S(i).yd; distance=sqrt( (S(i).xd-(S(n+1).xd) )^2 + (S(i).yd-(S(n+1).yd) )^2 ); C(cluster).distance=distance; C(cluster).id=i; X(cluster)=S(i).xd; Y(cluster)=S(i).yd; cluster=cluster+1; distance; if (distance;do) S(i).E=S(i).E- ( (ETX+EDA)*(1000) + Emp*1000*(distance*distance*distance*distance )); end if (distance;=do) S(i).E=S(i).E- ( (ETX+EDA)*(1000) + Efs*1000*(distance * distance )); end %end packets_TO_BS=packets_TO_BS+1; PACKETS_TO_BS(r+1)=packets_TO_BS; packets_TO_CH=packets_TO_CH+1; endelsefor i=1:1:n if(S(i).E;0) temp_rand=rand; if ( (S(i).G);=0) if(temp_rand;= (p/(1-p*mod(r,round(1/p))))) countCHs=countCHs+1; packets_TO_BS=packets_TO_BS+1; PACKETS_TO_BS(r+1)=packets_TO_BS; S(i).type=’C’; S(i).G=round(1/p)-1; C(cluster).xd=S(i).xd; C(cluster).yd=S(i).yd; plot(S(i).xd,S(i).yd,’k*’); distance=sqrt( (S(i).xd-(S(n+1).xd) )^2 + (S(i).yd-(S(n+1).yd) )^2 ); C(cluster).distance=distance; C(cluster).id=i; X(cluster)=S(i).xd; Y(cluster)=S(i).yd; cluster=cluster+1; distance; if (distance;do) S(i).E=S(i).E- ( (ETX+EDA)*(1000) + Emp*1000*(distance*distance*distance*distance )); end if (distance;=do) S(i).E=S(i).E- ( (ETX+EDA)*(1000) + Efs*1000*(distance * distance )); end end end endendendSTATISTICS.COUNTCHS(r+1)=countCHs; for i=1:1:n if ( S(i).type==’N’ ;; S(i).E;0 ) if(cluster-1;=1) min_dis=Inf; min_dis_cluster=0; for c=1:1:cluster-1 temp=min(min_dis,sqrt( (S(i).xd-C(c).xd)^2 + (S(i).yd-C(c).yd)^2 ) ); if ( temp;min_dis ) min_dis=temp; min_dis_cluster=c; end end min_dis; if (min_dis;do1) S(i).E=S(i).E- ( ETX*(1000) + Emp1*1000*( min_dis *min_dis * min_dis * min_dis)); end if (min_dis;=do1) S(i).E=S(i).E- ( ETX*(1000) + Efs1*1000*( min_dis * min_dis)); end S(C(min_dis_cluster).id).E =S(C(min_dis_cluster).id).E- ( (ERX + EDA)*1000 ); packets_TO_CH=packets_TO_CH+1; %end %sv S(i).min_dis=min_dis; S(i).min_dis_cluster=min_dis_cluster; else min_dis=sqrt( (S(i).xd-S(n+1).xd)^2 + (S(i).yd-S(n+1).yd)^2 ); if (min_dis;do) S(i).E=S(i).E- ( ETX*(1000) + Emp*1000*( min_dis *min_dis * min_dis * min_dis)); end if (min_dis;=do) S(i).E=S(i).E- ( ETX*(1000) + Efs*1000*( min_dis * min_dis)); end packets_TO_BS=packets_TO_BS+1; sv=plaintext; end endendSTATISTICS.PACKETS_TO_CH(r+1)=packets_TO_CH; STATISTICS.PACKETS_TO_BS(r+1)=packets_TO_BS; re_plaintext = inv_cipher (ciphertext, w, inv_s_box, inv_poly_mat, 1); endfirst_dead; teenth_dead; all_dead; STATISTICS.DEAD(r+1) STATISTICS.ALLIVE(r+1) STATISTICS.PACKETS_TO_CH(r+1) STATISTICS.PACKETS_TO_BS(r+1) STATISTICS.COUNTCHS(r+1) hold on; warning(‘OFF’); VX,VY=voronoi(X,Y); plot(X,Y,’k+’,VX,VY,’r-‘); xlabel(‘X-Axis’); ylabel(‘Y-Axis’); title(‘TOTAL CLUSTERING NODES DEPLOYMENT IN WSN’); axis(0 xm 0 ym); hold on;

Improved Data Security in Wsn Using Leach-C Protocol by Integrated Aes essay

Remember. This is just a sample

You can get your custom paper from our expert writers

Get custom paper