TPM2 工作原理及操作 -- 授权和会话(一)


目录

 

前言

授权和会话

1. Password密码授权

2.HMAC授权

3、Policy策略授权

授权和会话的区别


 

前言

以下部分内容来自我对tpm2-tools API文档、《A Practical Guide to TPM 2.0》的翻译和理解

关于TPM2基本原理、特性、密钥、层次、PCR等内容,TPM-JS这个项目有较详细的说明: 

TPM-JShttps://google.github.io/tpm-js/#pg_welcome想自学以及更深入了解的同学可以参考tpm2-tools doc :Home - tpm2-tools

TPM 的外部编程接口规范: https ://trustedcomputinggroup.org/tpm-library-specification/

TPM2.0实用指南 《A Practical Guide to TPM 2.0》:

​​​​​​https://link.springer.com/content/pdf/10.1007/978-1-4302-6584-9.pdf

授权和会话

授权和会话是TPM 2.0中最重要的概念。会话和授权在TPM 2.0规范中是密切相关的,有时甚至是重叠的概念,但它们不是同义词。授权控制对TPM中的实体的访问,从而提供了TPM的许多安全保证。会话是授权的载体,并维护后续命令之间的状态。但它们也用于授权以外的目的,可以与授权结合使用,也可以完全独立于授权。例如,用于授权的会话还可以用于指定每个命令的修饰符,如加密、解密和审计。会话还可以用于这些每个命令的修饰符,而不需要同时用于任何授权。

1. Password密码授权

密码会话是最简单的授权类型:向TPM传递一个明文密码来授权一个操作。如果是远程访问TPM,那么这就有明显的安全问题;密码会话的目的是用于本地访问。在TPM中,有一个单一的、始终可用的密码会话,用于授权单个TPM命令,在后续使用之间不保留任何状态。因此,密码会话永远不需要启动。

2.HMAC授权

HMAC授权是一种以更安全的方式使用简单密码的方式:在创建实体或修改其授权值时,一旦调用应用程序和TPM在密码上达成一致,就再也不需要通信密码了。这种密码与TPM的一次性通信可以以安全的方式完成:即密码可以以加密的形式与TPM进行通信。

HMAC会话通过使用密码(即authValue,在TPM 2.0规范中称为authValue)作为根据命令和响应计算的HMAC的输入之一来实现这种更高级别的安全性。对于命令,调用应用程序计算HMAC并将其插入到命令字节流中。当TPM接收到命令字节流时,如果TPM认为HMAC计算正确,则该动作被授权。在响应时,TPM计算响应上的HMAC并将其插入到响应字节流中。调用者独立计算响应HMAC,并将其与响应字节流的HMAC字段进行比较。如果它们匹配,则响应数据是可信的。只有当调用应用程序和TPM都知道并同意authValue时,所有这些才能工作

HMAC会话使用两个nonces来防止重放攻击:一个来自调用者(nonceCaller),一个来自TPM (nonceTPM)。这些nonces因素在HMAC计算中,因为nonceTPM会对发送的每个命令进行更改,而调用应用程序如果愿意,可以更改每个命令上的nonceCaller,因此攻击者无法重放命令字节流。因为重放时nonces会不同,所以重放使用HMAC授权的命令字节流总是会失败。

HMAC会话在会话的生命周期内维护状态,可用于授权对TPM实体的多个操作。使用TPM2_StartAuthSession命令启动HMAC会话。在启动时,HMAC会话可以配置为绑定与未绑定、加盐与未加盐会话。这两种选择的组合产生了四种HMAC会话变体;这四种变化决定了如何计算会话密钥和hmac。

3、Policy策略授权

策略会话,也称为增强授权(Enhanced Authorization, EA),构建在HMAC会话之上,并增加了额外的授权级别。虽然HMAC授权仅基于一个授权值或密码,但策略授权通过基于TPM命令序列、TPM状态和外部设备(如指纹识别器、视网膜扫描仪和智能卡)的授权增强了这一点。许多条件可以与或结合在一起形成复杂的授权树,从而提供无限的授权可能性。

三种授权类型的比较

Password

HMAC

Policy

状态/其他信息

后续使用之间不维护任何状态。

状态在会话的生命周期内维护。

状态在会话的生命周期内维护。

安全性

密码在每条命令上都是清晰的;偷窥者很容易就能获取密码。

比密码安全得多(特别是在向远程TPM发送命令时)。

Nonces用于防止重放攻击。

通过允许对复杂的命令序列以及内部和外部状态进行授权,增强了安全性。

如果一个HMAC正在使用,Nonces是用来防止重放攻击,

命令开始方法

None

TPM2_StartAuthSession

TPM2_StartAuthSession

各命令会话修饰符

None

Decrypt, encrypt,

audit

Decrypt and encrypt

授权和会话的区别

 

授权和会话维恩图

上图中,审计、加密或解密是唯一显示的会话使用修饰符,但还有其他修饰符,展示这三个是因为它们是更常用的。

