Partial search on Encrypted field

冷暖自知 提交于 2020-01-03 04:47:08

问题


Recently I am assigned with a problem, encrypting the database field such as SSN but still have to keep the "partial searching" working on it.

E.g: SSN 123-45-6789 is encrypted to abcdxyz in the database. When user enters "2345" to the search box then it has to come up in the result.

We have millions records in the database. We are using SQL server 2008 R2. I has been googling around but still not see any good solution yet. Is there any good solution for this ?

Thanks for help.


回答1:


No, there isn't. If it would be possible to search an encrypted field then by definition it would be badly encrypted. The possible alternatives are:

  1. Search on decrypted values. This is unbearable slow in practice as millions of values have to be decryption for each query.
  2. Only search exact matches. Since the encrypted values are salted, the exact match search is only possible if a cryptographically secure hash is stored along with the encrypted data and the search is done on the hash value.
  3. Use Transparent Data Encryption instead of column encryption.

Option 3) is by far the best, but requires Enterprise Edition licensing. If TDE is not available, then the requirement for partial search must be removed, there is no realistic way to satisfy it.




回答2:


There are fewer than 1 billion possible values for a SSN, and the distribution is not even. If someone were to obtain a copy of your database, a brute-force attack on any particular record would be straightforward. In fact, if the person's birthdate and state are in cleartext in the record and they are born prior to 2011, a custom algorithm can cut the number of likely SSNs down tremendously, making a brute-force attack much easier.

As you've noticed, once you encrypt data, you can't search the clear text of it without decrypting every record first -- an unreasonably expensive operation.

I applaud the desire to protect people's privacy, but you should be using TDE, BitLocker, or EFS, not encrypting individual fields like this.



来源:https://stackoverflow.com/questions/12258738/partial-search-on-encrypted-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!