简体   繁体   中英

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM