# Algorithm to transform plaintext to a key of desired keysize, when using input plaintext as key for FPE?

Using a format preserving encryption scheme that uses AES internally as its block cipher, for a plaintext that I encrypt I want to use that input plaintext as the key.

However using AES-128, my keysize is required to be 128 bit. But i cannot guarantee my plaintext to be exactly this length - they are words or numbers of variable length.

Is there a computationally efficient and acceptably secure way to convert the plaintext to exactly the keysize required by the AES algorithm? Does it even matter what algorithm I use?

EDIT: The FPE I'm using is BPS. I'm using it as a one way encryption on plaintext values such as SSN, names, dates, etc. (Note: not using this for any authentication purposes - merely trying to eliminate the need to store or reuse a single key - I also have no need to use a single key anyway because I have no need to decrypt the original plaintext)

EDIT 2: Although it is convenient in the sense that this approach doesn't require storing a key anywhere I realize now that using the input plaintext as key is flawed especially for smaller plaintext which the attacker can brute force rather trivially. This is definitely not the way the FPE was designed to be used.

• What's the point of using the plaintext as the key? Doesn't that mean that you can't decrypt it unless you already know the decryption? Or, are you just looking to find a noninvertable transform of the plaintext? Oct 21, 2015 at 21:54
• @poncho Yes that is what I am doing. I'm using my FPE as a non invertible transform of the plaintext. Therefore no decryption wanted. Oct 21, 2015 at 23:03
• It seems to me that you are aiming at a authentication tag of the same size as the output. I'm not sure that this is actually feasible. If you use different key and plaintext you are certain to run into collisions. You could use HKDF-expand or even a password hash to increase the plaintext to the given key size, but that would not necessarily make the scheme secure. Oct 22, 2015 at 18:40
• @MaartenBodewes I'm not sure what to do now. Is the problem because my output from the FPE will have collisions due to my changing the key for every plaintext? Oct 22, 2015 at 20:47
• Depends on the amount of plaintext and the size of the plaintext. But FPE is Format Preserving Encryption, I'm not sure but you could be stepping outside the boundaries here. Oct 22, 2015 at 20:51