EDIT 1 : I think I was not clear myself
before and hence could not word it
better. So, I am creating a system
where I am providing page content to
another system via IFRAMEs. A user
will login to the other system and
that system will set their apiKey and
userKey in a cookie on my system so
that access will be granted into my
system. I want to encrypt these values
so that a malicious user cannot be
granted access into someone elses
sytem by modifying a value. Are there
good .NET standards for this type of
encryption/security? What do you
recommend I do in this scenario?
Hi all,
Firstly this might be asked before but I have never implemented hashing or encryption before so I just want to make sure that I put my point across clearly.I want to have some good idea of what needs to be done here.
I have couple of keys which are unique to the users and are being passed by client through the iframes and to maintain session we create cookies using these values for them.So, now I want encrypt or generate a hash for these values since they are visible in the url I dont want the users manipulating these values.
So, I guess I want to generate a hash for both the keys and display that in the browser in order to stop the users from entering some random values and try to abuse the system. I guess would store these hashed values in the database and then compare with original values.
Please just anyone guide me to the steps what all I need to do and what should I be using to achieve it.
Firstly if I understand your scenario correctly you don’t need a hash but you need an encryption of those keys. If you hash them you will never be able to read the original values back and create the session cookie. You are trying to implement a cross domain Single-Sign-On (if this is not your case and I misunderstood your scenario you could ignore the rest of my answer).
I would recommend you using the machine keys to encrypt/decrypt:
Encrypt:
Now send the encrypted string over the wire and on the other hand decrypt. It is important to perform this over an encrypted channel using SSL to avoid a Man-In-The-Middle who can steal the encrypted value and try to brute force it:
For this to work it is necessary to have the same machine keys on both the encrypting and the decrypting side.
UPDATE:
Here are the steps:
You have achieved cross domain single sign on. Of course this technique is not limited to iframes.