Silverlight and Encryption, how to store/generate they key/iv pair?

Posted by cmaduro on Stack Overflow See other posts from Stack Overflow or by cmaduro
Published on 2010-04-22T19:06:49Z Indexed on 2010/04/23 13:33 UTC
Read the original article Hit count: 757

Filed under:
|

I have a Silverlight app that connects to a php webservice. I want to encrypt the communication between the webservice and the Silverlight client. I'm not relying on SSL. I'm encrypting/decrypting the POST string myself using AES 256bit Key and IV.

The big questions then are:

  1. How do I generate a random unique key/iv pair in PHP.

  2. How do I share this key/iv pair between the web service and silverlight client in a secure way.

It seems impossible without having some kind of hard coded key or iv on the client. Which would compromise security.

This is a public website, there are no logins. Just the requirement of secure communication.

I can hard code the seed for the key/iv (which is hashed with SHA256 with a time stamp salt and then assigned as the key or iv) in PHP source code, that's on the server so that is pretty safe. However on the client the seed for the key/iv pair would be visible, if it is hard coded.

Further more using a time stamp as the basis for uniqueness/randomness is definitely not ok, since timestamps are predictable. It does however provide a common factor between the C# code and the PHP code.

The only other option that I can think of would be to have a 3rd service involved that provides the key/iv to the Silverlight client, as well as the php webservice. This of course start the cycle anew, with the question of how to store the credentials for accessing the key/iv distribution service on the Silverlight client.

Sounds like the solution is then asymmetric encryption, since sensitive data will be viewed only on the administrative back end of the website. Unfortunately Silverlight has no asymmetric encryption classes. The solution? Roll my own Diffie-Hellman key exchange! Plug that key into AES256!

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about encryption