Doro
Doro

Reputation: 785

Authorize USB drive

Is there any method or suggestion how to prepare and authorize an USB drive in program written in C#? I do not want to prepare some kind of a whitelist but somehow detect that USB drive was prepared by me. The USB drive would be used to update my program.

Detecting hidden files and folders is not a solution because user can always display/delete all those hidden things.

In addition the program has got to detect that USB drive is authorized on Windows >= XP.

EDIT

The USB drive should work on every OS just like regular USB except the thing that It should be authorize-able in my program.

Upvotes: 1

Views: 857

Answers (3)

Doro
Doro

Reputation: 785

Based on some Mike of SST advices I've managed to prepare a solution which satisfies me. It does not use C# directly but it is manageable in that language,

Steps to do in my solution:

  1. Create the smallest possible unallocated partition in your USB drive (in my case it's 7.8MB)
  2. Based on USB drive infos create a hashed string and write it to that unallocated partition.

In that solution user simply doesn't know if that USB is authorized, he can format a visible partition and write everything on it. Even copying the image of that drive doesn't give an authorization to copied usb drive.

Using dd for Windows I am able to read and write that hash and I can run that process directly from c#.

Upvotes: 2

Mark Twain
Mark Twain

Reputation: 836

Why do you try to avoid a special file? You place a hidden txt file with generated hash key in it. This hash is generated base on your USB drive manufacturer serial number and secret key (which your program has). When you place a USB drive in computer, your program read hash key from the file and compare it with calculated by the program. If they are same, you authorize USB drive. You just doesn't authorize USB drives without this file. If you want to user not able to remove this file, you should use hidden partition, but it's more complex solution.

Upvotes: 1

marsze
marsze

Reputation: 17144

What about encrypting the entire drive or putting an encrypted file/container on it? The password could be embedded in your program. (This is not the most secure solution, but an easy one for your purposes.)

Upvotes: 0

Related Questions