Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a length-preserving encryption scheme, that preserves the lengths of input sizes such that the length of the input plain text is same as length of the output cipher text ?

share|improve this question
It's possible to do that, but there are downsides. You should describe your additional requirements and say how you plan to use it. For example CTR mode encrypts to the same size, but it's quite likely that it'll be totally insecure in your scenario. – CodesInChaos Jan 24 '13 at 12:00
Your question is very vague. Same length encryption can't offer semantic security, but that doesn't mean its insecure for every situation. There are different approaches, with different downsides. So you need to describe your scenario so we can find one that fits for your situation. – CodesInChaos Jan 24 '13 at 12:22
Search for format preserving encryption. I'd guess the correct security model for length preserving encryption is that it's a variable length pseudo-random permutation (PRP). – CodesInChaos Jan 24 '13 at 12:30
To 100% clarify, you are looking for an encryption algorithm that maps every possible binary input with an integral number of bytes to a encrypted output of the same length. Is that correct? And you understand the inherent security problems with such an algorithm? (No defense against corruption, replay attacks, and so on.) – David Schwartz Jan 29 '13 at 1:10
-1, this question is so vague and poorly written that, even with the "clarifying" comments, it's hard for me to tell what's really being asked. Sorry, but it really is. Considering voting to close as "not a real question". – Ilmari Karonen Feb 27 '13 at 11:37

Your are looking for a encryption scheme that supports length preserving encryption. I recommend to use an authenticated encryption scheme like OCB or McOE. There are two common techniques to achieve this goal:

  1. Ciphertext Stealing
  2. Tag splitting

Note that you need at least either a nonce or authentication tag -- or better both -- to preserve data privacy, i.e., security against chosen plaintext attacks (CPA).

Maybe I got you wrong. Maybe you are looking for format-preserving encryption or something else. Hence, a more detailed problem description would be great.

share|improve this answer
I see no way for authenticated encryption to be length preserving. Length preserving encryption is obviously a bit weaker than what we can achieve by adding a nonce/IV and authentication tag, but it's still useful sometimes. – CodesInChaos Jan 28 '13 at 10:27
@CodesInChaos I am not familiar with cryptography dictionary, however I am a porgrammer somehow. I am not in a needing of a length preserving algorithm, I am trying to understand the situation of my algorithm in real world of cryptography with your precious assists with your understanding, thank you! – Digerkam Jan 29 '13 at 10:33

One could design length (and format) preserving encryption schemes using Luby Rackoff Constructions (which are based on Feistel Networks)

While there are variety of variants to achieve (especially , the FFX modes of encryption ) one more notable work is done by Naor and Reigold [1]. They introduce another layer to classic Feistel networks by using Pair-wise Independent Functions ( PWIP), which they prove to be more secure than classic version.

We have very recently re-designed their work and proposed a new, FNR mode of encryption [2] which is practical arbitrary length block cipher algorithm to do the same . One could build format-preserving-encryption using such scheme. Which is variant of Naor and Reingold's work .

[1] Naor, Moni, and Omer Reingold. "On the Construction of Pseudorandom Permutations: Luby—Rackoff Revisited." Journal of Cryptology 12.1 (1999): 29-66.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.