1 /* 2 * Copyright (c) 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 #ifndef NAPI_CERT_DEFINES_H 17 #define NAPI_CERT_DEFINES_H 18 19 #include <cstdint> 20 #include <string> 21 22 namespace OHOS { 23 namespace CertFramework { 24 constexpr size_t ARGS_SIZE_ONE = 1; 25 constexpr size_t ARGS_SIZE_TWO = 2; 26 constexpr size_t ARGS_SIZE_THREE = 3; 27 constexpr size_t ARGS_SIZE_FOUR = 4; 28 constexpr int32_t PARAM0 = 0; 29 constexpr int32_t PARAM1 = 1; 30 constexpr int32_t PARAM2 = 2; 31 constexpr uint32_t BYTE_TO_BIT_CNT = 8; 32 constexpr uint32_t QUAD_WORD_ALIGN_UP = 3; 33 34 const std::string CERT_TAG_DATA = "data"; 35 const std::string CERT_TAG_ERR_CODE = "code"; 36 const std::string CERT_TAG_COUNT = "count"; 37 const std::string CERT_TAG_ENCODING_FORMAT = "encodingFormat"; 38 const std::string CERT_TAG_ALGORITHM = "algorithm"; 39 const std::string CRYPTO_TAG_ALG_NAME = "algName"; 40 const std::string CRYPTO_TAG_FORMAT = "format"; 41 42 enum ResultCode { 43 JS_SUCCESS = 0, 44 JS_ERR_CERT_INVALID_PARAMS = 401, 45 JS_ERR_CERT_NOT_SUPPORT = 801, 46 JS_ERR_CERT_OUT_OF_MEMORY = 19020001, 47 JS_ERR_CERT_RUNTIME_ERROR = 19020002, 48 JS_ERR_CERT_CRYPTO_OPERATION = 19030001, 49 JS_ERR_CERT_SIGNATURE_FAILURE = 19030002, 50 JS_ERR_CERT_NOT_YET_VALID = 19030003, 51 JS_ERR_CERT_HAS_EXPIRED = 19030004, 52 JS_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY = 19030005, 53 JS_ERR_KEYUSAGE_NO_CERTSIGN = 19030006, 54 JS_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE = 19030007 55 }; 56 57 enum AsyncType { 58 ASYNC_TYPE_CALLBACK = 1, 59 ASYNC_TYPE_PROMISE = 2 60 }; 61 } // namespace CertFramework 62 } // namespace OHOS 63 64 #endif // NAPI_CERT_DEFINES_H 65