[go: up one dir, main page]

CN117473530B - Lightweight trusted measurement system and method based on trusted execution environment - Google Patents

Lightweight trusted measurement system and method based on trusted execution environment Download PDF

Info

Publication number
CN117473530B
CN117473530B CN202311484847.7A CN202311484847A CN117473530B CN 117473530 B CN117473530 B CN 117473530B CN 202311484847 A CN202311484847 A CN 202311484847A CN 117473530 B CN117473530 B CN 117473530B
Authority
CN
China
Prior art keywords
measurement
request
virtual machine
trusted
secure world
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202311484847.7A
Other languages
Chinese (zh)
Other versions
CN117473530A (en
Inventor
华志超
程一同
夏虞斌
陈海波
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Shanghai Jiao Tong University
Original Assignee
Shanghai Jiao Tong University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Shanghai Jiao Tong University filed Critical Shanghai Jiao Tong University
Priority to CN202311484847.7A priority Critical patent/CN117473530B/en
Publication of CN117473530A publication Critical patent/CN117473530A/en
Application granted granted Critical
Publication of CN117473530B publication Critical patent/CN117473530B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/70Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer
    • G06F21/78Protecting specific internal or peripheral components, in which the protection of a component leads to protection of the entire computer to assure secure storage of data

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Security & Cryptography (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Storage Device Security (AREA)

Abstract

The invention provides a lightweight trusted measurement system and method based on a trusted execution environment, comprising the following steps: the measurement service driving module: receiving a measurement request sent by an application layer, and sending the measurement request to a secure world through an SMC Call; and setting a scheduler to periodically yield CPU resources from the common world to the secure world; an address translation module: designing an EL2 level in the safety world, performing preliminary analysis on the request, translating related addresses, and mapping related memory pages to a measurement execution module; the measurement execution module: designing an EL1 level execution running in the secure world managed by SPMC; trusted communication protocol: based on an asymmetric encryption algorithm, the true and effective measurement result is ensured, so that communication among all components in the measurement system is credible, and the source security of the message can be determined by all the components. The invention can ensure the safety and usability of the system, and can ensure the safety of the private data and prevent the data from being stolen or abused.

Description

基于可信执行环境的轻量级可信度量系统及方法Lightweight trusted measurement system and method based on trusted execution environment

技术领域Technical Field

本发明涉及计算机技术领域,具体地,涉及一种基于可信执行环境的轻量级可信度量系统及方法。The present invention relates to the field of computer technology, and in particular to a lightweight trusted measurement system and method based on a trusted execution environment.

背景技术Background Art

计算机系统的完整性是指,计算机系统内部状态始终处于未被恶意程序篡改的状态,运行着使用者期望的代码。完整性度量系统是运行在计算机系统内部的软件,能够通过对计算机系统运行时的状态进行访问、提取和分析,来判断此时操作系统是否受到非法的篡改,并将可验证的检查结果返回给使用者,同时能够一定程度上防御恶意的攻击。随着云计算的发展,针对云平台来设计和实现完整性度量系统伴随着额外的挑战。一方面,云平台需要并行地运行不同用户提供的不同类型的虚拟机,这使得系统架构更加复杂,具有更广的攻击面,同时也要求度量系统能够根据不同用户的需求提供定制化的度量方式;另一方面,用户对云平台的实时性有更高的要求,完整性度量系统的引入不能影响云平台本身的实时性,对度量系统的性能提出了更高的要求。The integrity of a computer system means that the internal state of the computer system is always in a state that has not been tampered with by malicious programs and runs the code expected by the user. The integrity measurement system is software running inside the computer system. It can access, extract and analyze the state of the computer system during operation to determine whether the operating system has been illegally tampered with at this time, and return verifiable inspection results to the user. At the same time, it can defend against malicious attacks to a certain extent. With the development of cloud computing, the design and implementation of integrity measurement systems for cloud platforms are accompanied by additional challenges. On the one hand, cloud platforms need to run different types of virtual machines provided by different users in parallel, which makes the system architecture more complex and has a wider attack surface. At the same time, it also requires the measurement system to provide customized measurement methods according to the needs of different users; on the other hand, users have higher requirements for the real-time performance of cloud platforms. The introduction of integrity measurement systems cannot affect the real-time performance of the cloud platform itself, which puts higher requirements on the performance of measurement systems.

TrustZone作为一组安全扩展,在Armv6时第一次被提出。目的是提供一个独立的环境来执行重要和私密的软件。TrustZone将硬件资源分为了两个世界,一个是安全敏感的安全世界,另外一个是运行常规软件的普通世界,其中安全世界中运行着的各种安全敏感的软件之间的管理及隔离通过可信系统内核来实现。普通世界中的软件通过SMC Call,经安全固件检查后,安全地切换到安全世界。Armv8.4-A中安全虚拟化扩展被提出,让监视器模式,即Arm架构中的Except ion Level 2(EL2)特权级,能够在安全世界中使用。安全世界中的虚拟化与普通世界中的比较相似。运行在安全世界中EL2特权级的Secure PartitionManager通过Memory Management Unit(MMU)和IO Memory Management Unit(IOMMU)中的二阶段页表来限制安全世界中运行在EL1的虚拟机,被称为Secure Partit ion(SP),能够访问的系统资源(包括安全资源和非安全资源),通过配置Generic Interrupt Controller(GIC)来控制中断的处理。开启了安全虚拟化扩展后,安全世界中能够平行地运行多个安全敏感的软件,互相之间无法访问彼此的资源。TrustZone, as a set of security extensions, was first proposed in Armv6. The purpose is to provide an independent environment to execute important and private software. TrustZone divides hardware resources into two worlds, one is the security-sensitive secure world, and the other is the normal world that runs regular software. The management and isolation between various security-sensitive software running in the secure world are implemented through the trusted system kernel. The software in the normal world switches to the secure world safely through SMC Call after being checked by the security firmware. The secure virtualization extension was proposed in Armv8.4-A, allowing monitor mode, that is, the Exception Level 2 (EL2) privilege level in the Arm architecture, to be used in the secure world. Virtualization in the secure world is similar to that in the normal world. The Secure PartitionManager running at the EL2 privilege level in the secure world limits the virtual machines running at EL1 in the secure world, called Secure Partition (SP), through the two-stage page tables in the Memory Management Unit (MMU) and IO Memory Management Unit (IOMMU). The system resources (including secure resources and non-secure resources) that can be accessed are controlled by configuring the Generic Interrupt Controller (GIC). After the secure virtualization extension is enabled, multiple security-sensitive software can run in parallel in the secure world without accessing each other's resources.

Arm提出了Firmware Framework for Arm A-profile(FF-A)来管理不同世界,不同特权级下的软件,是一个通过提供一套二进制接口标准(FF-A ABI)来实现:1.利用虚拟化技术隔离不同厂家提供的软件映像;2.描述一个标准的接口,以在不同软件间进行通讯。这包括了安全世界和普通世界间的通信;3.规范安全世界中的软件与特权固件的交互。Arm proposed the Firmware Framework for Arm A-profile (FF-A) to manage software in different worlds and privilege levels. It is implemented by providing a set of binary interface standards (FF-A ABI): 1. Using virtualization technology to isolate software images provided by different manufacturers; 2. Describing a standard interface for communication between different software. This includes communication between the secure world and the normal world; 3. Standardizing the interaction between software in the secure world and privileged firmware.

Trusted Platform Module是由Trusted Computing Group推出的安全芯片标准,能够提供安全存储,平台完整性报告,平台验证功能。TPM常以协处理器的形式存在,不需要对主要硬件平台进行修改,但只能被动地接受系统的服务请求,而不会主动对系统造成影响。当系统进行度量时,需要由被度量系统自己进行运算得到度量结果,再发送给TPM由其进行签名。用户可以通过远程验证协议得知经TPM授权的度量结果。缺点是,攻击者可以攻击CPU和TPM间的总线。由于安全世界和普通世界之间是平行且隔离的,这种关系与TPM和CPU间的关系较为类似,本发明借鉴了TPM的思路来实现远程验证协议。Trusted Platform Module is a security chip standard launched by the Trusted Computing Group, which can provide secure storage, platform integrity reporting, and platform verification functions. TPM often exists in the form of a coprocessor, and does not require modifications to the main hardware platform, but can only passively accept system service requests without actively affecting the system. When the system is measured, the measured system needs to perform calculations to obtain the measurement results, and then send them to the TPM for signature. Users can obtain the measurement results authorized by the TPM through the remote verification protocol. The disadvantage is that attackers can attack the bus between the CPU and the TPM. Since the secure world and the ordinary world are parallel and isolated, this relationship is similar to the relationship between the TPM and the CPU. The present invention draws on the idea of TPM to implement the remote verification protocol.

最初的完整性度量系统一般都基于由Trusted Comput ing Group提出的TrustedPlatform Module,是一个安全协处理器的国际标准,通过硬编码的密钥,来为CPU提供了一系列可信的密码学接口,可作为可信根来为度量结果提供远程证明。美国研究人员提出的LKIM基于TPM为Linux内核提供了较为完善的完整性度量解决方案,通过修改操作系统内核实现了对操作系统及应用程序的度量。但这一方案不能适用于具有虚拟化技术的云平台场景中,因为云平台中会并行地运行由用户提供的多个操作系统映像,无法进行侵入式的修改,且硬件平台上TPM的芯片数量有限,无法提供给每个虚拟机。为了解决云平台场景中TPM芯片数量不够的问题,北卡罗来纳州立大学的学者提出了HIMA,使用软件手段将TPM进行了虚拟化,在通过虚拟机监视器劫持虚拟机中的关键事件,以提供对虚拟机增量式的度量,还针对云平台场景设计了虚拟机迁移方案。然而,随着虚拟机监视器本身Trusted Computing Base(TCB)的膨胀,通过软件的方法解决会使得度量系统的安全性难以保障,而且这一方案仍然强绑定特定的虚拟机。惠普的研究人员提出了OSck,处理了在度量系统中多线程抢占的问题,且能够让用户自定义度量方案。但只针对单机系统,无法应用到云平台上。中国科学院软件研究所基础软件国家工程研究中心的研究人员提出的基于动态信任根的虚拟机监控器动态完整性度量架构以及张景提出的基于安全芯片的虚拟机监控器安全加固方法分别使用不同方法实现了在云平台中对虚拟机监视器的度量,但缺乏对其他系统组件的度量能力。The initial integrity measurement system is generally based on the Trusted Platform Module proposed by the Trusted Comput ing Group, which is an international standard for secure coprocessors. It provides a series of trusted cryptographic interfaces for the CPU through hard-coded keys, and can be used as a trusted root to provide remote proof of measurement results. LKIM proposed by American researchers provides a relatively complete integrity measurement solution for the Linux kernel based on TPM, and realizes the measurement of operating systems and applications by modifying the operating system kernel. However, this solution cannot be applied to cloud platform scenarios with virtualization technology, because multiple operating system images provided by users will run in parallel in the cloud platform, and intrusive modifications cannot be made. In addition, the number of TPM chips on the hardware platform is limited and cannot be provided to each virtual machine. In order to solve the problem of insufficient number of TPM chips in cloud platform scenarios, scholars from North Carolina State University proposed HIMA, which virtualized TPM using software means, hijacked key events in virtual machines through virtual machine monitors to provide incremental measurements of virtual machines, and designed virtual machine migration solutions for cloud platform scenarios. However, as the Trusted Computing Base (TCB) of the virtual machine monitor itself expands, it will be difficult to ensure the security of the measurement system through software solutions, and this solution is still strongly bound to a specific virtual machine. HP researchers proposed OSck, which deals with the problem of multi-thread preemption in the measurement system and allows users to customize the measurement solution. However, it is only applicable to stand-alone systems and cannot be applied to cloud platforms. The dynamic integrity measurement architecture of virtual machine monitors based on dynamic trust roots proposed by researchers from the National Engineering Research Center for Basic Software, Institute of Software, Chinese Academy of Sciences, and the virtual machine monitor security reinforcement method based on security chips proposed by Zhang Jing use different methods to achieve the measurement of virtual machine monitors in cloud platforms, but lack the ability to measure other system components.

以上这些工作是在系统架构的层面上设计完整性度量系统。还有一些工作注重于如何选择系统的一些状态或者如何执行度量操作,来使得度量结果更加准确和高效。佐治亚理工学院的学者提出了KOP技术,能够精确识别动态分配物体的类型,进而保证系统运行时的动态完整性。但缺点是性能较差,无法保证实时性,难以实际应用在云平台中。新奥尔良大学的学者提出了ModChecker,针对云平台难以修改虚拟机映像的问题,能够透明地度量系统内核模块的方案。中国信息安全国家重点实验室提出了TF-BIV,针对云平台中的性能需求,提出在线性扫描堆内存的同时,识别系统的部分动态属性。这些工作局限于如何选择系统中一些动态的完整性属性,与本发明目前的方案是正交的,可以根据用户需求随时添加进系统当中去。The above works are designed integrity measurement systems at the level of system architecture. Some other works focus on how to select some states of the system or how to perform measurement operations to make the measurement results more accurate and efficient. Scholars from Georgia Institute of Technology proposed KOP technology, which can accurately identify the types of dynamically allocated objects, thereby ensuring the dynamic integrity of the system during operation. But the disadvantage is that the performance is poor, real-time performance cannot be guaranteed, and it is difficult to be applied in cloud platforms. Scholars from the University of New Orleans proposed ModChecker, which is a solution that can transparently measure system kernel modules to address the problem that it is difficult to modify virtual machine images on cloud platforms. The State Key Laboratory of Information Security of China proposed TF-BIV, which proposes to identify some dynamic properties of the system while linearly scanning the heap memory to meet the performance requirements in the cloud platform. These works are limited to how to select some dynamic integrity attributes in the system, which is orthogonal to the current solution of the present invention and can be added to the system at any time according to user needs.

尽管目前已经有了利用TEE来实现度量系统的工作,但这些工作仅针对特定的硬件平台,难以迁移到基于Arm架构的云平台场景中。且随着TEE软件栈也愈发复杂化,也需要利用一些可信的机制对TEE中的软件进行隔离,以及对这些安全软件进行完整性度量,才能保证系统的整体安全。Although there are some works that use TEE to implement measurement systems, these works are only for specific hardware platforms and are difficult to migrate to cloud platform scenarios based on the Arm architecture. And as the TEE software stack becomes more and more complex, it is also necessary to use some trusted mechanisms to isolate the software in the TEE and measure the integrity of these security software to ensure the overall security of the system.

此外,一些其他工作(TZ-RKP,PAL)提供了度量以外的其他程度的完整性保护,本发明借鉴了其中部分细节以完善本发明的方案。In addition, some other works (TZ-RKP, PAL) provide other levels of integrity protection beyond metric, and the present invention draws on some details therein to improve the solution of the present invention.

总的来说,现有的工作都无法充分利用云平台场景下Arm架构的安全虚拟化技术,具有以下一个或多个缺点:需要侵入式地修改用户的虚拟机,或是只针对特定操作系统的单机场景;系统本身的TCB较大,难以保证安全性;运行时性能开销较大,难以保证应用到云平台后的实时性。In general, existing work cannot fully utilize the secure virtualization technology of the Arm architecture in the cloud platform scenario, and has one or more of the following disadvantages: it is necessary to invasively modify the user's virtual machine, or it is only applicable to stand-alone scenarios with specific operating systems; the system's own TCB is large, making it difficult to ensure security; the runtime performance overhead is large, making it difficult to ensure real-time performance after being applied to the cloud platform.

综上所述,当前现有技术中需要解决以下问题:1)如何利用安全虚拟化特性,保证系统的安全性?2)如何保证能够准确反映度量对象的完整性,且兼容云平台中多种不同的度量对象?3)在保证度量系统能够提供较高安全性的度量结果的同时,如何针对云平台场景的特殊性以及本发明当前所使用的硬件平台来进行性能优化,以达到低时延以及较高的可用性,同时允许用户根据自己的安全性需求配置是否开启这些优化。In summary, the following problems need to be solved in the current existing technology: 1) How to use the security virtualization feature to ensure the security of the system? 2) How to ensure that the integrity of the measurement object can be accurately reflected and compatible with various different measurement objects in the cloud platform? 3) While ensuring that the measurement system can provide highly secure measurement results, how to optimize the performance based on the particularity of the cloud platform scenario and the hardware platform currently used in the present invention to achieve low latency and high availability, while allowing users to configure whether to enable these optimizations according to their own security requirements.

