views:

115

answers:

5

We have around 60 MB of device configuration implemented in at least 1000 xml files.

Now we are releasing the software to the customers. But our requirement is not to allow the user to view and edit the xml configuration files. XML configuration files contains a lot of secret of the device information which can be easily hacked if it is readable.

Now we need to encrypt the xml files. Are there any recommended method to encrypt the xml file and it can be decrypted at run time?

+2  A: 

How determined are you expecting the "hackers" to be? If all the information required to decrypt the information has to be present on the system anyway, then a determined attacker is going to be able to get at it anyway.

Jon Skeet
they are basically field users of the software and may be some of customers developers.
Gopalakrishnan Subramani
+1  A: 

You can use the classes in the Cryptography namespace.

Most of the encryption classes will allow you to encrypt and decrypt streams, so are good for your purpose.

However, you will still need to hold the encryption keys somewhere, even if it is in the assembly.

As Jon points out, a determined hacker will find a way to break any encryption.

Oded
+3  A: 

This is a problem known from DRM applications - you want to make the data available to the user agent of your choice but not to the user operating the user agent. But, since the user agent is usually on the user's side, as Jon and Oded point out, a determined hacker will find a way to break the encryption. It's a cat and mouse game. You are trying to find a solution to exactly the same problem that people implementing DRM want to solve. Software-only user agents are easier to hack than hardware-assisted user agents, but in either case time works for the hackers. The latest development is the latter - embedding all the cryptography in hardware - like the HDMI's HDCP method (High-bandwith Digital Content protection Path) where they have essentially made the decrypted digital signal inaccessible to the user by letting it pass along black-box hardware from its point of decryption until it is made so available, but at the intended destination - TV screen. The key for HDCP to succeed however was implementing it in hardware. Most hackers have learned to deal with software. But since I would say there is 1 good hardware hacker per 100 good software hackers these days, the mouse hopes no cat will be around to catch it. Sorry for too much theory, it is essential to your problem though, I believe. If you are still willing to play the game, encrypt your XML files and make sure the decryption key is not available to potential hackers on a silver plate - i.e. obfuscate it, can't do much else.

amn
if the movie industry with all its millions its thrown at the issue can't protect its films, what hope has anyone got.
Sam Holder
+1  A: 

As others explained, you won't get it absolutely secure without a trusted device which stores the key and does the decryption without granting access to the key under any circumstances. Computers aren't "trusted devices"... My employer sells such technology and if your data is really money worth, you should possibly take such a solution into account. If an additional USB-Dongle is not acceptable (or too expensive) at least use public-key (asymmetic) cryptography (see System.Security.Cryptography). Asymmetric cryptography has the advantage that the key used to decrypt your data can't be used to encrypt the data. Your application has to store the decryption key and the hacker can determine it with more or less effort. He then can decrypt all your data but he can't not encrpyt the changed data again. So he can't use your application with the changed data. If you want to prevent him from doing this, you have to obfuscate your application and use anti-debugging techniques (static and runtime). If you go this way buying an existing solution is probably cheaper.

ur
A: 

Watch out: Hackers can see all functions in .net generated executables and dll's! If you make a decription algorithm in your .net project like DecryptXML(string Path), it is very easy for a hacker to call this instruction. So be sure to dotfuscate your project.

Erik Van Hecke