<p>My company is going to be storing sensitive data for our customers, and will be encrypting data using one of the managed .NET encryption algorithm classes. Most of the work is done, but we haven't figured out how/where to store the key. I've done some light searching and reading, and it seems like a hardware solution might be the most secure. Does anyone have any recommendations on a key storage solution or method?</p>

<hr>

<p>Thanks for your replies, everyone.</p>

<p>spoulson, the issue is actually both the "scopes" that you mentioned. I suppose I should have been clearer.</p>

<p>The data itself, as well as the logic that encrypts it and decrypts it is abstracted away into an ASP.NET profile provider. This profile provider allows both encrypted profile properties as well as plain text ones. The encrypted property values are stored in exactly the same way the plain text ones are - with the obvious exception that they've been encrypted.</p>

<p>That said, the key will need to be able to be summoned for one of three reasons:</p>

<ol>
<li>The authorized web application, running on an authorized server, needs to encrypt data.</li>
<li>Same as #1, but for decrypting the data.</li>
<li>Authorized members of our business team need to view the encrypted data.</li>
</ol>

<p>The way I'm imagining it is that nobody would ever actually know the key - there would be a piece of software controlling the actual encrypting and decrypting of data. That said, the key still needs to come from <em>somewhere</em>.</p>

<p>Full disclosure - if you couldn't already tell, I've never done anything like this before, so if I'm completely off base in my perception of how this should work, by all means, let me know.</p>

