views:

113

answers:

1

There are two algorithms presented in the web.

In both the algorithms, the first part is the same...

 1. Pad the last partial plaintext block
    with 0.

 2. Encrypt the whole padded plaintext
    using the standard CBC mode.

 3. Swap the last two ciphertext blocks.

 4. Truncate the ciphertext to the length of the original plaintext

However for decryption, there are two methods... I really dunno which one is correct This one was taken from here

1. If the ciphertext length is not a multiple of the block size, say it is n bits short, then pad it with the last n bits of the block cipher decryption of the last full ciphertext block.
2. Swap the last two ciphertext blocks.
3. Decrypt the ciphertext using the Cipher Block Chaining mode.
4. Truncate the plaintext to the length of the original ciphertext.

Is this the correct decryption procedure? Will this reverse what happened in the first encryption part?

I am confused as the Wikipedia Article has the same encryption procedure but the decryption is different

Can a cryptographic expert shed some light on me? Thanx a lot in advance :)

+2  A: 

The two descriptions seem equivalent. Steps 1 and 2 of the wikipedia article are equivalent to the first step of the other article. Wikipedia is a bit more formal.

deinst
Thank deinst. But Wikipedia says to decrypt using zeros as IV. But the other article doesn't seem to mention anything about using 0's as the IV. Am i missing something important here?
Ranhiru Cooray
You will note that CBC decryption with an initial vector of 0 is identical to block cipher decryption. Note the preceding paragraph on wikipedia, particularly : "For CBC ciphertext stealing, there is a clever (but opaque) method of implementing the described ciphertext stealing process using a standard CBC interface."The section before that has a 7 step procedure, more in line with the other description.
deinst