AES itself has three variants: AES-128, AES-192 and AES-256. Internally, the algorithms have very similar constructions. The number is the length of the key (in bits), i.e. the length of the prearranged secret (AES is a shared-secret cipher). A higher number means not only a longer key, but also more work done with the key and the input to produce the output.
Each of these three algorithms specifies two functions encrypt
and decrypt
; both functions take as input one n-bit value (n = 128, 192 or 256) called the key and one 128-bit value called the input block, and produce as output one 128-bit value called the output block. The input block to encrypt
is called the plaintext and the output block is called the ciphertext; for decrypt
, the roles are reversed.
encrypt(key, plaintext) = ciphertext
decrypt(key, ciphertext) = plaintext
AES is a block cipher. It only specifies how to encrypt or decrypt a 128-bit block. If your data is shorter or longer than that, you need something more sophisticated: you need to have a
mode of operation, often called chaining mode because it specifies how to process one block after the other. The choice of chaining mode is largely independent of the choice of block processing algorithm.
Some chaining modes only require the key and the input. For example, ECB, the simplest mode of all, only says to cut the input into blocks of the appropriate size, apply the encryption/decryption algorithm, and paste the output blocks together. This mode has many flaws (for example, you can spot repetitions in the input if they are aligned with a block boundary; you can tell whether two encrypted messages are the same because they then have the same ciphertext).
Many chaining modes require an additional piece of input, typically one block in size. It is usually mixed with the first input block in some way, and called an initialization vector (often abbreviated IV). The IV is usually chosen randomly; this is a requirement for some modes, while for others it is enough never to choose the same IV twice for the same key (which a random draw ensures). The IV serves (at least) to make two encryptions of the same plaintext with the same key distinct. A popular mode using a random IV is CBC. Another popular mode is CTR (counter); its IV is more properly called a nonce, because it does not have to be random, only non-repeated.
Breaking up the input into blocks only works when it is a multiple of the block size. Otherwise, the usual process is to split off as many blocks as possible at the beginning and apply a padding scheme to the last, partial block. Although padding tends to imply that some bits are added to make up a full block, padding securely isn't that simple: a partial block B with some padding P appended risks being confused with a full block that happens to be BP. Good padding schemes have to apply some padding to all messages, even the ones that happen to be an exact number of blocks. Some modes of operation impose a particular padding schemes, while others are padding-agnostic. Crypto libraries often require that the input to block cipher functions be only full blocks, leaving the task of padding to the caller.
There are modes that make something else than an encryption/decryption algorithm out of block ciphers. Modes such as CMAC make a message authentication code, i.e. a signature based on a shared secret. Modes such as GCM do both encryption and signature (the output of AES-n-GCM-encrypt(key, IV, tag, plaintext) is both a ciphertext and a MAC).