21
ALWAYS ENCRYPTED Beginners 101 Guide To Always Encrypted

Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

ALWAYS ENCRYPTED

Beginners 101 Guide To Always Encrypted

Page 2: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

MONICA RATHBUNConsultant

Denny Cherry & Associates Consulting

PASS Mid-Atlantic Regional Mentor

User Group Leader: Hampton Roads SQL Server User Group

[email protected]

@SQLEspresso

http://www.sqlespresso.com

http://www.linkedin.com/in/sqlespresso

Page 3: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

PRESENTATION RULES

Always ask Questions

Interrupt Me

This is a two way conversation, let’s learn from each other’s experiences.

Page 4: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

AGENDA

The Basic Terminology

Types of Encryption

What is Always Encrypted (AE)?

Key Storage

How to Encrypt/Decrypt

GOTCHAS

vNext Enclaves

Page 5: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

ENCRYPTION TERMINOLOGY• Encrypt & Decrypt

• Column Encryption Key (CEK)

• Column Master Keys (CMK)

• Certificate

• Key Vaults

Page 6: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

TYPES OF ENCRYPTIONType Usage Things to Note

Transparent Data Encryption (TDE)

Database Level

Data at Rest, Decrypted while in motion from Memoryto Storage processor.

Column Level Encryption

Column LevelDBA Can Get to Data, SQL Knows The Keys

Dynamic Data Masking Column Level Not Really Encryption

Always Encryption Column LevelEncrypted Everywhere For Everyone

Page 7: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

WHAT IS AE ?

Available in Standard 2016 SP1 STANDARD

Can be used to Block DBA’s from seeing the data

• CEK is stored outside of SQL Server

No Code Changes Needed*

Data Encrypted as it is SENT to

application

Page 8: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

TWO TYPES OF AE

Deterministic

ABCACBACB

WHERE clauses,

GROUP BY and JOINS.

Indexes

Randomized

ABCACBACB, BBBCCAA, or CCCAAABBB

More Secure

Non Searchable

Page 9: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

Distributed Queries (linked servers)

No Default Or Check Constraints

No Partition Columns

Columns Reference By Computed

Columns

No Transactional/Merge

Replication Aggregations

Columns with the IDENTITY property

No Triggers

AE GOTCHAS

Page 10: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

STORING KEYS

WINDOWS CERTIFICATE STORE

Local to Server https://docs.microsoft.com/en-us/dotnet/framework/wcf/feature-details/how-to-view-certificates-with-the-mmc-snap-in

AZURE KEY Vault

Azure Subscription

Reliable Internet

https://azure.microsoft.com/en-us/services/key-vault/ternet Connection

Page 11: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

WINDOWS CERTIFICATE STORE

Two certificate locations: local

machine or current user

Key store exists on each machine

hosting your application

Page 12: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

AZURE KEY VAULT

• Extra Security Level

• Role Separation

• Key Logs to Audit Key Usage

Page 13: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

ENCRYPTION DEMO

Page 14: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

DECRYPTION IN SSMSSSMS uses .NET 4.6 so you can pass in the necessary encryption options. SSMS uses the connection string to access the Master Key and return the data in its decrypted format.

Page 15: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

DECRYPTION IN APPLICATIONDatabase Permissions

• VIEW ANY COLUMN MASTER KEY DEFINITION

• VIEW ANY COLUMN ENCRYPTION KEY DEFINITION

These permissions are required to access the metadata about Always Encrypted keys in the database.

string connectionString = "Data Source=server63; Initial Catalog=Clinic; Integrated Security=true; Column Encryption Setting=enabled"; SqlConnection connection = new SqlConnection(connectionString);

Page 16: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

DECRYPTION IN APPLICATIONDatabase Permissions

• VIEW ANY COLUMN MASTER KEY DEFINITION

• VIEW ANY COLUMN ENCRYPTION KEY DEFINITION

These permissions are required to access the metadata about Always Encrypted keys in the database.

string connectionString = "Data Source=server63; Initial Catalog=Clinic; Integrated Security=true;

Column Encryption Setting=enabled"; SqlConnection connection = new SqlConnection(connectionString);

Page 17: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

DECRYPTION DEMO

Page 18: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

VNEXT…ENCLAVES (IN PREVIEW)

An enclave is a protected region of memory that acts as a trusted execution environment.

An enclave appears as a black box to the containing process and to other processes running on the machine. There is no way to view the data or the code inside the enclave from the outside, even with a debugger.

Page 19: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

AE USING ENCLAVES (IN PREVIEW)

• Pattern Matching• Range Comparisons• Sorting

Rich Computations

• Initial Data Encryption• Rotating a Column Encryption Key• Changing a Data Type of an Encrypted

Column

In-PlaceEncryptions

Page 20: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

QUESTIONS?

Page 21: Always ENcrypted - A Shot of SQLEspresso€¦ · MONICA RATHBUN Consultant Denny Cherry & Associates Consulting PASS Mid-Atlantic Regional Mentor User Group Leader: Hampton Roads

RESOURCESMSDNhttps://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/always-encrypted-database-engine?view=sql-server-2017

Secure Enclaves https://blogs.msdn.microsoft.com/sqlsecurity/2017/10/05/enabling-confidential-computing-with-always-encrypted-using-enclaves-early-access-preview/

TDEhttps://docs.microsoft.com/en-us/sql/relational-databases/security/encryption/transparent-data-encryption?view=sql-server-2017

Aaron Bertrand Bloghttps://blogs.sentryone.com/aaronbertrand/t-sql-tuesday-69-always-encrypted-limitations/