AVR1318: Using the XMEGA built-in AES accelerator. 8-bit Microcontrollers. Application Note. Features. 1 Introduction



Similar documents
AVR1309: Using the XMEGA SPI. 8-bit Microcontrollers. Application Note. Features. 1 Introduction SCK MOSI MISO SS

AVR1301: Using the XMEGA DAC. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1600: Using the XMEGA Quadrature Decoder. 8-bit Microcontrollers. Application Note. Features. 1 Introduction. Sensors

AVR1900: Getting started with ATxmega128A1 on STK bit Microcontrollers. Application Note. 1 Introduction

AVR32701: AVR32AP7 USB Performance. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR353: Voltage Reference Calibration and Voltage ADC Usage. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1510: Xplain training - XMEGA USART. 8-bit Microcontrollers. Application Note. Prerequisites. 1 Introduction

Using CryptoMemory in Full I 2 C Compliant Mode. Using CryptoMemory in Full I 2 C Compliant Mode AT88SC0104CA AT88SC0204CA AT88SC0404CA AT88SC0808CA

8-bit. Application Note. Microcontrollers. AVR282: USB Firmware Upgrade for AT90USB

AVR1922: Xplain Board Controller Firmware. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32138: How to optimize the ADC usage on AT32UC3A0/1, AT32UC3A3 and AT32UC3B0/1 series. 32-bit Microcontrollers. Application Note.

Application Note. 8-bit Microcontrollers. AVR270: USB Mouse Demonstration

AVR2006: Design and characterization of the Radio Controller Board's 2.4GHz PCB Antenna. Application Note. Features.

AVR033: Getting Started with the CodeVisionAVR C Compiler. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR305: Half Duplex Compact Software UART. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Application Note. 8-bit Microcontrollers. AVR272: USB CDC Demonstration UART to USB Bridge

AVR319: Using the USI module for SPI communication. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR317: Using the Master SPI Mode of the USART module. 8-bit Microcontrollers. Application Note. Features. Introduction

AVR115: Data Logging with Atmel File System on ATmega32U4. Microcontrollers. Application Note. 1 Introduction. Atmel

AVR287: USB Host HID and Mass Storage Demonstration. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

Atmel AVR4921: ASF - USB Device Stack Differences between ASF V1 and V2. 8-bit Atmel Microcontrollers. Application Note. Features.

AVR055: Using a 32kHz XTAL for run-time calibration of the internal RC. 8-bit Microcontrollers. Application Note. Features.

AVR32788: AVR 32 How to use the SSC in I2S mode. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

General Porting Considerations. Memory EEPROM XRAM

Application Note. 8-bit Microcontrollers. AVR293: USB Composite Device

Atmel AVR4920: ASF - USB Device Stack - Compliance and Performance Figures. Atmel Microcontrollers. Application Note. Features.

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary. Features. Applications. 1. Description

AVR030: Getting Started with IAR Embedded Workbench for Atmel AVR. 8-bit Microcontrollers. Application Note. Features.

AVR1003: Using the XMEGA Clock System. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR2004: LC-Balun for AT86RF230. Application Note. Features. 1 Introduction

AVR245: Code Lock with 4x4 Keypad and I2C LCD. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

How To Use An Atmel Atmel Avr32848 Demo For Android (32Bit) With A Microcontroller (32B) And An Android Accessory (32D) On A Microcontroller (32Gb) On An Android Phone Or

Atmel AVR4903: ASF - USB Device HID Mouse Application. Atmel Microcontrollers. Application Note. Features. 1 Introduction

AT91SAM ARM-based Flash MCU. Application Note

8-bit Microcontroller. Application Note. AVR222: 8-point Moving Average Filter

AVR32110: Using the AVR32 Timer/Counter. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR1321: Using the Atmel AVR XMEGA 32-bit Real Time Counter and Battery Backup System. 8-bit Microcontrollers. Application Note.

Application Note. Atmel CryptoAuthentication Product Uses. Atmel ATSHA204. Abstract. Overview

32-bit AVR UC3 Microcontrollers. 32-bit AtmelAVR Application Note. AVR32769: How to Compile the standalone AVR32 Software Framework in AVR32 Studio V2

Application Note. Atmel ATSHA204 Authentication Modes. Prerequisites. Overview. Introduction

8-bit RISC Microcontroller. Application Note. AVR236: CRC Check of Program Memory

