# AES CBC: how shall i get to know with AES CBC method, the received Cipher Text is padded or not [closed]

Algorithm: AES - CBC mode with PKCS7 padding

KeyValue:

10a58869d74be5a374cf867cfb473859


IV:

00000000000000000000000000000000


Plaintext:

00000000000000000000000000000000


Expected ciphertext:

6d251e6944b051e04eaa6fb4dbf78465


Three steps are used to compute the CBC Encrypt as mentioned below:

CBC_Start(Key,IV)
CBC_Update(Plaintext, plaintext length, Ciphertext, Ciphertextlength)
CBC_Finish(Ciphertext, Ciphertextlength)


Ciphertext is obtained when the update is finished, but when finish is completed, the ciphertext obtained is different from what is expected.

Why is this happening?

• It looks like you are trying to use some specific crypto-library. Could you tell us which one? – Paŭlo Ebermann Mar 30 '18 at 9:17
• APIs that use the init,update,finish model require that the calls use output buffers that do not overlap and in particular are not exactly the same. The method for doing this varies (wildly) depending on the language you are using, which you didn't state and anyway is offtopic as noted. – dave_thompson_085 Mar 31 '18 at 4:28

Your expected ciphertext is correct if you work with no padding. With PKCS padding the result is 6D251E6944B051E04EAA6FB4DBF78465881572C3A96A612C111055707BD7614E
As gammatester said, the ciphertext you're expecting is correct if you don't use any padding. When using a padding, if you try to encrypt a 16 bytes long message, it will append a full block of padding to your plaintext before the encryption start. Basically, you're encrypting 0000000000000000000000000000000010101010101010101010101010101010 instead of the given plaintext.