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