Application Note. C51 Bootloaders. C51 General Information about Bootloader and In System Programming. Overview. Abreviations

APPLICATION NOTE. Atmel AVR134: Real Time Clock (RTC) Using the Asynchronous Timer. Atmel AVR 8-bit Microcontroller. Introduction.

8-bit Microcontroller. Application Note. AVR415: RC5 IR Remote Control Transmitter. Features. Introduction. Figure 1.

AVR106: C functions for reading and writing to Flash memory. 8-bit Microcontrollers. Application Note. Features. Introduction

APPLICATION NOTE. Secure Personalization with Transport Key Authentication. ATSHA204A, ATECC108A, and ATECC508A. Introduction.

AVR134: Real Time Clock (RTC) using the Asynchronous Timer. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

8-bit RISC Microcontroller. Application Note. AVR182: Zero Cross Detector

AT91 ARM Thumb Microcontrollers. AT91SAM CAN Bootloader. AT91SAM CAN Bootloader User Notes. 1. Description. 2. Key Features

AN3270 Application note

USER GUIDE EDBG. Description

AVR151: Setup and Use of the SPI. Introduction. Features. Atmel AVR 8-bit Microcontroller APPLICATION NOTE

AVR223: Digital Filters with AVR. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR ONE!... Quick-start Guide. EVK Windows 32104B AVR ONE! 02/10

Application Note. USB Microcontrollers. USB PC Drivers Based on Generic HID Class. 1. Introduction

8-bit Microcontroller. Application Note. AVR105: Power Efficient High Endurance Parameter Storage in Flash Memory

AVR125: ADC of tinyavr in Single Ended Mode. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR32100: Using the AVR32 USART. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE. Atmel LF-RFID Kits Overview. Atmel LF-RFID Kit. LF-RFID Kit Introduction

8051 Flash Microcontroller. Application Note. A Digital Thermometer Using the Atmel AT89LP2052 Microcontroller

APPLICATION NOTE. Atmel AT04389: Connecting SAMD20E to the AT86RF233 Transceiver. Atmel SAMD20. Description. Features

AVR034: Mixing C and Assembly Code with IAR Embedded Workbench for AVR. 8-bit Microcontroller. Application Note. Features.

AN AES encryption and decryption software on LPC microcontrollers. Document information

APPLICATION NOTE. Atmel AVR443: Sensor-based Control of Three Phase Brushless DC Motor. Atmel AVR 8-bit Microcontrollers. Features.

8-bit RISC Microcontroller. Application Note. AVR155: Accessing an I 2 C LCD Display using the AVR 2-wire Serial Interface

8-bit Microcontroller. Application Note. AVR314: DTMF Generator

AT89C5131A Starter Kit... Software User Guide

8-bit RISC Microcontroller. Application Note. AVR910: In-System Programming

Atmel AVR1017: XMEGA - USB Hardware Design Recommendations. 8-bit Atmel Microcontrollers. Application Note. Features.

AT91 ARM Thumb Microcontrollers. Application Note. Interfacing a PC Card to an AT91RM9200-DK. Introduction. Hardware Interface

256K (32K x 8) Battery-Voltage Parallel EEPROMs AT28BV256

APPLICATION NOTE. Authentication Counting. Atmel CryptoAuthentication. Features. Introduction

AVR1324: XMEGA ADC Selection Guide. 8-bit Atmel Microcontrollers. Application Note. Features. 1 Introduction

8-bit Microcontroller. Application Note. AVR400: Low Cost A/D Converter

USER GUIDE. ZigBit USB Stick User Guide. Introduction

3-output Laser Driver for HD-DVD/ Blu-ray/DVD/ CD-ROM ATR0885. Preliminary. Summary

8-bit Microcontroller. Application Note. AVR201: Using the AVR Hardware Multiplier

AVR106: C Functions for Reading and Writing to Flash Memory. Introduction. Features. AVR 8-bit Microcontrollers APPLICATION NOTE

SPC5-CRYP-LIB. SPC5 Software Cryptography Library. Description. Features. SHA-512 Random engine based on DRBG-AES-128

How to Calculate the Capacitor of the Reset Input of a C51 Microcontroller 80C51. Application Note. Microcontrollers. Introduction

Atmel AVR4027: Tips and Tricks to Optimize Your C Code for 8-bit AVR Microcontrollers. 8-bit Atmel Microcontrollers. Application Note.

