# using a hashed IV for AES128-CBC

I would like to minimize the encrypted packet size. Is it possible to derive the IV from a non-repeatable counter? For example, take a 32 bit counter, hash it with a key (different from the AES key), and then use the result as a 128 bit IV. The counter will increment on each packet, and not recycle during the lifetime of the key. Then I could send the 32 bit of the counter, instead of the whole 128 bit IV, and if the transmitter and receiver are in sync, then there is even no need to transmit the counter at all.

Is it a reasonable solution?

• I guess this boils down to "Does a 32 bit counter provide sufficient entropy for an AES-CBC?". Great question! (NIST SP800-38a doesn't seem to mention this) Oct 16, 2018 at 11:26
• @MikeOunsworth Looks to me like the entropy would come from the "IV hashing key" (though of course HMAC would be better than a homemade keyed hash construction). I know the IV in TLS is implicit, but I don't remember exactly how it's done, that might be something to look at. Oct 16, 2018 at 12:18
• @AndrolGenhald That would depend how frequently the HMAC key is being changed, right? On first reading I assumed it was a static key, therefore not adding entropy from one IV to the next. Oct 16, 2018 at 12:21
• @AndrolGenhald Yeah, definitely a question for the crypto folks. If the goal is to be unpredictable then I agree with you, but I think that for IVs the goal is to never repeat an IV, in which case a 32-bit counter gives you 2^32 unique IVs, regardless of how you hash it. Oct 16, 2018 at 12:36
• @MikeOunsworth Sometimes they're used interchangeably, but I prefer to distinguish between a nonce (used in CTR mode) and an IV (used in CBC mode). Nonces must be used once, IVs must be both unpredictable and also used once. I think you can get an IV by HMACing a nonce (provided the HMAC key remains secret of course). With a 32 bit counter it might also be a good idea to make sure it fails rather than wrapping around and reusing IVs, just in case. Oct 16, 2018 at 18:51