I do not know the specific technologies that you are using, so my answer will mainly point to a problem with the keystore.
Firstly, two big points:
- Even with the help of some heavy specialized equipment (for banks and other critical systems, the security modules -HSM are used for this), there is always a risk of getting a stolen key. What you decide to do depends on how important your key is and how willing you are to protect it. I will try to avoid mentioning hardware solutions because for most people they are usually redundant.
- There are, however, good practices you can follow: https://www.owasp.org/index.php/Cryptographic_Storage_Cheat_Sheet
Now, some advise. No matter what you do, do not store your key in clear text (and much less hard-coded). If you use public key cryptography, PKCS12 files (usually with the extension .p12 or .pfx) are the standard way to store data. They are usually password protected.
Here you are faced with a problem: if you have a key, you need to use it. If you use the key, it will be in "plain text", at least in RAM. So you need a way to enable access that keeps the key as isolated as possible. If actions are initiated by the user, everything is relatively good, because you can request a password before using the key.
If the actions are automated, you need to find a way to store the password. Even security software, such as some PGP implementations, has approaches to this, which is not very nice:
- Request a password at the command line: command -password my-password. This, put in the bat, works. But the password is saved and, depending on the operating system, even accessible using the
history
command. - Keep it in a file: at least you do not leave a copy, but the password is still in clear text.
- Encrypt it using system data as the encryption key: the password is relatively secure, but you lose portability, and the attacker with access to the computer will not be stopped by the control.
- Request a password if one of the services is turned on: a little more reasonable, but not always possible (if the service is critical, but one person has a password, availability may be compromised).
- Unusual things can be done by decrypting the threshold, but probably too much for this case.
I do not provide details for each parameter, because what you can do may depend on what your infrastructure allows and how you use your system, but I hope this helps as a reference to the various parameters. In any case, they do not perform any cryptographic functions on their own . Bad crypto is worse than no crypto at all.
source share