8-bit Microcontroller. Application. Note. AVR204: BCD Arithmetics. Features. Introduction. 16-bit Binary to 5-digit BCD Conversion bin2bcd16

8-bit Microcontroller. Application Note. AVR134: Real-Time Clock (RTC) using the Asynchronous Timer. Features. Theory of Operation.

APPLICATION NOTE. AT07175: SAM-BA Bootloader for SAM D21. Atmel SAM D21. Introduction. Features

AVR442: PC Fan Control using ATtiny13. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

AVR2027: AES Security Module. 8-bit Microcontrollers. Application Note. Features. 1 Introduction

APPLICATION NOTE Atmel AT02509: In House Unit with Bluetooth Low Energy Module Hardware User Guide 8-bit Atmel Microcontroller Features Description

AT88CK490 Evaluation Kit

AT89LP Flash Data Memory. Application Note. AT89LP Flash Data Memory API. 1. Introduction. 2. Theory of Operation. 2.1 Flash Memory Operation

Step Motor Controller. Application Note. AVR360: Step Motor Controller. Theory of Operation. Features. Introduction

AVR32737: AVR32 AP7 Linux Getting Started. 32-bit Microcontrollers. Application Note. Features. 1 Introduction

64K (8K x 8) Parallel EEPROM with Page Write and Software Data Protection AT28C64B

Pavithra.S, Vaishnavi.M, Vinothini.M, Umadevi.V

SMARTCARD XPRO. Preface. SMART ARM-based Microcontrollers USER GUIDE

More Secure, Less Costly IoT Edge Node Security Provisioning

Introducing a platform to facilitate reliable and highly productive embedded developments

AVR120: Characterization and Calibration of the ADC on an AVR. 8-bit Microcontrollers. Application Note. Features. Introduction

How To Design An Ism Band Antenna For 915Mhz/2.4Ghz Ism Bands On A Pbbb (Bcm) Board

APPLICATION NOTE. Atmel AT02985: User s Guide for USB-CAN Demo on SAM4E-EK. Atmel AVR 32-bit Microcontroller. Features. Description.

Quick Start Guide. CAN Microcontrollers. ATADAPCAN01 - STK501 CAN Extension. Requirements

Transcription:

AVR1318: Using the XMEGA built-in AES accelerator Features Full compliance with AES (FIPS Publication 197, 2002) - Both encryption and decryption procedures 128-bit Key and State memory XOR load option to State memory useful for cipher block coding Sequential access to State and Key memories Optional Interrupt- and DMA request on AES complete 8-bit Microcontrollers Application Note 1 Introduction The XMEGA AES Crypto Module supports the Advanced Encryption Standard (AES), and can perform encryption and decryption. The module supports a key length of 128 bits. The 128-bit key block and 128-bit data block (plaintext or ciphertext) must be loaded into the Key and State memory in the AES Crypto Module. The AES uses 375 clock cycles to execute one encryption/decryption after the Key and State memory is loaded and the mode of operation is selected. This application note describes the basic functionality of the XMEGA AES with code examples to get up and running quickly. A driver interface written in C is included as well. Advanced usage, such as Direct Memory Access and the XMEGA Event System, is outside the scope of this application note. Please refer to the device datasheets and other relevant application notes for details. Rev.

2 Theory Cryptography is the art or science of keeping information secret and is based on either hiding the cryptographic method or securing the cryptographic key. Algorithms only based on the secrecy of the method used are mainly of historical interest and do not meet the needs of the real world. Modern algorithms use a key to control encryption and decryption. Without the matching key, the scrambled message or data cannot be arranged into plaintext. Algorithms based on cryptographic keys are divided in two classes; symmetric and asymmetric. Symmetric algorithms use the same key for encryption and decryption while asymmetric algorithms use different keys. AES is a symmetric key algorithm. 2.1 Advanced Encryption Standard AES This section is not intended to be a detailed description of the AES algorithm, but a brief overview. For more details the reader should study the AES specification. The AES algorithm uses functions that are based on finite field arithmetic. The AES algorithm has a fixed block size of 128 bits, while the length of the key can be 128, 192 or 256 bits depending on the desired security. The flow of the AES algorithm is illustrated in Figure 2-1. See AES specification for explanation of the different operations in the flowchart. 2 AVR1318

