SQL Server – How Database Encryption Key for TDE is Linked to Certificate

sql servertransparent-data-encryption

The MSDN article on SQL Server TDE states "Create a database encryption key and protect it by the certificate". What does protect mean? The database encryption key is not created from the certificate?

Best Answer

"Create a database encryption key and protect it by the certificate". What does protect mean?

This is from the encryption hierarchy and protection. When using TDE you need to create at least two keys:

  1. Server Certificate to protect the DEK
  2. Database Encryption Key (DEK)

The way this works is as follows:

  1. The Service Master Key (SMK) protects the database master key (DMK). When we say "protects" we mean encrypts. This could be said as, "The SMK encrypts the DMK."
  2. The DMK in the master database "protects" (Encrypts) the Server Certificate.
  3. The Server Certificate "protects" (Encrypts) the Database Encryption Key (DEK).

This means, in order to OPEN the DEK to decrypt the database data you need to open the Server Certificate. To open the Server Certificate you'll need to open the Database Master Key (DMK). To open the DMK you'll need to open the SMK.

This is normally done automatically for you as part of automatic key decryption if all levels of the hierarchy are setup properly.

Thus, if we attempt to restore the database using TDE to another instance and that instance does not have the server certificate then it will not be able to read the database and cannot open the database. This is why the Server Certificate is required and we can open it properly.

Encryption Hierarchy: https://msdn.microsoft.com/en-us/library/ms189586.aspx