缩略语和关键术语定义:Definitions of Abbreviations and Key Terms:

TEE:可信执行环境(Trusted Execut ion Environment),是计算机系统中与系统主操作系统(OS)分离的一个区域。它确保数据在一个安全的环境中被存储、处理和保护。TEE: Trusted Execution Environment is an area in a computer system that is separated from the system's main operating system (OS). It ensures that data is stored, processed, and protected in a secure environment.

FF-A:可信硬件框架-A(Firmware Framework A),是由Arm提出的是一个通过提供一套二进制接口标准(FF-A ABI)来管理不同世界,不同特权级下的软件的软件架构。FF-A: Trusted Hardware Framework-A (Firmware Framework A), proposed by Arm, is a software architecture that manages software in different worlds and privilege levels by providing a set of binary interface standards (FF-A ABI).

发明内容Summary of the invention

针对现有技术中的缺陷,本发明提供一种基于可信执行环境的轻量级可信度量系统及方法。In view of the defects in the prior art, the present invention provides a lightweight trusted measurement system and method based on a trusted execution environment.

根据本发明提供的一种基于可信执行环境的轻量级可信度量系统及方法,所述方案如下:According to a lightweight trusted measurement system and method based on a trusted execution environment provided by the present invention, the scheme is as follows:

第一方面,提供了一种基于可信执行环境的轻量级可信度量系统,所述方法包括:In a first aspect, a lightweight trusted measurement system based on a trusted execution environment is provided, the method comprising:

度量服务驱动模块:接受应用层发来的度量请求,通过SMC Call将度量请求发送到安全世界中去;以及设置调度器,周期性地将CPU资源从普通世界让渡给安全世界;Metrics service driver module: accepts metrics requests from the application layer and sends them to the secure world through SMC Call; and sets up a scheduler to periodically transfer CPU resources from the normal world to the secure world;

地址翻译模块:设计在安全世界中的EL2层级,负责对请求进行初步的解析、将相关地址进行翻译,并将相关的内存页映射给度量执行模块;Address translation module: Designed at the EL2 level in the secure world, it is responsible for preliminary parsing of requests, translating relevant addresses, and mapping relevant memory pages to the measurement execution module;

度量执行模块:设计运行在由SPMC管理的安全世界中的EL1层级执行;Measurement execution module: designed to run at EL1 level in the secure world managed by SPMC;

可信通信协议:基于非对称加密算法,保证度量结果真实有效,使得度量系统中的各个组件间的通信可信,以及各个组件能够确定消息的来源安全。Trusted communication protocol: Based on asymmetric encryption algorithms, it ensures that the measurement results are authentic and valid, makes the communication between components in the measurement system trustworthy, and enables each component to determine the security of the source of the message.

优选地,所述度量服务驱动模块包括:Preferably, the measurement service driving module includes:

通过Linux编写系统内核模块作为度量服务驱动的示例,通过将其动态添加到虚拟机中,以作为度量请求的发起点;An example of writing a system kernel module in Linux as a measurement service driver is given, which is dynamically added to the virtual machine as the initiation point of the measurement request.

在内核模块初始化时创建一个字符串设备,同时使用ioctl来将相关接口暴露给用户态,用户态程序通过打开相应字符串设备,并使用ioctl相关系统调用来使用度量服务驱动提供的功能。度量服务驱动接收到来自用户态的请求后,将度量请求写入到一个完整的内存页,通过共享内存的方法将请求发送至安全世界。When the kernel module is initialized, a string device is created and ioctl is used to expose the relevant interface to the user state. The user state program opens the corresponding string device and uses the ioctl related system calls to use the functions provided by the measurement service driver. After receiving the request from the user state, the measurement service driver writes the measurement request to a complete memory page and sends the request to the secure world through the shared memory method.

优选地,所述度量服务驱动模块包括:所述调度器根据安全世界中所有SP的虚拟CPU总数来创建对应数量的线程,这些线程的调度由Linux本身的调度器来完成;当某个线程被调度到后,该线程则调用FF-A中与调度相关的ABI,将自己的CPU资源让渡给安全世界中对应的虚拟机CPU。Preferably, the measurement service driver module includes: the scheduler creates a corresponding number of threads according to the total number of virtual CPUs of all SPs in the secure world, and the scheduling of these threads is completed by the scheduler of Linux itself; when a thread is scheduled, the thread calls the ABI related to scheduling in FF-A and transfers its own CPU resources to the corresponding virtual machine CPU in the secure world.

优选地,所述地址翻译模块包括:在地址翻译模块中维护一个队列,储存已经完成翻译和映射的请求的哈希值,且按照此请求对上一次执行的顺序进行排列。当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到了自己虚拟地址空间的哪一个部分。否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。Preferably, the address translation module includes: maintaining a queue in the address translation module, storing the hash values of the requests that have been translated and mapped, and arranging the order of the last execution according to this request. When a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its own virtual address space the memory related to this request is mapped to. Otherwise, no repeated translation and mapping operations are performed, and the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly.

优选地,所述地址翻译模块需要结合其他模块来获取地址翻译相关的寄存器;Preferably, the address translation module needs to be combined with other modules to obtain registers related to address translation;

本系统使用额外的通用寄存器,将所需寄存器暂存下来,然后传递到安全世界当中;在EL3中,修改固件使其会识别ABI中的Magic Code,只有当前接口是与度量服务相关时,才会将相关寄存器传递至安全世界。This system uses additional general registers to temporarily store the required registers and then pass them to the secure world; in EL3, the firmware is modified to recognize the Magic Code in the ABI, and the relevant registers are passed to the secure world only when the current interface is related to the measurement service.

