What will I get if I "decrypt" a plaintext?

"Encryption" is a large term. In all generality, encryption takes an input message in some space of possible input messages; usually arbitrary "sequences of bits" with various restrictions on length, e.g. "length in bits must be a multiple of 8" (i.e. input must be a sequence of bytes), or "length must not exceed 245 bytes" (typical of asymmetric encryption with RSA in PKCS#1 v1.5 mode, with a 2048-bit RSA key). The output is al part of some space of possible output messages.

Computers being computers, both input and output messages are ultimately encoded in sequences of bits, so it may happen that input and output message spaces overlap, in which case you can conceptually take an input message (a "plaintext"), interpret it as an output message, and try to decrypt it. This is not necessarily possible: for instance, with RSA asymmetric encryption (PKCS#1 v1.5) and a 2048-bit key, input messages (plaintexts) are arbitrary sequences of 0 to 245 bytes (inclusive) while output messages (ciphertexts) are sequences of exactly 256 bytes, so it is not possible, in such a case, to try to "decrypt a plaintext": possible plaintexts are not long enough to feed the decryption engine.

When you can "decrypt a plaintext", what happens depends on the encryption system. Usually, when decryption works at all, what you get is essentially random-looking nonsense. In some cases, encryption is an involution (e.g. stream ciphers such as RC4 that work by XORing the message with a key-dependent stream), meaning that decryption and encryption are actually the same operation, so by "decrypting" the plaintext you are actually encrypting it.

However, it may also happen that not all sequences of bits of the right length are valid ciphertexts. For instance, consider a block cipher in CBC mode. To encrypt a message m, you must:

  1. Pad the message to a length multiple of the block size, by appending between 1 and n bytes (n is the block size) with some specific contents.

  2. Generate a new random IV of the same size as the block size.

  3. Apply CBC encryption on the padded message, using that IV.

  4. Output is the concatenation of the IV and the encryption result.

In such a case, when decrypting, not only must the length be a non-zero multiple of the block size, but after decryption, a valid padding must be found. If using the usual "PKCS#7 padding" (when adding k bytes, all added bytes have value exactly k), the probability that a plaintext of a compatible length actually decrypts to something with a valid padding is about 1/255. In that case, "decrypting the plaintext" will produce a decryption error 99.61% of the time, and some random-looking junk the remaining 0.39%.

Good encryption system include a MAC, in which case attempting to decrypt something which was not the result of encryption with the same key should result in a duly reported decryption error with overwhelming probability.

Summary: when you try to do something that does not make sense, you can obtain various results.


It depends on what cipher you use. For example, with the famous and very secure (sarcasm) ROT13 algorithm, encryption and decryption are the same operation. If you decrypt a plaintext, actually, you just encrypted it.

With a more modern cipher like AES, you will likely get a big nonsensical number. I think it will be the same for most ciphers.

Tags:

Decryption