AVR1318 Figure 2-1 Encryption and Decryption flowcharts Encrypt Block Decrypt Block Substitute Bytes Inverse Shift Rows No Shift Rows No Inverse Substitute Bytes Mix Columns Inverse Mix Columns Ready for the last round? Ready for the last round? Yes Yes Substitute Bytes Inverse Shift Rows Shift Rows Inverse Substitute Bytes Add round key Return Return 2.2 Cipher Block Chaining (CBC) The number of rounds the algorithm needs to run is depended on the key length. AES is a block cipher, meaning that the algorithm operates on fixed size blocks of data. For known input block and a constant encryption key, the output will always be the same. This information may provide useful for somebody wanting to attack the cipher system. There are methods commonly used, which cause identical plaintext blocks being encrypted to different ciphertext blocks. One such methode called Cipher Block Chaining (CBC). CBC is a method of connecting the cipher blocks such that leading blocks influence all trailing blocks. This is achieved by first performing an XOR operation on the 3

plaintext block and the previous ciphertext block before encrypting the result. This increases the number of plaintext bits one ciphertext bit depends on. Figure 2-2. CBC Encryption Plaintext 0 Plaintext 1 Plaintext N Initalization vector Keys Encryption Keys Encryption Keys Encryption Ciphertext 0 Ciphertext 1 Ciphertext N Figure 2-3. CBC Decryption Ciphertext 0 Plaintext 1 Plaintext N Keys Decryption Keys Decryption Keys Decryption Initalization vector Plaintext 0 Ciphertext 0 Ciphertext N 3 AES Crypto Module The following subsections contain an introduction on how to operate the AES Crypto Module. The different feature the AES Crypto Module supports is also presented. The XMEGA AES Crypto Module supports an AES key length of 128-bits. The service of the AES Crypto Module can be executed through an interrupt mechanism or polling. The DMA can also be setup to handle the AES crypto module, but this is outside the scope of this application note. For more information, please refer to the device datasheet or the application note AVR1304: Using the XMEGA DMA Controller. 3.1 Key and State memory 4 AVR1318 The AES Crypto Module contains two 128 bits memories needed to keep the AES plaintext/ciphertext and the Key. Note that in the AES Crypto Module the following definition of the Key is used: In encryption mode, the Key is the one defined in the AES standard. In decryption mode, the Key is the last subkey of the Expanded Key defined in the AES standard. The State and Key memory can be written / read sequentially byte by byte through the AES State Register (STATE) or AES Key Register (KEY). Both the State and Key memory have two 4-bit address pointers that address the memory for read and write access. The appropriate pointer is automatically incremented after an access to the AES memory. It is only possible to access the Key and State memories while the AES start bit (START) in the AES Control register (CTRL) is zero.

AVR1318 NOTE: Both the Key and State memory must be completely loaded before an encryption/decryption can start, if not the AES Error flag (ERROR) in the status register (STATUS) is set. 3.2 Encryption To execute an AES encryption using the AES Crypto Module the following should be done. Enable/disable AES interrupts, by setting/clearing the Interrupt priority and enable bits (INTLVL) in the Interrupt Control register (INTCTRL). Select the AES encryption direction, by clearing the decrypt bit (decrypt) in the control register (CTRL). Load the AES key into the AES Key memory Load the data block into the AES State memory Start encryption, by setting the start bit (START) in the control register (CTRL). When the encryption is completed, the AES State Ready Interrupt Flag (SRIF) in the AES Status register (STATUS) is set. If the interrupt mechanism is used an interrupt is generated. The AES State memory will after an encryption is completed contain the generated ciphertext while the AES Key memory will contain the last subkey of the Expanded Key defined in the AES standard. 3.3 Decryption To execute an AES decryption using the AES Crypto Module the following should be done. Enable/disable AES interrupts, by setting/clearing the Interrupt priority and enable bits (INTLVL) in the Interrupt Control register (INTCTRL). Select the AES decryption direction, by setting the decrypt bit (decrypt) in the control register (CTRL). Load the last subkey of the Expanded Key defined in the AES standard into the AES Key memory. Load the data block into the AES State memory Start decryption, by setting the start bit (START) in the control register (CTRL). When the decryption is completed, the AES State Ready Interrupt Flag (SRIF) in the AES Status register (STATUS) is set. If the interrupt mechanism is used an interrupt is generated. The AES State memory will after a decryption is completed contain the generated plaintext while the AES Key memory will contain the original Key defined in the AES standard. NOTE: The last subkey of the Expanded Key that is needed to do a decryption can be generated in two optional ways. It can be generated by a Key Expansion procedure executed in software or by the AES Crypto module. The AES Crypto Module can generate the last subkey of the Expanded Key by processing a dummy data block in encryption mode, using the original Key. After the end of the encryption, the Key memory contains the last subkey. 5

