Tupu Sipaia Kikhteva
Tupu Sipaia Kikhteva

Reputation: 53

How to store encryption key .NET

My .NET application contains some RSA encryption. And my question: where to store the keys?

After a bit of googleing I can't see any real suggestions. What I have seen

  1. Split them and store into different folders.
  2. Use ProtectedData. But if I am using protected data I still have to store encrypted result of the key. Still the same question, where to store it?

Are there better options?

Upvotes: 2

Views: 2601

Answers (1)

freedeveloper
freedeveloper

Reputation: 4082

The standard method is stored the key in a key container, net has a API to do this. See How to: Store Asymmetric Keys in a Key Container You can stored the key container as private, in this case only you have access to the key. IF you want to share the key between different user or program in your computer you should used the machine level key container. To store in the machine level you only need to add in the parameters of container the flag UseMachineKeyStore

CspParameters cp = new CspParameters();
cp.KeyContainerName = ContainerName;
cp.Flags = UseMachineKeyStore 

Remember that any time that you use the machine key store, you need to set the flag. This configuration has some security concert dependable how sensible is the information. You can restrict the access to the create container using rules of access.

I hope that this information will be useful to you.

Upvotes: 1

Related Questions