Assuming $k$ is the key (128 bit) and $m$ is the message (128 bit), how can I use the block cipher $blockenc(k,m)$ to make a stream cipher which can produce quintillion pseudo-random bits?
Assuming k is the key (128 bit) and m is the message (128 bit), how can I use the block cipher blockenc(k,m) to make a stream cipher…
Probably the easiest way to achieve that would be to use Counter Mode (CTR) as a block cipher mode of operation where the counter increases by some value, which can be but does not have to be
+1. So, to also address your comment: you could indeed increment by the number of bytes or bits you’re encrypting.
If you want to dive into CTR mode a bit more, be sure to also look at our CTR tag which lists related Q&As.
... which can produce quintillion pseudo-random bits?
It has to be noted that that will depend on the block cipher you’re using – more specifically: the block cipher security bounds. Weak block ciphers and/or block ciphers from the "lightweight crypto" category might, in some cases, reach their limits before that.
Practically, I’ll simply point to AES in CTR mode as a well-vetted and somewhat standard choice (as used, for example, in RFC 3686 – Using Advanced Encryption Standard (AES) Counter Mode With IPsec Encapsulating Security Payload (ESP)).
There are 3 modes of operation which make a stream cipher out of a block cipher:
- Cipher Feedback Mode,
- Output Feedback Mode, and
- Counter Mode.
Taking example of the Counter Mode, this is how encryption and decryption works
$$C_i = P_i \oplus BlockEnc_k(count)\\ P_i = C_i \oplus BlockEnc_k(count)$$ $count$ is increased by 1 with every byte of the stream.