I am implementing a shared-secret encryption scheme for moderately secure data transfer. When the server is provisioning a client, I can generate one or more strings representing the secret. The client will then use this secret information to encrypt data before sending it to the server. I want ensure the shared secret is as strong as practicable and sufficient to guarantee interoperability.
Algorithm/class selection: It seems one should "stick to AES unless you have a good reason not to." Is AesManaged a good choice for this? Difference between symmetric crypto algorithms
Settings and default object: I am using .NET 4.0 and .NET 4.5 in different parts of the system, and may upgrade over time. I cannot find documentation for the default properties of KeySize and BlockSize, nor the default length for IV. In .NET 4.0 it appears the default key size is 32 (bytes, 256-bit) and the default IV size is 16 (bytes). BlockSize and FeedbackSize are 128 (bits). Mode is CBC and Padding is PKCS7. Which properties should I set explicitly, and should I regenerate the key and IV afterwards?
[Edits: Fixed 256-bit above and below. Added questions.]
Is a 256-bit key and a 16-byte IV strong enough for "non-government work?"
I have read that 256-bit keys are vulnerable to a certain kind of attack (which I don't think applies in my case). Is there any reason to use a 128-bit key instead? What is the performance differential?
Is it normal that the default key size is larger than the block size?
[Edits: Done.]
Strength of default key and IV: Is there any reason to use RNGCryptoServiceProvider.GetBytes() or is that what AesManaged is doing already?
Interoperability: I am assuming the shared secret consists of they key and the IV (encoded to Base64 strings). Will setting the Key and IV properties from the recovered byte arrays be sufficient to set the related properties (e.g. KeySize)?
Can any other properties be inferred and guaranteed to agree, or should I set them explicitly for key generation, encryption, and decryption?
Key generation code:
AesManaged myAes = new AesManaged(); // use defaults
string keyString = Convert.ToBase64String(myAes.Key);
string ivString = Convert.ToBase64String(myAes.IV);
Code and context: I borrowed heavily from here: http://msdn.microsoft.com/en-us/library/vstudio/system.security.cryptography.aesmanaged%28v=vs.100%29