优选地,所述度量执行模块中,提供三种不同维度的度量方式,判断当前系统是否处于安全状态:Preferably, the measurement execution module provides three different dimensional measurement methods to determine whether the current system is in a safe state:

1)计算静态数据对应虚拟地址中数据的哈希值;1) Calculate the hash value of the data in the virtual address corresponding to the static data;

2)计算指定虚拟地址在二阶段页表中的权限位;2) Calculate the permission bits of the specified virtual address in the second-stage page table;

3)检查和监视物理地址的共享状态。3) Check and monitor the sharing status of physical addresses.

优选地,所述度量请求中需要有一个字段,储存此请求的哈希值;通过采取FirstIn,First Out策略,在地址翻译模块中维护一个队列,储存已经完成翻译和映射的请求的哈希值,且按照此请求上一次执行的顺序进行排列;Preferably, the measurement request needs to have a field to store the hash value of the request; by adopting the FirstIn, FirstOut strategy, a queue is maintained in the address translation module to store the hash values of the requests that have completed translation and mapping, and the requests are arranged in the order of the last execution of the requests;

当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到自己虚拟地址空间的哪一个部分;否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。When a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its own virtual address space the memory related to this request is mapped to; otherwise, no repeated translation and mapping operations are performed, and the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly.

第二方面,提供了一种基于可信执行环境的轻量级可信度量方法,所述方法包括:In a second aspect, a lightweight trusted measurement method based on a trusted execution environment is provided, the method comprising:

云平台启动过程、虚拟机启动过程、请求传递过程、地址翻译过程、度量的执行过程、度量结果的验证过程;Cloud platform startup process, virtual machine startup process, request transmission process, address translation process, measurement execution process, and measurement result verification process;

其中,云平台启动过程包括:The cloud platform startup process includes:

步骤1)由硬件平台厂商生成EK的公私钥;Step 1) The hardware platform manufacturer generates the public and private keys of the EK;

步骤2)硬件平台厂商将EK的公钥放置于安全验证者中;通常安全验证者为硬件平台厂商对外提供的服务;Step 2) The hardware platform manufacturer places the public key of the EK in the security verifier; usually the security verifier is a service provided by the hardware platform manufacturer to the outside world;

步骤3)硬件平台厂商将EK的私钥以安全且私密的方式放置于安全世界的软件映像中;Step 3) The hardware platform manufacturer places the EK’s private key in the software image of the secure world in a secure and private manner;

步骤4)安全世界中的软件以可信的方式进行启动;需要保证软件本身不被篡改,以及其中的隐私信息不被泄露;如果启动失败,跳转到步骤6);否则进入下一步;Step 4) The software in the secure world is started in a trusted manner; it is necessary to ensure that the software itself is not tampered with and the privacy information therein is not leaked; if the startup fails, jump to step 6); otherwise, proceed to the next step;

步骤5)启动成功,能够向其中部署用户的虚拟机;Step 5) The startup is successful and the user's virtual machine can be deployed therein;

步骤6)创建失败,过程中有异常或受到攻击;Step 6) Creation failed, there was an exception or attack during the process;

虚拟机启动过程包括:The virtual machine startup process includes:

步骤1)用户将自身虚拟机映像上传至平台,进行虚拟机本身的启动,初始化度量服务驱动;Step 1) The user uploads his own virtual machine image to the platform, starts the virtual machine itself, and initializes the measurement service driver;

步骤2)虚拟机启动后,向安全世界请求生成AK,以供后续度量使用;Step 2) After the virtual machine is started, it requests the secure world to generate an AK for subsequent measurement;

步骤3)安全世界接收到AK生成请求,生成AK的公私钥,并将这对密钥与虚拟机的VMID进行绑定;最后,使用EK私钥对此次请求的结果进行签名,并将结果返还至虚拟机验证者;Step 3) The secure world receives the AK generation request, generates the public and private keys of the AK, and binds the key pair to the VMID of the virtual machine; finally, the result of this request is signed using the EK private key and returned to the virtual machine verifier;

步骤4)虚拟机验证者向安全验证者请求验证AK生成结果的签名正确性,验证不通过,跳转到步骤7),否则进入下一步;Step 4) The virtual machine verifier requests the security verifier to verify the correctness of the signature of the AK generation result. If the verification fails, jump to step 7), otherwise proceed to the next step;

步骤5)虚拟机验证者将AK的公钥储存下来,用以校验之后度量结果的正确性;Step 5) The virtual machine verifier stores the public key of AK to verify the correctness of the subsequent measurement results;

步骤6)虚拟机启动阶段结束,能够相应后续的度量请求;Step 6) The virtual machine startup phase ends and can respond to subsequent measurement requests;

步骤7)启动失败;Step 7) Startup failure;

请求传递过程包括:The request delivery process includes:

步骤1)想要发起度量的用户通过远程函数调用从虚拟机验证者处获得具体的请求;Step 1) The user who wants to initiate the measurement obtains a specific request from the virtual machine verifier through a remote function call;

步骤2)用户向虚拟机中的度量驱动发起请求;Step 2) The user initiates a request to the metric driver in the virtual machine;

步骤3)虚拟机驱动通过smc call将请求直接发送到安全世界;Step 3) The virtual machine driver sends the request directly to the secure world through smc call;

步骤4)安全世界接受到度量请求,将要执行度量操作;Step 4) The secure world receives the measurement request and will perform the measurement operation;

地址翻译过程包括:The address translation process includes:

步骤1)SPMC初步解析获取的度量请求;Step 1) SPMC preliminarily parses the obtained measurement request;

步骤2)将度量请求分别映射到SPMC和度量执行模块的地址空间中;Step 2) Mapping the measurement request to the address space of the SPMC and the measurement execution module respectively;

步骤3)SPMC进一步解析请求,获取地址翻译信息;Step 3) SPMC further parses the request and obtains address translation information;

步骤4)将需要度量的内存映射到度量执行模块的地址空间中;Step 4) Mapping the memory to be measured into the address space of the measurement execution module;

步骤5)地址经重映射后,请求中的地址范围需要重新转换,此处进行度量请求的转换;Step 5) After the address is remapped, the address range in the request needs to be reconverted, and the conversion of the measurement request is performed here;

步骤6)根据FF-A规范将请求传递给度量执行模块;Step 6) passing the request to the measurement execution module according to the FF-A specification;

度量执行过程包括:The measurement execution process includes:

步骤1)度量执行模块解析收到的度量请求;Step 1) The measurement execution module parses the received measurement request;

步骤2)度量执行模块将需要被度量的内存映射到自己的第一级页表中;Step 2) The measurement execution module maps the memory to be measured into its own first-level page table;

步骤3)执行度量操作,对被度量内存的哈希操作;Step 3) Perform a measurement operation and a hash operation on the measured memory;

步骤4)使用对应的AK私钥将度量结果进行签名,进而生成可验证的度量结果;Step 4) Use the corresponding AK private key to sign the measurement result, thereby generating a verifiable measurement result;

步骤5)将度量结果返回;Step 5) Return the measurement result;

度量结果的验证过程包括:The verification process of the measurement results includes:

步骤1)用户通过远程函数调用将度量结果传递给虚拟机验证者;Step 1) The user passes the measurement result to the virtual machine verifier through a remote function call;

步骤2)虚拟机验证者通过AK公钥验证度量结果签名的正确性;验证失败,跳转到步骤6);否则,进入下一步;Step 2) The virtual machine verifier verifies the correctness of the signature of the measurement result through the AK public key; if the verification fails, jump to step 6); otherwise, proceed to the next step;

步骤3)虚拟机验证者比对度量结果中内容是否正确;验证失败,跳转到步骤6);否则,进入下一步;Step 3) The virtual machine verifier compares the measurement results to see if the content is correct; if the verification fails, jump to step 6); otherwise, proceed to the next step;

步骤4)返还验证结果给用户;Step 4) Return the verification result to the user;

步骤5)度量成功,度量目标的完整性没有受到破坏;Step 5) The measurement is successful and the integrity of the measurement target is not compromised;

步骤6)度量失败,度量目标的完整性可能受到破坏。Step 6) If the measurement fails, the integrity of the measurement target may be compromised.

第三方面,提供了一种存储有计算机程序的计算机可读存储介质,所述计算机程序被处理器执行时实现所述的基于可信执行环境的轻量级可信度量方法的步骤。In a third aspect, a computer-readable storage medium storing a computer program is provided, and when the computer program is executed by a processor, the steps of the lightweight trusted measurement method based on a trusted execution environment are implemented.

第四方面,提供了一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被处理器执行时实现所述的基于可信执行环境的轻量级可信度量方法的步骤。In a fourth aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the lightweight trusted measurement method based on a trusted execution environment when executed by the processor.

与现有技术相比,本发明具有如下的有益效果:Compared with the prior art, the present invention has the following beneficial effects:

1、利用安全虚拟化特性,保证系统的安全性,需要借用已有的开源软件和开源软件框架,将大多数安全敏感的代码逻辑配置在隔离的环境中,让TCB在必要部分的基础上,仅仅增加有限的一小部分代码。TCB意味着可信代码出现问题的概率更低,有着更高的安全性,也更有可能形式化验证其安全性。1. To ensure the security of the system by using the security virtualization feature, it is necessary to borrow the existing open source software and open source software framework, configure most security-sensitive code logic in an isolated environment, and let TCB only add a limited small part of the code on the basis of the necessary part. TCB means that the probability of problems in trusted code is lower, it has higher security, and it is more likely to formally verify its security.

2、保证能够准确反映度量对象的完整性,且兼容云平台中多种不同的度量对象,由于云平台的特殊性,度量对象的类型可能各不相同,需要在一定程度上可根据用户需求进行自定义;同时,对于有特殊安全性需求的用户,还允许其扩展其他类型的度量方式。2. Ensure that the integrity of the measurement object can be accurately reflected and that it is compatible with a variety of different measurement objects in the cloud platform. Due to the particularity of the cloud platform, the types of measurement objects may be different and need to be customized to a certain extent according to user needs. At the same time, for users with special security requirements, they are also allowed to expand other types of measurement methods.

3、本发明具有高安全性,体现在两个方面:系统本身设计得足够安全,TCB足够小,能够防御外部攻击者的攻击,且内部的漏洞尽可能少;产生的度量结果难以伪造,能够验证其可信性。3. The present invention has high security, which is reflected in two aspects: the system itself is designed to be secure enough, the TCB is small enough to defend against attacks from external attackers, and the internal vulnerabilities are as few as possible; the measurement results generated are difficult to forge and their credibility can be verified.

4、本发明能够进行灵活的度量选择,用户能够根据自身的安全性需求,灵活地选择执行不同维度、不同程度的度量。4. The present invention can perform flexible measurement selection, and users can flexibly choose to execute measurements of different dimensions and degrees according to their own security requirements.

