I have seen articles regarding encrypt/decrypt data using Private/Public key. All I want to do is to just encrypt a generated RSA private key already stored in a file. I have been browsing widely to get an idea how it can be done but with no luck.I presume my question is rather an unusual one. Please help!
Asked
Active
Viewed 1,015 times
0
-
3Are you sure you want to be encrypting a private key? What are you using to encrypt it - another public/private key? This feels like it might be an [XY Problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – James Thorpe May 18 '17 at 15:27
-
@James. I've developed a light control application.To deploy application for first time at client side, I'll be sending private RSA key in encrypted format, with encrypted pass phrase to client through email for validation. When client enters passphrase for the initial set up ,if that password matches , aplication decrypts the encrypted file and make connection with server to control lights. Initially, thought DPAPI fulfill my requirements but encryption and decryption process solely dependent on current user. So I am looking for Cryptographic algorithm to encrypt RSA key.Please help. – user7274707 May 18 '17 at 16:02
1 Answers
0
First, you need a *Key derivation function, to turn your password into a symmetric key which you can use to encrypt your private key. If you solely use the .NET framework, you should use the Rfc2898DeriveBytes class for that. If you are able to use BouncyCastle, then SCrypt would be preferred.
Then you can encrypt your key, prefreably using the AES algorithm.
Some usable code sample can be found in this answer