Questions tagged [always-encrypted]

Always Encrypted is a feature of Microsoft SQL Server 2016+ and Azure SQL Database, designed to protect sensitive data. It allows client applications to encrypt sensitive data without revealing the encryption keys to the database engine, so the data cannot be accessed either in flight on the wire or at rest on SQL Server.

Always Encrypted is a feature of Microsoft SQL Server 2016 and Azure SQL Database, designed to protect sensitive data. It allows client applications to encrypt sensitive data without revealing the encryption keys to the database engine, so the data cannot be accessed either in flight or at rest.

See MSDN for more details.

Encryption Keys

This is mainly focused on 2 Keys

  1. Column Master Key (CMK)
  2. Column Encryption Key (CEK)

CMK

Creates a column master key metadata object in a database. A column master key metadata entry that represents a key, stored in an external key store, which is used to protect (encrypt) column encryption keys when using the Always Encrypted (Database Engine) feature. Multiple column master keys allow for key rotation; periodically changing the key to enhance security. You can create a column master key in a key store and its corresponding metadata object in the database by using the Object Explorer in SQL Server Management Studio or PowerShell.

Read more here

CEK

Creates a column encryption key with the initial set of values, encrypted with the specified column master keys. This is a metadata operation. A CEK can have up to two values which allows for a column master key rotation. Creating a CEK is required before any column in the database can be encrypted using the Always Encrypted (Database Engine) feature. CEK's can also be created by using SQL Server Management Studio

Before creating a CEK, you must define a CMK by using Management Studio or the CREATE COLUMN MASTER KEY statement.

Read more here

Types of Encryption

  1. Deterministic Encryption
  2. Randomized Encryption

Deterministic Encryption

Deterministic encryption always generates the same encrypted value for any given plaintext value. Using deterministic encryption allows point lookups, equality joins, grouping and indexing on encrypted columns. However, but may also allow unauthorized users to guess information about encrypted values by examining patterns in the encrypted column, especially if there is a small set of possible encrypted values, such as True/False, or North/South/East/West region. Deterministic encryption must use a column collation with a binary2 sort order for character column

Randomized Encryption

Randomized encryption uses a method that encrypts data in a less predictable manner. Randomized encryption is more secure, but prevents searching, grouping, indexing, and joining on encrypted columns.

Read more here

299 questions
3
votes
1 answer

SQL server 2016 always encrypted certificate stopped working, timeout error

Yesterday the always encrypted certificate stopped working. Which drove my application to a halt. The only response I got from the application was timeout error. I have a database with a user table, where pwd is encrypted. The web server has the…
3
votes
1 answer

SQL Server 2016 Always Encrypted Timeout at Published IIS

I Have strange problem when i tried to publish my asp.net mvc application to my local (pc) iis with "Always Encrypted" Enabled. My application keep timeout when i tried to access database using EF6 at local IIS (not express) : But if i tried to…
3
votes
3 answers

Always Encrypted Feature - Failed to decrypt column. Call from Windows-Service App

.NET Framework Ver = 4.6.2 , Database = SQL Server 2016 App Type = Windows Service We are working on the "Always Encrypted" feature in the SQL 2016 db to perform the encryption on certain customer data columns. Our web application is built in the…
Karan
  • 3,265
  • 9
  • 54
  • 82
3
votes
1 answer

Always Encrypted with Azure Key Vault SSMS Purge Error

I'm trying to setup a new Always Encrypted database using Azure Key Vault (I have previously had this working). In the SSMS Always Encrypted Wizard I can select the table and column to encrypt but I have a problem after selecting "Azure Key Vault"…
Al.
  • 73
  • 1
  • 6
3
votes
1 answer

SQL Server 2016 - Is it possible to concatenate two nvarchar always encrypted columns?

I have created a table using: create table dbo.employee(firstname nvarchar(100) null,lastname nvarchar(100) null) Inserted some sample data using: insert into dbo.employee values('Sachin','Tendulkar') insert into dbo.employee…
CleanBold
  • 1,551
  • 1
  • 14
  • 37
3
votes
2 answers

SQL Server 2016 How to read/write to an always encrypted column from command line?

I am able to read and write to a column with always encrypted from a C# ASP.NET app. However, I need to do it from sqlcmd. After some research I found here, that you need the -g parameter to activate the Column Encryption Setting, and to update to…
user7792598
  • 177
  • 1
  • 6
  • 17
3
votes
2 answers

Memory Optimized Tables + Encryption and Identity Column

I was wondering whether it is possible to have a always encrypted Memory Optimized Table and also have its Primary Key automatically seeded? For example, I want to create the following: CREATE TABLE Foo ( [Id] [int] Identity(1,1) NOT NULL, …
Dr Schizo
  • 4,045
  • 7
  • 38
  • 77
3
votes
2 answers

Always Encrypted SQL 2016 and Entity Framework 6: “Operand type clash: datetime2 is incompatible with date”

Current project: MVC 5.2 DotNet 4.6.2 EF 6 Identity 2 (modified as per the repository pattern below) SQL Server 2016 RTM Repository Pattern: Persistence-Ignorant ASP.NET Identity Always Encrypted column encryption as described here and here All SQL…
3
votes
3 answers

Azure Key Vault .NET - Method not found

I want to use an Always Encrypted SQL 2016 DB in my .NET app with an Azure Key Vault for storing the encryption keys. I have been following this article so far:…
3
votes
2 answers

How to encrypt column SQL Server 2016 Always Encrypted ? -Alter Query

It's easy to encrypt column using query in SQL Server 2016 with "Always Encrypted". But we have existing tables. So how to encrypt a column in existing table? I need it using alter query. I tried following Query alter table testemp alter column…
Karthikeyan
  • 173
  • 4
  • 18
2
votes
1 answer

How to resolve this error: "Encryption scheme mismatch for columns/variables" for Always Encrypted feature enabled in Entity Framework

I am getting below exception when I try to run the application from visual studio 2019. I am fetching data through Entity framework form SQL server 2019. I have made all necessary configurations to enable always encrypted in respective DB and…
2
votes
2 answers

Using SQL server Always Encrypted in asp.net core app that is deployed to docker/ linux

I have created an ASP.NET Core Web API app that connects to a SQL Server database. I have a table in which I need to use SQL Server always encryption. I'm creating a column master key with the following T-SQL: CREATE COLUMN MASTER KEY [MyCMK] …
Ali.Rashidi
  • 1,284
  • 4
  • 22
  • 51
2
votes
0 answers

is it possible to select encrypted data and insert into another table via T-SQL?

I want to select the encrypted data via some conditional expression. So I tried 2 method to select data shown below. Method1: I have a table called "EncryptedIdentityID", which contains 3 columns…
SIMON
  • 21
  • 3
2
votes
1 answer

Operand type clash: varchar is incompatible with varchar(255) Using Always Encrypted with Secure Enclaves and CASE statement

I'm trying to return an Encrypted value from the database from within a Case Statement. DECLARE @emptyValue VARCHAR(255) = ''; Select Top 1 CASE WHEN o.shippingFirstName = @emptyValue AND o.shippingLastName = @emptyValue THEN '' ELSE…
Chris Utt
  • 21
  • 2
2
votes
1 answer

Authenticate to SQL Server through PowerShell with MFA (Active Directory Interactive)

I am trying to set up a PowerShell script to enable Always Encrypted on our Azure SQL Server databases. I am following this guide, which offers the following sample code: # Import the SqlServer module Import-Module "SqlServer" # Connect to your…