How do you save and retrieve a Key/IV pair securely?

Posted by Shawn Steward on Stack Overflow See other posts from Stack Overflow or by Shawn Steward
Published on 2010-05-17T18:06:37Z Indexed on 2010/05/17 18:10 UTC
Read the original article Hit count: 269

I'm using VB.Net's RijndaelManaged (RM) to encrypt files, using the RM.GenerateKey and RM.GenerateIV methods to generate the Key and IV and encrypting the file using the CryptoStream class. I'm planning on saving this Key and IV to a file and want to make sure I'm doing it the right way. I am combining the IV+Key, and encrypting that with my RSA Public key and writing it out to a file. Then, to decrypt I use the RSA Private key on this file to get the IV+Key, split them up and set RM.Key and RM.IV to these values and run the decryptor.

Is this the best method to accomplish this, or is there a preferred method for saving the IV & Key? Also, what's the best way to construct and deconstruct the byte array? I used the .Concat method to join them together and that seems to work well but I can't seem to find something as easy to deconstruct it. I played with the .Take method that takes the first x # of bytes and it works for the first part but can't find anything that gets the rest of it.

© Stack Overflow or respective owner

Related posts about rijndaelmanaged

Related posts about visual-studio-2008