1
$\begingroup$

I understand that for AES CBC you need to split the plaintext up into blocks and perform XOR'ing using the previous blocks calculations etc.

However, if your message is exactly 128 bits long, do you only perform the XOR with the IV and the encryption with the key once? Or is there a way to split up a 128 bit message so that you can perform the cipher block chaining method as intended.

Thanks.

$\endgroup$
1
$\begingroup$

However, if your message is exactly 128 bits long, do you only perform the XOR with the IV and the encryption with the key once? Or is there a way to split up a 128 bit message so that you can perform the cipher block chaining method as intended.

This is a non-starter, as there is nothing wrong with performing a single block encrypt in CBC mode. For 128 bits messages you don't need any padding method, even for CBC mode, but generally we try and apply PKCS#7 padding for compatibility reasons.

The XOR of the unpredictable IV with the plaintext is required, otherwise your cipher would not be able to handle identical messages without leaking information. If your 128 bit messages are unique by itself they you could just use a single block encrypt of the block cipher (the attacker would only know that no repetition is present in the messages).

$\endgroup$
0
$\begingroup$

A standard way to encrypt a message is to apply some sort of padding (PKCS #7 for instance), that converts messages of arbitrary length to a set of fixed-size plaintext blocks (16 bytes in case of AES-128). If your properly padded message is contained in one block only, you just encrypt that block.

CBC and other modes of block cipher operation do not require at least two blocks of plaintext, you can use them on just one as well.

$\endgroup$
  • $\begingroup$ The last sentence clarified for me. I'm doing an assignment where we need to explain the use of an IV in AES to make it more secure but we are only encrypting a 128 bit message. I'll have a look at the other modes now, thank you :) $\endgroup$ – Joel Moffatt Oct 2 at 7:42
  • $\begingroup$ No, IV is needed for semantic security. The last sentence is not correct. $\endgroup$ – kelalaka Oct 2 at 7:42
  • $\begingroup$ So I need to have m1 and m2 (message 1 and 2) to use an IV? $\endgroup$ – Joel Moffatt Oct 2 at 7:44
  • $\begingroup$ What will happen, later, you send the $m_1$ again? You are suggesting to use ECB mode, That is not good. $\endgroup$ – kelalaka Oct 2 at 7:45
  • $\begingroup$ @kelalaka I did not like the last sentence myself, I have changed it. $\endgroup$ – zajic Oct 2 at 7:49
0
$\begingroup$

Firstly, you need to apply a padding scheme like PKCS#5 or PKCS#7 so that your message will be always a multiple of 128. A 128-bit message than will be two-block.

However, if you have one byte less than the block size, you will have 128-bit messages this means that you have one block.

After the padding, you can encrypt with CBC mode. The first block will be x-ored with the IV. In CBC mode the IV must be unpredictable.

If you have only messages with 128-bit, you may not need the padding. if you want, you can skip the padding, just encrypt the message.

Having always one full block shouldn't put you into the ECB mode trap. ECB mode insecure and once you send a message again, you start to reveal information. You need at least Probabilistic Encryption. The better is authenticated encryption modes like AES-GCM or ChaCha-Poly1305.

$\endgroup$
  • $\begingroup$ So if I have a message (128 bits) I need to apply padding to the message to obtain another plaintext-block? Which then allows me to perform CBC with those two blocks? $\endgroup$ – Joel Moffatt Oct 2 at 7:50
  • $\begingroup$ Well, padding helps you to have always multiple of 128-bit and later, removing them. If you always 128-bit messages, you may have two options. pad or no pad. If you pad it will be 2 128-bit blocks. If you don't pad, it is just one block. $\endgroup$ – kelalaka Oct 2 at 7:53
  • $\begingroup$ Can I still do CBC with an IV on just a single 128-bit message? (if so how), or do I need to pad it to 2 128-bit blocks like you said and then do the CBC calculations with an IV. $\endgroup$ – Joel Moffatt Oct 2 at 7:54
  • $\begingroup$ I've given a simple answer here. We need probabilistic encryption. You should use IV and in the CBC mode the IV must be unpredictable. $\endgroup$ – kelalaka Oct 2 at 7:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.