+ All Categories
Home > Documents > SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James...

SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James...

Date post: 15-Jun-2020
Category:
Upload: others
View: 3 times
Download: 0 times
Share this document with a friend
25
Presented by Date Event SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15
Transcript
Page 1: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Presented by

Date

Event

SFO15-503: Secure storage in OP-TEE

James Kung, SY ChiuJames Kung, Sheng-Yu Chiu

Friday 25 September 2015

SFO15

Page 2: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Agenda

● Overview● Key Manager● Atomic Operations● Future Work

Page 3: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Secure Storage System Architecture

REE File Operation Interface

TEE Supplicant

TEE DriverREE FileSystem TEE FileSystem Key

Manager

TEE File Operation Interface

TEE Trusted Storage Service

TATATA

GP Trusted Storage API

Support Atomic Operations

Normal World Secure World

Use

r Spa

ceK

erne

l Spa

ce

Page 4: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

GP Trusted Storage Requirement

From GlobalPlatform TEE Internal Core API v1.1:(section 2.5 and section 5.2)

● Must be bound to a particular device● Guarantees on the confidentiality and integrity of the data● Guarantees on the atomicity of the operations that modify the storage● Ability to hide sensitive key material from the TA itself● Separation of storage among different TAs● Provide protection against rollback attacks (future work)

Page 5: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

TEE File Operation Interfaceint (*open)(const char *file, int flags, ...);

int (*close)(int fd);

int (*read)(int fd, void *buf, size_t len);

int (*write)(int fd, const void *buf, size_t len);

tee_fs_off_t (*lseek)(int fd, tee_fs_off_t offset, int whence);

int (*rename)(const char *old, const char *new);

int (*unlink)(const char *file);

int (*ftruncate)(int fd, tee_fs_off_t length);

int (*access)(const char *name, int mode);

int (*mkdir)(const char *path, tee_fs_mode_t mode);

tee_fs_dir *(*opendir)(const char *name);

int (*closedir)(tee_fs_dir *d);

struct tee_fs_dirent *(*readdir)(tee_fs_dir *d);

int (*rmdir)(const char *pathname);

Page 6: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

TEE Storage And File Structure In REE File System

block 0

block 1

block N

● Provide separate folder for each TA

● TEE filename == object id (provided by TA)

● TEE file == a folder contains a meta file and several block files (folder name is object id)

● Meta file○ Storing info. of a TEE file. e.g. file length.○ Always encrypted

● block file○ Storing TEE file data○ Optionally encrypted depends on the

compile time flag - CFG_ENC_FS

/data/tee/

<obj-id>/

<ta-uuid>/

meta* default max. data size in block file is 4KB

* default max. number of blocks is 1024

* default max TEE file size = 4MB (4KB * 1024)

Page 7: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

● Overview● Key Manager● Atomic Operations● Future Work

Page 8: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Key Manager● Provide file encryption/decryption functions● Key management

○ Secure Storage Key (SSK)■ Per-device key■ Used by secure storage subsystem for FEK

encryption/decryption■ Generated and stored in secure memory at boot time

○ File Encryption Key (FEK)■ Per-file key■ Used for TEE file encryption/decryption■ Generated, encrypted and stored in meta file when a

new TEE file is created

Page 9: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Key Derivation

● Secure Storage Key (SSK)○ SSK = HMACSHA256(HUK, Chip ID || “static string”)○ HUK: Hardware Unique Key

● File Encryption Key (FEK)○ By default, generated by Fortuna (PRNG*)○ Default key length: 128 bits

* It is better to leverage platform H/W RNG(TRNG) if your platform supports that

* Can be implemented in platform porting layer

* To avoid other subsystems to generate the same per-device key

Page 10: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Meta Data Encryption

Meta IV Tag Encrypted Meta Data

AESECBSSK

FEK

AESGCM

Meta DataMeta IVEncrypted FEK

Encrypted FEK

Generated by PRNG, and default length is 96 bits

Meta Data = {TEE_file_data_length;backup_version_table[number of blocks];

}

Meta File:

AAD

Page 11: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Block Data Encryption

Block IV Tag Encrypted Block Data

AESECBSSK

FEK

AESGCM

Block DataBlock IV

Generated by PRNG, and default length is 96 bits

...Encrypted FEKMeta File:

Block File:

Decryption

Page 12: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

● Overview● Key Manager● Atomic Operations● Future Work

Page 13: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

What is Atomic Update

● Each update can only have two results○ Update succeed○ Update failed, rollback to old version

● We cannot modify the file contents directly○ Out-of-place update○ Modify a copy of file content instead

Page 14: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Changes to Support Out-of-place Update

data.0 data.1

write datawrite data

● Both Meta and Block file has an additional attribute called backup version, backup version is 0 or 1

● We toggle the backup version each time when we want to update something

● We should follow the step to update meta or block file

Page 15: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

How to Keep Track Backup Version

Meta.0 Block0.0

Block1.1

BlockN.0

0 1 1 0version table

● Introduce a version table in meta data, which stores the backup version of each Block file. This is used to keep track of the backup version of each block file.

Block2.1

Page 16: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

GP Internal Core API Says...

● The following operations should be atomic○ Write○ Truncate○ Rename○ Create/Delete

Page 17: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Ensure Atomic Operation

Commit stageWrite new meta file to storage (commit the change).Remove old meta file

Out-of-place update stageAny fault here would cause a failed update(no changes has been made)

Clean-up stageAny fault here was ignored(changes has been made)

* should having a tool to do garbage collection to clean up invalid block or meta. The idea is similar to fsck for Linux file system.

Page 18: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Atomic Write Operation

block0.0

block1.1

block0.1

(in memory)

meta.0

0 1

meta.1

0 11

Assume block size is 1KB, we want to write 20 Bytes at position 0

write data

Page 19: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Atomic Truncate Operation

meta.0

block0.0

block1.1

meta.1

(in memory)

Assume block size is 1KB, file length is 1.5 KB, we want to truncate it to 500 Bytes

len:1.5KB len:1.5KBlen:500B

Page 20: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

REE path: .../bar/REE path: .../foo/

Atomic Rename Operation

meta.0

block0.0

block1.1

meta.0

block0.0

block1.1

hard link

Assume we want to rename foo to bar

* ISO C requires rename to be atomic. We are considering to use it.** Atomic override is not supported yet.

Page 21: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Atomic Create/Delete Operation

● Create○ If the meta file is successfully encrypted and stored,

we are done.○ If any failure occurs during meta file creation, no file

is created.● Delete

○ Rename <filename> to <filename>.trash○ Then remove <filename>.trash

* unlink is not need to be atomic. Thus we can’t simply unlink(‘meta’)

Page 22: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

● Overview● Key Manager● Atomic Operations● Future Work

Page 23: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Binding TEE File to TA

● TEE file folder can be copied or moved into other TA’s folder in normal world

● We do not have a mechanism to prevent TA’s from opening other TA’s TEE file(s)

● A simple way to bind TEE file to TA is adding TA’s UUID to meta file

Page 24: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Rollback Attack Detection

● TEE file content can be backed up and then restored without any error. TEE should be able to detect this kind of actions.

● The solution is to add a file version number in meta file and store it in another safe place.

● The safe place can be○ normal world file system (Protection Level = 100)○ RPMB (Protection Level = 1000)

Page 25: SFO15-503: Secure storage in OP-TEE - Amazon S3€¦ · SFO15-503: Secure storage in OP-TEE James Kung, SY Chiu James Kung, Sheng-Yu Chiu Friday 25 September 2015 SFO15. Agenda Overview

Thank you~


Recommended