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_PROFILESIGNTOOOL_H 16 #define SIGNATRUETOOLS_PROFILESIGNTOOOL_H 17 18 #include <memory> 19 #include <string> 20 21 #include "openssl/pkcs7.h" 22 #include "openssl/err.h" 23 #include "openssl/x509.h" 24 #include "signer.h" 25 #include "localization_adapter.h" 26 #include "pkcs7_data.h" 27 28 namespace OHOS { 29 namespace SignatureTools { 30 /** 31 * To sign and verify profile. 32 * 33 * @since 2021/12/28 34 */ 35 class ProfileSignTool { 36 public: 37 /** 38 * generateP7b. 39 * 40 * @param adapter local adapter with params 41 * @param content content to sign 42 * @param ret signed content 43 * @return 0:success <0:error 44 */ 45 static int GenerateP7b(LocalizationAdapter& adapter, const std::string& content, std::string& ret); 46 /** 47 * signProfile. 48 * 49 * @param content content to sign 50 * @param signer signer 51 * @param sigAlg sign algorithm only SHAwith256 or SHAwith384 52 * @ret signed data 53 * @return 0:success <0:error 54 */ 55 static int SignProfile(const std::string& content, 56 const std::shared_ptr<Signer>& signer, const std::string& sigAlg, std::string& ret); 57 }; 58 } // namespace SignatureTools 59 } // namespace OHOS 60 #endif // SIGNATRUETOOLS_PROFILESIGNTOOOL_H