15. 15
通常のRISC-V
Linux
OS
Normal
App2 U mode
S mode
M mode
RV64GC
Memory for AppCore
Rocket (4 cores)
Normal
App1
ROM
Rocket コアでLinuxの実行を想定
正確には割り込みがM modeに落ちるの
で対処が必要だが省略。
18. 18
TEE Task Groupの活動 (PMPの開発方向)
PMP (Physical Memory Protection)の拡張
PMPレジスタとセキュリティ設定機能を拡張する。(最近のPriv仕様1.12でレジスタが16から64に拡張)
RISC-Vの特権命令仕様にもかかわるのでその提案。
sPMPの提案
既存のPMPはマシンモードでS+U modeを分割したが、S modeのOSがプロセス単位のTEEができるように
なる拡張
U
S
M Security Monitor
(PMP Management)
OS OS OS
U
S
M Security Monitor
(PMP Manage)
OS OS
OS
(sPMP Manage)
19. 19
RISC-V PMPと類似技術
Arm MPU: Memory Protection Unit
A Survey on RISC-V Security: Hardware and Architecture [arXiv21] https://arxiv.org/abs/2107.04175 より
RISC-Vでは32/64でPMPががあるが、ArmはCortex-Mのみ?
20. 20
TEEの問題点 (Root of Trust) 1/4
TEE は一時的な隔離実行環境で長期的な鍵保存をするRoot of Trustになれない
Root of Trust は基本的に耐タンパーなセキュアコプロセッサ
Remote Attestation は Root of Trust に基づかないと信頼できない
Root of Trustの例
Intel の Intel ME(Management Engine). Intel Quark x86-based (32bit)
AMD の PSP(Platform Security Processor). Arm Cortex-A5 (32bit)
Arm TrustZone needs an extra IP
CryptCell(Discretix -> Arm) ● CryptoManager (Rambus)
Apple M2
RISC-V でも IPがある
Rambus RISC-V CryptoManager ● Silex Insight Secure Root of Trust
OpenTitan (Open Source)
多くが商用で詳細不明。
たまに脆弱性が見つかり、ニュースになる
21. 21
TEEの問題点 (プログラミング) 2/4
TEEの多くは独自のSDKでプログラムを要求する
Intel SGX
Intel SGX SDK
Open Enclave (Microsoft)
Asylo (Google)
AMD SEV
Asylo (Google)
Enarx (Redhat)
Arm Cortex-A TrustZone
Open Enclave (Microsoft)
GlobalPlatform (GP) TEE Internal API
RISC-V Keystone
Keystone SKD
ソースコードレベルで互換性が無く、
異なるCPUでは使うことが出来ない。
27. 27
Enclave
Runtime
Trusted
App1
TEE
Linux
OS
Normal
App2
REE
SM (Security Monitor)
U mode
S mode
M mode
Zephyr
RV64GC RV32IM
Memory for AppCore Memory for Secure
Unit
AppCore (4 cores)
Shared Memory
Secure
App1
Secure
App2
Normal
App1
M mode
Secure Unit (1 core)
Enclave
Enclave
Interrupt
Enclave
Runtime
Trusted
App2
Trusted RV
ROM ROM
SU (Secure Unit)の役割
鍵管理・証明書管理
セキュアブート・リモートアテステー
ション管理
TRV (Trusted RISC-V)でのKeystone
29. 29
SUを使うソフトウェア構成
SUとの通信は制限されている。TA経由のみ。
(Normal App) -> (Secure Monitor) -> (Trusted App) -> (Secure Monitor) -> (Zephyr) -> (Secure App)
長期的な機密情報(鍵・証明書)や機密処理の漏洩を防ぐ。
Enclave
Runtime
Trusted
App1
TEE
Linux
OS
Normal
App2
REE
SM (Security Monitor)
U mode
S mode
M mode
Zephyr
AppCore (4 cores)
Secure
App1
Secure
App2
Normal
App1
M mode
Secure Unit (1 core)
Enclave Enclave
Runtime
Trusted
App2
Trusted RV
Enclave
30. 30
TEEとSecure CoProcessorのレイヤー構成(セキュリティレベル)
REE only
• No isolated environment
• No hardware tamper-proof
• Critical data and processing are not protected
REE + Secure CoProcessor
• No isolated environment
• Critical processing is not protected
REE + TEE
• No hardware tamper-proof
• Critical data is not protected
REE + TEE + Secure CoProcessor
• The order is important
• REE -> TEE -> Secure CoProcessor
0 layer
1 layer
2 layers
同様のレイヤー構成がArm TrustZoneでも提案されている。
Intel SGXではこの構成が取れない。(Ring3のみで直接デバイスにアクセスできないため)
31. 31
TEEとRoot of Trustの構成例(FIDO Authenticator)
Realizing FIDO Authentication Solutions with
GlobalPlatform Technologies, 2018
https://globalplatform.org/wp-content/uploads/2018/04/White-Paper-
Technical-FIDO-Auth-using-GlobalPlatform-Jan2018.pdf
FIDO Authenticatorの実装パターン
① REE直接
② REE+SE(RoT)
③ REE+TEE
④ REE+TEE+SE
① ②
③ ④
32. 32
RISC-V Secure CoProcessor比較 *this table is not complete.
Google Open Titan Rambus RISC-V CryptoManager
(RT-6*0, RT-7*0)
Silex Insight eSecure
(BA470)
Trusted RV
Secure Unit
Core Ibex
(RV32IMC/EMC)
M/U Mode
Custom
(RV32IMC)
M/S/U Mode
Andes N22
(RV32IMAC/EMAC)
M or M/U mode
Custom
(RV32IM)
M mode
OS Tock OS Zephyr --- Zephyr
Comm to Main SPI GPIO/SPI --- GPIO
Shared Memory
Accelerator AES,SHA AES, SHA AES, SHA Not yet ***
Peripherals Timer, RNG Timer, RNG RNG Timer, RNG, Flash
Anti-tampering Yes? Yes Yes Not yet
Target Key Management,
Secure Boot, OTA
Key Management,
Secure Boot, OTA, User App
Key Management,
Secure Boot, OTA
Key Management,
Secure Boot, OTA
Misc. FIPS 140-2 Level 2 FIPS 140 2 level 3
PUF for Unique Key
Design with TEE
(Keystone)
34. 34
TEEのプログラム: GlobalPlatform TEE Internal API
GP TEE Internal APIは多くのスマホで使われている
kinibi (Trustonic)
17億台のデバイスで使われている [USENIX Sec20,PARTEMU]
QSEE (Qualcomm)
2019年時点の60% のAndroid スマホで使われている [USENIX Sec20,PARTEMU]
OP-TEE(Linaro)
Open-source 実装。 We have developed some applications and want to port them.
GP TEE Internal APIを RISC-VとIntel SGXで走るライブラリとして実装。
Reference
Library Implementation and Performance Analysis of GlobalPlatform TEE Internal API for
Intel SGX and RISC-V Keystone[IEEE TrustCom2020]
https://conferences.computer.org/trustcompub/pdfs/TrustCom2020-4sgfK5r538MStgrShyle8b/438000b200/438000b200.pdf
Portable Implementation of GlobalPlatform API for TEE[RISC-V Global Forum 2020]
https://riscvglobalforum2020.sched.com/event/dO37
35. 35
ポータルなGP internal API ライブラリの実装
各TEEのSDKを活用して新しい抽象化を提供
The library is ported to Intel SGX as well as RISC-V Keystone.
実装のチャレンジ
GP internal APIは非常の多くの暗号スィートをサポート
• 必要なものを選んで実装。
幾つかのAPIはCPU依存
• CPU 依存のAPIはCPU毎に作成。
GP TEE Internal APIsを既存のSDK(Keystone, SGX)と融合
• Keystone SDK と SGX SDK は ”edger8r” and “keedger”と呼ぶEDL (Enclave Definition
Language) を含む。 EDL はOCALL (TEEからREEの呼び出し) の際にポインターやバウンダリーのチェックを行うた
め、この整合性が必要。
36. 36
GP TEE Internal APIの実装形態
CPU アーキテクチャ依存
Random Generator, Time, Secure Storage, Transient Object(TEE_GenerateKey)
CPU アーキテクチャ非依存 (Crypto)
Transient Object(exclude TEE_GenerateKey), Crypto Common, Authenticated Encryption,
Symmetric/Asymmetric Cipher, Message Digest
Reference
1. Library Implementation and Performance Analysis of GlobalPlatform TEE Internal API for Intel SGX and RISC-V
Keystone[TrustCom2020] https://conferences.computer.org/trustcompub/pdfs/TrustCom2020-4sgfK5r538MStgrShyle8b/438000b200/438000b200.pdf
2. Portable Implementation of GlobalPlatform API for TEE[RISC-V Global Forum 2020]
https://riscvglobalforum2020.sched.com/event/dO37
43. 43
Remote Attestation
Keystoneが提供するRemote Attestationでは鍵の管理をRoot of Trustで行っていない。
TRVのSecure Unitで鍵管理できるように改良。更に機能追加。
RISC-V Client
Remote Attestation Server
ZSBL
Power-on
FSBL
SM
Root of Trust
(Device Pub-key)
(SM Signature,
SM Secret Key)
ROM
Trusted Side
Untrusted Side
BBL
Linux
Enclave-App
Runtime
Connect TCP/IP
(Untrusted Comm) Load
Device Pub-key
Secure Monitor Hash
Enclave Hash
Enclave-App
Runtime
Enclave-Host
• Hash taken by SM
• Hash signed by SM
Secret key
• SM Signature
Trust-Client
Verify Enclave
Hashes and
Signatures
Report
Key Exchange
Secure Communication
(Dynamicall
y created)
Device Pub-key
SM Secret/Pub-key
SM Signature by Device Secret key
Enclave-App
Runtime
Valid
Start Enclave-App
prerequisite
prerequisite