I'm working on a Windows Phone 7 app that requires some data encryption. I'm having a hard time finding any documentation about a key ring or DPAPI for Windows Phone 7. I've come up with a few wa开发者_运维知识库ys, but they all have downsides.
Generate a random encryption key and store it to IsolatedStorage. The pros of this is that it is simple, and it "just works". The cons are that this key will likely show up in backup files, etc.
Generate a random key and use the device ID to encrypt that key. The pros are that it offers SOME better protection. It isn't hard to figure out the device ID. The Cons are that if they back it up and restore it to another phone, the key will be invalid.
User input cannot be required (i.e. I can't derive the key from user input)
I don't like either of the two. There must be something like DPAPI or a key ring in Windows Phone 7. Or is it lacking that?
Unfortunately there is no currently keyring/dpapi exposed to managed code. If you can't ask the user for input, then you're stuck with one of your two approaches. Personally, I like the approach where you use the IMEI as part of the key i.e. (psudocode) ...
shared_secret = sha512(newGuid + IMEI)
The benefit to doing it that way is that if the phone is lost or stolen and the SIM card is swapped out (for phones with SIM cards like GSM or Verizon's LTE), the data will remain inaccessible and if they leave the old SIM card in to access the data, there is a better chance the phone can be found and/or remote wiped.
精彩评论