diff --git a/README.md b/README.md index 00419fdc8a9ce2b0908085a63153245b7c908111..341e944a82184ba4044ae48a5543a5296dfc2f16 100644 --- a/README.md +++ b/README.md @@ -2,49 +2,64 @@ ## Introduction -Code signature is a security mechanism on OpenHarmony to protect integrity of the application and verify the validity of the application source on runtime. +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. -The code signature component provides the following features: +Architecture of the code signature component -- Writing trusted code signing certificates into the kernel -- Enabling code signing for applicaitons -- Signing local code +![](figures/codesign_en.png) + +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 # APIs +├── 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 signing +│ └── local_code_sign # APIs for local code signing ├── services # Service layer │ ├── key_enable # Certificate initialization -│ └── local_code_sign # Local signing service +│ └── local_code_sign # Local code signing service ├── test # Test cases │ ├── fuzztest # Fuzz test cases │ └── unittest # Unit test cases -└── utils # Common basic capacities +└── utils # Common basic capabilities ``` ## Usage ### Available APIs -| **API** | **Description** | +| **API**| **Description**| | --- | --- | -| int32_t EnforceCodeSignForApp(const EntryMap &entryPath, const std::string &signatureFile); | Enforces code signing for an hap | -| int32_t EnforceCodeSignForFile(const std::string &path, const ByteBuffer &signature); | Enforces code signing for an file | -| int32_t SignLocalCode(const std::string &filePath, ByteBuffer &signature); | Signs the local code | +| 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 InitXpmRegion(void); | Initializes the XPM region.| +| int SetXpmOwnerId(uint32_t idType, const char *ownerId); | Sets an owner ID.| -### Signing Tool User Guide +### Usage Guidelines -**[User Guide](https://gitee.com/openharmony/developtools_hapsigner/blob/master/codesigntool/README.md)** - -## 相关仓 +[hapsigner User Guide](https://gitee.com/openharmony/developtools_hapsigner/blob/master/README.md) ## Repositories Involved -**[developtools\_hapsigner](https://gitee.com/openharmony/developtools_hapsigner/blob/master/codesigntool/README.md)** +**[developtools\_hapsigner](https://gitee.com/openharmony/developtools_hapsigner/blob/master/README.md)** + +**[kernel_linux_common_modules](https://gitee.com/openharmony/kernel_linux_common_modules)** **[third\_party\_fsverity-utils](https://gitee.com/openharmony/third_party_fsverity-utils/blob/master/README.md)** diff --git a/figures/codesign_en.png b/figures/codesign_en.png new file mode 100644 index 0000000000000000000000000000000000000000..d4be3e0b458df4c263f12eccf89a28f40fc2f78a Binary files /dev/null and b/figures/codesign_en.png differ