Take the 2-minute tour ×
Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. It's 100% free, no registration required.

I am trying to implement an FPE for a 19-digit long number. I am trying to follow the lecture of Prof. Dan Boneh and here is how I understand it:

  1. Get the nearest power of two greater than $10^{19} \rightarrow 2^{64}$,
  2. Get the binary representation of the 19-digit number,
  3. Split the 64-bit long binary representation into two 32-bit for Feistel network,
  4. Perform 7 rounds of Feistel network with AES (PRF),

    • pad zeroes to left of 32-bit until 128 bits for AES,
    • truncate cipherText obtained to the 32 Least significant bits for Feistel XOR and next rounds,
  5. Convert the output of the Feistel network to Decimal and check if it is in the range of $0 - 10^{19}$ (some values are between $10^{19}$ and $2^{64}$), if not perform Feistel on the cipher text until it is within the range.

I am trying to do pad-encrypt-truncate for step 4 but I was not able to recover the plaintext from the truncated ciphertext. I am doing these decrypt steps right now:

  1. Pad zeroes to the left of the 32-bit ciphertext (truncated) until 128-bits,
  2. Decrypt using AES,
  3. Truncate to Least Significant 32 bits (this is different from the ciphertext).
share|improve this question
    
Truncation is not reversible. These truncated values are only used in the Feistel network. The feistel network ensures reversibility even when using a non reversible function. –  CodesInChaos Aug 20 at 12:12
    
You might want to take a look at FFX mode which uses a pretty similar principl. –  CodesInChaos Aug 20 at 12:14
    
Thanks for the info. I'll look into FFX later. For now, how should I implement the decryption algo for the FPE I used above? I am still trying to learn the basic :D –  Frank Smith Aug 20 at 12:21
    
Read the Feistel network article I linked. –  CodesInChaos Aug 20 at 12:23
1  
Yes, changing the AES key round would suffice, but (IMHO) is more heavy weight than you need. Instead, I would suggest you put the round index into the (currently zero) padding you use to pad out the 32-bit into a full 128 bits. –  poncho Aug 20 at 15:52

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.