5、本发明能够保证低时延和高实时性,在保证度量系统能够提供较高安全性的度量结果的同时,根据现有硬件平台的特性尽可能进行优化,以达到低时延以及较高的实时性。5. The present invention can ensure low latency and high real-time performance. While ensuring that the measurement system can provide measurement results with high security, it is optimized as much as possible according to the characteristics of the existing hardware platform to achieve low latency and high real-time performance.

本发明的其他有益效果,将在具体实施方式中通过具体技术特征和技术方案的介绍来阐述,本领域技术人员通过这些技术特征和技术方案的介绍,应能理解所述技术特征和技术方案带来的有益技术效果。Other beneficial effects of the present invention will be explained in the specific implementation manner through the introduction of specific technical features and technical solutions. Through the introduction of these technical features and technical solutions, those skilled in the art should be able to understand the beneficial technical effects brought about by the technical features and technical solutions.

附图说明BRIEF DESCRIPTION OF THE DRAWINGS

通过阅读参照以下附图对非限制性实施例所作的详细描述,本发明的其它特征、目的和优点将会变得更明显:Other features, objects and advantages of the present invention will become more apparent from the detailed description of non-limiting embodiments made with reference to the following drawings:

图1为本发明系统示意图;Fig. 1 is a schematic diagram of the system of the present invention;

图2为云平台启动过程示意图;Figure 2 is a schematic diagram of the cloud platform startup process;

图3为虚拟机启动过程示意图;FIG3 is a schematic diagram of a virtual machine startup process;

图4为请求传递过程示意图;FIG4 is a schematic diagram of a request transmission process;

图5为地址翻译过程示意图;FIG5 is a schematic diagram of the address translation process;

图6为度量执行过程示意图;FIG6 is a schematic diagram of the measurement execution process;

图7为度量结果的验证过程示意图。FIG7 is a schematic diagram of the verification process of the measurement results.

具体实施方式DETAILED DESCRIPTION

下面结合具体实施例对本发明进行详细说明。以下实施例将有助于本领域的技术人员进一步理解本发明,但不以任何形式限制本发明。应当指出的是,对本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变化和改进。这些都属于本发明的保护范围。The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several changes and improvements can also be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

本发明实施例提供了一种基于可信执行环境的轻量级可信度量系统,参照图1所示,该系统通过利用多层级协同化的架构,有效地减少可信代码段的大小,为深度性能优化提供了可能;使用了可扩展定制化的度量,能够度量云平台中多种类型的虚拟机映像,以及大部分系统组件;提供了可配置的针对性优化,根据云平台场景的特殊性以及Arm硬件特性来优化执行性能,以达到低时延以及较高的可用性。实验结果表明,该系统通过有效地利用新硬件特性,能够以较小的可信代码段,对多种类型的虚拟机执行低时延的度量,并保证度量结果的安全性。The embodiment of the present invention provides a lightweight trusted measurement system based on a trusted execution environment. As shown in FIG1 , the system effectively reduces the size of the trusted code segment by utilizing a multi-level collaborative architecture, providing the possibility for deep performance optimization; uses extensible and customized measurements, and can measure various types of virtual machine images and most system components in the cloud platform; provides configurable targeted optimization, and optimizes execution performance according to the particularity of the cloud platform scenario and the characteristics of Arm hardware to achieve low latency and high availability. Experimental results show that the system can effectively utilize new hardware features to perform low-latency measurements on various types of virtual machines with smaller trusted code segments and ensure the security of the measurement results.

本发明的具体装置实施例如图1所示。普通世界中的软件通常由云平台服务商根据自己的业务需求进行定制,本发明这里给出了一种示例,普通世界中EL2运行了由云平台提供的Hypervisor,用于管理用户的虚拟机;其下运行了若干虚拟机,上面运行着用户自定义的各种应用和服务;如果用户想要启用度量服务来保证自己虚拟机的完整性,则需要在自己的虚拟机中增加度量服务驱动,用于接受用户态或内核中其他模块发送的度量请求,并向度量系统发起度量请求,例如在Linux下,是一个内核模块。The specific device embodiment of the present invention is shown in Figure 1. Software in the ordinary world is usually customized by cloud platform service providers according to their own business needs. The present invention gives an example here. In the ordinary world, EL2 runs a Hypervisor provided by the cloud platform to manage the user's virtual machine; several virtual machines are running under it, and various user-defined applications and services are running on it; if the user wants to enable the measurement service to ensure the integrity of his virtual machine, he needs to add a measurement service driver in his virtual machine to accept measurement requests sent by user state or other modules in the kernel, and initiate measurement requests to the measurement system. For example, under Linux, it is a kernel module.

在安全世界中,SPMD承担着EL3固件的作用,负责执行最高权限的配置和管理,以及校验两个世界之间的通信请求;SPMC负责管理其下运行的多个SP;地址翻译模块和SPMC一样运行在EL2,负责将度量对象的虚拟地址翻译为物理地址,并映射到执行度量计算的SP的地址空间中;度量执行模块被设计为运行在EL1的一个SP,它执行了度量过程中几乎所有计算操作以及相关的密码学操作。In the secure world, SPMD plays the role of EL3 firmware, responsible for executing the configuration and management of the highest permissions, and verifying the communication requests between the two worlds; SPMC is responsible for managing multiple SPs running under it; the address translation module runs in EL2 like SPMC, responsible for translating the virtual address of the measurement object into a physical address and mapping it to the address space of the SP that performs the measurement calculation; the measurement execution module is designed as an SP running in EL1, which performs almost all calculation operations and related cryptographic operations in the measurement process.

本发明中各个模块的具体实施:The specific implementation of each module in the present invention:

度量服务驱动模块:Metrics service driver module:

由于SMC Call需要软件至少要运行在EL1特权级才能调用,无法在EL0即应用层直接发起度量请求。而为了满足兼容性要求,需要尽可能减少对操作系统的修改。现代操作系统大多支持通过添加系统内核模块的方式来动态扩展内核的功能,这在不修改操作系统内核的基础上提供了执行特权代码的可能。本发明为Linux编写了一个系统内核模块作为度量服务驱动的示例,通过将其动态添加到虚拟机中,以作为度量请求的发起点。Since SMC Call requires the software to run at least at the EL1 privilege level to call, it is impossible to directly initiate a measurement request at EL0, i.e., the application layer. In order to meet compatibility requirements, it is necessary to minimize the modification of the operating system. Most modern operating systems support dynamic expansion of kernel functions by adding system kernel modules, which provides the possibility of executing privileged code without modifying the operating system kernel. The present invention writes a system kernel module for Linux as an example of a measurement service driver, and dynamically adds it to a virtual machine as the starting point for a measurement request.

度量服务驱动主要承担两个方面的作用。最主要的是接受应用层发来的度量请求,并通过SMC Call将其发送到安全世界中去;其次为了让安全世界中其他类型的SP能够正常运行,还实现了一个简单的调度器,能够周期性地将CPU资源从普通世界让渡给安全世界。The measurement service driver mainly plays two roles. The most important one is to accept measurement requests from the application layer and send them to the secure world through SMC Call. Secondly, in order to enable other types of SPs in the secure world to run normally, a simple scheduler is also implemented to periodically transfer CPU resources from the normal world to the secure world.

为了让运行在内核态的度量服务驱动能够接收到来自应用层的消息,本发明在内核模块初始化时创建了一个字符串设备,同时使用Input Output ConTroL(ioctl)来将相关接口暴露给用户态。用户态程序可以通过打开相应字符串设备,并使用ioctl相关系统调用来使用度量服务驱动提供的功能。度量服务驱动接收到来自用户态的请求后,会将度量请求写入到一个完整的内存页,通过共享内存的方法将请求发送至安全世界。In order to enable the measurement service driver running in the kernel state to receive messages from the application layer, the present invention creates a string device when the kernel module is initialized, and uses Input Output ConTroL (ioctl) to expose the relevant interface to the user state. The user state program can use the functions provided by the measurement service driver by opening the corresponding string device and using the ioctl related system call. After receiving the request from the user state, the measurement service driver will write the measurement request to a complete memory page and send the request to the secure world through the shared memory method.

调度器部分,会根据安全世界中所有SP的虚拟CPU总数来创建对应数量的线程,这些线程的调度由Linux本身的调度器来完成。当某个线程被调度到后,它会调用FF-A中与调度相关的ABI,来将自己的CPU资源让渡给安全世界中对应的虚拟机CPU。The scheduler will create a corresponding number of threads according to the total number of virtual CPUs of all SPs in the secure world. The scheduling of these threads is done by the Linux scheduler itself. When a thread is scheduled, it will call the scheduling-related ABI in FF-A to transfer its own CPU resources to the corresponding virtual machine CPU in the secure world.

地址翻译模块:Address translation module:

地址翻译模块被设计为和SPMC一样运行在安全世界中的EL2层级,负责对请求进行初步的解析、将相关地址进行翻译,并将相关的内存页映射给度量执行模块。为了减少地址翻译所需的开销,在地址翻译模块中维护了一个队列,储存了已经完成翻译和映射的请求的哈希值,且按照此请求上一次执行的顺序进行排列。当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到了自己虚拟地址空间的哪一个部分。否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。The address translation module is designed to run at the EL2 level in the secure world like SPMC. It is responsible for preliminary parsing of requests, translating relevant addresses, and mapping relevant memory pages to the measurement execution module. In order to reduce the overhead required for address translation, a queue is maintained in the address translation module to store the hash values of requests that have been translated and mapped, and arranged in the order of the last execution of this request. When a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its own virtual address space the memory related to this request is mapped. Otherwise, no repeated translation and mapping operations are performed, and the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly.

还需要结合其他模块来获取地址翻译相关的寄存器。对于运行在普通世界中EL1特权级的虚拟机进行度量时,需要访问两个阶段的页表,分别为第一阶段页表,将虚拟机的虚拟地址转换为间接物理地址,由虚拟机自身进行配置;第二阶段页表,将间接物理地址转换为物理地址,由Hypervisor进行配置。然而,在当前系统中,SPMC和Hypervisor都运行在EL2,都需要对第二阶段页表进行配置,且所使用的页表寄存器的名称相同。在Hypervisor视角下,有一组寄存器用于配置虚拟机的第二阶段页表,但在SPMC的视角下,这组寄存器用于配置SP的非安全内存的第二阶段页表。EL3中运行的TF-A固件的目前实现中,世界切换时也会切换这组寄存器的值,导致SPMC无法正常访问到虚拟机的二阶段页表。因此本发明使用了额外的通用寄存器,将所需寄存器暂存下来,然后传递到安全世界当中。然而,不是所有两个世界间的交互都需要暂存这组寄存器,因为这可能会带来额外的信息传递,增加潜在的信息泄漏风险。因此在EL3中,本发明修改了固件使其会识别ABI中的Magic Code,只有当前接口是与度量服务相关时,才会将相关寄存器传递至安全世界。It is also necessary to combine other modules to obtain registers related to address translation. When measuring a virtual machine running at the EL1 privilege level in the normal world, it is necessary to access two stages of page tables, namely the first stage page table, which converts the virtual address of the virtual machine into an indirect physical address and is configured by the virtual machine itself; the second stage page table, which converts the indirect physical address into a physical address and is configured by the Hypervisor. However, in the current system, both SPMC and Hypervisor run at EL2, and both need to configure the second stage page table, and the names of the page table registers used are the same. From the perspective of the Hypervisor, there is a set of registers used to configure the second stage page table of the virtual machine, but from the perspective of the SPMC, this set of registers is used to configure the second stage page table of the SP's non-secure memory. In the current implementation of the TF-A firmware running in EL3, the values of this set of registers will also be switched when the world is switched, resulting in the SPMC being unable to access the second stage page table of the virtual machine normally. Therefore, the present invention uses additional general registers to temporarily store the required registers and then pass them to the secure world. However, not all interactions between the two worlds require the temporary storage of this set of registers, because this may bring additional information transmission and increase the potential risk of information leakage. Therefore, in EL3, the present invention modifies the firmware so that it can recognize the Magic Code in the ABI, and only when the current interface is related to the measurement service will the relevant registers be passed to the secure world.

