Go to file
openharmony_ci 6882785c06
!227 区分普通证书和profile证书
Merge pull request !227 from maliang/cert_fix
2024-10-18 12:20:23 +00:00
figures update README for jit code signing 2024-05-17 15:41:20 +08:00
interfaces/innerkits !224 普通模式、坚盾模式使用ownerId type为APP_TEMP_ALLOW时均需要查询对应列表 2024-10-17 09:08:16 +00:00
services discriminate profile and common trusted cert 2024-10-18 19:27:31 +08:00
test !226 修复tdd用例 2024-10-18 08:03:27 +00:00
utils remove unnecessary info 2024-10-12 14:45:48 +08:00
BUILD.gn add jit code signer 2024-05-15 11:05:50 +08:00
bundle.json external_deps added 2024-06-29 02:47:41 -07:00
code_signature.gni enable keys for rddevice 2024-06-13 15:47:14 +08:00
hisysevent.yaml feat:新增设备id校验 2023-11-18 08:45:30 +08:00
LICENSE 添加代码签名开源合规文件 2023-08-19 11:28:12 +08:00
OAT.xml oat warning fixed 2024-05-23 14:12:43 +08:00
README_zh.md Refactor XPM init interface, add jitfort enable support. 2024-08-01 16:34:26 +08:00
README.md Refactor XPM init interface, add jitfort enable support. 2024-08-01 16:34:26 +08:00

Code Signature

Introduction

The code signature component implements the code signing mechanism of OpenHarmony, which provides validity check and integrity protection for apps in runtime, eliminating execution of malicious code on devices and malicious tampering of app code by attackers.

Architecture of the code signature component

The code signature component provides the following functions:

  • Trusted certificate management: imports the device certificate and local code signing certificate and validates the certificate chain and its trusted source.
  • Code signing enabling: provides APIs in user mode to enable code signing of apps or code files during installation.
  • Local code signing: runs the signing service on the device and provides interfaces to sign local code (e.g. native code generated by the AOT).
  • Code attribute setting: provides APIs for setting the code owner ID and initializing the XPM region.

Directory Structure

/base/security/code_signature
├── interfaces                   # Interface layer
│   └── innerkits                #
│       ├── code_sign_attr_utils # APIs for setting code signing attributes
│       ├── code_sign_utils      # APIs for enabling code signing
│       ├── common               # Common basic capacities
│       └── local_code_sign      # APIs for local code signing
├── services                     # Service layer
│    ├── key_enable              # Certificate initialization
│    └── local_code_sign         # Local code signing service
├── test                         # Test cases
│    ├── fuzztest                # Fuzz test cases
│    └── unittest                # Unit test cases
└── utils                        # Common basic capabilities

Usage

Available APIs

API Description
int32_t EnforceCodeSignForApp(const EntryMap &entryPath, const std::string &signatureFile); Enforces code signing for HAPs.
int32_t EnforceCodeSignForApp(const std::string &path, const EntryMap &entryPathMap, FileType type); Enforces code signing for HAPs.
int32_t EnforceCodeSignForFile(const std::string &path, const ByteBuffer &signature); Enforces code signing for files.
int32_t EnforceCodeSignForAppWithOwnerId(std::string ownerId, const std::string &path, const EntryMap &entryPathMap, FileType type); Enforces code signing for HAPs with the owner ID.
int ParseOwnerIdFromSignature(const ByteBuffer &sigbuffer, std::string &ownerID); Parses the owner ID from the signature.
int32_t EnableKeyInProfile(const std::string &bundleName, const ByteBuffer &profileBuffer); Trusts a developer certificate.
int32_t RemoveKeyInProfile(const std::string &bundleName); Revokes a trusted developer certificate.
int32_t InitLocalCertificate(ByteBuffer &cert); Initializes a local code signing certificate.
int32_t SignLocalCode(const std::string &filePath, ByteBuffer &signature); Signs the local code.
int32_t SignLocalCode(const std::string &ownerID, const std::string &filePath, ByteBuffer &signature); Signs the local code with the owner ID.
int InitXpm(int enableJitFort, uint32_t idType, const char *ownerId); Initializes XPM related resources(XPM region, JitFort, OwnerId).
int SetXpmOwnerId(uint32_t idType, const char *ownerId); Sets an owner ID.

Usage Guidelines

hapsigner User Guide

Repositories Involved

developtools_hapsigner

kernel_linux_common_modules

third_party_fsverity-utils