0

I have a Windows application that does not use a database and is not on the Internet. It contains very important data (data loaded from encrypted files). The user needs a password to enter this application.

Where should I safely store the application password? (also there is a few short string data that need be stored (files addresses)). The application is run on Windows XP and later versions. I use C#.

Note: I do not ask how to store password. I know it should be hashed and should use salt for it. See this post.

  • 5
    why do you have a password on the app? why are you trying to hide the location of the application's files from the local user? – schroeder Apr 5 '17 at 9:11
  • 1
    Data in the app is hardcoded and in plaintext? You just want to have a password to unlock the app? – Marko Vodopija Apr 5 '17 at 9:31
  • 1
    Is the password also used to generate the encryption key? Or where does the key come from? – Anders Apr 5 '17 at 9:33
  • 1
    Why would you store the password then? – Marko Vodopija Apr 5 '17 at 9:51
  • 3
    If the password is only used to decrypt the encrypted file, than you do not need to store it at all. If the file decrypts with the derived key, the password was correct. Otherwise, it was not. – mat Apr 5 '17 at 9:52
2

https://msdn.microsoft.com/en-us/library/windows/desktop/aa374789(v=vs.85).aspx

Developers who write for Windows can use the Credentials Management API including Credentials Management User Interface (UI) functions to obtain and manage credential information such as user names and passwords. These functions request Windows account information to be used instead of the credentials established while logging on. Such requests typically occur when the logon credentials do not have permissions that are required by the application. The Credentials Management UI functions provide interfaces with the appearance of the Windows user interface. These functions include customizable options that add user's information to the user's credentials store.

In your data are really impotent consider using hardware based solution (ex. Smart cards, TPM).

  • I would also like to suggest the DPAPI (Data Protection API) which provides a way of encrypting blobs using either a per-machine or per-user (roaming) secret and the process is transparent to the end-user. – The D Mar 7 '18 at 0:52
1

From your question? I don't think you should store the password at all.

From what I gathered from your question, here's your current thought process:

  1. User fires up app
  2. User has to type app password
  3. App checks if password is correct
  4. If it's not, the app closes down
  5. If it is, it starts loading the data

Well, what about this model instead?

  1. User fires up app
  2. User has to type app password
  3. App reads encrypted data from disk
  4. App tries to decrypt data using user-provided password
  5. If the decrypted data isn't valid, the app closes down (password wasn't right)
  6. If the decrypted data is valid, the app continues (password was correct)

Does that make sense? Your app isn't storing the key at all - it's simply trying to decrypt the data with whatever the user typed in.

0

For solving this problem, I need somewhere to store data. Even if I chose to use a key to decrypt the file and if it fails, think of it as a wrong key (that is not quite right) I would need the file address.

There are two possible ways:

  1. use the registry
  2. use another file

Both have positive and negative sides, but I recommend a file.

For a filename, you can create one name by using some properties like username, etc. (property should remain unique for user in acceptable conditions). Also, you can use serialization and binaryformatter for save/load data.

Now the question is should this file be encrypted or not? Because we will store some data (file address) that we need them as they saved we cannot use inserted password for encryption else there would be hints to password. We can encrypt the file or some of its data with some other password created by some properties or do not encrypt it (I do not think encryption this way helps anyone).

It would be wise to have a backup of this file.

I will wait for a week or so and if there is not a better answer and this answer is valid (base on comments), I will accept it as the answer.

  • 3
    You are still not clear on what you are trying to accomplish. None of this makes a lot of sense. – schroeder Apr 9 '17 at 9:50
  • @schroeder♦ thanks for response. simply I want to keep some data that needs to run application (password, file path) and I want this data be safe as possible. so question is where and how store them. – NokhodSiah Apr 10 '17 at 4:41
  • 1
    I get that, but you do not explain why you want to keep the file path a secret from the local user or why you need a password for a local program. Why would Word keep all those things secret or require a password? If we understood that part, we might be able to think of something. Whenever you want to secure something, you need to understand the threats that you want to secure against. You have not explained that part at all. – schroeder Apr 10 '17 at 6:14
  • The registry is not designed to store secrets. Anyone can read it. Many programs in the past have used encrypted or obfuscated files to store data, but they are not effective in keeping data secure from the local user. The local user has access to everything. – schroeder Apr 10 '17 at 6:15
  • @schroeder♦ thanks. yes user have access to everything. but there is different between keeping password in text in registry and use hashed salted password in a file that you need algorithm or a software to find file (and messed with it). although it is not entirely safe, it would be safer. (and probably safest that I can do) – NokhodSiah Apr 11 '17 at 12:19

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.