Rev. 0.1 6/07 Copyright © 2007 by Silicon Laboratories AN324
AN324
ADVANCED ENCRYPTION STANDARD
RELEVANT DEVICES
All Silicon Labs MCUs.
1. Introduction
The Advanced Encryption Standard (AES) is an algorithm used to encrypt and decrypt data for the purposes of
protecting the data when it is transmitted electronically. The AES algorithm allows for the use of cipher keys that
are 128, 192, or 256 bits long to protect data in 16-byte blocks.
AES is a U.S. Federal Information Processing Standards approved algorithm that is also approved for commercial
and private applications. Since its acceptance in 2001, AES has become widely used in a variety of applications.
The AES algorithm is a reduced version of the Rijndael algorithm, though the names are sometimes used
interchangeably. The Rijndael algorithm allows for additional key sizes and data sizes that are not supported by
AES.
The purpose of this application note is to provide a sample implementation of the AES algorithm for Silicon Labs
microcontrollers and to detail the performance of the implementation. The provided example code is intended for
C8051F326/7 devices, but, since the code is not hardware-specific, it can easily be ported to any Silicon Labs
microcontroller.
This application note does not describe the mathematics used in the algorithm. An explanation of the mathematics,
along with other information about AES, is available in the official AES document provided by the National Institute
of Standards and Technology, FIPS PUB 197 (available at http://csrc.nist.gov/publications/fips/).
1.1. Potential Applications
Since the minimum key size of AES is 128-bits, it is considered to be immune to brute force attacks for the near
future. Given the strength of the cipher, implementing AES requires relatively few resources in terms of memory
and system cycles, which makes it a good choice for an encryption algorithm. Some sample applications where
AES is useful are:
Wireless communication, such as wireless keyboards
Point-of-sale terminals
Surveillance applications
2. Implementation
The AES algorithm is a symmetric-key algorithm. A symmetric-key algorithm uses the same or related keys to
encrypt and decrypt the data. In the AES algorithm, the input data is 16 bytes, and the resulting encrypted data is
also 16 bytes. The encryption and decryption routines use the same private key that is 128, 192, or 256 bits. The
larger the key size used, the more difficult it is to break the algorithm and obtain the encrypted data.
The example code provided with this application note is a mostly straightforward implementation of the algorithm
provided in FIPS PUB 197. In order to maintain easy readability, the example code uses the same terminology and
function names provided in the specification. The optimizations used in this example that deviate from the example
implementation provided in the specification are described in more detail in "3.2. Optimization" on page 4.
2.1. Firmware Organization
The code is divided into three independent modules: encryption, decryption, and key expansion. The encryption
module includes the firmware necessary to convert the input data to cipher text. The decryption module converts
cipher text back to plain text or unencrypted data. The key expansion module expands the cipher key into a global
array that is used by both the encryption and decryption routines.