3.4 AES State XOR load 3.5 AES Auto Start Trigger When the AES State XOR load feature is enabled the loaded value to the AES State memory is bitwise XORed with the current value of the AES Stat memory. To enable AES State XOR feature set the XOR bit (XOR) in the AES Control register (CTRL). This feature is very useful when CBC or other Cipher Modes shall be executed. When the AES Auto Start Trigger feature is enabled the encryption/decryption will automatically start when the State register is fully loaded. 4 Driver Implementation 4.1 Files This application note includes a source code package with a basic AES driver implemented in C. It is written for the IAR Embedded Workbench compiler. The AES driver supports encryption and decryptions of single block data and CBC. Both interrupted and a polled version of the driver is supported. Note that this AES driver is not intended for use with high-performance code. It is designed as a library to get started using the AES accelerator. Please refer to the driver source code and device datasheet for more details. The source code package consists of three files: AES_driver.c AES accelerator driver source file. AES_driver.h DES accelerator driver header file. AES_example_polled.c Example code using the polled driver. AES_example_interrupt.c Example code using the interrupt driver. 4.2 Doxygen Documentation For a complete overview of the available driver interface functions and their use, please refer to the source code documentation. All source code is prepared for automatic documentation generation using Doxygen. Doxygen is a tool for generating documentation from source code by analyzing the source code and using special keywords. For more details about Doxygen please visit http://www.doxygen.org. Precompiled Doxygen documentation is also supplied with the source code accompanying this application note, available from the readme.html file in the source code folder. 6 AVR1318

Disclaimer Headquarters International Atmel Corporation 2325 Orchard Parkway San Jose, CA 95131 USA Tel: 1(408) 441-0311 Fax: 1(408) 487-2600 Atmel Asia Room 1219 Chinachem Golden Plaza 77 Mody Road Tsimshatsui East Kowloon Hong Kong Tel: (852) 2721-9778 Fax: (852) 2722-1369 Atmel Europe Le Krebs 8, Rue Jean-Pierre Timbaud BP 309 78054 Saint-Quentin-en- Yvelines Cedex France Tel: (33) 1-30-60-70-00 Fax: (33) 1-30-60-71-11 Atmel Japan 9F, Tonetsu Shinkawa Bldg. 1-24-8 Shinkawa Chuo-ku, Tokyo 104-0033 Japan Tel: (81) 3-3523-3551 Fax: (81) 3-3523-7581 Product Contact Web Site www.atmel.com Technical Support avr@atmel.com Sales Contact www.atmel.com/contacts Literature Request www.atmel.com/literature Disclaimer: The information in this document is provided in connection with Atmel products. No license, express or implied, by estoppel or otherwise, to any intellectual property right is granted by this document or in connection with the sale of Atmel products. EXCEPT AS SET FORTH IN ATMEL S TERMS AND CONDITIONS OF SALE LOCATED ON ATMEL S WEB SITE, ATMEL ASSUMES NO LIABILITY WHATSOEVER AND DISCLAIMS ANY EXPRESS, IMPLIED OR STATUTORY WARRANTY RELATING TO ITS PRODUCTS INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, CONSEQUENTIAL, PUNITIVE, SPECIAL OR INCIDENTAL DAMAGES (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF INFORMATION) ARISING OUT OF THE USE OR INABILITY TO USE THIS DOCUMENT, EVEN IF ATMEL HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. Atmel makes no representations or warranties with respect to the accuracy or completeness of the contents of this document and reserves the right to make changes to specifications and product descriptions at any time without notice. Atmel does not make any commitment to update the information contained herein. Unless specifically provided otherwise, Atmel products are not suitable for, and shall not be used in, automotive applications. Atmel s products are not intended, authorized, or warranted for use as components in applications intended to support or sustain life. 2008 Atmel Corporation. All rights reserved. Atmel, logo and combinations thereof, AVR and others, are the registered trademarks, XMEGA TM and others are trademarks of Atmel Corporation or its subsidiaries. Other terms and product names may be trademarks of others.