By the end of today’s lecture, you will learn:
“Cryptography is about communication in the presence of an adversary.”
– Prof. Ron Rivest
Encryption is one of the main tools that we use to protect data confidentiality. The goal of Part 3 of this course is to study encryption and its role in:
Last time, we studied pseudorandom permutations \(f: \{0, 1\}^n \to \{0, 1\}^n\), which are deterministic, fixed-length functions that act “as if” they are random.
The most common pseudorandom permutation used in practice is the Advaned Encryption Standard (AES).
We also studied the sponge function design, from which we constructed many symmetric crypto primitives.
The SHA-3 hash function family.
Password-based hash functions that are deliberately slow.
Symmetric key encryption, which allows two parties to send messages to each other with confidentiality.
A message authentication code, which allows two parties to send messages to each other with integrity. It is the symmetric-key version of a signature scheme, where each party can both sign and verify.
A combined primitive called authenticated encryption that performs both of these tasks at once.
Definition. Authenticated encryption with associated data (AEAD) contains three algorithms:
KeyGen
: randomly choose \(k\), as usualEnc
\((k, P, A, N)\): produces a ciphertext/tag \(C\) of length \(|C| > |P|\)Dec
\((k, C, A, N)\): returns the original private message \(P\)“If you have to perform any cryptographic operation before verifying the MAC on a message you’ve received, it will somehow inevitably lead to doom!”
– Moxie Marlinspike
Our goal for today is to study encryption of data on your laptop or phone.
All major operating systems support disk encryption, often by default.
Operating system | Product | On by default since… |
---|---|---|
Windows | Microsoft Bitlocker | Windows 8 (2012) |
Mac OS X | Apple FileVault | OS X Yosemite 10.10 (2014) |
Linux | Linux Unified Key Setup (luks) | |
Multi OS 3rd party tools | TrueCrypt, SecureDoc, … | |
iOS | [built into OS] | iOS 8 (2013) |
Android | [built into OS] | Android 6.0 (2015) |
Our objective is to protect data confidentiality against an adversary Mallory who temporarily obtains physical access to Alice’s laptop or phone.
Here is the scenario with Alice and Mallory that we will consider today.
Alice | Mallory | Future Alice | ||
---|---|---|---|---|
|
\(\longrightarrow\) |
|
\(\longrightarrow\) |
|
Alice’s actions
Mallory’s capabilities
Our objective: even with these powers, Mallory still cannot
Non-objective: Mallory can replay earlier contents of the hard drive. We will not be able to use crypto to stop this.
We will consider two options.
Imagine you are the manufacturer of the hard drive and other hardware. Your goal is to build a cryptosystem that automatically encrypts the drive.
Some terminology: the basic unit of data within a hard drive is called a “sector.” Sectors have a fixed length specified by the drive manufacturer.
Here are the 4 types of hardware that we are going to consider today.
Remember that having the secret key gives someone the power to decrypt and read a message. With that in mind, whenever you see encryption used in practice, the first question you should ask is “where are the keys?
Question. In sector-level encryption, where should we store the symmetric key?
An appealing, but ultimately incorrect, idea is to store the symmetric key in hard drive. After all, we already use the hard drive to store everything else.
Question. Why is this a mistake?
Instead, a better workflow is to store the key in a tamper-resistant piece of hardware when the computer is off, and move the key into the RAM when the computer is on.
Sector-level encryption uses a special kind of symmetric encryption scheme, called AES-XTS. Why is that?
How does the Trusted Platform Module work?
It computes the symmetric encryption key \(k\) at boot time from:
Importantly: when the device is powered off, it lacks the ability to derive the key!
Recall that in the last lecture, we discussed the idea of a password hash function that is deliberately slow to frustrate brute-force attackers.
Password hashing is useful when your goal is to compare equality of the current password attempt with the correct password provided during account registration.
By contrast, in today’s lecture we want to do something stronger.
Concretely, we want a function that maps a password \(P\) \(\mapsto\) a symmetric key \(K\).
This is the best way to derive symmetric keys from a login procedure that is non-interactive (i.e., runs on your computer, rather than with a web server) because the device never stores its own long-term secrets.
/etc/passwd
PBKDF2 works as shown on the right. It uses a pseudorandom function (PRF) and has four inputs.
The output is the symmetric key \(MK\).
Common PRFs used in practice are AES and HMAC-SHA2 (which is just SHA-2 with some important but minor tweaks).
What if several keys should grant access to the data on the hard drive?
However, we do not want to encrypt the entire drive several times.
\[ \operatorname{Enc}_{\text{K1}}(\text{sector}) \quad \operatorname{Enc}_{\text{K2}}(\text{sector}) \quad \operatorname{Enc}_{\text{K3}}(\text{sector}) \]
Question. What can we do instead?
Key wrapping is a special kind of encryption that allows us to protect one key under another.
\[ \operatorname{Wrap}_{\text{K1}}(ek) \quad \operatorname{Wrap}_{\text{K2}}(ek) \quad \operatorname{Wrap}_{\text{K3}}(ek) \quad \operatorname{Enc}_{\text{ek}}(\text{sector}) \]
There are two downsides to this approach:
For the rest of today’s lecture, we will explore how modern operating systems encrypt data at the filesystem level. This approach is more flexible because we don’t have to fit the encrypted data back into a fixed-size sector.
As a case study, we will examine the design of Apple’s data encryption system on iPhones.
This part of the lecture is based on the descriptions in Apple’s security guide.
They have provided full disk encryption since iOS 8, with TPM-like hardware protection of key material since the iPhone 5s (released in September 2013)
File-level encryption on other phones and laptops works similarly.
Core idea: data should only be decryptable in the right context.
The iOS file-level encryption system uses a lot of symmetric keys.
Let’s work our way through this image from right to left. There is (at least) one symmetric key for each file that is stored on the drive.
“Every time a file on the data volume is created, Data Protection creates a new 256-bit key (the per-file key) and gives it to the hardware AES Engine, which uses the key to encrypt the file as it’s being written to flash storage.
On A14 through A18 and M1 through M4 devices, the encryption uses AES-256 in XTS mode, where the 256-bit per-file-key goes through a Key Derivation Function (NIST Special Publication 800-108) to derive a 256-bit tweak and a 256-bit cipher key.”
– Apple Platform Security guide (link)
Since Apple controls both the software and hardware:
Moving left, each of the file keys is itself key-wrapped using a “class key,” which determines when the file needs to be readable and writable.
Availability | Example | Key erased if phone is… |
---|---|---|
Always | SIM PIN | Wiped |
After 1st unlock | WiFi password | Shut down |
When unlocked | Browser bookmarks | 10s after unlock (without biometric) |
When locked | Incoming email | (works differently) |
This keywrap goes in the file’s metadata. Whenever the file is read, the filesystem is designed to retrieve this metadata along with the encrypted file contents.
Question. How does the phone get the class keys?
Remember our mantra for today: derive keys rather than storing them! Once again we use keywrapping to protect the class keys with a passcode key that is derived from:
Note that there exist other ways to derive the class keys, in order to enable:
There are two countermeasures built into the phone in order to make brute forcing the PIN as difficult as possible.
Remember that encryption is a powerful tool with immense social consequences.
“Cryptography rearranges power: it configures who can do what, from what.”
– Prof. Phillip Rogaway (UC Davis)
Let’s look at some of the legal questions raised by the use of encryption.
The latter question gained significant attention in early 2016, when the FBI wanted data on a locked iPhone 5c in its possession, but they did not have the PIN.
Remember that key
= pbkdf2(pin
, uid
), so to read the files they could:
pin
on the phone itself, oruid
and then brute-force the pin
on a faster computer.FBI wanted Apple to modify its operating system to enable a brute-force search of the PINs:
Note: the iPhone 5c does not have a Secure Enclave, so its delay is software-enforced rather than hardware-enforced.
Question. If these are software-only protections, why couldn’t the FBI change the operating system code on its own?
Here we need to discuss the crypto used for updates to the operating system. Since the code itself is not a secret, here the goal is integrity.
The server’s digital signature contains:
Many (though not all!) automatic software update systems for operating systems and individual programs work similarly.
The FBI wanted Apple to produce and digitally sign an updated “GovtOS” without the delay and poison pill. Only Apple could create this software update, or else the phone would reject it.
This court case was never fully resolved.
We will discuss more interactions between cryptography and the law, often informally dubbed the Crypto Wars, in Part 5 of the course.
DS 653 — Lecture 16