度量执行模块:Metrics execution module:

度量执行模块被设计为运行在由SPMC管理的安全世界中的EL1层级执行。为了保证度量结果的完备性,使得用户获得度量结果后,有充分的理由判断当前系统是否处于安全状态,我们提供了三种不同维度的度量方式:The measurement execution module is designed to run at the EL1 level in the secure world managed by SPMC. In order to ensure the completeness of the measurement results, so that users have sufficient reasons to determine whether the current system is in a secure state after obtaining the measurement results, we provide three different dimensions of measurement:

计算静态数据对应虚拟地址中数据的哈希值。在早期度量系统以及目前常用的安全启动技术中,都需要对软件映像进行哈希计算得到哈希值,并报告给用户,因此用户能够判断目标机器上是否运行了自己想要运行的系统。但是仅仅对操作系统启动前的映像进行度量,无法反映操作系统运行时的安全状态。我们借鉴这种思路,支持了对静态数据在运行时的度量。同时为了能够适配尽可能多的操作系统,静态数据实际加载的虚拟地址需要由虚拟机的拥有者自行生成度量请求以字节为粒度进行指定。这种方法对用户自身的操作系统水平提出了一定要求,因为需要他们有能力知道哪些虚拟地址上的数据是安全敏感的,且有一定的编程水平来生成这样一份度量请求。为了易用性,我们提供了一些工具以辅助用户进行使用,且度量请求也可由操作系统开发者来生成,由多个用户共同使用。地址翻译模块会将度量请求中需要计算哈希值的所有虚拟地址翻译为物理地址,并映射到度量执行模块的地址空间中,再由度量执行模块进行计算。度量系统将哈希值经签名后传递出去,用户可根据哈希值是否符合预期来判断系统的安全状态。Calculate the hash value of the data in the virtual address corresponding to the static data. In the early measurement system and the currently commonly used secure boot technology, it is necessary to calculate the hash value of the software image and report it to the user, so that the user can determine whether the system he wants to run is running on the target machine. However, only measuring the image before the operating system is started cannot reflect the security status of the operating system at runtime. We borrow this idea and support the measurement of static data at runtime. At the same time, in order to adapt to as many operating systems as possible, the virtual address where the static data is actually loaded needs to be specified by the owner of the virtual machine by generating a measurement request with bytes as the granularity. This method places certain requirements on the user's own operating system level, because they need to be able to know which data on the virtual address is security-sensitive and have a certain level of programming to generate such a measurement request. For ease of use, we provide some tools to assist users in using it, and the measurement request can also be generated by the operating system developer and used by multiple users. The address translation module will translate all virtual addresses in the measurement request that need to calculate the hash value into physical addresses, and map them to the address space of the measurement execution module, and then the measurement execution module will calculate them. The measurement system passes the hash value after signing, and users can judge the security status of the system based on whether the hash value meets expectations.

计算指定虚拟地址在二阶段页表中的权限位。一些数据在运行时会动态地修改,难以简单通过一个哈希值来反映其是否安全。我们观察到,一些数据在页表上的权限位始终具有特定的属性。例如,操作系统中的代码段一般始终具有可执行权限,而不具有可写权限。具体哪些页需要进行何种类型的权限检查同样由用户决定,也同样是以字节为粒度,并经由度量服务驱动传递给度量系统。如果启用了这一维度的度量方式,地址翻译模块会将相关页表的物理地址同样映射到度量执行模块的地址空间中,由度量执行模块执行相关检查。Calculate the permission bits of the specified virtual address in the two-stage page table. Some data will be modified dynamically at runtime, and it is difficult to simply reflect whether it is safe through a hash value. We have observed that the permission bits of some data on the page table always have specific properties. For example, the code segment in the operating system generally always has executable permissions but not writable permissions. Which pages require what type of permission check is also determined by the user, also at the byte granularity, and passed to the measurement system via the measurement service driver. If this dimension of measurement is enabled, the address translation module will also map the physical address of the relevant page table to the address space of the measurement execution module, and the measurement execution module will perform the relevant checks.

检查和监视物理地址的共享状态。当具有以上两种度量方式时,已经能够一定程度上保证系统的完整性。但在FF-A规范的基础上,能够进一步对物理地址在多个SP间的共享状态进行保护。SP可以要求度量系统在结果里返回某些物理地址的共享状态,或者要求度量系统保证某些物理地址始终处于某个共享状态。例如,如果某个SP想实现一定程度上的私密存储,让某块内存不会被攻击者共享给其他SP,即可委托度量系统对这块内存的共享状态进行监视。当SP间进行内存共享的操作时,度量系统会保证这些操作不会违背预先制定的共享规则。由于物理地址没有任何可用性的保证,且不具备调度能力,不能及时将违规操作告知给相应SP,只能在SP下次请求度量时,在度量报告中附带上相关信息。其次,攻击者可能伪造SP的行为来取消对内存的保护,度量系统会将相关行为保存下来,随度量报告一并告知给用户。这种度量方式由SPMC来实现,因为SPMC负责SP的内存共享和隔离。此外,由于安全世界不具备针对Hypervisor的特权关系,这种完整性保护不适用于普通世界中的虚拟机。但是如果普通世界中Hypervisor遵循FF-A标准的话,这种保护方式可以很方便地迁移到Hypervisor上。Check and monitor the sharing status of physical addresses. With the above two measurement methods, the integrity of the system can be guaranteed to a certain extent. However, based on the FF-A specification, the sharing status of physical addresses between multiple SPs can be further protected. SPs can require the measurement system to return the sharing status of certain physical addresses in the results, or require the measurement system to ensure that certain physical addresses are always in a certain sharing state. For example, if an SP wants to achieve a certain degree of private storage so that a certain block of memory will not be shared with other SPs by attackers, it can entrust the measurement system to monitor the sharing status of this memory. When SPs perform memory sharing operations, the measurement system will ensure that these operations do not violate the pre-established sharing rules. Since physical addresses do not have any availability guarantees and do not have scheduling capabilities, the illegal operations cannot be notified to the corresponding SP in time. The only thing to do is to attach relevant information in the measurement report when the SP requests measurement next time. Secondly, the attacker may forge the behavior of the SP to cancel the protection of the memory. The measurement system will save the relevant behavior and inform the user together with the measurement report. This measurement method is implemented by SPMC because SPMC is responsible for the memory sharing and isolation of SPs. In addition, since the secure world does not have privileged relationships with the hypervisor, this integrity protection does not apply to virtual machines in the normal world. However, if the hypervisor in the normal world complies with the FF-A standard, this protection method can be easily migrated to the hypervisor.

度量请求中需要有一个字段,储存了此请求的哈希值。通过采取了First In,First Out策略,在地址翻译模块中维护了一个队列,储存了已经完成翻译和映射的请求的哈希值,且按照此请求上一次执行的顺序进行排列。当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到了自己虚拟地址空间的哪一个部分。否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。There needs to be a field in the measurement request to store the hash value of this request. By adopting the First In, First Out strategy, a queue is maintained in the address translation module to store the hash values of the requests that have been translated and mapped, and they are arranged in the order of the last execution of this request. When a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its virtual address space the memory related to this request is mapped to. Otherwise, no repeated translation and mapping operations are performed, and the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly.

对度量对象的内存执行线性的扫描并计算哈希也是一项比较耗时的操作,我们的解决方法是使用一些计算速度快但安全性较低的哈希算法,与安全性较强的算法混合使用。更具体地说,当用户周期性地请求度量系统执行度量时,可以配置一个时间阈值。这个时间阈值要求度量系统必须在规定的时间范围内执行一次使用强安全性哈希算法的度量操作,在此之间执行的度量请求将采用低安全性哈希算法。如果出现度量失败的情况进行第二次度量时,将始终选择安全性较强的算法。目前,低安全性哈希算法我们使选择将被度量内存以一定步长异或起来,并经Arm Scalable Vector Extension(SVE)加速;高安全性哈希算法我们使用了MbedTLS提供的SHA-256算法。这种优化势必会使得当前度量报告无法安全地反映度量对象本身的完整性,造成假阴性的概率增加,因此我们同样提供了配置选项允许用户来关闭此项优化。Performing a linear scan of the memory of the measurement object and calculating the hash is also a time-consuming operation. Our solution is to use some fast but less secure hash algorithms mixed with more secure algorithms. More specifically, when users periodically request the measurement system to perform measurements, a time threshold can be configured. This time threshold requires the measurement system to perform a measurement operation using a strong security hash algorithm within a specified time range. Measurement requests executed during this period will use a low-security hash algorithm. If a measurement fails, the second measurement will always use a more secure algorithm. Currently, for the low-security hash algorithm, we select the memory to be measured XORed with a certain step size and accelerated by Arm Scalable Vector Extension (SVE); for the high-security hash algorithm, we use the SHA-256 algorithm provided by MbedTLS. This optimization will inevitably make the current measurement report unable to safely reflect the integrity of the measurement object itself, resulting in an increased probability of false negatives, so we also provide a configuration option to allow users to turn off this optimization.

可信通信协议:Trusted communication protocol:

数据一旦流出安全世界,就可能受到攻击,被恶意窃取和篡改。因此我们设计了一个基于非对称加密算法的可信通信协议,能够保证度量结果真实有效,使得度量系统中的各个组件间的通信是可信的,以及各个组件能够确定消息的来源是安全的。为了简明,这里介绍的是对普通世界中虚拟机度量流程中的通信协议,不失一般性的,对其他组件度量时也可以应用此协议,但实现细节上有轻微的改变。使用此可信通信协议的前提是,非对称加密算法的安全性,这要求安全世界中软件能够正确地生成随机数,以及安全世界中软件能够可信地获取一个时间戳。以下为在这个通信协议中参与通信的各个实体:Once data flows out of the secure world, it may be attacked, maliciously stolen, and tampered with. Therefore, we designed a trusted communication protocol based on an asymmetric encryption algorithm to ensure that the measurement results are authentic and valid, so that the communication between the components in the measurement system is credible, and each component can determine that the source of the message is secure. For the sake of simplicity, this article introduces the communication protocol for the virtual machine measurement process in the ordinary world. Without loss of generality, this protocol can also be applied when measuring other components, but there are slight changes in the implementation details. The premise of using this trusted communication protocol is the security of the asymmetric encryption algorithm, which requires that the software in the secure world can correctly generate random numbers and that the software in the secure world can reliably obtain a timestamp. The following are the entities involved in the communication in this communication protocol:

