I have an application written in Classic ASP that encrypts data via CAPICOM and stores it in a database. The encryption code looks something like this (Classic ASP, VB. Simplified a bit for brevity):
set encryptObject = Server.CreateObject("CAPICOM.EncryptedData")
encryptObject.Algorithm.Name = 4 ' 4 is AES
encryptObject.Algorithm.KeyLength = ' 0 is MAX
encryptObject.SetSecret(sharedSecret) ' sharedSecret was set earlier
encryptObject.Content = stringToEncrypt
encryptedString = encryptObject.Encrypt()
Now, I have a .NET application that needs to read this data and decrypt it. I've done AES-compatible encryption/decryption in .NET before using the RijndaelManaged
class, and I'm hoping I can use that same method to decrypt this data. However, I can't figure out how to get this to work with CAPICOM's encrypted data, because RijndaelManaged
requires that you pass a key AND an intialization vector when calling RijndaelManaged.CreateEncryptor
, and CAPICOM doesn't take an initialization vector. I assume CAPICOM must be using an initialization vector, but not exposing it. How can I find that vector?