2

I know very little about encryption, so I figured I'd ask the internet if it's possible to do the following (and if so, what kind of algorithm should I be looking at):

Write some code that saves data to and loads data from a file, however the file is usable only once. What I mean is that the data is loaded in from it, and the file is overwritten with new data by the software which is now the file that can be loaded. If the user however made a copy of the previous version and replaces the new file with it, that same file should no longer work.

The conditions under which I'd like to achieve this are the following:

  • Windows environment.
  • The software is offline, on the user's machine.
  • The user is smart enough to be able to locate any files the software creates and make copies (meaning keeping some sort of validation code in a separate file would be insufficient as a solution). They are smart, tenacious and motivated in finding a method to load data from old files, but they don't know much about computer science, so they wouldn't decompile the software or crack any encryption that might be involved in the solution.
5

The operating conditions that you describe are not sufficient to create a use-once guarantee like the self-destructing devices from Mission Impossible:

  • your programme could be monitored very precisely, so that any registry key or any file accessed/created/modified could be tracked.
  • your attacker has control on the operating environment and could hence make a perfect clone of it, backup any data or state, and do whatever is needed to recreate the initial conditions which would permit to use your encrypted information as often as desired.

The only way to make something usable only once would be to rely on an external element that you totally control. For example a specially manufactured hardware device (such as the encryption tokens used in the PKI infrastructures of your government that are molded in plastic so that they can't be opened without total destruction, and with a counter that ensures a single use) or with the help of a remote server under your control (like Microsoft does it for the Windows activation).

In both case, you need to design your use-once protocol in a way that prevents session replay. If you don't, your website could perfom the decription only once, but the attacker could record the TCP/IP exchanges and create a dummy server in his/her environment that would simulate the same exchanges. A typical approach here is to make use in the encryption scheme of some unique random token that is provided by your server when initialising the connection.

A good reference book for such secured exchange protocols is Bruce Schneier's Applied Cryptography. But keep in mind that what you intend to do requires advanced cryptographic skills and is extremely difficult.

  • Thank you for the answer, it's perfect. This was an optional idea for a simple hobby project, so I'll just forego it. – Zoltán Király Apr 8 at 22:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.