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_BC_PKCS7_GENERATOR_GENERATOR_H 16 #define SIGNATRUETOOLS_BC_PKCS7_GENERATOR_GENERATOR_H 17 18 #include <string> 19 #include <memory> 20 21 #include "pkcs7_generator.h" 22 #include "openssl/x509.h" 23 #include "signer_config.h" 24 #include "signer.h" 25 26 namespace OHOS { 27 namespace SignatureTools { 28 class BCPkcs7Generator : public Pkcs7Generator { 29 public: 30 /** 31 * Generate PKCS#7 signed data with the specific content and signer config. 32 * 33 * @param content PKCS7 data, content of unsigned file digest. 34 * @param signerConfig configurations of signer. 35 * @ret PKCS7 signed data. 36 * @return 0:success <0:error 37 */ 38 virtual ~BCPkcs7Generator(); 39 int GenerateSignedData(const std::string& content, SignerConfig* signerConfig, std::string& ret) override; 40 private: 41 int PackagePKCS7(const std::string& content, const std::shared_ptr<Signer>& signer, 42 const std::string& sigAlg, std::string& ret); 43 }; 44 } // namespace SignatureTools 45 } // namespace OHOS 46 #endif // SIGNATRUETOOLS_BC_PKCS7_GENERATOR_GENERATOR_H