• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 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 NAPI_CRYPTO_FRAMEWORK_DEFINES_H
17 #define NAPI_CRYPTO_FRAMEWORK_DEFINES_H
18 
19 #include <cstdint>
20 
21 namespace OHOS {
22 namespace CryptoFramework {
23 constexpr size_t CALLBACK_SIZE = 1;
24 constexpr size_t ARGS_SIZE_ZERO = 0;
25 constexpr size_t ARGS_SIZE_ONE = 1;
26 constexpr size_t ARGS_SIZE_TWO = 2;
27 constexpr size_t ARGS_SIZE_THREE = 3;
28 constexpr size_t ARGS_SIZE_FOUR = 4;
29 constexpr size_t GCM_AUTH_TAG_LEN = 16;
30 constexpr size_t CCM_AUTH_TAG_LEN = 12;
31 constexpr int32_t PARAM0 = 0;
32 constexpr int32_t PARAM1 = 1;
33 constexpr int32_t PARAM2 = 2;
34 constexpr uint32_t JS_ERR_DEFAULT_ERR = 0;
35 constexpr uint32_t JS_ERR_INVALID_PARAMS = 401;
36 constexpr uint32_t JS_ERR_NOT_SUPPORT = 801;
37 constexpr uint32_t JS_ERR_OUT_OF_MEMORY = 17620001;
38 constexpr uint32_t JS_ERR_RUNTIME_ERROR = 17620002;
39 constexpr uint32_t JS_ERR_CRYPTO_OPERATION = 17630001;
40 
41 constexpr uint32_t JS_ERR_CERT_INVALID_PARAMS = 401;
42 constexpr uint32_t JS_ERR_CERT_NOT_SUPPORT = 801;
43 constexpr uint32_t JS_ERR_CERT_OUT_OF_MEMORY = 19020001;
44 constexpr uint32_t JS_ERR_CERT_RUNTIME_ERROR = 19020002;
45 constexpr uint32_t JS_ERR_CERT_CRYPTO_OPERATION = 19030001;
46 constexpr uint32_t JS_ERR_CERT_SIGNATURE_FAILURE = 19030002;
47 constexpr uint32_t JS_ERR_CERT_NOT_YET_VALID = 19030003;
48 constexpr uint32_t JS_ERR_CERT_HAS_EXPIRED = 19030004;
49 constexpr uint32_t JS_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 19030005;
50 constexpr uint32_t JS_ERR_KEYUSAGE_NO_CERTSIGN = 19030006;
51 constexpr uint32_t JS_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE = 19030007;
52 
53 const std::string CRYPTO_TAG_DATA = "data";
54 const std::string CRYPTO_TAG_ERR_CODE = "code";
55 const std::string CRYPTO_TAG_ERR_MSG = "message";
56 const std::string CRYPTO_TAG_COUNT = "count";
57 const std::string CRYPTO_TAG_ENCODING_FORMAT = "encodingFormat";
58 const std::string CRYPTO_TAG_ALGORITHM = "algorithm";
59 const std::string CRYPTO_TAG_ALG_NAME = "algName";
60 const std::string CRYPTO_TAG_FORMAT = "format";
61 const std::string CRYPTO_TAG_PUB_KEY = "pubKey";
62 const std::string CRYPTO_TAG_PRI_KEY = "priKey";
63 const std::string IV_PARAMS = "iv";
64 const std::string AAD_PARAMS = "aad";
65 const std::string AUTHTAG_PARAMS = "authTag";
66 const std::string ALGO_PARAMS = "algName";
67 const std::string ALGO_PARAMS_OLD = "algoName";
68 const std::string IV_PARAMS_SPEC = "IvParamsSpec";
69 const std::string GCM_PARAMS_SPEC = "GcmParamsSpec";
70 const std::string CCM_PARAMS_SPEC = "CcmParamsSpec";
71 const std::string COMMON_ERR_MSG = "An exception occurs.";
72 
73 enum CfAsyncType {
74     ASYNC_TYPE_CALLBACK = 1,
75     ASYNC_TYPE_PROMISE = 2
76 };
77 } // namespace CryptoFramework
78 } // namespace OHOS
79 
80 #endif // NAPI_CRYPTO_FRAMEWORK_DEFINES_H
81