Reputation: 921
Server side is using AES/ECB/PKCS5Padding mode of encryption and in client side (mobile)is it possible to decrypt it with AES/CBC/PKCS5Padding .or we need to use same mode for both server and client side?
Please advise.
Upvotes: 0
Views: 599
Reputation: 61952
ECB and CBC modes are inherently different (wikipedia). ECB simply applies the block cipher on every plaintext block with the key separately, but CBC XORs the current plaintext block with the last ciphertext block.
Exactly the same mode and padding is needed to decrypt in one go. If you have access to AES/CBC/NoPadding
, but not AES/ECB/PKCS5Padding
or AES/ECB/NoPadding
, you can decrypt AES/ECB/PKCS5Padding
-encrypted data by decrypting every block separately.
ECB is a mode where every block is encrypted in exactly the same way and not chained with the previous block like in CBC mode. So you can use CBC mode to decrypt every single block separately which results in ECB mode. The IV must be set to 0x00 bytes and the last block must be decrypted with AES/CBC/PKCS5Padding
and a zero IV.
Upvotes: 2