Search code examples
rsacryptoserviceprovider

Can the data at UseMachineKeyStore be backed up and recovered?


I have the following code:

const int PROVIDER_RSA_FULL = 1;
const string CONTAINER_NAME = "Example";
CspParameters cspParams;
cspParams = new CspParameters(PROVIDER_RSA_FULL);
cspParams.KeyContainerName = CONTAINER_NAME;
cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
cspParams.ProviderName = "Microsoft Strong Cryptographic Provider";
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cspParams);

As I understand it, a keypair is generated automatically and then becomes the referenced key pair using the KeyContainerName "Example".

I'm using a dedicated host. I want to be sure that our hosting company are aware of this information being important, making sure it's backed up, and not losing it, because then all the information I have encrypted and stored in a database will be useless.

I can't find any word in MSDN about how it works in the background.


Solution

  • The Key containers are stored in the file system. The directories are Machine Keys: documents and settings\all users\application\data\microsoft\crypto and subdirectories.

    Be aware that you can not "reuse" those keys on other machines or if you are going to rebuild your machine!

    Ref.