Cryptography Stack Exchange is a question and answer site for software developers, mathematicians and others interested in cryptography. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm using a 64-bit nonce (incremented between the streams) and a 64-bit counter (incremented within a stream) for AES in CTR mode. How many different key streams can I produce with this setup?

share|improve this question
Do you mean how many different keystreams or how many bits (or bytes) in a single keystream (for a fixed nonce and key)? – mikeazo Jul 31 '12 at 13:05
how many different keystreams – goldroger Jul 31 '12 at 13:37
Is the key fixed? Is the nonce incremented for each stream, or does it get chosen randomly? – CodesInChaos Jul 31 '12 at 14:11
@CodesInChaos, the key is fixed, the nonce incremented for each stream.. ex: this is my nonce = aaaaaaaaaaaaaaaa this is the counter = 0000000000000001 in the next stream the counter will increment, 0000000000000002 – goldroger Jul 31 '12 at 14:41
up vote 3 down vote accepted

The number of different key streams depends on the keysize used and the number of bits in the nonce. Say you are using an $n$ bit key and $k$ bits for your nonce. Then the theoretical maximum number of keystreams is $2^n\cdot 2^k=2^{n+k}$ since each combination of nonce and key should result in a different keystream.

If you limit the length of your keystreams, however, this changes. Say you only want $128$-bit keystreams, but you use a $256$-bit key and a $64$-bit nonce. There will only be $2^{128}$ different key streams.

So, if your keystreams are $s$ bits long, you use an $n$ bit key, and a $k$ bit nonce, then really, the number of possible key streams is $\min(2^{s}, 2^{n+k})=2^{\min(s,n+k)}$.

Based on the comment that the key is fixed, this changes the analysis. Since there is only one key it becomes $\min(2^{s}, 2^{k})=2^{\min(s,k)}$. The above analysis if for a randomly chosen key.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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