1 /* 2 * Copyright (c) 2024-2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 #ifndef SIGNATRUETOOLS_SIGNTOOLSERVICELMPL_H 16 #define SIGNATRUETOOLS_SIGNTOOLSERVICELMPL_H 17 18 #include "options.h" 19 #include "file_utils.h" 20 #include "cert_tools.h" 21 #include "localization_adapter.h" 22 #include "signature_tools_log.h" 23 #include "service_api.h" 24 25 namespace OHOS { 26 namespace SignatureTools { 27 28 class SignToolServiceImpl : public ServiceApi { 29 public: 30 static int GetProvisionContent(const std::string& input, std::string& ret); 31 32 SignToolServiceImpl() = default; 33 virtual ~SignToolServiceImpl() = default; 34 35 bool GenerateCA(Options* options)override; 36 bool GenerateRootCertToFile(Options* options, EVP_PKEY* rootKey); 37 bool GenerateSubCertToFile(Options* options, EVP_PKEY* rootKey); 38 bool OutputModeOfCert(X509* cert, Options* options); 39 bool GenerateCert(Options* options)override; 40 bool GenerateKeyStore(Options* options)override; 41 bool GenerateCsr(Options* options)override; 42 bool OutputString(std::string content, std::string file); 43 bool GenerateAppCert(Options* option)override; 44 bool GenerateProfileCert(Options* options)override; 45 bool GetAndOutPutCert(LocalizationAdapter& adapter, X509* cert); 46 bool SignProfile(Options* options)override; 47 bool SignHap(Options* options)override; 48 bool VerifyProfile(Options* options)override; 49 bool OutPutCertChain(std::vector<X509*>& certs, const std::string& outPutPath); 50 bool OutPutCert(X509* cert, const std::string& outPutPath); 51 bool PrintX509CertFromMemory(X509* cert); 52 bool PrintX509CertChainFromMemory(std::vector<X509*> certs); 53 bool VerifyHapSigner(Options* option)override; 54 bool X509CertVerify(X509* cert, EVP_PKEY* privateKey); 55 X509_REQ* GetCsr(EVP_PKEY* keyPair, std::string signAlg, std::string subject); 56 int HandleIssuerKeyAliasEmpty(Options* options); 57 int HandleIsserKeyAliasNotEmpty(Options* options); 58 }; 59 } // namespace SignatureTools 60 } // namespace OHOS 61 #endif // SIGNATRUETOOLS_SIGNTOOLSERVICELMPL_H 62