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