Home / Knowledge hub / Initialisation vector (IV)
Knowledge hub
Initialisation vector (IV)
A starting value that makes the same data encrypt differently each time.
What it means
An initialisation vector, or IV, is an extra input to an encryption mode. It is not a key and it is not secret. Its job is to make sure that encrypting the same message twice with the same key gives two different results.
Without it, patterns survive encryption. Two identical records produce two identical blocks of ciphertext, and anyone looking can see the repeat without breaking anything. NIST SP 800-38A describes the IV as a data block used to start the mode, and it sets out which modes need one.
Why it matters
Get the IV wrong and the encryption you paid for leaks. Repeated or guessable values let an outsider spot matching records, work out which fields changed, or in some modes recover the plaintext. The data is still "encrypted", so audits and dashboards show a tick.
It is also an easy flaw to hide. The code runs, round trips work, and nothing fails visibly. The error sits in a line that sets the IV to zeros or to a constant. It is a cryptographic weakness that encryption at rest claims quietly depend on.
How it shows up
You meet IVs wherever data is encrypted by your own code or by a library you configure: stored files, database fields, tokens, backups and messages. The IV is normally stored beside the ciphertext, because the reader needs it to decrypt. Hiding it adds nothing.
The rules differ by mode. For CBC the IV must be unpredictable. For GCM and CTR it must never repeat under the same key, which is covered under nonce reuse. The mistakes: a hardcoded IV, a counter that resets on restart, and using the key itself as the IV. Read how each encrypt call builds its IV.
Questions people ask
Initialisation vector (IV), answered
Does an IV have to be secret?
No. It is normally stored or sent alongside the ciphertext, because the recipient needs it to decrypt. What matters is that it is unique, and for some modes unpredictable.
Treat it as public and keep the key secret.
Is an IV the same as a nonce?
They are close cousins. A nonce is a value used once. Some modes call their input an IV and require it to be a nonce, meaning it never repeats under one key.
CBC wants an unpredictable IV; GCM wants a unique one. The name matters less than the rule for your mode.
Is an IV the same as a salt?
No, though both are random values stored in the open. A salt is added to a password before hashing so equal passwords give different hashes. An IV is an input to encryption.
See salt for the hashing side.
Can we use the same IV for every record if the key is different?
Technically a different key per record avoids the problem, but few systems really do that. If the key is shared, a fixed IV repeats under it, which is the weak case.
Generate a fresh IV for every encryption and store it with the output.
How long should an IV be?
It depends on the algorithm and mode. AES uses 128-bit blocks, so a CBC IV is 16 bytes. For GCM, NIST recommends a 96-bit IV and gives the rules for other lengths.
Use the library default for your mode rather than inventing a size.
Related
Terms that sit next to this one
Nonce reuse
Using a single-use value twice, which can break the encryption or the check built on it.
Nonce
A value issued for a single use, so it cannot be replayed later.
Symmetric encryption
Encryption where the same secret key locks and unlocks the data.
AES-GCM
A widely used encryption mode that also detects tampering with the data.
Encryption at rest
Stored data scrambled so a stolen disk is useless without the key.
Is your encryption really varying?
We look for the places where your app encrypts or signs data and check whether the values around it can be repeated or predicted. Each finding comes with the request and response we saw. Book a pilot on one app.
Or start with a $199 pilot on one application: thirty days, success criteria agreed before day one, credited against the annual if you convert.