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 16 #ifndef SIGNATRUETOOLS_CONSTANT_H 17 #define SIGNATRUETOOLS_CONSTANT_H 18 19 #include <stdint.h> 20 #include <string> 21 22 namespace OHOS { 23 namespace SignatureTools { 24 const char APP_SIGNING_CAPABILITY[] = {0x30, 0x06, 0x02, 0x01, 0x01, 0x0A, 0x01, 0x00}; 25 const char PROFILE_SIGNING_CAPABILITY[] = {0x30, 0x06, 0x02, 0x01, 0x01, 0x0A, 0x01, 0x01}; 26 27 constexpr long DEFAULT_START_VALIDITY = 0; 28 constexpr long ONE_DAY_TIME = 86400; 29 constexpr long DEFAULT_CERT_VERSION = 2; 30 31 constexpr int NIST_P_256 = 256; 32 constexpr int NIST_P_384 = 384; 33 constexpr int DEFAULT_VALIDITY_DAYS = 3650; 34 constexpr int INVALIDCHAR = 3; 35 constexpr int DEFAULT_BASIC_CONSTRAINTS_PATH_LEN = 0; 36 constexpr int RANDOM_SERIAL_NUMBER_LENGTH = 32; 37 constexpr int DEFAULT_CUSTOM_VALIDITY_DAYS = 1095; 38 39 const bool DEFAULT_KEY_USAGE_CRITICAL = true; 40 const bool DEFAULT_EXT_KEY_USAGE_CRITICAL = false; 41 const bool DEFAULT_BASIC_CONSTRAINTS = false; 42 const bool DEFAULT_BASIC_CONSTRAINTS_CRITICAL = false; 43 const bool DEFAULT_BASIC_CONSTRAINTS_CA = false; 44 45 const std::string SIGN_ALG_SHA256 = "SHA256withECDSA"; 46 const std::string SIGN_ALG_SHA384 = "SHA384withECDSA"; 47 const std::string DEFAULT_BASIC_EXTENSION = "critical,CA:FALSE"; 48 const std::string DEFAULT_KEYUSAGE_EXTENSION = "digitalSignature"; 49 const std::string DEFAULT_EXTEND_KEYUSAGE = "codeSigning"; 50 const std::string NID_BASIC_CONST = "basicConstraints"; 51 const std::string NID_KEYUSAGE_CONST = "keyUsage"; 52 const std::string NID_EXT_KEYUSAGE_CONST = "extendedKeyUsage"; 53 const std::string PKCS7_EXT_SIGNATURE_OID = "1.2.840.113549.1.1.10"; 54 const std::string X509_EXT_OID = "1.3.6.1.4.1.2011.2.376.1.3"; 55 const std::string OWNERID_OID = "1.3.6.1.4.1.2011.2.376.1.4.1"; // SIGNED_ID 56 const std::string OWNERID_OID_SHORT_NAME = "ownerID"; 57 const std::string OWNERID_OID_LONG_NAME = "Code Signature Owner ID"; 58 const std::string DEFAULT_PROFILE_SIGNED_1 = "1"; 59 const std::string DEFAULT_PROFILE_SIGNED_0 = "0"; 60 const std::string ZIP = "zip"; 61 const std::string ELF = "elf"; 62 const std::string BIN = "bin"; 63 const std::string OUT_FORM_CERT = "cert"; 64 const std::string OUT_FORM_CERT_CHAIN = "certChain"; 65 const std::string DEBUG_STR = "debug"; 66 const std::string DEBUG_LIB_ID = "DEBUG_LIB_ID"; 67 const std::string REMOTE_SIGN = "remoteSign"; 68 const std::string LOCAL_SIGN = "localSign"; 69 70 // Corresponding to each functional module 71 const std::string GENERATE_KEYPAIR = "generate-keypair"; 72 const std::string GENERATE_CSR = "generate-csr"; 73 const std::string GENERATE_CA = "generate-ca"; 74 const std::string GENERATE_CERT = "generate-cert"; 75 const std::string GENERATE_APP_CERT = "generate-app-cert"; 76 const std::string GENERATE_PROFILE_CERT = "generate-profile-cert"; 77 const std::string SIGN_ELF = "sign"; 78 const std::string VERIFY_ELF = "display-sign"; 79 const std::string SIGN_PROFILE = "sign-profile"; 80 const std::string VERIFY_APP = "verify-app"; 81 const std::string VERIFY_PROFILE = "verify-profile"; 82 83 constexpr int32_t ONE_DAY_HOUR = 24; 84 constexpr int32_t ONE_DAY_MINUTE = 60; 85 constexpr int32_t ONE_DAY_SECOND = 60; 86 87 static constexpr int YEAR1900 = 1900; 88 static constexpr int MIN_CERTS_NUM = 2; 89 static constexpr int MAX_CERTS_NUM = 3; 90 } // namespace UpdateEngine 91 } // namespace OHOS 92 #endif // SIGNATRUETOOLS_CONSTANT_H