安全世界:为了简明,将安全世界中所有组件抽象为一个共同体。由于安全世界相对于普通世界的关系是平行的,更像是一个协处理器,承担着类似TPM芯片的作用;Secure world: For simplicity, all components in the secure world are abstracted as a community. Since the secure world is parallel to the ordinary world, it is more like a coprocessor and plays a role similar to that of a TPM chip.

安全验证者:可以是云平台服务提供商,或由其委托的可信第三方,需要为硬件平台提供身份证明;Security verifier: can be a cloud platform service provider, or a trusted third party entrusted by it, who needs to provide identity proof for the hardware platform;

虚拟机验证者:普通世界中某个虚拟机的拥有者,或由其委托的可信第三方,需要为该虚拟机的某个度量结果提供证明;Virtual machine verifier: The owner of a virtual machine in the ordinary world, or a trusted third party entrusted by the owner, needs to provide proof for a certain measurement result of the virtual machine;

挑战者:度量请求的发起者,在使用运行在虚拟机上的某个服务前,想要知道这个虚拟机的完整性。Challenger: The initiator of the measurement request wants to know the integrity of the virtual machine before using a service running on the virtual machine.

为了使情况更简明,在这里规定,任何实体与安全验证者和虚拟机验证者之间的通信是可信的,因为能够通过事先分发公钥来保证这一点。此外,虚拟机的迁移不在考虑范围内,因为可信的迁移能够以正交的形式实现。我们的通信协议的基础是非对称加密算法,在算法中总共涉及到两对公私钥,分别为:Endorsement Key(EK),其私钥存储在安全世界中,用于证明硬件平台本身的身份和完整性完整性;Attestation Key(AK),其私钥同样存储在安全世界中,针对每个虚拟机将使用不同的AK。各实体之间具体交互的细节将在后续流程实施例中进行阐述。To make the situation more concise, it is stipulated here that the communication between any entity and the security verifier and the virtual machine verifier is trusted, because this can be guaranteed by distributing public keys in advance. In addition, the migration of virtual machines is not considered, because trusted migration can be implemented in an orthogonal form. The basis of our communication protocol is an asymmetric encryption algorithm, which involves a total of two pairs of public and private keys, namely: Endorsement Key (EK), whose private key is stored in the secure world and is used to prove the identity and integrity of the hardware platform itself; Attestation Key (AK), whose private key is also stored in the secure world, and a different AK will be used for each virtual machine. The details of the specific interactions between the entities will be explained in the subsequent process embodiments.

接下来,对本发明进行更为具体的说明。Next, the present invention will be described in more detail.

本发明中技术方案的具体实施流程包含云平台启动过程、虚拟机启动过程、请求传递过程、地址翻译过程、度量的执行过程、度量结果的验证过程。The specific implementation process of the technical solution in the present invention includes a cloud platform startup process, a virtual machine startup process, a request transmission process, an address translation process, a measurement execution process, and a measurement result verification process.

其中,参照图2所示,云平台启动过程包括:As shown in FIG. 2 , the cloud platform startup process includes:

步骤1)硬件平台厂商私密地生成EK的公私钥。Step 1) The hardware platform manufacturer privately generates the public and private keys of the EK.

步骤2)硬件平台厂商将EK的公钥放置于安全验证者中;通常安全验证者为硬件平台厂商对外提供的服务。Step 2) The hardware platform manufacturer places the public key of the EK in the security verifier; usually the security verifier is a service provided by the hardware platform manufacturer to the outside world.

步骤3)硬件平台厂商将EK的私钥以安全且私密的方式放置于安全世界的软件映像中。Step 3) The hardware platform manufacturer places the EK's private key in the software image of the secure world in a secure and private manner.

步骤4)安全世界中的软件以可信的方式进行启动;需要保证软件本身不被篡改,以及其中的隐私信息不被泄露。如果启动失败,跳转到步骤6;否则进入下一步。Step 4) The software in the secure world is started in a trusted manner; it is necessary to ensure that the software itself is not tampered with and the private information therein is not leaked. If the startup fails, jump to step 6; otherwise, proceed to the next step.

步骤5)启动成功,能够向其中部署用户的虚拟机。Step 5) The startup is successful and the user's virtual machine can be deployed therein.

步骤6)创建失败,过程中有异常或可能受到攻击。Step 6) Creation failed. There was an exception during the process or it may be attacked.

参照图3所示,虚拟机启动过程包括:As shown in FIG. 3 , the virtual machine startup process includes:

步骤1)用户将自身虚拟机映像上传至平台,进行虚拟机本身的启动,其中会初始化度量服务驱动。Step 1) The user uploads his own virtual machine image to the platform and starts the virtual machine itself, during which the measurement service driver is initialized.

步骤2)虚拟机启动后,向安全世界请求生成AK,以供后续度量使用。Step 2) After the virtual machine is started, it requests the secure world to generate an AK for subsequent measurement.

步骤3)安全世界接收到AK生成请求,生成AK的公私钥,并将这对密钥与虚拟机的VMID进行绑定;最后,使用EK私钥对此次请求的结果进行签名,并将结果返还至虚拟机验证者。Step 3) The secure world receives the AK generation request, generates the public and private keys of the AK, and binds this pair of keys to the VMID of the virtual machine; finally, the result of this request is signed using the EK private key and returned to the virtual machine verifier.

步骤4)虚拟机验证者向安全验证者请求验证AK生成结果的签名正确性。验证不通过,跳转到步骤7,否则进入下一步。Step 4) The virtual machine verifier requests the security verifier to verify the correctness of the signature of the AK generation result. If the verification fails, jump to step 7, otherwise proceed to the next step.

步骤5)虚拟机验证者将AK的公钥储存下来,用以校验之后度量结果的正确性。Step 5) The virtual machine verifier stores the public key of AK to verify the correctness of the subsequent measurement results.

步骤6)虚拟机启动阶段结束,能够相应后续的度量请求。Step 6) The virtual machine startup phase ends and can respond to subsequent measurement requests.

步骤7)启动失败。Step 7) Startup failed.

参照图4所示,请求传递过程包括:As shown in FIG4 , the request delivery process includes:

步骤1)想要发起度量的用户通过远程函数调用从虚拟机验证者处获得具体的请求。Step 1) A user who wants to initiate a measurement obtains a specific request from the virtual machine verifier through a remote function call.

步骤2)用户向虚拟机中的度量驱动发起请求。Step 2) The user initiates a request to the metric driver in the virtual machine.

步骤3)虚拟机驱动通过smc call将请求直接发送到安全世界。Step 3) The virtual machine driver sends the request directly to the secure world via an smc call.

步骤4)安全世界接受到度量请求,将要执行度量操作。Step 4) The secure world receives the measurement request and will perform the measurement operation.

参照图5所示,地址翻译过程包括:As shown in FIG5 , the address translation process includes:

步骤1)SPMC初步解析获取的度量请求。Step 1) SPMC initially parses the obtained measurement request.

步骤2)将度量请求分别映射到SPMC和度量执行模块的地址空间中。Step 2) Map the measurement request to the address space of SPMC and measurement execution module respectively.

步骤3)SPMC进一步解析请求,获取地址翻译信息。Step 3) SPMC further parses the request and obtains address translation information.

步骤4)将需要度量的内存映射到度量执行模块的地址空间中。Step 4) Map the memory to be measured into the address space of the measurement execution module.

步骤5)地址经重映射后,请求中的地址范围需要重新转换,此处进行度量请求的转换。Step 5) After the address is remapped, the address range in the request needs to be reconverted, and the conversion of the measurement request is performed here.

步骤6)根据FF-A规范将请求传递给度量执行模块。Step 6) Pass the request to the measurement execution module according to the FF-A specification.

参照图6所示,度量执行过程包括:As shown in FIG6 , the measurement execution process includes:

步骤1)度量执行模块解析收到的度量请求。Step 1) The measurement execution module parses the received measurement request.

步骤2)度量执行模块将需要被度量的内存映射到自己的第一级页表中。Step 2) The measurement execution module maps the memory to be measured into its own first-level page table.

步骤3)执行度量操作,主要为对被度量内存的哈希操作。Step 3) performs measurement operations, mainly hash operations on the measured memory.

步骤4)使用对应的AK私钥将度量结果进行签名,进而生成可验证的度量结果。Step 4) Use the corresponding AK private key to sign the measurement result, thereby generating a verifiable measurement result.

步骤5)将度量结果返回。Step 5) Return the measurement result.

参照图7所示,度量结果的验证过程包括:As shown in FIG. 7 , the verification process of the measurement result includes:

步骤1)用户通过远程函数调用将度量结果传递给虚拟机验证者。Step 1) The user passes the measurement result to the virtual machine verifier through a remote function call.

步骤2)虚拟机验证者通过AK公钥验证度量结果签名的正确性。验证失败,跳转到步骤6;否则,进入下一步。Step 2) The virtual machine verifier verifies the correctness of the signature of the measurement result through the AK public key. If the verification fails, jump to step 6; otherwise, go to the next step.

步骤3)虚拟机验证者比对度量结果中内容是否正确。验证失败,跳转到步骤6;否则,进入下一步。Step 3) The virtual machine verifier compares the measurement results to see if they are correct. If the verification fails, jump to step 6; otherwise, proceed to the next step.

步骤4)返还验证结果给用户。Step 4) Return the verification result to the user.

步骤5)度量成功,度量目标的完整性没有受到破坏。Step 5) The measurement is successful and the integrity of the measurement target is not compromised.

步骤6)度量失败,度量目标的完整性可能受到破坏。Step 6) If the measurement fails, the integrity of the measurement target may be compromised.

本发明核心创新点:1:利用安全虚拟化硬件特性,进一步保障系统安全。The core innovation of the present invention is: 1: Utilizing the characteristics of secure virtualization hardware to further ensure system security.

从属创新点1.1:使用多层级协同化架构,只对核心安全模块进行尽可能少的修改,以减少整体TCB的大小。Subordinate Innovation 1.1: Use a multi-level collaborative architecture and make as few modifications as possible to the core security modules to reduce the size of the overall TCB.

丛属创新点1.2:通过SPMC进行地址翻译过程,提高代码的可重复利用率,保障整体安全性。Innovation point 1.2: Perform address translation through SPMC to improve code reusability and ensure overall security.

核心创新点2:准确反映度量对象的完整性,且兼容云平台中多种不同的度量对象。Core innovation 2: Accurately reflects the integrity of the measurement object and is compatible with a variety of different measurement objects in the cloud platform.