[{'answer_id': 50155, 'author': 'spoulson', 'author_id': 3347, 'author_profile': 'https://Stackoverflow.com/users/3347', 'pm_score': 0, 'selected': False, 'text': '<p><a href="http://www.microsoft.com/rms" rel="nofollow noreferrer">Microsoft Rights Management Server (RMS)</a> has a similar problem.  It just solves it by encrypting its configuration with a master password. ...A password on a password, if you will.</p>\n'}, {'answer_id': 50317, 'author': 'Kyle Cronin', 'author_id': 658, 'author_profile': 'https://Stackoverflow.com/users/658', 'pm_score': 0, 'selected': False, 'text': "<p>Your best bet is to physically secure the hardware the key is on. Also, don't ever write it to disk - find some way to prevent that section of memory from being paged to disk. When encrypting/decrypting the key needs to be loaded into memory, and with unsecure hardware there's always this venue of attack.</p>\n\n<p>There are, like you said, hardware encryption devices but they don't scale - all encryption/decryption passes through the chip.</p>\n"}, {'answer_id': 50374, 'author': 'sock', 'author_id': 4028, 'author_profile': 'https://Stackoverflow.com/users/4028', 'pm_score': 0, 'selected': False, 'text': '<p>You can encrypt the symmetric key using another symmetric key that is derived from a password using something like <a href="http://en.wikipedia.org/wiki/PBKDF2" rel="nofollow noreferrer">PBKDF2</a>.</p>\n\n<p>Have the user present a password, generate a new key used to encrypt the data, generate another key using the password, then encrypt and store the data encryption key.</p>\n\n<p>It isn\'t as secure as using a hardware token, but it might still be good enough and is pretty easy to use.</p>\n'}, {'answer_id': 50555, 'author': 'spoulson', 'author_id': 3347, 'author_profile': 'https://Stackoverflow.com/users/3347', 'pm_score': 0, 'selected': False, 'text': '<p>I think I misunderstood your question.  What you\'re asking for is not in scope of how the application handles its key storage, but rather how your company will store it.</p>\n\n<p>In that case, you have two obvious choices:</p>\n\n<ul>\n<li><p>Physical: Write to USB drive, burn to CD, etc.  Store in physically secure location.  But you run into the recursive problem: where do you store the key to the vault?  Typically, you delegate 2 or more people (or a team) to hold the keys.</p></li>\n<li><p>Software: <a href="http://www.cyber-ark.com/" rel="nofollow noreferrer">Cyber-Ark</a> Private Ark is what my company uses to store its secret digital information.  We store all our admin passwords, license keys, private keys, etc.  It works by running a Windows "vault" server that is not joined to a domain, firewalls all ports except its own, and stores all its data encrypted on disk.  Users access through a web interface that first authenticates the user, then securely communicates with the vault server via explorer-like interface.  All changes and versions are logged.  But, this also has the same recursive problem... a master admin access CD.  This is stored in our physical vault with limited access.</p></li>\n</ul>\n'}, {'answer_id': 50690, 'author': 'Jason Cohen', 'author_id': 4926, 'author_profile': 'https://Stackoverflow.com/users/4926', 'pm_score': 0, 'selected': False, 'text': "<p>Use a hard-coded key to encrypt the generated key before writing it out.  Then you can write it anywhere.</p>\n\n<p>Yes you can find the hard-coded key, but so long as you're assuming it's OK to store a symmetric key <em>anywhere</em>, it's not less secure.</p>\n"}, {'answer_id': 50692, 'author': 'Jason Cohen', 'author_id': 4926, 'author_profile': 'https://Stackoverflow.com/users/4926', 'pm_score': 0, 'selected': False, 'text': '<p>Depending on your application you could use the <a href="http://en.wikipedia.org/wiki/Diffie-Hellman" rel="nofollow noreferrer">Diffie-Hellman</a> method for two parties to securely agree on a symmetric key.</p>\n\n<p>After an initial, secure exchange, the key is agreed upon and the rest of the session (or a new session) can use this new symmetric key.</p>\n'}, {'answer_id': 70641, 'author': 'AviD', 'author_id': 10080, 'author_profile': 'https://Stackoverflow.com/users/10080', 'pm_score': 4, 'selected': True, 'text': '<p>There only two real solutions for (the technical aspect of) this problem. \nAssuming it\'s only the application itself that needs access the key...</p>\n\n<ol>\n<li><p>Hardware Security Module (HSM) - usually pretty expensive, and not simple to implement. Can be dedicated appliance (e.g. nCipher) or specific token (e.g. Alladin eToken). And then you still have to define how to handle that hardware...</p></li>\n<li><p>DPAPI (Windows Data Protection API). There are classes for this in System.Security.Cryptography (ProtectedMemory, ProtectedStorage, etc). This hands off key management to the OS - and it handles it well. Used in "USER_MODE", DPAPI will lock decryption of the key to the single user that encrypted it. \n(Without getting too detailed, the user\'s password is part of the encryption/decryption scheme - and no, changing the password does not foul it up.)</p></li>\n</ol>\n\n<p>ADDED: Best to use DPAPI for protecting your master key, and not encrypting your application\'s data directly. And don\'t forget to set strong ACLs on your encrypted key...</p>\n'}, {'answer_id': 107810, 'author': 'roo', 'author_id': 716, 'author_profile': 'https://Stackoverflow.com/users/716', 'pm_score': 1, 'selected': False, 'text': '<p>In response to #3 of this <a href="https://stackoverflow.com/questions/50142/symmetric-key-storage#50622">answer</a> from the OP</p>\n\n<p>One way for authorized members to be able to view the encrypted data, but without them actually knowing the key would be to use key escrow <a href="http://www.rsa.com/rsalabs/node.asp?id=2348" rel="nofollow noreferrer">(rsa labs)</a> <a href="http://en.wikipedia.org/wiki/Key_escrow" rel="nofollow noreferrer">(wikipedia)</a></p>\n\n<p>In summary the key is broken up into seperate parts and given to \'trustees\'. Due to the nature of private keys each segment is useless to by its self. Yet if data is needed to be decrypted then the \'trustees\' can assemble thier segments into the whole key.</p>\n'}, {'answer_id': 153467, 'author': 'AJ.', 'author_id': 7211, 'author_profile': 'https://Stackoverflow.com/users/7211', 'pm_score': 1, 'selected': False, 'text': "<p>We have the same problem, and have been through the same process.<br>\nWe need to have a process start up on one computer (client) which then logs in to a second computer (database server).  </p>\n\n<p>We currently believe that the best practice would be: </p>\n\n<ul>\n<li>Operator manually starts the process on client PC.  </li>\n<li>Client PC prompts operator for <em>his</em> personal login credentials.  </li>\n<li>Operator enters his credentials.  </li>\n<li>Client PC uses these to login to the database server. </li>\n<li>Client PC requests its own login credentials from database server.  </li>\n<li>Database server checks that operator's login credentials are authorised to get the client process' credentials and returns them to the client PC.  </li>\n<li>Client PC logs out of datbase server.  </li>\n<li>Client PC logs back into database server using its own credentials. </li>\n</ul>\n\n<p>Effectively, the operator's login password is the key, but it isn't stored anywhere.  </p>\n"}]
['https://Stackoverflow.com/questions/50142', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2596/']