Key Security
The primitives in this toolkit allow you to do a lot of low-level operations with RSA and ECC keys.
The original design only permitted private keys to be stored as a file in encrypted format.
In response to many requests from users, we've added various functions that allow you to import and
save private keys in a variety of unencrypted formats, including XML and OpenSSL-compatible PEM formats.
Use these functions in your tests by all means, but if you are using this toolkit to make an application
to be used by less-experienced end users (and this is almost always the case), follow the following guidelines:
- Do not give your users the ability to save an unencrypted private key, ever. Just say no.
- Never, ever save production private keys to disk in unencrypted format.
Remember that's never, even when testing (especially when testing).
- Use the
WIPE_Data
function to wipe the
internal private key string as soon as you've finished using it.
- Ditto for passwords.
- If you have to save secret data as an intermediate file,
use the
WIPE_File
function to erase it immediately afterwards.
Make sure this happens even if an error condition occurs.
- Never print out the "internal" string representation of a production private key.
(We know we do in our examples, but that's to demonstrate how it works.)
Likewise the password. See Internal key strings.
- Do not hard code private key strings or passwords, ever. (Again, do as we say, not as
we do in our examples.) See Internal key strings.
- If you need a private key on a server to be used repeatedly in internal format,
force the administrator to enter the password each time the server starts.
Set up a hierarchy of keys and certificates in case the server key gets compromised.
- Enforce a policy so that users are forced to use strong passwords for the private key.
The higher up the chain the longer the password needs to be.
Do not compromise on this, even when the client complains.
It's good practice for important passwords to be so long that they have to written down.
Keep the piece of paper in a safe.
- And build in a function that detects when the user has stuck a Post-It note
on their monitor with the private key password on it.