从属创新点2.1:支持多种不同类型的度量内容和度量方式,保障云平台中用户的安全性。Subordinate innovation point 2.1: Support different types of measurement content and measurement methods to ensure the security of users in the cloud platform.

从属创新点2.2:支持度量请求的动态变化,保障长时间维度下的安全性。Subordinate innovation 2.2: Support dynamic changes in measurement requests to ensure security over long periods of time.

从属创新点2.3:设计了可信的通信协议,防止中间人攻击。Subordinate Innovation 2.3: A trusted communication protocol is designed to prevent man-in-the-middle attacks.

核心创新点3:针对硬件特殊性和场景特殊性降低时延,提高可用性。Core innovation point 3: Reduce latency and improve availability based on hardware and scenario specificity.

从属创新点3.1:通过多个层级协同设计,减少度量请求传递通路的长度。Subordinate Innovation 3.1: Reduce the length of the measurement request transmission path through multi-level collaborative design.

从属创新点3.2:支持不同哈希算法可配置地混合进行计算。Subordinate Innovation Point 3.2: Support configurable mixing of different hash algorithms for calculation.

从属创新点3.3:使用队列避免重复的地址映射操作。Subordinate Innovation 3.3: Use queues to avoid repeated address mapping operations.

本发明实施例提供了一种基于可信执行环境的轻量级可信度量系统及方法,利用安全虚拟化特性,保证系统的安全性,借用已有的开源软件和开源软件框架,将大多数安全敏感的代码逻辑配置在隔离的环境中,让TCB在必要部分的基础上,仅仅增加有限的一小部分代码。通过灵活性的设计,准确反映度量对象的完整性,且兼容云平台中多种不同的度量对象,且保障数据流通的安全。在保证度量系统能够提供较高安全性的度量结果的同时,针对云平台场景的特殊性以及本发明当前所使用的硬件平台来进行性能优化。The embodiment of the present invention provides a lightweight trusted measurement system and method based on a trusted execution environment, which uses the characteristics of secure virtualization to ensure the security of the system, and uses existing open source software and open source software frameworks to configure most security-sensitive code logic in an isolated environment, so that TCB only adds a limited small part of the code on the basis of the necessary part. Through flexible design, the integrity of the measurement object is accurately reflected, and it is compatible with a variety of different measurement objects in the cloud platform, and the security of data flow is guaranteed. While ensuring that the measurement system can provide measurement results with higher security, performance optimization is performed based on the particularity of the cloud platform scenario and the hardware platform currently used by the present invention.

本领域技术人员知道,除了以纯计算机可读程序代码方式实现本发明提供的系统及其各个装置、模块、单元以外,完全可以通过将方法步骤进行逻辑编程来使得本发明提供的系统及其各个装置、模块、单元以逻辑门、开关、专用集成电路、可编程逻辑控制器以及嵌入式微控制器等的形式来实现相同功能。所以,本发明提供的系统及其各项装置、模块、单元可以被认为是一种硬件部件,而对其内包括的用于实现各种功能的装置、模块、单元也可以视为硬件部件内的结构;也可以将用于实现各种功能的装置、模块、单元视为既可以是实现方法的软件模块又可以是硬件部件内的结构。Those skilled in the art know that, in addition to realizing the system and its various devices, modules, and units provided by the present invention in a purely computer-readable program code, it is entirely possible to realize the same functions in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers by logically programming the method steps. Therefore, the system and its various devices, modules, and units provided by the present invention can be considered as a hardware component, and the devices, modules, and units included therein for realizing various functions can also be regarded as structures within the hardware component; the devices, modules, and units for realizing various functions can also be regarded as both software modules for realizing the method and structures within the hardware component.

以上对本发明的具体实施例进行了描述。需要理解的是,本发明并不局限于上述特定实施方式,本领域技术人员可以在权利要求的范围内做出各种变化或修改,这并不影响本发明的实质内容。在不冲突的情况下,本申请的实施例和实施例中的特征可以任意相互组合。The above describes the specific embodiments of the present invention. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art can make various changes or modifications within the scope of the claims, which does not affect the essence of the present invention. In the absence of conflict, the embodiments of the present application and the features in the embodiments can be combined with each other arbitrarily.

Claims (6)

