Aes Advanced Encryption Standard
Aes Advanced Encryption Standard
Technology Administration
Phillip J. Bond, Under Secretary for Technology
Abstract
In 2000, NIST announced the selection of the Rijndael block cipher family as the winner of the
Advanced Encryption Standard (AES) competition. Block ciphers are the foundation for many
cryptographic services, especially those that provide assurance of the confdentiality of data.
Three members of the Rijndael family are specifed in this Standard: AES-128, AES-192, and
AES-256. Each of them transforms data in blocks of 128 bits, and the numerical suffx indicates
the bit length of the associated cryptographic keys.
ii
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Federal Information
Processing Standards Publication 197
Announcing the
ADVANCED ENCRYPTION STANDARD (AES)
Federal Information Processing Standards Publications (FIPS) are developed by NIST under 15
U.S.C. 278g-3 and issued by the Secretary of Commerce under 40 U.S.C. 11331.
1. Name of Standard. Advanced Encryption Standard (AES) (FIPS 197).
2. Category of Standard. Computer Security Standard, Cryptography.
3. Explanation. The Advanced Encryption Standard (AES) specifes a FIPS-approved cryp-
tographic algorithm that can be used to protect electronic data. The AES algorithm is a
symmetric block cipher that can encrypt (encipher) and decrypt (decipher) digital information.
The AES algorithm is capable of using cryptographic keys of 128, 192, and 256 bits to encrypt
and decrypt data in blocks of 128 bits.
4. Approving Authority. Secretary of Commerce.
5. Maintenance Agency. Department of Commerce, National Institute of Standards and Tech-
nology, Information Technology Laboratory (ITL).
6. Applicability. Federal Information Processing Standards apply to information systems used
or operated by federal agencies, a contractor of an agency, or other organization on behalf of
an agency. They do not apply to national security systems as defned in 44 U.S.C. 3552.
This Standard may be used by federal agencies to protect information when they have deter-
mined that encryption is appropriate, in accordance with applicable Offce of Management
and Budget and agency policies. Federal agencies may also use alternative methods that NIST
has indicated are appropriate for this purpose.
This Standard may be adopted and used by non-Federal Government organizations.
7. Specifcations. Federal Information Processing Standard (FIPS) 197, Advanced Encryption
Standard (AES) (affxed).
8. Implementations. The algorithm specifed in this Standard may be implemented in software,
frmware, hardware, or any combination thereof. The specifc implementation may depend
on several factors, such as the application, the environment, the technology used, etc. The
algorithm shall be used in conjunction with a FIPS-approved or NIST-recommended mode
of operation. Object Identifers (OIDs) and any associated parameters for AES used in
iii
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
these modes are available at the Computer Security Objects Register (CSOR), located at
https://csrc.nist.gov/projects/csor.
NIST has developed a validation program to test implementations for conformance to the
algorithms in this Standard. Information about the validation program is available at https:
//nist.gov/cmvp. Examples for each key size are available at https://csrc.nist.gov/projects/aes.
9. Implementation Schedule. This Standard became effective on May 26, 2002.
10. Patents. Implementations of the algorithm specifed in this Standard may be covered by U.S.
and foreign patents.
11. Export Control. Certain cryptographic devices and technical data regarding them are subject
to federal export controls. Exports of cryptographic modules implementing this Standard and
technical data regarding them must comply with all federal laws and regulations and must
be licensed by the Bureau of Industry and Security of the U.S. Department of Commerce.
Information about export regulations is available at https://www.bis.doc.gov.
12. Qualifcations. NIST will continue to follow developments in the analysis of the AES
algorithm. As with its other cryptographic algorithm standards, NIST will formally reevaluate
this Standard every fve years.
Both this Standard and possible threats reducing the security provided through the use of this
Standard will undergo review by NIST as appropriate, taking into account newly available
analysis and technology. In addition, the awareness of any breakthrough in technology or
any mathematical weakness of the algorithm will cause NIST to reevaluate this Standard and
provide necessary revisions.
13. Where to Obtain Copies. This publication is available by accessing https://csrc.nist.gov/
publications. Other computer security publications are available at the same website.
14. Inquiries and Comments. Inquiries and comments about this FIPS may be submitted to
[email protected].
15. How to Cite This Publication. NIST has assigned NIST FIPS 197-upd1 as the publication
identifer for this FIPS, per the NIST Technical Series Publication Identifer Syntax. NIST
recommends that it be cited as follows:
National Institute of Standards and Technology (2001) Advanced Encryption
Standard (AES). (Department of Commerce, Washington, D.C.), Federal Infor-
mation Processing Standards Publication (FIPS) NIST FIPS 197-upd1, updated
May 9, 2023. https://doi.org/10.6028/NIST.FIPS.197-upd1
iv
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Federal Information
Processing Standards Publication 197
2 Defnitions 2
2.1 Terms and Acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 List of Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3 Algorithm Parameters and Symbols . . . . . . . . . . . . . . . . . . . . . . 4
4 Mathematical Preliminaries 8
4.1 Addition in GF(28 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.2 Multiplication in GF(28 ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4.3 Multiplication of Words by a Fixed Matrix . . . . . . . . . . . . . . . . . . 9
4.4 Multiplicative Inverses in GF(28 ) . . . . . . . . . . . . . . . . . . . . . . . . 10
5 Algorithm Specifcations 11
5.1 C IPHER() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
5.1.1 S UB B YTES() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
5.1.2 S HIFT ROWS() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
5.1.3 M IX C OLUMNS() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
5.1.4 A DD ROUND K EY() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
5.2 K EY E XPANSION() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
v
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.3 I NV C IPHER() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3.1 I NV S HIFT ROWS() . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.3.2 I NV S UB B YTES() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.3.3 I NV M IX C OLUMNS() . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
5.3.4 Inverse of A DD ROUND K EY() . . . . . . . . . . . . . . . . . . . . . . 24
5.3.5 E Q I NV C IPHER() . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6 Implementation Considerations 26
6.1 Key Length Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.2 Keying Restrictions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.3 Parameter Extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
6.4 Implementation Suggestions Regarding Various Platforms . . . . . . . . . 26
6.5 Modes of Operation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
References 28
vi
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
List of Tables
Table 1 Hexadecimal representation of 4-bit sequences . . . . . . . . . . . . . . 5
Table 2 Indices for bytes and bits . . . . . . . . . . . . . . . . . . . . . . . . . . 6
Table 3 Key-Block-Round Combinations . . . . . . . . . . . . . . . . . . . . . . . 11
Table 4 SB OX(): substitution values for the byte xy (in hexadecimal format) . . . 14
Table 5 Round constants . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Table 6 I NV SB OX(): substitution values for the byte xy (in hexadecimal format) 23
List of Figures
Figure 1 State array input and output . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 2 Illustration of S UB B YTES() . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 3 Illustration of S HIFT ROWS() . . . . . . . . . . . . . . . . . . . . . . . 15
Figure 4 Illustration of M IX C OLUMNS() . . . . . . . . . . . . . . . . . . . . . . 16
Figure 5 Illustration of A DD ROUND K EY() . . . . . . . . . . . . . . . . . . . . . 16
Figure 6 K EY E XPANSION() of AES-128 to generate the words w[i] for 4 ≤ i < 44,
where l ranges over the multiples of 4 between 0 and 36 . . . . . . . . . . . . . 19
Figure 7 K EY E XPANSION() of AES-192 to generate the words w[i] for 6 ≤ i < 52,
where l ranges over the multiples of 6 between 0 and 42 . . . . . . . . . . . . . 20
Figure 8 K EY E XPANSION() of AES-256 to generate the words w[i] for 8 ≤ i < 60,
where l ranges over the multiples of 8 between 0 and 48 . . . . . . . . . . . . . . 21
Figure 9 Illustration of I NV S HIFT ROWS() . . . . . . . . . . . . . . . . . . . . . 23
List of Algorithms
Algorithm 1 Pseudocode for C IPHER() . . . . . . . . . . . . . . . . . . . . . . . 12
Algorithm 2 Pseudocode for K EY E XPANSION() . . . . . . . . . . . . . . . . . . 18
Algorithm 3 Pseudocode for I NV C IPHER() . . . . . . . . . . . . . . . . . . . . . 22
Algorithm 4 Pseudocode for E Q I NV C IPHER() . . . . . . . . . . . . . . . . . . . 25
Algorithm 5 Pseudocode for K EY E XPANSION EIC() . . . . . . . . . . . . . . . 25
vii
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
1. Introduction
A block is a sequence of bits of a given fxed length. A block cipher is a family of permutations
of blocks that is parameterized by a sequence of bits called the key.
In 1997, NIST initiated the Advanced Encryption Standard (AES) development effort [1] and
called for the public to submit candidate algorithms for block ciphers. Block ciphers are the
foundation for many cryptographic services, especially those that provide assurance of the
confdentiality of data. In 2000, NIST announced the selection of Rijndael [2, 3] for the AES.
This Standard specifes three instantiations of Rijndael: AES-128, AES-192, and AES-256, where
the suffx indicates the bit length of the key. The block size (i.e., the length of the data inputs and
outputs) is 128 bits in each case. Rijndael supports additional block sizes and key lengths that are
not adopted in this Standard.
This Standard is organized as follows:
• Section 2 defnes the terms, acronyms, algorithm parameters, symbols, and functions in
this Standard.
• Section 3 describes the notation and conventions for the ordering and indexing of bits,
bytes, and words.
• Section 4 explains some mathematical components of the AES specifcations: fnite feld
arithmetic and multiplication by a fxed matrix of fnite feld elements.
• Section 5 specifes AES-128, AES-192, and AES-256.
• Section 6 provides implementation guidelines on key length requirements, keying restric-
tions, parameter extensions, and implementation suggestions regarding various platforms.
• Appendix A gives examples of the key expansion routines for AES-128, AES-192, and
AES-256.
• Appendix B gives a step-by-step example of an invocation of AES-128.
• Appendix C gives a reference to the NIST website for extensive example vectors for
AES-128, AES-192, and AES-256.
• Appendix D summarizes the updates to the original version of this publication.
1
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
2. Defnitions
2.1 Terms and Acronyms
The following defnitions are used in this Standard:
2
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
A DD ROUND K EY() The transformation of the state in which a round key is combined
with the state.
AES-128() The block cipher specifed in this Standard with 128-bit keys.
AES-192() The block cipher specifed in this Standard with 192-bit keys.
AES-256() The block cipher specifed in this Standard with 256-bit keys.
C IPHER() The transformation of blocks that underlies AES-128, AES-192,
and AES-256; the key schedule and the number of rounds are
parameters of the transformation.
E Q I NV C IPHER() The inverse of C IPHER() in which dw replaces w as the key schedule
parameter.
I NV C IPHER() The inverse of C IPHER().
I NV M IX C OLUMNS() The inverse of M IX C OLUMNS().
I NV SB OX() The inverse of SB OX().
I NV S HIFT ROWS() The inverse of S HIFT ROWS().
I NV S UB B YTES() The inverse of S UB B YTES().
K EY E XPANSION() The routine that generates the round keys from the key.
K EY E XPANSION EIC() The routine that generates the modifed round keys for the equiva-
lent inverse cipher.
M IX C OLUMNS() The transformation of the state that takes all of the columns of the
state and mixes their data (independently of one another) to produce
new columns.
ROT W ORD() The transformation of words in which the four bytes of the word
are permuted cyclically.
SB OX() The transformation of bytes defned by the S-box.
S HIFT ROWS() The transformation of the state in which the last three rows are
cyclically shifted by different offsets.
S UB B YTES() The transformation of the state that applies the S-box independently
to each byte of the state.
S UB W ORD() The transformation of words in which the S-box is applied to each
of the four bytes of the word.
X T IMES() The transformation of bytes in which the polynomial representation
of the input byte is multiplied by x, modulo m(x), to produce the
polynomial representation of the output byte.
3
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
•
Multiplication in GF 28 .
�
∗ Integer multiplication.
← Assignment of a variable in pseudocode.
{} Delimiters for a byte in hexadecimal or binary notation.
4
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
3.2 Bytes
The basic processing unit in the AES algorithms is the byte — a sequence of eight bits.
�
A byte value is denoted by the concatenation of the eight bits between braces e.g., {10100011} .
When the bits of a byte are denoted by an�indexed variable, the convention in this Standard is for
the indices to decrease from left to right i.e., {b7 b6 b5 b4 b3 b2 b1 b0 } .
It is also convenient to denote byte values using hexadecimal notation. The 16 hexadecimal
characters represent sequences of four bits, as listed in Table 1. A byte is represented by an
ordered pair of hexadecimal characters, where the left character in the pair represents the four
left-most bits(i.e., b7 , b6 , b5 , b4 ), and the right character in the pair represents the four right-most
bits (i.e., b3 , b2 , b1 , b0 ). For example, the hexadecimal form of the byte {10100011} is {a3}.
(for some positive integer k), the bytes a j for 0 ≤ j ≤ k − 1 are defned as follows:
5
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
where
a0 ={r0 r1 . . . r7 };
a1 ={r8 r9 . . . r15 };
.. (3.5)
.
a15 ={r120 r121 . . . r127 }.
As described in Section 3.2, the bits within any individual byte are indexed in decreasing order
from left to right. This ordering is more natural for the fnite feld arithmetic on bytes that is
described in Section 4. The two types of bit indices for byte sequences are illustrated in Table 2.
A sequence of transformations is then applied to the state array, after which its fnal value is
copied to the output array of bytes out0 , out1 , . . . , out15 as follows:
The correspondence between the indices of the input and output with the indices of the state array
is illustrated in Fig. 1.
6
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Thus, the column index c of s becomes the index for v, and the row index r of s becomes the
index for the four bytes in each word.
Given a one-dimensional array u of words, u[i] denotes the word that is indexed by i, and the
sequence of four words u[i], u[i + 1], u[i + 2], u[i + 3] is denoted by u[i..i + 3].
7
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
4. Mathematical Preliminaries
For some transformations of the AES algorithms specifed in Sec. 5, each byte in the state array
is interpreted as one of the 256 elements of a fnite feld, also known as a Galois Field, denoted
by GF(28 ). 1
In order to defne addition and multiplication in GF(28 ), each byte {b7 b6 b5 b4 b3 b2 b1 b0 } is
interpreted as a polynomial, denoted by b(x), as follows:
b(x) = b7 x7 + b6 x6 + b5 x5 + b4 x4 + b3 x3 + b2 x2 + b1 x + b0 . (4.1)
Because the coeffcients of the polynomials are reduced modulo 2, the coeffcient 1 is equivalent
to the coeffcient –1, so addition is equivalent to subtraction. For example, x4 + x2 represents the
same fnite feld element as x4 − x2 , −x4 + x2 , and −x4 − x2 . Similarly, the sum of any element
with itself is the zero element.
m(x) = x8 + x4 + x3 + x + 1. (4.3)
Within both steps, the individual coeffcients of the polynomials are reduced modulo 2.
1 Information about the properties of fnite felds can be found in textbooks, such as Michael Artin’s Algebra [4].
8
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Thus, if b(x) and c(x) represent bytes b and c, then b • c is represented by the following modular
reduction of their product as polynomials:
The modular reduction by m(x) may be applied to intermediate steps in the calculation of b(x)c(x);
consequently, it is useful to consider the special case that c(x) = x (i.e., c = {02}). In particular,
the product b • {02} can be expressed as a function of b, denoted by X T IMES(b), as follows:
(
{b6 b5 b4 b3 b2 b1 b0 0} if b7 = 0
X T IMES (b) = (4.5)
{b6 b5 b4 b3 b2 b1 b0 0} ⊕ {0 0 0 1 1 0 1 1} if b7 = 1.
Multiplication by higher powers of x (such as {04}, {08}, and {10}) can be implemented by the
repeated application of X T IMES(). For example, let b = {57}:
These products facilitate the computation of any multiple of {57}. For example, because {13} =
{10} ⊕ {02} ⊕ {01}, it follows that
9
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
⎡ ⎤ ⎡ ⎤⎡ ⎤
d0 a0 a3 a2 a1 b0
⎢d1 ⎥ ⎢a1 a0 a3 a2 ⎥
⎥ ⎢b1 ⎥ .
⎢ ⎥
⎢ ⎥=⎢ (4.9)
⎣d2 ⎦ ⎣a2 a1 a0 a3 ⎣b2 ⎦
⎦
d3 a3 a2 a1 a0 b3
The defnition of the S UB B YTES() transformation in the specifcations of the AES block cipher
involves multiplicative inverses in GF(28 ), which can be calculated as follows:
Alternatively, let b(x) be the polynomial that represents b. The extended Euclidean algorithm [5]
can be applied to b(x) and m(x) to fnd polynomials a(x) and c(x) such that
10
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5. Algorithm Specifcations
The general function for executing AES-128, AES-192, or AES-256 is denoted by C IPHER(); its
inverse is denoted by I NV C IPHER().2
The core of the algorithms for C IPHER() and I NV C IPHER() is a sequence of fxed transformations
of the state called a round. Each round requires an additional input called the round key; the round
key is a block that is usually represented as a sequence of four words (i.e., 16 bytes).
An expansion routine, denoted by K EY E XPANSION(), takes the block cipher key as input and
generates the round keys as output. In particular, the input to K EY E XPANSION() is represented as
an array of words, denoted by key, and the output is an expanded array of words, denoted by w,
called the key schedule.
The block ciphers AES-128, AES-192, and AES-256 differ in three respects: 1) the length of the
key; 2) the number of rounds, which determines the size of the required key schedule; and 3)
the specifcation of the recursion within K EY E XPANSION(). For each algorithm, the number of
rounds is denoted by Nr, and the number of words of the key is denoted by Nk. (The number of
words in the state is denoted by Nb for Rijndael in general; in this Standard, Nb = 4.) The specifc
values of Nk, Nb, and Nr are given in Table 3. No other confgurations of Rijndael conform to
this Standard.
For implementation issues relating to the key length, block size, and number of rounds, see
Section 6.3.
The three inputs to C IPHER() are: 1) the data input in, which is a block represented as a linear
array of 16 bytes; 2) the number of rounds Nr for the instance; and 3) the round keys. Thus,
The inverse permutations are defned by replacing C IPHER() with I NV C IPHER() in Eq. 5.1.
2 Informally,these functions are sometimes called “encryption” and “decryption,” but neutral terminology is appro-
priate because there are other applications of block ciphers besides encryption.
11
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
The specifcations of C IPHER(), K EY E XPANSION(), and I NV C IPHER() are given in Sections 5.1,
5.2, and 5.3, respectively.
5.1 C IPHER()
The rounds in the specifcation of C IPHER() are composed of the following four byte-oriented
transformations on the state:
• S UB B YTES() applies a substitution table (S-box) to each byte.
• S HIFT ROWS() shifts rows of the state array by different offsets.
• M IX C OLUMNS() mixes the data within each column of the state array.
• A DD ROUND K EY() combines a round key with the state.
The four transformations are specifed in Sections 5.1.1–5.1.4. In those specifcations, the
transformed bit, �byte, or block is denoted by appending the symbol 0 as a superscript on the
0 0 0 0
original variable i.e., by bi , b , si, j , or s .
The round keys for A DD ROUND K EY() are generated by K EY E XPANSION(), which is specifed in
Section 5.2. In particular, the key schedule is represented as an array w of 4 ∗ (Nr + 1) words.
C IPHER() is specifed in the pseudocode in Alg. 1.
The frst step (Line 2) is to copy the input into the state array using the conventions from Sec. 3.4.
After an initial round key addition (Line 3), the state array is transformed by Nr applications of
the round function (Lines 4–12); the fnal round (Lines 10–12) differs in that the M IX C OLUMNS()
transformation is omitted. The fnal state is then returned as the output (Line 13), as described in
Section 3.4.
12
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.1.1 S UB B YTES()
S UB B YTES() is an invertible, non-linear transformation of the state in which a substitution table,
called an S-box, is applied independently to each byte in the state. The AES S-box is denoted by
SB OX().
Let b denote an input byte to SB OX(), and let c denote the constant byte {01100011}. The
0
output byte b = SB OX(b) is constructed by composing the following two transformations:
1. Defne an intermediate value b̃, as follows, where b−1 is the multiplicative inverse of b, as
described in Section 4.4:
(
{00} if b = {00}
b̃ = −1 (5.2)
b 6 {00}.
if b =
0
2. Apply the following affne transformation of the bits of b̃ to produce the bits of b :
b0i = b˜ i ⊕ b̃(i+4) mod 8 ⊕ b̃(i+5) mod 8 ⊕ b̃(i+6) mod 8 ⊕ b̃(i+7) mod 8 ⊕ ci . (5.3)
⎡ 0⎤ ⎡ ⎤⎡ ⎤ ⎡ ⎤
b0 1 0 0 0 1 1 1 1 b̃0 1
0
⎢b1 ⎥ ⎢1 1 0 0 0 1 1 1⎥ ⎢b̃1 ⎥ ⎢1⎥
⎢ ⎥
⎢ 0⎥ ⎢
⎢b2 ⎥ ⎢1 1 1 0 0 0 1 1⎥ ⎢b̃2 ⎥ 0⎥
⎥ ⎢ ⎥
⎢ 0⎥ ⎢ ⎥⎢ ⎥ ⎢
⎢b3 ⎥ ⎢1 1 1 1 0 0 0 1⎥ ⎢b̃3 ⎥ ⎢0⎥
⎢ ⎥ ⎢ ⎥
⎢ 0⎥=⎢ +⎢ ⎥. (5.4)
⎢b4 ⎥ ⎢1 1 1 1 1 0 0 0⎥ ⎢b̃4 ⎥ ⎢0⎥
⎥
⎢b0 ⎥ ⎢0 1 1 1 1 1 0 0⎥
⎢ ⎥ ⎢1⎥
⎢ 5⎥ ⎢ ⎥⎢ b̃
⎢ 5⎥ ⎢
⎥ ⎥
⎣b0 ⎦ ⎣0 0 1 1 1 1 1 0 b̃6
⎦ ⎣1⎦
6
⎣ ⎦
b07 0 0 0 1 1 1 1 1 b˜ 7 0
The AES S-box is presented in hexadecimal form in Table 4. For example, if sr,c = {53}, then
13
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Table 4. SB OX(): substitution values for the byte xy (in hexadecimal format)
y
0 1 2 3 4 5 6 7 8 9 a b c d e f
0 63 7c 77 7b f2 6b 6f c5 30 01 67 2b fe d7 ab 76
1 ca 82 c9 7d fa 59 47 f0 ad d4 a2 af 9c a4 72 c0
2 b7 fd 93 26 36 3f f7 cc 34 a5 e5 f1 71 d8 31 15
3 04 c7 23 c3 18 96 05 9a 07 12 80 e2 eb 27 b2 75
4 09 83 2c 1a 1b 6e 5a a0 52 3b d6 b3 29 e3 2f 84
5 53 d1 00 ed 20 fc b1 5b 6a cb be 39 4a 4c 58 cf
6 d0 ef aa fb 43 4d 33 85 45 f9 02 7f 50 3c 9f a8
x 7 51 a3 40 8f 92 9d 38 f5 bc b6 da 21 10 ff f3 d2
8 cd 0c 13 ec 5f 97 44 17 c4 a7 7e 3d 64 5d 19 73
9 60 81 4f dc 22 2a 90 88 46 ee b8 14 de 5e 0b db
a e0 32 3a 0a 49 06 24 5c c2 d3 ac 62 91 95 e4 79
b e7 c8 37 6d 8d d5 4e a9 6c 56 f4 ea 65 7a ae 08
c ba 78 25 2e 1c a6 b4 c6 e8 dd 74 1f 4b bd 8b 8a
d 70 3e b5 66 48 03 f6 0e 61 35 57 b9 86 c1 1d 9e
e e1 f8 98 11 69 d9 8e 94 9b 1e 87 e9 ce 55 28 df
f 8c a1 89 0d bf e6 42 68 41 99 2d 0f b0 54 bb 16
the substitution value would be determined by the intersection of the row with index ‘5’ and the
column with index ‘3’ in Table 4, so that s0r,c = {ed}.
S HIFT ROWS() is illustrated in Figure 3. In that representation of the state, the effect is to move
each byte by r positions to the left in the row, cycling the left-most r bytes around to the right end
of the row. The frst row, where r = 0, is unchanged.
14
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.1.3 M IX C OLUMNS()
M IX C OLUMNS() is a transformation of the state that multiplies each of the four columns of the
state by a single fxed matrix, as described in Section 4.3, with its entries taken from the following
word:
[a0 , a1 , a2 , a3 ] = [{02}, {01}, {01}, {03}]. (5.6)
Thus,
⎡ 0 ⎤
s0,c
⎡ ⎤⎡ ⎤
02 03 01 01 s0,c
⎢s0 ⎥ ⎢
⎢ 1,c ⎥ ⎢01 02 03 ⎥ ⎢s1,c ⎥
01⎥ ⎢ ⎥
⎢ 0 ⎥=⎣ for 0 ≤ c < 4, (5.7)
⎣s2,c ⎦ 01 01 02 03⎦ ⎣s2,c ⎦
0 03 01 01 02 s3,c
s3,c
15
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
where round is a value in the range 0 ≤ round ≤ Nr, and w[i] is the array of key schedule words
described in Section 5.2. In the specifcation of C IPHER(), A DD ROUND K EY() is invoked Nr + 1
times — once prior to the frst application of the round function (see Alg. 1) and once within each
of the Nr rounds, when 1 ≤ round ≤ Nr.
The action of this transformation is illustrated in Fig. 5, where l = 4 ∗ round. The byte address
within words of the key schedule was described in Sec. 3.5.
16
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.2 K EY E XPANSION()
K EY E XPANSION() is a routine that is applied to the key to generate 4 ∗ (Nr + 1) words. Thus,
four words are generated for each of the Nr + 1 applications of A DD ROUND K EY() within the
specifcation of C IPHER(), as described in Section 5.1.4. The output of the routine consists of a
linear array of words, denoted by w[i], where i is in the range 0 ≤ i < 4 ∗ (Nr + 1).
K EY E XPANSION() invokes 10 fxed words denoted by Rcon[ j] for 1 ≤ j ≤ 10. These 10 words
are called the round constants. For AES-128, a distinct round constant is called in the generation
of each of the 10 round keys. For AES-192 and AES-256, the key expansion routine calls the
frst eight and seven of these same constants, respectively. The values of Rcon[ j] are given in
hexadecimal notation in Table 5:
j Rcon[ j] j Rcon[ j]
1 [01,00,00,00] 6 [20,00,00,00]
2 [02,00,00,00] 7 [40,00,00,00]
3 [04,00,00,00] 8 [80,00,00,00]
4 [08,00,00,00] 9 [1b,00,00,00]
5 [10,00,00,00] 10 [36,00,00,00]
The value of the left-most byte of Rcon[ j] in polynomial form is x j−1 . Note that for j > 0, these
bytes may be generated by successively applying X T IMES() to the byte represented by x j−1 (see
Eq. 4.5).
Two transformations on words are called within K EY E XPANSION(): ROT W ORD() and S UB -
W ORD(). Given an input word represented as a sequence [a0 , a1 , a2 , a3 ] of four bytes,
and
The expansion of the key proceeds according to the pseudocode in Alg. 2. The frst Nk words of
the expanded key are the key itself. Every subsequent word w[i] is generated recursively from the
preceding word, w[i − 1], and the word Nk positions earlier, w[i − Nk], as follows:
• If i is a multiple of Nk, then w[i] = w[i − Nk] ⊕ S UB W ORD(ROT W ORD(w[i − 1])) ⊕
Rcon[i/Nk].
• For AES-256, if i + 4 is a multiple of 8, then w[i] = w[i − Nk] ⊕ S UB W ORD(w[i − 1]).
• For all other cases, w[i] = w[i − Nk] ⊕ w[i − 1].
17
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.3 I NV C IPHER()
To implement I NV C IPHER(), the transformations in the specifcation of C IPHER() (Section 5.1)
are inverted and executed in reverse order. The inverted transformations of the state — denoted
by I NV S HIFT ROWS(), I NV S UB B YTES(), I NV M IX C OLUMNS(), and A DD ROUND K EY() — are
described in Sections 5.3.1–5.3.4.
I NV C IPHER() is described in the pseudocode in Alg. 3, where the array w denotes the key
schedule, as described in Section 5.2.
18
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Figure 6. K EY E XPANSION() of AES-128 to generate the words w[i] for 4 ≤ i < 44, where l
ranges over the multiples of 4 between 0 and 36
19
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Figure 7. K EY E XPANSION() of AES-192 to generate the words w[i] for 6 ≤ i < 52, where l
ranges over the multiples of 6 between 0 and 42
20
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Figure 8. K EY E XPANSION() of AES-256 to generate the words w[i] for 8 ≤ i < 60, where l
ranges over the multiples of 8 between 0 and 48
21
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
I NV S HIFT ROWS() is illustrated in Figure 9. In that representation of the state, the effect is to
move each byte by r positions to the right in the row, cycling the right-most r bytes around to the
left end of the row. The frst row, where r = 0, is unchanged.
22
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.3.2 I NV S UB B YTES()
I NV S UB B YTES() is the inverse of S UB B YTES(), in which the inverse of SB OX(), denoted by
I NV SB OX(), is applied to each byte of the state. I NV SB OX() is derived from Table 4 by switching
the roles of inputs and outputs, as presented in Table 6:
Table 6. I NV SB OX(): substitution values for the byte xy (in hexadecimal format)
y
0 1 2 3 4 5 6 7 8 9 a b c d e f
0 52 09 6a d5 30 36 a5 38 bf 40 a3 9e 81 f3 d7 fb
1 7c e3 39 82 9b 2f ff 87 34 8e 43 44 c4 de e9 cb
2 54 7b 94 32 a6 c2 23 3d ee 4c 95 0b 42 fa c3 4e
3 08 2e a1 66 28 d9 24 b2 76 5b a2 49 6d 8b d1 25
4 72 f8 f6 64 86 68 98 16 d4 a4 5c cc 5d 65 b6 92
5 6c 70 48 50 fd ed b9 da 5e 15 46 57 a7 8d 9d 84
6 90 d8 ab 00 8c bc d3 0a f7 e4 58 05 b8 b3 45 06
7 d0 2c 1e 8f ca 3f 0f 02 c1 af bd 03 01 13 8a 6b
x
8 3a 91 11 41 4f 67 dc ea 97 f2 cf ce f0 b4 e6 73
9 96 ac 74 22 e7 ad 35 85 e2 f9 37 e8 1c 75 df 6e
a 47 f1 1a 71 1d 29 c5 89 6f b7 62 0e aa 18 be 1b
b fc 56 3e 4b c6 d2 79 20 9a db c0 fe 78 cd 5a f4
c 1f dd a8 33 88 07 c7 31 b1 12 10 59 27 80 ec 5f
d 60 51 7f a9 19 b5 4a 0d 2d e5 7a 9f 93 c9 9c ef
e a0 e0 3b 4d ae 2a f5 b0 c8 eb bb 3c 83 53 99 61
f 17 2b 04 7e ba 77 d6 26 e1 69 14 63 55 21 0c 7d
23
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
5.3.3 I NV M IX C OLUMNS()
I NV M IX C OLUMNS() is the inverse of M IX C OLUMNS(). In particular, I NV M IX C OLUMNS()
multiplies each of the four columns of the state by a single fxed matrix, as described in Section 4.3,
with its entries taken from the following word:
Thus, ⎡0 ⎤ ⎡ ⎤⎡ ⎤
s0,c 0e 0b 0d 09 s0,c
⎢s01,c ⎥ ⎢09 0e 0b ⎥ ⎢s1,c ⎥
0d⎥ ⎢ ⎥
⎢ 0 ⎥=⎢
⎣s2,c ⎦ ⎣0d for 0 ≤ c < 4. (5.14)
09 0e 0b⎦ ⎣s2,c ⎦
s03,c 0b 0d 09 0e s3,c
As a result of this matrix multiplication, the four bytes in a column are replaced by the following:
5.3.5 E Q I NV C IPHER()
Several properties of the AES algorithm allow for an alternative specifcation of the inverse of
C IPHER(), called the equivalent inverse cipher, denoted by E Q I NV C IPHER(). In the specifcation
of E Q I NV C IPHER(), the transformations of the round function of the cipher in Alg. 1 are directly
replaced by their inverses in E Q I NV C IPHER(), in the same order. The effciency of this structure
in comparison to the specifcation of I NV C IPHER() in Alg. 3 is explained in the Rijndael proposal
document [2].
The pseudocode for the equivalent inverse cipher, given in Alg. 4, uses a modifed key schedule,
denoted by the word array dw. The routine to generate dw is an extension of K EY E XPANSION(),
denoted by K EY E XPANSION EIC(), whose pseudocode is given in Alg. 5.
24
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
The frst and last round keys in dw are the same as in w; the modifcation of the other round keys
is described in Lines 19–22. The comment in Line 21 refers to the input to I NV M IX C OLUMNS():
the one-dimensional array of words is converted to a two-dimensional array of bytes, as in Fig. 1.
25
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
6. Implementation Considerations
6.1 Key Length Requirements
An implementation of the AES algorithm shall support at least one of the three key lengths
specifed in Sec. 5: 128, 192, or 256 bits (i.e., Nk = 4, 6, or 8, respectively). Implementations
may optionally support two or three key lengths, which may promote the interoperability of
algorithm implementations.
26
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
27
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
References
[1] James Nechvatal, Elaine Barker, Lawrence Bassham, William Burr, Morris Dworkin, James
Foti, and Edward Roback. Report on the Development of the Advanced Encryption Standard
(AES). Journal of Research of NIST (NIST JRES), May 2001. https://doi.org/10.6028/jres.
106.023.
[2] Joan Daemen and Vincent Rijmen. AES Proposal: Rijndael Document
Version 2. AES Algorithm Submission, September 1999. Available at
https://csrc.nist.gov/csrc/media/projects/cryptographic-standards-and-guidelines/
documents/aes-development/rijndael-ammended.pdf.
[3] Joan Daemen and Vincent Rijmen. The Design of Rijndael - The Advanced Encryption
Standard (AES), Second Edition. Information Security and Cryptography. Springer, 2020.
https://doi.org/10.1007/978-3-662-60769-5.
[4] Michael Artin. Algebra. Pearson Modern Classic. Pearson, second edition, 2017.
[5] Alfred J. Menezes, Scott A. Vanstone, and Paul C. Van Oorschot. Handbook of Applied Cryp-
tography. CRC Press, Inc., USA, 1st edition, 1997. https://doi.org/10.1201/9780429466335.
[6] Elaine Barker, Allen Roginsky, and Richard Davis. Recommendation for Cryptographic
Key Generation. (National Institute of Standards and Technology, Gaithersburg, MD), NIST
Special Publication (SP) 800-133, Rev. 2, June 2020. https://doi.org/10.6028/NIST.SP.
800-133r2.
[7] National Institute of Standards and Technology. AES Development, 2022. Available at
https://csrc.nist.gov/projects/aes.
[8] National Institute of Standards and Technology. Cryptographic Standards and Guide-
lines: Examples with Intermediate Values, 2022. Available at https://csrc.nist.gov/projects/
cryptographic-standards-and-guidelines/example-values.
[9] National Institute of Standards and Technology. Crypto Publications Review Board, 2022.
Available at https://csrc.nist.gov/projects/crypto-publication-review-project.
[10] Nicky Mouha. Review of the Advanced Encryption Standard. (National Institute of
Standards and Technology, Gaithersburg, MD), NIST Interagency Report (IR) 8319. https:
//doi.org/10.6028/NIST.IR.8319.
28
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
w[i] =
i After After Rcon[i/Nk] After XOR w[i − Nk]
temp temp ⊕
(dec) R O T W O R D () S U B W O R D () with Rcon
w[i − Nk]
29
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Key = 8e 73 b0 f7 da 0e 64 52 c8 10 f3 2b
80 90 79 e5 62 f8 ea d2 52 2c 6b 7b
for Nk = 6, which results in
w[i] =
i After After Rcon[i/Nk] After XOR w[i − Nk]
temp temp ⊕
(dec) R O T W O R D () S U B W O R D () with Rcon
w[i − Nk]
31
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Key = 60 3d eb 10 15 ca 71 be 2b 73 ae f0 85 7d 77 81
1f 35 2c 07 3b 61 08 d7 2d 98 10 a3 09 14 df f4
for Nk = 8, which results in
32
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
33
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
Input = 32 43 f6 a8 88 5a 30 8d 31 31 98 a2 e0 37 07 34
Key = 2b 7e 15 16 28 ae d2 a6 ab f7 15 88 09 cf 4f 3c
The Round Key values are taken from the Key Expansion example in Appendix A.1.
32 88 31 e0 2b 28 ab 09
43 5a 31 37 7e ae f7 cf
input
f6 30 98 07 15 d2 15 4f
a8 8d a2 34 16 a6 88 3c
19 a0 9a e9 d4 e0 b8 1e d4 e0 b8 1e 04 e0 48 28 a0 88 23 2a
3d f4 c6 f8 27 bf b4 41 bf b4 41 27 66 cb f8 06 fa 54 a3 6c
1
e3 e2 8d 48 11 98 5d 52 5d 52 11 98 81 19 d3 26 fe 2c 39 76
be 2b 2a 08 ae f1 e5 30 30 ae f1 e5 e5 9a 7a 4c 17 b1 39 05
a4 68 6b 02 49 45 7f 77 49 45 7f 77 58 1b db 1b f2 7a 59 73
9c 9f 5b 6a de db 39 02 db 39 02 de 4d 4b e7 6b c2 96 35 59
2
7f 35 ea 50 d2 96 87 53 87 53 d2 96 ca 5a ca b0 95 b9 80 f6
f2 2b 43 49 89 f1 1a 3b 3b 89 f1 1a f1 ac a8 e5 f2 43 7a 7f
aa 61 82 68 ac ef 13 45 ac ef 13 45 75 20 53 bb 3d 47 1e 6d
8f dd d2 32 73 c1 b5 23 c1 b5 23 73 ec 0b c0 25 80 16 23 7a
3
5f e3 4a 46 cf 11 d6 5a d6 5a cf 11 09 63 cf d0 47 fe 7e 88
03 ef d2 9a 7b df b5 b8 b8 7b df b5 93 33 7c dc 7d 3e 44 3b
48 67 4d d6 52 85 e3 f6 52 85 e3 f6 0f 60 6f 5e ef a8 b6 db
6c 1d e3 5f 50 a4 11 cf a4 11 cf 50 d6 31 c0 b3 44 52 71 0b
4
4e 9d b1 58 2f 5e c8 6a c8 6a 2f 5e da 38 10 13 a5 5b 25 ad
ee 0d 38 e7 28 d7 07 94 94 28 d7 07 a9 bf 6b 01 41 7f 3b 00
e0 c8 d9 85 e1 e8 35 97 e1 e8 35 97 25 bd b6 4c d4 7c ca 11
92 63 b1 b8 4f fb c8 6c fb c8 6c 4f d1 11 3a 4c d1 83 f2 f9
5
7f 63 35 be d2 fb 96 ae 96 ae d2 fb a9 d1 33 c0 c6 9d b8 15
e8 c0 50 01 9b ba 53 7c 7c 9b ba 53 ad 68 8e b0 f8 87 bc bc
34
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
f1 c1 7c 5d a1 78 10 4c a1 78 10 4c 4b 2c 33 37 6d 11 db ca
00 92 c8 b5 63 4f e8 d5 4f e8 d5 63 86 4a 9d d2 88 0b f9 00
6
6f 4c 8b d5 a8 29 3d 03 3d 03 a8 29 8d 89 f4 18 a3 3e 86 93
55 ef 32 0c fc df 23 fe fe fc df 23 6d 80 e8 d8 7a fd 41 fd
26 3d e8 fd f7 27 9b 54 f7 27 9b 54 14 46 27 34 4e 5f 84 4e
0e 41 64 d2 ab 83 43 b5 83 43 b5 ab 15 16 46 2a 54 5f a6 a6
7
2e b7 72 8b 31 a9 40 3d 40 3d 31 a9 b5 15 56 d8 f7 c9 4f dc
17 7d a9 25 f0 ff d3 3f 3f f0 ff d3 bf ec d7 43 0e f3 b2 4f
5a 19 a3 7a be d4 0a da be d4 0a da 00 b1 54 fa ea b5 31 7f
41 49 e0 8c 83 3b e1 64 3b e1 64 83 51 c8 76 1b d2 8d 2b 8d
8
42 dc 19 04 2c 86 d4 f2 d4 f2 2c 86 2f 89 6d 99 73 ba f5 29
b1 1f 65 0c c8 c0 4d fe fe c8 c0 4d d1 ff cd ea 21 d2 60 2f
ea 04 65 85 87 f2 4d 97 87 f2 4d 97 47 40 a3 4c ac 19 28 57
83 45 5d 96 ec 6e 4c 90 6e 4c 90 ec 37 d4 70 9f 77 fa d1 5c
9
5c 33 98 b0 4a c3 46 e7 46 e7 4a c3 94 e4 3a 42 66 dc 29 00
f0 2d ad c5 8c d8 95 a6 a6 8c d8 95 ed a5 a6 bc f3 21 41 6e
eb 59 8b 1b e9 cb 3d af e9 cb 3d af d0 c9 e1 b6
40 2e a1 c3 09 31 32 2e 31 32 2e 09 14 ee 3f 63
10
f2 38 13 42 89 07 7d 2c 7d 2c 89 07 f9 25 0c 0c
1e 84 e7 d2 72 5f 94 b5 b5 72 5f 94 a8 89 c8 a6
39 02 dc 19
25 dc 11 6a
output
84 09 85 0b
1d fb 97 32
35
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
36
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
37
FIPS 197 A DVANCED E NCRYPTION S TANDARD (AES)
38