menu

arrow_back How to properly store the encryption key for desktop applications?

by
2 votes
Recently saw an article https://habr.com/ru/company/globalsign/blog/492970/ (briefly hacking relatively old versions of team Viewer, which stored password files in the registry in encrypted form), and wondered if there was a reliable way to store the shfing key (given that it must be stored locally)?

3 Answers

by
 
Best answer
0 votes
The only reliable way is to use the master password. If there is no password, you can reverse-engineer any encryption method and decrypt all the stored data just like the product itself does. Sometimes you don't even have to figure it out - you can just tear out the right pieces of code from the product and run them.

And with the password - you need some kind of cryptographically resistant kdf- function convert it into an encryption key and then use either AES or some other encryption algorithm.

The main thing is not to cycle anything cryptographic on your own. Take popular crypto libraries and use standard and modern cryptographic primitives.

However, there is a problem here - if the user forgets the master password, there is no way to retrieve the locally saved data. The key obtained from the password via KDF can be encrypted in some simple way (or even in playtext) and additionally given to the user to save on a flash drive and use to recover the password: if there is no password, the key from the file is applied, then the data are encrypted with the new key obtained from the new user password. It is important just to convince the user not to keep the file on the same computer. If you see this file in the program folder, on the desktop or in "my documents", you should scold the user for disregarding security.

To verify that the password is correct, the data must be provided with some kind of checksum (before encryption).

Everything else is security through obscurity. Doesn't work in the long run.
by
1 vote
Whatever you want.
In your case, the encryption key is essentially just valuable information, the leakage of which is critical.
Do not store it on the computer, if you do, then encrypt it, and unplug the computer from the network.

3 Comments

It makes no difference what you store - if the information is valuable, then just encrypt it. That's all.
It will be impossible to decrypt it without knowing the encryption key.
And the key will not be on the computer because it is not safe to keep it there.
It doesn't make any sense.
What do you have there passwords or encryption keys and what exactly do you want to store?
Maybe I didn't phrase my question very well. Suppose there is an application that takes passwords in encrypted form (you won't force a regular user to deal with keys), so I wanted to know where it is customary to store the key locally.
by
2 votes
Passwords in principle cannot be stored, neither on the disk nor in memory, and it does not lead to anything good. Even master passwords can be stolen while they are being entered and processed. But to be fair the servers keep secret keys so that we can connect to them with encryption. They are just relying on the privilege differentiation of the operating system. But if another program is running with your program privileges or higher, or an intruder has physical access to your hardware, they can read all your secrets. But on Windows or Android this distinction is useless, on the first one a lot of garbage is executed with maximal privileges, and on the second one they don't close the holes at all and only the freshest hardware is able to keep secrets.
Security is a set of measures and simple actions at the level of the program can not provide it.

2 Comments

wataru If you enter a password, you can lose it, but if you enter a master password, you can lose everything. There is no point in creating a master password to store a single password. Moreover, if this password is from a remote server, it's difficult and time-consuming to find it without running into a security system. It's much easier to guess the master password using video cards. This is an additional attack vector.
> Even master passwords can be stolen while they are being entered and processed.

Exactly the same way you can steal the very passwords you want to keep in this matter. Thus, the master password makes life easier for users without creating additional attack vectors.