1.一种基于可信执行环境的轻量级可信度量系统,其特征在于,包括:1. A lightweight trusted measurement system based on a trusted execution environment, comprising: 度量服务驱动模块:接受应用层发来的度量请求,通过SMC Call将度量请求发送到安全世界中去;以及设置调度器,周期性地将CPU资源从普通世界让渡给安全世界;Metrics service driver module: accepts metrics requests from the application layer and sends them to the secure world through SMC Call; and sets up a scheduler to periodically transfer CPU resources from the normal world to the secure world; 地址翻译模块:设计在安全世界中的EL2层级,负责对请求进行初步的解析、将相关地址进行翻译,并将相关的内存页映射给度量执行模块;Address translation module: Designed at the EL2 level in the secure world, it is responsible for preliminary parsing of requests, translating relevant addresses, and mapping relevant memory pages to the measurement execution module; 度量执行模块:设计运行在由SPMC管理的安全世界中的EL1层级执行;Measurement execution module: designed to run at EL1 level in the secure world managed by SPMC; 可信通信协议:基于非对称加密算法,保证度量结果真实有效,使得度量系统中的各个组件间的通信可信,以及各个组件能够确定消息的来源安全;Trusted communication protocol: Based on asymmetric encryption algorithms, it ensures that the measurement results are authentic and valid, making the communication between components in the measurement system trustworthy, and each component can determine the security of the source of the message; 所述度量服务驱动模块包括:The measurement service driver module includes: 通过Linux编写系统内核模块作为度量服务驱动的示例,通过将其动态添加到虚拟机中,以作为度量请求的发起点;An example of writing a system kernel module in Linux as a measurement service driver is given, which is dynamically added to the virtual machine as the initiation point of the measurement request. 在内核模块初始化时创建一个字符串设备,同时使用ioctl来将相关接口暴露给用户态,用户态程序通过打开相应字符串设备,并使用ioctl相关系统调用来使用度量服务驱动提供的功能;度量服务驱动接收到来自用户态的请求后,将度量请求写入到一个完整的内存页,通过共享内存的方法将请求发送至安全世界;When the kernel module is initialized, a string device is created and ioctl is used to expose the relevant interface to the user state. The user state program opens the corresponding string device and uses the ioctl related system calls to use the functions provided by the measurement service driver. After receiving the request from the user state, the measurement service driver writes the measurement request to a complete memory page and sends the request to the secure world through the shared memory method. 所述度量服务驱动模块包括:所述调度器根据安全世界中所有SP的虚拟CPU总数来创建对应数量的线程,这些线程的调度由Linux本身的调度器来完成;当某个线程被调度到后,该线程则调用FF-A中与调度相关的ABI,将自己的CPU资源让渡给安全世界中对应的虚拟机CPU;The metric service driver module includes: the scheduler creates a corresponding number of threads according to the total number of virtual CPUs of all SPs in the secure world, and the scheduling of these threads is completed by the scheduler of Linux itself; when a thread is scheduled, the thread calls the ABI related to scheduling in FF-A to transfer its own CPU resources to the corresponding virtual machine CPU in the secure world; 所述地址翻译模块需要结合其他模块来获取地址翻译相关的寄存器;The address translation module needs to be combined with other modules to obtain registers related to address translation; 使用额外的通用寄存器,将所需寄存器暂存下来,然后传递到安全世界当中;在EL3中,修改固件使其会识别ABI中的Magic Code,只有当前接口是与度量服务相关时,才会将相关寄存器传递至安全世界;Use additional general registers to temporarily store the required registers and then pass them to the secure world; in EL3, modify the firmware to recognize the Magic Code in the ABI, and only pass the relevant registers to the secure world when the current interface is related to the measurement service; 所述度量执行模块中,提供三种不同维度的度量方式,判断当前系统是否处于安全状态:The measurement execution module provides three different dimensional measurement methods to determine whether the current system is in a safe state: 1)计算静态数据对应虚拟地址中数据的哈希值;1) Calculate the hash value of the data in the virtual address corresponding to the static data; 2)计算指定虚拟地址在二阶段页表中的权限位;2) Calculate the permission bits of the specified virtual address in the second-stage page table; 3)检查和监视物理地址的共享状态。3) Check and monitor the sharing status of physical addresses. 2.根据权利要求1所述的基于可信执行环境的轻量级可信度量系统,其特征在于,所述地址翻译模块包括:在地址翻译模块中维护一个队列,储存已经完成翻译和映射的请求的哈希值,且按照此请求对上一次执行的顺序进行排列;当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到了自己虚拟地址空间的哪一个部分;否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。2. According to claim 1, the lightweight trusted measurement system based on the trusted execution environment is characterized in that the address translation module includes: maintaining a queue in the address translation module to store the hash values of the requests that have been translated and mapped, and arranging the order of the last execution according to this request; when a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its own virtual address space the memory related to this request is mapped to; otherwise, no repeated translation and mapping operations are performed, the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly. 3.根据权利要求1所述的基于可信执行环境的轻量级可信度量系统,其特征在于,所述度量请求中需要有一个字段,储存此请求的哈希值;通过采取FirstIn,First Out策略,在地址翻译模块中维护一个队列,储存已经完成翻译和映射的请求的哈希值,且按照此请求上一次执行的顺序进行排列;3. According to claim 1, the lightweight trusted measurement system based on the trusted execution environment is characterized in that the measurement request needs to have a field to store the hash value of the request; by adopting the FirstIn, FirstOut strategy, a queue is maintained in the address translation module to store the hash values of the requests that have completed translation and mapping, and the hash values are arranged in the order of the last execution of the request; 当接收到一个新的度量请求,且队列中查不到此请求对应的哈希值时,才进行翻译和映射等后续操作,且为此度量请求分配一个句柄,用以指示度量执行模块这个请求相关的内存被映射到自己虚拟地址空间的哪一个部分;否则,不再进行重复的翻译和映射操作,根据度量请求的哈希值查找到对应句柄,直接进行后续操作。When a new measurement request is received and the hash value corresponding to this request cannot be found in the queue, subsequent operations such as translation and mapping are performed, and a handle is allocated for this measurement request to indicate to the measurement execution module which part of its own virtual address space the memory related to this request is mapped to; otherwise, no repeated translation and mapping operations are performed, and the corresponding handle is found according to the hash value of the measurement request, and subsequent operations are performed directly. 4.一种基于可信执行环境的轻量级可信度量方法,其特征在于,基于权利要求1-3任意一项权利要求所述的基于可信执行环境的轻量级可信度量系统,包括:云平台启动过程、虚拟机启动过程、请求传递过程、地址翻译过程、度量的执行过程、度量结果的验证过程;4. A lightweight trusted measurement method based on a trusted execution environment, characterized in that the lightweight trusted measurement system based on a trusted execution environment according to any one of claims 1 to 3 includes: a cloud platform startup process, a virtual machine startup process, a request transmission process, an address translation process, a measurement execution process, and a measurement result verification process; 其中,云平台启动过程包括:The cloud platform startup process includes: 步骤1)由硬件平台厂商生成EK的公私钥;Step 1) The hardware platform manufacturer generates the public and private keys of the EK; 步骤2)硬件平台厂商将EK的公钥放置于安全验证者中;通常安全验证者为硬件平台厂商对外提供的服务;Step 2) The hardware platform manufacturer places the public key of the EK in the security verifier; usually the security verifier is a service provided by the hardware platform manufacturer to the outside world; 步骤3)硬件平台厂商将EK的私钥以安全且私密的方式放置于安全世界的软件映像中;Step 3) The hardware platform manufacturer places the EK’s private key in the software image of the secure world in a secure and private manner; 步骤4)安全世界中的软件以可信的方式进行启动;需要保证软件本身不被篡改,以及其中的隐私信息不被泄露;如果启动失败,跳转到步骤6);否则进入下一步;Step 4) The software in the secure world is started in a trusted manner; it is necessary to ensure that the software itself is not tampered with and the privacy information therein is not leaked; if the startup fails, jump to step 6); otherwise, proceed to the next step; 步骤5)启动成功,能够向其中部署用户的虚拟机;Step 5) The startup is successful and the user's virtual machine can be deployed therein; 步骤6)创建失败,过程中有异常或受到攻击;Step 6) Creation failed, there was an exception or attack during the process; 虚拟机启动过程包括:The virtual machine startup process includes: 步骤1)用户将自身虚拟机映像上传至平台,进行虚拟机本身的启动,初始化度量服务驱动;Step 1) The user uploads his own virtual machine image to the platform, starts the virtual machine itself, and initializes the measurement service driver; 步骤2)虚拟机启动后,向安全世界请求生成AK,以供后续度量使用;Step 2) After the virtual machine is started, it requests the secure world to generate an AK for subsequent measurement; 步骤3)安全世界接收到AK生成请求,生成AK的公私钥,并将这对密钥与虚拟机的VMID进行绑定;最后,使用EK私钥对此次请求的结果进行签名,并将结果返还至虚拟机验证者;Step 3) The secure world receives the AK generation request, generates the public and private keys of the AK, and binds the key pair to the VMID of the virtual machine; finally, the result of this request is signed using the EK private key and returned to the virtual machine verifier; 步骤4)虚拟机验证者向安全验证者请求验证AK生成结果的签名正确性,验证不通过,跳转到步骤7),否则进入下一步;Step 4) The virtual machine verifier requests the security verifier to verify the correctness of the signature of the AK generation result. If the verification fails, jump to step 7), otherwise proceed to the next step; 步骤5)虚拟机验证者将AK的公钥储存下来,用以校验之后度量结果的正确性;Step 5) The virtual machine verifier stores the public key of AK to verify the correctness of the subsequent measurement results; 步骤6)虚拟机启动阶段结束,能够相应后续的度量请求;Step 6) The virtual machine startup phase ends and can respond to subsequent measurement requests; 步骤7)启动失败;Step 7) Startup failure; 请求传递过程包括:The request delivery process includes: 步骤1)想要发起度量的用户通过远程函数调用从虚拟机验证者处获得具体的请求;Step 1) The user who wants to initiate the measurement obtains a specific request from the virtual machine verifier through a remote function call; 步骤2)用户向虚拟机中的度量驱动发起请求;Step 2) The user initiates a request to the metric driver in the virtual machine; 步骤3)虚拟机驱动通过smccall将请求直接发送到安全世界;Step 3) The virtual machine driver sends the request directly to the secure world via smccall; 步骤4)安全世界接受到度量请求,将要执行度量操作;Step 4) The secure world receives the measurement request and will perform the measurement operation; 地址翻译过程包括:The address translation process includes: 步骤1)SPMC初步解析获取的度量请求;Step 1) SPMC preliminarily parses the obtained measurement request; 步骤2)将度量请求分别映射到SPMC和度量执行模块的地址空间中;Step 2) Mapping the measurement request to the address space of the SPMC and the measurement execution module respectively; 步骤3)SPMC进一步解析请求,获取地址翻译信息;Step 3) SPMC further parses the request and obtains address translation information; 步骤4)将需要度量的内存映射到度量执行模块的地址空间中;Step 4) Mapping the memory to be measured into the address space of the measurement execution module; 步骤5)地址经重映射后,请求中的地址范围需要重新转换,此处进行度量请求的转换;Step 5) After the address is remapped, the address range in the request needs to be reconverted, and the conversion of the measurement request is performed here; 步骤6)根据FF-A规范将请求传递给度量执行模块;Step 6) passing the request to the measurement execution module according to the FF-A specification; 度量执行过程包括:The measurement execution process includes: 步骤1)度量执行模块解析收到的度量请求;Step 1) The measurement execution module parses the received measurement request; 步骤2)度量执行模块将需要被度量的内存映射到自己的第一级页表中;Step 2) The measurement execution module maps the memory to be measured into its own first-level page table; 步骤3)执行度量操作,对被度量内存的哈希操作;Step 3) Perform a measurement operation and a hash operation on the measured memory; 步骤4)使用对应的AK私钥将度量结果进行签名,进而生成可验证的度量结果;Step 4) Use the corresponding AK private key to sign the measurement result, thereby generating a verifiable measurement result; 步骤5)将度量结果返回;Step 5) Return the measurement result; 度量结果的验证过程包括:The verification process of the measurement results includes: 步骤1)用户通过远程函数调用将度量结果传递给虚拟机验证者;Step 1) The user passes the measurement result to the virtual machine verifier through a remote function call; 步骤2)虚拟机验证者通过AK公钥验证度量结果签名的正确性;验证失败,跳转到步骤6);否则,进入下一步;Step 2) The virtual machine verifier verifies the correctness of the signature of the measurement result through the AK public key; if the verification fails, jump to step 6); otherwise, proceed to the next step; 步骤3)虚拟机验证者比对度量结果中内容是否正确;验证失败,跳转到步骤6);否则,进入下一步;Step 3) The virtual machine verifier compares the measurement results to see if the content is correct; if the verification fails, jump to step 6); otherwise, proceed to the next step; 步骤4)返还验证结果给用户;Step 4) Return the verification result to the user; 步骤5)度量成功,度量目标的完整性没有受到破坏;Step 5) The measurement is successful and the integrity of the measurement target is not compromised; 步骤6)度量失败,度量目标的完整性存在受到破坏的可能性。Step 6) If the measurement fails, there is a possibility that the integrity of the measurement target will be compromised. 5.一种存储有计算机程序的计算机可读存储介质,其特征在于,所述计算机程序被处理器执行时实现权利要求4中所述的基于可信执行环境的轻量级可信度量方法的步骤。5. A computer-readable storage medium storing a computer program, characterized in that when the computer program is executed by a processor, the steps of the lightweight trusted measurement method based on a trusted execution environment described in claim 4 are implemented. 6.一种电子设备,包括存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,其特征在于,所述计算机程序被处理器执行时实现权利要求4中所述的基于可信执行环境的轻量级可信度量方法的步骤。6. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the lightweight trusted measurement method based on a trusted execution environment as described in claim 4.
CN202311484847.7A 2023-11-08 2023-11-08 Lightweight trusted measurement system and method based on trusted execution environment Active CN117473530B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311484847.7A CN117473530B (en) 2023-11-08 2023-11-08 Lightweight trusted measurement system and method based on trusted execution environment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311484847.7A CN117473530B (en) 2023-11-08 2023-11-08 Lightweight trusted measurement system and method based on trusted execution environment

Publications (2)

Publication Number Publication Date
CN117473530A CN117473530A (en) 2024-01-30
CN117473530B true CN117473530B (en) 2024-10-25

Family

ID=89627201

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311484847.7A Active CN117473530B (en) 2023-11-08 2023-11-08 Lightweight trusted measurement system and method based on trusted execution environment

Country Status (1)

Country Link
CN (1) CN117473530B (en)

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019140274A1 (en) * 2018-01-12 2019-07-18 Virsec Systems, Inc. Defending against speculative execution exploits
EP3757829A1 (en) * 2019-06-29 2020-12-30 INTEL Corporation Processor instruction support for mitigating controlled-channel and cache-based side-channel attacks

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7058768B2 (en) * 2002-04-17 2006-06-06 Microsoft Corporation Memory isolation through address translation data edit control
US10101936B2 (en) * 2014-07-28 2018-10-16 Hewlett Packard Enterprise Development Lp Memory access control
US9904805B2 (en) * 2015-09-23 2018-02-27 Intel Corporation Cryptographic cache lines for a trusted execution environment
CN110113439B (en) * 2019-04-09 2020-09-22 华南理工大学 A method of NAT traversal
CN116204884A (en) * 2021-11-30 2023-06-02 华为技术有限公司 Kernel protection method, device and system

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019140274A1 (en) * 2018-01-12 2019-07-18 Virsec Systems, Inc. Defending against speculative execution exploits
EP3757829A1 (en) * 2019-06-29 2020-12-30 INTEL Corporation Processor instruction support for mitigating controlled-channel and cache-based side-channel attacks

Also Published As

Publication number Publication date
CN117473530A (en) 2024-01-30

Similar Documents

Publication Publication Date Title
US11163911B2 (en) Secure public cloud with protected guest-verified host control
US20220019698A1 (en) Secure Public Cloud with Protected Guest-Verified Host Control
CN109918919B (en) Management of authentication variables
US8826391B2 (en) Virtualized trusted descriptors
KR20200036732A (en) Technologies for fast launch of trusted containers
US8627414B1 (en) Methods and apparatuses for user-verifiable execution of security-sensitive code
CN111382445A (en) A Method for Providing Trusted Service by Using Trusted Execution Environment System
Zhao et al. vsgx: Virtualizing sgx enclaves on amd sev
EP4020156B1 (en) Reducing latency of hardware trusted execution environments
US20220245255A1 (en) Systems and methods for processor virtualization
Brandão et al. Hardening cryptographic operations through the use of secure enclaves
Atamli-Reineh et al. Securing application with software partitioning: A case study using sgx
Pop et al. Towards securely migrating webassembly enclaves
Sahita et al. Security analysis of confidential-compute instruction set architecture for virtualized workloads
Zhang et al. iFlask: Isolate flask security system from dangerous execution environment by using ARM TrustZone
CN117473530B (en) Lightweight trusted measurement system and method based on trusted execution environment
CN118036012A (en) Trusted execution environment design method and system based on virtual machine manager
Song et al. Tz-ima: Supporting integrity measurement for applications with arm trustzone
Ushakov et al. Trusted hart for mobile RISC-V security
Yan et al. Performance Overheads of Confidential Virtual Machines
Sechkova et al. Cloud & edge trusted virtualized infrastructure manager (vim)-security and trust in openstack
Zhang et al. An efficient trustzone-based in-application isolation schema for mobile authenticators
aw Ideler Cryptography as a service in a cloud computing environment
Bove et al. Basic secure services for standard RISC-V architectures
Wang et al. TrustOSV: Building Trustworthy Executing Environment with Commodity Hardware for a Safe Cloud.

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant