I have an application written in C, running in Linux. It uses IPsec (ESP)
(manually putting the IPSec packet together) to send certain packets. The algorithm used for encrypting the payload is 3DES-CBC
(using Libgcrypt
).
So my doubts are regarding the IV
that I have to use. For this scheme to be secure:
Is it enough to generate a random IV
?
If so, what random number generator source should I use for this? (e.g. /dev/random)
The other requirement that I noted while reading RFC 1851 is that the IV
should be 64-bit long.
Update:
NIST Recommendations for Block Cipher Modes of Operations, Appendix C [PDF] states:
There are two recommended methods for generating unpredictable IVs. The first method is to apply the forward cipher function, under the same key that is used for the encryption of the plaintext, to a nonce. The nonce must be a data block that is unique to each execution of the encryption operation. For example, the nonce may be a counter, as described in Appendix B, or a message number. The second method is to generate a random data block using a FIPS-approved random number generator.
Tried to find a list of all Linux random number generator implementations that are FIPS-approved but couldn't find much information on this.