开发者

Exchanging Symmetric Keys

开发者 https://www.devze.com 2023-03-14 06:27 出处:网络
I have a WinForms client that is sending encrypted data to a 开发者_高级运维web service.The WinForms client creates a Symmetric RijndaelManaged sessionKey and also has a \"hard-coded RSA asymmetric pu

I have a WinForms client that is sending encrypted data to a 开发者_高级运维web service. The WinForms client creates a Symmetric RijndaelManaged sessionKey and also has a "hard-coded RSA asymmetric public key".

I am using the EncryptedXml class which makes it really easy to package up my data.

The Web Service has both the private and public keys "hardcoded" and can successfully decrypt the SessionKey and then use it to decrypt the actual data I am sending.

This is pretty much handled automatically by the EncryptedData class.

The problem I am having is that on the Web Service end when I want to reply, I can't seem to figure out how to get the SessionKey that was sent over.

Before I do any decrypting on the Web Service side, I can see the encrypted session key, but after I decrypt the XML, it's gone (and therefore I don't have any session keys for my reply).

Any ideas how I can get this unencrypted key?


The reason that you cannot see the session key is that it is automatically decrypted and used. Normally it is considered part of the XML. If you want to get at it, just use

encryptedxml.decryptencryptedkey

And you should be alright. Note that for all the less important security warnings, the code represented here is vulnerable to both man in the middle attacks and to a lesser extend to padding oracle attacks. It should help against most eavesdropping attempts though.

Finally, reusing a session key is considered pretty bad security practice too. If you reuse it, at least consider using an IV, e.g. a counter for each followup message.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号