# How do I communicate the value of the initialization vector to the end user? Should it be part of the encrypted message?

I am taking a cryptography class and our first homework is to implement a 32-bit block cipher. I implemented a simple block-cipher that uses CBC. Currently, my implementation reads both the 32-bit IV and the 32-bit key from a key file.

However, I read that the initialization vector is generated randomly, and can be public as well. If I changed my algorithm to generate a random IV, where would I store this IV (or communicate it to the user)? Would I simply output the value of the IV to the user after I finish encrypting the message? Or could I store the initialization vector as part of the message itself (perhaps at the beginning).

Then my decryption algorithm can simply read the first 32-bits of the encrypted message, which will be the initialization vector. Is this the right way to do it?

• "to implement a 32-bit block cipher" for which a specification was given, or one chosen by you? $\hspace{.6 in}$ "a simple block-cipher that uses CBC" is possible, although it seems far more likely that you mean "CBC mode with a simple block cipher", especially since you then jump straight into talking about IVs. $\hspace{.6 in}$ – user991 Jan 28 '15 at 21:39
• Yes, the implementation is open to us. The only requirement is that it is a block-cipher and it is 32-bit. Also, I did mean "CBC mode". Sorry, I'm quite new at this and I don't have my terminology right. – Vivin Paliath Jan 28 '15 at 21:42
• From the short description you gave of the assignment, it sounds like you don't need to implement a mode of operation. $\:$ For modes of operation (including CBC), you would store the initialization vector as the beginning of the ciphertext, so that the decryption algorithm can do what you describe. $\;\;\;\;$ – user991 Jan 28 '15 at 22:03
• He left it up to us whether we wanted to implement a mode of operation or not. It's very open ended. But I think you answered my question - adding it to the beginning of the ciphertext makes sense. Thank you! If you put that as an answer, I can accept it. – Vivin Paliath Jan 28 '15 at 22:13
• Standard practice is using a random per message IV and sending it alongside the message, typically as a prefix. So in principle you got the IV handling right. – CodesInChaos Jan 28 '15 at 22:22