views:

359

answers:

1

Hello,

I am in need to encrypt/decrypt data that has been encrypted on the database (Sql Server 2005) level in the .Net code. RjindaelManaged with 256 bit key length and 128 bit block size is the equivalent of AES 256 algorithm, but I don't know how to go about matching Key and IV so that both Sql Server and .Net encryption methods would produce same results.

Has anyone come across this in the past?

Sql Server key is created with code similar to the one below:

create symmetric key SomeKeyName
  with 
    algorithm = AES_256,
    key_source = 'SomePassword',
    identity_value = 'SomePassword'
    encryption by certificate SomeCertificate
A: 

You can't. If is encrypted in SQL EncryptByKey function, then it must be decrypted using DecryptByKey. The format in which the encrypted data is stored is proprietary and is not public.

Remus Rusanu
That's exactly what I was afraid of. I am in need to have the same encryption mechanism both on Sql Server (used by legacy ASP code) and .Net side. I guess that the other option would be to use CLR with SQL Server. Thanks a bunch!!!
User