I am currently working on a little project.
I am trying to generate an AES key with that I would like to encrypt a private RSA key. I have to do it this way. However, I do not want to save the AES key, but generate it everytime when I would like to decrypt my RSA key.
I wanted to use AES in CTR mode with random IVs. Since the plaintext the AES encrypts does not matter, I figured I just used my initial starting IV to be encrypted with the AES itself. As a passphrase I have a user's password in plaintext.
CCBox._user.masterkey = CryptoJS.AES.encrypt(CCCBox._user.serial, CCCBox._user.password ,
{
iv: CCCBox._user.serial,
mode: CryptoJS.mode.CTR
});
I am using the CryptoJS library. CCCBox is my Javascript class. Actually I am saving the IV ( the CCCBox._user.serial ) in my database as well, but I would like to change that as well.
The problem is, that whenever I generate the masterkey I do not get the same key twice. What way is there around so that I can allow a user to generate its own masterkey everytime without saving it in my database ?
All the best, Richard