1 Star 0 Fork 48

lihehe/security_code_signature

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

代码签名

简介

代码签名部件用于支持OpenHarmony的代码签名机制。OpenHarmony使用代码签名提供运行时应用程序的完整性保护,校验应用来源的合法性。

代码签名部件架构图

代码签名部件主要提供如下模块功能:

  • 可信证书管理:将设备证书和本地签名证书写入内核.fs-verity keyring,支持证书链及其合法路径校验。
  • 代码签名使能:在用户态提供代码签名校验的相关接口和逻辑,供应用安装的时候调用,为应用和代码文件使能代码签名。
  • 本地代码签名:在设备侧运行签名服务给本地代码提供签名接口,为AOT生成的机器码文件生成代码签名。
  • 代码属性设置:支持代码所有者标记及校验,提供配置XPM验签地址区接口。

目录

/base/security/code_signature
├── interfaces                   # 接口层
│   └── innerkits                #
│       ├── code_sign_attr_utils # 属性设置接口
│       ├── code_sign_utils      # 使能接口
│       ├── common               # 公共基础能力
│       └── local_code_sign      # 本地签名接口
├── services                     # 服务层
│    ├── key_enable              # 证书初始化
│    └── local_code_sign         # 本地签名服务
├── test                         # 测试用例
│    ├── fuzztest                # fuzz测试用例
│    └── unittest                # 单元测试用例
└── utils                        # 公共基础能力

使用

接口说明

接口声明 接口描述
int32_t EnforceCodeSignForApp(const EntryMap &entryPath, const std::string &signatureFile); 对hap使能代码签名
int32_t EnforceCodeSignForApp(const std::string &path, const EntryMap &entryPathMap, FileType type); 对hap使能代码签名
int32_t EnforceCodeSignForFile(const std::string &path, const ByteBuffer &signature); 对文件使能代码签名
int32_t EnforceCodeSignForAppWithOwnerId(std::string ownerId, const std::string &path, const EntryMap &entryPathMap, FileType type); 对hap使能代码签名和OwnerId校验
int ParseOwnerIdFromSignature(const ByteBuffer &sigbuffer, std::string &ownerID); 从签名中解析OwnerId
int32_t EnableKeyInProfile(const std::string &bundleName, const ByteBuffer &profileBuffer); 信任开发者证书
int32_t RemoveKeyInProfile(const std::string &bundleName); 撤销已信任的开发者证书
int32_t InitLocalCertificate(ByteBuffer &cert); 初始化本地签名证书
int32_t SignLocalCode(const std::string &filePath, ByteBuffer &signature); 本地代码签名
int32_t SignLocalCode(const std::string &ownerID, const std::string &filePath, ByteBuffer &signature); 带OwnerId的本地代码签名
int InitXpmRegion(void); 初始化XPM地址
int SetXpmOwnerId(uint32_t idType, const char *ownerId); 设置OwnerId

签名工具使用指南

使用指南

相关仓

developtools_hapsigner

kernel_linux_common_modules

third_party_fsverity-utils

空文件

简介

代码签名部件是OpenHarmony提供的代码签名能力,对应用进行签名保护,校验应用程序来源合法性,保证系统中被加载的代码是可信的。 展开 收起
README
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/hehehe-li/security_code_signature.git
git@gitee.com:hehehe-li/security_code_signature.git
hehehe-li
security_code_signature
security_code_signature
list

搜索帮助