I'm given a very simple 8 bit block cipher in which to encrypt plaintext x with k k one performs $ x \oplus k $. I am given IV = 0101 and a CTR of value CCCCCCCC (36bits).

My understanding is that counter mode relies on the output block size of my cipher to yield a stream key of b (in this case 8) bits which will then be XORed with my plaintext, and that the bit length of IV and counter should also be b-bits long.

Am I misunderstanding, or did my professor make a mistake with the counter and IV being 40 bits long?

To aide, here is the exact text from the assignment:

Consider a simple system with 8-bit block size. Assume the encryption (and decryption) to be a simple XOR of the key with the input. In other words, to encrypt x with k we simply perform $ x \oplus k $ giving y. Similarly to decrypt y, we perform $ y \oplus k$ giving x.

You are given the following 16-bit input. 1111000011110000 (F0F0 in hex).

You are provided IV as: 00001111 (or 0F in hex).

For CTR assume the stream of bits ot be used for counter to be "110011001100110011001100110011001100" (or CCCCCCCCC)

The key to be used (where appropriate) is 10100011 (A3 in hex).

Compute the encrypted output with (i) ECB, (ii) CBC, (iii) OFB, (iv) CFB, (v) CTR (use IV = 0101 for CTR)

  • $\begingroup$ I am confused by your description. A block cipher is a keyed map from a space into the same space, e.g. a map from 128-bit strings to 128-bit strings. An 8-bit block cipher can't possibly handle a 36-bit block counter in CTR mode; even if it is used only for a single message, so that the message number is empty, it can only handle an 8-bit block counter at most. $\endgroup$ Sep 24, 2019 at 1:05
  • 2
    $\begingroup$ I'll delete my answer. That's an assignment that has been written down horribly and your professor should feel ashamed for stating it this way. I don't have a clue what is meant with the "stream of bits" and having an IV of 0101 seems to be in direct conflict with it as well, without actually even showing how the counter should be produced. Yuck. $\endgroup$
    – Maarten Bodewes
    Sep 24, 2019 at 1:36
  • 2
    $\begingroup$ My solution to this professor's assignment: wat $\endgroup$ Sep 24, 2019 at 1:50
  • $\begingroup$ I suppose I'm relieved that the question is jacked up, and not my understanding, but I would have liked to finish the assignment. Oh well. Thanks for your help clarifying, all. $\endgroup$
    – Alex Launi
    Sep 24, 2019 at 2:15
  • 2
    $\begingroup$ Just do it at the best of your ability showing what you know. Just make assumptions on how it should be and clarify that. And, if possible, ask your prof. for clarification. This looks like practice, I can only hope that a graded test gets more attention than this. $\endgroup$
    – Maarten Bodewes
    Sep 24, 2019 at 2:16

1 Answer 1


To use the stream grab 4 bits at a time and append those to the IV 0101 (which is 4 bits) so you have an 8-bit piece to XOR against

  • yi = ((IV + CTR) Ꚛ k )Ꚛ xi
  • IV + first 4 bits of CTR : 0101 1100 Ꚛ 1010 0011 = 1111 1111
  • XOR'd against block 1: 1111 0000 Ꚛ 1111 1111 = 0000 1111
  • IV + second 4 bits of CTR : 0101 1100 Ꚛ 1010 0011 = 1111 1111
  • XOR'd against block 2: 1111 0000 Ꚛ 1111 1111 = 0000 1111

Result = 0000 1111 0000 1111 = 0F0F

  • $\begingroup$ I'm glad you are able to understand the assignment, but as this indicates how a counter should not work I think it is safe to say that it still doesn't make sense. I get that having the same counter repeat makes it less work, but sheesh.' $\endgroup$
    – Maarten Bodewes
    Nov 6, 2023 at 10:30

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