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 16#ifndef SIGNATRUETOOLS_OPTIONS_H 17#define SIGNATRUETOOLS_OPTIONS_H 18 19#include <initializer_list> 20#include <unordered_map> 21#include <variant> 22#include <string> 23 24#include "signature_tools_log.h" 25 26namespace OHOS { 27namespace SignatureTools { 28class Options : public std::unordered_map<std::string, std::variant<std::string, int, bool, char*>> { 29public: 30 Options() = default; 31 ~Options() = default; 32 char* GetChars(const std::string& key); 33 std::string GetString(const std::string& key); 34 std::string GetString(const std::string& key, const std::string& checkStr); 35 int GetInt(const std::string& key); 36 bool Equals(const std::string& argf, const std::string& args); 37 bool Required(const std::initializer_list<std::string>& keys); 38 bool IsEmpty(const std::string& cs); 39 bool GetBool(const std::string& key); 40 41public: 42 /* Key alias parameter name. */ 43 static const std::string KEY_ALIAS; 44 45 /* Key right parameter name. */ 46 static const std::string KEY_RIGHTS; 47 48 /* Key size parameter name(NIST-P-256, NIST-P-384). */ 49 static const std::string KEY_SIZE; 50 51 /* Key alg parameter name(ECC). */ 52 static const std::string KEY_ALG; 53 54 /* Keystore file parameter name. */ 55 static const std::string KEY_STORE_FILE; 56 57 /* Keystore right parameter name. */ 58 static const std::string KEY_STORE_RIGHTS; 59 60 /* Issuer key alias parameter name. */ 61 static const std::string ISSUER_KEY_ALIAS; 62 63 /* Issuer key right parameter name. */ 64 static const std::string ISSUER_KEY_RIGHTS; 65 66 /* Issuer Key Store File parameter name. */ 67 static const std::string ISSUER_KEY_STORE_FILE; 68 69 /* Issuer Key Store Pwd parameter name. */ 70 static const std::string ISSUER_KEY_STORE_RIGHTS; 71 72 /* issuer subject. */ 73 static const std::string ISSUER; 74 75 /* issuer subject. */ 76 static const std::string INFORM; 77 78 /* certificate subject. */ 79 static const std::string SUBJECT; 80 81 /* the validity period of the certificate. */ 82 static const std::string VALIDITY; 83 84 /* signature algorithm. */ 85 static const std::string SIGN_ALG; 86 87 /* length of path. */ 88 static const std::string BASIC_CONSTRAINTS_PATH_LEN; 89 90 /* outfile. */ 91 static const std::string OUT_FILE; 92 93 /* End file type of cert. values in: cert / certChain */ 94 static const std::string OUT_FORM; 95 96 /* Sub cert for sig. */ 97 static const std::string SUB_CA_CERT_FILE; 98 99 /* Ca cert file parameter name. */ 100 static const std::string CA_CERT_FILE; 101 102 /* In file parameter name. */ 103 static const std::string IN_FILE; 104 static const std::string PROFILE_CERT_FILE; 105 static const std::string APP_CERT_FILE; 106 static const std::string KEY_USAGE; 107 static const std::string EXT_KEY_USAGE; 108 static const std::string KEY_USAGE_CRITICAL; 109 static const std::string EXT_KEY_USAGE_CRITICAL; 110 static const std::string BASIC_CONSTRAINTS; 111 static const std::string BASIC_CONSTRAINTS_CRITICAL; 112 static const std::string BASIC_CONSTRAINTS_CA; 113 114 /* Out form includes all forms. */ 115 static const std::string OUT_FORM_SCOPE; 116 static const std::string MODE; 117 static const std::string OUT_CERT_CHAIN; 118 static const std::string OUT_PROFILE; 119 static const std::string PROOF_FILE; 120 static const std::string PROFILE_FILE; 121 static const std::string PROFILE_SIGNED; 122}; 123} // namespace SignatureTools 124} // namespace OHOS 125#endif // SIGNATRUETOOLS_OPTIONS_H 126