Professional Documents
Culture Documents
The AES encryption/decryption algorithm is widely used in modern consumer electronic products for security. To shorten the encryption/decryption time of plenty of data, it is necessary to adopt the algorithm of hardware implementation; however, it is possible to meet the requirement for low cost by completely using software only. In this paper, we implemented the AES encryption algorithm with hardware in combination with part of software using the custom instruction mechanism provided by the ARM7 with keil platform. The main functional blocks of this algorithm are AES-128 key expansion block: The initial 128-bit cipher key has to be expanded to eleven round keys of same length. The first round key is the cipher key (RoundKey0) and all subsequent round keys are produced when a function is applied to the previously generated round key. A data block of 128-bits, called plaintext, is provided as input to the AES encryption algorithm. AES performs a number of transformations to the plaintext, and a 128-bit output block (called cipher text) is produced as a result.
Introduction
Page 1
CHAPTER-1
An Embedded system is any computer system hidden inside a product other than a computer. Embedded systems are found in wide range of applications like expensive industrial control applications. As the technology brought down the cost of dedicated processors. They began to appear in moderately expansive applications such as automobiles, communications and office equipment, televisions. Todays embedded system is so inexpensive that they are used in almost every electronic product in our life. Performance goals will force us to learn and apply new techniques such as multitasking and scheduling. The need to communicate directly with sensors actuators, keypads, displays etc will require programmers to have a better understanding of how alternative methods for performing input and output provide opportunities to trade speed, complexity and cost
another. C compilers are available for a number of different target processors, and they generate very efficient code. Despite the popularity of C++ and Java for desktop application programming, they are rarely used in embedded systems because of the large run-time overhead required to support some of their features. For example, even a relatively simple C++ program will produce about twice as much code as the same program written in C,and the situation is Much worse for large program that makes extensive use of the run-time library.
Object files Compiler Executable Image Assebler file Linker Loader Read write RAM Memory (RAM)
Introduction
Page 3
Object Files Compiler Executable Assembler Image File Linker Loader file
Rom image
A compiler and/or an assembler are used to build one or more object files that are
Run-time gather linked to kernel with a run-time library to form an executable image thats stored as a file on
the disk. When we want run a desktop application program, its executable image is loaded from a disk into memory by a part of the operating system known as the Loader. The operating system itself is already in memory, put there during the boot process. The desktop system is intended to run a number of different application programs. Thus, read-write main memory is used so that an entirely different application program can be quickly and easily loaded into memory, replacing the previous application whenever necessary. Unlike general desktop systems embedded systems are designed to serve a single purpose. Once the embedded software is in memory, there is usually no reason to change it.
Application programmers typically do their work on the same kind of computer on which the application will run. If programmers edit the program, compiles its links it, tries it out and debugs it, all on the same machin The tactic has to change for embedded systems. In the first place, most embedded systems have specialized hardware to attach to special sensors or to drive special controls, and the only way to try out the software is on the specialized hardware.
Introduction
Page 4
In the second place, embedded systems often use microprocessors that have never been used as the basis of workstations. Obviously, programs do not get magically compiled into the instruction set for what ever microprocessor you happen to have chosen for your system, and programs do not magically jump into the memory of your embedded system for execution
Introduction
Page 5
HOST
Cross Assembler
.O bj
Target
System
Fig. 1.3 Cross Compilers
Introduction
Page 6
1.2.4 Linker/Locators for Embedded Software The first difference between a native linker and locator is the nature of the output files that they create. The native linker creates a file on the disk drive of the host system that is read by a part of the O.S called the loader. The locator creates file that will be used by some program that copies the output to the target system. Later, the output from the locator will have to run its own. In an embedded system, there is no separate O.S. Linkers for embedded system is often called as locators.
Introduction
Page 7
CHAPTER-2
INTRODUCTION
2.1Information Security:
The concept of information will be taken to be an understood quantity. To introduce cryptography, an understanding of issues related to information security in general is necessary. Information security manifests itself in many ways according to the situation and requirement. Regardless of who is involved, to one degree or another, all parties to a transaction must have confidence that certain objectives associated with information security have been met. Over the centuries, an elaborate set of protocols and mechanisms has been created to deal with information security issues when the information is conveyed by physical documents. Often the objectives of information security cannot solely be achieved through mathematical algorithms and protocols alone, but require procedural techniques and abidance of laws to achieve the desired result.
For example, privacy of letters is provided by sealed envelopes delivered by an accepted mail service. The physical security of the envelope is, for practical necessity, limited and so laws are enacted which make it a criminal offense to open mail for which one is not authorized. It is sometimes the case that security is achieved not through the information itself but through the physical document recording it.
For example, paper currency requires special inks and material to prevent counterfeiting. Conceptually, the way information is recorded has not changed dramatically over time. Whereas information was typically stored and transmitted on paper, much of it now resides on magnetic media and is transmitted via telecommunications systems, some wireless. What has changed dramatically is the ability to copy and alter information. One can make thousands of identical copies of a piece of information stored electronically and each is indistinguishable from the original. With information on paper, this is much more difficult.
Introduction
Page 8
What is needed then for a society where information is mostly stored and transmitted in electronic form is a means to ensure information security which is independent of the physical medium recording or conveying it and such that the objectives of information security rely solely on digital information itself. One of the fundamental tools used in information security is the signature. It is a building block for many other services such as non-repudiation, data origin authentication, identification, and witnessing, to mention a few. Having learned the basics in writing, an individual is taught how to produce a handwritten signature for the purpose of identification. At contract age the signature evolves to take on a very integral part of the persons identity. This signature is intended to be unique to the individual and serve as a means to identify, authorize, and validate.
With electronic information the concept of a signature needs to be redressed; it cannot simply be something unique to the signer and independent of the information signed. Electronic replication of it is so simple that appending a signature to a document not signed by the originator of the signature is almost a triviality. Analogues of the paper protocols currently in use are required. Hopefully these new electronic based protocols are at least as good as those they replace. There is a unique opportunity for society to introduce new and more efficient ways of ensuring information security. Much can be learned from the evolution of the paper based system, mimicking those aspects which have served us well and removing the inefficiencies. Achieving information security in an electronic society requires a vast array of technical and legal skills. There is, however, no guarantee that all of the information security objectives deemed necessary can be adequately met. The technical means is provided through cryptography.
Introduction
Page 9
2.2 Cryptography:
Cryptography has a long and fascinating history. The most complete non-technical account of the subject is Kahns The Codebreakers. This book traces cryptography from its initial and limited use by the Egyptians some 4000 years ago, to the twentieth century where it played a crucial role in the outcome of both world wars. The most striking development in the history of cryptography came in 1976 when Diffie and Hellman published New Directions in Cryptography. This paper introduced the revolutionary concept of public-key cryptography and also provided a new and ingenious method for key exchange, the security of which is based on the intractability of the discrete logarithm problem. Although the authors had no practical realization of a public-key encryption scheme at the time, the idea was clear and it generated extensive interest and activity in the cryptographic community.
In 1978 Rivest, Shamir, and Adleman discovered the first practical public-key encryption and signature scheme, now referred to as RSA. The RSA scheme is based on another hard mathematical problem, the intractability of factoring large integers. This application of a hard mathematical problem to cryptography revitalized efforts to find more efficient methods to factor. The 1980s saw major advances in this area but none which rendered the RSA system insecure.Another class of powerful and practical public-key schemes was found by ElGamal in 1985. These are also based on the discrete logarithm problem. One of the most significant contributions provided by public-key cryptography is the digital signature. In 1991 the first international standard for digital signatures (ISO/IEC 9796) was adopted. It is based on the RSA public-key scheme. In 1994 the U.S. Government adopted the Digital Signature Standard, a mechanism based on the ElGamal publickey scheme. Cryptography is the study of mathematical techniques related to aspects of information security such as confidentiality, data integrity, entity authentication, and data origin authentication. Cryptography is not the only means of providing information security, but rather one set of techniques. 2.2.1 Cryptography Terminology Until modern times cryptography referred almost exclusively to encryption, which is the process of converting ordinary information (called plaintext) into unintelligible gibberish
Introduction Page 10
(called ciphertext).Decryption is the reverse, in other words, moving from the unintelligible cipher text back to plaintext. A cipher (or cipher) is a pair of algorithms that create the encryption and the reversing decryption. The detailed operation of a cipher is controlled both by the algorithm and in each instance by a "key". This is a secret parameter (ideally known only to the communicants) for a specific message exchange context. A "cryptosystem" is the ordered list of elements of finite possible plaintexts, finite possible cyphertexts, finite possible keys, and the encryption and decryption algorithms which correspond to each key. Keys are important, as ciphers without variable keys can be trivially broken with only the knowledge of the cipher used and are therefore useless (or even counter-productive) for most purposes. Historically, ciphers were often used directly for encryption or decryption without additional procedures such as authentication or integrity checks. 2.2.2 Cryptographic goals (1) Privacy or confidentiality (2) Data integrity (3) Authentication (4) Non-repudiation 1. Confidentiality is a service used to keep the content of information from all but those authorized to have it. Secrecy is a term synonymous with confidentiality and privacy. There are numerous approaches to providing confidentiality, ranging from physical protection to mathematical algorithms which render data unintelligible. 2. Data integrity is a service which addresses the unauthorized alteration of data. To assure data integrity, one must have the ability to detect data manipulation by unauthorized parties. Data manipulation includes such things as insertion, deletion, and substitution. 3. Authentication is a service related to identification. This function applies to both entities and information itself. Two parties entering into a communication should identify each other. Information delivered over a channel should be authenticated as to origin, date of origin, data content, time sent, etc. For these reasons this aspect of cryptography is usually subdivided into two major classes: entity authentication and data origin authentication. Data origin authentication implicitly provides data integrity
Introduction
Page 11
4. Non-repudiation is a service which prevents an entity from denying previous commitments or actions. When disputes arise due to an entity denying that certain actions were taken, a means to resolve the situation is necessary. For example, one entity may authorize the purchase of property by another entity and later deny such authorization was granted. A procedure involving a trusted third party is needed to resolve the dispute. A fundamental goal of cryptography is to adequately address these four areas in both theory and practice. Cryptography is about the prevention and detection of cheating and other malicious activities.
There are number of basic cryptographic tools (primitives) used to provide information security. Examples of primitives include encryption schemes hash functions, and digital signature schemes provides a schematic listing of the primitives considered and how they relate. These primitives should be evaluated with respect to various criteria such as:
a whole. Cryptography, over the ages, has been an art practised by many who have devised ad hoc techniques to meet some of the information security requirements. The last twenty years have been a period of transition as the disciplinemoved froman art to a science. There are now several international scientific conferences devoted exclusively to cryptography and also an international scientific organization, the International Association for Cryptologic Research (IACR), aimed at fostering research in the area.
Introduction
Page 12
2.2.3Cryptography Types
i) Classic Cryptography:
The earliest forms of secret writing required little more than local pen and paper analogs, as most people could not read. More literacy, or literate opponents, required actual cryptography. The main classical cipher types are transposition ciphers, which rearrange the order of letters in a message (e.g., 'hello world' becomes 'ehlolowrdl' in a trivially simple rearrangement scheme), and substitution ciphers, which systematically replace letters or groups of letters with other letters or groups of letters (e.g., 'fly at once' becomes 'gmzbupodf' by replacing each letter with the one following it in the Latin alphabet). Simple versions of either have never offered much confidentiality from enterprising opponents. An early substitution cipher was the Caesar cipher, in which each letter in the plaintext was replaced by a letter some fixed number of positions further down the alphabet. Suetonius reports that Julius Caesar used it with a shift of three to communicate with his generals. Atbash is an example of an early Hebrew cipher. The earliest known use of cryptography is some carved ciphertext on stone in Egypt (ca 1900 BCE), but this may have been done for the amusement of literate observers rather than as a way of concealing information. Cryptography is recommended in the Kama Sutra (ca 400 BCE) as a way for lovers to communicate without inconvenient discovery. The Greeks of Classical times are said to have known of ciphers (e.g., the scytale transposition cipher claimed to have been used by the Spartan military). Steganography (i.e., hiding even the existence of a message so as to keep it confidential) was also first developed in ancient times. An early example, from Herodotus, concealed a messagea tattoo on a slave's shaved headunder the regrown hair. Another Greek method was developed by Polybius (now called the "Polybius Square"). More modern examples of steganography include the use of invisible ink, microdots, and digital watermarks to conceal information. Ciphertexts produced by a classical cipher (and some modern ciphers) always reveal statistical information about the plaintext, which can often be used to break them. After the discovery of frequency analysis perhaps by the Arab mathematician and polymath, Al-Kindi (also known as Alkindus), in the 9th century, nearly all such ciphers became more or less readily breakable by any informed attacker. Such classical ciphers still enjoy popularity today, though mostly as puzzles (see cryptogram). Al-Kindi wrote a book on cryptography
Introduction Page 13
entitled Risalah fi Istikhraj al-Mu'amma (Manuscript for the Deciphering Cryptographic Messages), in which described the first cryptanalysis techniques.
Enciphered letter from Gabriel de Luetzd'Aramon, French Ambassador to the Ottoman Empire, after 1546, with partial decipherment Essentially all ciphers remained vulnerable to cryptanalysis using the frequency analysis technique until the development of the polyalphabetic cipher, most clearly by Leon Battista Alberti around the year 1467, though there is some indication that it was already known to Al-Kindi. Alberti's innovation was to use different ciphers (i.e., substitution alphabets) for various parts of a message (perhaps for each successive plaintext letter at the limit). He also invented what was probably the first automatic cipher device, a wheel which implemented a partial realization of his invention. In the polyalphabetic Vigenre cipher, encryption uses a key word, which controls letter substitution depending on which letter of the key word is used. In the mid-19th century Charles Babbage showed that the Vigenre cipher was vulnerable to Kasiski examination, but this was first published about ten years later by Friedrich Kasiski.
Introduction
Page 14
One round (out of 8.5) of the patented IDEA cipher, used in some versions of PGP for high-speed encryption of, for instance, e-mail Symmetric key ciphers are implemented as either block ciphers or stream ciphers. A block cipher enciphers input in blocks of plaintext as opposed to individual characters, the input form used by a stream cipher. The Data Encryption Standard (DES) and the Advanced Encryption Standard (AES) are block cipher designs which have been designated cryptography standards by the US government (though DES's designation was finally withdrawn after the AES was adopted). Despite its deprecation as an official standard, DES (especially its still-approved and much more secure triple-DES variant) remains quite popular; it is used across a wide range of applications, from ATM encryption to e-mail privacy and secure remote access. Many other block ciphers have been designed and released, with considerable variation in quality. Many have been thoroughly broken, such as FEAL. Stream ciphers, in contrast to the 'block' type, create an arbitrarily long stream of key material, which is combined with the plaintext bit-by-bit or character-by-character, somewhat like the one-time pad. In a stream cipher, the output stream is created based on a hidden internal state which changes as the cipher operates. That internal state is initially set up using the secret key material. RC4 is a widely used stream cipher. Block ciphers can be used as stream ciphers..
Introduction Page 15
Cryptographic hash functions are a third type of cryptographic algorithm. They take a message of any length as input, and output a short, fixed length hash which can be used in (for example) a digital signature. For good hash functions, an attacker cannot find two messages that produce the same hash. MD4 is a long-used hash function which is now broken; MD5, a strengthenAed variant of MD4, is also widely used but broken in practice. The U.S. National Security Agency developed the Secure Hash Algorithm series of MD5-like hash functions: SHA-0 was a flawed algorithm that the agency withdrew; SHA-1 is widely deployed and more secure than MD5, but cryptanalysts have identified attacks against it; the SHA-2 family improves on SHA-1, but it isn't yet widely deployed, and the U.S. standards authority thought it "prudent" from a security perspective to develop a new standard to "significantly improve the robustness of NIST's overall hash algorithm toolkit."[25] Thus, a hash function design competition is underway and meant to select a new U.S. national standard, to be called SHA-3, by 2012. Message authentication codes (MACs) are much like cryptographic hash functions, except that a secret key can be used to authenticate the hash value upon receipt. modular multiplication and exponentiation, which are much more computationally expensive than the techniques used in most block ciphers, especially with typical key sizes. As a result, public-key cryptosystems are commonly hybrid cryptosystems, in which a fast high-quality symmetric-key encryption algorithm is used for the message itself, while the relevant symmetric key is sent with the message, but encrypted using a public-key algorithm. Similarly, hybrid signature schemes are often used, in which a cryptographic hash function is computed, and only the resulting hash is digitally signed. iii) Public-Key Cryptography :
In an asymmetric key encryption scheme, anyone can encrypt messages using the public key, but only the holder of the paired private key can decrypt. Security depends on the secrecy of that private key. In some related signature schemes, the private key is used to sign a message; anyone can check the signature using the public key. Validity depends on security of the private key. In the DiffieHellman key exchange scheme, each party generates a public/private key pair and distributes the public key... After obtaining an authentic copy of each other's public keys, Alice and Bob can compute a shared secret offline. The shared secret can be used, for instance, as the key for a symmetric cipher. This cryptographic approach uses asymmetric key algorithms such as RSA, hence the more general name of "asymmetric key cryptography". Some of these algorithms have the public key/private key property; that is, neither key is derivable from knowledge of the other; not all asymmetric key algorithms do. Those with this property are particularly useful and have been widely deployed, and are the source of the commonly used name. Although unrelated, the key pair are mathematically linked. The public key is used to transform a message into an unreadable form, decryptable only by using the (different but matching) private key. By publishing the public key, the key producer empowers anyone who gets a copy of the public key to produce messages only s/he can readbecause only the key producer has a copy of the private key (required for decryption). When someone wants to send a secure message to the creator of those keys, the sender encrypts it (i.e., transforms it into an unreadable form) using the intended recipient's public key; to decrypt the message, the recipient uses the private key. No one else, including the sender, can do so. The use of these algorithms also allows authenticity of a message to be checked by creating a digital signature of a message using the private key, which can be verified using the public key. Public key cryptography is a fundamental and widely used technology. It is an approach used by many cryptographic algorithms and cryptosystems. It underpins such Internet standards as Transport Layer Security (TLS) (successor to SSL), PGP, and GPG.
Introduction
Page 17
How It Works
The distinguishing technique used in public key cryptography is the use of asymmetric key algorithms, where the key used to encrypt a message is not the same as the key used to decrypt it. Each user has a pair of cryptographic keys a public encryption key and a private decryption key. The publicly available encrypting-key is widely distributed, while the private decrypting-key is known only to the recipient. Messages are encrypted with the recipient's public key and can be decrypted only with the corresponding private key. The keys are related mathematically, but parameters are chosen so that determining the private key from the public key is prohibitively expensive. The discovery of algorithms that could produce public/private key pairs revolutionized the practice of cryptography beginning in the mid-1970s. In contrast, symmetric-key algorithms, variations of which have been used for thousands of years, use a single secret key which must be shared and kept private by both sender and receiver for both encryption and decryption. To use a symmetric encryption scheme, the sender and receiver must securely share a key in advance. Because symmetric key algorithms are nearly always much less computationally intensive, it is common to exchange a key using a key-exchange algorithm and transmit data using that key and a symmetric key algorithm. PGP and the SSL/TLS family of schemes do this, for instance, and are thus called hybrid cryptosystems.
Description
The two main branches of public key cryptography are:
Public key encryption: a message encrypted with a recipient's public key cannot be decrypted by anyone except a possessor of the matching private key, it is presumed that this will be the owner of that key and the person associated with the public key used. This is used for confidentiality.
Digital signatures: a message signed with a sender's private key can be verified by anyone who has access to the sender's public key, thereby proving that the sender had access to the private key (and therefore is likely to be the person associated with the
Introduction
Page 18
public key used), and the part of the message that has not been tampered with. On the question of authenticity, see also message digest. An analogy to public-key encryption is that of a locked mail box with a mail slot. The mail slot is exposed and accessible to the public; its location (the street address) is in essence the public key. Anyone knowing the street address can go to the door and drop a written message through the slot; however, only the person who possesses the key can open the mailbox and read the message. An analogy for digital signatures is the sealing of an envelope with a personal wax seal. The message can be opened by anyone, but the presence of the seal authenticates the sender.
a second input, which is the secret key. It is important to know that the secret key can be of any size (depending on the cipher used) and that AES uses three different key sizes: 128, 192 and 256 bits. While AES supports only block sizes of 128 bits and key sizes of 128, 192 and 256 bits, the Original Rijndael supports key and block sizes in any multiple of 32, with a minimum of128 and a maximum of 256 bits.
2.4 Objectives
To generate 11keys each of length 128bit. To encrypt the pain text into cipher text using the generated keys. To study the synthesis results of AES key expander.
Introduction
Page 20
Page 21
3.2 Description
DES is the archetypal block cipher an algorithm that takes a fixed-length string of plaintext bits and transforms it through a series of complicated operations into another ciphertext bitstring of the same length. In the case of DES, the block size is 64 bits. DES also uses a key to customize the transformation, so that decryption can supposedly only be performed by those who know the particular key used to encrypt. The key ostensibly consists of 64 bits; however, only 56 of these are actually used by the algorithm. Eight bits are used solely for checking parity, and are thereafter discarded. Hence the effective key length is 56 bits, and it is never quoted as such. Every 8th bit of the selected key is discarded, that is, positions 8, 16, 24, 32, 40, 48, 56, 64 are removed from the 64 bit key leaving behind only the 56 bit key.
Figure.3.1DES Algorithm Structure The algorithm's overall structure is shown in Figure 1: there are 16 identical stages of processing, termed rounds. There is also an initial and final permutation, termed IP and FP,
Data Encryption Standard Page 22
which are inverses (IP "undoes" the action of FP, and vice versa). IP and FP have almost no cryptographic significance, but were apparently included in order to facilitate loading blocks in and out of mid-1970s hardware. Before the main rounds, the block is divided into two 32-bit halves and processed alternately; this criss-crossing is known as the Feistel scheme. The Feistel structure ensures that decryption and encryption are very similar processes the only difference is that the subkeys are applied in the reverse order when decrypting. The rest of the algorithm is identical. This greatly simplifies implementation, particularly in hardware, as there is no need for separate encryption and decryption algorithms.The symbol denotes the exclusive-OR (XOR) operation. The F-function scrambles half a block together with some of the key. The output from the F-function is then combined with the other half of the block, and the halves are swapped before the next round. After the final round, the halves are not swapped; this is a feature of the Feistel structure which makes encryption and decryption similar processes.
This is the regular DES algorithm. Data is divided into 64-bit blocks and each block is encrypted one at a time. Separate encryptions with different blocks are totally independent of each other.
This means that if data is transmitted over a network or phone line, transmission errors will only affect the block containing the error.
It also means, however, that the blocks can be rearranged, thus scrambling a file beyond recognition, and this action would go undetected.
ECB is the weakest of the various modes because no additional security measures are implemented besides the basic DES algorithm.
However, ECB is the fastest and easiest to implement, making it the most common mode of DES.
Page 23
variation is called two-key (K1 and K3 is same) 3DES reduces the effective key size to 112 bits which is less secure. Two-key 3DES is widely used in electronic payments industry. 3DES takes three times as much CPU power than compare with its predecessor which is significant performance hit. AES outperforms 3DES both in software and in hardware. The Rijndael algorithm has been selected as the Advance Encryption Standard (AES) to replace 3DES. AES is modified version of Rijndael algorithm Rijndael was submitted by Joan Diemen and Vincent Rijmen. When considered together Rijndaels combination of security, performance, efficiency, implementability, and flexibility made it an appropriate selection for the AES. By design AES is faster in software and works efficiently in hardware. It works fast even on small devices such as smart phones, smart cards etc. AES provides more security due to larger block size and longer keys. AES uses 128 bit fixed block size and works with 128, 192 and 256 bit keys. Rigndael algorithm in general is flexible enough to work with key and block size of any multiple of 32 bit with minimum of128 bits and maximum of 256 bit.
Page 24
individuals submitted comments. None had any reservations about the suggested algorithm.About AES Axantum Software AB Svante Seleborg2(3)AES is founded on solid and well-published mathematical ground, and appears to resist all known attacks well. Theres a strong indication that in fact no back-door or known weakness exists since it has been published for a long time, has been the subject of intense scrutiny by researchers all over the world, and such enormous amounts of economic value and information is already successfully protected by AES. There are no unknown factors in its design, and it was developed by Belgian researchers in Belgium therefore voiding the conspiracy theories sometimes voiced concerning an government agency. encryption standard developed by a United States
A strong encryption algorithm need only meet only single main criteria:
There must be no way to find the unencrypted clear text if the key is unknown, except brute force, i.e. to try all possible keys until the right one is found.
The AES algorithm is a round-based, symmetric block cipher. It processes data blocks of fixed size (128 bits) using cipher keys of length 128, 196 or 256 bits. Depending on the key used, it is usually abbreviated as AES-128, AES-196 or AES-256 respectively. In this project only AES-128 is considered, as it is the most popular variant of the algorithm. The functional blocks of the algorithm are Key expansion and encryption. In this project we are concentrating on the key generation algorithm. The initial 128-bit cipher key has to be expanded to new eleven round keys of same length. In order to produce a new round key, two transformations have to be performed, RotWord and SubWord. The first one simply cyclically shifts the bytes of the first 32-bit word of the previous key by one position to the left. SubWord on the other hand performs the SubBytes transformation to each byte of the
Input/output Port Description Page 26
rotated word. Simple bit wise xors are then needed in order to produce the final round key. The SubWord (SubBytes) transformation is implemented with a ROM (LUT).
Page 27
4.2 Cipher
A cipher (pronounced SAI-fuhr) is any method of encrypting text (concealing its readability and meaning). It is also sometimes used to refer to the encrypted text message itself
although here the term ciphertext is preferred. Its origin is the Arabic sifr, meaning empty or zero. In addition to the cryptographic meaning, cipher also means someone insignificant, and a combination of symbolic letters as in an entwined weaving of letters for a monogram. Some ciphers work by simply realigning the alphabet (for example, A is represented by F, B is represented by G, and so forth) or otherwise manipulating the text in some consistent pattern. However, almost all serious ciphers use both a key (a variable that is combined in some way with the unencrypted text) and an algorithm (a formula for combining the key with the text). A block cipher is one that breaks a message up into chunks and combines a key with each chunk (for example, 64-bits of text). A stream cipher is one that applies a key to each bit, one at a time. Most modern ciphers are block ciphers
Page 28
Page 29
Significance
Keys are used to control the operation of a cipher so that only the correct key can convert encrypted text (ciphertext) to plaintext. Many ciphers are based on publicly known algorithms or are open source, and so it is only the difficulty of obtaining the key that determines security of the system, provided that there is no analytic attack (i.e., a 'structural weakness' in the algorithms or protocols used), and assuming that the key is not otherwise available (such as via theft, extortion, or compromise of computer systems). The widely accepted notion that the security of the system should depend on the key alone has been explicitly formulated by AugusteKerckhoffs (in the 1880s) and Claude Shannon (in the 1940s); the statements are known as Kerckhoffs' principle and Shannon's Maxim respectively. A key should therefore be large enough that a brute force attack (possible against any encryption algorithm) is infeasible i.e., would take too long to execute. Shannon's work on information theory showed that to achieve so called perfect secrecy, it is necessary for the key length to be at least as large as the message to be transmitted and only used once (this algorithm is called the One-time pad). In light of this, and the practical difficulty of managing such long keys, modern cryptographic practice has discarded the notion of perfect secrecy as a requirement for encryption, and instead focuses on computational security, under which the computational requirements of breaking an encrypted text must be infeasible for an attacker.
Input/output Port Description Page 30
The preferred numbers commonly used as key sizes (in bits) are powers of two, potentially multiplied with a small odd integer.
Figure 4.4 The Sub Bytes In the SubBytes step, each byte in the state is replaced with its entry in a fixed 8-bit lookup table, S; bij = S(aij). In the SubBytes step, each byte in the matrix is updated using an 8-bit substitution box, the Rijndael S-box. This operation provides the non-linearity in the cipher. The S-box used is
Input/output Port Description Page 34
derived from the multiplicative inverse over GF(28), known to have good non-linearity properties. To avoid attacks based on simple algebraic properties, the S-box is constructed by combining the inverse function with an invertible affine transformation. The S-box is also chosen to avoid any fixed points (and so is a derangement), and also any opposite fixed points. 4.7 RCON Rcon is what the Rijndael documentation calls the exponentiation of 2 to a user-specified value. Note that this operation is not performed with regular integers, but in Rijndael's finite field. In polynomial form, 2 is
, and we compute
in
or equivalently,
in
Page 35
4.8 S-BOX
In cryptography, an S-Box (Substitution-box) is a basic component of symmetric key algorithms which performs substitution. In block ciphers, they are typically used to obscure the relationship between the key and the ciphertext Shannon's property of confusion. In many cases, the S-Boxes are carefully chosen to resist cryptanalysis. In general, an S-Box takes some number of input bits, m, and transforms them into some number of output bits, n: an mn S-Box can be implemented as a lookup table with 2m words of n bits each. Fixed tables are normally used, as in the Data Encryption Standard (DES), but in some ciphers the tables are generated dynamically from the key; e.g. the Blowfish and the Twofish encryption algorithms. Bruce Schneier describes IDEA's modular multiplication step as a key-dependent S-Box.
Page 36
History
Part of a 20th century table of common logarithms in the reference book Abramowitz and Stegun. Before the advent of computers, lookup tables of values were used by people to speed up hand calculations of complex functions, such as in trigonometry, logarithms, and statistical density functions. In ancient India, Aryabhata created one of the first sine tables, which he encoded in a Sanskrit-letter-based number system. In 493 A.D., Victorius of Aquitaine wrote a 98-column multiplication table which gave (in Roman numerals) the product of every number from 2 to 50 times and the rows were "a list of numbers starting with one thousand, descending by hundreds to one hundred, then descending by tens to ten, then by ones to one, and then the fractions down to 1/144" . Modern school children are often taught to memorize "times tables" to avoid calculations of the most commonly used numbers (up to 9 x 9 or 12 x 12). Early in the history of computers, input/output operations were particularly slow even in comparison to processor speeds of the time. It made sense to reduce expensive read operations by a form of manual caching by creating either static lookup tables (embedded in the program) or dynamic prefetched arrays to contain only the most commonly occurring data items. Despite the introduction of systemwide caching that now automates this process, application level lookup tables can still improve performance for data items that rarely, if ever, change.
Input/output Port Description Page 37
4.10 Encryption
Encryption is the conversion of data into a form, called a cipher text, that cannot be easily understood by unauthorized people. Decryption is the process of converting encrypted data back into its original form, so it can be understood. The use of encryption/decryption is as old as the art of communication. In wartime, a cipher, often incorrectly called a code, can be employed to keep the enemy from obtaining the contents of transmissions. (Technically, a code is a means of representing a signal without the intent of keeping it secret; examples are Morse code and ASCII.) Simple ciphers include the substitution of letters for numbers, the rotation of letters in the alphabet, and the "scrambling" of voice signals by inverting the sideband frequencies. More complex ciphers work according to sophisticated computer algorithms that rearranges the data bits in digital signals. In order to easily recover the contents of an encrypted signal, the correct decryption key is required. The key is an algorithm that undoes the work of the encryption algorithm. Alternatively, a computer can be used in an attempt to break the cipher. The more complex the encryption algorithm, the more difficult it becomes to eavesdrop on the communications without access to the key. Encryption/decryption is especially important in wireless communications. This is because wireless circuits are easier to tap than their hard-wired counterparts. Nevertheless, encryption/decryption is a good idea when carrying out any kind of sensitive transaction, such as a credit-card purchase online, or the discussion of a company secret between different departments in the organization. The stronger the cipher -- that is, the harder it is for unauthorized people to break it -- the better, in general. However, as the strength of encryption/decryption increases, so does the cost. In recent years, a controversy has arisen over so-called strong encryption. This refers to ciphers that are essentially unbreakable without the decryption keys. While most companies and their customers view it as a means of keeping secrets and minimizing fraud, some governments view strong encryption as a potential vehicle by which terrorists might evade authorities. These governments, including that of the United States, want to set up a key-escrow arrangement. This means everyone who uses a cipher would be required to
Input/output Port Description Page 38
provide the government with a copy of the key. Decryption keys would be stored in a supposedly secure place, used only by authorities, and used only if backed up by a court order. Opponents of this scheme argue that criminals could hack into the key-escrow database and illegally obtain, steal, or alter the keys. Supporters claim that while this is a possibility, implementing the key escrow scheme would be better than doing nothing to prevent criminals from freely using encryption/decryption.
Figure 4.7 The Shiftrows Step In the ShiftRows step, bytes in each row of the state are shifted cyclically to the left. The number of places each byte is shifted differs for each row. The ShiftRows step operates on the rows of the state; it cyclically shifts the bytes in each row by a certain offset. For AES, the first row is left unchanged. Each byte of the second row is shifted one to the left. Similarly, the third and fourth rows are shifted by offsets of two and three respectively. For blocks of sizes 128 bits and 192 bits, the shifting pattern is the same. In this way, each column of the output state of the ShiftRows step is composed of bytes from each column of the input state. (Rijndael variants with a larger block size have slightly different offsets). For a 256-bit block, the first row is unchanged and the shifting for the second, third and fourth row is 1 byte, 3 bytes and 4 bytes respectivelythis change only applies for the Rijndael cipher when used with a 256-bit block, as AES does not use 256-bit blocks.
Page 39
Figure 4.8 Mix coloumns In the MixColumns step, each column of the state is multiplied with a fixed polynomial c(x). In the MixColumns step, the four bytes of each column of the state are combined using an invertible linear transformation. The MixColumns function takes four bytes as input and outputs four bytes, where each input byte affects all four output bytes. Together with ShiftRows, MixColumns provides diffusion in the cipher.
Page 40
In the AddRoundKey step, the subkey is combined with the state. For each round, a subkey is derived from the main key using Rijndael's key schedule; each subkey is the same size as the state. The subkey is added by combining each byte of the state with the corresponding byte of the subkey using bitwise XOR.
(ROM), but this is actually a misnomer because these types of memory can be erased and reprogrammed multiple times. When used in this less precise way, "ROM" indicates a nonvolatile memory which serves functions typically provided by mask ROM, such as storage of program code and nonvolatile data.
4.12 Register
In digital electronics, especially computing, a register stores bits of information, in a way that all the bits can be written to or read out simultaneously. The hardware registers inside a central processing unit (CPU) are called processor registers. Signals from a state machine to the register control when registers transmit to or accept information from other registers. Sometimes the state machine routes information from one register through a functional transform, such as an adder unit, and then to another register that stores the results. Typical uses of hardware registers include configuration and start-up of certain features, especially during initialization, buffer storage e.g. video memory for graphics cards, input/output (I/O) of different kinds, and status reporting such as whether a certain event has occurred in the hardware unit. Reading a hardware register in "peripheral units" -- computer hardware outside the CPUinvolves accessing its memory-mapped I/O address or port-mapped I/O address with a "load" or "store" instruction, issued by the processor. Hardware registers are addressed in words, but sometimes only use a few bits of the word read in to, or written out to the register. Strobe registers have the same interface as normal hardware registers, but instead of storing data, they trigger an action each time they are written to (or, in rare cases, read from). They are a means of signaling. Commercial design tools such as Socrates Bitwise by Duolog Technologies, simplify and automate memory-mapped register specification and code generation for hardware, firmware, hardware verification, testing and documentation. Using IP-XACT IEEE 1685, commercial design tools, such as Socrates Bitwise by Duolog Technologies and MRV Magillem Register View by MAGILLEM, provide a real synchronization between the register description and the RTL hardware platform description, then collaborative work in the design flow can be addressed.
Input/output Port Description Page 42
Simulation Result
Page 43
C51 C Compiler
Compiler Details
Compiler Directives Code Optimizer Memory Models Memory Types Pointers Interrupt Functions Library Reference
The Keil C51 C Compiler for the 8051 microcontroller is the most popular 8051 C compiler in the world. It provides more features than any other 8051 C compiler available today. The C51 Compiler allows you to write 8051 microcontroller applications in C that, once compiled, have the efficiency and speed of assembly language. Language extensions in the C51 Compiler give you full access to all resources of the 8051. The C51 Compiler translates C source files into relocatable object modules which contain full symbolic information for debugging with the Vision Debugger or an in-circuit emulator. In addition to the object file, the compiler generates a listing file which may optionally include symbol table and cross reference information.
Features
Nine basic data types, including 32-bit IEEE floating-point, Flexible variable allocation with bit, data, bdata, idata, xdata, and pdata memory types, Interrupt functions may be written in C, Full use of the 8051 register banks, Complete symbol and type information for source-level debugging, Built-in interface for the RTX51 Real-Time Kernel,
Simulation Result
Page 44
Support for dual data pointers on Atmel, AMD, Cypress, Dallas Semiconductor, Infineon, Philips, and Triscend microcontrollers, Support for the Philips 8xC750, 8xC751, and 8xC752 limited instruction sets, Support for the Infineon 80C517 arithmetic unit.
The BL51 code banking linker. The A51 assembler. The OC51 banked object converter.
Intel HEX files are ASCII files that contain a hexadecimal representation of your program. They may be easily loaded into a device programmer for writing EPROMs or other memory devices. Several utilities are available that may help you with your HEX files:
HEX2BIN converts an Intel HEX file into a flat BINARY file. BIN2HEX converts a flat BINARY file into an Intel HEX file.
Page 45
Simulation Result
The following documents provide additional information about the different output file formats.
Description of the Intel OMF51 Object Module Format. Description of the Intel HEX File Format.
It is our experience that customers who have a simulator require LESS technical support and are able to get up-to-speed with the tools faster. The simulator makes it easy to write and test code and learn about programming your microcontroller.
The Vision Debugger provides complete simulation support for on-chip peripherals like PWM, Power saving modes, A/D, Serial I/O, and so on.
Simulation Result
Page 46
It is easier for our support engineers to explain complex problems if you have a simulator.
It is easier to discover if a problem is in the hardware or software when you use a simulator. For example, if the application works in the simulator and if it works in the emulator, there's most likely a problem with the target hardware.
The simulator requires no setup time. An emulator may require configuration and a target board before you can debug.
The simulator is not a replacement for an emulator. A simulator is a different tool entirely. While an emulator allows you to debug software running on your target hardware, a simulator allows you to debug your software as well as your understanding of the microcontroller and the programming language. There are no real-time debugging effects of a simulator. For debugging embedded applications, we have a general list of favorite tools that we use inhouse.
Logic Probe Digital Multi-Meter High-speed Analog Oscilloscope High-speed Digital Storage Oscilloscope Logic Analyzer (with a disassembly pod) Emulator Software Simulator
Simulation Result
Fig 5.1: Window for choosing target device. Next, Micro Vision must be instructed to generate a HEX file upon program compilation. A HEX file is a standard file format for storing executable code that is to be loaded onto the microcontroller. In the Project Workspace pane at the left, rightclick on Target 1 and select Options for Target 1 .Under the Output tab of the resulting options dialog, ensure that both the Create Executable and Create HEX File options are checked. Then click OK.
Next, a file must be added to the project that will contain the project code. To do this, expand the Target 1 heading, rightclick on the Source Group 1 folder, and select Add files Create a new blank file (the file name should end in .asm), select it, and click Add. The new file should now appear in the Project Workspace pane under the Source Group 1 folder. Double-click on the newly created file to open it in the editor. All code for this lab will go in this file. To compile the program, first save all source files by clicking on the Save All button, and then click on the Rebuild All Target Files to compile the program as shown in the figure below. If any errors or warnings occur during compilation, they will be displayed in the output window at the bottom of the screen. All errors and warnings will reference the line and column number in which they occur along with a description of the problem so that they can be easily located. Note that only errors indicate that the compilation failed, warnings do not (though it is generally a good idea to look into them anyway).
Fig 5.4: Save All and Build All Target Files Buttons
Simulation Result Page 49
When the program has been successfully compiled, it can be simulated using the integrated debugger in Keil MicroVision. To start the debugger, select Debug=>Start/Stop Debug Session from the pulldown menus. At the left side of the debugger window, a table is displayed containing several key parameters about the simulated microcontroller, most notably the elapsed time (circled in the figure below). Just above that, there are several buttons that control code execution. The Run button will cause the program to run continuously until a breakpoint is reached, whereas the Step Into button will execute the next line of code and then pause (the current position in the program is indicated by a yellow arrow to the left of the code).
5.4 PROGRAMMER:
The programmer used is a powerful programmer for the Atmel 89 series of microcontrollers that includes 89C51/52/55, 89S51/52/55 and many more. It is simple to use & low cost, yet powerful flash microcontroller programmer for the Atmel 89 series. It will Program, Read and Verify Code Data, Write Lock Bits, Erase and Blank Check. All fuse and lock bits are programmable. This programmer has intelligent onboard firmware and connects to the serial port. It can be used with any type of computer and requires no special hardware. All that is needed is a serial communication port which all computers have.
Simulation Result Page 50
All devices also have a number of lock bits to provide various levels of software and programming protection. These lock bits are fully programmable using this programmer. Lock bits are useful to protect the program to be read back from microcontroller only allowing erase to reprogram the microcontroller.
FLOWCHART
The flowchart given below represents the working of the system.
Simulation Result
Page 51
/************ System Header Files **********/ #include <E:\ARM2010\MyFiles\lpc2148.h> #include <E:\ARM2010\MyFiles\lcd0801.h> #include <E:\ARM2010\MyFiles\lcdSys.h> #include <E:\ARM2010\MyFiles\Myfunctions.h> /************ Functions Prototype **********/ /************ UART0 Functions Prototype ****/
/************ AES Functions Prototype ******/ unsigned long int word (unsigned char,unsigned char,unsigned char,unsigned char); unsigned char byte(unsigned long int,unsigned char); unsigned long int rotword(unsigned long int); unsigned long int rotword1(unsigned long int); unsigned long int rotword2(unsigned long int); unsigned long int inv_rotword1(unsigned long int); unsigned long int inv_rotword2(unsigned long int); unsigned long int inv_rotword3(unsigned long into); unsigned long int subbytes(unsigned char,unsigned char, unsigned char,unsigned char); unsigned long int inv_subbytes(unsigned char,unsigned char,unsigned char,unsigned char); unsigned long int RCON(unsigned long int,unsigned long int); unsigned long int xor_wi(unsigned long int,unsigned long int); /* Macro Definitions */ #define TEMT (1<<6) #define RDR 0x01 #define LINE_FEED 0x0A #define CARRIAGE_RET 0x0D #define PLOCK 0x400 // clock initialisation related
Simulation Result Page 52
/************ Local variables **************/ //unsigned long int s,v,y,z,u,p,r,x,t,a,b,c,d; //unsigned char D[16]; //unsigned char rcon[10]={0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80,0x1b,0x36}; //unsigned char key[11][16]={0x2b,0x7e,0x15,0x16,0x28,0xae,0xd2,0xa6,0xab,0xf7,0x15,0x88,0x09,0xcf,0 x4f,0x3c}; //unsigned char text[16]={0x32,0x43,0xf6,0xa8,0x88,0x5a,0x30,0x8d,0x31,0x31,0x98,0xa2,0xe0,0x37,0x07, 0x34}; /*************** UART0 variable Declarations ***************/ unsigned char unsigned char unsigned char unsigned char text[64]; Data[16]; Enc[16]; Edata[64];
unsigned char Flag=0; unsigned char C; unsigned int J; //unsigned char A[4][4]={0x02,0x03,0x01,0x01,0x01,0x02,0x03,0x01,0x01,0x01,0x02,0x03,0x03,0x01,0x01 ,0x02}; //unsigned char B[4][4]={0x0e,0x0b,0x0d,0x09,0x09,0x0e,0x0b,0x0d,0x0d,0x09,0x0e,0x0b,0x0b,0x0d,0x09 ,0x0e}; /************** Decryption variable Declarations************/ //unsigned char loop,i,k,j,q[4],e[4],f[4],g[4],m[15],r_key[16],h[4][4],mix_col[4][4],l,n,o,inmix_col[4][4]; unsigned char i;
Simulation Result Page 53
unsigned Index,Index1;
/*************** ARM Initilisation *************************/ PINSEL0 = 0X00000000; PINSEL1 = 0X00000000; IO0DIR = 0XFFFFFFFF; IO1DIR = 0XFFFF0000;
/*********** Device initialsatiojn ********/ lcd_init(); //LCD Initialisation initialize_clock(); //System clock Initialisation initialize_uart(); //UART0 Device Initialisation Flag=0; /************ System Application code ******/
lcd_clear; lcd_print(" AES Algorithm ",L1); lcd_print("on ARM LPC-2148",L2); wait_sec; wait_sec; lcd_clear; lcd_print(" Enter U'r ",L1); lcd_print("* Message #",L2); wait_sec; wait_sec;
while (1) {
Simulation Result Page 54
while(U0LSR & RDR) // Cheking for UART0 RX interrupt { C=U0RBR; if(Flag==0) { switch (C) //2 //3
//1
case '*' : lcd_clear; lcd_print(" RECEIVING ",L1); i =0; Flag =0; wait_sec; lcd_clear; lcd_putchar(0x80,0); break; case '#' : i=0; lcd_clear; Flag=1; break; default : text[i]=C; // Storing message if(i==16) lcd_putchar(0xC0,0); if(i==32) { lcd_clear; lcd_putchar(0x80,0); } if(i==48) lcd_putchar(0xC0,0); lcd_putchar(text[i],1);
Simulation Result Page 55
i++; Flag=0; for(J=0; J< 1000000; J++); break; } } } //2 //3 //1
/******************************/ if(Flag==1) {
// 3
for(Index1=0;Index1<=3;Index1++) { //2 switch (Index1) { 1 case 0x00 : lcd_clear; lcd_print(" I BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(text[i],1); wait_sec; wait_sec; break; case 0x01 : lcd_clear; lcd_print(" II BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(text[i+16],1);
Simulation Result Page 56
//
wait_sec; wait_sec; break; case 0x02 : lcd_clear; lcd_print(" III BLOCK (16)",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(text[i+32],1); wait_sec; wait_sec; break;
case 0x03 : lcd_clear; lcd_print(" IV BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(text[i+48],1); wait_sec; wait_sec; break; default : break; } } //2 //1
switch (Index)
Simulation Result Page 57
{ //1 case 0x00 : for(i=0;i<=15;i++) Data[i]=text[i]; break; case 0x01 : for(i=0;i<=15;i++) Data[i]=text[i+16];
lcd_clear; wait_sec;
/***********************************************************************/
Simulation Result
Page 58
/***********************************************************************/
switch (Index) { //1 case 0x00 : for(i=0;i<=15;i++) Edata[i]=Enc[i]; break; case 0x01 : for(i=0;i<=15;i++) Edata[i+16]=Enc[i]; break; case 0x02 : for(i=0;i<=15;i++) Edata[i+32]=Enc[i]; break; case 0x03 : for(i=0;i<=15;i++) Edata[i+48]=Enc[i]; break; } } //2 lcd_clear; lcd_print(" Encryption ",L1); lcd_print(" wait_sec; Over ",L2); //1
for(Index1=0;Index1<=3;Index1++) { //2
Simulation Result Page 59
switch (Index1) { //1 case 0x00 : lcd_clear; lcd_print(" I BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i],1); wait_sec; wait_sec; break; case 0x01 : lcd_clear; lcd_print(" II BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i+16],1); wait_sec; wait_sec; break; case 0x02 : lcd_clear; lcd_print(" III BLOCK (16)",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i+32],1); wait_sec; wait_sec; break;
} //1 } //2
switch (Index) { //1 case 0x00 : for(i=0;i<=15;i++) Data[i]=Edata[i]; break; case 0x01 : for(i=0;i<=15;i++) Data[i]=Edata[i+16];
break;
Simulation Result Page 61
/******************************************************************** ***/
switch (Index) { //1 case 0x00 : for(i=0;i<=15;i++) Edata[i]=Data[i]; break; case 0x01 : for(i=0;i<=15;i++) Edata[i+16]=Data[i]; break; case 0x02 : for(i=0;i<=15;i++) Edata[i+32]=Data[i]; break; case 0x03 : for(i=0;i<=15;i++) Edata[i+48]=Data[i]; break; } //1
Simulation Result
Page 62
} //2
Over
",L2);
for(Index1=0;Index1<=3;Index1++) { //2 switch (Index1) { //1 case 0x00 : lcd_clear; lcd_print(" I BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i],1); wait_sec; wait_sec; break; case 0x01 : lcd_clear; lcd_print(" II BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i+16],1); wait_sec; wait_sec; break; case 0x02 : lcd_clear; lcd_print(" III BLOCK (16)",L1); lcd_putchar(0xC0,0);
Simulation Result Page 63
case 0x03 : lcd_clear; lcd_print(" IV BLOCK (16) ",L1); lcd_putchar(0xC0,0); for(i=0;i<=15;i++) lcd_putchar(Edata[i+48],1); wait_sec; wait_sec; break; default : break;
} //1 } //2
lcd_clear; lcd_print(" Enter U'r ",L1); lcd_print("* Next Message #",L2); wait_sec; wait_sec; Flag=0; } //3
} } //5
//4
/*************** System Initialization ***************/ void initialize_uart() { /* Initialize Pin Select Block for Tx and Rx */ PINSEL0=0x5; /* Enable FIFO's and reset them */ // U0FCR=0x7; U0FCR=0x07; /* Set DLAB and word length set to 8bits */ U0LCR=0x83; /* Baud rate set to 9600 */ U0DLL=0xC2; U0DLM=0x0; /* Clear DLAB */ U0LCR=0x3; U0TER=0x80; // U0TER[7]--> 1 TxEna 0-->0 disable } void initialize_clock() { /* Initialize PLL (Configured for a 12MHz crystal) to boost processor clock to 60MHz */ /* Setting Multiplier and divider values */ PLLCFG=0x24; feed(); /* Enabling the PLL */ PLLCON=0x1; feed(); /* Wait for the PLL to lock to set frequency */ while(!(PLLSTAT & PLOCK)){} /* Connect the PLL as the clock source */ PLLCON=0x3; feed(); /* Setting peripheral Clock (pclk) to System Clock (cclk)*/
Simulation Result Page 65
VPBDIV=0x02; } /********************************************************** Feed Sequence for PLL **********************************************************/ void feed() { PLLFEED=0xAA; PLLFEED=0x55; }
Simulation Result
Page 66
Simulation Result
Page 67
Hardware Modules:
MAX232. ARM7 PROCESSOR RF Tx & Rx pairs. voltage regulator, RPS. LCD.
Microcontroller Beginner Kit.). To make a 5 volt power supply, we use a LM7805 voltage regulator IC .
The LM7805 is simple to use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the Output pin.
A. CIRCUIT FEATURES
Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA
Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot
Circuit complexity: Very simple and easy to build Circuit performance: Very stable +5V output voltage, reliable operation Availability of components: Easy to get, uses only very common basic components Design testing: Based on datasheet example circuit, I have used this circuit successfully as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply Power supply voltage: Unregulated DC 8-18V power supply Power supply current: Needed output current + 5 mA Component costs: Few dollars for the electronics components + the input transformer cost
B. BLOCK DIAGRAM
C. CIRCUIT DIAGRAM
Above is the circuit of a basic unregulated dc power supply. A bridge rectifier D1 to D4 rectifies the ac from the transformer secondary, which may also be a block rectifier such as WO4 or even four individual diodes such as 1N4004 types. (See later re rectifier ratings). The principal advantage of a bridge rectifier is you do not need a centre tap on the secondary of the transformer. A further but significant advantage is that the ripple frequency at the output is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes filtering somewhat easier. As a design example consider we wanted a small unregulated bench supply for our projects. Here we will go for a voltage of about 12 - 13V at a maximum output current (IL) of 500ma (0.5A). Maximum ripple will be 2.5% and load regulation is 5%. Now the RMS secondary voltage (primary is whatever is consistent with your area) for our power transformer T1 must be our desired output Vo PLUS the voltage drops across D2 and D4 ( 2 * 0.7V) divided by 1.414. This means that Vsec = [13V + 1.4V] / 1.414 which equals about 10.2V. Depending on the VA rating of your transformer, the secondary voltage will vary considerably in accordance with the applied load. The secondary voltage on a transformer advertised as say 20VA will be much greater if the secondary is only lightly loaded. If we accept the 2.5% ripple as adequate for our purposes then at 13V this becomes 13 * 0.025 = 0.325 Vrms. The peak to peak value is 2.828 times this value. Vrip = 0.325V X 2.828 = 0.92 V and this value is required to calculate the value of C1. Also required for this calculation is the time interval for charging pulses. If you are on a 60Hz system it is 1/ (2 * 60 ) = 0.008333 which is 8.33 milliseconds. For a 50Hz system it is 0.01 sec or 10 milliseconds. Remember the tolerance of the type of capacitor used here is very loose. The important thing to be aware of is the voltage rating should be at least 13V X 1.414 or 18.33. Here you would use at least the standard 25V or higher (absolutely not 16V).With our rectifier diodes or bridge they should have a PIV rating of 2.828 times the Vsec or at least 29V. Don't search for this rating because it doesn't exist. Use the next highest standard or even higher. The current rating should be at least twice the load current maximum i.e. 2 X 0.5A or 1A. A good type to use would be 1N4004, 1N4006 or 1N4008 types.
These are rated 1 Amp at 400PIV, 600PIV and 1000PIV respectively. Always be on the lookout for the higher voltage ones when they are on special.
TRANSFORMER RATING:
In our example above we were taking 0.5A out of the Vsec of 10V. The VA required is 10 X 0.5A = 5VA. This is a small PCB mount transformer available in Australia and probably elsewhere. This would be an absolute minimum and if you anticipated drawing the maximum current all the time then go to a higher VA rating. The two capacitors in the primary side are small value types and if you don't know precisely and I mean precisely what you are doing then OMIT them. Their loss won't cause you heartache or terrible problems. THEY MUST BE HIGH VOLTAGE TYPES RATED FOR A.C USE The fuse F1 must be able to carry the primary current but blow under excessive current, in this case we use the formula from the diagram. Here N = 240V / 10V or perhaps 120V / 10V. The fuse calculates in the first instance to [ 2 X 0.5A ] / [240 / 10] or .04A or 40 ma. In the second case .08A or 80 ma. The difficulty here is to find suitable fuses of that low a current and voltage rating. In practice you use the closest you can get (often 100 ma ). Don't take that too literal and use 1A or 5A fuses.
CONSTRUCTION
The whole project MUST be enclosed in a suitable box. The main switch (preferably double pole) must be rated at 240V or 120V at the current rating. All exposed parts within the box MUST be fully insulated, preferably with heat shrink tubing.
An 8051 program must interact with the outside world using input and output devices that communicate directly with a human being. One of the most common devices attached to an 8051 is an LCD display. Some of the most common LCDs connected to the 8051 are 16x2 and 20x2 displays. This means 16 characters per line by 2 lines and 20 characters per line by 2 lines, respectively. Fortunately, a very popular standard exists which allows us to communicate with the vast majority of LCDs regardless of their manufacturer. The standard is referred to as HD44780U, which refers to the controller chip which receives data from an external source (in this case, the 8051) and communicates directly with the LCD. The 44780 standard requires 3 control lines as well as either 4 or 8 I/O lines for the data bus. The user may select whether the LCD is to operate with a 4-bit data bus or an 8-bit data bus. If a 4-bit data bus is used the LCD will require a total of 7 data lines (3 control lines plus the 4 lines for the data bus). If an 8-bit data bus is used the LCD will require a total of 11 data lines (3 control lines plus the 8 lines for the data bus).
The three control lines are referred to as EN, RS, and RW.
The EN line is called "Enable." This control line is used to tell the LCD that you are sending it data. To send data to the LCD, your program should make sure this line is low (0) and then set the other two control lines and/or put data on the data bus Finally, the data bus consists of 4 or 8 lines (depending on the mode of
Technical Specifications:
Power Requirements: 5 VDC Communication: 4-bit or 8-bit Parallel Interface Dimensions: ~3.25L x ~1.75W x 0.25H in (~85L x ~45W x ~6H mm)
Applications:
Portable Computers Low-Power Modems Interface Translation Battery-Powered RS-232 Systems Multidrop RS-232 Networks
Features
ARM7TDMI-S based high-performance 32-bit RISC Microcontroller with Thumb extensions, 16-bit/32-bit ARM7TDMI-S microcontroller in a tiny LQFP64 package. 512KB on-chip Flash ROM with In-System Programming (ISP) and In-Application Programming (IAP), 32KB RAM. Vectored Interrupt Controller, Two 10bit ADCs with 14 channels, USB 2.0 Full Speed Device Controller, Two UARTs, one with full modem interface.
Two I2C serial interfaces, Two SPI serial interfaces Two 32-bit timers, Watchdog Timer, PWM unit, Real Time Clock with optional battery backup, Brown out detect circuit General purpose I/O pins. CPU clock up to 60 MHz, On-chip crystal oscillator and On-chip PLL
9.2 Architecture :
Fig9.1 Architecture
Architectural overview:
The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high performance and very low power consumption. The ARM architecture is based on Reduced Instruction Set Computer (RISC) principles, and the instruction set and related decode mechanism are much simpler than those of microprogrammed Complex Instruction Set Computers (CISC). This simplicity results in a high instruction throughput and impressive realtime interrupt response from a small and cost-effective processor core. Pipeline techniques are employed so that all parts of the processing and memory systems can operate continuously. Typically, while one instruction is being executed, its successor is being decoded, and a third instruction is being fetched from memory. The ARM7TDMI-S processor also employs a unique architectural strategy known as Thumb, which makes it ideally suited to high-volume applications with memory restrictions, or applications where code density is an issue. The key idea behind Thumb is that of a super-reduced instruction set. Essentially, the ARM7TDMI-S processor has two instruction sets:
The standard 32-bit ARM set. A 16-bit Thumb set. The Thumb sets 16-bit instruction length allows it to approach twice the density of standard ARM code while retaining most of the ARMs performance advantage over a traditional 16-bit processor using 16-bit registers. This is possible because Thumb code operates on the same 32-bit register set as ARM code. Thumb code is able to provide up to 65 % of the code size of ARM, and 160 % of the performance of an equivalent ARM processor connected to a 16-bit memory system. The particular flash implementation in the LPC2141/42/44/46/48 allows for full speed execution also in ARM mode. It is recommended to program performance critical and short code sections (such as interrupt service routines and DSP algorithms) in ARM mode. The impact on the overall code size will be minimal but the speed can be increased by 30% over Thumb mode.
Memory map
The general purpose RAM for data storage and code storage and execution. The LPC2148 memory map incorporates several distinct regions. In addition, the CPU interrupt vectors may be remapped to allow them to reside in either flash memory (the default) or on-chip static RAM. System control.
Interrupt controller
The Vectored Interrupt Controller (VIC) accepts all of the interrupt request inputs and categorizes them as Fast Interrupt Request (FIQ), vectored Interrupt Request (IRQ), and nonvectored IRQ as defined by programmable settings. The programmable assignment scheme means that priorities of interrupts from the various peripherals can be dynamically assigned and adjusted. Fast interrupt request (FIQ) has the highest priority. If more than one request is assigned to FIQ, the VIC combines the requests to produce the FIQ signal to the ARM processor. The fastest possible FIQ latency is achieved when only one request is classified as FIQ, because then the FIQ service routine does not need to branch into the interrupt service routine but can run
The interrupt vector location. If more than one request is assigned to the FIQ class, the FIQ service routine will read a word from the VIC that identifies which FIQ source(s) is (are) requesting an interrupt. Vectored IRQs have the middle priority. Sixteen of the interrupt requests can be assigned to this category. Any of the interrupt requests can be assigned to any of the 16 vectored IRQ slots, among which slot 0 has the highest priority and slot 15 has the lowest. Nonvectored IRQs have the lowest priority. The VIC combines the requests from all the vectored and non-vectored IRQs to produce the IRQ signal to the ARM processor. The IRQ service routine can start by reading a register from the VIC and jumping there. If any of the vectored IRQs are pending, the VIC provides the address of the highest-priority requesting IRQs service routine, otherwise it provides the address of a default routine that is shared by all the non-vectored IRQs. The default routine can read another VIC register to see what IRQs are active.
Interrupt sources
Each peripheral device has one interrupt line connected to the Vectored Interrupt Controller, but may have several internal interrupt flags. Individual interrupt flags may also represent more than one interrupt source.
if trace is enabled, the Trace pins will assume their trace functionality. The pins associated with the I2C0 and I2C1 interface are open drain.
Features
Bit-level set and clear registers allow a single instruction set or clear of any number of bits in one port. Direction control of individual bits. Separate control of output set and clear. All I/O default to inputs after reset.
10-bit ADC
The LPC2141/42 contain one and the LPC2144/46/48 contain two analog to digital converters. These converters are single 10-bit successive approximation analog to digital converters. While ADC0 has six channels, ADC1 has eight channels. Therefore, total number of available ADC inputs for LPC2141/42 is 6 and for LPC2144/46/48 is 14.
Features
10 bit successive approximation analog to digital converter. Measurement range of 0 V to VREF (2.0 V VREF VDDA). Each converter capable of performing more than 400,000 10-bit samples per second. Every analog input has a dedicated result register to reduce interrupt overhead. Burst conversion mode for single or multiple inputs. Optional conversion on transition on input pin or timer match signal. Global Start command for both converters .
Features
10-bit DAC. Buffered output. Power-down mode available.
Features
A 32-bit timer/counter with a programmable 32-bit prescaler. External event counter or timer operation. Four 32-bit capture channels per timer/counter that can take a snapshot of the timer value when an input signal transitions. A capture event may also optionally generate an interrupt.
The purpose of the watchdog is to reset the microcontroller within a reasonable amount of time if it enters an erroneous state. When enabled, the watchdog will generate a system reset if the user program fails to feed (or reload) the watchdog within a predetermined amount of time.
Features
Internally resets chip if not periodically reloaded. Debug mode. Enabled by software but requires a hardware reset or a watchdog reset/interrupt to be disabled. Incorrect/Incomplete feed sequence causes reset/interrupt if enabled. Flag to indicate watchdog reset. Programmable 32-bit timer with internal pre-scaler. Selectable time period from (TPCLK 256 4) to (TPCLK 232 4) in multiples of TPCLK 4.
Features
Measures the passage of time to maintain a calendar and clock. Ultra-low power design to support battery powered systems. Provides Seconds, Minutes, Hours, Day of Month, Month, Year, Day of Week, and Day of Year. Can use either the RTC dedicated 32 kHz oscillator input or clock derived from the external crystal/oscillator input at XTAL1. Programmable reference clock divider allows fine adjustment of the RTC.
Dedicated power supply pin can be connected to a battery or the main 3.3 V.
Features
Seven match registers allow up to six single edge controlled or three double edge controlled PWM outputs, or a mix of both types. The match registers also allow: Continuous operation with optional interrupt generation on match. Stop timer on match with optional interrupt generation. Reset timer on match with optional interrupt generation.
PLL
The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz. The input frequency is multiplied up into the range of 10 MHz to 60 MHz with a Current Controlled Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the multiplier value cannot be higher than 6 on this family of microcontrollers due to the upper frequency limit of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there is an additional divider in the loop to keep the CCO within its frequency range while the PLL is providing the desired output frequency. The output divider may be set to divide by 2, 4, 8, or 16 to produce the output clock. Since the minimum output divider value is 2, it is insured that the PLL output has a 50 % duty cycle. The PLL is turned off and bypassed following a chip reset and may be enabled
by software. The program must configure and activate the PLL, wait for the PLL to Lock, then connect to the PLL as a clock source. The PLL settling time is 100 s.
Brownout detector
The LPC2141/42/44/46/48 include 2-stage monitoring of the voltage on the VDD pins. If this voltage falls below 2.9 V, the BOD asserts an interrupt signal to the VIC. This signal can be enabled for interrupt; if not, software can monitor the signal by reading dedicated register. The second stage of low voltage detection asserts reset to inactivate the LPC2141/42/44/46/48 when the voltage on the VDD pins falls below 2.6 V. This reset prevents alteration of the flash as operation of the various elements of the chip would otherwise become unreliable due to low voltage. The BOD circuit maintains this reset down below 1 V, at which point the POR circuitry maintains the overall reset. Both the 2.9 V and 2.6 V thresholds include some hysteresis. In normal operation, this hysteresis allows the 2.9 V detection to reliably interrupt, or a regularlyexecuted event loop to sense the condition.
Code security
This feature of the LPC2141/42/44/46/48 allow an application to control whether it can be debugged or protected from observation. If after reset on-chip boot loader detects a valid checksum in flash and reads 0x8765 4321 from address 0x1FC in flash, debugging will be disabled and thus the code in flash will be protected from observation. Once debugging is disabled, it can be enabled only by performing a full chip erase using the ISP.
wake-up the processor from Power-down mode. Additionally capture input pins can also be used as external interrupts without the option to wake the device up from Power-down mode.
Embedded ICE
Standard ARM Embedded ICE logic provides on-chip debug support. The debugging of the target system requires a host computer running the debugger software and an Embedded ICE protocol convertor. Embedded ICE protocol convertor converts the remote debug protocol commands to the JTAG data needed to access the ARM core. The ARM core has a Debug Communication Channel (DCC) function built-in. The DCC allows a program running on the target to communicate with the host debugger or another separate host without stopping the program flow or even entering the debug state. The DCC is accessed as a co-processor 14 by the program running on the ARM7TDMI-S core. The DCC allows the JTAG port to be used for sending and receiving data without affecting the normal program flow. The DCC data and control registers are mapped in to addresses in the Embedded ICE logic.
Embedded trace
Since the LPC2141/42/44/46/48 have significant amounts of on-chip memory, it is not possible to determine how the processor core is operating simply by observing the external pins. The Embedded Trace Microcell (ETM) provides real-time trace capability for deeply embedded processor cores. It outputs information about processor execution to the trace port. The ETM is connected directly to the ARM core and not to the main AMBA system bus. It compresses the trace information and exports it through a narrow trace port. An external trace port analyzer must
capture the trace information under software debugger control. Instruction trace (or PC trace) shows the flow of execution of the processor and provides a list of all the instructions that were executed. Instruction trace is significantly compressed by only broadcasting branch addresses as well as a set of status signals that indicate the pipeline status on a cycle by cycle basis. Trace information generation can be controlled by selecting the trigger resource. Trigger resources include address comparators, counters and sequencers. Since trace information is compressed the software debugger requires a static image of the code being executed. Self-modifying code can not be traced because of this restriction.
Real Monitor
RealMonitor is a configurable software module, developed by ARM Inc., which enables real-time debug. It is a lightweight debug monitor that runs in the background while users debug their foreground application. It communicates with the host using the DCC, which is present in the EmbeddedICE logic. The LPC2141/42/44/46/48 contain a specific configuration of
CHAPTER-10 APPICATIONS
1. Provides security for images sent through wireless technology. 2. Security for text data. 3. Widely used in modern consumer electronic products for security.
CHAPTER-11 ADVANTAGES&DISADVANTAGES
11.1 ADVANTAGES
1. Key Bytes are used for providing high security for any kind of data. 2. AES has been widely used in many applications such as : Internet routers Mobile phone applications Electronic financial transactions
11.2 DISADVANTAGES
1.If there is increase in key bytes, the complexity increases
CHAPTER-12 CONCLUSION
The embedded system found in most consumer products employs a single chip controller. That includes the microprocessor, a limited amount of memory and simple input output devices. By far the vast majority of the embedded systems in production today are based on the 4bit, 8bit, or 16bit processors. Although 32bit processors account for relatively small percentage of the current market, their use in embedded systems is growing at the fastest rate In this project, we have implemented the AES encryption and decryption algorithm with hardware in combination with part of software using the custom instruction mechanism provided by the ARM7 With a language of embedded C using of keil platform , we explored various combinations of hardware and software to realize the AES algorithm and discussed possible best solutions of different needs.
CHAPTER-13 BIBLIOGRAPHY
Reference books:
1. 2. 3. ARM PROCESSOR AND EMBEDDED SYSTEM., ELECTRONIC COMPONENTS EMBEDDED SOFTWARE PRIMER. Janice Gillispie Mazadi Ramesh S. Gaonkar David .E. Simon.
Reference Websites:
1. 2. 3. 4. 5. 6. 7. www.mitel.databook.com www.atmel.databook.com www.franklin.com www.keil.com http://www.ikalogic.com/cat_microcontrollers.php http://www.electronicsforu.com/Electronicsforu/articles/subcategory.asp?cid=23&id=14 http://electrosofts.com/dtmf/