ArticleslgStudy

computer science

Ciphertext stealing

Ciphertext stealing is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Ciphertext stealing rather than just read about it. In short: In cryptography, ciphertext stealing (CTS) is a general method of using a block cipher mode of operation that allows for processing of messages that are not evenly divisible into blocks without resulting in any expansion of the ciphertext, at the cost of slightly increased complexity. General characteristics Ciphertext stealing is a technique for encrypting plaintext using a block cipher, without padding the message…

Ciphertext stealing — main illustration
Ciphertext stealing — illustration

Key takeaways

  • Ciphertext stealing belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Ciphertext stealing to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Ciphertext stealing from memory before moving on to harder problems.

Reference excerpt

In cryptography, ciphertext stealing (CTS) is a general method of using a block cipher mode of operation that allows for processing of messages that are not evenly divisible into blocks without resulting in any expansion of the ciphertext, at the cost of slightly increased complexity.

General characteristics Ciphertext stealing is a technique for encrypting plaintext using a block cipher, without padding the message to a multiple of the block size, so the ciphertext is the same size as the plaintext. It does this by altering processing of the last two blocks of the message. The processing of all but the last two blocks is unchanged, but a portion of the second-to-last block's ciphertext is "stolen" to pad the last plaintext block. The padded final block is then encrypted as usual. The final ciphertext, for the last two blocks, consists of the partial penultimate block (with the "stolen" portion omitted) plus the full final block, which are the same size as the original plaintext. Decryption requires decrypting the final block first, then restoring the stolen ciphertext to the penultimate block, which can then be decrypted as usual. In principle any block-oriented block cipher mode of operation can be used, but stream-cipher-like modes can already be applied to messages of arbitrary length without padding, so they do not benefit from this technique. The common modes of operation that are coupled with ciphertext stealing are Electronic Codebook (ECB) and Cipher Block Chaining (CBC). Ciphertext stealing for ECB mode requires the plaintext to be longer than one block. A possible workaround is to use a stream cipher-like block cipher mode of operation when the plaintext length is one block or less, such as the CTR, CFB or OFB modes. Ciphertext stealing for CBC mode doesn't necessarily require the plaintext to be longer than one block. In the case where the plaintext is one block long or less, the Initialization vector (IV) can act as the prior block of ciphertext. In this case a modified IV must be sent to the receiver. This may not be possible in situations where the IV can not be freely chosen by the sender when the ciphertext is sent (e.g., when the IV is a derived or pre-established value), and in this case ciphertext stealing for CBC mode can only occur in plaintexts longer than one block. To implement CTS encryption or decryption for data of unknown length, the implementation must delay processing (and buffer) the two most recent blocks of data, so that they can be properly processed at the end of the data stream.

Ciphertext format There are several different ways to arrange the ciphertext for transmission. The ciphertext bits are the same in all cases, just transmitted in a different order, so the choice has no security implications; it is purely one of implementation convenience. The numbering here is taken from Dworkin, who describes them all. The third is the most popular, and described by Daemen and Schneier; Meyer describes a related, but incompatible scheme (with respect to bit ordering and key use).

CS1 Arguably the most obvious way to arrange the ciphertext is to transmit the truncated penultimate block, followed by the full final block. This is not convenient for the receiver for two reasons:

The receiver must decrypt the final block first in any case, and This results in the final block not being aligned on a natural boundary, complicating hardware implementations. This does have the advantage that, if the final plaintext block happens to be a multiple of the block size, the ciphertext is identical to that of the original mode of operation without ciphertext stealing.

CS2 It is often more convenient to swap the final two ciphertext blocks, so the ciphertext ends with the full final block, followed by the truncated penultimate block. This results in naturally aligned ciphertext blocks. In order to maintain compatibility with the non-stealing modes, option CS2 performs this swap only if the amount of stolen ciphertext is non-zero, i.e. the original message was not a multiple of the block size. This maintains natural alignment, and compatibility with the non-stealing modes, but requires treating the cases of aligned and unaligned message size differently.

CS3 The most popular alternative swaps the final two ciphertext blocks unconditionally. This is the ordering used in the descriptions below.

Ciphertext stealing mode description In order to encrypt or decrypt data, use the standard block cipher mode of operation on all but the last two blocks of data. The following steps describe how to handle the last two blocks of the plaintext, called Pn−1 and Pn, where the length of Pn−1 equals the block size of the cipher in bits, B; the length of the last block, Pn, is M bits; and K is the key that is in use. M can range from 1 to B, inclusive, so Pn could possibly be a complete block. The CBC mode description also makes use of the ciphertext block just previous to the blocks concerned, Cn−2, which may in fact be the IV if the plaintext fits within two blocks. For this description, the following functions and operators are used:

Head (data, a): returns the first a bits of the 'data' string. Tail (data, a): returns the last a bits of the 'data' string. Encrypt (K, data): use the underlying block cipher in encrypt mode on the 'data' string using the key K. Decrypt (K, data): use the underlying block cipher in decrypt mode on the 'data' string using the key K. XOR: Bitwise Exclusive-OR. Equivalent to bitwise addition without use of a carry bit. ||: Concatenation operator. Combine the strings on either side of the operator. 0a: a string of a 0 bits.

ECB ciphertext stealing Ciphertext stealing in ECB mode introduces an inter-block dependency within the last two blocks, resulting in altered error propagation behavior for the last two blocks.

ECB encryption steps (see figure)

… excerpt ends here. Continue reading the full article.

Illustrations

Ciphertext stealing: CipherText Stealing (CTS) on CBC, encryption mode
CipherText Stealing (CTS) on CBC, encryption mode
Ciphertext stealing: CipherText Stealing (CTS) on CBC, decryption mode
CipherText Stealing (CTS) on CBC, decryption mode

Worked examples

Example 1 — a first encounter with Ciphertext stealing

Start with the simplest possible case. Write down what Ciphertext stealing claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Ciphertext stealing before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Ciphertext stealing ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Ciphertext stealing

In research
Ciphertext stealing appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Ciphertext stealing in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Ciphertext stealing is common in secondary-school and first-year university syllabi. It links to neighbouring topics Cryptographic algorithms, so understanding it makes those chapters shorter.
In everyday life
Look for Ciphertext stealing outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Ciphertext stealing” →

How to study Ciphertext stealing in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Ciphertext stealing means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Ciphertext stealing out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Ciphertext stealing in simple terms?

In cryptography, ciphertext stealing (CTS) is a general method of using a block cipher mode of operation that allows for processing of messages that are not evenly divisible into blocks without resulting in any expansion of the ciphertext, at the cost of slightly increased complexity. General chara…

Why does Ciphertext stealing matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Ciphertext stealing?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Ciphertext stealing.

Tags

  • Cryptographic algorithms

Keep exploring