在上图中,需要特别注意以下几点:

  • 授权可以是密码授权、HMAC授权或策略授权。
  • 密码授权永远不能用于会话使用。
  • HMAC和策略会话可以用于授权,但也可以用于设置会话使用修饰符,有别于任何授权。这就是HMAC和策略会话跨越授权圈边界的原因。
  • 命令的授权区域是指定所有这些授权、会话和会话修饰符的地方。
  • 命令修饰符可以在用于授权的会话中使用,也可以在那些没有使用授权的会话中使用,这就是为什么审计、加密和解密圈跨越授权圈的边界。
  • 未用于授权的会话也可以位于命令和响应字节流的authorization area。
  • 策略会话可以用于加密或解密,但不能用于审计。
  • HMAC会话可以用于加密、解密或审计。

 

授权和会话框图

授权和会话框图展示了不同的关系:

  • 授权区域可以指定密码会话、HMAC会话和策略会话的参数。
  • 使用TPM2_StartAuthSession命令启动的会话可以是HMAC、policy或trial policy会话。
  • HMAC会话可以在每个命令的基础上配置为审计、解密和/或加密会话。
  • 策略会话可以在每个命令的基础上配置为解密和/或加密会话。它们不能用于审计。
  • 这四种会话初始化变化可以应用于HMAC、policy或trial policy会话。

不管会话是如何使用的,也不管授权的类型是什么,命令和响应授权区域都用于与TPM通信授权和会话数据。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
A Practical Guide to TPM 2.0: Using the Trusted Platform Module in the New Age of Security is a straight-forward primer for developers. It shows security and TPM concepts, demonstrating their use in real applications that the reader can try out. Simply put, this book is designed to empower and excite the programming community to go out and do cool things with the TPM. The approach is to ramp the reader up quickly and keep their interest.A Practical Guide to TPM 2.0: Using the Trusted Platform Module in the New Age of Security explains security concepts, describes the TPM 2.0 architecture, and provides code and pseudo-code examples in parallel, from very simple concepts and code to highly complex concepts and pseudo-code. The book includes instructions for the available execution environments and real code examples to get readers up and talking to the TPM quickly. The authors then help the users expand on that with pseudo-code descriptions of useful applications using the TPM. What you’ll learn TPM 2.0 architecture fundamentals, including changes from TPM 1.2 TPM 2.0 security concepts Essential application development techniques A deep dive into the features of TPM 2.0 A primer on the execution environments available for application development. Learn as you go! Who this book is for Application software developers, OS developers, device-driver developers, and embedded-device specialists, who will benefit from mastering TPM 2.0 capabilities and building their own applications quickly. This book will give them the tools they need to experiment with and understand the technology. Software architects who need to understand the security guarantees provided by TPMs Managers who fund the projects that use TPMs. Non-technical users who may want to know why TPMs are on their computers and how to make use of them.
A Practical Guide to TPM 2.0: Using the Trusted Platform Module in the New Age of Security is a straight-forward primer for developers. It shows security and TPM concepts, demonstrating their use in real applications that the reader can try out. Simply put, this book is designed to empower and excite the programming community to go out and do cool things with the TPM. The approach is to ramp the reader up quickly and keep their interest.A Practical Guide to TPM 2.0: Using the Trusted Platform Module in the New Age of Security explains security concepts, describes the TPM 2.0 architecture, and provides code and pseudo-code examples in parallel, from very simple concepts and code to highly complex concepts and pseudo-code. The book includes instructions for the available execution environments and real code examples to get readers up and talking to the TPM quickly. The authors then help the users expand on that with pseudo-code descriptions of useful applications using the TPM. What you’ll learn TPM 2.0 architecture fundamentals, including changes from TPM 1.2 TPM 2.0 security concepts Essential application development techniques A deep dive into the features of TPM 2.0 A primer on the execution environments available for application development. Learn as you go! Who this book is for Application software developers, OS developers, device-driver developers, and embedded-device specialists, who will benefit from mastering TPM 2.0 capabilities and building their own applications quickly. This book will give them the tools they need to experiment with and understand the technology. Software architects who need to understand the security guarantees provided by TPMs Managers who fund the projects that use TPMs. Non-technical users who may want to know why TPMs are on their computers and how to make use of them. Table of Contents Chapter 1: History of the TPM Chapter 2: Basic Security Concepts Chapter 3: Quick Tutorial on TPM 2.0 Chapter 4: Existing Applications That Use TPMs Chapter 5: Navigating the Specification Chapter 6: Execution Environment Chapter 7: TPM Software Stack Chapter 8: TPM Entities Chapter 9: Hierarchies Chapter 10: Keys Chapter 11: NV Indexes Chapter 12: Platform Configuration Registers Chapter 13: Authorizations and Sessions Chapter 14: Extended Authorization (EA) Policies Chapter 15: Key Management Chapter 16: Auditing TPM Commands Chapter 17: Decrypt/Encrypt Sessions Chapter 18: Context Management Chapter 19: Startup, Shutdown, and Provisioning Chapter 20: Debugging Chapter 21: Solving Bigger Problems with the TPM 2.0 Chapter 22: Platform Security Technologies That Use TPM 2.0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值