sql server - Enforcing a unique constraint on a column encrypted with cell level encryption -
i want enforce unique constraint on column must encrypted in mssql 2005 using cell level encyption (cle).
create master key encryption password = 'itsasecret!!!3£3£3£!!!' create certificate ercert subject = 'a cert use procs' create symmetric key erkey algorithm = aes_256 encryption certificate ercert -- illustrates point. -- results differ declare @temptable table ( [email] [varbinary](254) unique not null ) open symmetric key erkey decryption certificate ercert insert @temptable(email) values(encryptbykey(key_guid('erkey'), n'duplicate')) insert @temptable(email) values(encryptbykey(key_guid('erkey'), n'duplicate')) insert @temptable(email) values(encryptbykey(key_guid('erkey'), n'duplicate')) close symmetric key erkey select * @temptable the output makes obvious why constraint has 'not' been enforced. (please excuse awesomeness of ascii-art.)
email ------- 1 | 0x00703529af46d24ba863a3534260374e01000000328909b51ba44a49510f24df31c46f2e30977626d96617e2bd13d9115eb578852eebae326b8f3e2d422230478a29767c 2 | 0x00703529af46d24ba863a3534260374e01000000773e06e1b53f2c57f97c54370fecbb45bc8a154fea5ceeb9b6bb1133305282328aafad65b9bdc595f0006474190f6482 3 | 0x00703529af46d24ba863a3534260374e01000000c9edb1c83b52e60598038d832d34d75867ab0abb23f9044b7ebc76832f22c432a867078d10974dc3717d6086d3031bdb but, how work around this?
normally, use "deterministic encryption", example, aes ecb mode, or aes-siv. since within limitations of sql server encryption, you'll have find way. here old post discusses issue: http://blogs.msdn.com/b/raulga/archive/2006/03/11/549754.aspx. here newer post mentions sql server 2016 support deterministic encryption: http://www.brentozar.com/archive/2015/05/sql-server-2016-security-roadmap-session-notes-msignite/, looking for.
Comments
Post a Comment