• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025-2025 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     static int GetSigAlg(SignerConfig* signerConfig, std::string& sigAlg);
41 private:
42     int PackagePKCS7(const std::string& content, const std::shared_ptr<Signer>& signer,
43                      const std::string& sigAlg, std::string& ret);
44 };
45 } // namespace SignatureTools
46 } // namespace OHOS
47 #endif // SIGNATRUETOOLS_BC_PKCS7_GENERATOR_GENERATOR_H