Download WIRELESS COMMUNICATIONS

Transcript
1/11/2010
9:50 AM
Page 54
F EATURE
2102015_Dalrymple.qxp
ARTICLE
by Monte Dalrymple
Advanced Encryption Standard
Understanding AES Without Math
Does the Advanced Encryption Standard (AES) confuse you? Try taking the
complicated math out of the pictur e and approaching it from a hardware
point of view. This will make the encryption/decryption pr ocess a little clearer
and help you ensure your data is protected.
I
’d always been curious about how data encryption and
decryption worked, but the math involved had put me
off until recently. While I was designing a CPU, I was asked
to add instructions to speed up encryption and decryption
using the Advanced Encryption Standard (AES), which is the
current United States government’s approved encryption
standard. This meant digging into the standard and figuring
out how it actually works.
In this article, I’ll show you how AES really works from a
hardware standpoint and hopefully spare you the complicated and confusing math that the standard uses to specify the
algorithm. Instead of terms like “affine transformations” and
“Galois Fields,” I’ll describe the algorithm using the Verilog
hardware description language and some pseudo-code for the
high-level stuff.
While there is just one AES algorithm, there are three different “flavors” (the word used in the standard) that depend
on the cipher key’s length. For this description, I’ll use the
most common version, which is AES-128. It uses a cipher
key that is 128 bits long.
February 2010 – Issue 235
HIGH-LEVEL VIEW
54
The AES algorithm is a type of symmetric block cipher.
This means the algorithm uses the same key for encrypting
and decrypting (the symmetric part) and operates on blocks
of data of a particular size, transforming a fixed-size block of
data (known as the plaintext) into an identical size block of
encrypted data (called the ciphertext) and vice versa. The
block size for AES is 128 bits, which conveniently fits into
four 32-bit registers, as shown in Figure 1.
The AES algorithm applies a handful of fairly simple operations to these data bits in a series of “rounds” (a fancy way
of saying iterations). For AES-128, there are 10 of these
rounds, nine of which are identical. The output of each
round is used as the input to the next round, and the output
of the final round is the encrypted data. Decryption reverses
this process, step by step, to transform the encrypted data
back to its original form.
During each round, the intermediate data is combined
with a round key, which is an expanded version of the original 128-bit cipher key. I’ll cover the algorithm to generate
these round keys later in this article. Using a different key for
each round makes the encryption significantly stronger,
because it’s almost the same as using a much longer cipher key.
Using an expanded key generated from the smaller cipher
key has two other advantages. One, a smaller cipher key is
easier to communicate and keep track of. Two, the key
expansion process can compensate for what would otherwise
be weak keys. Think of the case where someone inadvertently picked a key of all zeros.
Before I dig into the details of the algorithm, let me point
out the most important fact to remember when dealing with
encryption: the original data cannot be destroyed. So, no
matter what the algorithm does to those original 128 bits of
data—by shuffling the order of the bits, or combining them
amongst themselves in convoluted ways, or combining them
with bits of a key—the original data bits are all still there.
w_reg
31:24
23:16
15:8
7:0
x_reg
63:56
55:48
47:40
39:32
y_reg
95:88
87:80
79:72
71:64
z_reg
127:120
119:112
111:104
103:96
Figure 1—The 128-bit data block is contained in four 32-bit registers. In this implementation all 128 bits are operated on in parallel,
simplifying the storage requirements and increasing performance.
CIRCUIT CELLAR®
•
www.circuitcellar.com