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 :)