• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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 package com.ohos.hapsigntool.entity;
17 
18 /**
19  * Define const parameters
20  *
21  * @since 2021-12-13
22  */
23 public class ParamConstants {
24     /**
25      * error code of hap format error.
26      */
27     public static final int HAP_FORMAT_ERROR = 20001;
28 
29     /**
30      * error code of hap parse error.
31      */
32     public static final int HAP_PARSE_ERROR = 20002;
33 
34     /**
35      * error code of hap signatures error.
36      */
37     public static final int HAP_SIGNATURE_ERROR = 20003;
38 
39     /**
40      * error code of hap signature block not found error.
41      */
42     public static final int HAP_SIGNATURE_NOT_FOUND_ERROR = 20004;
43 
44     /**
45      * Algorithm name of sha-256.
46      */
47     public static final String HAP_SIG_SCHEME_V256_DIGEST_ALGORITHM = "SHA-256";
48 
49     /**
50      * Algorithm name of sha-384.
51      */
52     public static final String HAP_SIG_SCHEME_V384_DIGEST_ALGORITHM = "SHA-384";
53 
54     /**
55      * Algorithm name of sha-512.
56      */
57     public static final String HAP_SIG_SCHEME_V512_DIGEST_ALGORITHM = "SHA-512";
58 
59     /**
60      * Signature algorithm name of SHA256withECDSA.
61      */
62     public static final String HAP_SIG_ALGORITHM_SHA256_ECDSA = "SHA256withECDSA";
63 
64     /**
65      * Signature algorithm name of SHA384withECDSA.
66      */
67     public static final String HAP_SIG_ALGORITHM_SHA384_ECDSA = "SHA384withECDSA";
68 
69     /**
70      * Signature algorithm name of SHA512withECDSA.
71      */
72     public static final String HAP_SIG_ALGORITHM_SHA512_ECDSA = "SHA512withECDSA";
73 
74     /**
75      * Signature algorithm name of SHA256withRSA.
76      */
77     public static final String HAP_SIG_ALGORITHM_SHA256_RSA = "SHA256withRSA";
78 
79     /**
80      * Signature algorithm name of SHA384withRSA.
81      */
82     public static final String HAP_SIG_ALGORITHM_SHA384_RSA = "SHA384withRSA";
83 
84     /**
85      * Signature algorithm name of SHA256withRSA/PSS.
86      */
87     public static final String HAP_SIG_ALGORITHM_SHA256_RSA_PSS = "SHA256withRSA/PSS";
88 
89     /**
90      * Signature algorithm name of SHA384withRSA/PSS.
91      */
92     public static final String HAP_SIG_ALGORITHM_SHA384_RSA_PSS = "SHA384withRSA/PSS";
93 
94     /**
95      * Signature algorithm name of SHA512withRSA/PSS.
96      */
97     public static final String HAP_SIG_ALGORITHM_SHA512_RSA_PSS = "SHA512withRSA/PSS";
98 
99     /**
100      * Signature algorithm name of SHA256withRSAANDMGF1.
101      */
102     public static final String HAP_SIG_ALGORITHM_SHA256_RSA_MGF1 = "SHA256withRSAANDMGF1";
103 
104     /**
105      * Signature algorithm name of SHA384withRSAANDMGF1.
106      */
107     public static final String HAP_SIG_ALGORITHM_SHA384_RSA_MGF1 = "SHA384withRSAANDMGF1";
108 
109     /**
110      * Signature algorithm name of SHA512withRSAANDMGF1.
111      */
112     public static final String HAP_SIG_ALGORITHM_SHA512_RSA_MGF1 = "SHA512withRSAANDMGF1";
113 
114     /**
115      * Default value of zip-file align
116      */
117     public static final String ALIGNMENT = "4";
118 
119     /**
120      * Signature mode
121      */
122     public static final String PARAM_SIGN_MODE = "mode";
123 
124     /**
125      * Certificate revocation list
126      */
127     public static final String PARAM_BASIC_CRL = "crl";
128 
129     /**
130      * Hap-file's property, stored developer info
131      */
132     public static final String PARAM_BASIC_PROPERTY = "property";
133 
134     /**
135      * Hap-file's capability profile
136      */
137     public static final String PARAM_BASIC_PROFILE = "profileFile";
138 
139     /**
140      * json type content of Hap-file's capability profile
141      */
142     public static final String PARAM_PROFILE_JSON_CONTENT = "profileContent";
143 
144     /**
145      * Hap-file's proof-of-rotation
146      */
147     public static final String PARAM_BASIC_PROOF = "proof";
148 
149     /**
150      * Alignment
151      */
152     public static final String PARAM_BASIC_ALIGNMENT = "a";
153 
154     /**
155      * Private key used in signature
156      */
157     public static final String PARAM_BASIC_PRIVATE_KEY = "keyAlias";
158 
159     /**
160      * Unsigned file
161      */
162     public static final String PARAM_BASIC_INPUT_FILE = "inFile";
163 
164     /**
165      * Signed file
166      */
167     public static final String PARAM_BASIC_OUTPUT_FILE = "outFile";
168 
169     /**
170      * Algorithm name of signature
171      */
172     public static final String PARAM_BASIC_SIGANTURE_ALG = "signAlg";
173 
174     /**
175      * Flag indicates whether profile is signed
176      */
177     public static final String PARAM_BASIC_PROFILE_SIGNED = "profileSigned";
178 
179     /**
180      * The minimum SDK version required for running the application
181      */
182     public static final String PARAM_BASIC_COMPATIBLE_VERSION = "compatibleVersion";
183 
184     /**
185      * Url of signature server
186      */
187     public static final String PARAM_REMOTE_SERVER = "signServer";
188 
189     /**
190      * username used in remote sign mode
191      */
192     public static final String PARAM_REMOTE_USERNAME = "username";
193 
194     /**
195      * password used in remote sign mode
196      */
197     public static final String PARAM_REMOTE_CODE = "password";
198 
199     /**
200      * Local keystore path
201      */
202     public static final String PARAM_LOCAL_JKS_KEYSTORE = "keystoreFile";
203 
204     /**
205      * The password of keystore
206      */
207     public static final String PARAM_LOCAL_JKS_KEYSTORE_CODE = "keystorePwd";
208 
209     /**
210      * The key alias password
211      */
212     public static final String PARAM_LOCAL_JKS_KEYALIAS_CODE = "keyPwd";
213 
214     /**
215      * The certificate file path
216      */
217     public static final String PARAM_LOCAL_PUBLIC_CERT = "appCertFile";
218 
219     /**
220      * The path used to output certificate-chain
221      */
222     public static final String PARAM_VERIFY_CERTCHAIN_FILE = "outCertChain";
223 
224     /**
225      * The path used to output profile
226      */
227     public static final String PARAM_VERIFY_PROFILE_FILE = "outProfile";
228 
229     /**
230      * The path used to output proof-rotation file
231      */
232     public static final String PARAM_VERIFY_PROOF_FILE = "outproof";
233 
234     /**
235      * The path used to output property file
236      */
237     public static final String PARAM_VERIFY_PROPERTY_FILE = "outproperty";
238 
239     /**
240      * The config params of resign hap
241      */
242     public static final String PARAM_RESIGN_CONFIG_FILE = "resignconfig";
243 
244     /**
245      * sign file type bin or zip or elf
246      */
247     public static final String PARAM_IN_FORM = "inForm";
248 
249     /**
250      * The code sign params of resign hap
251      */
252     public static final String PARAM_SIGN_CODE = "signCode";
253 
254     /**
255      * file name split . of min length
256      */
257     public static final int FILE_NAME_MIN_LENGTH = 2;
258 
259     /**
260      * Enumerated value of whether a profile is signed
261      */
262     public enum ProfileSignFlag {
263         DISABLE_SIGN_CODE("0"),
264         ENABLE_SIGN_CODE("1");
265 
266         private String signFlag;
267 
ProfileSignFlag(String signFlag)268         ProfileSignFlag(String signFlag) {
269             this.signFlag = signFlag;
270         }
271 
getSignFlag()272         public String getSignFlag() {
273             return signFlag;
274         }
275     }
276 
277     /**
278      * Enumerated value of whether a code sign is signed.
279      */
280     public enum SignCodeFlag {
281         DISABLE_SIGN_CODE("0"),
282         ENABLE_SIGN_CODE("1");
283 
284         private String signCodeFlag;
285 
SignCodeFlag(String signCodeFlag)286         SignCodeFlag(String signCodeFlag) {
287             this.signCodeFlag = signCodeFlag;
288         }
289 
getSignCodeFlag()290         public String getSignCodeFlag() {
291             return signCodeFlag;
292         }
293     }
294 }