Is there any free & open source tool for public key cryptography, where the private key is just a chosen password?
Here is what I need:
- I want to make backups every hour using a script
- I want to only use open source tools.
- The backups must be encrypted,
- I need to be able to decrypt them without any files.
I cannot use symmetric encryption for backups, because the password cannot be given in the script in plaintext, and I cannot be asked each time a backup is made for the password (e.g. because when I'm on 1-month holidays, the backups need to be still made).
So I thought about public key cryptography, but all tools that I read about store the private key in a file. I'm afraid of losing it, just like all other data (that's why I'm doing backups in the first place). Imagine my disk suffers hardware failure, someone steals it, it burns in a fire, etc. Sure, I have backups, but I can't decrypt them without the private key file, which is now lost! Of course I could have backups of my private key file, but I simply don't want to rely on a file to decrypt my data.
I found a solution (at least from mathematical point of view, because I can't find any tool implementing this). Let's say I have my password. Let us generate a pair of prime numbers (p1,p2) using the following function p2rsapk:
(p1,p2) = p2rsapk(password) = {
bits = password as vector of bits
(n1,n2) = split bits into two parts in deterministic way, e.g. just take halves
p1 = find prime based on n1, e.g. lowest prime p1 s.t. p1 > 2^n1-2
p2 = find prime based on n2
}
Voila! We have just taken a password and turned it into our private/public key pair. Now I could encrypt my backup with the public key (used by the script), and decrypt it when I have to without the need for any private key file (because my password IS my private key with the help of the p2rsapk function).
I could also send my public key to friends, so they can send me encrypted messages, and I can decrypt them from anywhere without the access to my no-longer-needed private key file.
However, while the idea is quite simple, I haven't found any tool that implements it. Is this approach known? And are there tools for this?
EDIT: I cannot stress enough how important it is for me not to rely on a file as the private key. I am well aware of the approach where one stores private key in a (possibly password-protected) file and its advantages and disadvantages, and I acknowledge that it is the most secure way to go for many scenarios. There are many books, tutorials, and man pages describing how to proceed if one wants the private key in a file. I know about that, but when answering please keep in mind that it is a strict requirement that there is no file for storing the private key.
EDIT2: I am perfectly aware of the problems with weak passwords. I know the password is the weakest link, so please assume I will use a safe password (minimum 50 characters including lower and uppercase letters, digits, symbols and no dictionary words).