1

If I have a 16-number sequence (7,7,7,....7), and I need to encrypt this using a simple 4-bit substitution cipher, do I have to "chop" the plaintext in blocks which are of same size as the IV?

In my situation the IV is specified as having to be exactly 4 bits. Let's say it's 1001.

So my plaintext is 001101110111,.....,0011.

When I start, I say 'IV' XOR '4bit plaintext' hence ==> 1001 XOR 0011 = 1010 which corresponds to 10 in decimal. If I look up 10 in my substitution cipher it corresponds to 9, so 1001 is the corresponding ciphertext C1.

Then I continue by XORing the next 4bit plaintext (the same as before) with C1 and so on.

The one thing that is not clear to me is whether I'm doing the right thing by dividing my plaintext into 4bits because the IV has to be 4 bits as well?

2

In CBC mode, the IV is ALWAYS the same size as the block size used by your encryption algorythm.

Thus, if you use AES, your IV will have to be of exactly 128 bits, regardless of the size of the data you have to encrypt.

So, the proper way to encrypt your data in CBC mode is to:

  • Divide your data in blocks of the appropriate size (128 bits for AES) bits
  • If necessary, Add padding the last block to extend it to the block boundary.
  • Generate an IV of the same size as the block size used by the algorythm (128 bits for AES)
  • XOR your IV with the first block and apply your encryption algorythm to the result.
  • Take that first cyphertext block and XOR it with the second plaintext block.
  • Repeat.

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.