• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_SIGNER_CONFIG_H
16 #define SIGNATRUETOOLS_SIGNER_CONFIG_H
17 
18 #include <map>
19 #include <mutex>
20 #include <vector>
21 #include <string>
22 #include <memory>
23 
24 #include "options.h"
25 #include "openssl/x509.h"
26 #include "signature_algorithm_helper.h"
27 #include "signer.h"
28 
29 namespace OHOS {
30 namespace SignatureTools {
31 class SignerConfig {
32 public:
33     SignerConfig();
34     ~SignerConfig();
35     Options* GetOptions() const;
36     void SetOptions(Options* optionsParam);
37     STACK_OF(X509)* GetCertificates() const;
38     void SetCertificates(STACK_OF(X509)* certificatesParam);
39     STACK_OF(X509_CRL)* GetX509CRLs() const;
40     void SetX509CRLs(STACK_OF(X509_CRL)* crls);
41     std::vector<SignatureAlgorithmHelper> GetSignatureAlgorithms() const;
42     void SetSignatureAlgorithms(const std::vector<SignatureAlgorithmHelper>& signatureAlgorithmsParam);
43     const std::map<std::string, std::string>& GetSignParamMap() const;
44     void FillParameters(const std::map<std::string, std::string>& params);
45     std::shared_ptr<Signer> GetSigner();
46     int GetCompatibleVersion() const;
47     void SetCompatibleVersion(int compatibleVersionParam);
48 
49 private:
50     bool IsInputCertChainNotEmpty() const;
51     bool IsInputCrlNotEmpty() const;
52     Options* options;
53     STACK_OF(X509)* certificates;
54     STACK_OF(X509_CRL)* x509CRLs;
55     std::vector<SignatureAlgorithmHelper> signatureAlgorithms;
56     std::map<std::string, std::string> signParamMap;
57     std::shared_ptr<Signer> signer;
58     int compatibleVersion;
59     std::mutex signerMtx;
60 };
61 } // namespace SignatureTools
62 } // namespace OHOS
63 #endif // SIGNATRUETOOLS_SIGNER_CONFIG_H
64