Enabling Transparent Data Encryption (TDE)

Published Mar 23 2019 11:29 AM 211 Views
Microsoft
First published on TECHNET on May 10, 2010

Transparent Data Encryption (TDE) is a feature added in SQL Server 2008 which allows you to encrypt an entire database at a time. A major potential benefit is that when TDE is enabled, all backups are automatically encrypted, which may be worthwhile if you have concerns that copies of the backup files may end up on insecure file servers.


If you need TDE, or want to play with it on a development system, I've attached a script to this post to help you enable it as quickly and easily as possible. In fact, that script is my main purpose for this post, but I figured I'd add a few relevant thoughts to help folks decide whether or not to download and look at the script.


Database encryption encodes the data at-rest (on the hard drives) and helps protect against file-level attacks. It makes it difficult or impossible (for most folks) to read the data without the key, but it comes with a cost – in extra CPU cycles both to encrypt and decrypt. Which leads into a set of precautions...


Warning: Don't turn on TDE just because you can. Here are some issues to consider before you do. First, all encryption/decryption increases CPU utilization, so it should not be used unless it is needed. Secondly, if you use TDE, you must backup the encryption keys (and optional passwords) because your backups will be useless without them. Third, if any database is encypted by TDE, the tempdb will be encrypted, and if tempdb encryption/decryption causes performance problems on non-encrypted databases, you should consider having your encrypted databases on a separate instance of SQL Server from the non-encrypted databases.


Other Comments: For a database that is small enough to fit entirely into memory, or for databases with infrequent inserts and updates, the extra CPU cycles will usually be an insignificant additional cost. Even for in-memory databases, though, encrypting data on disk is a low priority because file access protections provide a strong first-line-of-defense, and encrypted data on disk is useless if someone can pull it out through conventional queries. Even on a laptop, full-disk encryption such as BitLocker can provide a better alternative in many cases. Finally, note that TDE will not encrypt data stored in the file system using SQL Server FileStream.



Enable TDE.sql

%3CLINGO-SUB%20id%3D%22lingo-sub-383618%22%20slang%3D%22en-US%22%3EEnabling%20Transparent%20Data%20Encryption%20(TDE)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-383618%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20TECHNET%20on%20May%2010%2C%202010%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3ETransparent%20Data%20Encryption%20(TDE)%20is%20a%20feature%20added%20in%20SQL%20Server%202008%20which%20allows%20you%20to%20encrypt%20an%20entire%20database%20at%20a%20time.%20A%20major%20potential%20benefit%20is%20that%20when%20TDE%20is%20enabled%2C%20all%20backups%20are%20automatically%20encrypted%2C%20which%20may%20be%20worthwhile%20if%20you%20have%20concerns%20that%20copies%20of%20the%20backup%20files%20may%20end%20up%20on%20insecure%20file%20servers.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EIf%20you%20need%20TDE%2C%20or%20want%20to%20play%20with%20it%20on%20a%20development%20system%2C%20I've%20attached%20a%20script%20to%20this%20post%20to%20help%20you%20enable%20it%20as%20quickly%20and%20easily%20as%20possible.%20In%20fact%2C%20that%20script%20is%20my%20main%20purpose%20for%20this%20post%2C%20but%20I%20figured%20I'd%20add%20a%20few%20relevant%20thoughts%20to%20help%20folks%20decide%20whether%20or%20not%20to%20download%20and%20look%20at%20the%20script.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3EDatabase%20encryption%20encodes%20the%20data%20at-rest%20(on%20the%20hard%20drives)%20and%20helps%20protect%20against%20file-level%20attacks.%20It%20makes%20it%20difficult%20or%20impossible%20(for%20most%20folks)%20to%20read%20the%20data%20without%20the%20key%2C%20but%20it%20comes%20with%20a%20cost%20%E2%80%93%20in%20extra%20CPU%20cycles%20both%20to%20encrypt%20and%20decrypt.%20Which%20leads%20into%20a%20set%20of%20precautions...%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3EWarning%3A%20%3C%2FSTRONG%3E%20Don't%26nbsp%3Bturn%20on%26nbsp%3BTDE%20just%20because%20you%20can.%20Here%20are%20some%26nbsp%3Bissues%20to%20consider%20before%20you%20do.%26nbsp%3BFirst%2C%20all%20encryption%2Fdecryption%20increases%20CPU%20utilization%2C%20so%20it%26nbsp%3Bshould%20not%20be%20used%20unless%20it%20is%20needed.%20Secondly%2C%20if%20you%20use%20TDE%2C%20you%20must%20backup%20the%20encryption%20keys%20(and%20optional%20passwords)%20because%20your%20backups%20will%20be%20useless%20without%20them.%20Third%2C%20if%20any%20database%20is%20encypted%20by%20TDE%2C%20the%20tempdb%20will%20be%20encrypted%2C%20and%20if%20tempdb%20encryption%2Fdecryption%20causes%20performance%20problems%20on%20non-encrypted%20databases%2C%20you%20should%20consider%20having%20your%20encrypted%20databases%20on%20a%20separate%20instance%20of%20SQL%20Server%20from%20the%20non-encrypted%20databases.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CSTRONG%3EOther%20Comments%3A%20%3C%2FSTRONG%3E%20For%20a%20database%20that%20is%20small%20enough%20to%20fit%20entirely%20into%20memory%2C%20or%20for%20databases%20with%20infrequent%20inserts%20and%20updates%2C%20the%20extra%20CPU%20cycles%20will%20usually%20be%20an%20insignificant%20additional%20cost.%20Even%20for%20in-memory%20databases%2C%20though%2C%20encrypting%20data%20on%20disk%20is%20a%20low%20priority%20because%20file%20access%20protections%20provide%20a%20strong%20first-line-of-defense%2C%20and%20encrypted%20data%20on%20disk%20is%20useless%20if%20someone%20can%20pull%20it%20out%20through%20conventional%20queries.%20Even%20on%20a%20laptop%2C%20full-disk%20encryption%20such%20as%20BitLocker%20can%20provide%20a%20better%20alternative%20in%20many%20cases.%20Finally%2C%20note%20that%20TDE%20will%20%3CSTRONG%3E%20not%20%3C%2FSTRONG%3E%20encrypt%20data%20stored%20in%20the%20file%20system%20using%20SQL%20Server%26nbsp%3BFileStream.%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3C%2FP%3E%3CBR%20%2F%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fmsdnshared.blob.core.windows.net%2Fmedia%2FTNBlogsFS%2Fprod.evol.blogs.technet.com%2Ftelligent.evolution.components.attachments%2F01%2F7622%2F00%2F00%2F03%2F33%2F15%2F82%2FEnable%2520TDE.sql%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%22%3E%20Enable%20TDE.sql%20%3C%2FA%3E%3C%2FP%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-383618%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20TECHNET%20on%20May%2010%2C%202010%20Transparent%20Data%20Encryption%20(TDE)%20is%20a%20feature%20added%20in%20SQL%20Server%202008%20which%20allows%20you%20to%20encrypt%20an%20entire%20database%20at%20a%20time.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-383618%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerSecurity%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Mar 23 2019 11:29 AM
Updated by: