If I encrypt a message once using AES CTR, will I need an IV? Additionally, if I do use an IV, will I need to send it with the cipher text?


Yes, you need an IV in CTR mode and you do need to send it with the ciphertext, or at least make it possible for the encryption process to know it. Specifically, you need a nonce. The nonce can be anything, as long as it is unique so no key:nonce tuple ever repeats. The nonce is part of the counter. CTR mode operates by encrypting this value and XORing the result with the plaintext. When the next block is to be encrypted, the value is incremented by one and the process repeats.

CTR encryption

  • $\begingroup$ So CTR will not result in producing a same size message correct. It will generate a cipher text of the same size, but the message that is sent will end up being larger since it must include the IV correct? $\endgroup$ – Mike Sep 4 '18 at 7:34
  • $\begingroup$ @Mike The way you transmit the IV doesn't usually matter. It can be sent with the ciphertext, or with the key. How it is sent is implementation-specific. When it comes to CTR mode itself, it takes plaintext of arbitrary size and outputs ciphertext of the same size, or vice versa. In fact, you can even use an all-zero nonce, as long as you never, ever re-use a single key. All that matters is that the nonce is only used once for each key's keystream. $\endgroup$ – forest Sep 4 '18 at 7:36
  • 1
    $\begingroup$ All modes exception ECB require the receiver to know the IV. If you use a different key for each message then you can use the same IV with most modes (NOT CBC!). Or you can use one key and multiple IVs and transmit the IV each time, but either the key or the IV or both must be made known to the receiver. $\endgroup$ – Swashbuckler Sep 4 '18 at 15:19
  • $\begingroup$ @Swashbuckler Sure, but each mode has different requirements from their IV. $\endgroup$ – forest Sep 4 '18 at 19:26

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.